GATKSamRecord now produced by SAMFileReaders by default
-- Removed all of the unnecessary caching operations in GATKSAMRecord -- GATKSAMRecord renamed to GATKSamRecord for consistency
This commit is contained in:
parent
df3e4e1abd
commit
7928b287fc
|
|
@ -647,7 +647,9 @@ public class SAMDataSource {
|
|||
BAQ.QualityMode qmode,
|
||||
IndexedFastaSequenceFile refReader,
|
||||
byte defaultBaseQualities) {
|
||||
wrappedIterator = new ReadFormattingIterator(wrappedIterator, useOriginalBaseQualities, defaultBaseQualities);
|
||||
if ( useOriginalBaseQualities || defaultBaseQualities >= 0 )
|
||||
// only wrap if we are replacing the original qualitiies or using a default base quality
|
||||
wrappedIterator = new ReadFormattingIterator(wrappedIterator, useOriginalBaseQualities, defaultBaseQualities);
|
||||
|
||||
// NOTE: this (and other filtering) should be done before on-the-fly sorting
|
||||
// as there is no reason to sort something that we will end of throwing away
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package org.broadinstitute.sting.gatk.iterators;
|
|||
|
||||
import net.sf.samtools.SAMRecord;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
|
||||
|
||||
/**
|
||||
* An iterator which does post-processing of a read, including potentially wrapping
|
||||
|
|
@ -78,7 +77,30 @@ public class ReadFormattingIterator implements StingSAMIterator {
|
|||
* no next exists.
|
||||
*/
|
||||
public SAMRecord next() {
|
||||
return new GATKSAMRecord(wrappedIterator.next(), useOriginalBaseQualities, defaultBaseQualities);
|
||||
SAMRecord rec = wrappedIterator.next();
|
||||
|
||||
// if we are using default quals, check if we need them, and add if necessary.
|
||||
// 1. we need if reads are lacking or have incomplete quality scores
|
||||
// 2. we add if defaultBaseQualities has a positive value
|
||||
if (defaultBaseQualities >= 0) {
|
||||
byte reads [] = rec.getReadBases();
|
||||
byte quals [] = rec.getBaseQualities();
|
||||
if (quals == null || quals.length < reads.length) {
|
||||
byte new_quals [] = new byte [reads.length];
|
||||
for (int i=0; i<reads.length; i++)
|
||||
new_quals[i] = defaultBaseQualities;
|
||||
rec.setBaseQualities(new_quals);
|
||||
}
|
||||
}
|
||||
|
||||
// if we are using original quals, set them now if they are present in the record
|
||||
if ( useOriginalBaseQualities ) {
|
||||
byte[] originalQuals = rec.getOriginalBaseQualities();
|
||||
if ( originalQuals != null )
|
||||
rec.setBaseQualities(originalQuals);
|
||||
}
|
||||
|
||||
return rec;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -30,18 +30,16 @@ import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
|
|||
import org.broadinstitute.sting.gatk.contexts.AlignmentContextUtils;
|
||||
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
|
||||
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
||||
import org.broadinstitute.sting.gatk.walkers.indels.HaplotypeIndelErrorModel;
|
||||
import org.broadinstitute.sting.gatk.walkers.indels.PairHMMIndelErrorModel;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||
import org.broadinstitute.sting.utils.Haplotype;
|
||||
import org.broadinstitute.sting.utils.collections.Pair;
|
||||
import org.broadinstitute.sting.utils.exceptions.StingException;
|
||||
import org.broadinstitute.sting.utils.pileup.ExtendedEventPileupElement;
|
||||
import org.broadinstitute.sting.utils.pileup.PileupElement;
|
||||
import org.broadinstitute.sting.utils.pileup.ReadBackedExtendedEventPileup;
|
||||
import org.broadinstitute.sting.utils.pileup.ReadBackedPileup;
|
||||
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
|
||||
import org.broadinstitute.sting.utils.sam.GATKSamRecord;
|
||||
import org.broadinstitute.sting.utils.sam.ReadUtils;
|
||||
import org.broadinstitute.sting.utils.variantcontext.Allele;
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
|
||||
|
|
@ -127,7 +125,7 @@ public class IndelGenotypeLikelihoodsCalculationModel extends GenotypeLikelihood
|
|||
|
||||
for ( ExtendedEventPileupElement p : indelPileup.toExtendedIterable() ) {
|
||||
//SAMRecord read = p.getRead();
|
||||
GATKSAMRecord read = ReadUtils.hardClipAdaptorSequence(p.getRead());
|
||||
GATKSamRecord read = ReadUtils.hardClipAdaptorSequence(p.getRead());
|
||||
if (read == null)
|
||||
continue;
|
||||
if(ReadUtils.is454Read(read)) {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ import org.broadinstitute.sting.utils.collections.NestedHashMap;
|
|||
import org.broadinstitute.sting.utils.exceptions.DynamicClassResolutionException;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.pileup.PileupElement;
|
||||
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
|
||||
import org.broadinstitute.sting.utils.sam.GATKSamRecord;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -352,7 +352,7 @@ public class CountCovariatesWalker extends LocusWalker<CountCovariatesWalker.Cou
|
|||
if( tracker.getValues(knownSites).size() == 0 ) { // If something here is in one of the knownSites tracks then skip over it, otherwise proceed
|
||||
// For each read at this locus
|
||||
for( final PileupElement p : context.getBasePileup() ) {
|
||||
final GATKSAMRecord gatkRead = (GATKSAMRecord) p.getRead();
|
||||
final GATKSamRecord gatkRead = (GATKSamRecord) p.getRead();
|
||||
int offset = p.getOffset();
|
||||
|
||||
if( gatkRead.containsTemporaryAttribute( SKIP_RECORD_ATTRIBUTE ) ) {
|
||||
|
|
@ -445,7 +445,7 @@ public class CountCovariatesWalker extends LocusWalker<CountCovariatesWalker.Cou
|
|||
* @param offset The offset in the read for this locus
|
||||
* @param refBase The reference base at this locus
|
||||
*/
|
||||
private void updateDataFromRead(CountedData counter, final GATKSAMRecord gatkRead, final int offset, final byte refBase) {
|
||||
private void updateDataFromRead(CountedData counter, final GATKSamRecord gatkRead, final int offset, final byte refBase) {
|
||||
final Object[][] covars = (Comparable[][]) gatkRead.getTemporaryAttribute(COVARS_ATTRIBUTE);
|
||||
final Object[] key = covars[offset];
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import org.broadinstitute.sting.utils.collections.NestedHashMap;
|
|||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.sam.AlignmentUtils;
|
||||
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
|
||||
import org.broadinstitute.sting.utils.sam.GATKSamRecord;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -243,7 +243,7 @@ public class RecalDataManager {
|
|||
// There is no readGroup so defaulting to these values
|
||||
readGroup = new SAMReadGroupRecord( RAC.DEFAULT_READ_GROUP );
|
||||
readGroup.setPlatform( RAC.DEFAULT_PLATFORM );
|
||||
((GATKSAMRecord)read).setReadGroup( readGroup );
|
||||
((GATKSamRecord)read).setReadGroup( readGroup );
|
||||
} else {
|
||||
throw new UserException.MalformedBAM(read, "The input .bam file contains reads with no read group. First observed at read with name = " + read.getReadName() );
|
||||
}
|
||||
|
|
@ -253,7 +253,7 @@ public class RecalDataManager {
|
|||
final String oldPlatform = readGroup.getPlatform();
|
||||
readGroup = new SAMReadGroupRecord( RAC.FORCE_READ_GROUP );
|
||||
readGroup.setPlatform( oldPlatform );
|
||||
((GATKSAMRecord)read).setReadGroup( readGroup );
|
||||
((GATKSamRecord)read).setReadGroup( readGroup );
|
||||
}
|
||||
|
||||
if( RAC.FORCE_PLATFORM != null && (readGroup.getPlatform() == null || !readGroup.getPlatform().equals(RAC.FORCE_PLATFORM))) {
|
||||
|
|
@ -572,7 +572,7 @@ public class RecalDataManager {
|
|||
* value for the ith position in the read and the jth covariate in
|
||||
* reqeustedCovariates list.
|
||||
*/
|
||||
public static Comparable[][] computeCovariates(final GATKSAMRecord gatkRead, final List<Covariate> requestedCovariates) {
|
||||
public static Comparable[][] computeCovariates(final GATKSamRecord gatkRead, final List<Covariate> requestedCovariates) {
|
||||
//compute all covariates for this read
|
||||
final List<Covariate> requestedCovariatesRef = requestedCovariates;
|
||||
final int numRequestedCovariates = requestedCovariatesRef.size();
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ import org.broadinstitute.sting.utils.classloader.PluginManager;
|
|||
import org.broadinstitute.sting.utils.collections.NestedHashMap;
|
||||
import org.broadinstitute.sting.utils.exceptions.DynamicClassResolutionException;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
|
||||
import org.broadinstitute.sting.utils.sam.GATKSamRecord;
|
||||
import org.broadinstitute.sting.utils.text.TextFormattingUtils;
|
||||
import org.broadinstitute.sting.utils.text.XReadLines;
|
||||
|
||||
|
|
@ -398,7 +398,7 @@ public class TableRecalibrationWalker extends ReadWalker<SAMRecord, SAMFileWrite
|
|||
|
||||
//compute all covariate values for this read
|
||||
final Comparable[][] covariateValues_offset_x_covar =
|
||||
RecalDataManager.computeCovariates((GATKSAMRecord) read, requestedCovariates);
|
||||
RecalDataManager.computeCovariates((GATKSamRecord) read, requestedCovariates);
|
||||
|
||||
// For each base in the read
|
||||
for( int offset = 0; offset < read.getReadLength(); offset++ ) {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,8 @@
|
|||
package org.broadinstitute.sting.utils.sam;
|
||||
|
||||
import net.sf.samtools.*;
|
||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
|
@ -26,70 +22,35 @@ import java.util.Map;
|
|||
* done. Hopefully SAMRecord will become an interface and
|
||||
* this will eventually be fixed.
|
||||
*/
|
||||
public class GATKSAMRecord extends SAMRecord {
|
||||
|
||||
// the underlying SAMRecord which we are wrapping
|
||||
private final SAMRecord mRecord;
|
||||
|
||||
public class GATKSamRecord extends BAMRecord {
|
||||
// the SAMRecord data we're caching
|
||||
private String mReadString = null;
|
||||
private SAMReadGroupRecord mReadGroup = null;
|
||||
private boolean mNegativeStrandFlag;
|
||||
private boolean mUnmappedFlag;
|
||||
private Boolean mSecondOfPairFlag = null;
|
||||
|
||||
// because some values can be null, we don't want to duplicate effort
|
||||
private boolean retrievedReadGroup = false;
|
||||
|
||||
/** A private cache for the reduced read quality. Null indicates the value hasn't be fetched yet or isn't available */
|
||||
private boolean lookedUpReducedReadQuality = false;
|
||||
private Integer reducedReadQuality;
|
||||
|
||||
// These temporary attributes were added here to make life easier for
|
||||
// certain algorithms by providing a way to label or attach arbitrary data to
|
||||
// individual GATKSAMRecords.
|
||||
// These attributes exist in memory only, and are never written to disk.
|
||||
private Map<Object, Object> temporaryAttributes;
|
||||
|
||||
public GATKSAMRecord(SAMRecord record, boolean useOriginalBaseQualities, byte defaultBaseQualities) {
|
||||
super(null); // it doesn't matter - this isn't used
|
||||
if ( record == null )
|
||||
throw new IllegalArgumentException("The SAMRecord argument cannot be null");
|
||||
mRecord = record;
|
||||
|
||||
mNegativeStrandFlag = mRecord.getReadNegativeStrandFlag();
|
||||
mUnmappedFlag = mRecord.getReadUnmappedFlag();
|
||||
|
||||
// because attribute methods are declared to be final (and we can't overload them),
|
||||
// we need to actually set all of the attributes here
|
||||
List<SAMTagAndValue> attributes = record.getAttributes();
|
||||
for ( SAMTagAndValue attribute : attributes )
|
||||
setAttribute(attribute.tag, attribute.value);
|
||||
|
||||
// if we are using default quals, check if we need them, and add if necessary.
|
||||
// 1. we need if reads are lacking or have incomplete quality scores
|
||||
// 2. we add if defaultBaseQualities has a positive value
|
||||
if (defaultBaseQualities >= 0) {
|
||||
byte reads [] = record.getReadBases();
|
||||
byte quals [] = record.getBaseQualities();
|
||||
if (quals == null || quals.length < reads.length) {
|
||||
byte new_quals [] = new byte [reads.length];
|
||||
for (int i=0; i<reads.length; i++)
|
||||
new_quals[i] = defaultBaseQualities;
|
||||
record.setBaseQualities(new_quals);
|
||||
}
|
||||
}
|
||||
|
||||
// if we are using original quals, set them now if they are present in the record
|
||||
if ( useOriginalBaseQualities ) {
|
||||
byte[] originalQuals = mRecord.getOriginalBaseQualities();
|
||||
if ( originalQuals != null )
|
||||
mRecord.setBaseQualities(originalQuals);
|
||||
}
|
||||
|
||||
// sanity check that the lengths of the base and quality strings are equal
|
||||
if ( getBaseQualities().length != getReadLength() )
|
||||
throw new UserException.MalformedBAM(this, String.format("Error: the number of base qualities does not match the number of bases in %s.", mRecord.getReadName()));
|
||||
public GATKSamRecord(final SAMFileHeader header,
|
||||
final int referenceSequenceIndex,
|
||||
final int alignmentStart,
|
||||
final short readNameLength,
|
||||
final short mappingQuality,
|
||||
final int indexingBin,
|
||||
final int cigarLen,
|
||||
final int flags,
|
||||
final int readLen,
|
||||
final int mateReferenceSequenceIndex,
|
||||
final int mateAlignmentStart,
|
||||
final int insertSize,
|
||||
final byte[] variableLengthBlock) {
|
||||
super(header, referenceSequenceIndex, alignmentStart, readNameLength, mappingQuality, indexingBin, cigarLen,
|
||||
flags, readLen, mateReferenceSequenceIndex, mateAlignmentStart, insertSize, variableLengthBlock);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -98,18 +59,18 @@ public class GATKSAMRecord extends SAMRecord {
|
|||
|
||||
public String getReadString() {
|
||||
if ( mReadString == null )
|
||||
mReadString = mRecord.getReadString();
|
||||
mReadString = super.getReadString();
|
||||
return mReadString;
|
||||
}
|
||||
|
||||
public void setReadString(String s) {
|
||||
mRecord.setReadString(s);
|
||||
super.setReadString(s);
|
||||
mReadString = s;
|
||||
}
|
||||
|
||||
public SAMReadGroupRecord getReadGroup() {
|
||||
if ( !retrievedReadGroup ) {
|
||||
SAMReadGroupRecord tempReadGroup = mRecord.getReadGroup();
|
||||
SAMReadGroupRecord tempReadGroup = super.getReadGroup();
|
||||
mReadGroup = (tempReadGroup == null ? tempReadGroup : new GATKSAMReadGroupRecord(tempReadGroup));
|
||||
retrievedReadGroup = true;
|
||||
}
|
||||
|
|
@ -120,38 +81,6 @@ public class GATKSAMRecord extends SAMRecord {
|
|||
mReadGroup = record;
|
||||
}
|
||||
|
||||
public boolean getReadUnmappedFlag() {
|
||||
return mUnmappedFlag;
|
||||
}
|
||||
|
||||
public void setReadUnmappedFlag(boolean b) {
|
||||
mRecord.setReadUnmappedFlag(b);
|
||||
mUnmappedFlag = b;
|
||||
}
|
||||
|
||||
public boolean getReadNegativeStrandFlag() {
|
||||
return mNegativeStrandFlag;
|
||||
}
|
||||
|
||||
public void setReadNegativeStrandFlag(boolean b) {
|
||||
mRecord.setReadNegativeStrandFlag(b);
|
||||
mNegativeStrandFlag = b;
|
||||
}
|
||||
|
||||
public boolean getSecondOfPairFlag() {
|
||||
if( mSecondOfPairFlag == null ) {
|
||||
//not done in constructor because this method can't be called for
|
||||
//all SAMRecords.
|
||||
mSecondOfPairFlag = mRecord.getSecondOfPairFlag();
|
||||
}
|
||||
return mSecondOfPairFlag;
|
||||
}
|
||||
|
||||
public void setSecondOfPairFlag(boolean b) {
|
||||
mRecord.setSecondOfPairFlag(b);
|
||||
mSecondOfPairFlag = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether an attribute has been set for the given key.
|
||||
*
|
||||
|
|
@ -205,269 +134,14 @@ public class GATKSAMRecord extends SAMRecord {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the attribute that has the given key.
|
||||
*
|
||||
* Temporary attributes provide a way to label or attach arbitrary data to
|
||||
* individual GATKSAMRecords. These attributes exist in memory only,
|
||||
* and are never written to disk.
|
||||
*
|
||||
* @param key key
|
||||
* @return The value that was associated with this key, or null.
|
||||
*/
|
||||
public Object removeTemporaryAttribute(Object key) {
|
||||
if(temporaryAttributes != null) {
|
||||
return temporaryAttributes.remove(key);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// *** The following methods just call the appropriate method in the record ***//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String getReadName() { return mRecord.getReadName(); }
|
||||
|
||||
public int getReadNameLength() { return mRecord.getReadNameLength(); }
|
||||
|
||||
public void setReadName(String s) { mRecord.setReadName(s); }
|
||||
|
||||
public byte[] getReadBases() { return mRecord.getReadBases(); }
|
||||
|
||||
public void setReadBases(byte[] bytes) { mRecord.setReadBases(bytes); }
|
||||
|
||||
public int getReadLength() { return mRecord.getReadLength(); }
|
||||
|
||||
public byte[] getBaseQualities() { return mRecord.getBaseQualities(); }
|
||||
|
||||
public void setBaseQualities(byte[] bytes) { mRecord.setBaseQualities(bytes); }
|
||||
|
||||
public String getBaseQualityString() { return mRecord.getBaseQualityString(); }
|
||||
|
||||
public void setBaseQualityString(String s) { mRecord.setBaseQualityString(s); }
|
||||
|
||||
public byte[] getOriginalBaseQualities() { return mRecord.getOriginalBaseQualities(); }
|
||||
|
||||
public void setOriginalBaseQualities(byte[] bytes) { mRecord.setOriginalBaseQualities(bytes); }
|
||||
|
||||
public String getReferenceName() { return mRecord.getReferenceName(); }
|
||||
|
||||
public void setReferenceName(String s) { mRecord.setReferenceName(s); }
|
||||
|
||||
public Integer getReferenceIndex() { return mRecord.getReferenceIndex(); }
|
||||
|
||||
public void setReferenceIndex(int i) { mRecord.setReferenceIndex(i); }
|
||||
|
||||
public String getMateReferenceName() { return mRecord.getMateReferenceName(); }
|
||||
|
||||
public void setMateReferenceName(String s) { mRecord.setMateReferenceName(s); }
|
||||
|
||||
public Integer getMateReferenceIndex() { return mRecord.getMateReferenceIndex(); }
|
||||
|
||||
public void setMateReferenceIndex(int i) { mRecord.setMateReferenceIndex(i); }
|
||||
|
||||
public int getAlignmentStart() { return mRecord.getAlignmentStart(); }
|
||||
|
||||
public void setAlignmentStart(int i) { mRecord.setAlignmentStart(i); }
|
||||
|
||||
public int getAlignmentEnd() { return mRecord.getAlignmentEnd(); }
|
||||
|
||||
public int getUnclippedStart() { return mRecord.getUnclippedStart(); }
|
||||
|
||||
public int getUnclippedEnd() { return mRecord.getUnclippedEnd(); }
|
||||
|
||||
public void setAlignmentEnd(int i) { mRecord.setAlignmentEnd(i); }
|
||||
|
||||
public int getMateAlignmentStart() { return mRecord.getMateAlignmentStart(); }
|
||||
|
||||
public void setMateAlignmentStart(int i) { mRecord.setMateAlignmentStart(i); }
|
||||
|
||||
public int getInferredInsertSize() { return mRecord.getInferredInsertSize(); }
|
||||
|
||||
public void setInferredInsertSize(int i) { mRecord.setInferredInsertSize(i); }
|
||||
|
||||
public int getMappingQuality() { return mRecord.getMappingQuality(); }
|
||||
|
||||
public void setMappingQuality(int i) { mRecord.setMappingQuality(i); }
|
||||
|
||||
public String getCigarString() { return mRecord.getCigarString(); }
|
||||
|
||||
public void setCigarString(String s) { mRecord.setCigarString(s); }
|
||||
|
||||
public Cigar getCigar() { return mRecord.getCigar(); }
|
||||
|
||||
public int getCigarLength() { return mRecord.getCigarLength(); }
|
||||
|
||||
public void setCigar(Cigar cigar) { mRecord.setCigar(cigar); }
|
||||
|
||||
public int getFlags() { return mRecord.getFlags(); }
|
||||
|
||||
public void setFlags(int i) { mRecord.setFlags(i); }
|
||||
|
||||
public boolean getReadPairedFlag() { return mRecord.getReadPairedFlag(); }
|
||||
|
||||
public boolean getProperPairFlag() { return mRecord.getProperPairFlag(); }
|
||||
|
||||
public boolean getMateUnmappedFlag() { return mRecord.getMateUnmappedFlag(); }
|
||||
|
||||
public boolean getMateNegativeStrandFlag() { return mRecord.getMateNegativeStrandFlag(); }
|
||||
|
||||
public boolean getFirstOfPairFlag() { return mRecord.getFirstOfPairFlag(); }
|
||||
|
||||
public boolean getNotPrimaryAlignmentFlag() { return mRecord.getNotPrimaryAlignmentFlag(); }
|
||||
|
||||
public boolean getReadFailsVendorQualityCheckFlag() { return mRecord.getReadFailsVendorQualityCheckFlag(); }
|
||||
|
||||
public boolean getDuplicateReadFlag() { return mRecord.getDuplicateReadFlag(); }
|
||||
|
||||
public void setReadPairedFlag(boolean b) { mRecord.setReadPairedFlag(b); }
|
||||
|
||||
public void setProperPairFlag(boolean b) { mRecord.setProperPairFlag(b); }
|
||||
|
||||
public void setMateUnmappedFlag(boolean b) { mRecord.setMateUnmappedFlag(b); }
|
||||
|
||||
public void setMateNegativeStrandFlag(boolean b) { mRecord.setMateNegativeStrandFlag(b); }
|
||||
|
||||
public void setFirstOfPairFlag(boolean b) { mRecord.setFirstOfPairFlag(b); }
|
||||
|
||||
public void setNotPrimaryAlignmentFlag(boolean b) { mRecord.setNotPrimaryAlignmentFlag(b); }
|
||||
|
||||
public void setReadFailsVendorQualityCheckFlag(boolean b) { mRecord.setReadFailsVendorQualityCheckFlag(b); }
|
||||
|
||||
public void setDuplicateReadFlag(boolean b) { mRecord.setDuplicateReadFlag(b); }
|
||||
|
||||
public net.sf.samtools.SAMFileReader.ValidationStringency getValidationStringency() { return mRecord.getValidationStringency(); }
|
||||
|
||||
public void setValidationStringency(net.sf.samtools.SAMFileReader.ValidationStringency validationStringency) { mRecord.setValidationStringency(validationStringency); }
|
||||
|
||||
public Object getAttribute(final String tag) { return mRecord.getAttribute(tag); }
|
||||
|
||||
public Integer getIntegerAttribute(final String tag) {
|
||||
if ( tag == ReadUtils.REDUCED_READ_QUALITY_TAG ) {
|
||||
if ( ! lookedUpReducedReadQuality ) {
|
||||
lookedUpReducedReadQuality = true;
|
||||
reducedReadQuality = mRecord.getIntegerAttribute(tag);
|
||||
}
|
||||
return reducedReadQuality;
|
||||
} else {
|
||||
return mRecord.getIntegerAttribute(tag);
|
||||
}
|
||||
}
|
||||
|
||||
public Short getShortAttribute(final String tag) { return mRecord.getShortAttribute(tag); }
|
||||
|
||||
public Byte getByteAttribute(final String tag) { return mRecord.getByteAttribute(tag); }
|
||||
|
||||
public String getStringAttribute(final String tag) { return mRecord.getStringAttribute(tag); }
|
||||
|
||||
public Character getCharacterAttribute(final String tag) { return mRecord.getCharacterAttribute(tag); }
|
||||
|
||||
public Float getFloatAttribute(final String tag) { return mRecord.getFloatAttribute(tag); }
|
||||
|
||||
public byte[] getByteArrayAttribute(final String tag) { return mRecord.getByteArrayAttribute(tag); }
|
||||
|
||||
protected Object getAttribute(final short tag) {
|
||||
Object attribute;
|
||||
try {
|
||||
Method method = mRecord.getClass().getDeclaredMethod("getAttribute",Short.TYPE);
|
||||
method.setAccessible(true);
|
||||
attribute = method.invoke(mRecord,tag);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
throw new ReviewedStingException("Unable to invoke getAttribute method",ex);
|
||||
}
|
||||
return attribute;
|
||||
}
|
||||
|
||||
public void setAttribute(final String tag, final Object value) { mRecord.setAttribute(tag,value); }
|
||||
|
||||
protected void setAttribute(final short tag, final Object value) {
|
||||
try {
|
||||
Method method = mRecord.getClass().getDeclaredMethod("setAttribute",Short.TYPE,Object.class);
|
||||
method.setAccessible(true);
|
||||
method.invoke(mRecord,tag,value);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
throw new ReviewedStingException("Unable to invoke setAttribute method",ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearAttributes() { mRecord.clearAttributes(); }
|
||||
|
||||
protected void setAttributes(final SAMBinaryTagAndValue attributes) {
|
||||
try {
|
||||
Method method = mRecord.getClass().getDeclaredMethod("setAttributes",SAMBinaryTagAndValue.class);
|
||||
method.setAccessible(true);
|
||||
method.invoke(mRecord,attributes);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
throw new ReviewedStingException("Unable to invoke setAttributes method",ex);
|
||||
}
|
||||
}
|
||||
|
||||
protected SAMBinaryTagAndValue getBinaryAttributes() {
|
||||
SAMBinaryTagAndValue binaryAttributes;
|
||||
try {
|
||||
Method method = mRecord.getClass().getDeclaredMethod("getBinaryAttributes");
|
||||
method.setAccessible(true);
|
||||
binaryAttributes = (SAMBinaryTagAndValue)method.invoke(mRecord);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
throw new ReviewedStingException("Unable to invoke getBinaryAttributes method",ex);
|
||||
}
|
||||
return binaryAttributes;
|
||||
}
|
||||
|
||||
public List<SAMTagAndValue> getAttributes() { return mRecord.getAttributes(); }
|
||||
|
||||
public SAMFileHeader getHeader() { return mRecord.getHeader(); }
|
||||
|
||||
public void setHeader(SAMFileHeader samFileHeader) { mRecord.setHeader(samFileHeader); }
|
||||
|
||||
public byte[] getVariableBinaryRepresentation() { return mRecord.getVariableBinaryRepresentation(); }
|
||||
|
||||
public int getAttributesBinarySize() { return mRecord.getAttributesBinarySize(); }
|
||||
|
||||
public String format() { return mRecord.format(); }
|
||||
|
||||
public List<AlignmentBlock> getAlignmentBlocks() { return mRecord.getAlignmentBlocks(); }
|
||||
|
||||
public List<SAMValidationError> validateCigar(long l) { return mRecord.validateCigar(l); }
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
||||
// note -- this forbids a GATKSAMRecord being equal to its underlying SAMRecord
|
||||
if (!(o instanceof GATKSAMRecord)) return false;
|
||||
if (!(o instanceof GATKSamRecord)) return false;
|
||||
|
||||
// note that we do not consider the GATKSAMRecord internal state at all
|
||||
return mRecord.equals(((GATKSAMRecord)o).mRecord);
|
||||
}
|
||||
|
||||
public int hashCode() { return mRecord.hashCode(); }
|
||||
|
||||
public List<SAMValidationError> isValid() { return mRecord.isValid(); }
|
||||
|
||||
public Object clone() throws CloneNotSupportedException { return mRecord.clone(); }
|
||||
|
||||
public String toString() { return mRecord.toString(); }
|
||||
|
||||
public SAMFileSource getFileSource() { return mRecord.getFileSource(); }
|
||||
|
||||
/**
|
||||
* Sets a marker providing the source reader for this file and the position in the file from which the read originated.
|
||||
* @param fileSource source of the given file.
|
||||
*/
|
||||
@Override
|
||||
protected void setFileSource(final SAMFileSource fileSource) {
|
||||
try {
|
||||
Method method = SAMRecord.class.getDeclaredMethod("setFileSource",SAMFileSource.class);
|
||||
method.setAccessible(true);
|
||||
method.invoke(mRecord,fileSource);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
throw new ReviewedStingException("Unable to invoke setFileSource method",ex);
|
||||
}
|
||||
return super.equals(o);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,18 +57,18 @@ public class GATKSamRecordFactory implements SAMRecordFactory {
|
|||
final int mateAlignmentStart,
|
||||
final int insertSize,
|
||||
final byte[] variableLengthBlock) {
|
||||
return new BAMRecord(header,
|
||||
referenceSequenceIndex,
|
||||
alignmentStart,
|
||||
readNameLength,
|
||||
mappingQuality,
|
||||
indexingBin,
|
||||
cigarLen,
|
||||
flags,
|
||||
readLen,
|
||||
mateReferenceSequenceIndex,
|
||||
mateAlignmentStart,
|
||||
insertSize,
|
||||
variableLengthBlock);
|
||||
return new GATKSamRecord(header,
|
||||
referenceSequenceIndex,
|
||||
alignmentStart,
|
||||
readNameLength,
|
||||
mappingQuality,
|
||||
indexingBin,
|
||||
cigarLen,
|
||||
flags,
|
||||
readLen,
|
||||
mateReferenceSequenceIndex,
|
||||
mateAlignmentStart,
|
||||
insertSize,
|
||||
variableLengthBlock);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -274,10 +274,10 @@ public class ReadUtils {
|
|||
* @param adaptorLength length of adaptor sequence
|
||||
* @return a new read with adaptor sequence hard-clipped out or null if read is fully clipped
|
||||
*/
|
||||
public static GATKSAMRecord hardClipAdaptorSequence(final SAMRecord rec, int adaptorLength) {
|
||||
public static GATKSamRecord hardClipAdaptorSequence(final SAMRecord rec, int adaptorLength) {
|
||||
|
||||
Pair<Integer, Integer> adaptorBoundaries = getAdaptorBoundaries(rec, adaptorLength);
|
||||
GATKSAMRecord result = (GATKSAMRecord)rec;
|
||||
GATKSamRecord result = (GATKSamRecord)rec;
|
||||
|
||||
if ( adaptorBoundaries != null ) {
|
||||
if ( rec.getReadNegativeStrandFlag() && adaptorBoundaries.second >= rec.getAlignmentStart() && adaptorBoundaries.first < rec.getAlignmentEnd() )
|
||||
|
|
@ -290,7 +290,7 @@ public class ReadUtils {
|
|||
}
|
||||
|
||||
// return true if the read needs to be completely clipped
|
||||
private static GATKSAMRecord hardClipStartOfRead(SAMRecord oldRec, int stopPosition) {
|
||||
private static GATKSamRecord hardClipStartOfRead(SAMRecord oldRec, int stopPosition) {
|
||||
|
||||
if ( stopPosition >= oldRec.getAlignmentEnd() ) {
|
||||
// BAM representation issue -- we can't clip away all bases in a read, just leave it alone and let the filter deal with it
|
||||
|
|
@ -298,9 +298,9 @@ public class ReadUtils {
|
|||
return null;
|
||||
}
|
||||
|
||||
GATKSAMRecord rec;
|
||||
GATKSamRecord rec;
|
||||
try {
|
||||
rec = (GATKSAMRecord)oldRec.clone();
|
||||
rec = (GATKSamRecord)oldRec.clone();
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -370,7 +370,7 @@ public class ReadUtils {
|
|||
return rec;
|
||||
}
|
||||
|
||||
private static GATKSAMRecord hardClipEndOfRead(SAMRecord oldRec, int startPosition) {
|
||||
private static GATKSamRecord hardClipEndOfRead(SAMRecord oldRec, int startPosition) {
|
||||
|
||||
if ( startPosition <= oldRec.getAlignmentStart() ) {
|
||||
// BAM representation issue -- we can't clip away all bases in a read, just leave it alone and let the filter deal with it
|
||||
|
|
@ -378,9 +378,9 @@ public class ReadUtils {
|
|||
return null;
|
||||
}
|
||||
|
||||
GATKSAMRecord rec;
|
||||
GATKSamRecord rec;
|
||||
try {
|
||||
rec = (GATKSAMRecord)oldRec.clone();
|
||||
rec = (GATKSamRecord)oldRec.clone();
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -598,7 +598,7 @@ public class ReadUtils {
|
|||
* @param rec original SAM record
|
||||
* @return a new read with adaptor sequence hard-clipped out or null if read is fully clipped
|
||||
*/
|
||||
public static GATKSAMRecord hardClipAdaptorSequence(final SAMRecord rec) {
|
||||
public static GATKSamRecord hardClipAdaptorSequence(final SAMRecord rec) {
|
||||
return hardClipAdaptorSequence(rec, DEFAULT_ADAPTOR_SIZE);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue