diff --git a/cool_seq_tool/app.py b/cool_seq_tool/app.py index fe7fabb0..06749f7b 100644 --- a/cool_seq_tool/app.py +++ b/cool_seq_tool/app.py @@ -53,5 +53,5 @@ def __init__( self.mane_transcript = MANETranscript( self.seqrepo_access, self.transcript_mappings, self.mane_transcript_mappings, self.uta_db) - self.exon_genomic_coords_mapper = ExonGenomicCoordsMapper(self.uta_db, - self.mane_transcript) + self.ex_g_coords_mapper = ExonGenomicCoordsMapper(self.uta_db, + self.mane_transcript) diff --git a/cool_seq_tool/handlers/seqrepo_access.py b/cool_seq_tool/handlers/seqrepo_access.py index af73d151..64c6eec2 100644 --- a/cool_seq_tool/handlers/seqrepo_access.py +++ b/cool_seq_tool/handlers/seqrepo_access.py @@ -20,17 +20,16 @@ class SeqRepoAccess(SeqRepoDataProxy): def get_reference_sequence( self, ac: str, start: Optional[int] = None, end: Optional[int] = None, - residue_mode: str = ResidueMode.RESIDUE + residue_mode: ResidueMode = ResidueMode.RESIDUE ) -> Tuple[str, Optional[str]]: """Get reference sequence for an accession given a start and end position. If `start` and `end` are not given, it will return the entire reference sequence - :param str ac: Accession - :param Optional[int] start: Start pos change - :param Optional[int] end: End pos change. If `None` assumes both - `start` and `end` have same values, if `start` exists. - :param str residue_mode: Residue mode for start/end positions - Must be either `inter-residue` or `residue` + :param ac: Accession + :param start: Start pos change + :param end: End pos change. If `None` assumes both `start` and `end` have same + values, if `start` exists. + :param residue_mode: Residue mode for `start` and `end` :return: Sequence at position (if accession and positions actually exist, else return empty string), warning if any """ diff --git a/cool_seq_tool/mappers/exon_genomic_coords.py b/cool_seq_tool/mappers/exon_genomic_coords.py index f0980b10..b1ed54aa 100644 --- a/cool_seq_tool/mappers/exon_genomic_coords.py +++ b/cool_seq_tool/mappers/exon_genomic_coords.py @@ -354,7 +354,7 @@ def _get_gene_and_alt_ac( async def _set_mane_genomic_data( self, params: Dict, gene: str, alt_ac: str, pos: int, strand: int, - is_start: bool, residue_mode: str + is_start: bool, residue_mode: ResidueMode ) -> Optional[str]: """Set genomic data in `params` found from MANE. @@ -365,8 +365,7 @@ async def _set_mane_genomic_data( :param strand: Strand :param is_start: `True` if `pos` is start position. `False` if `pos` is end position. - :param residue_mode: Residue mode for start/end positions. Must be either - `inter-residue` or `residue` + :param residue_mode: Residue mode for `pos` :return: Warnings if found """ mane_data = await self.mane_transcript.get_mane_transcript( diff --git a/cool_seq_tool/mappers/mane_transcript.py b/cool_seq_tool/mappers/mane_transcript.py index 04520027..47804691 100644 --- a/cool_seq_tool/mappers/mane_transcript.py +++ b/cool_seq_tool/mappers/mane_transcript.py @@ -338,18 +338,18 @@ def _validate_reading_frames(self, ac: str, start_pos: int, end_pos: int, def _validate_references(self, ac: str, coding_start_site: int, start_pos: int, end_pos: int, mane_transcript: Dict, expected_ref: str, - anno: AnnotationLayer, residue_mode: str) -> bool: + anno: AnnotationLayer, residue_mode: ResidueMode) -> bool: """Return whether or not reference changes are the same. - :param str ac: Query accession - :param int coding_start_site: ac's coding start site - :param int start_pos: Original start position change - :param int end_pos: Origin end position change - :param Dict mane_transcript: Ensembl and RefSeq transcripts with - corresponding position change - :param str expected_ref: Reference at position given during input - :param AnnotationLayer anno: Annotation layer we are starting from - :param ResidueMode residue_mode: Residue mode + :param ac: Query accession + :param coding_start_site: ac's coding start site + :param start_pos: Original start position change + :param end_pos: Origin end position change + :param mane_transcript: Ensembl and RefSeq transcripts with corresponding + position change + :param expected_ref: Reference at position given during input + :param anno: Annotation layer we are starting from + :param residue_mode: Residue mode for `start_pos` and `end_pos` :return: `True` if reference check passes. `False` otherwise. """ if anno == AnnotationLayer.CDNA: @@ -432,7 +432,7 @@ def _get_prioritized_transcripts_from_gene(self, async def get_longest_compatible_transcript( self, gene: str, start_pos: int, end_pos: int, start_annotation_layer: AnnotationLayer, ref: Optional[str] = None, - residue_mode: str = ResidueMode.RESIDUE, + residue_mode: ResidueMode = ResidueMode.RESIDUE, mane_transcripts: Optional[Set] = None, alt_ac: Optional[str] = None ) -> Optional[Dict]: @@ -440,15 +440,14 @@ async def get_longest_compatible_transcript( Try GRCh38 first, then GRCh37. Transcript is compatible if it passes validation checks. - :param str gene: Gene symbol - :param int start_pos: Start position change - :param int end_pos: End position change - :param AnnotationLayer start_annotation_layer: Starting annotation layer. - :param str ref: Reference at position given during input - :param str residue_mode: Residue mode - :param Optional[Set] mane_transcripts: Attempted mane transcripts that were not - compatible - :param Optional[str] alt_ac: Genomic accession + :param gene: Gene symbol + :param start_pos: Start position change + :param end_pos: End position change + :param start_annotation_layer: Starting annotation layer. + :param ref: Reference at position given during input + :param residue_mode: Residue mode for `start_pos` and `end_pos` + :param mane_transcripts: Attempted mane transcripts that were not compatible + :param alt_ac: Genomic accession :return: Data for longest compatible transcript """ inter_residue_pos, _ = get_inter_residue_pos( diff --git a/cool_seq_tool/routers/__init__.py b/cool_seq_tool/routers/__init__.py index ec2cc781..bafbb9d3 100644 --- a/cool_seq_tool/routers/__init__.py +++ b/cool_seq_tool/routers/__init__.py @@ -1,7 +1,7 @@ """Module for routers""" from enum import Enum -from cool_seq_tool import CoolSeqTool +from cool_seq_tool.app import CoolSeqTool cool_seq_tool = CoolSeqTool() diff --git a/cool_seq_tool/routers/default.py b/cool_seq_tool/routers/default.py index 63d63ab3..6d42ad37 100644 --- a/cool_seq_tool/routers/default.py +++ b/cool_seq_tool/routers/default.py @@ -14,6 +14,7 @@ UNHANDLED_EXCEPTION_MSG from cool_seq_tool.schemas import GenomicDataResponse, GenomicRequestBody, \ TranscriptRequestBody +from cool_seq_tool.utils import service_meta logger = logging.getLogger("cool_seq_tool") @@ -40,11 +41,11 @@ async def genomic_to_transcript_exon_coordinates( request_body = request_body.model_dump() response = GenomicDataResponse( - genomic_data=None, warnings=list(), service_meta=cool_seq_tool.service_meta()) + genomic_data=None, warnings=list(), service_meta=service_meta()) try: response = \ - await cool_seq_tool.genomic_to_transcript_exon_coordinates(**request_body) + await cool_seq_tool.ex_g_coords_mapper.genomic_to_transcript_exon_coordinates(**request_body) # noqa: E501 except Exception as e: logger.error(f"genomic_to_transcript_exon_coordinates unhandled exception {str(e)}") # noqa: E501 response.warnings.append(UNHANDLED_EXCEPTION_MSG) @@ -71,10 +72,10 @@ async def transcript_to_genomic_coordinates( request_body = request_body.model_dump() response = GenomicDataResponse( - genomic_data=None, warnings=list(), service_meta=cool_seq_tool.service_meta()) + genomic_data=None, warnings=list(), service_meta=service_meta()) try: - response = await cool_seq_tool.transcript_to_genomic_coordinates(**request_body) + response = await cool_seq_tool.ex_g_coords_mapper.transcript_to_genomic_coordinates(**request_body) # noqa: E501 except Exception as e: logger.error(f"transcript_to_genomic_coordinates unhandled exception {str(e)}") response.warnings.append(UNHANDLED_EXCEPTION_MSG) @@ -105,7 +106,7 @@ async def get_sequence( """ _, path = tempfile.mkstemp(suffix=".fasta") try: - cool_seq_tool.get_fasta_file(sequence_id, Path(path)) + cool_seq_tool.seqrepo_access.get_fasta_file(sequence_id, Path(path)) except KeyError: raise HTTPException( status_code=404, diff --git a/cool_seq_tool/routers/mane.py b/cool_seq_tool/routers/mane.py index ed1ef6f6..73476aef 100644 --- a/cool_seq_tool/routers/mane.py +++ b/cool_seq_tool/routers/mane.py @@ -8,6 +8,7 @@ from cool_seq_tool.routers import cool_seq_tool, SERVICE_NAME, RESP_DESCR, \ UNHANDLED_EXCEPTION_MSG, Tags from cool_seq_tool.schemas import AnnotationLayer, ManeDataService, ResidueMode +from cool_seq_tool.utils import service_meta logger = logging.getLogger("cool_seq_tool") @@ -74,5 +75,5 @@ async def get_mane_data( return ManeDataService( mane_data=mane_data, warnings=warnings, - service_meta=cool_seq_tool.service_meta() + service_meta=service_meta() ) diff --git a/cool_seq_tool/routers/mappings.py b/cool_seq_tool/routers/mappings.py index 00b340af..86ddb574 100644 --- a/cool_seq_tool/routers/mappings.py +++ b/cool_seq_tool/routers/mappings.py @@ -9,6 +9,7 @@ from cool_seq_tool.routers import cool_seq_tool, SERVICE_NAME, RESP_DESCR, Tags from cool_seq_tool.schemas import Assembly, ToGenomicService, ToCdnaService, \ ResidueMode +from cool_seq_tool.utils import service_meta logger = logging.getLogger("cool_seq_tool") @@ -51,7 +52,7 @@ async def p_to_c( return ToCdnaService( c_data=c_data, warnings=[w] if w else [], - service_meta=cool_seq_tool.service_meta() + service_meta=service_meta() ) @@ -100,7 +101,7 @@ async def c_to_g( return ToGenomicService( g_data=g_data, warnings=[w] if w else [], - service_meta=cool_seq_tool.service_meta() + service_meta=service_meta() ) @@ -144,5 +145,5 @@ async def p_to_g( return ToGenomicService( g_data=g_data, warnings=[w] if w else [], - service_meta=cool_seq_tool.service_meta() + service_meta=service_meta() ) diff --git a/cool_seq_tool/schemas.py b/cool_seq_tool/schemas.py index c73ad19e..85053381 100644 --- a/cool_seq_tool/schemas.py +++ b/cool_seq_tool/schemas.py @@ -419,10 +419,10 @@ class ManeDataService(BaseModelForbidExtra): class CdnaRepresentation(BaseModelForbidExtra): """Model response for cDNA representation""" - c_ac: str - c_start_pos: str - c_end_pos: str - cds_start: int + c_ac: StrictStr + c_start_pos: StrictInt + c_end_pos: StrictInt + cds_start: StrictInt residue_mode: Literal[ResidueMode.INTER_RESIDUE] = ResidueMode.INTER_RESIDUE.value model_config = ConfigDict( @@ -432,7 +432,7 @@ class CdnaRepresentation(BaseModelForbidExtra): "c_start_pos": 1797, "c_end_pos": 1800, "cds_start": 226, - "residue_mode": "inter-residue", + "residue_mode": ResidueMode.INTER_RESIDUE, } } ) @@ -453,7 +453,7 @@ class ToCdnaService(BaseModelForbidExtra): "c_start_pos": 1797, "c_end_pos": 1800, "cds_start": 226, - "residue_mode": "inter-residue", + "residue_mode": ResidueMode.INTER_RESIDUE, }, "warnings": [], "service_meta": { @@ -481,7 +481,7 @@ class GenomicRepresentation(BaseModelForbidExtra): "g_ac": "NC_000007.13", "g_start_pos": 140453134, "g_end_pos": 140453137, - "residue_mode": "inter-residue", + "residue_mode": ResidueMode.INTER_RESIDUE, } } ) @@ -501,7 +501,7 @@ class ToGenomicService(BaseModelForbidExtra): "g_ac": "NC_000007.13", "g_start_pos": 140453134, "g_end_pos": 140453137, - "residue_mode": "inter-residue", + "residue_mode": ResidueMode.INTER_RESIDUE, }, "warnings": [], "service_meta": { diff --git a/cool_seq_tool/utils.py b/cool_seq_tool/utils.py index 1e427f1c..2d99a483 100644 --- a/cool_seq_tool/utils.py +++ b/cool_seq_tool/utils.py @@ -11,15 +11,14 @@ def get_inter_residue_pos( - start_pos: int, residue_mode: str, end_pos: Optional[int] = None + start_pos: int, residue_mode: ResidueMode, end_pos: Optional[int] = None ) -> Tuple[Optional[Tuple[int, int]], Optional[str]]: """Return inter-residue position - :param int start_pos: Start position - :param str residue_mode: `inter-residue` if start/end are 0 based coords. - `residue` if start/end are 1 based coords - :param Optional[int] end_pos: End position. If `None` assumes both - `start` and `end` have same values. + :param start_pos: Start position + :param residue_mode: Residue mode for `start_pos` and `end_pos` + :param end_pos: End position. If `None` assumes both `start` and `end` have same + values. :return: Inter-residue coordinates, warning """ residue_mode = residue_mode.lower() diff --git a/tests/handlers/test_seqrepo_access.py b/tests/handlers/test_seqrepo_access.py index f0ee65ff..3686775f 100644 --- a/tests/handlers/test_seqrepo_access.py +++ b/tests/handlers/test_seqrepo_access.py @@ -1,6 +1,8 @@ """Module for testing seqrepo access class""" import pytest +from cool_seq_tool.schemas import ResidueMode + def test_get_reference_sequence(test_seqrepo_access): """Test that get_reference_sequence method works correctly""" @@ -14,7 +16,7 @@ def test_get_reference_sequence(test_seqrepo_access): assert resp == ("V", None) resp = test_seqrepo_access.get_reference_sequence( - "NP_004324.2", 599, 600, residue_mode="inter-residue") + "NP_004324.2", 599, 600, residue_mode=ResidueMode.INTER_RESIDUE) assert resp == ("V", None) resp = test_seqrepo_access.get_reference_sequence("NP_004324.2", 601, 600) diff --git a/tests/mappers/test_alignment.py b/tests/mappers/test_alignment.py index 452e6e1e..96ced287 100644 --- a/tests/mappers/test_alignment.py +++ b/tests/mappers/test_alignment.py @@ -23,7 +23,7 @@ def braf_v600e_c(): "c_start_pos": 1797, "c_end_pos": 1800, "cds_start": 226, - "residue_mode": "inter-residue" + "residue_mode": ResidueMode.INTER_RESIDUE } @@ -35,7 +35,7 @@ def egfr_l858r_c(): "c_start_pos": 2571, "c_end_pos": 2574, "cds_start": 261, - "residue_mode": "inter-residue" + "residue_mode": ResidueMode.INTER_RESIDUE } @@ -46,7 +46,7 @@ def braf_v600e_grch37(): "g_ac": "NC_000007.13", "g_start_pos": 140453134, "g_end_pos": 140453137, - "residue_mode": "inter-residue" + "residue_mode": ResidueMode.INTER_RESIDUE } @@ -57,7 +57,7 @@ def braf_v600e_grch38(): "g_ac": "NC_000007.14", "g_start_pos": 140753334, "g_end_pos": 140753337, - "residue_mode": "inter-residue" + "residue_mode": ResidueMode.INTER_RESIDUE } @@ -68,7 +68,7 @@ def egfr_l858r_grch37(): "g_ac": "NC_000007.13", "g_start_pos": 55259513, "g_end_pos": 55259516, - "residue_mode": "inter-residue" + "residue_mode": ResidueMode.INTER_RESIDUE } @@ -79,7 +79,7 @@ def egfr_l858r_grch38(): "g_ac": "NC_000007.14", "g_start_pos": 55191820, "g_end_pos": 55191823, - "residue_mode": "inter-residue" + "residue_mode": ResidueMode.INTER_RESIDUE } @@ -90,7 +90,7 @@ def delins_grch37(): "g_ac": "NC_000007.13", "g_start_pos": 140453131, "g_end_pos": 140453137, - "residue_mode": "inter-residue" + "residue_mode": ResidueMode.INTER_RESIDUE } @@ -104,7 +104,7 @@ def _expected(assembly): "g_ac": g_ac, "g_start_pos": 534316, "g_end_pos": 534319, - "residue_mode": "inter-residue" + "residue_mode": ResidueMode.INTER_RESIDUE } return _expected @@ -159,7 +159,7 @@ async def test_p_to_c(test_alignment_mapper, braf_v600e_c, egfr_l858r_c): "c_start_pos": 393, "c_end_pos": 396, "cds_start": 223, - "residue_mode": "inter-residue" + "residue_mode": ResidueMode.INTER_RESIDUE } diff --git a/tests/mappers/test_exon_genomic_coords.py b/tests/mappers/test_exon_genomic_coords.py index 4f162a56..65861ac2 100644 --- a/tests/mappers/test_exon_genomic_coords.py +++ b/tests/mappers/test_exon_genomic_coords.py @@ -5,13 +5,13 @@ import pytest -from cool_seq_tool.schemas import GenomicData, TranscriptExonData +from cool_seq_tool.schemas import GenomicData, TranscriptExonData, ResidueMode @pytest.fixture(scope="module") def test_egc_mapper(test_cool_seq_tool): """Build mane ExonGenomicCoordsMapper test fixture.""" - return test_cool_seq_tool.exon_genomic_coords_mapper + return test_cool_seq_tool.ex_g_coords_mapper @pytest.fixture(scope="module") @@ -352,7 +352,7 @@ async def test_tpm3(test_egc_mapper, tpm3_exon1_exon8, t_to_g_resp = await test_egc_mapper.transcript_to_genomic_coordinates(**g_to_t_resp.genomic_data.model_dump()) # noqa: E501 genomic_data_assertion_checks(t_to_g_resp, tpm3_exon1_exon8_t_to_g) - inputs["residue_mode"] = "INTER-RESIDUE" + inputs["residue_mode"] = ResidueMode.INTER_RESIDUE inputs["start"] = 154192135 inputs["end"] = 154170399 g_to_t_resp = \ @@ -375,7 +375,7 @@ async def test_tpm3(test_egc_mapper, tpm3_exon1_exon8, # Offset, no strand inputs["start"] = 154192132 inputs["end"] = 154170404 - inputs["residue_mode"] = "INTER-RESIDUE" + inputs["residue_mode"] = ResidueMode.INTER_RESIDUE tpm3_exon1_exon8_offset_t_to_g = copy.deepcopy(tpm3_exon1_exon8_offset) tpm3_exon1_exon8_offset_t_to_g.start = 154192132 g_to_t_resp = \ @@ -398,7 +398,7 @@ async def test_tpm3(test_egc_mapper, tpm3_exon1_exon8, "start": 154192135, "strand": -1, "transcript": "NM_152263.3", - "residue_mode": "inter-residue" + "residue_mode": ResidueMode.INTER_RESIDUE } tpm3_exon1_exon8_t_to_g = copy.deepcopy(tpm3_exon1_g) tpm3_exon1_exon8_t_to_g.start = 154192135 @@ -415,7 +415,7 @@ async def test_tpm3(test_egc_mapper, tpm3_exon1_exon8, "end": 154170399, "strand": -1, "transcript": "NM_152263.3", - "residue_mode": "inter-residue" + "residue_mode": ResidueMode.INTER_RESIDUE } tpm3_exon1_exon8_t_to_g = copy.deepcopy(tpm3_exon8_g) @@ -623,7 +623,7 @@ async def test_valid_inputs(test_egc_mapper): "start": 154437254, "end": 154437299, "gene": "GDI1", - "residue_mode": "inter-residue" + "residue_mode": ResidueMode.INTER_RESIDUE } resp = await test_egc_mapper.genomic_to_transcript_exon_coordinates(**inputs) assert resp.genomic_data diff --git a/tests/mappers/test_mane_transcript.py b/tests/mappers/test_mane_transcript.py index 78263b19..5d219eaf 100644 --- a/tests/mappers/test_mane_transcript.py +++ b/tests/mappers/test_mane_transcript.py @@ -6,7 +6,7 @@ import pandas as pd from cool_seq_tool.handlers.seqrepo_access import SeqRepoAccess -from cool_seq_tool.schemas import AnnotationLayer +from cool_seq_tool.schemas import AnnotationLayer, ResidueMode @pytest.fixture(scope="module") @@ -246,7 +246,7 @@ async def test_p_to_mane_p(test_mane_transcript, braf_v600e_mane_p, """Test that p_to_mane_p method works correctly.""" # BRAF V600E RefSeq Accessions mane_p = await test_mane_transcript.get_mane_transcript( - "NP_004324.2", 599, "p", residue_mode="inter-residue") + "NP_004324.2", 599, "p", residue_mode=ResidueMode.INTER_RESIDUE) assert mane_p == braf_v600e_mane_p mane_p = await test_mane_transcript.get_mane_transcript( @@ -254,7 +254,7 @@ async def test_p_to_mane_p(test_mane_transcript, braf_v600e_mane_p, assert mane_p == braf_v600e_mane_p mane_p = await test_mane_transcript.get_mane_transcript( - "NP_004324.2", 599, "p", residue_mode="inter-residue", end_pos=599) + "NP_004324.2", 599, "p", residue_mode=ResidueMode.INTER_RESIDUE, end_pos=599) assert mane_p == braf_v600e_mane_p mane_p = await test_mane_transcript.get_mane_transcript( @@ -263,7 +263,7 @@ async def test_p_to_mane_p(test_mane_transcript, braf_v600e_mane_p, # BRAF V600E Ensembl Accessions mane_p = await test_mane_transcript.get_mane_transcript( - "ENSP00000288602.7", 599, "p", residue_mode="inter-residue") + "ENSP00000288602.7", 599, "p", residue_mode=ResidueMode.INTER_RESIDUE) assert mane_p == braf_v600e_mane_p mane_p = await test_mane_transcript.get_mane_transcript( @@ -271,7 +271,7 @@ async def test_p_to_mane_p(test_mane_transcript, braf_v600e_mane_p, assert mane_p == braf_v600e_mane_p mane_p = await test_mane_transcript.get_mane_transcript( - "ENSP00000288602.7", 599, "p", residue_mode="inter-residue", + "ENSP00000288602.7", 599, "p", residue_mode=ResidueMode.INTER_RESIDUE, end_pos=599) assert mane_p == braf_v600e_mane_p @@ -324,11 +324,11 @@ async def test_c_to_mane_c(test_mane_transcript, braf_v600e_mane_c, assert mane_c == cpy_braf_v600e_mane_c mane_c = await test_mane_transcript.get_mane_transcript( - "NM_004333.4", 1798, "c", residue_mode="inter-residue") + "NM_004333.4", 1798, "c", residue_mode=ResidueMode.INTER_RESIDUE) assert mane_c == cpy_braf_v600e_mane_c mane_c = await test_mane_transcript.get_mane_transcript( - "NM_004333.4", 1798, "c", residue_mode="inter-residue", end_pos=1798) + "NM_004333.4", 1798, "c", residue_mode=ResidueMode.INTER_RESIDUE, end_pos=1798) assert mane_c == cpy_braf_v600e_mane_c mane_c = await test_mane_transcript.get_mane_transcript( @@ -437,12 +437,12 @@ async def test_get_longest_compatible_transcript(test_mane_transcript): } resp = await test_mane_transcript.get_longest_compatible_transcript( "BRAF", 599, 599, start_annotation_layer=AnnotationLayer.PROTEIN, - residue_mode="inter-residue", mane_transcripts=mane_transcripts) + residue_mode=ResidueMode.INTER_RESIDUE, mane_transcripts=mane_transcripts) assert resp == expected resp = await test_mane_transcript.get_longest_compatible_transcript( "BRAF", 600, 600, start_annotation_layer=AnnotationLayer.PROTEIN, - residue_mode="residue", mane_transcripts=mane_transcripts) + residue_mode=ResidueMode.RESIDUE, mane_transcripts=mane_transcripts) assert resp == expected expected = { @@ -459,7 +459,7 @@ async def test_get_longest_compatible_transcript(test_mane_transcript): resp = await test_mane_transcript.get_longest_compatible_transcript( "BRAF", 1798, 1798, start_annotation_layer=AnnotationLayer.CDNA, - residue_mode="inter-residue", mane_transcripts=mane_transcripts) + residue_mode=ResidueMode.INTER_RESIDUE, mane_transcripts=mane_transcripts) assert resp == expected resp = await test_mane_transcript.get_longest_compatible_transcript( @@ -484,7 +484,7 @@ async def test_g_to_mane_c(test_mane_transcript, egfr_l858r_mane_c, mane_c = await test_mane_transcript.g_to_mane_c( "NC_000007.13", 55259514, None, gene="EGFR", - residue_mode="inter-residue") + residue_mode=ResidueMode.INTER_RESIDUE) assert mane_c == egfr_l858r_mane_c mane_c = await test_mane_transcript.g_to_mane_c( @@ -493,7 +493,7 @@ async def test_g_to_mane_c(test_mane_transcript, egfr_l858r_mane_c, mane_c = await test_mane_transcript.g_to_mane_c( "NC_000007.13", 140453135, None, gene="BRAF", - residue_mode="inter-residue") + residue_mode=ResidueMode.INTER_RESIDUE) assert mane_c == braf_v600e_mane_c mane_c = await test_mane_transcript.get_mane_transcript( @@ -502,7 +502,7 @@ async def test_g_to_mane_c(test_mane_transcript, egfr_l858r_mane_c, mane_c = await test_mane_transcript.get_mane_transcript( "NC_000007.13", 140453135, "g", gene="BRAF", - residue_mode="inter-residue") + residue_mode=ResidueMode.INTER_RESIDUE) assert mane_c == braf_v600e_mane_c mane_c = await test_mane_transcript.g_to_mane_c( @@ -514,7 +514,7 @@ async def test_g_to_mane_c(test_mane_transcript, egfr_l858r_mane_c, assert resp == grch38 resp = await test_mane_transcript.get_mane_transcript( - "NC_000007.13", 55259514, "g", residue_mode="inter-residue") + "NC_000007.13", 55259514, "g", residue_mode=ResidueMode.INTER_RESIDUE) assert resp == grch38 resp = await test_mane_transcript.get_mane_transcript( @@ -527,7 +527,7 @@ async def test_g_to_mane_c(test_mane_transcript, egfr_l858r_mane_c, assert resp == grch38 resp = await test_mane_transcript.g_to_mane_c( - "NC_000007.13", 140453135, None, residue_mode="inter-residue") + "NC_000007.13", 140453135, None, residue_mode=ResidueMode.INTER_RESIDUE) assert resp == grch38 resp = await test_mane_transcript.g_to_mane_c( diff --git a/tests/test_utils.py b/tests/test_utils.py index d2b5048d..5c31005e 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,20 +1,21 @@ """Module for testing residue mode""" +from cool_seq_tool.schemas import ResidueMode from cool_seq_tool.utils import get_inter_residue_pos def test_get_inter_residue_pos(): """Test that get_inter_residue_pos method works correctly""" expected = ((599, 599), None) - resp = get_inter_residue_pos(600, "residue") + resp = get_inter_residue_pos(600, ResidueMode.RESIDUE) assert resp == expected - resp = get_inter_residue_pos(600, "residue", end_pos=600) + resp = get_inter_residue_pos(600, ResidueMode.RESIDUE, end_pos=600) assert resp == expected - resp = get_inter_residue_pos(599, "inter-residue") + resp = get_inter_residue_pos(599, ResidueMode.INTER_RESIDUE) assert resp == expected - resp = get_inter_residue_pos(599, "inter-residue", end_pos=599) + resp = get_inter_residue_pos(599, ResidueMode.INTER_RESIDUE, end_pos=599) assert resp == expected resp = get_inter_residue_pos(600, "test")