From 899f7ab0f40212442324566c230ee88646904e07 Mon Sep 17 00:00:00 2001 From: Benjamin Capodanno Date: Thu, 16 Apr 2026 12:11:07 -0700 Subject: [PATCH 1/2] fix(vrs_map): only generate protein layer if protein strings are valid --- src/dcd_mapping/vrs_map.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/dcd_mapping/vrs_map.py b/src/dcd_mapping/vrs_map.py index f2bf22a..aa90b7a 100644 --- a/src/dcd_mapping/vrs_map.py +++ b/src/dcd_mapping/vrs_map.py @@ -829,17 +829,18 @@ def _map_protein_coding( error_message=str(transcript).strip("'"), ) else: - if _hgvs_pro_is_valid(row.hgvs_pro) and protein_align_result is not None: - hgvs_pro_mappings = _map_protein_coding_pro( - row, psequence_id, transcript, protein_align_result - ) - # This should not occur because protein align result is only None if transcript selection failed, which should be caught by the TxSelectError check above. - elif protein_align_result is None: - hgvs_pro_mappings = MappedScore( - accession_id=row.accession, - score=row.score, - error_message="Could not perform mapping for protein variant because transcript sequence is missing or could not be aligned to reference sequence", - ) + if _hgvs_pro_is_valid(row.hgvs_pro): + if protein_align_result is not None: + hgvs_pro_mappings = _map_protein_coding_pro( + row, psequence_id, transcript, protein_align_result + ) + # This should not occur because protein align result is only None if transcript selection failed, which should be caught by the TxSelectError check above. + elif protein_align_result is None: + hgvs_pro_mappings = MappedScore( + accession_id=row.accession, + score=row.score, + error_message="Could not perform mapping for protein variant because transcript sequence is missing or could not be aligned to reference sequence", + ) elif ( not hgvs_nt_mappings ): # only create error message if there is not an hgvs nt mapping From d681cbcdadc77759738cbeb7593b32a1396b4fda Mon Sep 17 00:00:00 2001 From: Benjamin Capodanno Date: Thu, 16 Apr 2026 12:58:06 -0700 Subject: [PATCH 2/2] fix(vrs_map): avoid redundant error messages for protein alignment failure when valid hgvs nt mapping exists --- src/dcd_mapping/vrs_map.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/dcd_mapping/vrs_map.py b/src/dcd_mapping/vrs_map.py index aa90b7a..9779f7c 100644 --- a/src/dcd_mapping/vrs_map.py +++ b/src/dcd_mapping/vrs_map.py @@ -834,8 +834,10 @@ def _map_protein_coding( hgvs_pro_mappings = _map_protein_coding_pro( row, psequence_id, transcript, protein_align_result ) - # This should not occur because protein align result is only None if transcript selection failed, which should be caught by the TxSelectError check above. - elif protein_align_result is None: + # Only create this error message if there is not a valid hgvs nt mapping, because if there is a valid hgvs nt mapping, + # it indicates we expect protein alignemnt to fail and we don't want to create redundant error messages about missing + # transcript sequence or alignment failure + elif protein_align_result is None and not hgvs_nt_mappings: hgvs_pro_mappings = MappedScore( accession_id=row.accession, score=row.score,