2009-03-16 06:42:24 +08:00
|
|
|
package org.broadinstitute.sting.gatk.walkers;
|
|
|
|
|
|
|
|
|
|
import org.broadinstitute.sting.gatk.LocusContext;
|
|
|
|
|
import org.broadinstitute.sting.gatk.refdata.ReferenceOrderedDatum;
|
|
|
|
|
import org.broadinstitute.sting.gatk.refdata.rodDbSNP;
|
2009-04-04 03:54:54 +08:00
|
|
|
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
2009-03-29 04:37:27 +08:00
|
|
|
import org.broadinstitute.sting.utils.cmdLine.Argument;
|
2009-04-15 06:13:10 +08:00
|
|
|
import org.broadinstitute.sting.utils.ReadBackedPileup;
|
2009-03-16 06:42:24 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Created by IntelliJ IDEA.
|
|
|
|
|
* User: mdepristo
|
|
|
|
|
* Date: Feb 22, 2009
|
|
|
|
|
* Time: 3:22:14 PM
|
|
|
|
|
* To change this template use File | Settings | File Templates.
|
|
|
|
|
*/
|
2009-05-02 05:40:46 +08:00
|
|
|
public class PileupWalker extends LocusWalker<Integer, Integer> implements TreeReducible<Integer> {
|
2009-05-06 06:43:40 +08:00
|
|
|
@Argument(fullName="verbose",doc="verbose",required=false,defaultValue="false")
|
2009-04-14 08:54:48 +08:00
|
|
|
public boolean VERBOSE;
|
2009-04-22 06:27:26 +08:00
|
|
|
|
2009-05-06 06:43:40 +08:00
|
|
|
@Argument(fullName="extended",shortName="ext",doc="extended",required=false,defaultValue="false")
|
2009-04-22 06:27:26 +08:00
|
|
|
public boolean EXTENDED;
|
2009-04-14 08:54:48 +08:00
|
|
|
|
2009-03-29 04:37:27 +08:00
|
|
|
public boolean FLAG_UNCOVERED_BASES = true; // todo: how do I make this a command line argument?
|
|
|
|
|
|
2009-03-16 06:42:24 +08:00
|
|
|
public void initialize() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Do we actually want to operate on the context?
|
2009-04-04 03:54:54 +08:00
|
|
|
public boolean filter(RefMetaDataTracker tracker, char ref, LocusContext context) {
|
2009-03-16 06:42:24 +08:00
|
|
|
return true; // We are keeping all the reads
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-04 03:54:54 +08:00
|
|
|
public Integer map(RefMetaDataTracker tracker, char ref, LocusContext context) {
|
2009-04-15 06:21:36 +08:00
|
|
|
ReadBackedPileup pileup = new ReadBackedPileup(ref, context);
|
2009-04-15 06:13:10 +08:00
|
|
|
String bases = pileup.getBases();
|
|
|
|
|
|
2009-03-29 04:37:27 +08:00
|
|
|
if ( bases.equals("") && FLAG_UNCOVERED_BASES ) {
|
|
|
|
|
bases = "*** UNCOVERED SITE ***";
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-14 08:54:48 +08:00
|
|
|
String extras = "";
|
|
|
|
|
if ( VERBOSE ) {
|
2009-04-15 06:13:10 +08:00
|
|
|
extras += " BQ=" + pileup.getQualsAsInts();
|
|
|
|
|
extras += " MQ=" + pileup.getMappingQualsAsInts();
|
2009-04-14 08:54:48 +08:00
|
|
|
}
|
|
|
|
|
|
2009-03-16 06:42:24 +08:00
|
|
|
String rodString = "";
|
2009-04-04 03:54:54 +08:00
|
|
|
for ( ReferenceOrderedDatum datum : tracker.getAllRods() ) {
|
|
|
|
|
if ( datum != null && ! (datum instanceof rodDbSNP)) {
|
2009-04-15 06:13:10 +08:00
|
|
|
//System.out.printf("rod = %s%n", datum.toSimpleString());
|
2009-04-04 03:54:54 +08:00
|
|
|
rodString += datum.toSimpleString();
|
2009-04-15 06:13:10 +08:00
|
|
|
//System.out.printf("Rod string %s%n", rodString);
|
2009-03-16 06:42:24 +08:00
|
|
|
}
|
|
|
|
|
}
|
2009-04-15 06:13:10 +08:00
|
|
|
|
2009-04-04 03:54:54 +08:00
|
|
|
rodDbSNP dbsnp = (rodDbSNP)tracker.lookup("dbSNP", null);
|
|
|
|
|
if ( dbsnp != null )
|
|
|
|
|
rodString += dbsnp.toMediumString();
|
|
|
|
|
|
2009-03-16 06:42:24 +08:00
|
|
|
if ( rodString != "" )
|
|
|
|
|
rodString = "[ROD: " + rodString + "]";
|
|
|
|
|
|
2009-03-27 08:12:35 +08:00
|
|
|
//if ( context.getLocation().getStart() % 1 == 0 ) {
|
2009-04-15 06:13:10 +08:00
|
|
|
out.printf("%s%s %s%n", pileup.getPileupString(), extras, rodString);
|
2009-03-27 08:12:35 +08:00
|
|
|
//}
|
2009-03-16 06:42:24 +08:00
|
|
|
|
2009-04-22 06:27:26 +08:00
|
|
|
if ( EXTENDED ) {
|
|
|
|
|
String probDists = pileup.getProbDistPileup();
|
2009-05-02 05:40:46 +08:00
|
|
|
out.println(probDists);
|
2009-04-22 06:27:26 +08:00
|
|
|
}
|
|
|
|
|
|
2009-03-16 06:42:24 +08:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Given result of map function
|
|
|
|
|
public Integer reduceInit() { return 0; }
|
|
|
|
|
public Integer reduce(Integer value, Integer sum) {
|
2009-05-02 05:40:46 +08:00
|
|
|
return reduce(sum,value);
|
|
|
|
|
}
|
|
|
|
|
public Integer treeReduce(Integer lhs, Integer rhs) {
|
|
|
|
|
return lhs + rhs;
|
2009-03-16 06:42:24 +08:00
|
|
|
}
|
|
|
|
|
}
|