From 2cb0287188ede21abfcca84948b3345c1cb2a528 Mon Sep 17 00:00:00 2001 From: korikuzma Date: Fri, 26 Feb 2021 15:23:45 -0500 Subject: [PATCH] Fix allele state --- tests/fixtures/validators.yml | 1 + .../polypeptide_sequence_variant_base.py | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/fixtures/validators.yml b/tests/fixtures/validators.yml index f56d3efc..b6ba78f5 100644 --- a/tests/fixtures/validators.yml +++ b/tests/fixtures/validators.yml @@ -3,6 +3,7 @@ amino_acid_substitution: - query: BRAF V600E - query: NP_004324.2:p.Val600Glu - query: NP_005219.2:p.Thr790Met + - query: EGFR Leu858Arg should_not_match: - query: NP_004324.2:p.Val600000000000Glu - query: NP_004324.2:p.Glu600Val diff --git a/variant/validators/polypeptide_sequence_variant_base.py b/variant/validators/polypeptide_sequence_variant_base.py index 681f6605..4e42d9e7 100644 --- a/variant/validators/polypeptide_sequence_variant_base.py +++ b/variant/validators/polypeptide_sequence_variant_base.py @@ -96,16 +96,17 @@ def get_vrs_allele(self, sequence_id, s) -> dict: ) state = models.SequenceState(sequence=s.alt_protein) + state_dict = state.as_dict() + if len(state_dict['sequence']) == 3: + for one, three in \ + self._amino_acid_cache._amino_acid_code_conversion.items(): + if three == state_dict['sequence']: + state.sequence = one + allele = models.Allele(location=seq_location, state=state) allele['_id'] = ga4gh_identify(allele) - allele = allele.as_dict() - if len(allele['state']['sequence']) == 3: - for one, three in \ - self._amino_acid_cache._amino_acid_code_conversion: - if three == allele['state']['sequence']: - allele['state']['sequence'] = one - return allele + return allele.as_dict() def get_hgvs_expr(self, classification) -> str: """Return HGVS expression for a classification.