Skip to content

Commit

Permalink
Add better error handling around metrics calculation (#58)
Browse files Browse the repository at this point in the history
Add a simple error handling to the aggregator
  • Loading branch information
rexwangcc authored and barkasn committed Feb 25, 2019
1 parent 3b1199d commit ad3fbc5
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/sctools/metrics/aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,16 @@ def parse_molecule(
self._quality_above_threshold(
30, self._quality_string_to_numeric(record.get_tag(consts.QUALITY_MOLECULE_BARCODE_TAG_KEY))))

self.perfect_molecule_barcodes += (
record.get_tag(consts.RAW_MOLECULE_BARCODE_TAG_KEY) == record.get_tag(consts.MOLECULE_BARCODE_TAG_KEY))
# we should be tolerant and handle it if the pysam.AlignedSegment.get_tag
# cannot retrieve the data by a tag since it's not a fatal error
try:
self.perfect_molecule_barcodes += (
record.get_tag(consts.RAW_MOLECULE_BARCODE_TAG_KEY) == record.get_tag(consts.MOLECULE_BARCODE_TAG_KEY))
except KeyError:
# An error occurred while retrieving the data from the optional alighment section, which
# indicates that the read did not have a corrected UMI sequence. In the future we would like to
# keep track of these reads.
pass

self._genomic_reads_fraction_bases_quality_above_30.update(
self._quality_above_threshold(30, record.query_alignment_qualities))
Expand Down

0 comments on commit ad3fbc5

Please sign in to comment.