From aa0610ea929f98a4ee4e8a56eec195be8e37abd2 Mon Sep 17 00:00:00 2001 From: Mark DePristo Date: Wed, 16 Nov 2011 16:24:05 -0500 Subject: [PATCH] GenotypeCollection renamed to GenotypesContext --- .../gatk/refdata/VariantContextAdaptors.java | 6 +-- .../gatk/walkers/annotator/AlleleBalance.java | 4 +- .../gatk/walkers/annotator/HardyWeinberg.java | 4 +- .../walkers/annotator/InbreedingCoeff.java | 4 +- .../gatk/walkers/annotator/QualByDepth.java | 4 +- .../gatk/walkers/annotator/RankSumTest.java | 4 +- .../annotator/VariantAnnotatorEngine.java | 6 +-- .../beagle/BeagleOutputToVCFWalker.java | 4 +- .../beagle/ProduceBeagleInputWalker.java | 4 +- .../filters/VariantFiltrationWalker.java | 6 +-- .../AlleleFrequencyCalculationModel.java | 8 ++-- .../genotyper/ExactAFCalculationModel.java | 14 +++--- .../walkers/genotyper/UGCallVariants.java | 8 ++-- .../genotyper/UnifiedGenotyperEngine.java | 6 +-- .../indels/SomaticIndelDetectorWalker.java | 6 +-- .../walkers/phasing/PhaseByTransmission.java | 6 +-- .../gatk/walkers/phasing/PhasingUtils.java | 2 +- .../phasing/ReadBackedPhasingWalker.java | 6 +-- .../evaluators/GenotypePhasingEvaluator.java | 6 +-- .../variantutils/LeftAlignVariants.java | 4 +- .../walkers/variantutils/SelectVariants.java | 2 +- .../walkers/variantutils/VariantsToVCF.java | 2 +- .../utils/codecs/vcf/AbstractVCFCodec.java | 4 +- .../sting/utils/codecs/vcf/VCF3Codec.java | 6 +-- .../sting/utils/codecs/vcf/VCFCodec.java | 6 +-- .../sting/utils/codecs/vcf/VCFParser.java | 4 +- .../broadinstitute/sting/utils/gcf/GCF.java | 8 ++-- ...eCollection.java => GenotypesContext.java} | 48 +++++++++---------- .../utils/variantcontext/VariantContext.java | 35 +++++++------- .../variantcontext/VariantContextUtils.java | 16 +++---- .../utils/genotype/vcf/VCFWriterUnitTest.java | 4 +- .../VariantContextBenchmark.java | 2 +- .../VariantContextUtilsUnitTest.java | 4 +- 33 files changed, 124 insertions(+), 129 deletions(-) rename public/java/src/org/broadinstitute/sting/utils/variantcontext/{GenotypeCollection.java => GenotypesContext.java} (86%) diff --git a/public/java/src/org/broadinstitute/sting/gatk/refdata/VariantContextAdaptors.java b/public/java/src/org/broadinstitute/sting/gatk/refdata/VariantContextAdaptors.java index c5b8b628a..081f86ab9 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/refdata/VariantContextAdaptors.java +++ b/public/java/src/org/broadinstitute/sting/gatk/refdata/VariantContextAdaptors.java @@ -10,8 +10,6 @@ import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.classloader.PluginManager; import org.broadinstitute.sting.utils.codecs.hapmap.RawHapMapFeature; import org.broadinstitute.sting.utils.codecs.vcf.VCFConstants; -import org.broadinstitute.sting.utils.codecs.vcf.VCFHeader; -import org.broadinstitute.sting.utils.codecs.vcf.VCFHeaderLine; import org.broadinstitute.sting.utils.variantcontext.*; import java.util.*; @@ -195,7 +193,7 @@ public class VariantContextAdaptors { return null; // we weren't given enough reference context to create the VariantContext Byte refBaseForIndel = new Byte(ref.getBases()[index]); - GenotypeCollection genotypes = null; + GenotypesContext genotypes = null; VariantContext vc = new VariantContext(name, dbsnp.getRsID(), dbsnp.getChr(), dbsnp.getStart() - (sawNullAllele ? 1 : 0), dbsnp.getEnd() - (refAllele.isNull() ? 1 : 0), alleles, genotypes, VariantContext.NO_NEG_LOG_10PERROR, null, attributes, refBaseForIndel); return vc; } else @@ -316,7 +314,7 @@ public class VariantContextAdaptors { String[] samples = hapmap.getSampleIDs(); String[] genotypeStrings = hapmap.getGenotypes(); - GenotypeCollection genotypes = GenotypeCollection.create(samples.length); + GenotypesContext genotypes = GenotypesContext.create(samples.length); for ( int i = 0; i < samples.length; i++ ) { // ignore bad genotypes if ( genotypeStrings[i].contains("N") ) diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalance.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalance.java index c345c8741..4a13fccc6 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalance.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalance.java @@ -35,7 +35,7 @@ import org.broadinstitute.sting.utils.codecs.vcf.VCFHeaderLineType; import org.broadinstitute.sting.utils.codecs.vcf.VCFInfoHeaderLine; import org.broadinstitute.sting.utils.pileup.ReadBackedExtendedEventPileup; import org.broadinstitute.sting.utils.variantcontext.Genotype; -import org.broadinstitute.sting.utils.variantcontext.GenotypeCollection; +import org.broadinstitute.sting.utils.variantcontext.GenotypesContext; import org.broadinstitute.sting.utils.variantcontext.VariantContext; import java.util.Arrays; @@ -55,7 +55,7 @@ public class AlleleBalance extends InfoFieldAnnotation { if ( !vc.isBiallelic() ) return null; - final GenotypeCollection genotypes = vc.getGenotypes(); + final GenotypesContext genotypes = vc.getGenotypes(); if ( !vc.hasGenotypes() ) return null; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HardyWeinberg.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HardyWeinberg.java index 164c77d1c..33f2f1dd3 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HardyWeinberg.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HardyWeinberg.java @@ -11,7 +11,7 @@ import org.broadinstitute.sting.utils.QualityUtils; import org.broadinstitute.sting.utils.codecs.vcf.VCFHeaderLineType; import org.broadinstitute.sting.utils.codecs.vcf.VCFInfoHeaderLine; import org.broadinstitute.sting.utils.variantcontext.Genotype; -import org.broadinstitute.sting.utils.variantcontext.GenotypeCollection; +import org.broadinstitute.sting.utils.variantcontext.GenotypesContext; import org.broadinstitute.sting.utils.variantcontext.VariantContext; import java.util.Arrays; @@ -31,7 +31,7 @@ public class HardyWeinberg extends InfoFieldAnnotation implements WorkInProgress public Map annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { - final GenotypeCollection genotypes = vc.getGenotypes(); + final GenotypesContext genotypes = vc.getGenotypes(); if ( genotypes == null || genotypes.size() < MIN_SAMPLES ) return null; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/InbreedingCoeff.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/InbreedingCoeff.java index 917a75294..640ab036b 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/InbreedingCoeff.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/InbreedingCoeff.java @@ -10,7 +10,7 @@ import org.broadinstitute.sting.utils.MathUtils; import org.broadinstitute.sting.utils.codecs.vcf.VCFHeaderLineType; import org.broadinstitute.sting.utils.codecs.vcf.VCFInfoHeaderLine; import org.broadinstitute.sting.utils.variantcontext.Genotype; -import org.broadinstitute.sting.utils.variantcontext.GenotypeCollection; +import org.broadinstitute.sting.utils.variantcontext.GenotypesContext; import org.broadinstitute.sting.utils.variantcontext.VariantContext; import java.util.Arrays; @@ -33,7 +33,7 @@ public class InbreedingCoeff extends InfoFieldAnnotation implements StandardAnno public Map annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { - final GenotypeCollection genotypes = vc.getGenotypes(); + final GenotypesContext genotypes = vc.getGenotypes(); if ( genotypes == null || genotypes.size() < MIN_SAMPLES ) return null; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/QualByDepth.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/QualByDepth.java index 3a1f2cc87..0653b6015 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/QualByDepth.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/QualByDepth.java @@ -9,7 +9,7 @@ import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.StandardAnnota import org.broadinstitute.sting.utils.codecs.vcf.VCFHeaderLineType; import org.broadinstitute.sting.utils.codecs.vcf.VCFInfoHeaderLine; import org.broadinstitute.sting.utils.variantcontext.Genotype; -import org.broadinstitute.sting.utils.variantcontext.GenotypeCollection; +import org.broadinstitute.sting.utils.variantcontext.GenotypesContext; import org.broadinstitute.sting.utils.variantcontext.VariantContext; import java.util.Arrays; @@ -29,7 +29,7 @@ public class QualByDepth extends InfoFieldAnnotation implements StandardAnnotati if ( stratifiedContexts.size() == 0 ) return null; - final GenotypeCollection genotypes = vc.getGenotypes(); + final GenotypesContext genotypes = vc.getGenotypes(); if ( genotypes == null || genotypes.size() == 0 ) return null; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RankSumTest.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RankSumTest.java index 97e014373..ebf33496f 100644 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RankSumTest.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RankSumTest.java @@ -13,7 +13,7 @@ import org.broadinstitute.sting.utils.collections.Pair; import org.broadinstitute.sting.utils.pileup.PileupElement; import org.broadinstitute.sting.utils.pileup.ReadBackedPileup; import org.broadinstitute.sting.utils.variantcontext.Genotype; -import org.broadinstitute.sting.utils.variantcontext.GenotypeCollection; +import org.broadinstitute.sting.utils.variantcontext.GenotypesContext; import org.broadinstitute.sting.utils.variantcontext.VariantContext; import java.util.ArrayList; @@ -33,7 +33,7 @@ public abstract class RankSumTest extends InfoFieldAnnotation implements Standar if ( stratifiedContexts.size() == 0 ) return null; - final GenotypeCollection genotypes = vc.getGenotypes(); + final GenotypesContext genotypes = vc.getGenotypes(); if ( genotypes == null || genotypes.size() == 0 ) return null; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorEngine.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorEngine.java index 48fcdec10..9f0353eb9 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorEngine.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorEngine.java @@ -34,7 +34,7 @@ import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.*; import org.broadinstitute.sting.utils.codecs.vcf.*; import org.broadinstitute.sting.utils.exceptions.UserException; import org.broadinstitute.sting.utils.variantcontext.Genotype; -import org.broadinstitute.sting.utils.variantcontext.GenotypeCollection; +import org.broadinstitute.sting.utils.variantcontext.GenotypesContext; import org.broadinstitute.sting.utils.variantcontext.VariantContext; import java.util.*; @@ -225,11 +225,11 @@ public class VariantAnnotatorEngine { } } - private GenotypeCollection annotateGenotypes(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + private GenotypesContext annotateGenotypes(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( requestedGenotypeAnnotations.size() == 0 ) return vc.getGenotypes(); - GenotypeCollection genotypes = GenotypeCollection.create(vc.getNSamples()); + GenotypesContext genotypes = GenotypesContext.create(vc.getNSamples()); for ( final Genotype genotype : vc.getGenotypes() ) { AlignmentContext context = stratifiedContexts.get(genotype.getSampleName()); if ( context == null ) { diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/beagle/BeagleOutputToVCFWalker.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/beagle/BeagleOutputToVCFWalker.java index 297203aec..649b7621b 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/beagle/BeagleOutputToVCFWalker.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/beagle/BeagleOutputToVCFWalker.java @@ -187,7 +187,7 @@ public class BeagleOutputToVCFWalker extends RodWalker { byte refByte = ref.getBase(); // make new Genotypes based on Beagle results - GenotypeCollection genotypes = GenotypeCollection.create(vc_input.getGenotypes().size()); + GenotypesContext genotypes = GenotypesContext.create(vc_input.getGenotypes().size()); // for each genotype, create a new object with Beagle information on it @@ -196,7 +196,7 @@ public class BeagleOutputToVCFWalker extends RodWalker { Double alleleFrequencyH = 0.0; int beagleVarCounts = 0; - GenotypeCollection hapmapGenotypes = null; + GenotypesContext hapmapGenotypes = null; if (vc_comp != null) { hapmapGenotypes = vc_comp.getGenotypes(); diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/beagle/ProduceBeagleInputWalker.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/beagle/ProduceBeagleInputWalker.java index f7a84ee08..1d6eb4b64 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/beagle/ProduceBeagleInputWalker.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/beagle/ProduceBeagleInputWalker.java @@ -242,8 +242,8 @@ public class ProduceBeagleInputWalker extends RodWalker { } if ( markers != null ) markers.append("\n"); - GenotypeCollection preferredGenotypes = preferredVC.getGenotypes(); - GenotypeCollection otherGenotypes = goodSite(otherVC) ? otherVC.getGenotypes() : null; + GenotypesContext preferredGenotypes = preferredVC.getGenotypes(); + GenotypesContext otherGenotypes = goodSite(otherVC) ? otherVC.getGenotypes() : null; for ( String sample : samples ) { boolean isMaleOnChrX = CHECK_IS_MALE_ON_CHR_X && getSample(sample).getGender() == Gender.MALE; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationWalker.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationWalker.java index 6f482b6f2..409e180ae 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationWalker.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationWalker.java @@ -37,7 +37,7 @@ import org.broadinstitute.sting.utils.SampleUtils; import org.broadinstitute.sting.utils.codecs.vcf.*; import org.broadinstitute.sting.utils.exceptions.UserException; import org.broadinstitute.sting.utils.variantcontext.Genotype; -import org.broadinstitute.sting.utils.variantcontext.GenotypeCollection; +import org.broadinstitute.sting.utils.variantcontext.GenotypesContext; import org.broadinstitute.sting.utils.variantcontext.VariantContext; import org.broadinstitute.sting.utils.variantcontext.VariantContextUtils; @@ -283,11 +283,11 @@ public class VariantFiltrationWalker extends RodWalker { VariantContext vc = context.getVariantContext(); // make new Genotypes based on filters - GenotypeCollection genotypes; + GenotypesContext genotypes; if ( genotypeFilterExps.size() == 0 ) { genotypes = null; } else { - genotypes = GenotypeCollection.create(vc.getGenotypes().size()); + genotypes = GenotypesContext.create(vc.getGenotypes().size()); // for each genotype, check filters then create a new object for ( final Genotype g : vc.getGenotypes() ) { diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/AlleleFrequencyCalculationModel.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/AlleleFrequencyCalculationModel.java index b81c1d4c3..a8ce98945 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/AlleleFrequencyCalculationModel.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/AlleleFrequencyCalculationModel.java @@ -27,13 +27,11 @@ package org.broadinstitute.sting.gatk.walkers.genotyper; import org.apache.log4j.Logger; import org.broadinstitute.sting.utils.variantcontext.Allele; -import org.broadinstitute.sting.utils.variantcontext.Genotype; -import org.broadinstitute.sting.utils.variantcontext.GenotypeCollection; +import org.broadinstitute.sting.utils.variantcontext.GenotypesContext; import org.broadinstitute.sting.utils.variantcontext.VariantContext; import java.io.PrintStream; import java.util.List; -import java.util.Map; /** @@ -69,7 +67,7 @@ public abstract class AlleleFrequencyCalculationModel implements Cloneable { * @param log10AlleleFrequencyPriors priors * @param log10AlleleFrequencyPosteriors array (pre-allocated) to store results */ - protected abstract void getLog10PNonRef(GenotypeCollection GLs, List Alleles, + protected abstract void getLog10PNonRef(GenotypesContext GLs, List Alleles, double[] log10AlleleFrequencyPriors, double[] log10AlleleFrequencyPosteriors); @@ -81,7 +79,7 @@ public abstract class AlleleFrequencyCalculationModel implements Cloneable { * * @return calls */ - protected abstract GenotypeCollection assignGenotypes(VariantContext vc, + protected abstract GenotypesContext assignGenotypes(VariantContext vc, double[] log10AlleleFrequencyPosteriors, int AFofMaxLikelihood); } \ No newline at end of file diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/ExactAFCalculationModel.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/ExactAFCalculationModel.java index f0c73cd5f..980088305 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/ExactAFCalculationModel.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/ExactAFCalculationModel.java @@ -31,7 +31,7 @@ import org.broadinstitute.sting.utils.Utils; import org.broadinstitute.sting.utils.exceptions.UserException; import org.broadinstitute.sting.utils.variantcontext.Allele; import org.broadinstitute.sting.utils.variantcontext.Genotype; -import org.broadinstitute.sting.utils.variantcontext.GenotypeCollection; +import org.broadinstitute.sting.utils.variantcontext.GenotypesContext; import org.broadinstitute.sting.utils.variantcontext.VariantContext; import java.io.PrintStream; @@ -50,7 +50,7 @@ public class ExactAFCalculationModel extends AlleleFrequencyCalculationModel { super(UAC, N, logger, verboseWriter); } - public void getLog10PNonRef(GenotypeCollection GLs, List alleles, + public void getLog10PNonRef(GenotypesContext GLs, List alleles, double[] log10AlleleFrequencyPriors, double[] log10AlleleFrequencyPosteriors) { final int numAlleles = alleles.size(); @@ -94,7 +94,7 @@ public class ExactAFCalculationModel extends AlleleFrequencyCalculationModel { } } - private static final ArrayList getGLs(GenotypeCollection GLs) { + private static final ArrayList getGLs(GenotypesContext GLs) { ArrayList genotypeLikelihoods = new ArrayList(); genotypeLikelihoods.add(new double[]{0.0,0.0,0.0}); // dummy @@ -154,7 +154,7 @@ public class ExactAFCalculationModel extends AlleleFrequencyCalculationModel { } } - public int linearExact(GenotypeCollection GLs, + public int linearExact(GenotypesContext GLs, double[] log10AlleleFrequencyPriors, double[] log10AlleleFrequencyPosteriors, int idxAA, int idxAB, int idxBB) { final ArrayList genotypeLikelihoods = getGLs(GLs); @@ -267,14 +267,14 @@ public class ExactAFCalculationModel extends AlleleFrequencyCalculationModel { * * @return calls */ - public GenotypeCollection assignGenotypes(VariantContext vc, + public GenotypesContext assignGenotypes(VariantContext vc, double[] log10AlleleFrequencyPosteriors, int AFofMaxLikelihood) { if ( !vc.isVariant() ) throw new UserException("The VCF record passed in does not contain an ALT allele at " + vc.getChr() + ":" + vc.getStart()); - GenotypeCollection GLs = vc.getGenotypes(); + GenotypesContext GLs = vc.getGenotypes(); double[][] pathMetricArray = new double[GLs.size()+1][AFofMaxLikelihood+1]; int[][] tracebackArray = new int[GLs.size()+1][AFofMaxLikelihood+1]; @@ -341,7 +341,7 @@ public class ExactAFCalculationModel extends AlleleFrequencyCalculationModel { } } - GenotypeCollection calls = GenotypeCollection.create(); + GenotypesContext calls = GenotypesContext.create(); int startIdx = AFofMaxLikelihood; for (int k = sampleIdx; k > 0; k--) { diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UGCallVariants.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UGCallVariants.java index 00317eec6..6dc31edb8 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UGCallVariants.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UGCallVariants.java @@ -36,7 +36,7 @@ import org.broadinstitute.sting.utils.SampleUtils; import org.broadinstitute.sting.utils.codecs.vcf.*; import org.broadinstitute.sting.utils.exceptions.UserException; import org.broadinstitute.sting.utils.variantcontext.Genotype; -import org.broadinstitute.sting.utils.variantcontext.GenotypeCollection; +import org.broadinstitute.sting.utils.variantcontext.GenotypesContext; import org.broadinstitute.sting.utils.variantcontext.VariantContext; import org.broadinstitute.sting.utils.variantcontext.VariantContextUtils; @@ -129,7 +129,7 @@ public class UGCallVariants extends RodWalker { return null; VariantContext variantVC = null; - GenotypeCollection genotypes = GenotypeCollection.create(); + GenotypesContext genotypes = GenotypesContext.create(); for ( VariantContext vc : VCs ) { if ( variantVC == null && vc.isVariant() ) variantVC = vc; @@ -143,8 +143,8 @@ public class UGCallVariants extends RodWalker { return new VariantContext("VCwithGLs", VCFConstants.EMPTY_ID_FIELD, variantVC.getChr(), variantVC.getStart(), variantVC.getEnd(), variantVC.getAlleles(), genotypes, VariantContext.NO_NEG_LOG_10PERROR, null, null); } - private static GenotypeCollection getGenotypesWithGLs(GenotypeCollection genotypes) { - GenotypeCollection genotypesWithGLs = GenotypeCollection.create(genotypes.size()); + private static GenotypesContext getGenotypesWithGLs(GenotypesContext genotypes) { + GenotypesContext genotypesWithGLs = GenotypesContext.create(genotypes.size()); for ( final Genotype g : genotypes ) { if ( g.hasLikelihoods() && g.getLikelihoods().getAsVector() != null ) genotypesWithGLs.add(g); diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperEngine.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperEngine.java index 4f87f5eb0..5692c2525 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperEngine.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperEngine.java @@ -265,7 +265,7 @@ public class UnifiedGenotyperEngine { alleles.add(refAllele); boolean addedAltAlleles = false; - GenotypeCollection genotypes = GenotypeCollection.create(); + GenotypesContext genotypes = GenotypesContext.create(); for ( MultiallelicGenotypeLikelihoods GL : GLs.values() ) { if ( !addedAltAlleles ) { addedAltAlleles = true; @@ -354,7 +354,7 @@ public class UnifiedGenotyperEngine { } // create the genotypes - GenotypeCollection genotypes = afcm.get().assignGenotypes(vc, log10AlleleFrequencyPosteriors.get(), bestAFguess); + GenotypesContext genotypes = afcm.get().assignGenotypes(vc, log10AlleleFrequencyPosteriors.get(), bestAFguess); // print out stats if we have a writer if ( verboseWriter != null ) @@ -491,7 +491,7 @@ public class UnifiedGenotyperEngine { } // create the genotypes - GenotypeCollection genotypes = afcm.get().assignGenotypes(vc, log10AlleleFrequencyPosteriors.get(), bestAFguess); + GenotypesContext genotypes = afcm.get().assignGenotypes(vc, log10AlleleFrequencyPosteriors.get(), bestAFguess); // *** note that calculating strand bias involves overwriting data structures, so we do that last HashMap attributes = new HashMap(); diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/indels/SomaticIndelDetectorWalker.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/indels/SomaticIndelDetectorWalker.java index df1d081c6..e3dc59b19 100644 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/indels/SomaticIndelDetectorWalker.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/indels/SomaticIndelDetectorWalker.java @@ -60,7 +60,7 @@ import org.broadinstitute.sting.utils.sam.AlignmentUtils; import org.broadinstitute.sting.utils.sam.GATKSAMRecord; import org.broadinstitute.sting.utils.variantcontext.Allele; import org.broadinstitute.sting.utils.variantcontext.Genotype; -import org.broadinstitute.sting.utils.variantcontext.GenotypeCollection; +import org.broadinstitute.sting.utils.variantcontext.GenotypesContext; import org.broadinstitute.sting.utils.variantcontext.VariantContext; import java.io.*; @@ -1058,7 +1058,7 @@ public class SomaticIndelDetectorWalker extends ReadWalker { stop += event_length; } - GenotypeCollection genotypes = GenotypeCollection.create(); + GenotypesContext genotypes = GenotypesContext.create(); for ( String sample : normalSamples ) { Map attrs = call.makeStatsAttributes(null); @@ -1147,7 +1147,7 @@ public class SomaticIndelDetectorWalker extends ReadWalker { homRefAlleles.add( alleles.get(0)); homRefAlleles.add( alleles.get(0)); - GenotypeCollection genotypes = GenotypeCollection.create(); + GenotypesContext genotypes = GenotypesContext.create(); for ( String sample : normalSamples ) { genotypes.add(new Genotype(sample, homRefN ? homRefAlleles : alleles,Genotype.NO_NEG_LOG_10PERROR,null,attrsNormal,false)); diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/phasing/PhaseByTransmission.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/phasing/PhaseByTransmission.java index 2a3e353ef..0b28459d4 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/phasing/PhaseByTransmission.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/phasing/PhaseByTransmission.java @@ -293,7 +293,7 @@ public class PhaseByTransmission extends RodWalker { if (tracker != null) { VariantContext vc = tracker.getFirstValue(variantCollection.variants, context.getLocation()); - GenotypeCollection genotypeCollection = GenotypeCollection.create(vc.getGenotypes().size()); + GenotypesContext genotypesContext = GenotypesContext.create(vc.getGenotypes().size()); for (Trio trio : trios) { Genotype mother = vc.getGenotype(trio.getMother()); @@ -306,10 +306,10 @@ public class PhaseByTransmission extends RodWalker { Genotype phasedFather = trioGenotypes.get(1); Genotype phasedChild = trioGenotypes.get(2); - genotypeCollection.add(phasedMother, phasedFather, phasedChild); + genotypesContext.add(phasedMother, phasedFather, phasedChild); } - VariantContext newvc = VariantContext.modifyGenotypes(vc, genotypeCollection); + VariantContext newvc = VariantContext.modifyGenotypes(vc, genotypesContext); vcfWriter.add(newvc); } diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/phasing/PhasingUtils.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/phasing/PhasingUtils.java index ce35baf15..fddef5129 100644 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/phasing/PhasingUtils.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/phasing/PhasingUtils.java @@ -88,7 +88,7 @@ class PhasingUtils { } MergedAllelesData mergeData = new MergedAllelesData(intermediateBases, vc1, vc2); // ensures that the reference allele is added - GenotypeCollection mergedGenotypes = GenotypeCollection.create(); + GenotypesContext mergedGenotypes = GenotypesContext.create(); for (final Genotype gt1 : vc1.getGenotypes()) { Genotype gt2 = vc2.getGenotype(gt1.getSampleName()); diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/phasing/ReadBackedPhasingWalker.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/phasing/ReadBackedPhasingWalker.java index f2d870068..155b37af2 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/phasing/ReadBackedPhasingWalker.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/phasing/ReadBackedPhasingWalker.java @@ -352,7 +352,7 @@ public class ReadBackedPhasingWalker extends RodWalker samplePhaseStats = new TreeMap(); for (final Genotype gt : sampGenotypes) { String samp = gt.getSampleName(); @@ -1122,7 +1122,7 @@ public class ReadBackedPhasingWalker extends RodWalker alleles; - private GenotypeCollection genotypes; + private GenotypesContext genotypes; private double negLog10PError; private Set filters; private Map attributes; @@ -1135,7 +1135,7 @@ public class ReadBackedPhasingWalker extends RodWalker(vc.getAttributes()); diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/varianteval/evaluators/GenotypePhasingEvaluator.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/varianteval/evaluators/GenotypePhasingEvaluator.java index 08d62154d..ea12ada48 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/varianteval/evaluators/GenotypePhasingEvaluator.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/varianteval/evaluators/GenotypePhasingEvaluator.java @@ -14,7 +14,7 @@ import org.broadinstitute.sting.gatk.walkers.varianteval.util.TableType; import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.MathUtils; import org.broadinstitute.sting.utils.variantcontext.Genotype; -import org.broadinstitute.sting.utils.variantcontext.GenotypeCollection; +import org.broadinstitute.sting.utils.variantcontext.GenotypesContext; import org.broadinstitute.sting.utils.variantcontext.VariantContext; import java.util.HashMap; @@ -92,13 +92,13 @@ public class GenotypePhasingEvaluator extends VariantEvaluator { Set allSamples = new HashSet(); - GenotypeCollection compSampGenotypes = null; + GenotypesContext compSampGenotypes = null; if (isRelevantToPhasing(comp)) { allSamples.addAll(comp.getSampleNames()); compSampGenotypes = comp.getGenotypes(); } - GenotypeCollection evalSampGenotypes = null; + GenotypesContext evalSampGenotypes = null; if (isRelevantToPhasing(eval)) { allSamples.addAll(eval.getSampleNames()); evalSampGenotypes = eval.getGenotypes(); diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/LeftAlignVariants.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/LeftAlignVariants.java index 71e475fe0..4b3271ba6 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/LeftAlignVariants.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/LeftAlignVariants.java @@ -40,7 +40,7 @@ import org.broadinstitute.sting.utils.codecs.vcf.*; import org.broadinstitute.sting.utils.sam.AlignmentUtils; import org.broadinstitute.sting.utils.variantcontext.Allele; import org.broadinstitute.sting.utils.variantcontext.Genotype; -import org.broadinstitute.sting.utils.variantcontext.GenotypeCollection; +import org.broadinstitute.sting.utils.variantcontext.GenotypesContext; import org.broadinstitute.sting.utils.variantcontext.VariantContext; import java.util.*; @@ -211,7 +211,7 @@ public class LeftAlignVariants extends RodWalker { } // create new Genotype objects - GenotypeCollection newGenotypes = GenotypeCollection.create(vc.getNSamples()); + GenotypesContext newGenotypes = GenotypesContext.create(vc.getNSamples()); for ( final Genotype genotype : vc.getGenotypes() ) { List newAlleles = new ArrayList(); for ( Allele allele : genotype.getAlleles() ) { diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariants.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariants.java index 6fec0fac2..7f6e605e7 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariants.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariants.java @@ -556,7 +556,7 @@ public class SelectVariants extends RodWalker { return (compVCs == null || compVCs.isEmpty()); // check if we find it in the variant rod - GenotypeCollection genotypes = vc.getGenotypes(samples); + GenotypesContext genotypes = vc.getGenotypes(samples); for (final Genotype g : genotypes) { if (sampleHasVariant(g)) { // There is a variant called (or filtered with not exclude filtered option set) that is not HomRef for at least one of the samples. diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/VariantsToVCF.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/VariantsToVCF.java index 89322e9f9..78cfde1bd 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/VariantsToVCF.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/VariantsToVCF.java @@ -128,7 +128,7 @@ public class VariantsToVCF extends RodWalker { // set the appropriate sample name if necessary if ( sampleName != null && vc.hasGenotypes() && vc.hasGenotype(variants.getName()) ) { Genotype g = Genotype.modifyName(vc.getGenotype(variants.getName()), sampleName); - GenotypeCollection genotypes = GenotypeCollection.create(g); + GenotypesContext genotypes = GenotypesContext.create(g); vc = VariantContext.modifyGenotypes(vc, genotypes); } diff --git a/public/java/src/org/broadinstitute/sting/utils/codecs/vcf/AbstractVCFCodec.java b/public/java/src/org/broadinstitute/sting/utils/codecs/vcf/AbstractVCFCodec.java index 816863b5e..725cc8109 100755 --- a/public/java/src/org/broadinstitute/sting/utils/codecs/vcf/AbstractVCFCodec.java +++ b/public/java/src/org/broadinstitute/sting/utils/codecs/vcf/AbstractVCFCodec.java @@ -11,7 +11,7 @@ import org.broad.tribble.util.ParsingUtils; import org.broadinstitute.sting.utils.exceptions.ReviewedStingException; import org.broadinstitute.sting.utils.exceptions.UserException; import org.broadinstitute.sting.utils.variantcontext.Allele; -import org.broadinstitute.sting.utils.variantcontext.GenotypeCollection; +import org.broadinstitute.sting.utils.variantcontext.GenotypesContext; import org.broadinstitute.sting.utils.variantcontext.VariantContext; import java.io.*; @@ -76,7 +76,7 @@ public abstract class AbstractVCFCodec implements FeatureCodec, NameAwareCodec, * @param pos position * @return a mapping of sample name to genotype object */ - public abstract GenotypeCollection createGenotypeMap(String str, List alleles, String chr, int pos); + public abstract GenotypesContext createGenotypeMap(String str, List alleles, String chr, int pos); /** diff --git a/public/java/src/org/broadinstitute/sting/utils/codecs/vcf/VCF3Codec.java b/public/java/src/org/broadinstitute/sting/utils/codecs/vcf/VCF3Codec.java index 4d6f26e87..971400ca0 100755 --- a/public/java/src/org/broadinstitute/sting/utils/codecs/vcf/VCF3Codec.java +++ b/public/java/src/org/broadinstitute/sting/utils/codecs/vcf/VCF3Codec.java @@ -5,7 +5,7 @@ import org.broad.tribble.readers.LineReader; import org.broad.tribble.util.ParsingUtils; import org.broadinstitute.sting.utils.variantcontext.Allele; import org.broadinstitute.sting.utils.variantcontext.Genotype; -import org.broadinstitute.sting.utils.variantcontext.GenotypeCollection; +import org.broadinstitute.sting.utils.variantcontext.GenotypesContext; import org.broadinstitute.sting.utils.variantcontext.VariantContext; import java.io.File; @@ -118,13 +118,13 @@ public class VCF3Codec extends AbstractVCFCodec { * @param pos position * @return a mapping of sample name to genotype object */ - public GenotypeCollection createGenotypeMap(String str, List alleles, String chr, int pos) { + public GenotypesContext createGenotypeMap(String str, List alleles, String chr, int pos) { if (genotypeParts == null) genotypeParts = new String[header.getColumnCount() - NUM_STANDARD_FIELDS]; int nParts = ParsingUtils.split(str, genotypeParts, VCFConstants.FIELD_SEPARATOR_CHAR); - GenotypeCollection genotypes = GenotypeCollection.create(nParts); + GenotypesContext genotypes = GenotypesContext.create(nParts); // get the format keys int nGTKeys = ParsingUtils.split(genotypeParts[0], genotypeKeyArray, VCFConstants.GENOTYPE_FIELD_SEPARATOR_CHAR); diff --git a/public/java/src/org/broadinstitute/sting/utils/codecs/vcf/VCFCodec.java b/public/java/src/org/broadinstitute/sting/utils/codecs/vcf/VCFCodec.java index 696b35050..53b3d5fd4 100755 --- a/public/java/src/org/broadinstitute/sting/utils/codecs/vcf/VCFCodec.java +++ b/public/java/src/org/broadinstitute/sting/utils/codecs/vcf/VCFCodec.java @@ -5,7 +5,7 @@ import org.broad.tribble.readers.LineReader; import org.broad.tribble.util.ParsingUtils; import org.broadinstitute.sting.utils.variantcontext.Allele; import org.broadinstitute.sting.utils.variantcontext.Genotype; -import org.broadinstitute.sting.utils.variantcontext.GenotypeCollection; +import org.broadinstitute.sting.utils.variantcontext.GenotypesContext; import org.broadinstitute.sting.utils.variantcontext.VariantContext; import java.io.File; @@ -145,13 +145,13 @@ public class VCFCodec extends AbstractVCFCodec { * @param alleles the list of alleles * @return a mapping of sample name to genotype object */ - public GenotypeCollection createGenotypeMap(String str, List alleles, String chr, int pos) { + public GenotypesContext createGenotypeMap(String str, List alleles, String chr, int pos) { if (genotypeParts == null) genotypeParts = new String[header.getColumnCount() - NUM_STANDARD_FIELDS]; int nParts = ParsingUtils.split(str, genotypeParts, VCFConstants.FIELD_SEPARATOR_CHAR); - GenotypeCollection genotypes = GenotypeCollection.create(nParts); + GenotypesContext genotypes = GenotypesContext.create(nParts); // get the format keys int nGTKeys = ParsingUtils.split(genotypeParts[0], genotypeKeyArray, VCFConstants.GENOTYPE_FIELD_SEPARATOR_CHAR); diff --git a/public/java/src/org/broadinstitute/sting/utils/codecs/vcf/VCFParser.java b/public/java/src/org/broadinstitute/sting/utils/codecs/vcf/VCFParser.java index 86dd5d4f7..8903a176a 100755 --- a/public/java/src/org/broadinstitute/sting/utils/codecs/vcf/VCFParser.java +++ b/public/java/src/org/broadinstitute/sting/utils/codecs/vcf/VCFParser.java @@ -1,7 +1,7 @@ package org.broadinstitute.sting.utils.codecs.vcf; import org.broadinstitute.sting.utils.variantcontext.Allele; -import org.broadinstitute.sting.utils.variantcontext.GenotypeCollection; +import org.broadinstitute.sting.utils.variantcontext.GenotypesContext; import java.util.List; @@ -19,6 +19,6 @@ public interface VCFParser { * @param pos position * @return a mapping of sample name to genotype object */ - public GenotypeCollection createGenotypeMap(String str, List alleles, String chr, int pos); + public GenotypesContext createGenotypeMap(String str, List alleles, String chr, int pos); } diff --git a/public/java/src/org/broadinstitute/sting/utils/gcf/GCF.java b/public/java/src/org/broadinstitute/sting/utils/gcf/GCF.java index 20cadc469..b8672a7bd 100644 --- a/public/java/src/org/broadinstitute/sting/utils/gcf/GCF.java +++ b/public/java/src/org/broadinstitute/sting/utils/gcf/GCF.java @@ -29,7 +29,7 @@ import org.broadinstitute.sting.utils.codecs.vcf.VCFConstants; import org.broadinstitute.sting.utils.exceptions.UserException; import org.broadinstitute.sting.utils.variantcontext.Allele; import org.broadinstitute.sting.utils.variantcontext.Genotype; -import org.broadinstitute.sting.utils.variantcontext.GenotypeCollection; +import org.broadinstitute.sting.utils.variantcontext.GenotypesContext; import org.broadinstitute.sting.utils.variantcontext.VariantContext; import java.io.*; @@ -147,16 +147,16 @@ public class GCF { Map attributes = new HashMap(); attributes.put("INFO", info); Byte refPadByte = refPad == 0 ? null : refPad; - GenotypeCollection genotypes = decodeGenotypes(header); + GenotypesContext genotypes = decodeGenotypes(header); return new VariantContext(source, VCFConstants.EMPTY_ID_FIELD, contig, start, stop, alleleMap, genotypes, negLog10PError, filters, attributes, refPadByte); } - private GenotypeCollection decodeGenotypes(final GCFHeader header) { + private GenotypesContext decodeGenotypes(final GCFHeader header) { if ( genotypes.isEmpty() ) return VariantContext.NO_GENOTYPES; else { - GenotypeCollection map = GenotypeCollection.create(genotypes.size()); + GenotypesContext map = GenotypesContext.create(genotypes.size()); for ( int i = 0; i < genotypes.size(); i++ ) { final String sampleName = header.getSample(i); diff --git a/public/java/src/org/broadinstitute/sting/utils/variantcontext/GenotypeCollection.java b/public/java/src/org/broadinstitute/sting/utils/variantcontext/GenotypesContext.java similarity index 86% rename from public/java/src/org/broadinstitute/sting/utils/variantcontext/GenotypeCollection.java rename to public/java/src/org/broadinstitute/sting/utils/variantcontext/GenotypesContext.java index 4dbc23e63..3b2de4769 100644 --- a/public/java/src/org/broadinstitute/sting/utils/variantcontext/GenotypeCollection.java +++ b/public/java/src/org/broadinstitute/sting/utils/variantcontext/GenotypesContext.java @@ -29,9 +29,9 @@ import java.util.*; /** * */ -public class GenotypeCollection implements List { - public final static GenotypeCollection NO_GENOTYPES = - new GenotypeCollection(new ArrayList(0), new HashMap(0), new HashSet(0), true); +public class GenotypesContext implements List { + public final static GenotypesContext NO_GENOTYPES = + new GenotypesContext(new ArrayList(0), new HashMap(0), new HashSet(0), true); Set sampleNamesInOrder = null; Map sampleNameToOffset = null; @@ -45,25 +45,25 @@ public class GenotypeCollection implements List { // // --------------------------------------------------------------------------- - private GenotypeCollection() { + private GenotypesContext() { this(10, false); } - private GenotypeCollection(final int n, final boolean immutable) { + private GenotypesContext(final int n, final boolean immutable) { this(new ArrayList(n), immutable); } - private GenotypeCollection(final ArrayList genotypes, final boolean immutable) { + private GenotypesContext(final ArrayList genotypes, final boolean immutable) { this.genotypes = genotypes; this.immutable = immutable; this.sampleNameToOffset = null; this.cacheIsInvalid = true; } - private GenotypeCollection(final ArrayList genotypes, - final Map sampleNameToOffset, - final Set sampleNamesInOrder, - final boolean immutable) { + private GenotypesContext(final ArrayList genotypes, + final Map sampleNameToOffset, + final Set sampleNamesInOrder, + final boolean immutable) { this.genotypes = genotypes; this.immutable = immutable; this.sampleNameToOffset = sampleNameToOffset; @@ -77,27 +77,27 @@ public class GenotypeCollection implements List { // // --------------------------------------------------------------------------- - public static final GenotypeCollection create() { - return new GenotypeCollection(); + public static final GenotypesContext create() { + return new GenotypesContext(); } - public static final GenotypeCollection create(final int nGenotypes) { - return new GenotypeCollection(nGenotypes, false); + public static final GenotypesContext create(final int nGenotypes) { + return new GenotypesContext(nGenotypes, false); } - public static final GenotypeCollection create(final ArrayList genotypes) { - return genotypes == null ? NO_GENOTYPES : new GenotypeCollection(genotypes, false); + public static final GenotypesContext create(final ArrayList genotypes) { + return genotypes == null ? NO_GENOTYPES : new GenotypesContext(genotypes, false); } - public static final GenotypeCollection create(final Genotype... genotypes) { - return new GenotypeCollection(new ArrayList(Arrays.asList(genotypes)), false); + public static final GenotypesContext create(final Genotype... genotypes) { + return new GenotypesContext(new ArrayList(Arrays.asList(genotypes)), false); } - public static final GenotypeCollection copy(final GenotypeCollection toCopy) { + public static final GenotypesContext copy(final GenotypesContext toCopy) { return create(new ArrayList(toCopy.genotypes)); } - public static final GenotypeCollection copy(final Collection toCopy) { + public static final GenotypesContext copy(final Collection toCopy) { return toCopy == null ? NO_GENOTYPES : create(new ArrayList(toCopy)); } @@ -123,7 +123,7 @@ public class GenotypeCollection implements List { // // --------------------------------------------------------------------------- - public final GenotypeCollection immutable() { + public final GenotypesContext immutable() { this.genotypes = Collections.unmodifiableList(genotypes); immutable = true; return this; @@ -369,17 +369,17 @@ public class GenotypeCollection implements List { return getSampleNames().containsAll(samples); } - public GenotypeCollection subsetToSamples( final Collection samples ) { + public GenotypesContext subsetToSamples( final Collection samples ) { return subsetToSamples(new HashSet(samples)); } - public GenotypeCollection subsetToSamples( final Set samples ) { + public GenotypesContext subsetToSamples( final Set samples ) { if ( samples.size() == genotypes.size() ) return this; else if ( samples.isEmpty() ) return NO_GENOTYPES; else { - GenotypeCollection subset = create(samples.size()); + GenotypesContext subset = create(samples.size()); for ( final Genotype g : genotypes ) { if ( samples.contains(g.getSampleName()) ) { subset.add(g); diff --git a/public/java/src/org/broadinstitute/sting/utils/variantcontext/VariantContext.java b/public/java/src/org/broadinstitute/sting/utils/variantcontext/VariantContext.java index d0f88e2ec..0a193f59a 100755 --- a/public/java/src/org/broadinstitute/sting/utils/variantcontext/VariantContext.java +++ b/public/java/src/org/broadinstitute/sting/utils/variantcontext/VariantContext.java @@ -7,7 +7,6 @@ import org.broadinstitute.sting.utils.codecs.vcf.VCFConstants; import org.broadinstitute.sting.utils.codecs.vcf.VCFParser; import org.broadinstitute.sting.utils.exceptions.ReviewedStingException; -import java.lang.reflect.Array; import java.util.*; /** @@ -188,12 +187,12 @@ public class VariantContext implements Feature { // to enable tribble intergrati final protected List alleles; /** A mapping from sampleName -> genotype objects for all genotypes associated with this context */ - protected GenotypeCollection genotypes = null; + protected GenotypesContext genotypes = null; /** Counts for each of the possible Genotype types in this context */ protected int[] genotypeCounts = null; - public final static GenotypeCollection NO_GENOTYPES = GenotypeCollection.NO_GENOTYPES; + public final static GenotypesContext NO_GENOTYPES = GenotypesContext.NO_GENOTYPES; // a fast cached access point to the ref / alt alleles for biallelic case private Allele REF = null; @@ -226,12 +225,12 @@ public class VariantContext implements Feature { // to enable tribble intergrati * @param attributes attributes * @param referenceBaseForIndel padded reference base */ - public VariantContext(String source, String ID, String contig, long start, long stop, Collection alleles, GenotypeCollection genotypes, double negLog10PError, Set filters, Map attributes, Byte referenceBaseForIndel) { + public VariantContext(String source, String ID, String contig, long start, long stop, Collection alleles, GenotypesContext genotypes, double negLog10PError, Set filters, Map attributes, Byte referenceBaseForIndel) { this(source, ID, contig, start, stop, alleles, genotypes, negLog10PError, filters, attributes, referenceBaseForIndel, false, true); } @Deprecated - public VariantContext(String source, String contig, long start, long stop, Collection alleles, GenotypeCollection genotypes, double negLog10PError, Set filters, Map attributes, Byte referenceBaseForIndel) { + public VariantContext(String source, String contig, long start, long stop, Collection alleles, GenotypesContext genotypes, double negLog10PError, Set filters, Map attributes, Byte referenceBaseForIndel) { this(source, VCFConstants.EMPTY_ID_FIELD, contig, start, stop, alleles, genotypes, negLog10PError, filters, attributes, referenceBaseForIndel); } @@ -249,12 +248,12 @@ public class VariantContext implements Feature { // to enable tribble intergrati * @param filters filters: use null for unfiltered and empty set for passes filters * @param attributes attributes */ - public VariantContext(String source, String ID, String contig, long start, long stop, Collection alleles, GenotypeCollection genotypes, double negLog10PError, Set filters, Map attributes) { + public VariantContext(String source, String ID, String contig, long start, long stop, Collection alleles, GenotypesContext genotypes, double negLog10PError, Set filters, Map attributes) { this(source, ID, contig, start, stop, alleles, genotypes, negLog10PError, filters, attributes, null, false, true); } @Deprecated - public VariantContext(String source, String contig, long start, long stop, Collection alleles, GenotypeCollection genotypes, double negLog10PError, Set filters, Map attributes) { + public VariantContext(String source, String contig, long start, long stop, Collection alleles, GenotypesContext genotypes, double negLog10PError, Set filters, Map attributes) { this(source, VCFConstants.EMPTY_ID_FIELD, contig, start, stop, alleles, genotypes, negLog10PError, filters, attributes); } @@ -299,14 +298,14 @@ public class VariantContext implements Feature { // to enable tribble intergrati */ public VariantContext(String source, String ID, String contig, long start, long stop, Collection alleles, Collection genotypes, double negLog10PError, Set filters, Map attributes) { this(source, ID, contig, start, stop, alleles, - GenotypeCollection.copy(genotypes), + GenotypesContext.copy(genotypes), negLog10PError, filters, attributes, null, false, true); } @Deprecated public VariantContext(String source, String contig, long start, long stop, Collection alleles, Collection genotypes, double negLog10PError, Set filters, Map attributes) { this(source, VCFConstants.EMPTY_ID_FIELD, contig, start, stop, alleles, - GenotypeCollection.copy(genotypes), + GenotypesContext.copy(genotypes), negLog10PError, filters, attributes); } @@ -374,7 +373,7 @@ public class VariantContext implements Feature { // to enable tribble intergrati */ private VariantContext(String source, String ID, String contig, long start, long stop, - Collection alleles, GenotypeCollection genotypes, + Collection alleles, GenotypesContext genotypes, double negLog10PError, Set filters, Map attributes, Byte referenceBaseForIndel, boolean genotypesAreUnparsed, boolean performValidation ) { @@ -445,7 +444,7 @@ public class VariantContext implements Feature { // to enable tribble intergrati // // --------------------------------------------------------------------------------------------------------- - public static VariantContext modifyGenotypes(VariantContext vc, GenotypeCollection genotypes) { + public static VariantContext modifyGenotypes(VariantContext vc, GenotypesContext genotypes) { VariantContext modifiedVC = new VariantContext(vc.getSource(), vc.getID(), vc.getChr(), vc.getStart(), vc.getEnd(), vc.getAlleles(), genotypes, vc.getNegLog10PError(), vc.filtersWereApplied() ? vc.getFilters() : null, vc.getAttributes(), vc.getReferenceBaseForIndel(), false, false); modifiedVC.validateGenotypes(); return modifiedVC; @@ -544,7 +543,7 @@ public class VariantContext implements Feature { // to enable tribble intergrati public VariantContext subContextFromSamples(Set sampleNames, Collection alleles) { loadGenotypes(); - GenotypeCollection newGenotypes = genotypes.subsetToSamples(sampleNames); + GenotypesContext newGenotypes = genotypes.subsetToSamples(sampleNames); return new VariantContext(getSource(), getID(), contig, start, stop, alleles, newGenotypes, getNegLog10PError(), @@ -555,7 +554,7 @@ public class VariantContext implements Feature { // to enable tribble intergrati public VariantContext subContextFromSamples(Set sampleNames) { loadGenotypes(); - GenotypeCollection newGenotypes = genotypes.subsetToSamples(sampleNames); + GenotypesContext newGenotypes = genotypes.subsetToSamples(sampleNames); return new VariantContext(getSource(), getID(), contig, start, stop, allelesOfGenotypes(newGenotypes), newGenotypes, getNegLog10PError(), @@ -981,7 +980,7 @@ public class VariantContext implements Feature { // to enable tribble intergrati /** * @return set of all Genotypes associated with this context */ - public GenotypeCollection getGenotypes() { + public GenotypesContext getGenotypes() { loadGenotypes(); return genotypes; } @@ -999,7 +998,7 @@ public class VariantContext implements Feature { // to enable tribble intergrati * @return * @throws IllegalArgumentException if sampleName isn't bound to a genotype */ - public GenotypeCollection getGenotypes(String sampleName) { + public GenotypesContext getGenotypes(String sampleName) { return getGenotypes(Arrays.asList(sampleName)); } @@ -1011,11 +1010,11 @@ public class VariantContext implements Feature { // to enable tribble intergrati * @return * @throws IllegalArgumentException if sampleName isn't bound to a genotype */ - public GenotypeCollection getGenotypes(Collection sampleNames) { + public GenotypesContext getGenotypes(Collection sampleNames) { return getGenotypes().subsetToSamples(sampleNames); } - public GenotypeCollection getGenotypes(Set sampleNames) { + public GenotypesContext getGenotypes(Set sampleNames) { return getGenotypes().subsetToSamples(sampleNames); } @@ -1567,7 +1566,7 @@ public class VariantContext implements Feature { // to enable tribble intergrati } // now we can recreate new genotypes with trimmed alleles - GenotypeCollection genotypes = GenotypeCollection.create(inputVC.getNSamples()); + GenotypesContext genotypes = GenotypesContext.create(inputVC.getNSamples()); for (final Genotype g : inputVC.getGenotypes() ) { List inAlleles = g.getAlleles(); List newGenotypeAlleles = new ArrayList(g.getAlleles().size()); diff --git a/public/java/src/org/broadinstitute/sting/utils/variantcontext/VariantContextUtils.java b/public/java/src/org/broadinstitute/sting/utils/variantcontext/VariantContextUtils.java index 238cf4b3b..b77f606f5 100755 --- a/public/java/src/org/broadinstitute/sting/utils/variantcontext/VariantContextUtils.java +++ b/public/java/src/org/broadinstitute/sting/utils/variantcontext/VariantContextUtils.java @@ -294,7 +294,7 @@ public class VariantContextUtils { final Map attributes = subsetAttributes(vc.commonInfo, keysToPreserve); // Genotypes - final GenotypeCollection genotypes = GenotypeCollection.create(vc.getNSamples()); + final GenotypesContext genotypes = GenotypesContext.create(vc.getNSamples()); for ( final Genotype g : vc.getGenotypes() ) { Map genotypeAttributes = subsetAttributes(g.commonInfo, keysToPreserve); genotypes.add(new Genotype(g.getSampleName(), g.getAlleles(), g.getNegLog10PError(), g.getFilters(), @@ -402,7 +402,7 @@ public class VariantContextUtils { double negLog10PError = -1; VariantContext vcWithMaxAC = null; Set addedSamples = new HashSet(first.getNSamples()); - GenotypeCollection genotypes = GenotypeCollection.create(); + GenotypesContext genotypes = GenotypesContext.create(); // counting the number of filtered and variant VCs int nFiltered = 0; @@ -590,7 +590,7 @@ public class VariantContextUtils { // nothing to do if we don't need to trim bases if (trimVC) { List alleles = new ArrayList(); - GenotypeCollection genotypes = GenotypeCollection.create(); + GenotypesContext genotypes = GenotypesContext.create(); // set the reference base for indels in the attributes Map attributes = new TreeMap(inputVC.getAttributes()); @@ -644,8 +644,8 @@ public class VariantContextUtils { return inputVC; } - public static GenotypeCollection stripPLs(GenotypeCollection genotypes) { - GenotypeCollection newGs = GenotypeCollection.create(genotypes.size()); + public static GenotypesContext stripPLs(GenotypesContext genotypes) { + GenotypesContext newGs = GenotypesContext.create(genotypes.size()); for ( final Genotype g : genotypes ) { newGs.add(g.hasLikelihoods() ? removePLs(g) : g); @@ -825,7 +825,7 @@ public class VariantContextUtils { } } - private static void mergeGenotypes(GenotypeCollection mergedGenotypes, Set addedSamples, VariantContext oneVC, AlleleMapper alleleMapping, boolean uniqifySamples) { + private static void mergeGenotypes(GenotypesContext mergedGenotypes, Set addedSamples, VariantContext oneVC, AlleleMapper alleleMapping, boolean uniqifySamples) { for ( Genotype g : oneVC.getGenotypes() ) { String name = mergedSampleName(oneVC.getSource(), g.getSampleName(), uniqifySamples); if ( ! addedSamples.contains(name) ) { @@ -866,7 +866,7 @@ public class VariantContextUtils { } // create new Genotype objects - GenotypeCollection newGenotypes = GenotypeCollection.create(vc.getNSamples()); + GenotypesContext newGenotypes = GenotypesContext.create(vc.getNSamples()); for ( final Genotype genotype : vc.getGenotypes() ) { List newAlleles = new ArrayList(); for ( Allele allele : genotype.getAlleles() ) { @@ -886,7 +886,7 @@ public class VariantContextUtils { if ( allowedAttributes == null ) return vc; - GenotypeCollection newGenotypes = GenotypeCollection.create(vc.getNSamples()); + GenotypesContext newGenotypes = GenotypesContext.create(vc.getNSamples()); for ( final Genotype genotype : vc.getGenotypes() ) { Map attrs = new HashMap(); for ( Map.Entry attr : genotype.getAttributes().entrySet() ) { diff --git a/public/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFWriterUnitTest.java b/public/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFWriterUnitTest.java index ad38b46e3..4b21e09e3 100644 --- a/public/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFWriterUnitTest.java +++ b/public/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFWriterUnitTest.java @@ -4,7 +4,7 @@ import org.broad.tribble.Tribble; import org.broad.tribble.readers.AsciiLineReader; import org.broadinstitute.sting.utils.variantcontext.Allele; import org.broadinstitute.sting.utils.variantcontext.Genotype; -import org.broadinstitute.sting.utils.variantcontext.GenotypeCollection; +import org.broadinstitute.sting.utils.variantcontext.GenotypesContext; import org.broadinstitute.sting.utils.variantcontext.VariantContext; import org.broadinstitute.sting.utils.codecs.vcf.*; import org.broadinstitute.sting.utils.exceptions.UserException; @@ -122,7 +122,7 @@ public class VCFWriterUnitTest extends BaseTest { List alleles = new ArrayList(); Set filters = null; Map attributes = new HashMap(); - GenotypeCollection genotypes = GenotypeCollection.create(header.getGenotypeSamples().size()); + GenotypesContext genotypes = GenotypesContext.create(header.getGenotypeSamples().size()); alleles.add(Allele.create("-",true)); alleles.add(Allele.create("CC",false)); diff --git a/public/java/test/org/broadinstitute/sting/utils/variantcontext/VariantContextBenchmark.java b/public/java/test/org/broadinstitute/sting/utils/variantcontext/VariantContextBenchmark.java index eda74a965..273b8fdf7 100644 --- a/public/java/test/org/broadinstitute/sting/utils/variantcontext/VariantContextBenchmark.java +++ b/public/java/test/org/broadinstitute/sting/utils/variantcontext/VariantContextBenchmark.java @@ -226,7 +226,7 @@ public class VariantContextBenchmark extends SimpleBenchmark { List toMerge = new ArrayList(); for ( int i = 0; i < dupsToMerge; i++ ) { - GenotypeCollection gc = GenotypeCollection.create(vc.getNSamples()); + GenotypesContext gc = GenotypesContext.create(vc.getNSamples()); for ( final Genotype g : vc.getGenotypes() ) { gc.add(new Genotype(g.getSampleName()+"_"+i, g)); } diff --git a/public/java/test/org/broadinstitute/sting/utils/variantcontext/VariantContextUtilsUnitTest.java b/public/java/test/org/broadinstitute/sting/utils/variantcontext/VariantContextUtilsUnitTest.java index dbe131a14..805781fe0 100644 --- a/public/java/test/org/broadinstitute/sting/utils/variantcontext/VariantContextUtilsUnitTest.java +++ b/public/java/test/org/broadinstitute/sting/utils/variantcontext/VariantContextUtilsUnitTest.java @@ -100,7 +100,7 @@ public class VariantContextUtilsUnitTest extends BaseTest { int start = 10; int stop = start; // alleles.contains(ATC) ? start + 3 : start; return new VariantContext(source, VCFConstants.EMPTY_ID_FIELD, "1", start, stop, alleles, - GenotypeCollection.copy(genotypes), 1.0, filters, null, Cref.getBases()[0]); + GenotypesContext.copy(genotypes), 1.0, filters, null, Cref.getBases()[0]); } // -------------------------------------------------------------------------------- @@ -508,7 +508,7 @@ public class VariantContextUtilsUnitTest extends BaseTest { } // necessary to not overload equals for genotypes - private void assertGenotypesAreMostlyEqual(GenotypeCollection actual, GenotypeCollection expected) { + private void assertGenotypesAreMostlyEqual(GenotypesContext actual, GenotypesContext expected) { if (actual == expected) { return; }