-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from BIONF/dev
fix cli
- Loading branch information
Showing
3 changed files
with
68 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,12 +59,16 @@ def classify(genus, path, meta, step): | |
|
||
# define pipeline | ||
pipeline = Pipeline(genus + " classification", "Test Author", "[email protected]") | ||
species_execution = ModelExecution(genus + "-species", sparse_sampling_step=step) | ||
species_execution = ModelExecution( | ||
genus.lower() + "-species", sparse_sampling_step=step | ||
) | ||
if meta: | ||
species_filtering_step = PipelineStep( | ||
StepType.FILTERING, genus, 0.7, species_execution | ||
) | ||
genus_execution = ModelExecution(genus + "-genus", sparse_sampling_step=step) | ||
genus_execution = ModelExecution( | ||
genus.lower() + "-genus", sparse_sampling_step=step | ||
) | ||
genus_execution.add_pipeline_step(species_filtering_step) | ||
pipeline.add_pipeline_step(genus_execution) | ||
else: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
"""Test XspecT CLI""" | ||
|
||
import json | ||
import pytest | ||
from click.testing import CliRunner | ||
from src.xspect.main import cli | ||
|
||
|
||
@pytest.mark.parametrize( | ||
["assembly_file_path", "genus", "species"], | ||
[ | ||
( | ||
"GCF_000069245.1_ASM6924v1_genomic.fna", | ||
"Acinetobacter", | ||
"470", | ||
), | ||
( | ||
"GCF_000018445.1_ASM1844v1_genomic.fna", | ||
"Acinetobacter", | ||
"470", | ||
), | ||
("GCF_000006945.2_ASM694v2_genomic.fna", "Salmonella", "28901"), | ||
], | ||
indirect=["assembly_file_path"], | ||
) | ||
def test_species_assignment(assembly_file_path, genus, species): | ||
"""Test the species assignment""" | ||
runner = CliRunner() | ||
result = runner.invoke(cli, ["classify", genus, assembly_file_path]) | ||
|
||
run_path = result.output.strip().split("'")[1] | ||
with open(run_path, encoding="utf-8") as f: | ||
result_content = json.load(f) | ||
assert result_content["results"][0]["prediction"] == species | ||
|
||
|
||
@pytest.mark.parametrize( | ||
["assembly_file_path", "genus", "species"], | ||
[ | ||
( | ||
"GCF_000069245.1_ASM6924v1_genomic.fna", | ||
"Acinetobacter", | ||
"470", | ||
), | ||
], | ||
indirect=["assembly_file_path"], | ||
) | ||
def test_metagenome_mode(assembly_file_path, genus, species): | ||
"""Test the metagenome mode""" | ||
runner = CliRunner() | ||
result = runner.invoke(cli, ["classify", "-m", genus, assembly_file_path]) | ||
|
||
run_path = result.output.strip().split("'")[1] | ||
with open(run_path, encoding="utf-8") as f: | ||
result_content = json.load(f) | ||
assert ( | ||
result_content["results"][0]["subprocessing_steps"][0]["result"][ | ||
"prediction" | ||
] | ||
== species | ||
) |