Skip to content

Commit

Permalink
catch ValueErrors in dumpSTR and qcSTR arising from exceptions in cyvcf2
Browse files Browse the repository at this point in the history
  • Loading branch information
aryarm authored Jan 24, 2024
1 parent 9da066e commit 7f0745b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
7 changes: 7 additions & 0 deletions trtools/dumpSTR/dumpSTR.py
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,13 @@ def main(args):
return 1
else:
raise te
except ValueError as ve:
message = ve.args[0]
if 'properly formatted' in message:
common.WARNING("Could not parse VCF.\n" + message)
return 1
else:
raise ve
if args.verbose:
common.MSG("Processing %s:%s"%(record.chrom, record.pos))
record_counter += 1
Expand Down
19 changes: 18 additions & 1 deletion trtools/qcSTR/qcSTR.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,24 @@ def main(args):

# read the vcf
numrecords = 0
for trrecord in harmonizer:
while True:
try:
trrecord = next(harmonizer)
except StopIteration: break
except TypeError as te:
message = te.args[0]
if 'missing' in message and 'mandatory' in message:
common.WARNING("Could not parse VCF.\n" + message)
return 1
else:
raise te
except ValueError as ve:
message = ve.args[0]
if 'properly formatted' in message:
common.WARNING("Could not parse VCF.\n" + message)
return 1
else:
raise ve
if args.numrecords is not None and numrecords >= args.numrecords: break
if args.period is not None and len(trrecord.motif) != args.period: continue

Expand Down

0 comments on commit 7f0745b

Please sign in to comment.