misc code cleanup
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2190 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
e793e62fc9
commit
b89b9adb2c
|
|
@ -101,7 +101,7 @@ public class CovariateCounterWalker extends LocusWalker<Integer, PrintStream> {
|
||||||
private long countedBases = 0; // Number of bases used in the calculations, used for reporting in the output file
|
private long countedBases = 0; // Number of bases used in the calculations, used for reporting in the output file
|
||||||
private long skippedSites = 0; // Number of loci skipped because it was a dbSNP site, used for reporting in the output file
|
private long skippedSites = 0; // Number of loci skipped because it was a dbSNP site, used for reporting in the output file
|
||||||
private int numUnprocessed = 0; // Number of consecutive loci skipped because we are only processing every Nth site
|
private int numUnprocessed = 0; // Number of consecutive loci skipped because we are only processing every Nth site
|
||||||
private static final String versionString = "v2.0.10"; // Major version, minor version, and build number
|
private static final String versionString = "v2.0.11"; // Major version, minor version, and build number
|
||||||
private Pair<Long, Long> dbSNP_counts = new Pair<Long, Long>(0L, 0L); // mismatch/base counts for dbSNP loci
|
private Pair<Long, Long> dbSNP_counts = new Pair<Long, Long>(0L, 0L); // mismatch/base counts for dbSNP loci
|
||||||
private Pair<Long, Long> novel_counts = new Pair<Long, Long>(0L, 0L); // mismatch/base counts for non-dbSNP loci
|
private Pair<Long, Long> novel_counts = new Pair<Long, Long>(0L, 0L); // mismatch/base counts for non-dbSNP loci
|
||||||
private static final double DBSNP_VS_NOVEL_MISMATCH_RATE = 2.0; // rate at which dbSNP sites (on an individual level) mismatch relative to novel sites (determined by looking at NA12878)
|
private static final double DBSNP_VS_NOVEL_MISMATCH_RATE = 2.0; // rate at which dbSNP sites (on an individual level) mismatch relative to novel sites (determined by looking at NA12878)
|
||||||
|
|
@ -269,6 +269,7 @@ public class CovariateCounterWalker extends LocusWalker<Integer, PrintStream> {
|
||||||
byte refBase;
|
byte refBase;
|
||||||
byte prevBase;
|
byte prevBase;
|
||||||
byte[] colorSpaceQuals;
|
byte[] colorSpaceQuals;
|
||||||
|
byte[] bases;
|
||||||
|
|
||||||
// For each read at this locus
|
// For each read at this locus
|
||||||
for ( PileupElement p : context.getPileup() ) {
|
for ( PileupElement p : context.getPileup() ) {
|
||||||
|
|
@ -284,16 +285,18 @@ public class CovariateCounterWalker extends LocusWalker<Integer, PrintStream> {
|
||||||
// Skip if base quality is zero
|
// Skip if base quality is zero
|
||||||
if( read.getBaseQualities()[offset] > 0 ) {
|
if( read.getBaseQualities()[offset] > 0 ) {
|
||||||
|
|
||||||
|
bases = read.getReadBases();
|
||||||
refBase = (byte)ref.getBase();
|
refBase = (byte)ref.getBase();
|
||||||
prevBase = read.getReadBases()[offset - 1];
|
prevBase = bases[offset - 1];
|
||||||
|
|
||||||
// DinucCovariate is responsible for getting the complement bases if needed
|
// DinucCovariate is responsible for getting the complement bases if needed
|
||||||
if( read.getReadNegativeStrandFlag() ) {
|
if( read.getReadNegativeStrandFlag() ) {
|
||||||
prevBase = read.getReadBases()[offset + 1];
|
prevBase = bases[offset + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip if this base or the previous one was an 'N' or etc.
|
// Skip if this base or the previous one was an 'N' or etc.
|
||||||
if( BaseUtils.isRegularBase( (char)prevBase ) && BaseUtils.isRegularBase( (char)(read.getReadBases()[offset]) ) ) {
|
// BUGBUG: For DinucCovariate we should use previous reference base, not the previous base in this read.
|
||||||
|
if( BaseUtils.isRegularBase( (char)prevBase ) && BaseUtils.isRegularBase( (char)(bases[offset]) ) ) {
|
||||||
|
|
||||||
// SOLID bams insert the reference base into the read if the color space quality is zero, so skip over them
|
// SOLID bams insert the reference base into the read if the color space quality is zero, so skip over them
|
||||||
colorSpaceQuals = null;
|
colorSpaceQuals = null;
|
||||||
|
|
|
||||||
|
|
@ -114,12 +114,9 @@ public class CycleCovariate implements Covariate {
|
||||||
}
|
}
|
||||||
warnedUserBadPlatform = true;
|
warnedUserBadPlatform = true;
|
||||||
}
|
}
|
||||||
//ReadHashDatum correctedReadDatum = new ReadHashDatum( readDatum );
|
read.getReadGroup().setPlatform( defaultPlatform );
|
||||||
//correctedReadDatum.platform = defaultPlatform;
|
return getValue( read, offset ); // a recursive call
|
||||||
return 0; // BUGBUG: broken at the moment
|
|
||||||
//return getValue( correctedReadDatum, offset ); // a recursive call
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used to get the covariate's value from input csv file in TableRecalibrationWalker
|
// Used to get the covariate's value from input csv file in TableRecalibrationWalker
|
||||||
|
|
|
||||||
|
|
@ -60,23 +60,20 @@ public class DinucCovariate implements Covariate {
|
||||||
|
|
||||||
byte base;
|
byte base;
|
||||||
byte prevBase;
|
byte prevBase;
|
||||||
|
byte[] bases = read.getReadBases();
|
||||||
// If this is a negative strand read then we need to reverse the direction for our previous base
|
// If this is a negative strand read then we need to reverse the direction for our previous base
|
||||||
if( read.getReadNegativeStrandFlag() ) {
|
if( read.getReadNegativeStrandFlag() ) {
|
||||||
base = (byte)BaseUtils.simpleComplement( (char)(read.getReadBases()[offset]) );
|
base = (byte)BaseUtils.simpleComplement( (char)(bases[offset]) );
|
||||||
prevBase = (byte)BaseUtils.simpleComplement( (char)(read.getReadBases()[offset + 1]) );
|
prevBase = (byte)BaseUtils.simpleComplement( (char)(bases[offset + 1]) );
|
||||||
} else {
|
} else {
|
||||||
base = read.getReadBases()[offset];
|
base = bases[offset];
|
||||||
prevBase = read.getReadBases()[offset - 1];
|
prevBase = bases[offset - 1];
|
||||||
}
|
}
|
||||||
//char[] charArray = {(char)prevBase, (char)base};
|
|
||||||
//return new String( charArray ); // This is an expensive call
|
|
||||||
return dinucHashMap.get( Dinuc.hashBytes( prevBase, base ) );
|
return dinucHashMap.get( Dinuc.hashBytes( prevBase, base ) );
|
||||||
//return String.format("%c%c", prevBase, base); // This return statement is too slow
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used to get the covariate's value from input csv file in TableRecalibrationWalker
|
// Used to get the covariate's value from input csv file in TableRecalibrationWalker
|
||||||
public final Comparable getValue( final String str ) {
|
public final Comparable getValue( final String str ) {
|
||||||
//return str;
|
|
||||||
return dinucHashMap.get( Dinuc.hashBytes( (byte)str.charAt(0), (byte)str.charAt(1) ) );
|
return dinucHashMap.get( Dinuc.hashBytes( (byte)str.charAt(0), (byte)str.charAt(1) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -252,15 +252,15 @@ public class RecalDataManager {
|
||||||
((GATKSAMRecord)read).setReadGroup( readGroup );
|
((GATKSAMRecord)read).setReadGroup( readGroup );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( RAC.FORCE_READ_GROUP != null && !read.getReadGroup().getReadGroupId().equals(RAC.FORCE_READ_GROUP) ) { // Collapse all the read groups into a single common String provided by the user
|
if( RAC.FORCE_READ_GROUP != null && !readGroup.getReadGroupId().equals(RAC.FORCE_READ_GROUP) ) { // Collapse all the read groups into a single common String provided by the user
|
||||||
String oldPlatform = readGroup.getPlatform();
|
String oldPlatform = readGroup.getPlatform();
|
||||||
readGroup = new SAMReadGroupRecord( RAC.FORCE_READ_GROUP );
|
readGroup = new SAMReadGroupRecord( RAC.FORCE_READ_GROUP );
|
||||||
readGroup.setPlatform( oldPlatform );
|
readGroup.setPlatform( oldPlatform );
|
||||||
((GATKSAMRecord)read).setReadGroup( readGroup );
|
((GATKSAMRecord)read).setReadGroup( readGroup );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( RAC.FORCE_PLATFORM != null && !read.getReadGroup().getPlatform().equals(RAC.FORCE_PLATFORM)) {
|
if( RAC.FORCE_PLATFORM != null && !readGroup.getPlatform().equals(RAC.FORCE_PLATFORM)) {
|
||||||
read.getReadGroup().setPlatform( RAC.FORCE_PLATFORM );
|
readGroup.setPlatform( RAC.FORCE_PLATFORM );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ public class TableRecalibrationWalker extends ReadWalker<SAMRecord, SAMFileWrite
|
||||||
private static final Pattern COMMENT_PATTERN = Pattern.compile("^#.*");
|
private static final Pattern COMMENT_PATTERN = Pattern.compile("^#.*");
|
||||||
private static final Pattern OLD_RECALIBRATOR_HEADER = Pattern.compile("^rg,.*");
|
private static final Pattern OLD_RECALIBRATOR_HEADER = Pattern.compile("^rg,.*");
|
||||||
private static final Pattern COVARIATE_PATTERN = Pattern.compile("^ReadGroup,QualityScore,.*");
|
private static final Pattern COVARIATE_PATTERN = Pattern.compile("^ReadGroup,QualityScore,.*");
|
||||||
private static final String versionString = "v2.0.7"; // Major version, minor version, and build number
|
private static final String versionString = "v2.0.8"; // Major version, minor version, and build number
|
||||||
private SAMFileWriter OUTPUT_BAM = null;// The File Writer that will write out the recalibrated bam
|
private SAMFileWriter OUTPUT_BAM = null;// The File Writer that will write out the recalibrated bam
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------
|
||||||
|
|
@ -257,7 +257,7 @@ public class TableRecalibrationWalker extends ReadWalker<SAMRecord, SAMFileWrite
|
||||||
// Check if the data line is malformed, for example if the read group string contains a comma then it won't be parsed correctly
|
// Check if the data line is malformed, for example if the read group string contains a comma then it won't be parsed correctly
|
||||||
if( vals.length != requestedCovariates.size() + 3 ) { // +3 because of nObservations, nMismatch, and Qempirical
|
if( vals.length != requestedCovariates.size() + 3 ) { // +3 because of nObservations, nMismatch, and Qempirical
|
||||||
throw new StingException("Malformed input recalibration file. Found data line with too many fields: " + line +
|
throw new StingException("Malformed input recalibration file. Found data line with too many fields: " + line +
|
||||||
" --Perhaps the read group string contains a comma and isn't parsed correctly.");
|
" --Perhaps the read group string contains a comma and isn't being parsed correctly.");
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<Comparable> key = new ArrayList<Comparable>();
|
ArrayList<Comparable> key = new ArrayList<Comparable>();
|
||||||
|
|
@ -483,6 +483,5 @@ public class TableRecalibrationWalker extends ReadWalker<SAMRecord, SAMFileWrite
|
||||||
if ( output != null ) {
|
if ( output != null ) {
|
||||||
output.close();
|
output.close();
|
||||||
}
|
}
|
||||||
super.onTraversalDone(output);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue