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-03-29 04:37:27 +08:00
|
|
|
import org.broadinstitute.sting.utils.cmdLine.Argument;
|
2009-04-01 08:47:47 +08:00
|
|
|
import org.broadinstitute.sting.utils.Utils;
|
2009-03-16 06:42:24 +08:00
|
|
|
import net.sf.samtools.SAMRecord;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
2009-04-01 08:47:47 +08:00
|
|
|
import java.util.ArrayList;
|
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-03-27 00:22:35 +08:00
|
|
|
public class PileupWalker extends LocusWalker<Integer, Integer> {
|
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?
|
|
|
|
|
public boolean filter(List<ReferenceOrderedDatum> rodData, char ref, LocusContext context) {
|
|
|
|
|
return true; // We are keeping all the reads
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Integer map(List<ReferenceOrderedDatum> rodData, char ref, LocusContext context) {
|
|
|
|
|
List<SAMRecord> reads = context.getReads();
|
|
|
|
|
List<Integer> offsets = context.getOffsets();
|
2009-04-01 08:47:47 +08:00
|
|
|
String bases = Utils.basePileupAsString(reads, offsets);
|
|
|
|
|
String quals = Utils.qualPileupAsString(reads, offsets);
|
2009-03-16 06:42:24 +08:00
|
|
|
|
2009-03-29 04:37:27 +08:00
|
|
|
if ( bases.equals("") && FLAG_UNCOVERED_BASES ) {
|
|
|
|
|
bases = "*** UNCOVERED SITE ***";
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-16 06:42:24 +08:00
|
|
|
String rodString = "";
|
|
|
|
|
for ( ReferenceOrderedDatum datum : rodData ) {
|
|
|
|
|
if ( datum != null ) {
|
|
|
|
|
if ( datum instanceof rodDbSNP) {
|
|
|
|
|
rodDbSNP dbsnp = (rodDbSNP)datum;
|
|
|
|
|
rodString += dbsnp.toMediumString();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
rodString += datum.toSimpleString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ( rodString != "" )
|
|
|
|
|
rodString = "[ROD: " + rodString + "]";
|
|
|
|
|
|
2009-03-27 08:12:35 +08:00
|
|
|
//if ( context.getLocation().getStart() % 1 == 0 ) {
|
2009-03-27 23:03:32 +08:00
|
|
|
out.printf("%s: %s %s %s %s%n", context.getLocation(), ref, bases, quals, rodString);
|
2009-03-27 08:12:35 +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) {
|
|
|
|
|
return value + sum;
|
|
|
|
|
}
|
|
|
|
|
}
|