From ad28d9bf2087a9128de0b0d0b9727c4c888f8ea6 Mon Sep 17 00:00:00 2001 From: Harrison Deng Date: Wed, 8 Jan 2025 16:31:06 +0000 Subject: [PATCH] Added additional test for fully automatic typing based on sequence --- src/automlst/cli/aggregated.py | 2 +- src/automlst/engine/data/{MLST.py => mlst.py} | 0 src/automlst/engine/local/csv.py | 2 +- .../{mlstprofiler.py => mlst.py} | 2 +- src/automlst/engine/remote/databases/mlst.py | 2 +- .../pubmlst/{mlstprofiler.py => mlst.py} | 2 +- .../{test_profiling.py => test_mlst.py} | 22 +++++++++++++++++-- 7 files changed, 25 insertions(+), 7 deletions(-) rename src/automlst/engine/data/{MLST.py => mlst.py} (100%) rename src/automlst/engine/remote/databases/institutpasteur/{mlstprofiler.py => mlst.py} (98%) rename src/automlst/engine/remote/databases/pubmlst/{mlstprofiler.py => mlst.py} (98%) rename tests/nsbdiagnosistoolkit/engine/remote/databases/institutpasteur/{test_profiling.py => test_mlst.py} (66%) diff --git a/src/automlst/cli/aggregated.py b/src/automlst/cli/aggregated.py index e674956..4cb8207 100644 --- a/src/automlst/cli/aggregated.py +++ b/src/automlst/cli/aggregated.py @@ -1,6 +1,6 @@ from os import path from typing import Any, AsyncGenerator, AsyncIterable, Iterable, Sequence -from automlst.engine.data.MLST import MLSTProfile +from automlst.engine.data.mlst import MLSTProfile from automlst.engine.data.genomics import NamedString from automlst.engine.local.abif import read_abif from automlst.engine.local.fasta import read_fasta diff --git a/src/automlst/engine/data/MLST.py b/src/automlst/engine/data/mlst.py similarity index 100% rename from src/automlst/engine/data/MLST.py rename to src/automlst/engine/data/mlst.py diff --git a/src/automlst/engine/local/csv.py b/src/automlst/engine/local/csv.py index 20e2232..4d47e25 100644 --- a/src/automlst/engine/local/csv.py +++ b/src/automlst/engine/local/csv.py @@ -3,7 +3,7 @@ from io import TextIOWrapper from os import PathLike from typing import AsyncIterable, Iterable, Mapping, Sequence, Union -from automlst.engine.data.MLST import Allele, MLSTProfile +from automlst.engine.data.mlst import Allele, MLSTProfile def loci_alleles_variants_from_loci(alleles_map: Mapping[str, Sequence[Allele]]): diff --git a/src/automlst/engine/remote/databases/institutpasteur/mlstprofiler.py b/src/automlst/engine/remote/databases/institutpasteur/mlst.py similarity index 98% rename from src/automlst/engine/remote/databases/institutpasteur/mlstprofiler.py rename to src/automlst/engine/remote/databases/institutpasteur/mlst.py index 0f74c3a..b990e51 100644 --- a/src/automlst/engine/remote/databases/institutpasteur/mlstprofiler.py +++ b/src/automlst/engine/remote/databases/institutpasteur/mlst.py @@ -3,7 +3,7 @@ from contextlib import AbstractAsyncContextManager import re from typing import Any, AsyncGenerator, AsyncIterable, Generator, Iterable, Sequence, Union from aiohttp import ClientSession, ClientTimeout -from automlst.engine.data.MLST import Allele, MLSTProfile +from automlst.engine.data.mlst import Allele, MLSTProfile from automlst.engine.data.genomics import NamedString class InstitutPasteurProfiler(AbstractAsyncContextManager): diff --git a/src/automlst/engine/remote/databases/mlst.py b/src/automlst/engine/remote/databases/mlst.py index b7b8b1e..ed93da2 100644 --- a/src/automlst/engine/remote/databases/mlst.py +++ b/src/automlst/engine/remote/databases/mlst.py @@ -4,7 +4,7 @@ from typing import AsyncGenerator, AsyncIterable, Generator, Iterable, Mapping, from aiohttp import ClientSession -from automlst.engine.data.MLST import Allele, MLSTProfile +from automlst.engine.data.mlst import Allele, MLSTProfile MLST_DATABASES = [ "https://bigsdb.pasteur.fr/api/db", diff --git a/src/automlst/engine/remote/databases/pubmlst/mlstprofiler.py b/src/automlst/engine/remote/databases/pubmlst/mlst.py similarity index 98% rename from src/automlst/engine/remote/databases/pubmlst/mlstprofiler.py rename to src/automlst/engine/remote/databases/pubmlst/mlst.py index 2b586f2..00bf8f1 100644 --- a/src/automlst/engine/remote/databases/pubmlst/mlstprofiler.py +++ b/src/automlst/engine/remote/databases/pubmlst/mlst.py @@ -3,7 +3,7 @@ from contextlib import AbstractAsyncContextManager import re from typing import Any, AsyncGenerator, AsyncIterable, Generator, Iterable, Mapping, Sequence, Union from aiohttp import ClientSession, ClientTimeout -from automlst.engine.data.MLST import Allele, MLSTProfile +from automlst.engine.data.mlst import Allele, MLSTProfile from automlst.engine.data.genomics import NamedString from automlst.engine.remote.databases.mlst import MLSTProfiler diff --git a/tests/nsbdiagnosistoolkit/engine/remote/databases/institutpasteur/test_profiling.py b/tests/nsbdiagnosistoolkit/engine/remote/databases/institutpasteur/test_mlst.py similarity index 66% rename from tests/nsbdiagnosistoolkit/engine/remote/databases/institutpasteur/test_profiling.py rename to tests/nsbdiagnosistoolkit/engine/remote/databases/institutpasteur/test_mlst.py index 3bac78a..45dfba5 100644 --- a/tests/nsbdiagnosistoolkit/engine/remote/databases/institutpasteur/test_profiling.py +++ b/tests/nsbdiagnosistoolkit/engine/remote/databases/institutpasteur/test_mlst.py @@ -1,5 +1,5 @@ from Bio import SeqIO -from automlst.engine.data.MLST import Allele, MLSTProfile +from automlst.engine.data.mlst import Allele, MLSTProfile from automlst.engine.remote.databases.institutpasteur.mlst import InstitutPasteurProfiler @@ -32,4 +32,22 @@ async def test_profiling_results_in_correct_st(): assert mlst_st_data is not None assert isinstance(mlst_st_data, MLSTProfile) assert mlst_st_data.clonal_complex == "ST-2 complex" - assert mlst_st_data.sequence_type == "1" \ No newline at end of file + assert mlst_st_data.sequence_type == "1" + +async def test_sequence_profiling_is_correct(): + sequence = str(SeqIO.read("tests/resources/tohama_I_bpertussis.fasta", "fasta").seq) + dummy_alleles = [ + Allele("adk", "1"), + Allele("fumC", "1"), + Allele("glyA", "1"), + Allele("tyrB", "1"), + Allele("icd", "1"), + Allele("pepA", "1"), + Allele("pgm", "1"), + ] + async with InstitutPasteurProfiler(database_name="pubmlst_bordetella_seqdef") as dummy_profiler: + profile = await dummy_profiler.profile_string(sequence) + assert profile is not None + assert isinstance(profile, MLSTProfile) + assert profile.clonal_complex == "ST-2 complex" + assert profile.sequence_type == "1" \ No newline at end of file