Skip to content

Commit a33900a

Browse files
committed
More tolerant
1 parent 5dbf1ea commit a33900a

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

v03_pipeline/lib/misc/allele_registry.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -159,22 +159,20 @@ def handle_api_response( # noqa: C901
159159
continue
160160

161161
# Extract CAID and allele info
162-
caid = allele_response['@id'].split('/')[-1]
163-
allele_info = next(
164-
(
162+
try:
163+
caid = allele_response['@id'].split('/')[-1]
164+
allele_info = next(
165165
record
166166
for record in allele_response['genomicAlleles']
167167
if record['referenceGenome'] == reference_genome.value
168-
),
169-
None,
170-
)
171-
if not allele_info:
168+
)
169+
chrom = allele_info['chromosome']
170+
pos = allele_info['coordinates'][0]['end']
171+
ref = allele_info['coordinates'][0]['referenceAllele']
172+
alt = allele_info['coordinates'][0]['allele']
173+
except (KeyError, StopIteration):
172174
unmappable_variants.append(allele_response)
173175
continue
174-
chrom = allele_info['chromosome']
175-
pos = allele_info['coordinates'][0]['end']
176-
ref = allele_info['coordinates'][0]['referenceAllele']
177-
alt = allele_info['coordinates'][0]['allele']
178176

179177
if ref == '' or alt == '':
180178
# AR will turn alleles like ["A","ATT"] to ["", "TT"] so try using gnomad IDs instead

0 commit comments

Comments
 (0)