From 590bb50d1676cdac2ecb0f2c4115d65672b616d4 Mon Sep 17 00:00:00 2001 From: chartl Date: Thu, 2 Sep 2010 14:22:13 +0000 Subject: [PATCH] Test for missing read group git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4192 348d0f76-0448-11de-a6fe-93d51630548a --- .../sting/gatk/walkers/coverage/CoverageUtils.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/coverage/CoverageUtils.java b/java/src/org/broadinstitute/sting/gatk/walkers/coverage/CoverageUtils.java index 0705af8af..32dcd1b0e 100644 --- a/java/src/org/broadinstitute/sting/gatk/walkers/coverage/CoverageUtils.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/coverage/CoverageUtils.java @@ -86,7 +86,7 @@ public class CoverageUtils { Map countsByRG = new HashMap(); for ( PileupElement e : context.getBasePileup() ) { if ( e.getMappingQual() >= minMapQ && e.getMappingQual() <= maxMapQ && ( e.getQual() >= minBaseQ && e.getQual() <= maxBaseQ || e.isDeletion() ) ) { - SAMReadGroupRecord readGroup = e.getRead().getReadGroup(); + SAMReadGroupRecord readGroup = getReadGroup(e.getRead()); if ( ! countsByRG.keySet().contains(readGroup) ) { countsByRG.put(readGroup,new int[6]); updateCounts(countsByRG.get(readGroup),e); @@ -112,4 +112,16 @@ public class CoverageUtils { } } } + + private static SAMReadGroupRecord getReadGroup(SAMRecord r) { + SAMReadGroupRecord rg = r.getReadGroup(); + if ( rg == null ) { + String msg = "Read "+r.getReadName()+" lacks read group information."; + msg += " Please associate all reads with read groups [recommended]\n"; + msg += " Or run with -rf MissingReadGroup [not recommended]"; + throw new StingException(msg); + } + + return rg; + } }