From 0748d80baac56f5f2086a481170efe2f666322d4 Mon Sep 17 00:00:00 2001 From: ebanks Date: Tue, 22 Sep 2009 20:15:40 +0000 Subject: [PATCH] Added a convenience method in rodDbSNP to deal with Andrey's changes to the rod. Now you can just ask for the first real SNP rod from the list and not have to think about how it works. CountCovariates uses it. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1688 348d0f76-0448-11de-a6fe-93d51630548a --- .../sting/gatk/refdata/rodDbSNP.java | 15 +++++++++++++++ .../recalibration/CovariateCounterWalker.java | 12 +++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/refdata/rodDbSNP.java b/java/src/org/broadinstitute/sting/gatk/refdata/rodDbSNP.java index 5d2250b93..c74ff0335 100644 --- a/java/src/org/broadinstitute/sting/gatk/refdata/rodDbSNP.java +++ b/java/src/org/broadinstitute/sting/gatk/refdata/rodDbSNP.java @@ -386,4 +386,19 @@ public class rodDbSNP extends BasicReferenceOrderedDatum implements Variation, V public boolean hasGenotype(DiploidGenotype x) { return (!x.toString().equals(this.getAltBasesFWD())) ? false : true; } + + public static rodDbSNP getFirstRealSNP(RODRecordList dbsnpList) { + if ( dbsnpList == null ) + return null; + + rodDbSNP dbsnp = null; + for ( ReferenceOrderedDatum d : dbsnpList ) { + if ( ((rodDbSNP)d).isSNP() ) { + dbsnp = (rodDbSNP)d; + break; + } + } + + return dbsnp; + } } diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/recalibration/CovariateCounterWalker.java b/java/src/org/broadinstitute/sting/gatk/walkers/recalibration/CovariateCounterWalker.java index c488a5220..25bb01748 100644 --- a/java/src/org/broadinstitute/sting/gatk/walkers/recalibration/CovariateCounterWalker.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/recalibration/CovariateCounterWalker.java @@ -77,11 +77,6 @@ public class CovariateCounterWalker extends LocusWalker { } covariateCounter = new CovariateCounter(readGroups, collapsePos, collapseDinuc, assumeFaultyHeader); - // THIS IS A HACK required in order to reproduce the behavior of old (and imperfect) RODIterator and - // hence to pass the integration test. The new iterator this code is now using does see ALL the SNPs, - // whether masked by overlapping indels/other events or not. - //TODO process correctly all the returned dbSNP rods at each location - BrokenRODSimulator.attach("dbSNP"); logger.info(String.format("Created recalibration data collectors for %d read group(s)", covariateCounter.getNReadGroups())); } @@ -102,7 +97,8 @@ public class CovariateCounterWalker extends LocusWalker { */ public Integer map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) { - rodDbSNP dbsnp = (rodDbSNP)BrokenRODSimulator.simulate_lookup("dbSNP",ref.getLocus(),tracker); + rodDbSNP dbsnp = rodDbSNP.getFirstRealSNP(tracker.getTrackData("dbsnp", null)); + // long testpos = 10410913 ; // if ( ref.getLocus().getStart() == testpos ) { // System.out.println(rods.size()+" rods:"); @@ -110,9 +106,7 @@ public class CovariateCounterWalker extends LocusWalker { // System.exit(1); // } - - - if ( dbsnp == null || !dbsnp.isSNP() ) { + if ( dbsnp == null ) { // We aren't at a dbSNP position that's a SNP, so update the read // if ( ref.getLocus().getStart() == testpos) System.out.println("NOT A SNP INDEED");