Merge branch 'master' of ssh://nickel.broadinstitute.org/humgen/gsa-scr1/gsa-engineering/git/unstable
This commit is contained in:
commit
fbbd04621d
|
|
@ -215,8 +215,8 @@ public class GenomeAnalysisEngine {
|
|||
resetRandomGenerator(System.currentTimeMillis());
|
||||
|
||||
// if the use specified an input BQSR recalibration table then enable on the fly recalibration
|
||||
if (this.getArguments().RECAL_FILE != null)
|
||||
setBaseRecalibration(this.getArguments().RECAL_FILE);
|
||||
if (this.getArguments().BQSR_RECAL_FILE != null)
|
||||
setBaseRecalibration(this.getArguments().BQSR_RECAL_FILE);
|
||||
|
||||
// Determine how the threads should be divided between CPU vs. IO.
|
||||
determineThreadAllocation();
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ public class GATKArgumentCollection {
|
|||
* and the raw empirical quality score calculated by phred-scaling the mismatch rate.
|
||||
*/
|
||||
@Input(fullName="BQSR", shortName="BQSR", required=false, doc="Filename for the input covariates table recalibration .csv file which enables on the fly base quality score recalibration")
|
||||
public File RECAL_FILE = null; // BUGBUG: need a better argument name once we decide how BQSRs v1 and v2 will live in the code base simultaneously
|
||||
public File BQSR_RECAL_FILE = null; // BUGBUG: need a better argument name once we decide how BQSRs v1 and v2 will live in the code base simultaneously
|
||||
|
||||
@Argument(fullName="defaultBaseQualities", shortName = "DBQ", doc = "If reads are missing some or all base quality scores, this value will be used for all base quality scores", required=false)
|
||||
public byte defaultBaseQualities = -1;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
package org.broadinstitute.sting.gatk.walkers.recalibration;
|
||||
|
||||
import net.sf.samtools.SAMRecord;
|
||||
import org.broadinstitute.sting.utils.recalibration.BaseRecalibration;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
|
|
@ -35,19 +36,21 @@ import java.util.Arrays;
|
|||
* Date: 9/26/11
|
||||
*/
|
||||
|
||||
public class ContextCovariate implements Covariate {
|
||||
public class ContextCovariate implements ExperimentalCovariate {
|
||||
|
||||
final int CONTEXT_SIZE = 8;
|
||||
String allN = "";
|
||||
|
||||
// Initialize any member variables using the command-line arguments passed to the walkers
|
||||
@Override
|
||||
public void initialize( final RecalibrationArgumentCollection RAC ) {
|
||||
for( int iii = 0; iii < CONTEXT_SIZE; iii++ ) {
|
||||
allN += "N";
|
||||
}
|
||||
}
|
||||
|
||||
public void getValues(SAMRecord read, Comparable[] comparable) {
|
||||
@Override
|
||||
public void getValues( final SAMRecord read, final Comparable[] comparable, final BaseRecalibration.BaseRecalibrationType modelType ) {
|
||||
byte[] bases = read.getReadBases();
|
||||
for(int i = 0; i < read.getReadLength(); i++) {
|
||||
comparable[i] = ( i-CONTEXT_SIZE < 0 ? allN : new String(Arrays.copyOfRange(bases,i-CONTEXT_SIZE,i)) );
|
||||
|
|
@ -55,8 +58,8 @@ public class ContextCovariate implements Covariate {
|
|||
}
|
||||
|
||||
// Used to get the covariate's value from input csv file in TableRecalibrationWalker
|
||||
@Override
|
||||
public final Comparable getValue( final String str ) {
|
||||
return str;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ import org.broadinstitute.sting.utils.collections.NestedHashMap;
|
|||
import org.broadinstitute.sting.utils.exceptions.DynamicClassResolutionException;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.pileup.PileupElement;
|
||||
import org.broadinstitute.sting.utils.recalibration.BaseRecalibration;
|
||||
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
|
||||
|
||||
import java.io.PrintStream;
|
||||
|
|
@ -374,7 +375,7 @@ public class CountCovariatesWalker extends LocusWalker<CountCovariatesWalker.Cou
|
|||
|
||||
RecalDataManager.parseColorSpace( gatkRead );
|
||||
gatkRead.setTemporaryAttribute( COVARS_ATTRIBUTE,
|
||||
RecalDataManager.computeCovariates( gatkRead, requestedCovariates ));
|
||||
RecalDataManager.computeCovariates( gatkRead, requestedCovariates, BaseRecalibration.BaseRecalibrationType.BASE_SUBSTITUTION ));
|
||||
}
|
||||
|
||||
// Skip this position if base quality is zero
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package org.broadinstitute.sting.gatk.walkers.recalibration;
|
||||
|
||||
import net.sf.samtools.SAMRecord;
|
||||
import org.broadinstitute.sting.utils.recalibration.BaseRecalibration;
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 The Broad Institute
|
||||
|
|
@ -32,7 +33,7 @@ import net.sf.samtools.SAMRecord;
|
|||
* User: rpoplin
|
||||
* 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
|
||||
* The Covariate interface. A Covariate is a feature used in the recalibration that can be picked out of the read.
|
||||
* 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.
|
||||
*/
|
||||
|
|
@ -40,9 +41,10 @@ import net.sf.samtools.SAMRecord;
|
|||
public interface Covariate {
|
||||
public void initialize( RecalibrationArgumentCollection RAC ); // Initialize any member variables using the command-line arguments passed to the walkers
|
||||
public Comparable getValue( String str ); // Used to get the covariate's value from input csv file in TableRecalibrationWalker
|
||||
public void getValues( SAMRecord read, Comparable[] comparable ); //Takes an array of size (at least) read.getReadLength() and fills it with covariate
|
||||
//values for each position in the read. This method was created as an optimization over calling getValue( read, offset ) for each offset and allows
|
||||
//read-specific calculations to be done just once rather than for each offset.
|
||||
public void getValues( SAMRecord read, Comparable[] comparable, BaseRecalibration.BaseRecalibrationType modelType );
|
||||
//Takes an array of size (at least) read.getReadLength() and fills it with covariate
|
||||
//values for each position in the read. This method was created as an optimization over calling getValue( read, offset ) for each offset and allows
|
||||
//read-specific calculations to be done just once rather than for each offset.
|
||||
}
|
||||
|
||||
interface RequiredCovariate extends Covariate {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import net.sf.samtools.SAMRecord;
|
|||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.NGSPlatform;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.recalibration.BaseRecalibration;
|
||||
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
|
@ -51,6 +52,7 @@ public class CycleCovariate implements StandardCovariate {
|
|||
private final static EnumSet<NGSPlatform> FLOW_CYCLE_PLATFORMS = EnumSet.of(NGSPlatform.LS454, NGSPlatform.ION_TORRENT);
|
||||
|
||||
// Initialize any member variables using the command-line arguments passed to the walkers
|
||||
@Override
|
||||
public void initialize( final RecalibrationArgumentCollection RAC ) {
|
||||
if( RAC.DEFAULT_PLATFORM != null ) {
|
||||
if( RAC.DEFAULT_PLATFORM.equalsIgnoreCase( "SLX" ) || RAC.DEFAULT_PLATFORM.equalsIgnoreCase( "ILLUMINA" ) ||
|
||||
|
|
@ -63,7 +65,8 @@ public class CycleCovariate implements StandardCovariate {
|
|||
}
|
||||
|
||||
// Used to pick out the covariate's value from attributes of the read
|
||||
public void getValues(SAMRecord read, Comparable[] comparable) {
|
||||
@Override
|
||||
public void getValues( final SAMRecord read, final Comparable[] comparable, final BaseRecalibration.BaseRecalibrationType modelType ) {
|
||||
|
||||
//-----------------------------
|
||||
// Illumina, Solid, PacBio, and Complete Genomics
|
||||
|
|
@ -164,6 +167,7 @@ public class CycleCovariate implements StandardCovariate {
|
|||
}
|
||||
|
||||
// Used to get the covariate's value from input csv file in TableRecalibrationWalker
|
||||
@Override
|
||||
public final Comparable getValue( final String str ) {
|
||||
return Integer.parseInt( str );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package org.broadinstitute.sting.gatk.walkers.recalibration;
|
|||
|
||||
import net.sf.samtools.SAMRecord;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.recalibration.BaseRecalibration;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
|
|
@ -48,6 +49,7 @@ public class DinucCovariate implements StandardCovariate {
|
|||
private HashMap<Integer, Dinuc> dinucHashMap;
|
||||
|
||||
// Initialize any member variables using the command-line arguments passed to the walkers
|
||||
@Override
|
||||
public void initialize( final RecalibrationArgumentCollection RAC ) {
|
||||
final byte[] BASES = { (byte)'A', (byte)'C', (byte)'G', (byte)'T' };
|
||||
dinucHashMap = new HashMap<Integer, Dinuc>();
|
||||
|
|
@ -60,45 +62,11 @@ public class DinucCovariate implements StandardCovariate {
|
|||
dinucHashMap.put( Dinuc.hashBytes(NO_CALL, NO_CALL), NO_DINUC );
|
||||
}
|
||||
|
||||
/*
|
||||
// Used to pick out the covariate's value from attributes of the read
|
||||
public final Comparable getValue( final SAMRecord read, final int offset ) {
|
||||
|
||||
byte base;
|
||||
byte prevBase;
|
||||
final byte[] bases = read.getReadBases();
|
||||
// If this is a negative strand read then we need to reverse the direction for our previous base
|
||||
if( read.getReadNegativeStrandFlag() ) {
|
||||
// No dinuc at the beginning of the read
|
||||
if( offset == bases.length-1 ) {
|
||||
return NO_DINUC;
|
||||
}
|
||||
base = (byte)BaseUtils.simpleComplement( (char)(bases[offset]) );
|
||||
// Note: We are using the previous base in the read, not the previous base in the reference. This is done in part to be consistent with unmapped reads.
|
||||
prevBase = (byte)BaseUtils.simpleComplement( (char)(bases[offset + 1]) );
|
||||
} else {
|
||||
// No dinuc at the beginning of the read
|
||||
if( offset == 0 ) {
|
||||
return NO_DINUC;
|
||||
}
|
||||
base = bases[offset];
|
||||
// Note: We are using the previous base in the read, not the previous base in the reference. This is done in part to be consistent with unmapped reads.
|
||||
prevBase = bases[offset - 1];
|
||||
}
|
||||
|
||||
// Make sure the previous base is good
|
||||
if( !BaseUtils.isRegularBase( prevBase ) ) {
|
||||
return NO_DINUC;
|
||||
}
|
||||
|
||||
return dinucHashMap.get( Dinuc.hashBytes( prevBase, base ) );
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Takes an array of size (at least) read.getReadLength() and fills it with the covariate values for each position in the read.
|
||||
*/
|
||||
public void getValues( SAMRecord read, Comparable[] result ) {
|
||||
@Override
|
||||
public void getValues( final SAMRecord read, final Comparable[] comparable, final BaseRecalibration.BaseRecalibrationType modelType ) {
|
||||
final HashMap<Integer, Dinuc> dinucHashMapRef = this.dinucHashMap; //optimize access to dinucHashMap
|
||||
final int readLength = read.getReadLength();
|
||||
final boolean negativeStrand = read.getReadNegativeStrandFlag();
|
||||
|
|
@ -111,7 +79,7 @@ public class DinucCovariate implements StandardCovariate {
|
|||
if(negativeStrand) {
|
||||
bases = BaseUtils.simpleReverseComplement(bases); //this is NOT in-place
|
||||
}
|
||||
result[0] = NO_DINUC; // No dinuc at the beginning of the read
|
||||
comparable[0] = NO_DINUC; // No dinuc at the beginning of the read
|
||||
|
||||
prevBase = bases[0];
|
||||
offset++;
|
||||
|
|
@ -120,20 +88,21 @@ public class DinucCovariate implements StandardCovariate {
|
|||
// previous base in the reference. This is done in part to be consistent with unmapped reads.
|
||||
base = bases[offset];
|
||||
if( BaseUtils.isRegularBase( prevBase ) ) {
|
||||
result[offset] = dinucHashMapRef.get( Dinuc.hashBytes( prevBase, base ) );
|
||||
comparable[offset] = dinucHashMapRef.get( Dinuc.hashBytes( prevBase, base ) );
|
||||
} else {
|
||||
result[offset] = NO_DINUC;
|
||||
comparable[offset] = NO_DINUC;
|
||||
}
|
||||
|
||||
offset++;
|
||||
prevBase = base;
|
||||
}
|
||||
if(negativeStrand) {
|
||||
reverse( result );
|
||||
reverse( comparable );
|
||||
}
|
||||
}
|
||||
|
||||
// Used to get the covariate's value from input csv file in TableRecalibrationWalker
|
||||
@Override
|
||||
public final Comparable getValue( final String str ) {
|
||||
byte[] bytes = str.getBytes();
|
||||
final Dinuc returnDinuc = dinucHashMap.get( Dinuc.hashBytes( bytes[0], bytes[1] ) );
|
||||
|
|
@ -143,7 +112,6 @@ public class DinucCovariate implements StandardCovariate {
|
|||
return returnDinuc;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverses the given array in place.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package org.broadinstitute.sting.gatk.walkers.recalibration;
|
||||
|
||||
import net.sf.samtools.SAMRecord;
|
||||
import org.broadinstitute.sting.utils.recalibration.BaseRecalibration;
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010 The Broad Institute
|
||||
|
|
@ -41,12 +42,13 @@ public class GCContentCovariate implements ExperimentalCovariate {
|
|||
int numBack = 7;
|
||||
|
||||
// Initialize any member variables using the command-line arguments passed to the walkers
|
||||
@Override
|
||||
public void initialize( final RecalibrationArgumentCollection RAC ) {
|
||||
numBack = RAC.HOMOPOLYMER_NBACK;
|
||||
}
|
||||
|
||||
// Used to pick out the covariate's value from attributes of the read
|
||||
public final Comparable getValue( final SAMRecord read, final int offset ) {
|
||||
private final Comparable getValue( final SAMRecord read, final int offset ) {
|
||||
|
||||
// ATTGCCCCGTAAAAAAAGAGAA
|
||||
// 0000123456654321001122
|
||||
|
|
@ -75,18 +77,17 @@ public class GCContentCovariate implements ExperimentalCovariate {
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public void getValues(SAMRecord read, Comparable[] comparable) {
|
||||
|
||||
@Override
|
||||
public void getValues( final SAMRecord read, final Comparable[] comparable, final BaseRecalibration.BaseRecalibrationType modelType ) {
|
||||
for(int iii = 0; iii < read.getReadLength(); iii++) {
|
||||
comparable[iii] = getValue(read, iii); // BUGBUG: this can be optimized
|
||||
}
|
||||
}
|
||||
|
||||
// Used to get the covariate's value from input csv file in TableRecalibrationWalker
|
||||
@Override
|
||||
public final Comparable getValue( final String str ) {
|
||||
return Integer.parseInt( str );
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package org.broadinstitute.sting.gatk.walkers.recalibration;
|
||||
|
||||
import net.sf.samtools.SAMRecord;
|
||||
import org.broadinstitute.sting.utils.recalibration.BaseRecalibration;
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 The Broad Institute
|
||||
|
|
@ -43,12 +44,13 @@ public class HomopolymerCovariate implements ExperimentalCovariate {
|
|||
int numBack = 7;
|
||||
|
||||
// Initialize any member variables using the command-line arguments passed to the walkers
|
||||
@Override
|
||||
public void initialize( final RecalibrationArgumentCollection RAC ) {
|
||||
numBack = RAC.HOMOPOLYMER_NBACK;
|
||||
}
|
||||
|
||||
// Used to pick out the covariate's value from attributes of the read
|
||||
public final Comparable getValue( final SAMRecord read, final int offset ) {
|
||||
private final Comparable getValue( final SAMRecord read, final int offset ) {
|
||||
|
||||
// This block of code is for if you don't want to only count consecutive bases
|
||||
// ATTGCCCCGTAAAAAAAAATA
|
||||
|
|
@ -90,15 +92,16 @@ public class HomopolymerCovariate implements ExperimentalCovariate {
|
|||
return numAgree;
|
||||
}
|
||||
|
||||
public void getValues(SAMRecord read, Comparable[] comparable) {
|
||||
@Override
|
||||
public void getValues( final SAMRecord read, final Comparable[] comparable, final BaseRecalibration.BaseRecalibrationType modelType ) {
|
||||
for(int iii = 0; iii < read.getReadLength(); iii++) {
|
||||
comparable[iii] = getValue(read, iii); // BUGBUG: this can be optimized
|
||||
}
|
||||
}
|
||||
|
||||
// Used to get the covariate's value from input csv file in TableRecalibrationWalker
|
||||
@Override
|
||||
public final Comparable getValue( final String str ) {
|
||||
return Integer.parseInt( str );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package org.broadinstitute.sting.gatk.walkers.recalibration;
|
||||
|
||||
import net.sf.samtools.SAMRecord;
|
||||
import org.broadinstitute.sting.utils.recalibration.BaseRecalibration;
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 The Broad Institute
|
||||
|
|
@ -38,23 +39,25 @@ import net.sf.samtools.SAMRecord;
|
|||
public class MappingQualityCovariate implements ExperimentalCovariate {
|
||||
|
||||
// Initialize any member variables using the command-line arguments passed to the walkers
|
||||
@Override
|
||||
public void initialize( final RecalibrationArgumentCollection RAC ) {
|
||||
}
|
||||
|
||||
// Used to pick out the covariate's value from attributes of the read
|
||||
public final Comparable getValue( final SAMRecord read, final int offset ) {
|
||||
private final Comparable getValue( final SAMRecord read, final int offset ) {
|
||||
return read.getMappingQuality();
|
||||
}
|
||||
|
||||
// Used to get the covariate's value from input csv file in TableRecalibrationWalker
|
||||
@Override
|
||||
public final Comparable getValue( final String str ) {
|
||||
return Integer.parseInt( str );
|
||||
}
|
||||
|
||||
public void getValues(SAMRecord read, Comparable[] comparable) {
|
||||
@Override
|
||||
public void getValues( final SAMRecord read, final Comparable[] comparable, final BaseRecalibration.BaseRecalibrationType modelType ) {
|
||||
for(int iii = 0; iii < read.getReadLength(); iii++) {
|
||||
comparable[iii] = getValue(read, iii); // BUGBUG: this can be optimized
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package org.broadinstitute.sting.gatk.walkers.recalibration;
|
||||
|
||||
import net.sf.samtools.SAMRecord;
|
||||
import org.broadinstitute.sting.utils.recalibration.BaseRecalibration;
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 The Broad Institute
|
||||
|
|
@ -41,12 +42,13 @@ public class MinimumNQSCovariate implements ExperimentalCovariate {
|
|||
private int windowReach; // How far in each direction from the current base to look
|
||||
|
||||
// Initialize any member variables using the command-line arguments passed to the walkers
|
||||
@Override
|
||||
public void initialize( final RecalibrationArgumentCollection RAC ) {
|
||||
windowReach = RAC.WINDOW_SIZE / 2; // integer division
|
||||
}
|
||||
|
||||
// Used to pick out the covariate's value from attributes of the read
|
||||
public final Comparable getValue( final SAMRecord read, final int offset ) {
|
||||
private final Comparable getValue( final SAMRecord read, final int offset ) {
|
||||
|
||||
// Loop over the list of base quality scores in the window and find the minimum
|
||||
final byte[] quals = read.getBaseQualities();
|
||||
|
|
@ -61,14 +63,16 @@ public class MinimumNQSCovariate implements ExperimentalCovariate {
|
|||
return minQual;
|
||||
}
|
||||
|
||||
// Used to get the covariate's value from input csv file in TableRecalibrationWalker
|
||||
public final Comparable getValue( final String str ) {
|
||||
return Integer.parseInt( str );
|
||||
}
|
||||
|
||||
public void getValues(SAMRecord read, Comparable[] comparable) {
|
||||
@Override
|
||||
public void getValues( final SAMRecord read, final Comparable[] comparable, final BaseRecalibration.BaseRecalibrationType modelType ) {
|
||||
for(int iii = 0; iii < read.getReadLength(); iii++) {
|
||||
comparable[iii] = getValue(read, iii); // BUGBUG: this can be optimized
|
||||
}
|
||||
}
|
||||
|
||||
// Used to get the covariate's value from input csv file in TableRecalibrationWalker
|
||||
@Override
|
||||
public final Comparable getValue( final String str ) {
|
||||
return Integer.parseInt( str );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package org.broadinstitute.sting.gatk.walkers.recalibration;
|
||||
|
||||
import net.sf.samtools.SAMRecord;
|
||||
import org.broadinstitute.sting.utils.recalibration.BaseRecalibration;
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 The Broad Institute
|
||||
|
|
@ -39,11 +40,12 @@ import net.sf.samtools.SAMRecord;
|
|||
public class PositionCovariate implements ExperimentalCovariate {
|
||||
|
||||
// Initialize any member variables using the command-line arguments passed to the walkers
|
||||
@Override
|
||||
public void initialize( final RecalibrationArgumentCollection RAC ) {
|
||||
}
|
||||
|
||||
// Used to pick out the covariate's value from attributes of the read
|
||||
public final Comparable getValue( final SAMRecord read, final int offset ) {
|
||||
private final Comparable getValue( final SAMRecord read, final int offset ) {
|
||||
int cycle = offset;
|
||||
if( read.getReadNegativeStrandFlag() ) {
|
||||
cycle = read.getReadLength() - (offset + 1);
|
||||
|
|
@ -51,15 +53,16 @@ public class PositionCovariate implements ExperimentalCovariate {
|
|||
return cycle;
|
||||
}
|
||||
|
||||
// Used to get the covariate's value from input csv file in TableRecalibrationWalker
|
||||
public final Comparable getValue( final String str ) {
|
||||
return Integer.parseInt( str );
|
||||
}
|
||||
|
||||
public void getValues(SAMRecord read, Comparable[] comparable) {
|
||||
@Override
|
||||
public void getValues( final SAMRecord read, final Comparable[] comparable, final BaseRecalibration.BaseRecalibrationType modelType ) {
|
||||
for(int iii = 0; iii < read.getReadLength(); iii++) {
|
||||
comparable[iii] = getValue(read, iii); // BUGBUG: this can be optimized
|
||||
}
|
||||
}
|
||||
|
||||
// Used to get the covariate's value from input csv file in TableRecalibrationWalker
|
||||
@Override
|
||||
public final Comparable getValue( final String str ) {
|
||||
return Integer.parseInt( str );
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package org.broadinstitute.sting.gatk.walkers.recalibration;
|
||||
|
||||
import net.sf.samtools.SAMRecord;
|
||||
import org.broadinstitute.sting.utils.recalibration.BaseRecalibration;
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 The Broad Institute
|
||||
|
|
@ -40,11 +41,12 @@ import net.sf.samtools.SAMRecord;
|
|||
public class PrimerRoundCovariate implements ExperimentalCovariate {
|
||||
|
||||
// Initialize any member variables using the command-line arguments passed to the walkers
|
||||
@Override
|
||||
public void initialize( final RecalibrationArgumentCollection RAC ) {
|
||||
}
|
||||
|
||||
// Used to pick out the covariate's value from attributes of the read
|
||||
public final Comparable getValue( final SAMRecord read, final int offset ) {
|
||||
private final Comparable getValue( final SAMRecord read, final int offset ) {
|
||||
if( read.getReadGroup().getPlatform().equalsIgnoreCase( "SOLID" ) || read.getReadGroup().getPlatform().equalsIgnoreCase( "ABI_SOLID" ) ) {
|
||||
int pos = offset;
|
||||
if( read.getReadNegativeStrandFlag() ) {
|
||||
|
|
@ -57,14 +59,16 @@ public class PrimerRoundCovariate implements ExperimentalCovariate {
|
|||
|
||||
}
|
||||
|
||||
// Used to get the covariate's value from input csv file in TableRecalibrationWalker
|
||||
public final Comparable getValue( final String str ) {
|
||||
return Integer.parseInt( str );
|
||||
}
|
||||
|
||||
public void getValues(SAMRecord read, Comparable[] comparable) {
|
||||
@Override
|
||||
public void getValues( final SAMRecord read, final Comparable[] comparable, final BaseRecalibration.BaseRecalibrationType modelType ) {
|
||||
for(int iii = 0; iii < read.getReadLength(); iii++) {
|
||||
comparable[iii] = getValue(read, iii); // BUGBUG: this can be optimized
|
||||
}
|
||||
}
|
||||
|
||||
// Used to get the covariate's value from input csv file in TableRecalibrationWalker
|
||||
@Override
|
||||
public final Comparable getValue( final String str ) {
|
||||
return Integer.parseInt( str );
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,9 @@
|
|||
package org.broadinstitute.sting.gatk.walkers.recalibration;
|
||||
|
||||
import net.sf.samtools.SAMRecord;
|
||||
import org.broadinstitute.sting.utils.recalibration.BaseRecalibration;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 The Broad Institute
|
||||
|
|
@ -38,26 +41,26 @@ import net.sf.samtools.SAMRecord;
|
|||
public class QualityScoreCovariate implements RequiredCovariate {
|
||||
|
||||
// Initialize any member variables using the command-line arguments passed to the walkers
|
||||
@Override
|
||||
public void initialize( final RecalibrationArgumentCollection RAC ) {
|
||||
}
|
||||
|
||||
/*
|
||||
// Used to pick out the covariate's value from attributes of the read
|
||||
public final Comparable getValue( final SAMRecord read, final int offset ) {
|
||||
return (int)(read.getBaseQualities()[offset]);
|
||||
}
|
||||
*/
|
||||
|
||||
public void getValues(SAMRecord read, Comparable[] comparable) {
|
||||
byte[] baseQualities = read.getBaseQualities();
|
||||
for(int i = 0; i < read.getReadLength(); i++) {
|
||||
comparable[i] = (int) baseQualities[i];
|
||||
@Override
|
||||
public void getValues( final SAMRecord read, final Comparable[] comparable, final BaseRecalibration.BaseRecalibrationType modelType ) {
|
||||
if( modelType == BaseRecalibration.BaseRecalibrationType.BASE_SUBSTITUTION ) {
|
||||
byte[] baseQualities = read.getBaseQualities();
|
||||
for(int i = 0; i < read.getReadLength(); i++) {
|
||||
comparable[i] = (int) baseQualities[i];
|
||||
}
|
||||
} else { // model == BASE_INSERTION || model == BASE_DELETION
|
||||
Arrays.fill(comparable, 45); // Some day in the future when base insertion and base deletion quals exist the samtools API will
|
||||
// be updated and the original quals will be pulled here, but for now we assume the original quality is a flat Q45
|
||||
}
|
||||
}
|
||||
|
||||
// Used to get the covariate's value from input csv file in TableRecalibrationWalker
|
||||
@Override
|
||||
public final Comparable getValue( final String str ) {
|
||||
return Integer.parseInt( str );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package org.broadinstitute.sting.gatk.walkers.recalibration;
|
||||
|
||||
import net.sf.samtools.SAMRecord;
|
||||
import org.broadinstitute.sting.utils.recalibration.BaseRecalibration;
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 The Broad Institute
|
||||
|
|
@ -35,22 +36,17 @@ import net.sf.samtools.SAMRecord;
|
|||
* The Read Group covariate.
|
||||
*/
|
||||
|
||||
public class ReadGroupCovariate implements RequiredCovariate{
|
||||
public class ReadGroupCovariate implements RequiredCovariate {
|
||||
|
||||
public static final String defaultReadGroup = "DefaultReadGroup";
|
||||
|
||||
// Initialize any member variables using the command-line arguments passed to the walkers
|
||||
@Override
|
||||
public void initialize( final RecalibrationArgumentCollection RAC ) {
|
||||
}
|
||||
|
||||
/*
|
||||
// Used to pick out the covariate's value from attributes of the read
|
||||
public final Comparable getValue( final SAMRecord read, final int offset ) {
|
||||
return read.getReadGroup().getReadGroupId();
|
||||
}
|
||||
*/
|
||||
|
||||
public void getValues(SAMRecord read, Comparable[] comparable) {
|
||||
@Override
|
||||
public void getValues( final SAMRecord read, final Comparable[] comparable, final BaseRecalibration.BaseRecalibrationType modelType ) {
|
||||
final String readGroupId = read.getReadGroup().getReadGroupId();
|
||||
for(int i = 0; i < read.getReadLength(); i++) {
|
||||
comparable[i] = readGroupId;
|
||||
|
|
@ -58,10 +54,10 @@ public class ReadGroupCovariate implements RequiredCovariate{
|
|||
}
|
||||
|
||||
// Used to get the covariate's value from input csv file in TableRecalibrationWalker
|
||||
@Override
|
||||
public final Comparable getValue( final String str ) {
|
||||
return str;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import org.broadinstitute.sting.utils.Utils;
|
|||
import org.broadinstitute.sting.utils.collections.NestedHashMap;
|
||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.recalibration.BaseRecalibration;
|
||||
import org.broadinstitute.sting.utils.sam.AlignmentUtils;
|
||||
import org.broadinstitute.sting.utils.sam.GATKSAMReadGroupRecord;
|
||||
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
|
||||
|
|
@ -571,7 +572,7 @@ public class RecalDataManager {
|
|||
* value for the ith position in the read and the jth covariate in
|
||||
* reqeustedCovariates list.
|
||||
*/
|
||||
public static Comparable[][] computeCovariates(final GATKSAMRecord gatkRead, final List<Covariate> requestedCovariates) {
|
||||
public static Comparable[][] computeCovariates( final GATKSAMRecord gatkRead, final List<Covariate> requestedCovariates, final BaseRecalibration.BaseRecalibrationType modelType ) {
|
||||
//compute all covariates for this read
|
||||
final List<Covariate> requestedCovariatesRef = requestedCovariates;
|
||||
final int numRequestedCovariates = requestedCovariatesRef.size();
|
||||
|
|
@ -582,7 +583,7 @@ public class RecalDataManager {
|
|||
|
||||
// Loop through the list of requested covariates and compute the values of each covariate for all positions in this read
|
||||
for( int i = 0; i < numRequestedCovariates; i++ ) {
|
||||
requestedCovariatesRef.get(i).getValues( gatkRead, tempCovariateValuesHolder );
|
||||
requestedCovariatesRef.get(i).getValues( gatkRead, tempCovariateValuesHolder, modelType );
|
||||
for(int j = 0; j < readLength; j++) {
|
||||
//copy values into a 2D array that allows all covar types to be extracted at once for
|
||||
//an offset j by doing covariateValues_offset_x_covar[j]. This avoids the need to later iterate over covar types.
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ import org.broadinstitute.sting.utils.classloader.PluginManager;
|
|||
import org.broadinstitute.sting.utils.collections.NestedHashMap;
|
||||
import org.broadinstitute.sting.utils.exceptions.DynamicClassResolutionException;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.recalibration.BaseRecalibration;
|
||||
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
|
||||
import org.broadinstitute.sting.utils.text.TextFormattingUtils;
|
||||
import org.broadinstitute.sting.utils.text.XReadLines;
|
||||
|
|
@ -398,7 +399,7 @@ public class TableRecalibrationWalker extends ReadWalker<SAMRecord, SAMFileWrite
|
|||
|
||||
//compute all covariate values for this read
|
||||
final Comparable[][] covariateValues_offset_x_covar =
|
||||
RecalDataManager.computeCovariates(read, requestedCovariates);
|
||||
RecalDataManager.computeCovariates(read, requestedCovariates, BaseRecalibration.BaseRecalibrationType.BASE_SUBSTITUTION);
|
||||
|
||||
// For each base in the read
|
||||
for( int offset = 0; offset < read.getReadLength(); offset++ ) {
|
||||
|
|
|
|||
|
|
@ -71,25 +71,24 @@ public class KeepAFSpectrumFrequencySelector extends FrequencyModeSelector {
|
|||
// recompute AF,AC,AN based on genotypes:
|
||||
// todo - - maybe too inefficient??
|
||||
VariantContextUtils.calculateChromosomeCounts(vc, attributes, false);
|
||||
afArray = new double[] {Double.valueOf((String)attributes.get(VCFConstants.ALLELE_FREQUENCY_KEY))};
|
||||
} else {
|
||||
// sites-only vc or we explicitly tell to ignore genotypes; we trust the AF field if present
|
||||
if ( vc.hasAttribute(VCFConstants.ALLELE_FREQUENCY_KEY) ) {
|
||||
String afo = vc.getAttributeAsString(VCFConstants.ALLELE_FREQUENCY_KEY, null);
|
||||
}
|
||||
|
||||
if (afo.contains(",")) {
|
||||
String[] afs = afo.split(",");
|
||||
afs[0] = afs[0].substring(1,afs[0].length());
|
||||
afs[afs.length-1] = afs[afs.length-1].substring(0,afs[afs.length-1].length()-1);
|
||||
// sites-only vc or we explicitly tell to ignore genotypes; we trust the AF field if present
|
||||
if ( vc.hasAttribute(VCFConstants.ALLELE_FREQUENCY_KEY) ) {
|
||||
String afo = vc.getAttributeAsString(VCFConstants.ALLELE_FREQUENCY_KEY, null);
|
||||
|
||||
afArray = new double[afs.length];
|
||||
if (afo.contains(",")) {
|
||||
String[] afs = afo.split(",");
|
||||
afs[0] = afs[0].substring(1,afs[0].length());
|
||||
afs[afs.length-1] = afs[afs.length-1].substring(0,afs[afs.length-1].length()-1);
|
||||
|
||||
for (int k=0; k < afArray.length; k++)
|
||||
afArray[k] = Double.valueOf(afs[k]);
|
||||
}
|
||||
else
|
||||
afArray = new double[] {Double.valueOf(afo)};
|
||||
afArray = new double[afs.length];
|
||||
|
||||
for (int k=0; k < afArray.length; k++)
|
||||
afArray[k] = Double.valueOf(afs[k]);
|
||||
}
|
||||
else
|
||||
afArray = new double[] {Double.valueOf(afo)};
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -177,13 +177,13 @@ public class BaseRecalibration {
|
|||
dataManager.addToAllTables( key, datum, QualityUtils.MIN_USABLE_Q_SCORE ); //BUGBUG: used to be Q5 now is Q6, probably doesn't matter
|
||||
}
|
||||
|
||||
public byte[] recalibrateRead( final GATKSAMRecord read, final byte[] originalQuals ) {
|
||||
public byte[] recalibrateRead( final GATKSAMRecord read, final byte[] originalQuals, final BaseRecalibrationType modelType ) {
|
||||
|
||||
final byte[] recalQuals = originalQuals.clone();
|
||||
|
||||
//compute all covariate values for this read
|
||||
final Comparable[][] covariateValues_offset_x_covar =
|
||||
RecalDataManager.computeCovariates(read, requestedCovariates);
|
||||
RecalDataManager.computeCovariates(read, requestedCovariates, modelType);
|
||||
|
||||
// For each base in the read
|
||||
for( int offset = 0; offset < read.getReadLength(); offset++ ) {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ package org.broadinstitute.sting.utils.sam;
|
|||
import net.sf.samtools.*;
|
||||
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
|
||||
import org.broadinstitute.sting.utils.NGSPlatform;
|
||||
import org.broadinstitute.sting.utils.recalibration.BaseRecalibration;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
|
@ -162,9 +163,11 @@ public class GATKSAMRecord extends BAMRecord {
|
|||
return super.equals(o);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@Override
|
||||
public byte[] getBaseQualities() {
|
||||
return super.getBaseQualities();
|
||||
/*
|
||||
if( getAttribute( BQSR_BASES_HAVE_BEEN_RECALIBRATED_TAG ) != null ) {
|
||||
return super.getBaseQualities();
|
||||
} else {
|
||||
|
|
@ -178,8 +181,8 @@ public class GATKSAMRecord extends BAMRecord {
|
|||
return super.getBaseQualities();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Accessors for base insertion and base deletion quality scores
|
||||
|
|
@ -192,7 +195,7 @@ public class GATKSAMRecord extends BAMRecord {
|
|||
// if the recal data was populated in the engine then recalibrate the quality scores on the fly
|
||||
// else give default values which are flat Q45
|
||||
if( GenomeAnalysisEngine.hasBaseRecalibration() ) {
|
||||
quals = GenomeAnalysisEngine.getBaseRecalibration().recalibrateRead( this, quals ); // the original quals here are the flat base insertion/deletion quals, NOT the original base qualities
|
||||
quals = GenomeAnalysisEngine.getBaseRecalibration().recalibrateRead( this, quals, BaseRecalibration.BaseRecalibrationType.BASE_INSERTION ); // the original quals here are the flat base insertion/deletion quals, NOT the original base qualities
|
||||
}
|
||||
// add the qual array to the read so that we don't have to do the recalibration work again
|
||||
setAttribute( BQSR_BASE_INSERTION_QUALITIES, quals );
|
||||
|
|
@ -208,7 +211,7 @@ public class GATKSAMRecord extends BAMRecord {
|
|||
// if the recal data was populated in the engine then recalibrate the quality scores on the fly
|
||||
// else give default values which are flat Q45
|
||||
if( GenomeAnalysisEngine.hasBaseRecalibration() ) {
|
||||
quals = GenomeAnalysisEngine.getBaseRecalibration().recalibrateRead( this, quals ); // the original quals here are the flat base insertion/deletion quals, NOT the original base qualities
|
||||
quals = GenomeAnalysisEngine.getBaseRecalibration().recalibrateRead( this, quals, BaseRecalibration.BaseRecalibrationType.BASE_DELETION ); // the original quals here are the flat base insertion/deletion quals, NOT the original base qualities
|
||||
}
|
||||
// add the qual array to the read so that we don't have to do the recalibration work again
|
||||
setAttribute( BQSR_BASE_DELETION_QUALITIES, quals );
|
||||
|
|
|
|||
Loading…
Reference in New Issue