From aa3ee299294a4b35b0ef5812360adb463739a6b9 Mon Sep 17 00:00:00 2001 From: Mark DePristo Date: Sat, 22 Dec 2012 13:13:01 -0500 Subject: [PATCH] Handle case where the ReadGroup is null in GATKSAMRecord --- .../broadinstitute/sting/utils/sam/GATKSAMRecord.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/public/java/src/org/broadinstitute/sting/utils/sam/GATKSAMRecord.java b/public/java/src/org/broadinstitute/sting/utils/sam/GATKSAMRecord.java index cf06c59e8..beadead0a 100755 --- a/public/java/src/org/broadinstitute/sting/utils/sam/GATKSAMRecord.java +++ b/public/java/src/org/broadinstitute/sting/utils/sam/GATKSAMRecord.java @@ -155,7 +155,16 @@ public class GATKSAMRecord extends BAMRecord { public GATKSAMReadGroupRecord getReadGroup() { if ( ! retrievedReadGroup ) { final SAMReadGroupRecord rg = super.getReadGroup(); - mReadGroup = rg instanceof GATKSAMReadGroupRecord ? (GATKSAMReadGroupRecord)rg : new GATKSAMReadGroupRecord(rg); + + // three cases: rg may be null (no rg, rg may already be a GATKSAMReadGroupRecord, or it may be + // a regular SAMReadGroupRecord in which case we have to make it a GATKSAMReadGroupRecord + if ( rg == null ) + mReadGroup = null; + else if ( rg instanceof GATKSAMReadGroupRecord ) + mReadGroup = (GATKSAMReadGroupRecord)rg; + else + mReadGroup = new GATKSAMReadGroupRecord(rg); + retrievedReadGroup = true; } return mReadGroup;