Handle case where the ReadGroup is null in GATKSAMRecord

This commit is contained in:
Mark DePristo 2012-12-22 13:13:01 -05:00
parent bf81db40f7
commit aa3ee29929
1 changed files with 10 additions and 1 deletions

View File

@ -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;