GATKSamRecords with efficiency NGSPlatform method

This commit is contained in:
Mark DePristo 2011-10-21 09:38:41 -04:00
parent 94e1898d8f
commit ed74ebcfa1
2 changed files with 34 additions and 5 deletions

View File

@ -1,6 +1,7 @@
package org.broadinstitute.sting.utils.sam;
import net.sf.samtools.SAMReadGroupRecord;
import org.broadinstitute.sting.utils.NGSPlatform;
/**
* @author ebanks
@ -15,16 +16,28 @@ public class GATKSAMReadGroupRecord extends SAMReadGroupRecord {
// the SAMReadGroupRecord data we're caching
private String mSample = null;
private String mPlatform = null;
private NGSPlatform mNGSPlatform = null;
// because some values can be null, we don't want to duplicate effort
private boolean retrievedSample = false;
private boolean retrievedPlatform = false;
private boolean retrievedNGSPlatform = false;
public GATKSAMReadGroupRecord(final String id) {
super(id);
}
public GATKSAMReadGroupRecord(SAMReadGroupRecord record) {
super(record.getReadGroupId(), record);
}
public GATKSAMReadGroupRecord(SAMReadGroupRecord record, NGSPlatform pl) {
super(record.getReadGroupId(), record);
setPlatform(pl.getDefaultPlatform());
mNGSPlatform = pl;
retrievedPlatform = retrievedNGSPlatform = true;
}
///////////////////////////////////////////////////////////////////////////////
// *** The following methods are overloaded to cache the appropriate data ***//
///////////////////////////////////////////////////////////////////////////////
@ -55,5 +68,15 @@ public class GATKSAMReadGroupRecord extends SAMReadGroupRecord {
super.setPlatform(s);
mPlatform = s;
retrievedPlatform = true;
retrievedNGSPlatform = false; // recalculate the NGSPlatform
}
public NGSPlatform getNGSPlatform() {
if ( ! retrievedNGSPlatform ) {
mNGSPlatform = NGSPlatform.fromReadGroupPL(getPlatform());
retrievedNGSPlatform = true;
}
return mNGSPlatform;
}
}

View File

@ -1,6 +1,7 @@
package org.broadinstitute.sting.utils.sam;
import net.sf.samtools.*;
import org.broadinstitute.sting.utils.NGSPlatform;
import java.util.HashMap;
import java.util.Map;
@ -25,7 +26,7 @@ import java.util.Map;
public class GATKSamRecord extends BAMRecord {
// the SAMRecord data we're caching
private String mReadString = null;
private SAMReadGroupRecord mReadGroup = null;
private GATKSAMReadGroupRecord mReadGroup = null;
// because some values can be null, we don't want to duplicate effort
private boolean retrievedReadGroup = false;
@ -81,17 +82,22 @@ public class GATKSamRecord extends BAMRecord {
}
@Override
public SAMReadGroupRecord getReadGroup() {
public GATKSAMReadGroupRecord getReadGroup() {
if ( !retrievedReadGroup ) {
SAMReadGroupRecord tempReadGroup = super.getReadGroup();
mReadGroup = (tempReadGroup == null ? tempReadGroup : new GATKSAMReadGroupRecord(tempReadGroup));
mReadGroup = (tempReadGroup == null ? null : new GATKSAMReadGroupRecord(tempReadGroup));
retrievedReadGroup = true;
}
return mReadGroup;
}
public void setReadGroup(SAMReadGroupRecord record) {
mReadGroup = record;
public NGSPlatform getNGSPlatform() {
return getReadGroup().getNGSPlatform();
}
public void setReadGroup( final GATKSAMReadGroupRecord readGroup ) {
mReadGroup = readGroup;
retrievedReadGroup = true;
}
/**