VariantContext genotypes are now stored as GenotypeMap objects

-- Enables further sophisticated optimizations, as this class can be smarter about storing the data and will directly support operations like subset to samples
-- All instances in the gatk that used Map<String, Genotype> now use GenotypeMap type.
-- Amazingly, there were many places where HashMap<String, Genotype> is used, so that the order of the genotypes is technically undefined and could be dangerous.  Now everything uses GenotypeMap with a specific ordering of samples (by name)
-- Integrationtests updated and all pass
This commit is contained in:
Mark DePristo 2011-11-11 15:00:35 -05:00
parent 4938569b3a
commit fee9b367e4
34 changed files with 186 additions and 125 deletions

View File

@ -194,7 +194,7 @@ public class VariantContextAdaptors {
return null; // we weren't given enough reference context to create the VariantContext
Byte refBaseForIndel = new Byte(ref.getBases()[index]);
Map<String, Genotype> genotypes = null;
GenotypeMap genotypes = null;
VariantContext vc = new VariantContext(name, 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
@ -329,7 +329,7 @@ public class VariantContextAdaptors {
String[] samples = hapmap.getSampleIDs();
String[] genotypeStrings = hapmap.getGenotypes();
Map<String, Genotype> genotypes = new HashMap<String, Genotype>(samples.length);
GenotypeMap genotypes = GenotypeMap.create(samples.length);
for ( int i = 0; i < samples.length; i++ ) {
// ignore bad genotypes
if ( genotypeStrings[i].contains("N") )

View File

@ -35,6 +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.GenotypeMap;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import java.util.Arrays;
@ -54,7 +55,7 @@ public class AlleleBalance extends InfoFieldAnnotation {
if ( !vc.isBiallelic() )
return null;
final Map<String, Genotype> genotypes = vc.getGenotypes();
final GenotypeMap genotypes = vc.getGenotypes();
if ( !vc.hasGenotypes() )
return null;

View File

@ -11,6 +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.GenotypeMap;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import java.util.Arrays;
@ -30,7 +31,7 @@ public class HardyWeinberg extends InfoFieldAnnotation implements WorkInProgress
public Map<String, Object> annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
final Map<String, Genotype> genotypes = vc.getGenotypes();
final GenotypeMap genotypes = vc.getGenotypes();
if ( genotypes == null || genotypes.size() < MIN_SAMPLES )
return null;

View File

@ -10,6 +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.GenotypeMap;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import java.util.Arrays;
@ -32,7 +33,7 @@ public class InbreedingCoeff extends InfoFieldAnnotation implements StandardAnno
public Map<String, Object> annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
final Map<String, Genotype> genotypes = vc.getGenotypes();
final GenotypeMap genotypes = vc.getGenotypes();
if ( genotypes == null || genotypes.size() < MIN_SAMPLES )
return null;

View File

@ -9,6 +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.GenotypeMap;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import java.util.Arrays;
@ -28,7 +29,7 @@ public class QualByDepth extends InfoFieldAnnotation implements StandardAnnotati
if ( stratifiedContexts.size() == 0 )
return null;
final Map<String, Genotype> genotypes = vc.getGenotypes();
final GenotypeMap genotypes = vc.getGenotypes();
if ( genotypes == null || genotypes.size() == 0 )
return null;

View File

@ -13,6 +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.GenotypeMap;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import java.util.ArrayList;
@ -32,7 +33,7 @@ public abstract class RankSumTest extends InfoFieldAnnotation implements Standar
if ( stratifiedContexts.size() == 0 )
return null;
final Map<String, Genotype> genotypes = vc.getGenotypes();
final GenotypeMap genotypes = vc.getGenotypes();
if ( genotypes == null || genotypes.size() == 0 )
return null;

View File

@ -34,6 +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.GenotypeMap;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import java.util.*;
@ -216,11 +217,11 @@ public class VariantAnnotatorEngine {
}
}
private Map<String, Genotype> annotateGenotypes(RefMetaDataTracker tracker, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
private GenotypeMap annotateGenotypes(RefMetaDataTracker tracker, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
if ( requestedGenotypeAnnotations.size() == 0 )
return vc.getGenotypes();
Map<String, Genotype> genotypes = new HashMap<String, Genotype>(vc.getNSamples());
GenotypeMap genotypes = GenotypeMap.create(vc.getNSamples());
for ( Map.Entry<String, Genotype> g : vc.getGenotypes().entrySet() ) {
Genotype genotype = g.getValue();
AlignmentContext context = stratifiedContexts.get(g.getKey());

View File

@ -36,10 +36,7 @@ import org.broadinstitute.sting.gatk.walkers.RodWalker;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.SampleUtils;
import org.broadinstitute.sting.utils.codecs.vcf.*;
import org.broadinstitute.sting.utils.variantcontext.Allele;
import org.broadinstitute.sting.utils.variantcontext.Genotype;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import org.broadinstitute.sting.utils.variantcontext.VariantContextUtils;
import org.broadinstitute.sting.utils.variantcontext.*;
import java.util.*;
@ -190,8 +187,7 @@ public class BeagleOutputToVCFWalker extends RodWalker<Integer, Integer> {
byte refByte = ref.getBase();
// make new Genotypes based on Beagle results
Map<String, Genotype> genotypes = new HashMap<String, Genotype>(vc_input.getGenotypes().size());
GenotypeMap genotypes = GenotypeMap.create(vc_input.getGenotypes().size());
// for each genotype, create a new object with Beagle information on it
@ -200,7 +196,7 @@ public class BeagleOutputToVCFWalker extends RodWalker<Integer, Integer> {
Double alleleFrequencyH = 0.0;
int beagleVarCounts = 0;
Map<String,Genotype> hapmapGenotypes = null;
GenotypeMap hapmapGenotypes = null;
if (vc_comp != null) {
hapmapGenotypes = vc_comp.getGenotypes();

View File

@ -37,6 +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.GenotypeMap;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import org.broadinstitute.sting.utils.variantcontext.VariantContextUtils;
@ -282,11 +283,11 @@ public class VariantFiltrationWalker extends RodWalker<Integer, Integer> {
VariantContext vc = context.getVariantContext();
// make new Genotypes based on filters
Map<String, Genotype> genotypes;
GenotypeMap genotypes;
if ( genotypeFilterExps.size() == 0 ) {
genotypes = null;
} else {
genotypes = new HashMap<String, Genotype>(vc.getGenotypes().size());
genotypes = GenotypeMap.create(vc.getGenotypes().size());
// for each genotype, check filters then create a new object
for ( Map.Entry<String, Genotype> genotype : vc.getGenotypes().entrySet() ) {

View File

@ -30,6 +30,7 @@ import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.utils.variantcontext.Allele;
import org.broadinstitute.sting.utils.variantcontext.Genotype;
import org.broadinstitute.sting.utils.variantcontext.GenotypeMap;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import java.io.PrintStream;
@ -85,7 +86,7 @@ public abstract class AlleleFrequencyCalculationModel implements Cloneable {
*
* @return calls
*/
protected abstract Map<String, Genotype> assignGenotypes(VariantContext vc,
double[] log10AlleleFrequencyPosteriors,
int AFofMaxLikelihood);
protected abstract GenotypeMap assignGenotypes(VariantContext vc,
double[] log10AlleleFrequencyPosteriors,
int AFofMaxLikelihood);
}

View File

@ -33,6 +33,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.GenotypeMap;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import java.io.PrintStream;
@ -268,14 +269,14 @@ public class ExactAFCalculationModel extends AlleleFrequencyCalculationModel {
*
* @return calls
*/
public Map<String, Genotype> assignGenotypes(VariantContext vc,
double[] log10AlleleFrequencyPosteriors,
int AFofMaxLikelihood) {
public GenotypeMap 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());
Map<String, Genotype> GLs = vc.getGenotypes();
GenotypeMap GLs = vc.getGenotypes();
double[][] pathMetricArray = new double[GLs.size()+1][AFofMaxLikelihood+1];
int[][] tracebackArray = new int[GLs.size()+1][AFofMaxLikelihood+1];
@ -342,7 +343,7 @@ public class ExactAFCalculationModel extends AlleleFrequencyCalculationModel {
}
}
HashMap<String, Genotype> calls = new HashMap<String, Genotype>();
GenotypeMap calls = GenotypeMap.create();
int startIdx = AFofMaxLikelihood;
for (int k = sampleIdx; k > 0; k--) {

View File

@ -34,6 +34,7 @@ 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.Genotype;
import org.broadinstitute.sting.utils.variantcontext.GenotypeMap;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import java.io.PrintStream;
@ -89,15 +90,15 @@ public class GridSearchAFEstimation extends AlleleFrequencyCalculationModel {
*
* @return calls
*/
protected Map<String, Genotype> assignGenotypes(VariantContext vc,
double[] log10AlleleFrequencyPosteriors,
int AFofMaxLikelihood) {
protected GenotypeMap 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());
Allele refAllele = vc.getReference();
Allele altAllele = vc.getAlternateAllele(0);
HashMap<String, Genotype> calls = new HashMap<String, Genotype>();
GenotypeMap calls = GenotypeMap.create();
// first, the potential alt calls
for ( String sample : AFMatrix.getSamples() ) {

View File

@ -36,6 +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.GenotypeMap;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import org.broadinstitute.sting.utils.variantcontext.VariantContextUtils;
@ -128,7 +129,7 @@ public class UGCallVariants extends RodWalker<VariantCallContext, Integer> {
return null;
VariantContext variantVC = null;
Map<String, Genotype> genotypes = new HashMap<String, Genotype>();
GenotypeMap genotypes = GenotypeMap.create();
for ( VariantContext vc : VCs ) {
if ( variantVC == null && vc.isVariant() )
variantVC = vc;

View File

@ -265,7 +265,7 @@ public class UnifiedGenotyperEngine {
alleles.add(refAllele);
boolean addedAltAlleles = false;
HashMap<String, Genotype> genotypes = new HashMap<String, Genotype>();
GenotypeMap genotypes = GenotypeMap.create();
for ( MultiallelicGenotypeLikelihoods GL : GLs.values() ) {
if ( !addedAltAlleles ) {
addedAltAlleles = true;
@ -354,7 +354,7 @@ public class UnifiedGenotyperEngine {
}
// create the genotypes
Map<String, Genotype> genotypes = afcm.get().assignGenotypes(vc, log10AlleleFrequencyPosteriors.get(), bestAFguess);
GenotypeMap 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
Map<String, Genotype> genotypes = afcm.get().assignGenotypes(vc, log10AlleleFrequencyPosteriors.get(), bestAFguess);
GenotypeMap genotypes = afcm.get().assignGenotypes(vc, log10AlleleFrequencyPosteriors.get(), bestAFguess);
// *** note that calculating strand bias involves overwriting data structures, so we do that last
HashMap<String, Object> attributes = new HashMap<String, Object>();

View File

@ -60,6 +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.GenotypeMap;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import java.io.*;
@ -1057,7 +1058,7 @@ public class SomaticIndelDetectorWalker extends ReadWalker<Integer,Integer> {
stop += event_length;
}
Map<String,Genotype> genotypes = new HashMap<String,Genotype>();
GenotypeMap genotypes = GenotypeMap.create();
for ( String sample : normalSamples ) {
@ -1147,7 +1148,7 @@ public class SomaticIndelDetectorWalker extends ReadWalker<Integer,Integer> {
homRefAlleles.add( alleles.get(0));
homRefAlleles.add( alleles.get(0));
Map<String,Genotype> genotypes = new HashMap<String,Genotype>();
GenotypeMap genotypes = GenotypeMap.create();
for ( String sample : normalSamples ) {
genotypes.put(sample,new Genotype(sample, homRefN ? homRefAlleles : alleles,Genotype.NO_NEG_LOG_10PERROR,null,attrsNormal,false));

View File

@ -12,10 +12,7 @@ import org.broadinstitute.sting.utils.MathUtils;
import org.broadinstitute.sting.utils.SampleUtils;
import org.broadinstitute.sting.utils.codecs.vcf.*;
import org.broadinstitute.sting.utils.text.XReadLines;
import org.broadinstitute.sting.utils.variantcontext.Allele;
import org.broadinstitute.sting.utils.variantcontext.Genotype;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import org.broadinstitute.sting.utils.variantcontext.VariantContextUtils;
import org.broadinstitute.sting.utils.variantcontext.*;
import java.io.File;
import java.io.FileNotFoundException;
@ -296,7 +293,7 @@ public class PhaseByTransmission extends RodWalker<Integer, Integer> {
if (tracker != null) {
VariantContext vc = tracker.getFirstValue(variantCollection.variants, context.getLocation());
Map<String, Genotype> genotypeMap = vc.getGenotypes();
GenotypeMap genotypeMap = vc.getGenotypes();
for (Trio trio : trios) {
Genotype mother = vc.getGenotype(trio.getMother());

View File

@ -41,10 +41,7 @@ import org.broadinstitute.sting.utils.codecs.vcf.*;
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
import org.broadinstitute.sting.utils.pileup.PileupElement;
import org.broadinstitute.sting.utils.pileup.ReadBackedPileup;
import org.broadinstitute.sting.utils.variantcontext.Allele;
import org.broadinstitute.sting.utils.variantcontext.Genotype;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import org.broadinstitute.sting.utils.variantcontext.VariantContextUtils;
import org.broadinstitute.sting.utils.variantcontext.*;
import java.io.*;
import java.util.*;
@ -355,7 +352,7 @@ public class ReadBackedPhasingWalker extends RodWalker<PhasingStatsAndOutput, Ph
UnfinishedVariantContext uvc = uvr.unfinishedVariant;
// Perform per-sample phasing:
Map<String, Genotype> sampGenotypes = vc.getGenotypes();
GenotypeMap sampGenotypes = vc.getGenotypes();
Map<String, PhaseCounts> samplePhaseStats = new TreeMap<String, PhaseCounts>();
for (Map.Entry<String, Genotype> sampGtEntry : sampGenotypes.entrySet()) {
String samp = sampGtEntry.getKey();
@ -1126,7 +1123,7 @@ public class ReadBackedPhasingWalker extends RodWalker<PhasingStatsAndOutput, Ph
private int start;
private int stop;
private Collection<Allele> alleles;
private Map<String, Genotype> genotypes;
private GenotypeMap genotypes;
private double negLog10PError;
private Set<String> filters;
private Map<String, Object> attributes;
@ -1137,7 +1134,7 @@ public class ReadBackedPhasingWalker extends RodWalker<PhasingStatsAndOutput, Ph
this.start = vc.getStart();
this.stop = vc.getEnd();
this.alleles = vc.getAlleles();
this.genotypes = new HashMap<String, Genotype>(vc.getGenotypes()); // since vc.getGenotypes() is unmodifiable
this.genotypes = GenotypeMap.create(vc.getGenotypes()); // since vc.getGenotypes() is unmodifiable
this.negLog10PError = vc.getNegLog10PError();
this.filters = vc.filtersWereApplied() ? vc.getFilters() : null;
this.attributes = new HashMap<String, Object>(vc.getAttributes());

View File

@ -14,6 +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.GenotypeMap;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import java.util.HashMap;
@ -91,13 +92,13 @@ public class GenotypePhasingEvaluator extends VariantEvaluator {
Set<String> allSamples = new HashSet<String>();
Map<String, Genotype> compSampGenotypes = null;
GenotypeMap compSampGenotypes = null;
if (isRelevantToPhasing(comp)) {
allSamples.addAll(comp.getSampleNames());
compSampGenotypes = comp.getGenotypes();
}
Map<String, Genotype> evalSampGenotypes = null;
GenotypeMap evalSampGenotypes = null;
if (isRelevantToPhasing(eval)) {
allSamples.addAll(eval.getSampleNames());
evalSampGenotypes = eval.getGenotypes();

View File

@ -40,6 +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.GenotypeMap;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import java.util.*;
@ -210,7 +211,7 @@ public class LeftAlignVariants extends RodWalker<Integer, Integer> {
}
// create new Genotype objects
Map<String, Genotype> newGenotypes = new HashMap<String, Genotype>(vc.getNSamples());
GenotypeMap newGenotypes = GenotypeMap.create(vc.getNSamples());
for ( Map.Entry<String, Genotype> genotype : vc.getGenotypes().entrySet() ) {
List<Allele> newAlleles = new ArrayList<Allele>();
for ( Allele allele : genotype.getValue().getAlleles() ) {

View File

@ -33,7 +33,7 @@ import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.text.XReadLines;
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
import org.broadinstitute.sting.utils.MendelianViolation;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import org.broadinstitute.sting.utils.variantcontext.*;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
@ -41,9 +41,6 @@ import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.walkers.RodWalker;
import org.broadinstitute.sting.utils.SampleUtils;
import org.broadinstitute.sting.utils.variantcontext.Allele;
import org.broadinstitute.sting.utils.variantcontext.Genotype;
import org.broadinstitute.sting.utils.variantcontext.VariantContextUtils;
import java.io.File;
import java.io.FileNotFoundException;
@ -561,7 +558,7 @@ public class SelectVariants extends RodWalker<Integer, Integer> {
return (compVCs == null || compVCs.isEmpty());
// check if we find it in the variant rod
Map<String, Genotype> genotypes = vc.getGenotypes(samples);
GenotypeMap genotypes = vc.getGenotypes(samples);
for (Genotype g : genotypes.values()) {
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.
@ -659,7 +656,7 @@ public class SelectVariants extends RodWalker<Integer, Integer> {
if ( samples == null || samples.isEmpty() )
return vc;
VariantContext sub = vc.subContextFromSamples(samples);
VariantContext sub = vc.subContextFromSamples(samples, vc.getAlleles());
// if we have fewer alternate alleles in the selected VC than in the original VC, we need to strip out the GL/PLs (because they are no longer accurate)
if ( vc.getAlleles().size() != sub.getAlleles().size() )

View File

@ -42,10 +42,7 @@ import org.broadinstitute.sting.utils.SampleUtils;
import org.broadinstitute.sting.utils.codecs.hapmap.RawHapMapFeature;
import org.broadinstitute.sting.utils.codecs.vcf.*;
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.VariantContext;
import org.broadinstitute.sting.utils.variantcontext.VariantContextUtils;
import org.broadinstitute.sting.utils.variantcontext.*;
import java.io.File;
import java.util.*;
@ -133,7 +130,7 @@ public class VariantsToVCF extends RodWalker<Integer, Integer> {
// 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);
Map<String, Genotype> genotypes = new HashMap<String, Genotype>();
GenotypeMap genotypes = GenotypeMap.create(1);
genotypes.put(sampleName, g);
vc = VariantContext.modifyGenotypes(vc, genotypes);
}

View File

@ -12,6 +12,7 @@ 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.Genotype;
import org.broadinstitute.sting.utils.variantcontext.GenotypeMap;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import java.io.*;
@ -76,7 +77,7 @@ public abstract class AbstractVCFCodec implements FeatureCodec, NameAwareCodec,
* @param pos position
* @return a mapping of sample name to genotype object
*/
public abstract Map<String, Genotype> createGenotypeMap(String str, List<Allele> alleles, String chr, int pos);
public abstract GenotypeMap createGenotypeMap(String str, List<Allele> alleles, String chr, int pos);
/**

View File

@ -5,6 +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.GenotypeMap;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import java.io.File;
@ -118,13 +119,13 @@ public class VCF3Codec extends AbstractVCFCodec {
* @param pos position
* @return a mapping of sample name to genotype object
*/
public Map<String, Genotype> createGenotypeMap(String str, List<Allele> alleles, String chr, int pos) {
public GenotypeMap createGenotypeMap(String str, List<Allele> 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);
Map<String, Genotype> genotypes = new LinkedHashMap<String, Genotype>(nParts);
GenotypeMap genotypes = GenotypeMap.create(nParts);
// get the format keys
int nGTKeys = ParsingUtils.split(genotypeParts[0], genotypeKeyArray, VCFConstants.GENOTYPE_FIELD_SEPARATOR_CHAR);

View File

@ -5,6 +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.GenotypeMap;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import java.io.File;
@ -145,13 +146,13 @@ public class VCFCodec extends AbstractVCFCodec {
* @param alleles the list of alleles
* @return a mapping of sample name to genotype object
*/
public Map<String, Genotype> createGenotypeMap(String str, List<Allele> alleles, String chr, int pos) {
public GenotypeMap createGenotypeMap(String str, List<Allele> 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);
Map<String, Genotype> genotypes = new LinkedHashMap<String, Genotype>(nParts);
GenotypeMap genotypes = GenotypeMap.create(nParts);
// get the format keys
int nGTKeys = ParsingUtils.split(genotypeParts[0], genotypeKeyArray, VCFConstants.GENOTYPE_FIELD_SEPARATOR_CHAR);

View File

@ -2,6 +2,7 @@ package org.broadinstitute.sting.utils.codecs.vcf;
import org.broadinstitute.sting.utils.variantcontext.Allele;
import org.broadinstitute.sting.utils.variantcontext.Genotype;
import org.broadinstitute.sting.utils.variantcontext.GenotypeMap;
import java.util.List;
import java.util.Map;
@ -20,6 +21,6 @@ public interface VCFParser {
* @param pos position
* @return a mapping of sample name to genotype object
*/
public Map<String, Genotype> createGenotypeMap(String str, List<Allele> alleles, String chr, int pos);
public GenotypeMap createGenotypeMap(String str, List<Allele> alleles, String chr, int pos);
}

View File

@ -28,6 +28,7 @@ import org.broadinstitute.sting.utils.codecs.vcf.StandardVCFWriter;
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.GenotypeMap;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import java.io.*;
@ -145,16 +146,16 @@ public class GCF {
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put("INFO", info);
Byte refPadByte = refPad == 0 ? null : refPad;
Map<String, Genotype> genotypes = decodeGenotypes(header);
GenotypeMap genotypes = decodeGenotypes(header);
return new VariantContext(source, contig, start, stop, alleleMap, genotypes, negLog10PError, filters, attributes, refPadByte);
}
private Map<String, Genotype> decodeGenotypes(final GCFHeader header) {
private GenotypeMap decodeGenotypes(final GCFHeader header) {
if ( genotypes.isEmpty() )
return VariantContext.NO_GENOTYPES;
else {
Map<String, Genotype> map = new TreeMap<String, Genotype>();
GenotypeMap map = GenotypeMap.create();
for ( int i = 0; i < genotypes.size(); i++ ) {
final String sampleName = header.getSample(i);

View File

@ -0,0 +1,66 @@
/*
* Copyright (c) 2011, The Broad Institute
*
* 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.utils.variantcontext;
import java.util.Collection;
import java.util.Map;
import java.util.TreeMap;
/**
*
*/
public class GenotypeMap extends TreeMap<String, Genotype> implements Map<String, Genotype> {
public final static GenotypeMap NO_GENOTYPES = new GenotypeMap();
public static final GenotypeMap create() {
return new GenotypeMap();
}
public static final GenotypeMap create(int nGenotypes) {
return new GenotypeMap();
}
public static final GenotypeMap create(final GenotypeMap genotypes) {
return create(genotypes.values());
}
public static final GenotypeMap create(final Map<String, Genotype> genotypes) {
return create(genotypes.values());
}
public static final GenotypeMap create(final Collection<Genotype> genotypes) {
if ( genotypes == null )
return null; // todo -- really should return an empty map
else {
GenotypeMap genotypeMap = new GenotypeMap();
for ( final Genotype g : genotypes ) {
if ( genotypeMap.containsKey(g.getSampleName() ) )
throw new IllegalArgumentException("Duplicate genotype added to VariantContext: " + g);
genotypeMap.put(g.getSampleName(), g);
}
return genotypeMap;
}
}
}

View File

@ -22,7 +22,7 @@ public class MutableVariantContext extends VariantContext {
super(source, contig, start, stop, alleles, genotypes, negLog10PError, filters, attributes);
}
public MutableVariantContext(String source, String contig, long start, long stop, Collection<Allele> alleles, Map<String, Genotype> genotypes, double negLog10PError, Set<String> filters, Map<String, Object> attributes) {
public MutableVariantContext(String source, String contig, long start, long stop, Collection<Allele> alleles, GenotypeMap genotypes, double negLog10PError, Set<String> filters, Map<String, Object> attributes) {
super(source, contig, start, stop, alleles, genotypes, negLog10PError, filters, attributes);
}
@ -72,7 +72,7 @@ public class MutableVariantContext extends VariantContext {
}
public void clearGenotypes() {
genotypes = new TreeMap<String, Genotype>();
genotypes = GenotypeMap.create();
}
/**
@ -98,7 +98,6 @@ public class MutableVariantContext extends VariantContext {
* @param genotypes
*/
public void addGenotypes(Map<String, Genotype> genotypes) {
for ( Map.Entry<String, Genotype> elt : genotypes.entrySet() ) {
addGenotype(elt.getValue());
}

View File

@ -184,12 +184,12 @@ public class VariantContext implements Feature { // to enable tribble intergrati
final protected List<Allele> alleles;
/** A mapping from sampleName -> genotype objects for all genotypes associated with this context */
protected Map<String, Genotype> genotypes = null;
protected GenotypeMap genotypes = null;
/** Counts for each of the possible Genotype types in this context */
protected int[] genotypeCounts = null;
public final static Map<String, Genotype> NO_GENOTYPES = Collections.unmodifiableMap(new HashMap<String, Genotype>());
public final static GenotypeMap NO_GENOTYPES = GenotypeMap.NO_GENOTYPES;
// a fast cached access point to the ref / alt alleles for biallelic case
private Allele REF = null;
@ -222,7 +222,7 @@ public class VariantContext implements Feature { // to enable tribble intergrati
* @param attributes attributes
* @param referenceBaseForIndel padded reference base
*/
public VariantContext(String source, String contig, long start, long stop, Collection<Allele> alleles, Map<String, Genotype> genotypes, double negLog10PError, Set<String> filters, Map<String, Object> attributes, Byte referenceBaseForIndel) {
public VariantContext(String source, String contig, long start, long stop, Collection<Allele> alleles, GenotypeMap genotypes, double negLog10PError, Set<String> filters, Map<String, Object> attributes, Byte referenceBaseForIndel) {
this(source, contig, start, stop, alleles, genotypes, negLog10PError, filters, attributes, referenceBaseForIndel, false);
}
@ -239,7 +239,7 @@ 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 contig, long start, long stop, Collection<Allele> alleles, Map<String, Genotype> genotypes, double negLog10PError, Set<String> filters, Map<String, Object> attributes) {
public VariantContext(String source, String contig, long start, long stop, Collection<Allele> alleles, GenotypeMap genotypes, double negLog10PError, Set<String> filters, Map<String, Object> attributes) {
this(source, contig, start, stop, alleles, genotypes, negLog10PError, filters, attributes, null, false);
}
@ -278,7 +278,9 @@ public class VariantContext implements Feature { // to enable tribble intergrati
* @param attributes attributes
*/
public VariantContext(String source, String contig, long start, long stop, Collection<Allele> alleles, Collection<Genotype> genotypes, double negLog10PError, Set<String> filters, Map<String, Object> attributes) {
this(source, contig, start, stop, alleles, genotypes != null ? genotypeCollectionToMap(new TreeMap<String, Genotype>(), genotypes) : null, negLog10PError, filters, attributes, null, false);
this(source, contig, start, stop, alleles,
GenotypeMap.create(genotypes),
negLog10PError, filters, attributes, null, false);
}
/**
@ -333,7 +335,7 @@ public class VariantContext implements Feature { // to enable tribble intergrati
* @param genotypesAreUnparsed true if the genotypes have not yet been parsed
*/
private VariantContext(String source, String contig, long start, long stop,
Collection<Allele> alleles, Map<String, Genotype> genotypes,
Collection<Allele> alleles, GenotypeMap genotypes,
double negLog10PError, Set<String> filters, Map<String, Object> attributes,
Byte referenceBaseForIndel, boolean genotypesAreUnparsed) {
if ( contig == null ) { throw new IllegalArgumentException("Contig cannot be null"); }
@ -357,9 +359,8 @@ public class VariantContext implements Feature { // to enable tribble intergrati
// we need to make this a LinkedHashSet in case the user prefers a given ordering of alleles
this.alleles = makeAlleles(alleles);
if ( genotypes == null ) { genotypes = NO_GENOTYPES; }
this.genotypes = Collections.unmodifiableMap(genotypes);
this.genotypes = genotypes;
// cache the REF and ALT alleles
int nAlleles = alleles.size();
@ -382,7 +383,7 @@ public class VariantContext implements Feature { // to enable tribble intergrati
//
// ---------------------------------------------------------------------------------------------------------
public static VariantContext modifyGenotypes(VariantContext vc, Map<String, Genotype> genotypes) {
public static VariantContext modifyGenotypes(VariantContext vc, GenotypeMap genotypes) {
return new VariantContext(vc.getSource(), vc.getChr(), vc.getStart(), vc.getEnd(), vc.getAlleles(), genotypes, vc.getNegLog10PError(), vc.filtersWereApplied() ? vc.getFilters() : null, new HashMap<String, Object>(vc.getAttributes()), vc.getReferenceBaseForIndel(), false);
}
@ -447,7 +448,7 @@ public class VariantContext implements Feature { // to enable tribble intergrati
*/
public VariantContext subContextFromGenotypes(Collection<Genotype> genotypes, Collection<Allele> alleles) {
return new VariantContext(getSource(), contig, start, stop, alleles,
genotypes != null ? genotypeCollectionToMap(new TreeMap<String, Genotype>(), genotypes) : null,
GenotypeMap.create(genotypes),
getNegLog10PError(),
filtersWereApplied() ? getFilters() : null,
getAttributes(),
@ -879,7 +880,7 @@ public class VariantContext implements Feature { // to enable tribble intergrati
/**
* @return set of all Genotypes associated with this context
*/
public Map<String, Genotype> getGenotypes() {
public GenotypeMap getGenotypes() {
loadGenotypes();
return genotypes;
}
@ -898,7 +899,7 @@ public class VariantContext implements Feature { // to enable tribble intergrati
* @return
* @throws IllegalArgumentException if sampleName isn't bound to a genotype
*/
public Map<String, Genotype> getGenotypes(String sampleName) {
public GenotypeMap getGenotypes(String sampleName) {
return getGenotypes(Arrays.asList(sampleName));
}
@ -910,8 +911,8 @@ public class VariantContext implements Feature { // to enable tribble intergrati
* @return
* @throws IllegalArgumentException if sampleName isn't bound to a genotype
*/
public Map<String, Genotype> getGenotypes(Collection<String> sampleNames) {
HashMap<String, Genotype> map = new HashMap<String, Genotype>();
public GenotypeMap getGenotypes(Collection<String> sampleNames) {
GenotypeMap map = GenotypeMap.create(sampleNames.size());
for ( String name : sampleNames ) {
if ( map.containsKey(name) ) throw new IllegalArgumentException("Duplicate names detected in requested samples " + sampleNames);
@ -1402,16 +1403,6 @@ public class VariantContext implements Feature { // to enable tribble intergrati
return alleleList;
}
public static Map<String, Genotype> genotypeCollectionToMap(Map<String, Genotype> dest, Collection<Genotype> genotypes) {
for ( Genotype g : genotypes ) {
if ( dest.containsKey(g.getSampleName() ) )
throw new IllegalArgumentException("Duplicate genotype added to VariantContext: " + g);
dest.put(g.getSampleName(), g);
}
return dest;
}
// ---------------------------------------------------------------------------------------------------------
//
// tribble integration routines -- not for public consumption
@ -1464,9 +1455,8 @@ public class VariantContext implements Feature { // to enable tribble intergrati
Byte refByte = inputVC.getReferenceBaseForIndel();
List<Allele> alleles = new ArrayList<Allele>();
Map<String, Genotype> genotypes = new TreeMap<String, Genotype>();
Map<String, Genotype> inputGenotypes = inputVC.getGenotypes();
GenotypeMap genotypes = GenotypeMap.create();
GenotypeMap inputGenotypes = inputVC.getGenotypes();
for (Allele a : inputVC.getAlleles()) {
// get bases for current allele and create a new one with trimmed bases

View File

@ -70,7 +70,7 @@ public class VariantContextUtils {
* @return VariantContext object
*/
public static VariantContext toVC(String name, GenomeLoc loc, Collection<Allele> alleles, Collection<Genotype> genotypes, double negLog10PError, Set<String> filters, Map<String, Object> attributes) {
return new VariantContext(name, loc.getContig(), loc.getStart(), loc.getStop(), alleles, genotypes != null ? VariantContext.genotypeCollectionToMap(new TreeMap<String, Genotype>(), genotypes) : null, negLog10PError, filters, attributes);
return new VariantContext(name, loc.getContig(), loc.getStart(), loc.getStop(), alleles, GenotypeMap.create(genotypes), negLog10PError, filters, attributes);
}
/**
@ -404,7 +404,7 @@ public class VariantContextUtils {
*/
public static VariantContext masterMerge(Collection<VariantContext> unsortedVCs, String masterName) {
VariantContext master = findMaster(unsortedVCs, masterName);
Map<String, Genotype> genotypes = master.getGenotypes();
GenotypeMap genotypes = master.getGenotypes();
for (Genotype g : genotypes.values()) {
genotypes.put(g.getSampleName(), new MutableGenotype(g));
}
@ -526,7 +526,7 @@ public class VariantContextUtils {
final Map<String, Object> attributesWithMaxAC = new TreeMap<String, Object>();
double negLog10PError = -1;
VariantContext vcWithMaxAC = null;
Map<String, Genotype> genotypes = new TreeMap<String, Genotype>();
GenotypeMap genotypes = GenotypeMap.create();
// counting the number of filtered and variant VCs
int nFiltered = 0;
@ -716,7 +716,7 @@ public class VariantContextUtils {
// nothing to do if we don't need to trim bases
if (trimVC) {
List<Allele> alleles = new ArrayList<Allele>();
Map<String, Genotype> genotypes = new TreeMap<String, Genotype>();
GenotypeMap genotypes = GenotypeMap.create();
// set the reference base for indels in the attributes
Map<String,Object> attributes = new TreeMap<String,Object>(inputVC.getAttributes());
@ -770,8 +770,8 @@ public class VariantContextUtils {
return inputVC;
}
public static Map<String, Genotype> stripPLs(Map<String, Genotype> genotypes) {
Map<String, Genotype> newGs = new HashMap<String, Genotype>(genotypes.size());
public static GenotypeMap stripPLs(GenotypeMap genotypes) {
GenotypeMap newGs = GenotypeMap.create(genotypes.size());
for ( Map.Entry<String, Genotype> g : genotypes.entrySet() ) {
newGs.put(g.getKey(), g.getValue().hasLikelihoods() ? removePLs(g.getValue()) : g.getValue());
@ -951,7 +951,7 @@ public class VariantContextUtils {
}
}
private static void mergeGenotypes(Map<String, Genotype> mergedGenotypes, VariantContext oneVC, AlleleMapper alleleMapping, boolean uniqifySamples) {
private static void mergeGenotypes(GenotypeMap mergedGenotypes, VariantContext oneVC, AlleleMapper alleleMapping, boolean uniqifySamples) {
for ( Genotype g : oneVC.getGenotypes().values() ) {
String name = mergedSampleName(oneVC.getSource(), g.getSampleName(), uniqifySamples);
if ( ! mergedGenotypes.containsKey(name) ) {
@ -992,7 +992,7 @@ public class VariantContextUtils {
}
// create new Genotype objects
Map<String, Genotype> newGenotypes = new HashMap<String, Genotype>(vc.getNSamples());
GenotypeMap newGenotypes = GenotypeMap.create(vc.getNSamples());
for ( Map.Entry<String, Genotype> genotype : vc.getGenotypes().entrySet() ) {
List<Allele> newAlleles = new ArrayList<Allele>();
for ( Allele allele : genotype.getValue().getAlleles() ) {
@ -1012,7 +1012,7 @@ public class VariantContextUtils {
if ( allowedAttributes == null )
return vc;
Map<String, Genotype> newGenotypes = new HashMap<String, Genotype>(vc.getNSamples());
GenotypeMap newGenotypes = GenotypeMap.create(vc.getNSamples());
for ( Map.Entry<String, Genotype> genotype : vc.getGenotypes().entrySet() ) {
Map<String, Object> attrs = new HashMap<String, Object>();
for ( Map.Entry<String, Object> attr : genotype.getValue().getAttributes().entrySet() ) {
@ -1091,7 +1091,7 @@ public class VariantContextUtils {
}
MergedAllelesData mergeData = new MergedAllelesData(intermediateBases, vc1, vc2); // ensures that the reference allele is added
Map<String, Genotype> mergedGenotypes = new HashMap<String, Genotype>();
GenotypeMap mergedGenotypes = GenotypeMap.create();
for (Map.Entry<String, Genotype> gt1Entry : vc1.getGenotypes().entrySet()) {
String sample = gt1Entry.getKey();
Genotype gt1 = gt1Entry.getValue();

View File

@ -32,7 +32,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest {
public void testHasAnnotsAsking1() {
WalkerTestSpec spec = new WalkerTestSpec(
baseTestString() + " -G Standard --variant:VCF3 " + validationDataLocation + "vcfexample2.vcf -I " + validationDataLocation + "low_coverage_CEU.chr1.10k-11k.bam -L 1:10,020,000-10,021,000", 1,
Arrays.asList("8e7de435105499cd71ffc099e268a83e"));
Arrays.asList("a6687f0d3830fa6e518b7874857f6f70"));
executeTest("test file has annotations, asking for annotations, #1", spec);
}
@ -64,7 +64,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest {
public void testNoAnnotsAsking1() {
WalkerTestSpec spec = new WalkerTestSpec(
baseTestString() + " -G Standard --variant:VCF3 " + validationDataLocation + "vcfexample2empty.vcf -I " + validationDataLocation + "low_coverage_CEU.chr1.10k-11k.bam -L 1:10,020,000-10,021,000", 1,
Arrays.asList("fd1ffb669800c2e07df1e2719aa38e49"));
Arrays.asList("b59508cf66da6b2de280a79b3b7d85b1"));
executeTest("test file doesn't have annotations, asking for annotations, #1", spec);
}
@ -80,7 +80,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest {
public void testExcludeAnnotations() {
WalkerTestSpec spec = new WalkerTestSpec(
baseTestString() + " -G Standard -XA FisherStrand -XA ReadPosRankSumTest --variant:VCF3 " + validationDataLocation + "vcfexample2empty.vcf -I " + validationDataLocation + "low_coverage_CEU.chr1.10k-11k.bam -L 1:10,020,000-10,021,000", 1,
Arrays.asList("b49fe03aa4b675db80a9db38a3552c95"));
Arrays.asList("b8e18b23568e4d2381f51d4430213040"));
executeTest("test exclude annotations", spec);
}

View File

@ -30,20 +30,23 @@ public class UnifiedGenotyperIntegrationTest extends WalkerTest {
public void testMultiSamplePilot1() {
WalkerTest.WalkerTestSpec spec = new WalkerTest.WalkerTestSpec(
baseCommand + " -I " + validationDataLocation + "low_coverage_CEU.chr1.10k-11k.bam -o %s -L 1:10,022,000-10,025,000", 1,
Arrays.asList("b27939251539439a382538e507e03507"));
Arrays.asList("c93def488de12fb3b8199e001b7a24a8"));
executeTest("test MultiSample Pilot1", spec);
}
@Test
public void testWithAllelesPassedIn() {
public void testWithAllelesPassedIn1() {
WalkerTest.WalkerTestSpec spec1 = new WalkerTest.WalkerTestSpec(
baseCommand + " --genotyping_mode GENOTYPE_GIVEN_ALLELES -alleles " + validationDataLocation + "allelesForUG.vcf -I " + validationDataLocation + "pilot2_daughters.chr20.10k-11k.bam -o %s -L 20:10,000,000-10,025,000", 1,
Arrays.asList("8de2602679ffc92388da0b6cb4325ef6"));
Arrays.asList("cef4bd72cbbe72f28e9c72e2818b4708"));
executeTest("test MultiSample Pilot2 with alleles passed in", spec1);
}
@Test
public void testWithAllelesPassedIn2() {
WalkerTest.WalkerTestSpec spec2 = new WalkerTest.WalkerTestSpec(
baseCommand + " --output_mode EMIT_ALL_SITES --genotyping_mode GENOTYPE_GIVEN_ALLELES -alleles " + validationDataLocation + "allelesForUG.vcf -I " + validationDataLocation + "pilot2_daughters.chr20.10k-11k.bam -o %s -L 20:10,000,000-10,025,000", 1,
Arrays.asList("6458f3b8fe4954e2ffc2af972aaab19e"));
Arrays.asList("14f5cdfc6818cbba600cbdf5fe285275"));
executeTest("test MultiSample Pilot2 with alleles passed in and emitting all sites", spec2);
}
@ -261,7 +264,7 @@ public class UnifiedGenotyperIntegrationTest extends WalkerTest {
WalkerTest.WalkerTestSpec spec1 = new WalkerTest.WalkerTestSpec(
baseCommandIndels + " --genotyping_mode GENOTYPE_GIVEN_ALLELES -alleles " + validationDataLocation + "indelAllelesForUG.vcf -I " + validationDataLocation +
"pilot2_daughters.chr20.10k-11k.bam -o %s -L 20:10,000,000-10,100,000", 1,
Arrays.asList("118918f2e9e56a3cfc5ccb2856d529c8"));
Arrays.asList("81a1035e59cd883e413e62d34265c1a2"));
executeTest("test MultiSample Pilot2 indels with alleles passed in", spec1);
}
@ -271,7 +274,7 @@ public class UnifiedGenotyperIntegrationTest extends WalkerTest {
baseCommandIndels + " --output_mode EMIT_ALL_SITES --genotyping_mode GENOTYPE_GIVEN_ALLELES -alleles "
+ validationDataLocation + "indelAllelesForUG.vcf -I " + validationDataLocation +
"pilot2_daughters.chr20.10k-11k.bam -o %s -L 20:10,000,000-10,100,000", 1,
Arrays.asList("a20799237accd52c1b8c2ac096309c8f"));
Arrays.asList("102b7d915f21dff0a9b6ea64c4c7d409"));
executeTest("test MultiSample Pilot2 indels with alleles passed in and emitting all sites", spec2);
}
@ -281,7 +284,7 @@ public class UnifiedGenotyperIntegrationTest extends WalkerTest {
WalkerTest.WalkerTestSpec spec3 = new WalkerTest.WalkerTestSpec(
baseCommandIndels + " --genotyping_mode GENOTYPE_GIVEN_ALLELES -alleles " + validationDataLocation + "ALL.wgs.union_v2.20101123.indels.sites.vcf -I " + validationDataLocation +
"pilot2_daughters.chr20.10k-11k.bam -o %s -L 20:10,000,000-10,080,000", 1,
Arrays.asList("18ef8181157b4ac3eb8492f538467f92"));
Arrays.asList("5900344f97bbac35d147a0a7c2bf1d0c"));
executeTest("test MultiSample Pilot2 indels with complicated records", spec3);
}
@ -290,7 +293,7 @@ public class UnifiedGenotyperIntegrationTest extends WalkerTest {
WalkerTest.WalkerTestSpec spec4 = new WalkerTest.WalkerTestSpec(
baseCommandIndelsb37 + " --genotyping_mode GENOTYPE_GIVEN_ALLELES -alleles " + validationDataLocation + "ALL.wgs.union_v2_chr20_100_110K.20101123.indels.sites.vcf -I " + validationDataLocation +
"phase1_GBR_realigned.chr20.100K-110K.bam -o %s -L 20:100,000-110,000", 1,
Arrays.asList("ad884e511a751b05e64db5314314365a"));
Arrays.asList("45e7bf21cd6358921626404e7ae76c69"));
executeTest("test MultiSample 1000G Phase1 indels with complicated records emitting all sites", spec4);
}

View File

@ -4,6 +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.GenotypeMap;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import org.broadinstitute.sting.utils.codecs.vcf.*;
import org.broadinstitute.sting.utils.exceptions.UserException;
@ -121,7 +122,7 @@ public class VCFWriterUnitTest extends BaseTest {
List<Allele> alleles = new ArrayList<Allele>();
Set<String> filters = null;
Map<String, Object> attributes = new HashMap<String,Object>();
Map<String, Genotype> genotypes = new HashMap<String,Genotype>();
GenotypeMap genotypes = GenotypeMap.create();
alleles.add(Allele.create("-",true));
alleles.add(Allele.create("CC",false));

View File

@ -99,8 +99,7 @@ public class VariantContextUtilsUnitTest extends BaseTest {
int start = 10;
int stop = start; // alleles.contains(ATC) ? start + 3 : start;
return new VariantContext(source, "1", start, stop, alleles,
genotypes == null ? null : VariantContext.genotypeCollectionToMap(new TreeMap<String, Genotype>(), genotypes),
1.0, filters, null, Cref.getBases()[0]);
GenotypeMap.create(genotypes), 1.0, filters, null, Cref.getBases()[0]);
}
// --------------------------------------------------------------------------------