From 9b2fcc4711312b3bdde70e4596c59ec8a7a92aa1 Mon Sep 17 00:00:00 2001 From: ebanks Date: Wed, 9 Jun 2010 17:05:51 +0000 Subject: [PATCH] Refactoring of the annotation system: 1. VA is now a ROD walker so it no longer requires reads (needs a little more testing) 2. Annotations can now represent multiple INFO fields (i.e. sets of key/value pairs) 3. The chromosome count annotations have been pulled out of UG and the VCF writer code and into VA where they belong. Fixed the headers too. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3513 348d0f76-0448-11de-a6fe-93d51630548a --- .../gatk/refdata/VariantContextAdaptors.java | 12 ++- .../gatk/walkers/annotator/Alignability.java | 8 +- .../gatk/walkers/annotator/AlleleBalance.java | 13 ++-- .../annotator/BaseQualityRankSumTest.java | 12 +-- .../walkers/annotator/ChromosomeCounts.java | 74 +++++++++++++++++++ .../walkers/annotator/DepthOfCoverage.java | 8 +- .../annotator/DepthPerAlleleBySample.java | 17 ++--- .../gatk/walkers/annotator/GCContent.java | 8 +- .../walkers/annotator/HaplotypeScore.java | 6 +- .../gatk/walkers/annotator/HardyWeinberg.java | 8 +- .../walkers/annotator/HomopolymerRun.java | 8 +- .../sting/gatk/walkers/annotator/LowMQ.java | 8 +- .../annotator/MappingQualityRankSumTest.java | 14 ++-- .../walkers/annotator/MappingQualityZero.java | 8 +- .../gatk/walkers/annotator/QualByDepth.java | 8 +- .../QualityAdjustedSecondBaseLod.java | 8 +- .../walkers/annotator/RMSMappingQuality.java | 10 +-- .../gatk/walkers/annotator/RankSumTest.java | 6 +- .../walkers/annotator/SecondBaseSkew.java | 8 +- .../walkers/annotator/SpanningDeletions.java | 8 +- .../walkers/annotator/VariantAnnotator.java | 2 +- .../annotator/VariantAnnotatorEngine.java | 4 +- .../interfaces/GenotypeAnnotation.java | 9 ++- .../interfaces/InfoFieldAnnotation.java | 9 ++- ...JointEstimateGenotypeCalculationModel.java | 3 - .../walkers/genotyper/UnifiedGenotyper.java | 3 - .../AnnotationByAlleleFrequencyWalker.java | 3 +- .../annotator/InsertSizeDistribution.java | 8 +- .../ProportionOfNonrefBasesSupportingSNP.java | 11 +-- ...oportionOfRefSecondBasesSupportingSNP.java | 12 +-- ...oportionOfSNPSecondBasesSupportingRef.java | 12 +-- .../annotator/ThousandGenomesAnnotator.java | 14 ++-- .../walkers/annotator/GenomicAnnotation.java | 14 ++-- .../vcf/VCFGenotypeWriterAdapter.java | 14 ---- .../VariantAnnotatorIntegrationTest.java | 8 +- .../UnifiedGenotyperIntegrationTest.java | 22 +++--- 36 files changed, 244 insertions(+), 156 deletions(-) create mode 100755 java/src/org/broadinstitute/sting/gatk/walkers/annotator/ChromosomeCounts.java diff --git a/java/src/org/broadinstitute/sting/gatk/refdata/VariantContextAdaptors.java b/java/src/org/broadinstitute/sting/gatk/refdata/VariantContextAdaptors.java index 8c03e9ae1..973a89e2c 100755 --- a/java/src/org/broadinstitute/sting/gatk/refdata/VariantContextAdaptors.java +++ b/java/src/org/broadinstitute/sting/gatk/refdata/VariantContextAdaptors.java @@ -383,7 +383,17 @@ public class VariantContextAdaptors { result = VCFGenotypeRecord.getMissingFieldValue(key); else if ( val instanceof Double ) result = String.format("%.2f", (Double)val); - else + else if ( val instanceof List ) { + List list = (List)val; + if ( list.size() == 0 ) + return formatVCFField(key, null); + StringBuffer sb = new StringBuffer(formatVCFField(key, list.get(0))); + for ( int i = 1; i < list.size(); i++) { + sb.append(","); + sb.append(formatVCFField(key, list.get(i))); + } + result = sb.toString(); + } else result = val.toString(); return result; diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/Alignability.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/Alignability.java index f4f481c9b..ffdf8bf49 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/Alignability.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/Alignability.java @@ -10,6 +10,8 @@ import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnot import java.util.HashMap; import java.util.Map; +import java.util.List; +import java.util.Arrays; public class Alignability implements InfoFieldAnnotation { @@ -29,11 +31,11 @@ public class Alignability implements InfoFieldAnnotation { int value = Integer.parseInt(record.get("alignability")); Map map = new HashMap(); - map.put(getKeyName(), String.format("%d", value)); + map.put(getKeyNames().get(0), String.format("%d", value)); return map; } - public String getKeyName() { return "Alignability"; } + public List getKeyNames() { return Arrays.asList("Alignability"); } - public VCFInfoHeaderLine getDescription() { return new VCFInfoHeaderLine(getKeyName(), 1, VCFInfoHeaderLine.INFO_TYPE.Integer, "Alignability according to a mask file (3 is best, 0 is worst)"); } + public List getDescriptions() { return Arrays.asList(new VCFInfoHeaderLine(getKeyNames().get(0), 1, VCFInfoHeaderLine.INFO_TYPE.Integer, "Alignability according to a mask file (3 is best, 0 is worst)")); } } diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalance.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalance.java index 7f6b5d4d4..63aee013c 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalance.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalance.java @@ -26,7 +26,6 @@ package org.broadinstitute.sting.gatk.walkers.annotator; import org.broad.tribble.vcf.VCFInfoHeaderLine; -import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.gatk.contexts.variantcontext.*; @@ -37,6 +36,8 @@ import org.broadinstitute.sting.utils.pileup.ReadBackedExtendedEventPileup; import java.util.Map; import java.util.HashMap; +import java.util.List; +import java.util.Arrays; public class AlleleBalance implements InfoFieldAnnotation, StandardAnnotation { @@ -46,10 +47,8 @@ public class AlleleBalance implements InfoFieldAnnotation, StandardAnnotation { if ( !vc.isBiallelic() ) return null; final Map genotypes = vc.getGenotypes(); - if ( genotypes == null || genotypes.size() == 0 ) { - System.out.println("No genotypes for vc at "+ref.getLocus().toString()); + if ( !vc.hasGenotypes() ) return null; - } double ratio = 0.0; double totalWeights = 0.0; @@ -102,11 +101,11 @@ public class AlleleBalance implements InfoFieldAnnotation, StandardAnnotation { return null; Map map = new HashMap(); - map.put(getKeyName(), String.format("%.2f", (ratio / totalWeights))); + map.put(getKeyNames().get(0), String.format("%.2f", (ratio / totalWeights))); return map; } - public String getKeyName() { return "AB"; } + public List getKeyNames() { return Arrays.asList("AB"); } - public VCFInfoHeaderLine getDescription() { return new VCFInfoHeaderLine("AB", 1, VCFInfoHeaderLine.INFO_TYPE.Float, "Allele Balance for hets (ref/(ref+alt))"); } + public List getDescriptions() { return Arrays.asList(new VCFInfoHeaderLine("AB", 1, VCFInfoHeaderLine.INFO_TYPE.Float, "Allele Balance for hets (ref/(ref+alt))")); } } diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/BaseQualityRankSumTest.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/BaseQualityRankSumTest.java index 14bbcee3d..b322f2a2b 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/BaseQualityRankSumTest.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/BaseQualityRankSumTest.java @@ -5,24 +5,24 @@ import org.broadinstitute.sting.utils.pileup.ReadBackedPileup; import org.broadinstitute.sting.utils.pileup.PileupElement; import java.util.List; +import java.util.Arrays; public class BaseQualityRankSumTest /*extends RankSumTest*/ { // todo -- seems math in this test is dubious, need to recheck and verify (p-values wildly divergent from R or MATLAB) - public String getKeyName() { return "BaseQRankSum"; } + public List getKeyNames() { return Arrays.asList("BaseQRankSum"); } - public VCFInfoHeaderLine getDescription() { return new VCFInfoHeaderLine("BaseQRankSum", 1, VCFInfoHeaderLine.INFO_TYPE.Float, "Phred-scaled p-value From Wilcoxon Rank Sum Test of Het Vs. Ref Base Qualities"); } + public List getDescriptions() { return Arrays.asList(new VCFInfoHeaderLine("BaseQRankSum", 1, VCFInfoHeaderLine.INFO_TYPE.Float, "Phred-scaled p-value From Wilcoxon Rank Sum Test of Het Vs. Ref Base Qualities")); } - protected void fillQualsFromPileup(char ref, char alt, ReadBackedPileup pileup, List refQuals, List altQuals) { + protected void fillQualsFromPileup(byte ref, char alt, ReadBackedPileup pileup, List refQuals, List altQuals) { for ( PileupElement p : pileup ) { // ignore deletions if ( p.isDeletion() ) continue; - char base = (char)p.getBase(); - if ( base == ref ) + if ( p.getBase() == ref ) refQuals.add((int)p.getQual()); - else if ( base == alt ) + else if ( (char)p.getBase() == alt ) altQuals.add((int)p.getQual()); } } diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/ChromosomeCounts.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/ChromosomeCounts.java new file mode 100755 index 000000000..a0183b118 --- /dev/null +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/ChromosomeCounts.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2010. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package org.broadinstitute.sting.gatk.walkers.annotator; + +import org.broad.tribble.vcf.VCFInfoHeaderLine; +import org.broad.tribble.vcf.VCFRecord; +import org.broadinstitute.sting.gatk.contexts.ReferenceContext; +import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; +import org.broadinstitute.sting.gatk.contexts.variantcontext.*; +import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; +import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.*; + +import java.util.*; + + +public class ChromosomeCounts implements InfoFieldAnnotation, StandardAnnotation { + + private String[] keyNames = { VCFRecord.ALLELE_NUMBER_KEY, VCFRecord.ALLELE_COUNT_KEY, VCFRecord.ALLELE_FREQUENCY_KEY }; + private VCFInfoHeaderLine[] descriptions = { new VCFInfoHeaderLine(VCFRecord.ALLELE_FREQUENCY_KEY, -1, VCFInfoHeaderLine.INFO_TYPE.Float, "Allele Frequency"), + new VCFInfoHeaderLine(VCFRecord.ALLELE_COUNT_KEY, -1, VCFInfoHeaderLine.INFO_TYPE.Integer, "Allele count in genotypes, for each ALT allele, in the same order as listed"), + new VCFInfoHeaderLine(VCFRecord.ALLELE_NUMBER_KEY, 1, VCFInfoHeaderLine.INFO_TYPE.Integer, "Total number of alleles in called genotypes") }; + + public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + + if ( vc.getChromosomeCount() == 0 ) + return null; + + Map map = new HashMap(); + map.put(VCFRecord.ALLELE_NUMBER_KEY, vc.getChromosomeCount()); + + if ( vc.getAlternateAlleles().size() > 0 ) { + ArrayList alleleFreqs = new ArrayList(); + ArrayList alleleCounts = new ArrayList(); + for ( Allele allele : vc.getAlternateAlleles() ) { + alleleCounts.add(vc.getChromosomeCount(allele)); + alleleFreqs.add((double)vc.getChromosomeCount(allele) / (double)vc.getChromosomeCount()); + } + + map.put(VCFRecord.ALLELE_COUNT_KEY, alleleCounts); + map.put(VCFRecord.ALLELE_FREQUENCY_KEY, alleleFreqs); + } + + return map; + } + + public List getKeyNames() { + return Arrays.asList(keyNames); + } + + public List getDescriptions() { return Arrays.asList(descriptions); } +} \ No newline at end of file diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthOfCoverage.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthOfCoverage.java index 39e072e4d..a016e9116 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthOfCoverage.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthOfCoverage.java @@ -10,6 +10,8 @@ import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.*; import java.util.Map; import java.util.HashMap; +import java.util.List; +import java.util.Arrays; public class DepthOfCoverage implements InfoFieldAnnotation, StandardAnnotation { @@ -19,11 +21,11 @@ public class DepthOfCoverage implements InfoFieldAnnotation, StandardAnnotation for ( String sample : stratifiedContexts.keySet() ) depth += stratifiedContexts.get(sample).getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).size(); Map map = new HashMap(); - map.put(getKeyName(), String.format("%d", depth)); + map.put(getKeyNames().get(0), String.format("%d", depth)); return map; } - public String getKeyName() { return VCFRecord.DEPTH_KEY; } + public List getKeyNames() { return Arrays.asList(VCFRecord.DEPTH_KEY); } - public VCFInfoHeaderLine getDescription() { return new VCFInfoHeaderLine(getKeyName(), 1, VCFInfoHeaderLine.INFO_TYPE.Integer, "Total Depth"); } + public List getDescriptions() { return Arrays.asList(new VCFInfoHeaderLine(getKeyNames().get(0), 1, VCFInfoHeaderLine.INFO_TYPE.Integer, "Total Depth")); } } diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthPerAlleleBySample.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthPerAlleleBySample.java index f3fef4497..fd92fb108 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthPerAlleleBySample.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthPerAlleleBySample.java @@ -13,20 +13,19 @@ import java.util.*; public class DepthPerAlleleBySample implements GenotypeAnnotation, ExperimentalAnnotation { public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, StratifiedAlignmentContext stratifiedContext, VariantContext vc, Genotype g) { - // for now, we don't support indels if ( g == null || !g.isCalled() ) return null; if ( vc.isSNP() ) { - return annotateSNP(tracker,ref,stratifiedContext,vc,g); + return annotateSNP(stratifiedContext, vc); } else if ( vc.isIndel() ) { - return annotateIndel(tracker,ref,stratifiedContext,vc,g); + return annotateIndel(stratifiedContext, vc); } else { return null; } } - public Map annotateSNP(RefMetaDataTracker tracker, ReferenceContext ref, StratifiedAlignmentContext stratifiedContext, VariantContext vc, Genotype g) { + private Map annotateSNP(StratifiedAlignmentContext stratifiedContext, VariantContext vc) { Set altAlleles = vc.getAlternateAlleles(); if ( altAlleles.size() == 0 ) @@ -53,11 +52,11 @@ public class DepthPerAlleleBySample implements GenotypeAnnotation, ExperimentalA } Map map = new HashMap(); - map.put(getKeyName(), sb.toString()); + map.put(getKeyNames().get(0), sb.toString()); return map; } - public Map annotateIndel(RefMetaDataTracker tracker, ReferenceContext ref, StratifiedAlignmentContext stratifiedContext, VariantContext vc, Genotype g) { + private Map annotateIndel(StratifiedAlignmentContext stratifiedContext, VariantContext vc) { ReadBackedExtendedEventPileup pileup = stratifiedContext.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getExtendedEventPileup(); if ( pileup == null ) { return null; @@ -88,11 +87,11 @@ public class DepthPerAlleleBySample implements GenotypeAnnotation, ExperimentalA } Map map = new HashMap(); - map.put(getKeyName(),sb.toString()); + map.put(getKeyNames().get(0),sb.toString()); return map; } - public String getKeyName() { return "AD"; } + public List getKeyNames() { return Arrays.asList("AD"); } - public VCFFormatHeaderLine getDescription() { return new VCFFormatHeaderLine(getKeyName(), 1, VCFFormatHeaderLine.FORMAT_TYPE.Integer, "Depth in genotypes for each ALT allele, in the same order as listed"); } + public List getDescriptions() { return Arrays.asList(new VCFFormatHeaderLine(getKeyNames().get(0), -1, VCFFormatHeaderLine.FORMAT_TYPE.Integer, "Depth in genotypes for each ALT allele, in the same order as listed")); } } \ No newline at end of file diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/GCContent.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/GCContent.java index ed45a9099..9e6003481 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/GCContent.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/GCContent.java @@ -10,6 +10,8 @@ import org.broadinstitute.sting.utils.BaseUtils; import java.util.Map; import java.util.HashMap; +import java.util.List; +import java.util.Arrays; public class GCContent implements InfoFieldAnnotation, ExperimentalAnnotation { @@ -17,13 +19,13 @@ public class GCContent implements InfoFieldAnnotation, ExperimentalAnnotation { public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { double content = computeGCContent(ref); Map map = new HashMap(); - map.put(getKeyName(), String.format("%.2f", content)); + map.put(getKeyNames().get(0), String.format("%.2f", content)); return map; } - public String getKeyName() { return "GC"; } + public List getKeyNames() { return Arrays.asList("GC"); } - public VCFInfoHeaderLine getDescription() { return new VCFInfoHeaderLine("GC", 1, VCFInfoHeaderLine.INFO_TYPE.Integer, "GC content within 20 bp +/- the variant"); } + public List getDescriptions() { return Arrays.asList(new VCFInfoHeaderLine("GC", 1, VCFInfoHeaderLine.INFO_TYPE.Integer, "GC content within 20 bp +/- the variant")); } public boolean useZeroQualityReads() { return false; } diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HaplotypeScore.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HaplotypeScore.java index cf726ed65..8c68afd2a 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HaplotypeScore.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HaplotypeScore.java @@ -69,7 +69,7 @@ public class HaplotypeScore implements InfoFieldAnnotation, StandardAnnotation { // return the score Map map = new HashMap(); - map.put(getKeyName(), String.format("%.2f", score)); + map.put(getKeyNames().get(0), String.format("%.2f", score)); return map; } @@ -281,6 +281,6 @@ public class HaplotypeScore implements InfoFieldAnnotation, StandardAnnotation { return new ReadBackedPileup(pileup.getLocation(), filteredPileup); } - public String getKeyName() { return "HaplotypeScore"; } - public VCFInfoHeaderLine getDescription() { return new VCFInfoHeaderLine("HaplotypeScore", 1, VCFInfoHeaderLine.INFO_TYPE.Float, "Consistency of the site with two (and only two) segregating haplotypes"); } + public List getKeyNames() { return Arrays.asList("HaplotypeScore"); } + public List getDescriptions() { return Arrays.asList(new VCFInfoHeaderLine("HaplotypeScore", 1, VCFInfoHeaderLine.INFO_TYPE.Float, "Consistency of the site with two (and only two) segregating haplotypes")); } } \ No newline at end of file diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HardyWeinberg.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HardyWeinberg.java index edd579490..036f267f3 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HardyWeinberg.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HardyWeinberg.java @@ -11,6 +11,8 @@ import org.broadinstitute.sting.utils.QualityUtils; import java.util.Map; import java.util.HashMap; +import java.util.List; +import java.util.Arrays; public class HardyWeinberg implements InfoFieldAnnotation, WorkInProgressAnnotation { @@ -55,11 +57,11 @@ public class HardyWeinberg implements InfoFieldAnnotation, WorkInProgressAnnotat double pvalue = HardyWeinbergCalculation.hwCalculate(refCount, hetCount, homCount); //System.out.println(refCount + " " + hetCount + " " + homCount + " " + pvalue); Map map = new HashMap(); - map.put(getKeyName(), String.format("%.1f", QualityUtils.phredScaleErrorRate(pvalue))); + map.put(getKeyNames().get(0), String.format("%.1f", QualityUtils.phredScaleErrorRate(pvalue))); return map; } - public String getKeyName() { return "HW"; } + public List getKeyNames() { return Arrays.asList("HW"); } - public VCFInfoHeaderLine getDescription() { return new VCFInfoHeaderLine("HW", 1, VCFInfoHeaderLine.INFO_TYPE.Float, "Phred-scaled p-value for Hardy-Weinberg violation"); } + public List getDescriptions() { return Arrays.asList(new VCFInfoHeaderLine("HW", 1, VCFInfoHeaderLine.INFO_TYPE.Float, "Phred-scaled p-value for Hardy-Weinberg violation")); } } \ No newline at end of file diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HomopolymerRun.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HomopolymerRun.java index 2dbe70c09..fa4df7288 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HomopolymerRun.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HomopolymerRun.java @@ -11,6 +11,8 @@ import org.broadinstitute.sting.utils.GenomeLoc; import java.util.Map; import java.util.HashMap; +import java.util.List; +import java.util.Arrays; public class HomopolymerRun implements InfoFieldAnnotation, StandardAnnotation { @@ -32,13 +34,13 @@ public class HomopolymerRun implements InfoFieldAnnotation, StandardAnnotation { } Map map = new HashMap(); - map.put(getKeyName(), String.format("%d", run)); + map.put(getKeyNames().get(0), String.format("%d", run)); return map; } - public String getKeyName() { return "HRun"; } + public List getKeyNames() { return Arrays.asList("HRun"); } - public VCFInfoHeaderLine getDescription() { return new VCFInfoHeaderLine("HRun", 1, VCFInfoHeaderLine.INFO_TYPE.Integer, "Largest Contiguous Homopolymer Run of Variant Allele In Either Direction"); } + public List getDescriptions() { return Arrays.asList(new VCFInfoHeaderLine("HRun", 1, VCFInfoHeaderLine.INFO_TYPE.Integer, "Largest Contiguous Homopolymer Run of Variant Allele In Either Direction")); } public boolean useZeroQualityReads() { return false; } diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/LowMQ.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/LowMQ.java index 1100db5c8..a13f08abf 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/LowMQ.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/LowMQ.java @@ -11,6 +11,8 @@ import org.broadinstitute.sting.utils.pileup.PileupElement; import java.util.Map; import java.util.HashMap; +import java.util.List; +import java.util.Arrays; public class LowMQ implements InfoFieldAnnotation { @@ -30,11 +32,11 @@ public class LowMQ implements InfoFieldAnnotation { } } Map map = new HashMap(); - map.put(getKeyName(), String.format("%.04f,%.04f,%.00f", mq0/total, mq10/total, total)); + map.put(getKeyNames().get(0), String.format("%.04f,%.04f,%.00f", mq0/total, mq10/total, total)); return map; } - public String getKeyName() { return "LowMQ"; } + public List getKeyNames() { return Arrays.asList("LowMQ"); } - public VCFInfoHeaderLine getDescription() { return new VCFInfoHeaderLine(getKeyName(), 1, VCFInfoHeaderLine.INFO_TYPE.Integer, "3-tuple: ,,"); } + public List getDescriptions() { return Arrays.asList(new VCFInfoHeaderLine(getKeyNames().get(0), 3, VCFInfoHeaderLine.INFO_TYPE.Integer, "3-tuple: ,,")); } } diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityRankSumTest.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityRankSumTest.java index 07dc64102..5062919cb 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityRankSumTest.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityRankSumTest.java @@ -5,24 +5,24 @@ import org.broadinstitute.sting.utils.pileup.ReadBackedPileup; import org.broadinstitute.sting.utils.pileup.PileupElement; import java.util.List; +import java.util.Arrays; -public class MappingQualityRankSumTest extends RankSumTest { +public class MappingQualityRankSumTest /*extends RankSumTest*/ { - public String getKeyName() { return "MQRankSum"; } + public List getKeyNames() { return Arrays.asList("MQRankSum"); } - public VCFInfoHeaderLine getDescription() { return new VCFInfoHeaderLine("MQRankSum", 1, VCFInfoHeaderLine.INFO_TYPE.Float, "Phred-scaled p-value From Wilcoxon Rank Sum Test of Het Vs. Ref Read Mapping Qualities"); } + public List getDescriptions() { return Arrays.asList(new VCFInfoHeaderLine("MQRankSum", 1, VCFInfoHeaderLine.INFO_TYPE.Float, "Phred-scaled p-value From Wilcoxon Rank Sum Test of Het Vs. Ref Read Mapping Qualities")); } - protected void fillQualsFromPileup(char ref, char alt, ReadBackedPileup pileup, List refQuals, List altQuals) { + protected void fillQualsFromPileup(byte ref, char alt, ReadBackedPileup pileup, List refQuals, List altQuals) { for ( PileupElement p : pileup ) { // ignore deletions if ( p.isDeletion() ) continue; - char base = (char)p.getBase(); - if ( base == ref ) + if ( p.getBase() == ref ) refQuals.add(p.getMappingQual()); - else if ( base == alt ) + else if ( (char)p.getBase() == alt ) altQuals.add(p.getMappingQual()); } } diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZero.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZero.java index dee2dd145..d9f7e684c 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZero.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZero.java @@ -12,6 +12,8 @@ import org.broadinstitute.sting.utils.pileup.PileupElement; import java.util.Map; import java.util.HashMap; +import java.util.List; +import java.util.Arrays; public class MappingQualityZero implements InfoFieldAnnotation, StandardAnnotation { @@ -26,11 +28,11 @@ public class MappingQualityZero implements InfoFieldAnnotation, StandardAnnotati } } Map map = new HashMap(); - map.put(getKeyName(), String.format("%d", mq0)); + map.put(getKeyNames().get(0), String.format("%d", mq0)); return map; } - public String getKeyName() { return "MQ0"; } + public List getKeyNames() { return Arrays.asList("MQ0"); } - public VCFInfoHeaderLine getDescription() { return new VCFInfoHeaderLine(getKeyName(), 1, VCFInfoHeaderLine.INFO_TYPE.Integer, "Total Mapping Quality Zero Reads"); } + public List getDescriptions() { return Arrays.asList(new VCFInfoHeaderLine(getKeyNames().get(0), 1, VCFInfoHeaderLine.INFO_TYPE.Integer, "Total Mapping Quality Zero Reads")); } } \ No newline at end of file diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/QualByDepth.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/QualByDepth.java index 1faed4335..7099a5529 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/QualByDepth.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/QualByDepth.java @@ -10,6 +10,8 @@ import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.StandardAnnota import java.util.Map; import java.util.HashMap; +import java.util.List; +import java.util.Arrays; public class QualByDepth implements InfoFieldAnnotation, StandardAnnotation { @@ -26,13 +28,13 @@ public class QualByDepth implements InfoFieldAnnotation, StandardAnnotation { double QbyD = 10.0 * vc.getNegLog10PError() / (double)qDepth; Map map = new HashMap(); - map.put(getKeyName(), String.format("%.2f", QbyD)); + map.put(getKeyNames().get(0), String.format("%.2f", QbyD)); return map; } - public String getKeyName() { return "QD"; } + public List getKeyNames() { return Arrays.asList("QD"); } - public VCFInfoHeaderLine getDescription() { return new VCFInfoHeaderLine(getKeyName(), 1, VCFInfoHeaderLine.INFO_TYPE.Float, "Variant Confidence/Quality by Depth"); } + public List getDescriptions() { return Arrays.asList(new VCFInfoHeaderLine(getKeyNames().get(0), 1, VCFInfoHeaderLine.INFO_TYPE.Float, "Variant Confidence/Quality by Depth")); } private int variationQualByDepth(final Map genotypes, Map stratifiedContexts) { int depth = 0; diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/QualityAdjustedSecondBaseLod.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/QualityAdjustedSecondBaseLod.java index 31c738541..b60eb13c7 100644 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/QualityAdjustedSecondBaseLod.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/QualityAdjustedSecondBaseLod.java @@ -9,6 +9,8 @@ import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.*; import java.util.Map; import java.util.HashMap; +import java.util.List; +import java.util.Arrays; public class QualityAdjustedSecondBaseLod implements InfoFieldAnnotation, ExperimentalAnnotation { private final String KEY_NAME = "Qual_Adjusted_2blod"; @@ -17,9 +19,9 @@ public class QualityAdjustedSecondBaseLod implements InfoFieldAnnotation, Experi private final double log10e = Math.log10(Math.E); private final double log10half = Math.log10(1.0/2); - public String getKeyName() { return KEY_NAME; } + public List getKeyNames() { return Arrays.asList(KEY_NAME); } - public VCFInfoHeaderLine getDescription() { return new VCFInfoHeaderLine(KEY_NAME, 1, VCFInfoHeaderLine.INFO_TYPE.Float, "Adjusted residual quality based on second-base skew"); } + public List getDescriptions() { return Arrays.asList(new VCFInfoHeaderLine(KEY_NAME, 1, VCFInfoHeaderLine.INFO_TYPE.Float, "Adjusted residual quality based on second-base skew")); } public Map annotate( RefMetaDataTracker tracker, ReferenceContext ref, Map contexts, VariantContext vc) { String chi = skewCalc.getAnnotation(ref, contexts, vc); @@ -28,7 +30,7 @@ public class QualityAdjustedSecondBaseLod implements InfoFieldAnnotation, Experi double chi_square = Double.valueOf(chi); double chi_loglik = chi_square <= 0.0 ? 0.0 : Math.max(-(chi_square/2.0)*log10e + log10half,CHI_LOD_MAX); // cap it... Map map = new HashMap(); - map.put(getKeyName(), String.format("%f", 10*(vc.getNegLog10PError() + chi_loglik))); + map.put(getKeyNames().get(0), String.format("%f", 10*(vc.getNegLog10PError() + chi_loglik))); return map; } } diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RMSMappingQuality.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RMSMappingQuality.java index 200d035be..ca744bbbb 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RMSMappingQuality.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RMSMappingQuality.java @@ -12,9 +12,7 @@ import org.broadinstitute.sting.utils.MathUtils; import org.broadinstitute.sting.utils.pileup.ReadBackedPileup; import org.broadinstitute.sting.utils.pileup.PileupElement; -import java.util.Map; -import java.util.ArrayList; -import java.util.HashMap; +import java.util.*; public class RMSMappingQuality implements InfoFieldAnnotation, StandardAnnotation { @@ -32,11 +30,11 @@ public class RMSMappingQuality implements InfoFieldAnnotation, StandardAnnotatio quals[index++] = i; double rms = MathUtils.rms(quals); Map map = new HashMap(); - map.put(getKeyName(), String.format("%.2f", rms)); + map.put(getKeyNames().get(0), String.format("%.2f", rms)); return map; } - public String getKeyName() { return VCFRecord.RMS_MAPPING_QUALITY_KEY; } + public List getKeyNames() { return Arrays.asList(VCFRecord.RMS_MAPPING_QUALITY_KEY); } - public VCFInfoHeaderLine getDescription() { return new VCFInfoHeaderLine(getKeyName(), 1, VCFInfoHeaderLine.INFO_TYPE.Float, "RMS Mapping Quality"); } + public List getDescriptions() { return Arrays.asList(new VCFInfoHeaderLine(getKeyNames().get(0), 1, VCFInfoHeaderLine.INFO_TYPE.Float, "RMS Mapping Quality")); } } \ No newline at end of file diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RankSumTest.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RankSumTest.java index de2630111..3156e75e4 100644 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RankSumTest.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RankSumTest.java @@ -37,7 +37,7 @@ public abstract class RankSumTest implements InfoFieldAnnotation, WorkInProgress if ( context == null ) continue; - fillQualsFromPileup(ref.getBaseAsChar(), vc.getAlternateAllele(0).toString().charAt(0), context.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getBasePileup(), refQuals, altQuals); + fillQualsFromPileup(ref.getBase(), vc.getAlternateAllele(0).toString().charAt(0), context.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getBasePileup(), refQuals, altQuals); } } @@ -65,9 +65,9 @@ public abstract class RankSumTest implements InfoFieldAnnotation, WorkInProgress pvalue = minPValue; Map map = new HashMap(); - map.put(getKeyName(), String.format("%.1f", QualityUtils.phredScaleErrorRate(pvalue))); + map.put(getKeyNames().get(0), String.format("%.1f", QualityUtils.phredScaleErrorRate(pvalue))); return map; } - protected abstract void fillQualsFromPileup(char ref, char alt, ReadBackedPileup pileup, List refQuals, List altQuals); + protected abstract void fillQualsFromPileup(byte ref, char alt, ReadBackedPileup pileup, List refQuals, List altQuals); } \ No newline at end of file diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SecondBaseSkew.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SecondBaseSkew.java index 67766b022..21f5045d4 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SecondBaseSkew.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SecondBaseSkew.java @@ -38,6 +38,8 @@ import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.*; import java.util.Map; import java.util.HashMap; +import java.util.List; +import java.util.Arrays; public class SecondBaseSkew implements InfoFieldAnnotation, ExperimentalAnnotation { @@ -46,16 +48,16 @@ public class SecondBaseSkew implements InfoFieldAnnotation, ExperimentalAnnotati private final static double[] UNIFORM_ON_OFF_RATIO = {1.0/3.0, 2.0/3.0}; private double[] proportionExpectations = UNIFORM_ON_OFF_RATIO; - public String getKeyName() { return KEY_NAME; } + public List getKeyNames() { return Arrays.asList(KEY_NAME); } - public VCFInfoHeaderLine getDescription() { return new VCFInfoHeaderLine(KEY_NAME, 1, VCFInfoHeaderLine.INFO_TYPE.Float, "Chi-square Secondary Base Skew"); } + public List getDescriptions() { return Arrays.asList(new VCFInfoHeaderLine(KEY_NAME, 1, VCFInfoHeaderLine.INFO_TYPE.Float, "Chi-square Secondary Base Skew")); } public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { String annotation = getAnnotation(ref, stratifiedContexts, vc); if ( annotation == null ) return null; Map map = new HashMap(); - map.put(getKeyName(), annotation); + map.put(getKeyNames().get(0), annotation); return map; } diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SpanningDeletions.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SpanningDeletions.java index f4371184e..2ff018b8d 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SpanningDeletions.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SpanningDeletions.java @@ -11,6 +11,8 @@ import org.broadinstitute.sting.utils.pileup.ReadBackedPileup; import java.util.Map; import java.util.HashMap; +import java.util.List; +import java.util.Arrays; public class SpanningDeletions implements InfoFieldAnnotation, StandardAnnotation { @@ -24,11 +26,11 @@ public class SpanningDeletions implements InfoFieldAnnotation, StandardAnnotatio depth += pileup.size(); } Map map = new HashMap(); - map.put(getKeyName(), String.format("%.2f", depth == 0 ? 0.0 : (double)deletions/(double)depth)); + map.put(getKeyNames().get(0), String.format("%.2f", depth == 0 ? 0.0 : (double)deletions/(double)depth)); return map; } - public String getKeyName() { return "Dels"; } + public List getKeyNames() { return Arrays.asList("Dels"); } - public VCFInfoHeaderLine getDescription() { return new VCFInfoHeaderLine("Dels", 1, VCFInfoHeaderLine.INFO_TYPE.Float, "Fraction of Reads Containing Spanning Deletions"); } + public List getDescriptions() { return Arrays.asList(new VCFInfoHeaderLine("Dels", 1, VCFInfoHeaderLine.INFO_TYPE.Float, "Fraction of Reads Containing Spanning Deletions")); } } \ No newline at end of file diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java index b97519a64..27ef48744 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java @@ -56,7 +56,7 @@ import java.util.*; @Allows(value={DataSource.READS, DataSource.REFERENCE}) @Reference(window=@Window(start=-50,stop=50)) @By(DataSource.REFERENCE) -public class VariantAnnotator extends LocusWalker { +public class VariantAnnotator extends RodWalker { @Argument(fullName="sampleName", shortName="sample", doc="The sample (NA-ID) corresponding to the variant input (for non-VCF input only)", required=false) protected String sampleName = null; diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorEngine.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorEngine.java index b398173fe..561a56c85 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorEngine.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorEngine.java @@ -182,9 +182,9 @@ public class VariantAnnotatorEngine { Set descriptions = new HashSet(); for ( InfoFieldAnnotation annotation : requestedInfoAnnotations ) - descriptions.add(annotation.getDescription()); + descriptions.addAll(annotation.getDescriptions()); for ( GenotypeAnnotation annotation : requestedGenotypeAnnotations ) - descriptions.add(annotation.getDescription()); + descriptions.addAll(annotation.getDescriptions()); if ( annotateDbsnp ) descriptions.add(new VCFInfoHeaderLine(VCFRecord.DBSNP_KEY, 1, VCFInfoHeaderLine.INFO_TYPE.Integer, "dbSNP Membership")); if ( annotateHapmap2 ) diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/GenotypeAnnotation.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/GenotypeAnnotation.java index 9eafd8eaf..7c6618014 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/GenotypeAnnotation.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/GenotypeAnnotation.java @@ -8,16 +8,17 @@ import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContext; import org.broadinstitute.sting.gatk.contexts.variantcontext.Genotype; import java.util.Map; +import java.util.List; public interface GenotypeAnnotation { // return annotations for the given contexts/genotype split by sample public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, StratifiedAlignmentContext stratifiedContext, VariantContext vc, Genotype g); - // return the FORMAT key - public String getKeyName(); + // return the FORMAT keys + public List getKeyNames(); - // return the description used for the VCF FORMAT meta field - public VCFFormatHeaderLine getDescription(); + // return the descriptions used for the VCF FORMAT meta field + public List getDescriptions(); } \ No newline at end of file diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/InfoFieldAnnotation.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/InfoFieldAnnotation.java index 23e079358..3bd74b8c5 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/InfoFieldAnnotation.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/InfoFieldAnnotation.java @@ -7,16 +7,17 @@ import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContext; import java.util.Map; +import java.util.List; public interface InfoFieldAnnotation { // return annotations for the given contexts split by sample public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc); - // return the INFO key - public String getKeyName(); + // return the INFO keys + public List getKeyNames(); - // return the description used for the VCF INFO meta field - public VCFInfoHeaderLine getDescription(); + // return the descriptions used for the VCF INFO meta field + public List getDescriptions(); } \ No newline at end of file diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/JointEstimateGenotypeCalculationModel.java b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/JointEstimateGenotypeCalculationModel.java index 647ff1834..ae00b749b 100644 --- a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/JointEstimateGenotypeCalculationModel.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/JointEstimateGenotypeCalculationModel.java @@ -1,7 +1,6 @@ package org.broadinstitute.sting.gatk.walkers.genotyper; import org.broad.tribble.dbsnp.DbSNPFeature; -import org.broad.tribble.vcf.VCFRecord; import org.broadinstitute.sting.utils.*; import org.broadinstitute.sting.utils.pileup.*; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -385,8 +384,6 @@ public abstract class JointEstimateGenotypeCalculationModel extends GenotypeCalc // *** note that calculating strand bias involves overwriting data structures, so we do that last HashMap attributes = new HashMap(); - if ( bestAFguess != 0 ) - attributes.put(VCFRecord.ALLELE_FREQUENCY_KEY, new Double((double)bestAFguess / (double)(frequencyEstimationPoints-1))); DbSNPFeature dbsnp = getDbSNP(tracker); if ( dbsnp != null ) diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyper.java b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyper.java index 76813661c..a74a4f36c 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyper.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyper.java @@ -146,7 +146,6 @@ public class UnifiedGenotyper extends LocusWalker args = new HashSet(); diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/AnnotationByAlleleFrequencyWalker.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/AnnotationByAlleleFrequencyWalker.java index 9c49f44f3..f9779b736 100755 --- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/AnnotationByAlleleFrequencyWalker.java +++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/AnnotationByAlleleFrequencyWalker.java @@ -34,7 +34,6 @@ import org.broadinstitute.sting.gatk.walkers.RodWalker; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.AnnotationType; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.GenotypeAnnotation; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation; -import org.broadinstitute.sting.playground.gatk.walkers.annotator.GenomicAnnotation; import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.classloader.PackageUtils; @@ -183,7 +182,7 @@ public class AnnotationByAlleleFrequencyWalker extends RodWalker getKeyNames() { return Arrays.asList("INSIZE"); } + public List getDescriptions() { return Arrays.asList(new VCFInfoHeaderLine(getKeyNames().get(0),1,VCFInfoHeaderLine.INFO_TYPE.Integer,"Do not use this if your name is not Chris")); } public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map context, VariantContext variant) { int weirdInsertSizeReads = 0; @@ -34,7 +36,7 @@ public class InsertSizeDistribution implements InfoFieldAnnotation { } Map toReturn = new HashMap(); - toReturn.put(getKeyName(),String.format("%d",weirdInsertSizeReads)); + toReturn.put(getKeyNames().get(0),String.format("%d",weirdInsertSizeReads)); return toReturn; } } diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/ProportionOfNonrefBasesSupportingSNP.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/ProportionOfNonrefBasesSupportingSNP.java index a6a05c52b..5a146e771 100644 --- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/ProportionOfNonrefBasesSupportingSNP.java +++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/ProportionOfNonrefBasesSupportingSNP.java @@ -37,6 +37,8 @@ import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContext; import java.util.Map; import java.util.HashMap; +import java.util.List; +import java.util.Arrays; /** * Created by IntelliJ IDEA. @@ -48,11 +50,10 @@ import java.util.HashMap; public class ProportionOfNonrefBasesSupportingSNP implements InfoFieldAnnotation { private String KEY_NAME = "prop_nonref_that_are_snp"; - public String getKeyName() { return KEY_NAME; } + public List getKeyNames() { return Arrays.asList(KEY_NAME); } - public VCFInfoHeaderLine getDescription() { - return new VCFInfoHeaderLine(KEY_NAME, - 1,VCFInfoHeaderLine.INFO_TYPE.Float,"Simple proportion of non-reference bases that are the SNP base"); + public List getDescriptions() { + return Arrays.asList(new VCFInfoHeaderLine(KEY_NAME,1,VCFInfoHeaderLine.INFO_TYPE.Float,"Simple proportion of non-reference bases that are the SNP base")); } public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map context, VariantContext vc) { @@ -69,7 +70,7 @@ public class ProportionOfNonrefBasesSupportingSNP implements InfoFieldAnnotation return null; double p = getProportionOfNonrefBasesThatAreSNP(totalNonref_totalSNP); Map map = new HashMap(); - map.put(getKeyName(), String.format("%f", p )); + map.put(getKeyNames().get(0), String.format("%f", p )); return map; } diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/ProportionOfRefSecondBasesSupportingSNP.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/ProportionOfRefSecondBasesSupportingSNP.java index 23b645634..2f22c6432 100644 --- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/ProportionOfRefSecondBasesSupportingSNP.java +++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/ProportionOfRefSecondBasesSupportingSNP.java @@ -38,6 +38,8 @@ import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContext; import java.util.Map; import java.util.HashMap; +import java.util.List; +import java.util.Arrays; /** * Created by IntelliJ IDEA. @@ -50,7 +52,7 @@ public class ProportionOfRefSecondBasesSupportingSNP implements InfoFieldAnnotat private String KEY_NAME = "ref_2bb_snp_prop"; private boolean USE_MAPQ0_READS = false; - public String getKeyName() { return KEY_NAME; } + public List getKeyNames() { return Arrays.asList(KEY_NAME); } public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map context, VariantContext vc) { if ( ! vc.isSNP() || ! vc.isBiallelic() ) @@ -67,7 +69,7 @@ public class ProportionOfRefSecondBasesSupportingSNP implements InfoFieldAnnotat double p = getProportionOfRefSecondaryBasesSupportingSNP(totalAndSNPSupporting); Map map = new HashMap(); - map.put(getKeyName(), String.format("%f", p )); + map.put(getKeyNames().get(0), String.format("%f", p )); return map; } @@ -94,8 +96,8 @@ public class ProportionOfRefSecondBasesSupportingSNP implements InfoFieldAnnotat return refAndSNPCounts; } - public VCFInfoHeaderLine getDescription() { - return new VCFInfoHeaderLine(KEY_NAME, - 1,VCFInfoHeaderLine.INFO_TYPE.Float,"Simple proportion of second best base calls for reference base that support the SNP base"); + public List getDescriptions() { + return Arrays.asList(new VCFInfoHeaderLine(KEY_NAME, + 1,VCFInfoHeaderLine.INFO_TYPE.Float,"Simple proportion of second best base calls for reference base that support the SNP base")); } } diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/ProportionOfSNPSecondBasesSupportingRef.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/ProportionOfSNPSecondBasesSupportingRef.java index 43daf4d9c..ba2fb12cd 100644 --- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/ProportionOfSNPSecondBasesSupportingRef.java +++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/ProportionOfSNPSecondBasesSupportingRef.java @@ -38,6 +38,8 @@ import org.broadinstitute.sting.utils.pileup.PileupElement; import java.util.Map; import java.util.HashMap; +import java.util.List; +import java.util.Arrays; /** * Created by IntelliJ IDEA. @@ -51,7 +53,7 @@ public class ProportionOfSNPSecondBasesSupportingRef implements InfoFieldAnnotat public boolean USE_MAPQ0_READS = false; public String debug_file = "/humgen/gsa-scr1/chartl/temporary/ProportionOfRefSecondBasesSupportingSNP.debug.txt"; - public String getKeyName() { return KEY_NAME; } + public List getKeyNames() { return Arrays.asList(KEY_NAME); } public boolean useZeroQualityReads() { return USE_MAPQ0_READS; } @@ -70,7 +72,7 @@ public class ProportionOfSNPSecondBasesSupportingRef implements InfoFieldAnnotat double p = getProportionOfSNPSecondaryBasesSupportingRef(totalAndSNPSupporting); Map map = new HashMap(); - map.put(getKeyName(), String.format("%f", p )); + map.put(getKeyNames().get(0), String.format("%f", p )); return map; } @@ -102,9 +104,9 @@ public class ProportionOfSNPSecondBasesSupportingRef implements InfoFieldAnnotat return BaseUtils.isRegularBase(e.getSecondBase()); } - public VCFInfoHeaderLine getDescription() { - return new VCFInfoHeaderLine(KEY_NAME, - 1,VCFInfoHeaderLine.INFO_TYPE.Float,"Simple proportion of second best base calls for SNP base that support the Ref base"); + public List getDescriptions() { + return Arrays.asList(new VCFInfoHeaderLine(KEY_NAME, + 1,VCFInfoHeaderLine.INFO_TYPE.Float,"Simple proportion of second best base calls for SNP base that support the Ref base")); } diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/ThousandGenomesAnnotator.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/ThousandGenomesAnnotator.java index d42ff1364..fd85bdda6 100644 --- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/ThousandGenomesAnnotator.java +++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/ThousandGenomesAnnotator.java @@ -10,6 +10,8 @@ import org.broadinstitute.sting.oneoffprojects.refdata.HapmapVCFROD; import java.util.HashMap; import java.util.Map; +import java.util.List; +import java.util.Arrays; /** * IF THERE IS NO JAVADOC RIGHT HERE, YELL AT chartl @@ -19,13 +21,13 @@ import java.util.Map; */ public class ThousandGenomesAnnotator implements InfoFieldAnnotation { - public String getKeyName() { - return "1KG"; + public List getKeyNames() { + return Arrays.asList("1KG"); } - public VCFInfoHeaderLine getDescription() { - return new VCFInfoHeaderLine(getKeyName(), - 1,VCFInfoHeaderLine.INFO_TYPE.String,"Is this site seen in Pilot1 or Pilot2 of 1KG?"); + public List getDescriptions() { + return Arrays.asList(new VCFInfoHeaderLine(getKeyNames().get(0), + 1,VCFInfoHeaderLine.INFO_TYPE.String,"Is this site seen in Pilot1 or Pilot2 of 1KG?")); } public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map context, VariantContext vc) { @@ -49,7 +51,7 @@ public class ThousandGenomesAnnotator implements InfoFieldAnnotation { } } Map map = new HashMap(); - map.put(getKeyName(), result); + map.put(getKeyNames().get(0), result); return map; } } diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/annotator/GenomicAnnotation.java b/java/src/org/broadinstitute/sting/playground/gatk/walkers/annotator/GenomicAnnotation.java index 2c1b5bad6..d51d37de8 100644 --- a/java/src/org/broadinstitute/sting/playground/gatk/walkers/annotator/GenomicAnnotation.java +++ b/java/src/org/broadinstitute/sting/playground/gatk/walkers/annotator/GenomicAnnotation.java @@ -25,11 +25,7 @@ package org.broadinstitute.sting.playground.gatk.walkers.annotator; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.Map.Entry; import org.broad.tribble.vcf.VCFInfoHeaderLine; @@ -258,12 +254,12 @@ public class GenomicAnnotation implements InfoFieldAnnotation { - public VCFInfoHeaderLine getDescription() { - return new VCFInfoHeaderLine("GenericAnnotation", 1, VCFInfoHeaderLine.INFO_TYPE.Integer, "For each variant in the 'variants' ROD, finds all entries in the other -B files that overlap the variant's position. "); + public List getDescriptions() { + return Arrays.asList(new VCFInfoHeaderLine("GenericAnnotation", 1, VCFInfoHeaderLine.INFO_TYPE.Integer, "For each variant in the 'variants' ROD, finds all entries in the other -B files that overlap the variant's position. ")); } - public String getKeyName() { - return "GenericAnnotation"; + public List getKeyNames() { + return Arrays.asList("GenericAnnotation"); } } diff --git a/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFGenotypeWriterAdapter.java b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFGenotypeWriterAdapter.java index cbd9cdae2..4bae2afc5 100644 --- a/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFGenotypeWriterAdapter.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFGenotypeWriterAdapter.java @@ -5,7 +5,6 @@ import org.broad.tribble.vcf.VCFHeader; import org.broad.tribble.vcf.VCFHeaderLine; import org.broad.tribble.vcf.VCFRecord; import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContext; -import org.broadinstitute.sting.gatk.contexts.variantcontext.Allele; import org.broadinstitute.sting.gatk.refdata.VariantContextAdaptors; import org.apache.log4j.Logger; @@ -95,19 +94,6 @@ public class VCFGenotypeWriterAdapter implements VCFGenotypeWriter { VCFRecord call = VariantContextAdaptors.toVCF(vc, (byte)refAllele.charAt(0), allowedGenotypeFormatStrings, false, false); - Set altAlleles = vc.getAlternateAlleles(); - StringBuffer altAlleleCountString = new StringBuffer(); - for ( Allele allele : altAlleles ) { - if ( altAlleleCountString.length() > 0 ) - altAlleleCountString.append(","); - altAlleleCountString.append(vc.getChromosomeCount(allele)); - } - if ( vc.getChromosomeCount() > 0 ) { - call.addInfoField(VCFRecord.ALLELE_NUMBER_KEY, String.format("%d", vc.getChromosomeCount())); - if ( altAlleleCountString.length() > 0 ) - call.addInfoField(VCFRecord.ALLELE_COUNT_KEY, altAlleleCountString.toString()); - } - mWriter.addRecord(call, validationStringency); } diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorIntegrationTest.java index ac4294efe..1d59e67d9 100755 --- a/java/test/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorIntegrationTest.java @@ -66,7 +66,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest { public void testHasAnnotsAsking1() { WalkerTestSpec spec = new WalkerTestSpec( baseTestString() + " -G \"Standard\" -B variant,VCF," + validationDataLocation + "vcfexample2.vcf -I " + validationDataLocation + "low_coverage_CEU.chr1.10k-11k.bam -L 1:10,020,000-10,021,000", 1, - Arrays.asList("a3d781ed67bd80b02eeeba4407af93d1")); + Arrays.asList("dff7c888fbd142b6eff27c3233c1292d")); executeTest("test file has annotations, asking for annotations, #1", spec); } @@ -74,7 +74,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest { public void testHasAnnotsAsking2() { WalkerTestSpec spec = new WalkerTestSpec( baseTestString() + " -G \"Standard\" -B variant,VCF," + validationDataLocation + "vcfexample3.vcf -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -L 1:10,000,000-10,050,000", 1, - Arrays.asList("8d57463554486cf077faf190b5af5f2d")); + Arrays.asList("45c9d5136900d9ab347f489d6f442bb4")); executeTest("test file has annotations, asking for annotations, #2", spec); } @@ -98,7 +98,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest { public void testNoAnnotsAsking1() { WalkerTestSpec spec = new WalkerTestSpec( baseTestString() + " -G \"Standard\" -B variant,VCF," + validationDataLocation + "vcfexample2empty.vcf -I " + validationDataLocation + "low_coverage_CEU.chr1.10k-11k.bam -L 1:10,020,000-10,021,000", 1, - Arrays.asList("bfbdd00135812778138443ff1c45ac1f")); + Arrays.asList("7c13af3226a92bfc3826c37b30f179e0")); executeTest("test file doesn't have annotations, asking for annotations, #1", spec); } @@ -106,7 +106,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest { public void testNoAnnotsAsking2() { WalkerTestSpec spec = new WalkerTestSpec( baseTestString() + " -G \"Standard\" -B variant,VCF," + validationDataLocation + "vcfexample3empty.vcf -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -L 1:10,000,000-10,050,000", 1, - Arrays.asList("9d8b72384e90c5f8f278da9558ac2419")); + Arrays.asList("369ad538eacdc0943b58a807d92d823c")); executeTest("test file doesn't have annotations, asking for annotations, #2", spec); } diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperIntegrationTest.java index 8fd67f142..03e8d6c76 100755 --- a/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperIntegrationTest.java @@ -35,7 +35,7 @@ public class UnifiedGenotyperIntegrationTest extends WalkerTest { public void testMultiSamplePilot1Joint() { WalkerTest.WalkerTestSpec spec = new WalkerTest.WalkerTestSpec( "-T UnifiedGenotyper -R " + oneKGLocation + "reference/human_b36_both.fasta -I " + validationDataLocation + "low_coverage_CEU.chr1.10k-11k.bam -varout %s -L 1:10,022,000-10,025,000", 1, - Arrays.asList("4e403194fd00552804a0907bf905cffb")); + Arrays.asList("27917d676d6cc89e5b690dc1e982f670")); executeTest("testMultiSamplePilot1 - Joint Estimate", spec); } @@ -43,7 +43,7 @@ public class UnifiedGenotyperIntegrationTest extends WalkerTest { public void testMultiSamplePilot2Joint() { WalkerTest.WalkerTestSpec spec = new WalkerTest.WalkerTestSpec( "-T UnifiedGenotyper -R " + oneKGLocation + "reference/human_b36_both.fasta -I " + validationDataLocation + "pilot2_daughters.chr20.10k-11k.bam -varout %s -L 20:10,000,000-10,050,000", 1, - Arrays.asList("987aaf0268a364d35e4375bab2d69c9e")); + Arrays.asList("1319891457e0d7859a0859de7b9eb59f")); executeTest("testMultiSamplePilot2 - Joint Estimate", spec); } @@ -51,7 +51,7 @@ public class UnifiedGenotyperIntegrationTest extends WalkerTest { public void testSingleSamplePilot2Joint() { WalkerTest.WalkerTestSpec spec = new WalkerTest.WalkerTestSpec( "-T UnifiedGenotyper -R " + oneKGLocation + "reference/human_b36_both.fasta -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -varout %s -L 1:10,000,000-10,100,000", 1, - Arrays.asList("5ad0d5e8180f5290f511723392a54d03")); + Arrays.asList("4157f43949aa2ee514131d7719d51d39")); executeTest("testSingleSamplePilot2 - Joint Estimate", spec); } @@ -63,7 +63,7 @@ public class UnifiedGenotyperIntegrationTest extends WalkerTest { @Test public void testParallelization() { - String md5 = "c7bfe0500e933d1546cb40448d7b4c61"; + String md5 = "bc96dbb14581f46f6fc751d982cce566"; WalkerTest.WalkerTestSpec spec1 = new WalkerTest.WalkerTestSpec( "-T UnifiedGenotyper -R " + oneKGLocation + "reference/human_b36_both.fasta -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -varout %s -L 1:10,000,000-10,075,000", 1, @@ -85,11 +85,11 @@ public class UnifiedGenotyperIntegrationTest extends WalkerTest { @Test public void testParameter() { HashMap e = new HashMap(); - e.put( "-genotype", "96106a735876dc4ca9aa839610bee56f" ); - e.put( "-all_bases", "85b7bd300cc6852e25be430dd02e789f" ); - e.put( "--min_base_quality_score 26", "ecc1b0dd618eae9b9f62db2742ac3306" ); - e.put( "--min_mapping_quality_score 26", "75bd53d5070f1146350d633321a165e3" ); - e.put( "--max_mismatches_in_40bp_window 5", "8e1236b7f0f6c19a0be808b2d44e3255" ); + e.put( "-genotype", "0f6b11868a057db246145c98119cb8f7" ); + e.put( "-all_bases", "e45b5efc4aa285a7cebfb771da49ebe2" ); + e.put( "--min_base_quality_score 26", "a132bdcd9300b6483f78bd34d99bd794" ); + e.put( "--min_mapping_quality_score 26", "edce61eba0e6e65156452fe3476d6cfc" ); + e.put( "--max_mismatches_in_40bp_window 5", "56d3c59532b6e81e835f55bc1135f990" ); for ( Map.Entry entry : e.entrySet() ) { WalkerTest.WalkerTestSpec spec = new WalkerTest.WalkerTestSpec( @@ -103,12 +103,12 @@ public class UnifiedGenotyperIntegrationTest extends WalkerTest { public void testConfidence() { WalkerTest.WalkerTestSpec spec1 = new WalkerTest.WalkerTestSpec( "-T UnifiedGenotyper -R " + oneKGLocation + "reference/human_b36_both.fasta -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -varout %s -L 1:10,000,000-10,010,000 -stand_call_conf 10 ", 1, - Arrays.asList("ff8a1008ddfd342a20b3e032bade61bc")); + Arrays.asList("522f67194bf1849115775b3c24f8fcf1")); executeTest("testConfidence1", spec1); WalkerTest.WalkerTestSpec spec2 = new WalkerTest.WalkerTestSpec( "-T UnifiedGenotyper -R " + oneKGLocation + "reference/human_b36_both.fasta -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -varout %s -L 1:10,000,000-10,010,000 -stand_emit_conf 10 ", 1, - Arrays.asList("d469b4367188dd2b9be37ab8effc65c4")); + Arrays.asList("226ca8079db4e46a61367db49bac8b2b")); executeTest("testConfidence2", spec2); }