IndelCounterWalker -- a new little walker that counts indels over a region (want to see what kind of havoc BWA may be resulting in). Don't know when BasicPileup.indelPileup() was written, but kudos to whoever wrote it.

BTTJ - remove 'N's from previous base analysis -- even if both read and ref are 'N' (which does happen, occasionally)




git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1925 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
chartl 2009-10-28 19:50:50 +00:00
parent 04e9a494e9
commit 863d3023d5
2 changed files with 53 additions and 1 deletions

View File

@ -246,7 +246,7 @@ public class BaseTransitionTableCalculatorJavaWalker extends LocusWalker<Set<Bas
}
for ( int prevBase = 1; prevBase <= nPreviousBases; prevBase ++ ) {
if ( Character.toUpperCase(read.getReadBases()[offset + prevBase*c]) != Character.toUpperCase(ref.getBases()[nPreviousBases+1+prevBase*c]) ) {
if ( Character.toUpperCase(read.getReadBases()[offset + prevBase*c]) != Character.toUpperCase(ref.getBases()[nPreviousBases+1+prevBase*c]) || ! BaseUtils.isRegularBase(ref.getBases()[nPreviousBases+1+prevBase*c])) {
return true;
}
}

View File

@ -0,0 +1,52 @@
package org.broadinstitute.sting.playground.gatk.walkers;
import org.broadinstitute.sting.gatk.walkers.LocusWalker;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.utils.ReadBackedPileup;
import org.broadinstitute.sting.utils.BaseUtils;
import org.broadinstitute.sting.utils.BasicPileup;
/**
* Created by IntelliJ IDEA.
* User: chartl
* Date: Oct 28, 2009
* Time: 3:19:48 PM
* To change this template use File | Settings | File Templates.
*/
public class IndelCounterWalker extends LocusWalker<Integer,Integer> {
public Integer reduceInit() {
return 0;
}
public Integer reduce( Integer prevReduce, Integer map ) {
return map + prevReduce;
}
public Integer treeReduce( Integer reduce1, Integer reduce2 ) {
return reduce(reduce1,reduce2);
}
public Integer map ( RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context ) {
if (BaseUtils.isRegularBase(ref.getBase()) ) {
return numIndels(context);
} else {
return 0;
}
}
public Integer numIndels ( AlignmentContext context ) {
String[] indelPileup = BasicPileup.indelPileup(context.getReads(),context.getOffsets());
// number of indels is the number of non-"null" indeces
int nIndel = 0;
for( String indel : indelPileup ) {
if ( ! indel.equals("null") ) { // currently how non-indel bases are represented in pileup
nIndel ++;
}
}
return nIndel;
}
}