From ff4a0764df9a479246bd227c167c66ac7c9165aa Mon Sep 17 00:00:00 2001 From: chartl Date: Thu, 27 May 2010 19:00:09 +0000 Subject: [PATCH] Read error rate is now parallelizable git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3447 348d0f76-0448-11de-a6fe-93d51630548a --- .../walkers/ReadErrorRateWalker.java | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/ReadErrorRateWalker.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/ReadErrorRateWalker.java index 92aca4643..a159f821d 100755 --- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/ReadErrorRateWalker.java +++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/ReadErrorRateWalker.java @@ -29,11 +29,13 @@ import org.broadinstitute.sting.gatk.refdata.ReadMetaDataTracker; import org.broadinstitute.sting.gatk.walkers.ReadWalker; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.commandline.Argument; +import org.broadinstitute.sting.gatk.walkers.TreeReducible; import org.broadinstitute.sting.utils.QualityUtils; import org.broadinstitute.sting.utils.BaseUtils; import net.sf.samtools.SAMRecord; import java.util.HashMap; +import java.util.Map; import java.util.Random; /** @@ -45,7 +47,7 @@ import java.util.Random; * * @author Kiran Garimella */ -public class ReadErrorRateWalker extends ReadWalker { +public class ReadErrorRateWalker extends ReadWalker implements TreeReducible { @Argument(fullName="printVisualHits", shortName="v", doc="print visual hits", required=false) public boolean printVisualHits = false; @Argument(fullName="useNextBestBase", shortName="nb", doc="use next best base", required=false) public boolean useNextBestBase = false; @Argument(fullName="useNonNextBestBase",shortName="nnb",doc="use nonnext best base",required=false) public boolean useNonNextBestBase = false; @@ -180,6 +182,17 @@ public class ReadErrorRateWalker extends ReadWalker errorCounts : other.readsByReadLength.entrySet() ) { + if ( this.readsByReadLength.keySet().contains(errorCounts.getKey()) ) { + mergeCounts(readsByReadLength.get(errorCounts.getKey()),errorCounts.getValue()); + } else { + readsByReadLength.put(errorCounts.getKey(),errorCounts.getValue()); + } + } + } + private static int[] zeroArray( int length ) { int[] array = new int[length]; for ( int ii = 0; ii < length; ii ++ ) { @@ -231,6 +254,12 @@ class ReadErrorRateCollection { return array; } + private static void mergeCounts ( int[] addToMe, int[] dontTouchMe ) { + for ( int index = 0; index < addToMe.length; index ++ ) { + addToMe[index] += dontTouchMe[index]; + } + } + public static void updateErrorCounts(int[] sum, boolean[] value) { for (int cycle = 0; cycle < value.length; cycle++) {