From b05119987c54523b9ac8fabeb91216c24dfe002b Mon Sep 17 00:00:00 2001 From: rpoplin Date: Sat, 14 Nov 2009 18:44:05 +0000 Subject: [PATCH] Clarified some of the comments in the individual covariates now that things have been moved around to speed up the code. In general most error checking and adjustments to the data are done per read instead of per base. This means that functionality was moved out of the covariate modules and into CovariateCounterWalker and TableRecalibrationWalker. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2047 348d0f76-0448-11de-a6fe-93d51630548a --- .../playground/gatk/walkers/Recalibration/Covariate.java | 7 +++---- .../walkers/Recalibration/CovariateCounterWalker.java | 4 ++-- .../gatk/walkers/Recalibration/CycleCovariate.java | 2 +- .../gatk/walkers/Recalibration/DinucCovariate.java | 8 +++----- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/Covariate.java b/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/Covariate.java index 809ab7e9a..486fb9651 100644 --- a/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/Covariate.java +++ b/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/Covariate.java @@ -33,13 +33,12 @@ import net.sf.samtools.SAMRecord; * Date: Oct 30, 2009 * * The Covariate interface. A Covariate is a feature used in the recalibration that can be picked out of the read, offset, and corresponding reference bases + * In general most error checking and adjustments to the data are done before the call to the covariates getValue methods in order to speed up the code. + * This unfortunately muddies the code, but most of these corrections can be done per read while the covariates get called per base, resulting in a big speed up. */ public interface Covariate { - public static final String COVARIATE_ERROR = "COVARIATE_ERROR"; - public static final String COVARIATE_NULL = "COVARITATE_NULL"; - - public Comparable getValue(SAMRecord read, int offset, String readGroup, byte[] quals, char[] bases, char refBase); //used to pick out the value from attributes of the read + public Comparable getValue(SAMRecord read, int offset, String readGroup, byte[] quals, char[] bases, char refBase); // used to pick out the value from attributes of the read public Comparable getValue(String str); // used to get value from input file public int estimatedNumberOfBins(); // used to estimate the amount space required for the HashMap } diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/CovariateCounterWalker.java b/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/CovariateCounterWalker.java index c715b0668..2969888b2 100755 --- a/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/CovariateCounterWalker.java +++ b/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/CovariateCounterWalker.java @@ -242,14 +242,14 @@ public class CovariateCounterWalker extends LocusWalker { prevBase = bases[offset-1]; // Get the complement base strand if we are a negative strand read if( read.getReadNegativeStrandFlag() ) { - bases = BaseUtils.simpleComplement( read.getReadString() ).toCharArray(); + bases = BaseUtils.simpleComplement( read.getReadString() ).toCharArray(); // this is an expensive call refBase = BaseUtils.simpleComplement( refBase ); prevBase = bases[offset+1]; } // skip if this base or the previous one was an 'N' or etc. if( BaseUtils.isRegularBase(prevBase) && BaseUtils.isRegularBase(bases[offset]) ) { - readGroup = read.getReadGroup().getReadGroupId(); + readGroup = read.getReadGroup().getReadGroupId(); // this is an expensive call updateDataFromRead( read, offset, readGroup, quals, bases, refBase ); } } diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/CycleCovariate.java b/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/CycleCovariate.java index 37b2bda00..1bc050172 100755 --- a/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/CycleCovariate.java +++ b/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/CycleCovariate.java @@ -47,7 +47,7 @@ public class CycleCovariate implements Covariate { private String platform; public CycleCovariate() { // empty constructor is required to instantiate covariate in CovariateCounterWalker and TableRecalibrationWalker - platform = "SLX"; + platform = "SLX"; // Solexa is the default } public CycleCovariate(final String _platform) { diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/DinucCovariate.java b/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/DinucCovariate.java index f5a0d4ea1..34623c9ce 100755 --- a/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/DinucCovariate.java +++ b/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/DinucCovariate.java @@ -1,8 +1,6 @@ package org.broadinstitute.sting.playground.gatk.walkers.Recalibration; import net.sf.samtools.SAMRecord; -import org.broadinstitute.sting.utils.BaseUtils; -import org.broadinstitute.sting.utils.Pair; /* * Copyright (c) 2009 The Broad Institute @@ -34,9 +32,9 @@ import org.broadinstitute.sting.utils.Pair; * User: rpoplin * Date: Nov 3, 2009 * - * The Dinucleotide covariate. This base and the one that came before it in the read, remembering to swap directions on cardinality if negative strand read. - * This covariate will return null if there are bases that don't belong such as 'N' or 'X'. - * This covariate will also return null if attempting to get previous base at the start of the read. + * The Dinucleotide covariate. This base and the one that came before it in the read, remembering to swap directions if negative strand read. + * This covariate assumes that the bases have been swapped to their complement base counterpart if this is a negative strand read. + * This assumption is made to speed up the code. */ public class DinucCovariate implements Covariate {