AdamaJava / adamajava

Other
14 stars 4 forks source link

qProfiler assumes optional ZM tag is an integer #353

Closed delocalizer closed 4 months ago

delocalizer commented 4 months ago

Describe the bug Running qprofiler on a bam from the DRAGEN TSO500 workflow with records like this:

consensus_read_GTACACG+ACAGCG_4_180723216_7_4144962_6   97  chr1    163620  0   142M    chr8    4144866 0   AGTAAAAATGTCTGCCAAAGAAATGGGGAAAAAAGATTCAGAGAGTGAAAACAATTAATATACTAACAAGAGAGCAAAAAGCAAAGGGGGAGGAGAAACTAGGAAAATCATATATGGGCTCTCACCTATTTCCAAAGCTGGG  "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^S^^^^^^^^S^^^S^^^^^^^^^^^^^^S^S^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"""  RG:Z:1  AS:i:142    XS:i:142    NM:i:0  sd:f:0  RX:Z:GTACACG+ACAGCG XV:i:2  XW:i:0  ZM:Z:MantaBND:0:18770:18780:0:1:0:0|SRM

fails with java.lang.NumberFormatException:

17:51:02.922 [pool-2-thread-5] SEVERE org.qcmg.qprofiler.bam.BamSummarizerMT - error caught parsing SAMRecord with readName: consensus_read_TTGCCAG+AGAGACG_0_854556_15_3779068_5
java.lang.NumberFormatException: For input string: "MantaBND:0:129003:129004:0:0:0:0|PR"
    java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67)
    java.base/java.lang.Integer.parseInt(Integer.java:661)
    java.base/java.lang.Integer.parseInt(Integer.java:777)
    org.qcmg.qprofiler.bam.BamSummaryReport.parseTAGs(BamSummaryReport.java:591)
    org.qcmg.qprofiler.bam.BamSummaryReport.parseRecord(BamSummaryReport.java:552)
    org.qcmg.qprofiler.bam.BamSummarizerMT$Consumer.run(BamSummarizerMT.java:324)

To Reproduce As above.

Expected behavior qProfiler should run on any bam, including bams that use a different semantics for custom tags than we do internally. The root cause of the issue is that qProfiler is assuming that if ZM tag appears, that it is an integer and it has the meaning that we assign internally. At a minimum we should be using the tag type (in this case it's Z for string, not i for integer) of custom tags to determine if it's sensible to perform numeric operations on them.

holmeso commented 4 months ago

How dare someone else use the ZM tag