Cache SAMReadGroup rather than get it twice

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2087 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
alecw 2009-11-19 17:27:18 +00:00
parent 4082f4677e
commit b2b4ff7eca
1 changed files with 10 additions and 9 deletions

View File

@ -2,7 +2,6 @@ package org.broadinstitute.sting.playground.gatk.walkers.Recalibration;
import org.broadinstitute.sting.gatk.walkers.*; import org.broadinstitute.sting.gatk.walkers.*;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.refdata.rodDbSNP;
import org.broadinstitute.sting.gatk.refdata.ReferenceOrderedDatum; import org.broadinstitute.sting.gatk.refdata.ReferenceOrderedDatum;
import org.broadinstitute.sting.gatk.refdata.RODRecordList; import org.broadinstitute.sting.gatk.refdata.RODRecordList;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
@ -18,6 +17,7 @@ import java.io.FileNotFoundException;
import java.util.*; import java.util.*;
import net.sf.samtools.SAMRecord; import net.sf.samtools.SAMRecord;
import net.sf.samtools.SAMReadGroupRecord;
/* /*
* Copyright (c) 2009 The Broad Institute * Copyright (c) 2009 The Broad Institute
@ -233,7 +233,7 @@ public class CovariateCounterWalker extends LocusWalker<Integer, PrintStream> {
final List<Integer> offsets = context.getOffsets(); final List<Integer> offsets = context.getOffsets();
SAMRecord read; SAMRecord read;
int offset; int offset;
String readGroup; String readGroupId;
byte[] quals; byte[] quals;
byte[] bases; byte[] bases;
byte refBase; byte refBase;
@ -246,10 +246,10 @@ public class CovariateCounterWalker extends LocusWalker<Integer, PrintStream> {
for( int iii = 0; iii < numReads; iii++ ) { for( int iii = 0; iii < numReads; iii++ ) {
read = reads.get(iii); read = reads.get(iii);
//readGroup = readGroupHashMap.get( read ); //readGroupId = readGroupHashMap.get( read );
//if( readGroup == null ) { // read is not in the hashmap so add it //if( readGroupId == null ) { // read is not in the hashmap so add it
// readGroup = read.getReadGroup().getReadGroupId(); // readGroupId = read.getReadGroup().getReadGroupId();
// readGroupHashMap.put( read, readGroup ); // readGroupHashMap.put( read, readGroupId );
//} //}
offset = offsets.get(iii); // offset is zero based so quals[offset] and bases[offset] is correct offset = offsets.get(iii); // offset is zero based so quals[offset] and bases[offset] is correct
@ -284,8 +284,9 @@ public class CovariateCounterWalker extends LocusWalker<Integer, PrintStream> {
// 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)bases[offset] ) ) { if( BaseUtils.isRegularBase( (char)prevBase ) && BaseUtils.isRegularBase( (char)bases[offset] ) ) {
readGroup = read.getReadGroup().getReadGroupId(); // this is an expensive call final SAMReadGroupRecord readGroup = read.getReadGroup();
platform = read.getReadGroup().getPlatform(); // this is an expensive call readGroupId = readGroup.getReadGroupId(); // this is an expensive call
platform = readGroup.getPlatform(); // this is an expensive call
// 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;
@ -294,7 +295,7 @@ public class CovariateCounterWalker extends LocusWalker<Integer, PrintStream> {
} }
if( colorSpaceQuals == null || colorSpaceQuals[offset] > 0 ) //BUGBUG: This isn't exactly correct yet if( colorSpaceQuals == null || colorSpaceQuals[offset] > 0 ) //BUGBUG: This isn't exactly correct yet
{ {
updateDataFromRead( read, offset, readGroup, platform, quals, bases, refBase ); updateDataFromRead( read, offset, readGroupId, platform, quals, bases, refBase );
} }
} }
} }