Optimizations across the board, with help from Guillermo, Matt, and JProfiler. Too tired to give details now.
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4535 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
f76865abbc
commit
91049269c2
|
|
@ -44,6 +44,7 @@ import org.broadinstitute.sting.utils.sam.ReadUtils;
|
||||||
public class HaplotypeScore implements InfoFieldAnnotation, StandardAnnotation {
|
public class HaplotypeScore implements InfoFieldAnnotation, StandardAnnotation {
|
||||||
private final static boolean DEBUG = false;
|
private final static boolean DEBUG = false;
|
||||||
private final static int MIN_CONTEXT_WING_SIZE = 10;
|
private final static int MIN_CONTEXT_WING_SIZE = 10;
|
||||||
|
private final static int MAX_CONSENSUS_HAPLOTYPES_TO_CONSIDER = 20;
|
||||||
private final static char REGEXP_WILDCARD = '.';
|
private final static char REGEXP_WILDCARD = '.';
|
||||||
|
|
||||||
public Map<String, Object> annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map<String, StratifiedAlignmentContext> stratifiedContexts, VariantContext vc) {
|
public Map<String, Object> annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map<String, StratifiedAlignmentContext> stratifiedContexts, VariantContext vc) {
|
||||||
|
|
@ -124,7 +125,7 @@ public class HaplotypeScore implements InfoFieldAnnotation, StandardAnnotation {
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!foundHaplotypeMatch) {
|
if (!foundHaplotypeMatch && haplotypeList.size() < MAX_CONSENSUS_HAPLOTYPES_TO_CONSIDER) {
|
||||||
haplotypeList.add(elem);
|
haplotypeList.add(elem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -293,7 +294,7 @@ public class HaplotypeScore implements InfoFieldAnnotation, StandardAnnotation {
|
||||||
byte haplotypeBase = haplotypeBases[i];
|
byte haplotypeBase = haplotypeBases[i];
|
||||||
byte readBase = readBases[baseOffset];
|
byte readBase = readBases[baseOffset];
|
||||||
|
|
||||||
boolean matched = BaseUtils.basesAreEqual(readBase, haplotypeBase );
|
boolean matched = readBase == haplotypeBase;
|
||||||
double e = QualityUtils.qualToErrorProb(readQuals[baseOffset]);
|
double e = QualityUtils.qualToErrorProb(readQuals[baseOffset]);
|
||||||
expected += e;
|
expected += e;
|
||||||
mismatches += matched ? e : 1 - e / 3;
|
mismatches += matched ? e : 1 - e / 3;
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,13 @@ public class RMSMappingQuality implements InfoFieldAnnotation, StandardAnnotatio
|
||||||
if ( stratifiedContexts.size() == 0 )
|
if ( stratifiedContexts.size() == 0 )
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
ArrayList<Integer> qualities = new ArrayList<Integer>();
|
int totalSize = 0;
|
||||||
|
for ( StratifiedAlignmentContext context : stratifiedContexts.values() )
|
||||||
|
totalSize += context.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).size();
|
||||||
|
|
||||||
|
int[] qualities = new int[totalSize];
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
for ( Map.Entry<String, StratifiedAlignmentContext> sample : stratifiedContexts.entrySet() ) {
|
for ( Map.Entry<String, StratifiedAlignmentContext> sample : stratifiedContexts.entrySet() ) {
|
||||||
AlignmentContext context = sample.getValue().getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE);
|
AlignmentContext context = sample.getValue().getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE);
|
||||||
ReadBackedPileup pileup = null;
|
ReadBackedPileup pileup = null;
|
||||||
|
|
@ -34,14 +40,11 @@ public class RMSMappingQuality implements InfoFieldAnnotation, StandardAnnotatio
|
||||||
|
|
||||||
if (pileup != null) {
|
if (pileup != null) {
|
||||||
for (PileupElement p : pileup )
|
for (PileupElement p : pileup )
|
||||||
qualities.add(p.getRead().getMappingQuality());
|
qualities[index++] = p.getRead().getMappingQuality();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int[] quals = new int[qualities.size()];
|
|
||||||
int index = 0;
|
double rms = MathUtils.rms(qualities);
|
||||||
for ( Integer i : qualities )
|
|
||||||
quals[index++] = i;
|
|
||||||
double rms = MathUtils.rms(quals);
|
|
||||||
Map<String, Object> map = new HashMap<String, Object>();
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
map.put(getKeyNames().get(0), String.format("%.2f", rms));
|
map.put(getKeyNames().get(0), String.format("%.2f", rms));
|
||||||
return map;
|
return map;
|
||||||
|
|
|
||||||
|
|
@ -318,12 +318,6 @@ public class UnifiedGenotyperEngine {
|
||||||
|
|
||||||
ReadBackedPileup pileup = rawContext.getBasePileup();
|
ReadBackedPileup pileup = rawContext.getBasePileup();
|
||||||
|
|
||||||
// filter the reads
|
|
||||||
filterPileup(pileup, badBaseFilter);
|
|
||||||
|
|
||||||
// filter the context based on bad mates and mismatch rate
|
|
||||||
//pileup = pileup.getFilteredPileup(badReadPileupFilter);
|
|
||||||
|
|
||||||
// don't call when there is no coverage
|
// don't call when there is no coverage
|
||||||
if ( pileup.size() == 0 && !UAC.ALL_BASES_MODE )
|
if ( pileup.size() == 0 && !UAC.ALL_BASES_MODE )
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -335,6 +329,9 @@ public class UnifiedGenotyperEngine {
|
||||||
|
|
||||||
// stratify the AlignmentContext and cut by sample
|
// stratify the AlignmentContext and cut by sample
|
||||||
stratifiedContexts = StratifiedAlignmentContext.splitContextBySample(pileup, UAC.ASSUME_SINGLE_SAMPLE);
|
stratifiedContexts = StratifiedAlignmentContext.splitContextBySample(pileup, UAC.ASSUME_SINGLE_SAMPLE);
|
||||||
|
|
||||||
|
// filter the reads
|
||||||
|
filterPileup(stratifiedContexts, badBaseFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
return stratifiedContexts;
|
return stratifiedContexts;
|
||||||
|
|
@ -405,11 +402,14 @@ public class UnifiedGenotyperEngine {
|
||||||
verboseWriter.println();
|
verboseWriter.println();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void filterPileup(ReadBackedPileup pileup, BadBaseFilter badBaseFilter) {
|
private void filterPileup(Map<String, StratifiedAlignmentContext> stratifiedContexts, BadBaseFilter badBaseFilter) {
|
||||||
for ( PileupElement p : pileup ) {
|
for ( StratifiedAlignmentContext context : stratifiedContexts.values() ) {
|
||||||
final SAMRecord read = p.getRead();
|
ReadBackedPileup pileup = context.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getBasePileup();
|
||||||
if ( read instanceof GATKSAMRecord )
|
for ( PileupElement p : pileup ) {
|
||||||
((GATKSAMRecord)read).setGoodBases(badBaseFilter, true);
|
final SAMRecord read = p.getRead();
|
||||||
|
if ( read instanceof GATKSAMRecord )
|
||||||
|
((GATKSAMRecord)read).setGoodBases(badBaseFilter, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue