Preserve RG information on new GATKSAMRecord from SAMRecord
This commit is contained in:
parent
f9530e0768
commit
f080f64f99
|
|
@ -87,7 +87,12 @@ public class GATKSAMRecord extends BAMRecord {
|
||||||
read.getMateAlignmentStart(),
|
read.getMateAlignmentStart(),
|
||||||
read.getInferredInsertSize(),
|
read.getInferredInsertSize(),
|
||||||
null);
|
null);
|
||||||
super.clearAttributes();
|
SAMReadGroupRecord samRG = read.getReadGroup();
|
||||||
|
clearAttributes();
|
||||||
|
if (samRG != null) {
|
||||||
|
GATKSAMReadGroupRecord rg = new GATKSAMReadGroupRecord(samRG);
|
||||||
|
setReadGroup(rg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public GATKSAMRecord(final SAMFileHeader header,
|
public GATKSAMRecord(final SAMFileHeader header,
|
||||||
|
|
@ -134,6 +139,21 @@ public class GATKSAMRecord extends BAMRecord {
|
||||||
return mReadGroup;
|
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
|
* Efficient caching accessor that returns the GATK NGSPlatform of this read
|
||||||
* @return
|
* @return
|
||||||
|
|
@ -147,11 +167,9 @@ public class GATKSAMRecord extends BAMRecord {
|
||||||
retrievedReadGroup = true;
|
retrievedReadGroup = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
// *** ReduceReads functions ***//
|
||||||
// Reduced read functions
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
|
||||||
//
|
|
||||||
|
|
||||||
public byte[] getReducedReadCounts() {
|
public byte[] getReducedReadCounts() {
|
||||||
if ( ! retrievedReduceReadCounts ) {
|
if ( ! retrievedReduceReadCounts ) {
|
||||||
|
|
@ -170,6 +188,12 @@ public class GATKSAMRecord extends BAMRecord {
|
||||||
return getReducedReadCounts()[i];
|
return getReducedReadCounts()[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// *** GATKSAMRecord specific methods ***//
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether an attribute has been set for the given key.
|
* Checks whether an attribute has been set for the given key.
|
||||||
*
|
*
|
||||||
|
|
@ -223,28 +247,26 @@ public class GATKSAMRecord extends BAMRecord {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public int hashCode() {
|
* Checks whether if the read has any bases.
|
||||||
return super.hashCode();
|
*
|
||||||
}
|
* Empty reads can be dangerous as it may have no cigar strings, no read names and
|
||||||
|
* other missing attributes.
|
||||||
@Override
|
*
|
||||||
public boolean equals(Object o) {
|
* @return true if the read has no bases
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
return this.getReadLength() == 0;
|
return this.getReadLength() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears all attributes except ReadGroup of the read.
|
||||||
|
*/
|
||||||
public void simplify () {
|
public void simplify () {
|
||||||
GATKSAMReadGroupRecord rg = getReadGroup();
|
GATKSAMReadGroupRecord rg = getReadGroup();
|
||||||
this.clearAttributes();
|
this.clearAttributes();
|
||||||
setReadGroup(rg);
|
setReadGroup(rg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue