Skip to content

Commit

Permalink
Adjust tests for vsearch
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulthran committed Aug 6, 2024
1 parent a538faa commit b7ceab8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 40 deletions.
43 changes: 7 additions & 36 deletions .tests/e2e/test_full_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,15 @@
@pytest.fixture
def setup(tmpdir):
reads_fp = Path(".tests/data/reads/").resolve()
hosts_fp = Path(".tests/data/hosts/").resolve()
db_fp = Path(".tests/data/db/").resolve()
db_fp = Path(".tests/data/ref/").resolve()

project_dir = tmpdir / "project"

sp.check_output(["sunbeam", "init", "--data_fp", reads_fp, project_dir])

config_fp = project_dir / "sunbeam_config.yml"

config_str = f"sbx_kraken: {{kraken_db_fp: {db_fp}}}"
sp.check_output(
[
"sunbeam",
"config",
"modify",
"-i",
"-s",
f"{config_str}",
f"{config_fp}",
]
)

config_str = f"qc: {{host_fp: {hosts_fp}}}"
config_str = f"sbx_vsearch: {{db_fp: {db_fp}}}"
sp.check_output(
[
"sunbeam",
Expand Down Expand Up @@ -63,7 +49,7 @@ def run_sunbeam(setup):
"conda",
"--profile",
project_dir,
"all_classify",
"all_vsearch",
"--directory",
tmpdir,
]
Expand All @@ -84,24 +70,9 @@ def run_sunbeam(setup):
def test_full_run(run_sunbeam):
output_fp, benchmarks_fp = run_sunbeam

all_samples_fp = output_fp / "classify" / "kraken" / "all_samples.tsv"
long_report_fp = output_fp / "mapping" / "vsearch" / "LONG_report.tsv"
long_fasta_fp = output_fp / "mapping" / "vsearch" / "LONG.fasta"

# Check output
assert all_samples_fp.exists()

with open(all_samples_fp) as f:
header_line = f.readline()
print(f"Header line: {header_line}")
assert "TEST-taxa" in header_line
assert "EMPTY-taxa" in header_line
assert "Consensus Lineage" in header_line
test_index = header_line.split("\t").index("TEST-taxa")
empty_index = header_line.split("\t").index("EMPTY-taxa")

lines = f.readlines()
print(lines)
for line in lines:
if line[0] == "2":
fields = line.split("\t")
assert int(fields[empty_index]) == 0
assert int(fields[test_index]) > 0
assert long_report_fp.exists()
assert long_fasta_fp.exists()
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
# sbx_vsearch

<!-- badges: start -->

[![Tests](https://github.com/sunbeam-labs/sbx_vsearch/actions/workflows/pr.yml/badge.svg)](https://github.com/sunbeam-labs/sbx_vsearch/actions/workflows/pr.yml)
[![Release](https://img.shields.io/github/release/sunbeam-labs/sbx_vsearch.svg?style=flat)](https://github.com/sunbeam-labs/sbx_vsearch/releases/latest)
[![DockerHub](https://img.shields.io/docker/pulls/sunbeamlabs/sbx_vsearch)](https://hub.docker.com/repository/docker/sunbeamlabs/sbx_vsearch/)
<!-- badges: end -->

A [Sunbeam](https://github.com/sunbeam-labs/sunbeam) extension for using [Vsearch](https://github.com/torognes/vsearch) with the `--usearch-global` option to do alignment of reads to any fasta file.
Expand All @@ -27,7 +29,7 @@ N.B. For sunbeam versions <4 the last command will be something like `sunbeam ru

## Configuration

- db: Is the filepath to a directory containing reference fasta files
- db_fp: Is the filepath to a directory containing reference fasta files
- threads: Is the number of threads to use while running vsearch
- min_id: Is the minimum identity for query-target match
- weak_id: Is the set lower than min-id and you will get some weaker matches too
Expand Down
2 changes: 1 addition & 1 deletion config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sbx_vsearch:
db: ""
db_fp: ""
threads: 4
min_id: 0.85 #minimum identity for query-target match
weak_id: 0.85 #set lower than min-id and you will get some weaker matches too
Expand Down
2 changes: 1 addition & 1 deletion sbx_vsearch.smk
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ rule fq_2_fa:
rule run_vsearch:
input:
query=str(MAPPING_FP / "R1" / "{sample}_1.fasta"),
db=str(Cfg["sbx_vsearch"]["db"]),
db=str(Cfg["sbx_vsearch"]["db_fp"]),
output:
reports=str(MAPPING_FP / "vsearch" / "{sample}_report.tsv"),
alignments=str(MAPPING_FP / "vsearch" / "{sample}.fasta"),
Expand Down

0 comments on commit b7ceab8

Please sign in to comment.