From e410c005c0b1ec7da34676e0c06c026965b64602 Mon Sep 17 00:00:00 2001 From: kiran Date: Sun, 12 Apr 2009 19:40:42 +0000 Subject: [PATCH] A debugging tool to ensure the SQ tag in a four-prob SAM file matches the SAMRecord strand orientation. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@368 348d0f76-0448-11de-a6fe-93d51630548a --- .../walkers/DisplayFourBaseReadWalker.java | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 java/src/org/broadinstitute/sting/playground/gatk/walkers/DisplayFourBaseReadWalker.java diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/DisplayFourBaseReadWalker.java b/java/src/org/broadinstitute/sting/playground/gatk/walkers/DisplayFourBaseReadWalker.java new file mode 100644 index 000000000..e32fc2342 --- /dev/null +++ b/java/src/org/broadinstitute/sting/playground/gatk/walkers/DisplayFourBaseReadWalker.java @@ -0,0 +1,58 @@ +package org.broadinstitute.sting.playground.gatk.walkers; + +import org.broadinstitute.sting.gatk.walkers.ReadWalker; +import org.broadinstitute.sting.gatk.LocusContext; +import org.broadinstitute.sting.utils.QualityUtils; +import net.sf.samtools.SAMRecord; + +public class DisplayFourBaseReadWalker extends ReadWalker { + public Integer map(LocusContext context, SAMRecord read) { + String bases = read.getReadString(); + + boolean displayed = false; + + byte[] sq = (byte[]) read.getAttribute("SQ"); + + if (read.getReadName().equalsIgnoreCase("30JJE.5.24197751")) { + System.out.println(read.format()); + } + + for (int i = 0; i < sq.length; i++) { + int baseIndex = QualityUtils.compressedQualityToBaseIndex(sq[i]); + char base = '.'; + switch (baseIndex) { + case 0: base = 'A'; break; + case 1: base = 'C'; break; + case 2: base = 'G'; break; + case 3: base = 'T'; break; + } + + if (base == bases.charAt(i)) { + if (!displayed) { + System.out.println(bases); + displayed = true; + } + + System.out.print(base); + } + else { + if (displayed) { + System.out.print(" "); + } + } + } + if (displayed) { + System.out.print("\n"); + } + + return 0; + } + + public Integer reduceInit() { + return 0; + } + + public Integer reduce(Integer value, Integer sum) { + return 0; + } +}