Skip to content

Commit

Permalink
Merge pull request #51 from cancervariants/issue-50
Browse files Browse the repository at this point in the history
Remove duplicates
  • Loading branch information
korikuzma authored Feb 26, 2021
2 parents b9aa617 + 2cb0287 commit 23c1e8b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
4 changes: 3 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ def translate(q: str = Query(..., description=q_description)):

translations = []
for valid_variant in validations.valid_results:
translations.append(translator.perform(valid_variant))
result = translator.perform(valid_variant)
if result not in translations:
translations.append(result)
return TranslationResponseSchema(
search_term=q,
variants=translations
Expand Down
20 changes: 20 additions & 0 deletions tests/fixtures/translators.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,26 @@ amino_acid_substitution:
"type": "Allele"
}
]
- query: NP_004324.2:p.Val600Glu
variants: [
{
"id": "ga4gh:VA.mJbjSsW541oOsOtBoX36Mppr6hMjbjFr",
"location": {
"interval": {
"end": 600,
"start": 599,
"type": "SimpleInterval"
},
"sequence_id": "ga4gh:SQ.cQvw4UsHHRRlogxbWCB8W-mKD4AraM9y",
"type": "SequenceLocation"
},
"state": {
"sequence": "E",
"type": "SequenceState"
},
"type": "Allele"
}
]


polypeptide_truncation:
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/validators.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion variant/validators/polypeptide_sequence_variant_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ 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)
Expand Down Expand Up @@ -133,7 +140,6 @@ def get_valid_invalid_results(self, classification_tokens, transcripts,
tokens
:param list results: A list to store validation result objects
"""

for s in classification_tokens:
for t in transcripts:
valid = True
Expand Down

0 comments on commit 23c1e8b

Please sign in to comment.