Caching support across multiple technologies

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1480 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
depristo 2009-08-30 18:10:14 +00:00
parent 5af4bb628b
commit 522e4a77ae
2 changed files with 14 additions and 9 deletions

View File

@ -57,6 +57,13 @@ public class EmpiricalSubstitutionGenotypeLikelihoods extends NewHotnessGenotype
} }
} }
public static SequencerPlatform getReadSequencerPlatform( SAMRecord read ) {
final String readGroupString = ((String)read.getAttribute("RG"));
SAMReadGroupRecord readGroup = readGroupString == null ? null : read.getHeader().getReadGroup(readGroupString);
final String platformName = readGroup == null ? null : (String)readGroup.getAttribute(SAM_PLATFORM_TAG);
return standardizeSequencerPlatform(platformName);
}
// -------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------
// //
// Static methods to get at the transition tables themselves // Static methods to get at the transition tables themselves
@ -232,11 +239,7 @@ public class EmpiricalSubstitutionGenotypeLikelihoods extends NewHotnessGenotype
protected double log10PofTrueBaseGivenMiscall(char observedBase, char chromBase, SAMRecord read, int offset) { protected double log10PofTrueBaseGivenMiscall(char observedBase, char chromBase, SAMRecord read, int offset) {
boolean fwdStrand = ! read.getReadNegativeStrandFlag(); boolean fwdStrand = ! read.getReadNegativeStrandFlag();
SequencerPlatform pl = getReadSequencerPlatform(read);
final String readGroupString = ((String)read.getAttribute("RG"));
SAMReadGroupRecord readGroup = readGroupString == null ? null : read.getHeader().getReadGroup(readGroupString);
final String platformName = readGroup == null ? null : (String)readGroup.getAttribute(SAM_PLATFORM_TAG);
SequencerPlatform pl = standardizeSequencerPlatform(platformName);
if ( pl == SequencerPlatform.UNKNOWN ) { if ( pl == SequencerPlatform.UNKNOWN ) {
if ( raiseErrorOnUnknownPlatform ) if ( raiseErrorOnUnknownPlatform )

View File

@ -269,21 +269,23 @@ public class NewHotnessGenotypeLikelihoods extends GenotypeLikelihoods implement
// //
// //
// ----------------------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------------------
final static NewHotnessGenotypeLikelihoods[][][][] cache = new NewHotnessGenotypeLikelihoods[BaseUtils.BASES.length][QualityUtils.MAX_QUAL_SCORE][MAX_PLOIDY][2]; final static NewHotnessGenotypeLikelihoods[][][][][] cache =
new NewHotnessGenotypeLikelihoods[EmpiricalSubstitutionGenotypeLikelihoods.SequencerPlatform.values().length][BaseUtils.BASES.length][QualityUtils.MAX_QUAL_SCORE][MAX_PLOIDY][2];
static int cacheSize = 0; static int cacheSize = 0;
private NewHotnessGenotypeLikelihoods getSetCache( char observedBase, byte qualityScore, int ploidy, private NewHotnessGenotypeLikelihoods getSetCache( char observedBase, byte qualityScore, int ploidy,
SAMRecord read, int offset, NewHotnessGenotypeLikelihoods val ) { SAMRecord read, int offset, NewHotnessGenotypeLikelihoods val ) {
int a = EmpiricalSubstitutionGenotypeLikelihoods.getReadSequencerPlatform(read).ordinal();
int i = BaseUtils.simpleBaseToBaseIndex(observedBase); int i = BaseUtils.simpleBaseToBaseIndex(observedBase);
int j = qualityScore; int j = qualityScore;
int k = ploidy; int k = ploidy;
int x = strandIndex(! read.getReadNegativeStrandFlag()); int x = strandIndex(! read.getReadNegativeStrandFlag());
if ( val != null ) if ( val != null )
cache[i][j][k][x] = val; cache[a][i][j][k][x] = val;
return cache[i][j][k][x]; return cache[a][i][j][k][x];
} }
private NewHotnessGenotypeLikelihoods getCache( char observedBase, byte qualityScore, int ploidy, SAMRecord read, int offset ) { private NewHotnessGenotypeLikelihoods getCache( char observedBase, byte qualityScore, int ploidy, SAMRecord read, int offset ) {
@ -324,7 +326,7 @@ public class NewHotnessGenotypeLikelihoods extends GenotypeLikelihoods implement
setCache(observedBase, qualityScore, ploidy, read, offset, g); setCache(observedBase, qualityScore, ploidy, read, offset, g);
cacheSize++; cacheSize++;
//System.out.printf("Caching %c %d %d %d %b (%d total entries)%n", observedBase, BaseUtils.simpleBaseToBaseIndex(observedBase), qualityScore, ploidy, fwdStrand, cacheSize); //System.out.printf("Caching %c %d %d %s %s (%d total entries)%n", observedBase, qualityScore, ploidy, read.getReadName(), EmpiricalSubstitutionGenotypeLikelihoods.getReadSequencerPlatform(read), cacheSize);
return g; return g;
} catch ( CloneNotSupportedException e ) { } catch ( CloneNotSupportedException e ) {
throw new RuntimeException(e); throw new RuntimeException(e);