Compute and cache the length of the longest deletion observed at the site; ReadBackedExtendedEventPileup now has a getter to access that value.
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2487 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
9c41ac252f
commit
89791d730e
|
|
@ -320,15 +320,21 @@ public class LocusIteratorByState extends LocusIterator {
|
||||||
if ( readInfo.generateExtendedEvents() && hasExtendedEvents ) {
|
if ( readInfo.generateExtendedEvents() && hasExtendedEvents ) {
|
||||||
ArrayList<ExtendedEventPileupElement> indelPile = new ArrayList<ExtendedEventPileupElement>(readStates.size());
|
ArrayList<ExtendedEventPileupElement> indelPile = new ArrayList<ExtendedEventPileupElement>(readStates.size());
|
||||||
|
|
||||||
|
int maxDeletionLength = 0;
|
||||||
|
|
||||||
for ( SAMRecordState state : readStates ) {
|
for ( SAMRecordState state : readStates ) {
|
||||||
if ( state.hadIndel() ) {
|
if ( state.hadIndel() ) {
|
||||||
size++;
|
size++;
|
||||||
if ( state.getEventBases() == null ) nDeletions++;
|
if ( state.getEventBases() == null ) {
|
||||||
|
nDeletions++;
|
||||||
|
maxDeletionLength = Math.max(maxDeletionLength,state.getEventLength());
|
||||||
|
}
|
||||||
else nInsertions++;
|
else nInsertions++;
|
||||||
indelPile.add ( new ExtendedEventPileupElement(state.getRead(),
|
indelPile.add ( new ExtendedEventPileupElement(state.getRead(),
|
||||||
state.getReadEventStartOffset(),
|
state.getReadEventStartOffset(),
|
||||||
state.getEventLength(),
|
state.getEventLength(),
|
||||||
state.getEventBases()) );
|
state.getEventBases()) );
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if ( state.getCurrentCigarOperator() != CigarOperator.N ) {
|
if ( state.getCurrentCigarOperator() != CigarOperator.N ) {
|
||||||
// this read has no indel associated with the previous position on the ref;
|
// this read has no indel associated with the previous position on the ref;
|
||||||
|
|
@ -358,7 +364,7 @@ public class LocusIteratorByState extends LocusIterator {
|
||||||
GenomeLoc loc = GenomeLocParser.incPos(our1stState.getLocation(),-1);
|
GenomeLoc loc = GenomeLocParser.incPos(our1stState.getLocation(),-1);
|
||||||
// System.out.println("Indel(s) at "+loc);
|
// System.out.println("Indel(s) at "+loc);
|
||||||
// for ( ExtendedEventPileupElement pe : indelPile ) { if ( pe.isIndel() ) System.out.println(" "+pe.toString()); }
|
// for ( ExtendedEventPileupElement pe : indelPile ) { if ( pe.isIndel() ) System.out.println(" "+pe.toString()); }
|
||||||
return new AlignmentContext(loc, new ReadBackedExtendedEventPileup(loc, indelPile, size, nInsertions, nDeletions, nMQ0Reads));
|
return new AlignmentContext(loc, new ReadBackedExtendedEventPileup(loc, indelPile, size, maxDeletionLength, nInsertions, nDeletions, nMQ0Reads));
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
ArrayList<PileupElement> pile = new ArrayList<PileupElement>(readStates.size());
|
ArrayList<PileupElement> pile = new ArrayList<PileupElement>(readStates.size());
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ public class ReadBackedExtendedEventPileup implements Iterable<ExtendedEventPile
|
||||||
private ArrayList<ExtendedEventPileupElement> pileup = null;
|
private ArrayList<ExtendedEventPileupElement> pileup = null;
|
||||||
|
|
||||||
private int size = 0; // cached value of the size of the pileup
|
private int size = 0; // cached value of the size of the pileup
|
||||||
|
private int maxDeletionLength = 0; // cached value of the length of the longest deletion observed at the site
|
||||||
private int nDeletions = 0; // cached value of the number of deletions
|
private int nDeletions = 0; // cached value of the number of deletions
|
||||||
private int nInsertions = 0;
|
private int nInsertions = 0;
|
||||||
private int nMQ0Reads = 0; // cached value of the number of MQ0 reads
|
private int nMQ0Reads = 0; // cached value of the number of MQ0 reads
|
||||||
|
|
@ -53,13 +54,15 @@ public class ReadBackedExtendedEventPileup implements Iterable<ExtendedEventPile
|
||||||
* @param loc
|
* @param loc
|
||||||
* @param pileup
|
* @param pileup
|
||||||
*/
|
*/
|
||||||
public ReadBackedExtendedEventPileup(GenomeLoc loc, ArrayList<ExtendedEventPileupElement> pileup, int size, int nInsertions, int nDeletions, int nMQ0Reads ) {
|
public ReadBackedExtendedEventPileup(GenomeLoc loc, ArrayList<ExtendedEventPileupElement> pileup, int size,
|
||||||
|
int maxDeletionLength, int nInsertions, int nDeletions, int nMQ0Reads ) {
|
||||||
if ( loc == null ) throw new StingException("Illegal null genomeloc in ReadBackedExtendedEventPileup");
|
if ( loc == null ) throw new StingException("Illegal null genomeloc in ReadBackedExtendedEventPileup");
|
||||||
if ( pileup == null ) throw new StingException("Illegal null pileup in ReadBackedExtendedEventPileup");
|
if ( pileup == null ) throw new StingException("Illegal null pileup in ReadBackedExtendedEventPileup");
|
||||||
|
|
||||||
this.loc = loc;
|
this.loc = loc;
|
||||||
this.pileup = pileup;
|
this.pileup = pileup;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
|
this.maxDeletionLength = maxDeletionLength;
|
||||||
this.nDeletions = nDeletions;
|
this.nDeletions = nDeletions;
|
||||||
this.nInsertions = nInsertions;
|
this.nInsertions = nInsertions;
|
||||||
this.nMQ0Reads = nMQ0Reads;
|
this.nMQ0Reads = nMQ0Reads;
|
||||||
|
|
@ -78,9 +81,11 @@ public class ReadBackedExtendedEventPileup implements Iterable<ExtendedEventPile
|
||||||
nMQ0Reads = 0;
|
nMQ0Reads = 0;
|
||||||
|
|
||||||
for ( ExtendedEventPileupElement p : this ) {
|
for ( ExtendedEventPileupElement p : this ) {
|
||||||
|
|
||||||
size++;
|
size++;
|
||||||
if ( p.isDeletion() ) {
|
if ( p.isDeletion() ) {
|
||||||
nDeletions++;
|
nDeletions++;
|
||||||
|
maxDeletionLength = Math.max(maxDeletionLength, p.getEventLength());
|
||||||
} else {
|
} else {
|
||||||
if ( p.isInsertion() ) nInsertions++;
|
if ( p.isInsertion() ) nInsertions++;
|
||||||
}
|
}
|
||||||
|
|
@ -200,6 +205,16 @@ public class ReadBackedExtendedEventPileup implements Iterable<ExtendedEventPile
|
||||||
return nInsertions;
|
return nInsertions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Returns the length of the longest deletion observed at the site this
|
||||||
|
* pileup is associated with (NOTE: by convention, both insertions and deletions
|
||||||
|
* are associated with genomic location immediately before the actual event). If
|
||||||
|
* there are no deletions at the site, returns 0.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int getMaxDeletionLength() {
|
||||||
|
return maxDeletionLength;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Returns the number of mapping quality zero reads in this pileup.
|
* Returns the number of mapping quality zero reads in this pileup.
|
||||||
* @return
|
* @return
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue