Moved avg depth of coverage functionality into the core depth of coverage
walker. Used new command line args for walkers. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@234 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
007ecc8616
commit
3896cc8f17
|
|
@ -2,7 +2,8 @@ package org.broadinstitute.sting.gatk.walkers;
|
|||
|
||||
import org.broadinstitute.sting.gatk.LocusContext;
|
||||
import org.broadinstitute.sting.gatk.refdata.ReferenceOrderedDatum;
|
||||
|
||||
import org.broadinstitute.sting.utils.cmdLine.Argument;
|
||||
import org.broadinstitute.sting.utils.Pair;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -12,15 +13,25 @@ import java.util.List;
|
|||
* Time: 3:22:14 PM
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class DepthOfCoverageWalker extends LocusWalker<Integer, Integer> {
|
||||
public class DepthOfCoverageWalker extends LocusWalker<Integer, Pair<Long, Long>> {
|
||||
@Argument(fullName="printall",required=false,defaultValue="true")
|
||||
public String printAllLoci; // booleans don't work
|
||||
|
||||
public Integer map(List<ReferenceOrderedDatum> rodData, char ref, LocusContext context) {
|
||||
out.printf("%s: %d%n", context.getLocation(), context.getReads().size() );
|
||||
return 1;
|
||||
if (printAllLoci.equals("true"))
|
||||
out.printf("%s: %d%n", context.getLocation(), context.getReads().size() );
|
||||
return context.getReads().size();
|
||||
}
|
||||
|
||||
public Integer reduceInit() { return 0; }
|
||||
public Pair<Long, Long> reduceInit() { return new Pair<Long, Long>((long)0,(long)0); }
|
||||
|
||||
public Integer reduce(Integer value, Integer sum) {
|
||||
return value + sum;
|
||||
public Pair<Long, Long> reduce(Integer value, Pair<Long, Long> sum) {
|
||||
long left = new Long(value.longValue() + sum.getFirst().longValue());
|
||||
long right = new Long(sum.getSecond().longValue() + 1);
|
||||
return new Pair<Long, Long>(left, right);
|
||||
}
|
||||
|
||||
public void onTraversalDone(Pair<Long, Long> result) {
|
||||
out.println("Average depth of coverage is: " + ((double)result.getFirst() / (double)result.getSecond()));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
package org.broadinstitute.sting.playground.gatk.walkers;
|
||||
|
||||
import org.broadinstitute.sting.utils.Pair;
|
||||
import org.broadinstitute.sting.gatk.LocusContext;
|
||||
import org.broadinstitute.sting.gatk.refdata.ReferenceOrderedDatum;
|
||||
import org.broadinstitute.sting.gatk.walkers.LocusWalker;
|
||||
import org.broadinstitute.sting.gatk.walkers.WalkerName;
|
||||
import java.util.List;
|
||||
|
||||
@WalkerName("Average_Depth_Of_Coverage")
|
||||
public class AvgDepthOfCoverageWalker extends LocusWalker<Integer, Pair<Long, Long>> {
|
||||
|
||||
public Integer map(List<ReferenceOrderedDatum> rodData, char ref, LocusContext context) {
|
||||
return context.getReads().size();
|
||||
}
|
||||
|
||||
public Pair<Long, Long> reduceInit() { return new Pair<Long, Long>((long)0,(long)0); }
|
||||
|
||||
public Pair<Long, Long> reduce(Integer value, Pair<Long, Long> sum) {
|
||||
long left = new Long(value.longValue() + sum.getFirst().longValue());
|
||||
long right = new Long(sum.getSecond().longValue() + 1);
|
||||
return new Pair<Long, Long>(left, right);
|
||||
}
|
||||
|
||||
public void onTraversalDone(Pair<Long, Long> result) {
|
||||
System.out.println("Average depth of coverage is: " + ((double)result.getFirst() / (double)result.getSecond()));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue