Skip to content

Commit

Permalink
Check for post-map haplotype before accessing members
Browse files Browse the repository at this point in the history
  • Loading branch information
sallybg committed Nov 28, 2024
1 parent a6586b7 commit c877313
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions src/dcd_mapping/annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,22 +306,20 @@ def _annotate_haplotype_mapping(
for allele in pre_mapped.members:
allele.extensions = [_get_vrs_ref_allele_seq(allele, metadata, tx_results)]

# Determine reference sequence
if mapped_score.annotation_layer == AnnotationLayer.GENOMIC:
sequence_id = (
f"ga4gh:{post_mapped.members[0].location.sequenceReference.refgetAccession}"
)
accession = get_chromosome_identifier_from_vrs_id(sequence_id)
if accession is None:
raise ValueError
if accession.startswith("refseq:"):
accession = accession[7:]
else:
if tx_results is None:
raise ValueError # impossible by definition
accession = tx_results.np

if post_mapped:
# Determine reference sequence
if mapped_score.annotation_layer == AnnotationLayer.GENOMIC:
sequence_id = f"ga4gh:{post_mapped.members[0].location.sequenceReference.refgetAccession}"
accession = get_chromosome_identifier_from_vrs_id(sequence_id)
if accession is None:
raise ValueError
if accession.startswith("refseq:"):
accession = accession[7:]
else:
if tx_results is None:
raise ValueError # impossible by definition
accession = tx_results.np

sr = get_seqrepo()
for allele in post_mapped.members:
loc = allele.location
Expand Down

0 comments on commit c877313

Please sign in to comment.