Preserve RG information on new GATKSAMRecord from SAMRecord

This commit is contained in:
Mauricio Carneiro 2011-11-09 12:46:27 -05:00
parent f9530e0768
commit f080f64f99
1 changed files with 43 additions and 21 deletions

View File

@ -87,7 +87,12 @@ public class GATKSAMRecord extends BAMRecord {
read.getMateAlignmentStart(),
read.getInferredInsertSize(),
null);
super.clearAttributes();
SAMReadGroupRecord samRG = read.getReadGroup();
clearAttributes();
if (samRG != null) {
GATKSAMReadGroupRecord rg = new GATKSAMReadGroupRecord(samRG);
setReadGroup(rg);
}
}
public GATKSAMRecord(final SAMFileHeader header,
@ -134,6 +139,21 @@ public class GATKSAMRecord extends BAMRecord {
return mReadGroup;
}
@Override
public int hashCode() {
return super.hashCode();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof GATKSAMRecord)) return false;
// note that we do not consider the GATKSAMRecord internal state at all
return super.equals(o);
}
/**
* Efficient caching accessor that returns the GATK NGSPlatform of this read
* @return
@ -147,11 +167,9 @@ public class GATKSAMRecord extends BAMRecord {
retrievedReadGroup = true;
}
//
//
// Reduced read functions
//
//
///////////////////////////////////////////////////////////////////////////////
// *** ReduceReads functions ***//
///////////////////////////////////////////////////////////////////////////////
public byte[] getReducedReadCounts() {
if ( ! retrievedReduceReadCounts ) {
@ -170,6 +188,12 @@ public class GATKSAMRecord extends BAMRecord {
return getReducedReadCounts()[i];
}
///////////////////////////////////////////////////////////////////////////////
// *** GATKSAMRecord specific methods ***//
///////////////////////////////////////////////////////////////////////////////
/**
* Checks whether an attribute has been set for the given key.
*
@ -223,28 +247,26 @@ public class GATKSAMRecord extends BAMRecord {
return null;
}
@Override
public int hashCode() {
return super.hashCode();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof GATKSAMRecord)) return false;
// note that we do not consider the GATKSAMRecord internal state at all
return super.equals(o);
}
/**
* Checks whether if the read has any bases.
*
* Empty reads can be dangerous as it may have no cigar strings, no read names and
* other missing attributes.
*
* @return true if the read has no bases
*/
public boolean isEmpty() {
return this.getReadLength() == 0;
}
/**
* Clears all attributes except ReadGroup of the read.
*/
public void simplify () {
GATKSAMReadGroupRecord rg = getReadGroup();
this.clearAttributes();
setReadGroup(rg);
}
}