Change interface to getNegLog10PError to getLog10PError

This commit is contained in:
Mark DePristo 2011-11-18 21:07:30 -05:00
parent c7f2d5c7c7
commit 6cf315e17b
35 changed files with 193 additions and 226 deletions

View File

@ -9,7 +9,6 @@ import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
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.variantcontext.*;
import java.util.*;
@ -193,9 +192,12 @@ public class VariantContextAdaptors {
return null; // we weren't given enough reference context to create the VariantContext
Byte refBaseForIndel = new Byte(ref.getBases()[index]);
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;
final VariantContextBuilder builder = new VariantContextBuilder();
builder.source(name).id(dbsnp.getRsID());
builder.loc(dbsnp.getChr(), dbsnp.getStart() - (sawNullAllele ? 1 : 0), dbsnp.getEnd() - (refAllele.isNull() ? 1 : 0));
builder.alleles(alleles);
builder.referenceBaseForIndel(refBaseForIndel);
return builder.make();
} else
return null; // can't handle anything else
}
@ -255,7 +257,7 @@ public class VariantContextAdaptors {
genotypes.add(call);
alleles.add(refAllele);
GenomeLoc loc = ref.getGenomeLocParser().createGenomeLoc(geli.getChr(),geli.getStart());
return new VariantContextBuilder(name, loc.getContig(), loc.getStart(), loc.getStop(), alleles).genotypes(genotypes).negLog10PError(geli.getLODBestToReference()).attributes(attributes).make();
return new VariantContextBuilder(name, loc.getContig(), loc.getStart(), loc.getStop(), alleles).genotypes(genotypes).log10PError(-1 * geli.getLODBestToReference()).attributes(attributes).make();
} else
return null; // can't handle anything else
}
@ -349,7 +351,7 @@ public class VariantContextAdaptors {
long end = hapmap.getEnd();
if ( deletionLength > 0 )
end += deletionLength;
VariantContext vc = new VariantContext(name, hapmap.getName(), hapmap.getChr(), hapmap.getStart(), end, alleles, genotypes, VariantContext.NO_NEG_LOG_10PERROR, null, null, refBaseForIndel);
VariantContext vc = new VariantContextBuilder(name, hapmap.getChr(), hapmap.getStart(), end, alleles).id(hapmap.getName()).genotypes(genotypes).referenceBaseForIndel(refBaseForIndel).make();
return vc;
}
}

View File

@ -85,8 +85,8 @@ public class AlleleBalance extends InfoFieldAnnotation {
continue;
// weight the allele balance by genotype quality so that e.g. mis-called homs don't affect the ratio too much
ratio += genotype.getNegLog10PError() * ((double)refCount / (double)(refCount + altCount));
totalWeights += genotype.getNegLog10PError();
ratio += genotype.getLog10PError() * ((double)refCount / (double)(refCount + altCount));
totalWeights += genotype.getLog10PError();
} else if ( vc.isIndel() && context.hasExtendedEventPileup() ) {
final ReadBackedExtendedEventPileup indelPileup = context.getExtendedEventPileup();
if ( indelPileup == null ) {

View File

@ -27,7 +27,7 @@ public class HardyWeinberg extends InfoFieldAnnotation implements WorkInProgress
private static final int MIN_SAMPLES = 10;
private static final int MIN_GENOTYPE_QUALITY = 10;
private static final int MIN_NEG_LOG10_PERROR = MIN_GENOTYPE_QUALITY / 10;
private static final int MIN_LOG10_PERROR = MIN_GENOTYPE_QUALITY / 10;
public Map<String, Object> annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
@ -46,7 +46,7 @@ public class HardyWeinberg extends InfoFieldAnnotation implements WorkInProgress
// Right now we just ignore genotypes that are not confident, but this throws off
// our HW ratios. More analysis is needed to determine the right thing to do when
// the genotyper cannot decide whether a given sample is het or hom var.
if ( g.getNegLog10PError() < MIN_NEG_LOG10_PERROR )
if ( g.getLog10PError() > MIN_LOG10_PERROR )
continue;
if ( g.isHomRef() )

View File

@ -51,7 +51,7 @@ public class QualByDepth extends InfoFieldAnnotation implements StandardAnnotati
if ( depth == 0 )
return null;
double QD = 10.0 * vc.getNegLog10PError() / (double)depth;
double QD = -10.0 * vc.getLog10PError() / (double)depth;
Map<String, Object> map = new HashMap<String, Object>();
map.put(getKeyNames().get(0), String.format("%.2f", QD));

View File

@ -244,7 +244,7 @@ public class VariantAnnotatorEngine {
if ( result != null )
genotypeAnnotations.putAll(result);
}
genotypes.add(new Genotype(genotype.getSampleName(), genotype.getAlleles(), genotype.getNegLog10PError(), genotype.getFilters(), genotypeAnnotations, genotype.isPhased()));
genotypes.add(new Genotype(genotype.getSampleName(), genotype.getAlleles(), genotype.getLog10PError(), genotype.getFilters(), genotypeAnnotations, genotype.isPhased()));
}
return genotypes;

View File

@ -331,18 +331,16 @@ public class BeagleOutputToVCFWalker extends RodWalker<Integer, Integer> {
genotypes.add(imputedGenotype);
}
VariantContext filteredVC;
if ( beagleVarCounts > 0 || DONT_FILTER_MONOMORPHIC_SITES )
filteredVC = new VariantContext("outputvcf", vc_input.getID(), vc_input.getChr(), vc_input.getStart(), vc_input.getEnd(), vc_input.getAlleles(), genotypes, vc_input.getNegLog10PError(), vc_input.filtersWereApplied() ? vc_input.getFilters() : null, vc_input.getAttributes());
else {
final VariantContextBuilder builder = new VariantContextBuilder(vc_input).source("outputvcf").genotypes(genotypes);
if ( ! ( beagleVarCounts > 0 || DONT_FILTER_MONOMORPHIC_SITES ) ) {
Set<String> removedFilters = vc_input.filtersWereApplied() ? new HashSet<String>(vc_input.getFilters()) : new HashSet<String>(1);
removedFilters.add(String.format("BGL_RM_WAS_%s",vc_input.getAlternateAllele(0)));
filteredVC = new VariantContext("outputvcf", vc_input.getID(), vc_input.getChr(), vc_input.getStart(), vc_input.getEnd(), new HashSet<Allele>(Arrays.asList(vc_input.getReference())), genotypes, vc_input.getNegLog10PError(), removedFilters, vc_input.getAttributes());
builder.alleles(new HashSet<Allele>(Arrays.asList(vc_input.getReference()))).filters(removedFilters);
}
HashMap<String, Object> attributes = new HashMap<String, Object>(filteredVC.getAttributes());
HashMap<String, Object> attributes = new HashMap<String, Object>(vc_input.getAttributes());
// re-compute chromosome counts
VariantContextUtils.calculateChromosomeCounts(filteredVC, attributes, false);
VariantContextUtils.calculateChromosomeCounts(vc_input, attributes, false);
// Get Hapmap AC and AF
if (vc_comp != null) {
@ -356,13 +354,11 @@ public class BeagleOutputToVCFWalker extends RodWalker<Integer, Integer> {
if( !beagleR2Feature.getR2value().equals(Double.NaN) ) {
attributes.put("R2", beagleR2Feature.getR2value().toString() );
}
builder.attributes(attributes);
vcfWriter.add(new VariantContextBuilder(filteredVC).attributes(attributes).make());
vcfWriter.add(builder.make());
return 1;
}
public Integer reduceInit() {

View File

@ -99,7 +99,7 @@ public class VCFDiffableReader implements DiffableReader {
vcRoot.add("ID", vc.getID());
vcRoot.add("REF", vc.getReference());
vcRoot.add("ALT", vc.getAlternateAlleles());
vcRoot.add("QUAL", vc.hasNegLog10PError() ? vc.getNegLog10PError() * 10 : VCFConstants.MISSING_VALUE_v4);
vcRoot.add("QUAL", vc.hasLog10PError() ? vc.getLog10PError() * -10 : VCFConstants.MISSING_VALUE_v4);
vcRoot.add("FILTER", vc.getFilters());
// add info fields
@ -111,7 +111,7 @@ public class VCFDiffableReader implements DiffableReader {
for (Genotype g : vc.getGenotypes() ) {
DiffNode gRoot = DiffNode.empty(g.getSampleName(), vcRoot);
gRoot.add("GT", g.getGenotypeString());
gRoot.add("GQ", g.hasNegLog10PError() ? g.getNegLog10PError() * 10 : VCFConstants.MISSING_VALUE_v4 );
gRoot.add("GQ", g.hasLog10PError() ? g.getLog10PError() * -10 : VCFConstants.MISSING_VALUE_v4 );
for (Map.Entry<String, Object> attribute : g.getAttributes().entrySet()) {
if ( ! attribute.getKey().startsWith("_") )

View File

@ -277,14 +277,12 @@ public class VariantFiltrationWalker extends RodWalker<Integer, Integer> {
if ( context == null )
return;
VariantContext vc = context.getVariantContext();
final VariantContext vc = context.getVariantContext();
final VariantContextBuilder builder = new VariantContextBuilder(vc);
// make new Genotypes based on filters
GenotypesContext genotypes;
if ( genotypeFilterExps.size() == 0 ) {
genotypes = null;
} else {
genotypes = GenotypesContext.create(vc.getGenotypes().size());
if ( genotypeFilterExps.size() > 0 ) {
GenotypesContext genotypes = GenotypesContext.create(vc.getGenotypes().size());
// for each genotype, check filters then create a new object
for ( final Genotype g : vc.getGenotypes() ) {
@ -295,11 +293,13 @@ public class VariantFiltrationWalker extends RodWalker<Integer, Integer> {
if ( VariantContextUtils.match(vc, g, exp) )
filters.add(exp.name);
}
genotypes.add(new Genotype(g.getSampleName(), g.getAlleles(), g.getNegLog10PError(), filters, g.getAttributes(), g.isPhased()));
genotypes.add(new Genotype(g.getSampleName(), g.getAlleles(), g.getLog10PError(), filters, g.getAttributes(), g.isPhased()));
} else {
genotypes.add(g);
}
}
builder.genotypes(genotypes);
}
// make a new variant context based on filters
@ -319,14 +319,9 @@ public class VariantFiltrationWalker extends RodWalker<Integer, Integer> {
filters.add(exp.name);
}
}
builder.filters(filters);
VariantContext filteredVC;
if ( genotypes == null )
filteredVC = new VariantContextBuilder(vc).filters(filters).make();
else
filteredVC = new VariantContext(vc.getSource(), vc.getID(), vc.getChr(), vc.getStart(), vc.getEnd(), vc.getAlleles(), genotypes, vc.getNegLog10PError(), filters, vc.getAttributes());
writer.add(filteredVC);
writer.add(builder.make());
}
public Integer reduce(Integer value, Integer sum) {

View File

@ -431,7 +431,7 @@ public class ExactAFCalculationModel extends AlleleFrequencyCalculationModel {
ArrayList<Allele> myAlleles = new ArrayList<Allele>();
double qual = Genotype.NO_NEG_LOG_10PERROR;
double qual = Genotype.NO_LOG10_PERROR;
myAlleles.add(Allele.NO_CALL);
myAlleles.add(Allele.NO_CALL);
//System.out.println(myAlleles.toString());

View File

@ -137,7 +137,8 @@ public class UGCallVariants extends RodWalker<VariantCallContext, Integer> {
VariantContext vc = VCs.get(0);
throw new UserException("There is no ALT allele in any of the VCF records passed in at " + vc.getChr() + ":" + vc.getStart());
}
return new VariantContext("VCwithGLs", VCFConstants.EMPTY_ID_FIELD, variantVC.getChr(), variantVC.getStart(), variantVC.getEnd(), variantVC.getAlleles(), genotypes, VariantContext.NO_NEG_LOG_10PERROR, null, null);
return new VariantContextBuilder(variantVC).source("VCwithGLs").genotypes(genotypes).make();
}
private static GenotypesContext getGenotypesWithGLs(GenotypesContext genotypes) {

View File

@ -280,22 +280,13 @@ public class UnifiedGenotyperEngine {
attributes.put(VCFConstants.DEPTH_KEY, GL.getDepth());
attributes.put(VCFConstants.PHRED_GENOTYPE_LIKELIHOODS_KEY, likelihoods);
genotypes.add(new Genotype(GL.getSample(), noCall, Genotype.NO_NEG_LOG_10PERROR, null, attributes, false));
genotypes.add(new Genotype(GL.getSample(), noCall, Genotype.NO_LOG10_PERROR, null, attributes, false));
}
GenomeLoc loc = refContext.getLocus();
int endLoc = calculateEndPos(alleles, refAllele, loc);
return new VariantContext("UG_call",
VCFConstants.EMPTY_ID_FIELD, loc.getContig(),
loc.getStart(),
endLoc,
alleles,
genotypes,
VariantContext.NO_NEG_LOG_10PERROR,
null,
null,
refContext.getBase());
return new VariantContextBuilder("UG_call", loc.getContig(), loc.getStart(), endLoc, alleles).genotypes(genotypes).referenceBaseForIndel(refContext.getBase()).make();
}
// private method called by both UnifiedGenotyper and UGCallVariants entry points into the engine
@ -419,8 +410,14 @@ public class UnifiedGenotyperEngine {
myAlleles = new HashSet<Allele>(1);
myAlleles.add(vc.getReference());
}
VariantContext vcCall = new VariantContext("UG_call", VCFConstants.EMPTY_ID_FIELD, loc.getContig(), loc.getStart(), endLoc,
myAlleles, genotypes, phredScaledConfidence/10.0, passesCallThreshold(phredScaledConfidence) ? null : filter, attributes, refContext.getBase());
VariantContextBuilder builder = new VariantContextBuilder("UG_call", loc.getContig(), loc.getStart(), endLoc, myAlleles);
builder.genotypes(genotypes);
builder.log10PError(phredScaledConfidence/-10.0);
if ( ! passesCallThreshold(phredScaledConfidence) ) builder.filters(filter);
builder.attributes(attributes);
builder.referenceBaseForIndel(refContext.getBase());
VariantContext vcCall = builder.make();
if ( annotationEngine != null ) {
// Note: we want to use the *unfiltered* and *unBAQed* context for the annotations
@ -503,10 +500,15 @@ public class UnifiedGenotyperEngine {
myAlleles = new HashSet<Allele>(1);
myAlleles.add(vc.getReference());
}
VariantContext vcCall = new VariantContext("UG_call", VCFConstants.EMPTY_ID_FIELD, loc.getContig(), loc.getStart(), endLoc,
myAlleles, genotypes, phredScaledConfidence/10.0, passesCallThreshold(phredScaledConfidence) ? null : filter, attributes, vc.getReferenceBaseForIndel());
return new VariantCallContext(vcCall, confidentlyCalled(phredScaledConfidence, PofF));
VariantContextBuilder builder = new VariantContextBuilder("UG_call", loc.getContig(), loc.getStart(), endLoc, myAlleles);
builder.genotypes(genotypes);
builder.log10PError(phredScaledConfidence/-10.0);
if ( ! passesCallThreshold(phredScaledConfidence) ) builder.filters(filter);
builder.attributes(attributes);
builder.referenceBaseForIndel(vc.getReferenceBaseForIndel());
return new VariantCallContext(builder.make(), confidentlyCalled(phredScaledConfidence, PofF));
}
private int calculateEndPos(Collection<Allele> alleles, Allele refAllele, GenomeLoc loc) {

View File

@ -58,10 +58,7 @@ import org.broadinstitute.sting.utils.interval.IntervalUtils;
import org.broadinstitute.sting.utils.interval.OverlappingIntervalIterator;
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.GenotypesContext;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import org.broadinstitute.sting.utils.variantcontext.*;
import java.io.*;
import java.util.*;
@ -1064,9 +1061,9 @@ public class SomaticIndelDetectorWalker extends ReadWalker<Integer,Integer> {
Map<String,Object> attrs = call.makeStatsAttributes(null);
if ( call.isCall() ) // we made a call - put actual het genotype here:
genotypes.add(new Genotype(sample,alleles,Genotype.NO_NEG_LOG_10PERROR,null,attrs,false));
genotypes.add(new Genotype(sample,alleles,Genotype.NO_LOG10_PERROR,null,attrs,false));
else // no call: genotype is ref/ref (but alleles still contain the alt if we observed anything at all)
genotypes.add(new Genotype(sample, homref_alleles,Genotype.NO_NEG_LOG_10PERROR,null,attrs,false));
genotypes.add(new Genotype(sample, homref_alleles,Genotype.NO_LOG10_PERROR,null,attrs,false));
}
Set<String> filters = null;
@ -1074,8 +1071,8 @@ public class SomaticIndelDetectorWalker extends ReadWalker<Integer,Integer> {
filters = new HashSet<String>();
filters.add("NoCall");
}
VariantContext vc = new VariantContext("IGv2_Indel_call", VCFConstants.EMPTY_ID_FIELD, refName, start, stop, alleles, genotypes,
-1.0 /* log error */, filters, null, refBases[(int)start-1]);
VariantContext vc = new VariantContextBuilder("IGv2_Indel_call", refName, start, stop, alleles)
.genotypes(genotypes).filters(filters).referenceBaseForIndel(refBases[(int)start-1]).make();
vcf.add(vc);
}
@ -1150,11 +1147,11 @@ public class SomaticIndelDetectorWalker extends ReadWalker<Integer,Integer> {
GenotypesContext genotypes = GenotypesContext.create();
for ( String sample : normalSamples ) {
genotypes.add(new Genotype(sample, homRefN ? homRefAlleles : alleles,Genotype.NO_NEG_LOG_10PERROR,null,attrsNormal,false));
genotypes.add(new Genotype(sample, homRefN ? homRefAlleles : alleles,Genotype.NO_LOG10_PERROR,null,attrsNormal,false));
}
for ( String sample : tumorSamples ) {
genotypes.add(new Genotype(sample, homRefT ? homRefAlleles : alleles,Genotype.NO_NEG_LOG_10PERROR,null,attrsTumor,false) );
genotypes.add(new Genotype(sample, homRefT ? homRefAlleles : alleles,Genotype.NO_LOG10_PERROR,null,attrsTumor,false) );
}
Set<String> filters = null;
@ -1171,8 +1168,8 @@ public class SomaticIndelDetectorWalker extends ReadWalker<Integer,Integer> {
filters.add("TCov");
}
VariantContext vc = new VariantContext("IGv2_Indel_call", VCFConstants.EMPTY_ID_FIELD, refName, start, stop, alleles, genotypes,
-1.0 /* log error */, filters, attrs, refBases[(int)start-1]);
VariantContext vc = new VariantContextBuilder("IGv2_Indel_call", refName, start, stop, alleles)
.genotypes(genotypes).filters(filters).attributes(attrs).referenceBaseForIndel(refBases[(int)start-1]).make();
vcf.add(vc);
}

View File

@ -132,17 +132,17 @@ public class PhaseByTransmission extends RodWalker<Integer, Integer> {
List<Allele> homRefAlleles = new ArrayList<Allele>();
homRefAlleles.add(refAllele);
homRefAlleles.add(refAllele);
Genotype homRef = new Genotype(g.getSampleName(), homRefAlleles, g.getNegLog10PError(), null, g.getAttributes(), false);
Genotype homRef = new Genotype(g.getSampleName(), homRefAlleles, g.getLog10PError(), null, g.getAttributes(), false);
List<Allele> hetAlleles = new ArrayList<Allele>();
hetAlleles.add(refAllele);
hetAlleles.add(altAllele);
Genotype het = new Genotype(g.getSampleName(), hetAlleles, g.getNegLog10PError(), null, g.getAttributes(), false);
Genotype het = new Genotype(g.getSampleName(), hetAlleles, g.getLog10PError(), null, g.getAttributes(), false);
List<Allele> homVarAlleles = new ArrayList<Allele>();
homVarAlleles.add(altAllele);
homVarAlleles.add(altAllele);
Genotype homVar = new Genotype(g.getSampleName(), homVarAlleles, g.getNegLog10PError(), null, g.getAttributes(), false);
Genotype homVar = new Genotype(g.getSampleName(), homVarAlleles, g.getLog10PError(), null, g.getAttributes(), false);
ArrayList<Genotype> genotypes = new ArrayList<Genotype>();
genotypes.add(homRef);
@ -187,7 +187,7 @@ public class PhaseByTransmission extends RodWalker<Integer, Integer> {
possiblePhasedChildAlleles.add(momAllele);
possiblePhasedChildAlleles.add(dadAllele);
Genotype possiblePhasedChildGenotype = new Genotype(child.getSampleName(), possiblePhasedChildAlleles, child.getNegLog10PError(), child.getFilters(), child.getAttributes(), true);
Genotype possiblePhasedChildGenotype = new Genotype(child.getSampleName(), possiblePhasedChildAlleles, child.getLog10PError(), child.getFilters(), child.getAttributes(), true);
possiblePhasedChildGenotypes.add(possiblePhasedChildGenotype);
}
@ -204,7 +204,7 @@ public class PhaseByTransmission extends RodWalker<Integer, Integer> {
phasedMomAlleles.add(momTransmittedAllele);
phasedMomAlleles.add(momUntransmittedAllele);
Genotype phasedMomGenotype = new Genotype(mom.getSampleName(), phasedMomAlleles, mom.getNegLog10PError(), mom.getFilters(), mom.getAttributes(), true);
Genotype phasedMomGenotype = new Genotype(mom.getSampleName(), phasedMomAlleles, mom.getLog10PError(), mom.getFilters(), mom.getAttributes(), true);
Allele dadTransmittedAllele = phasedChildGenotype.getAllele(1);
Allele dadUntransmittedAllele = dad.getAllele(0) != dadTransmittedAllele ? dad.getAllele(0) : dad.getAllele(1);
@ -213,7 +213,7 @@ public class PhaseByTransmission extends RodWalker<Integer, Integer> {
phasedDadAlleles.add(dadTransmittedAllele);
phasedDadAlleles.add(dadUntransmittedAllele);
Genotype phasedDadGenotype = new Genotype(dad.getSampleName(), phasedDadAlleles, dad.getNegLog10PError(), dad.getFilters(), dad.getAttributes(), true);
Genotype phasedDadGenotype = new Genotype(dad.getSampleName(), phasedDadAlleles, dad.getLog10PError(), dad.getFilters(), dad.getAttributes(), true);
finalGenotypes.add(phasedMomGenotype);
finalGenotypes.add(phasedDadGenotype);

View File

@ -108,7 +108,7 @@ class PhasingUtils {
mergedAllelesForSample.add(mergedAllele);
}
double mergedGQ = Math.max(gt1.getNegLog10PError(), gt2.getNegLog10PError());
double mergedGQ = Math.max(gt1.getLog10PError(), gt2.getLog10PError());
Set<String> mergedGtFilters = new HashSet<String>(); // Since gt1 and gt2 were unfiltered, the Genotype remains unfiltered
Map<String, Object> mergedGtAttribs = new HashMap<String, Object>();
@ -121,7 +121,7 @@ class PhasingUtils {
}
String mergedName = mergeVariantContextNames(vc1.getSource(), vc2.getSource());
double mergedNegLog10PError = Math.max(vc1.getNegLog10PError(), vc2.getNegLog10PError());
double mergedLog10PError = Math.min(vc1.getLog10PError(), vc2.getLog10PError());
Set<String> mergedFilters = new HashSet<String>(); // Since vc1 and vc2 were unfiltered, the merged record remains unfiltered
Map<String, Object> mergedAttribs = mergeVariantContextAttributes(vc1, vc2);
@ -131,7 +131,7 @@ class PhasingUtils {
if ( vc2.hasID() ) mergedIDs.add(vc2.getID());
String mergedID = mergedIDs.isEmpty() ? VCFConstants.EMPTY_ID_FIELD : Utils.join(VCFConstants.ID_FIELD_SEPARATOR, mergedIDs);
VariantContext mergedVc = new VariantContext(mergedName, mergedID, vc1.getChr(), vc1.getStart(), vc2.getEnd(), mergeData.getAllMergedAlleles(), mergedGenotypes, mergedNegLog10PError, mergedFilters, mergedAttribs);
VariantContext mergedVc = new VariantContextBuilder(mergedName, vc1.getChr(), vc1.getStart(), vc2.getEnd(), mergeData.getAllMergedAlleles()).id(mergedID).genotypes(mergedGenotypes).log10PError(mergedLog10PError).filters(mergedFilters).attributes(mergedAttribs).make();
mergedAttribs = new HashMap<String, Object>(mergedVc.getAttributes());
VariantContextUtils.calculateChromosomeCounts(mergedVc, mergedAttribs, true);

View File

@ -361,7 +361,7 @@ public class ReadBackedPhasingWalker extends RodWalker<PhasingStatsAndOutput, Ph
if (isUnfilteredCalledDiploidGenotype(gt)) {
if (gt.isHom()) { // Note that this Genotype may be replaced later to contain the PQ of a downstream het site that was phased relative to a het site lying upstream of this hom site:
// true <-> can trivially phase a hom site relative to ANY previous site:
Genotype phasedGt = new Genotype(gt.getSampleName(), gt.getAlleles(), gt.getNegLog10PError(), gt.getFilters(), gt.getAttributes(), true);
Genotype phasedGt = new Genotype(gt.getSampleName(), gt.getAlleles(), gt.getLog10PError(), gt.getFilters(), gt.getAttributes(), true);
uvc.setGenotype(samp, phasedGt);
}
else if (gt.isHet()) { // Attempt to phase this het genotype relative to the previous het genotype
@ -397,7 +397,7 @@ public class ReadBackedPhasingWalker extends RodWalker<PhasingStatsAndOutput, Ph
ensurePhasing(allelePair, prevAllelePair, pr.haplotype);
Map<String, Object> gtAttribs = new HashMap<String, Object>(gt.getAttributes());
gtAttribs.put(PQ_KEY, pr.phaseQuality);
Genotype phasedGt = new Genotype(gt.getSampleName(), allelePair.getAllelesAsList(), gt.getNegLog10PError(), gt.getFilters(), gtAttribs, genotypesArePhased);
Genotype phasedGt = new Genotype(gt.getSampleName(), allelePair.getAllelesAsList(), gt.getLog10PError(), gt.getFilters(), gtAttribs, genotypesArePhased);
uvc.setGenotype(samp, phasedGt);
}
@ -417,7 +417,7 @@ public class ReadBackedPhasingWalker extends RodWalker<PhasingStatsAndOutput, Ph
if (genotypesArePhased) {
Map<String, Object> handledGtAttribs = new HashMap<String, Object>(handledGt.getAttributes());
handledGtAttribs.put(PQ_KEY, pr.phaseQuality);
Genotype phasedHomGt = new Genotype(handledGt.getSampleName(), handledGt.getAlleles(), handledGt.getNegLog10PError(), handledGt.getFilters(), handledGtAttribs, genotypesArePhased);
Genotype phasedHomGt = new Genotype(handledGt.getSampleName(), handledGt.getAlleles(), handledGt.getLog10PError(), handledGt.getFilters(), handledGtAttribs, genotypesArePhased);
interiorUvc.setGenotype(samp, phasedHomGt);
}
}
@ -1123,7 +1123,7 @@ public class ReadBackedPhasingWalker extends RodWalker<PhasingStatsAndOutput, Ph
private int stop;
private Collection<Allele> alleles;
private GenotypesContext genotypes;
private double negLog10PError;
private double log10PError;
private Set<String> filters;
private Map<String, Object> attributes;
private String id;
@ -1136,13 +1136,14 @@ public class ReadBackedPhasingWalker extends RodWalker<PhasingStatsAndOutput, Ph
this.stop = vc.getEnd();
this.alleles = vc.getAlleles();
this.genotypes = GenotypesContext.copy(vc.getGenotypes()); // since vc.getGenotypes() is unmodifiable
this.negLog10PError = vc.getNegLog10PError();
this.log10PError = vc.getLog10PError();
this.filters = vc.filtersWereApplied() ? vc.getFilters() : null;
this.attributes = new HashMap<String, Object>(vc.getAttributes());
}
public VariantContext toVariantContext() {
return new VariantContext(name, id, contig, start, stop, alleles, genotypes, negLog10PError, filters, attributes);
return new VariantContextBuilder(name, contig, start, stop, alleles).id(id)
.genotypes(genotypes).log10PError(log10PError).filters(filters).attributes(attributes).make();
}
public GenomeLoc getLocation() {

View File

@ -147,7 +147,7 @@ public class MendelianViolationEvaluator extends VariantEvaluator {
}
private boolean includeGenotype(Genotype g) {
return g.getNegLog10PError() > getQThreshold() && g.isCalled();
return g.getLog10PError() > getQThreshold() && g.isCalled();
}
public static boolean isViolation(VariantContext vc, Genotype momG, Genotype dadG, Genotype childG) {

View File

@ -220,6 +220,6 @@ public class LeftAlignVariants extends RodWalker<Integer, Integer> {
newGenotypes.add(Genotype.modifyAlleles(genotype, newAlleles));
}
return new VariantContext(vc.getSource(), vc.getID(), vc.getChr(), vc.getStart(), vc.getEnd(), alleleMap.values(), newGenotypes, vc.getNegLog10PError(), vc.filtersWereApplied() ? vc.getFilters() : null, vc.getAttributes(), refBaseForIndel);
return new VariantContextBuilder(vc).alleles(alleleMap.values()).genotypes(newGenotypes).referenceBaseForIndel(refBaseForIndel).make();
}
}

View File

@ -326,7 +326,7 @@ public class VariantsToTable extends RodWalker<Integer, Integer> {
getters.put("NCALLED", new Getter() { public String get(VariantContext vc) { return Integer.toString(vc.getNSamples() - vc.getNoCallCount()); } });
getters.put("GQ", new Getter() { public String get(VariantContext vc) {
if ( vc.getNSamples() > 1 ) throw new UserException("Cannot get GQ values for multi-sample VCF");
return String.format("%.2f", 10 * vc.getGenotype(0).getNegLog10PError());
return String.format("%.2f", -10 * vc.getGenotype(0).getLog10PError());
}});
}

View File

@ -272,7 +272,7 @@ public abstract class AbstractVCFCodec implements FeatureCodec, NameAwareCodec,
String ref = getCachedString(parts[3].toUpperCase());
String alts = getCachedString(parts[4].toUpperCase());
builder.negLog10PError(parseQual(parts[5]));
builder.log10PError(parseQual(parts[5]));
builder.filters(parseFilters(getCachedString(parts[6])));
builder.attributes(parseInfo(parts[7]));
@ -448,16 +448,16 @@ public abstract class AbstractVCFCodec implements FeatureCodec, NameAwareCodec,
protected static Double parseQual(String qualString) {
// if we're the VCF 4 missing char, return immediately
if ( qualString.equals(VCFConstants.MISSING_VALUE_v4))
return VariantContext.NO_NEG_LOG_10PERROR;
return VariantContext.NO_LOG10_PERROR;
Double val = Double.valueOf(qualString);
// check to see if they encoded the missing qual score in VCF 3 style, with either the -1 or -1.0. check for val < 0 to save some CPU cycles
if ((val < 0) && (Math.abs(val - VCFConstants.MISSING_QUALITY_v3_DOUBLE) < VCFConstants.VCF_ENCODING_EPSILON))
return VariantContext.NO_NEG_LOG_10PERROR;
return VariantContext.NO_LOG10_PERROR;
// scale and return the value
return val / 10.0;
return val / -10.0;
}
/**

View File

@ -204,7 +204,7 @@ public class StandardVCFWriter extends IndexingVCFWriter {
mWriter.write(VCFConstants.FIELD_SEPARATOR);
// QUAL
if ( !vc.hasNegLog10PError() )
if ( !vc.hasLog10PError() )
mWriter.write(VCFConstants.MISSING_VALUE_v4);
else
mWriter.write(getQualValue(vc.getPhredScaledQual()));
@ -353,7 +353,7 @@ public class StandardVCFWriter extends IndexingVCFWriter {
// some exceptions
if ( key.equals(VCFConstants.GENOTYPE_QUALITY_KEY) ) {
if ( Math.abs(g.getNegLog10PError() - Genotype.NO_NEG_LOG_10PERROR) < 1e-6)
if ( Math.abs(g.getLog10PError() + Genotype.NO_LOG10_PERROR) < 1e-6)
val = VCFConstants.MISSING_VALUE_v4;
else {
val = getQualValue(Math.min(g.getPhredScaledQual(), VCFConstants.MAX_GENOTYPE_QUAL));
@ -447,7 +447,7 @@ public class StandardVCFWriter extends IndexingVCFWriter {
keys.addAll(g.getAttributes().keySet());
if ( g.isAvailable() )
sawGoodGT = true;
if ( g.hasNegLog10PError() )
if ( g.hasLog10PError() )
sawGoodQual = true;
if (g.isFiltered() && g.isCalled())
sawGenotypeFilter = true;

View File

@ -139,7 +139,7 @@ public class VCF3Codec extends AbstractVCFCodec {
for (int genotypeOffset = 1; genotypeOffset < nParts; genotypeOffset++) {
int GTValueSplitSize = ParsingUtils.split(genotypeParts[genotypeOffset], GTValueArray, VCFConstants.GENOTYPE_FIELD_SEPARATOR_CHAR);
double GTQual = VariantContext.NO_NEG_LOG_10PERROR;
double GTQual = VariantContext.NO_LOG10_PERROR;
Set<String> genotypeFilters = null;
Map<String, Object> gtAttributes = null;
String sampleName = sampleNameIterator.next();

View File

@ -166,7 +166,7 @@ public class VCFCodec extends AbstractVCFCodec {
for (int genotypeOffset = 1; genotypeOffset < nParts; genotypeOffset++) {
int GTValueSplitSize = ParsingUtils.split(genotypeParts[genotypeOffset], GTValueArray, VCFConstants.GENOTYPE_FIELD_SEPARATOR_CHAR);
double GTQual = VariantContext.NO_NEG_LOG_10PERROR;
double GTQual = VariantContext.NO_LOG10_PERROR;
Set<String> genotypeFilters = null;
Map<String, Object> gtAttributes = null;
String sampleName = sampleNameIterator.next();

View File

@ -27,10 +27,7 @@ package org.broadinstitute.sting.utils.gcf;
import org.broadinstitute.sting.utils.codecs.vcf.StandardVCFWriter;
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.GenotypesContext;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import org.broadinstitute.sting.utils.variantcontext.*;
import java.io.*;
import java.util.*;
@ -72,7 +69,7 @@ public class GCF {
alleleOffsets[i+1] = GCFHeaderBuilder.encodeAllele(vc.getAlternateAllele(i));
}
qual = (float)vc.getNegLog10PError(); //qualToByte(vc.getPhredScaledQual());
qual = (float)vc.getLog10PError(); //qualToByte(vc.getPhredScaledQual());
info = infoFieldString(vc, GCFHeaderBuilder);
filterOffset = GCFHeaderBuilder.encodeString(StandardVCFWriter.getFilterString(vc));
@ -142,14 +139,14 @@ public class GCF {
public VariantContext decode(final String source, final GCFHeader header) {
final String contig = header.getString(chromOffset);
alleleMap = header.getAlleles(alleleOffsets);
double negLog10PError = qual; // QualityUtils.qualToErrorProb(qual);
Set<String> filters = header.getFilters(filterOffset);
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put("INFO", info);
Byte refPadByte = refPad == 0 ? null : refPad;
GenotypesContext genotypes = decodeGenotypes(header);
return new VariantContext(source, VCFConstants.EMPTY_ID_FIELD, contig, start, stop, alleleMap, genotypes, negLog10PError, filters, attributes, refPadByte);
VariantContextBuilder builder = new VariantContextBuilder(source, contig, start, stop, alleleMap);
builder.genotypes(decodeGenotypes(header));
builder.log10PError(qual);
builder.filters(header.getFilters(filterOffset));
builder.attribute("INFO", info);
builder.referenceBaseForIndel(refPad == 0 ? null : refPad);
return builder.make();
}
private GenotypesContext decodeGenotypes(final GCFHeader header) {

View File

@ -84,14 +84,14 @@ public class GCFGenotype {
public Genotype decode(final String sampleName, final GCFHeader header, GCF GCF, List<Allele> alleleIndex) {
final List<Allele> alleles = decodeAlleles(gt, alleleIndex);
final double negLog10PError = gq / 10.0;
final double log10PError = gq / -10.0;
final Set<String> filters = Collections.emptySet();
final Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put("DP", dp);
attributes.put("AD", ad);
attributes.put("PL", pl);
return new Genotype(sampleName, alleles, negLog10PError, filters, attributes, false);
return new Genotype(sampleName, alleles, log10PError, filters, attributes, false);
}
private static int encodeAlleles(List<Allele> gtList, List<Allele> allAlleles) {

View File

@ -12,19 +12,19 @@ import java.util.*;
* @author depristo
*/
final class CommonInfo {
public static final double NO_NEG_LOG_10PERROR = -1.0;
public static final double NO_LOG10_PERROR = 1.0;
private static Set<String> NO_FILTERS = Collections.emptySet();
private static Map<String, Object> NO_ATTRIBUTES = Collections.unmodifiableMap(new HashMap<String, Object>());
private double negLog10PError = NO_NEG_LOG_10PERROR;
private double log10PError = NO_LOG10_PERROR;
private String name = null;
private Set<String> filters = null;
private Map<String, Object> attributes = NO_ATTRIBUTES;
public CommonInfo(String name, double negLog10PError, Set<String> filters, Map<String, Object> attributes) {
public CommonInfo(String name, double log10PError, Set<String> filters, Map<String, Object> attributes) {
this.name = name;
setNegLog10PError(negLog10PError);
setLog10PError(log10PError);
if ( filters != null && ! filters.isEmpty() )
this.filters = filters;
if ( attributes != null && ! attributes.isEmpty() ) {
@ -97,22 +97,21 @@ final class CommonInfo {
//
// ---------------------------------------------------------------------------------------------------------
public boolean hasNegLog10PError() {
return getNegLog10PError() != NO_NEG_LOG_10PERROR;
public boolean hasLog10PError() {
return getLog10PError() != NO_LOG10_PERROR;
}
/**
* @return the -1 * log10-based error estimate
*/
public double getNegLog10PError() { return negLog10PError; }
public double getPhredScaledQual() { return getNegLog10PError() * 10; }
public double getLog10PError() { return log10PError; }
public double getPhredScaledQual() { return getLog10PError() * -10; }
public void setNegLog10PError(double negLog10PError) {
if ( negLog10PError < 0 && negLog10PError != NO_NEG_LOG_10PERROR ) throw new IllegalArgumentException("BUG: negLog10PError cannot be < than 0 : " + negLog10PError);
if ( Double.isInfinite(negLog10PError) ) throw new IllegalArgumentException("BUG: negLog10PError should not be Infinity");
if ( Double.isNaN(negLog10PError) ) throw new IllegalArgumentException("BUG: negLog10PError should not be NaN");
this.negLog10PError = negLog10PError;
public void setLog10PError(double log10PError) {
if ( this.log10PError > 0 && this.log10PError != NO_LOG10_PERROR) throw new IllegalArgumentException("BUG: log10PError cannot be > 0 : " + this.log10PError);
if ( Double.isInfinite(this.log10PError) ) throw new IllegalArgumentException("BUG: log10PError should not be Infinity");
if ( Double.isNaN(this.log10PError) ) throw new IllegalArgumentException("BUG: log10PError should not be NaN");
this.log10PError = log10PError;
}
// ---------------------------------------------------------------------------------------------------------

View File

@ -18,20 +18,20 @@ public class Genotype {
public final static String UNPHASED_ALLELE_SEPARATOR = "/";
protected CommonInfo commonInfo;
public final static double NO_NEG_LOG_10PERROR = CommonInfo.NO_NEG_LOG_10PERROR;
public final static double NO_LOG10_PERROR = CommonInfo.NO_LOG10_PERROR;
protected List<Allele> alleles = null; // new ArrayList<Allele>();
protected Type type = null;
protected boolean isPhased = false;
public Genotype(String sampleName, List<Allele> alleles, double negLog10PError, Set<String> filters, Map<String, Object> attributes, boolean isPhased) {
this(sampleName, alleles, negLog10PError, filters, attributes, isPhased, null);
public Genotype(String sampleName, List<Allele> alleles, double log10PError, Set<String> filters, Map<String, Object> attributes, boolean isPhased) {
this(sampleName, alleles, log10PError, filters, attributes, isPhased, null);
}
public Genotype(String sampleName, List<Allele> alleles, double negLog10PError, Set<String> filters, Map<String, Object> attributes, boolean isPhased, double[] log10Likelihoods) {
public Genotype(String sampleName, List<Allele> alleles, double log10PError, Set<String> filters, Map<String, Object> attributes, boolean isPhased, double[] log10Likelihoods) {
if ( alleles != null )
this.alleles = Collections.unmodifiableList(alleles);
commonInfo = new CommonInfo(sampleName, negLog10PError, filters, attributes);
commonInfo = new CommonInfo(sampleName, log10PError, filters, attributes);
if ( log10Likelihoods != null )
commonInfo.putAttribute(VCFConstants.PHRED_GENOTYPE_LIKELIHOODS_KEY, GenotypeLikelihoods.fromLog10Likelihoods(log10Likelihoods));
this.isPhased = isPhased;
@ -42,23 +42,23 @@ public class Genotype {
* Creates a new Genotype for sampleName with genotype according to alleles.
* @param sampleName
* @param alleles
* @param negLog10PError the confidence in these alleles
* @param log10PError the confidence in these alleles
* @param log10Likelihoods a log10 likelihoods for each of the genotype combinations possible for alleles, in the standard VCF ordering, or null if not known
*/
public Genotype(String sampleName, List<Allele> alleles, double negLog10PError, double[] log10Likelihoods) {
this(sampleName, alleles, negLog10PError, null, null, false, log10Likelihoods);
public Genotype(String sampleName, List<Allele> alleles, double log10PError, double[] log10Likelihoods) {
this(sampleName, alleles, log10PError, null, null, false, log10Likelihoods);
}
public Genotype(String sampleName, List<Allele> alleles, double negLog10PError) {
this(sampleName, alleles, negLog10PError, null, null, false);
public Genotype(String sampleName, List<Allele> alleles, double log10PError) {
this(sampleName, alleles, log10PError, null, null, false);
}
public Genotype(String sampleName, List<Allele> alleles) {
this(sampleName, alleles, NO_NEG_LOG_10PERROR, null, null, false);
this(sampleName, alleles, NO_LOG10_PERROR, null, null, false);
}
public Genotype(String sampleName, Genotype parent) {
this(sampleName, parent.getAlleles(), parent.getNegLog10PError(), parent.getFilters(), parent.getAttributes(), parent.isPhased());
this(sampleName, parent.getAlleles(), parent.getLog10PError(), parent.getFilters(), parent.getAttributes(), parent.isPhased());
}
@ -70,15 +70,15 @@ public class Genotype {
// ---------------------------------------------------------------------------------------------------------
public static Genotype modifyName(Genotype g, String name) {
return new Genotype(name, g.getAlleles(), g.getNegLog10PError(), g.filtersWereApplied() ? g.getFilters() : null, g.getAttributes(), g.isPhased());
return new Genotype(name, g.getAlleles(), g.getLog10PError(), g.filtersWereApplied() ? g.getFilters() : null, g.getAttributes(), g.isPhased());
}
public static Genotype modifyAttributes(Genotype g, Map<String, Object> attributes) {
return new Genotype(g.getSampleName(), g.getAlleles(), g.getNegLog10PError(), g.filtersWereApplied() ? g.getFilters() : null, attributes, g.isPhased());
return new Genotype(g.getSampleName(), g.getAlleles(), g.getLog10PError(), g.filtersWereApplied() ? g.getFilters() : null, attributes, g.isPhased());
}
public static Genotype modifyAlleles(Genotype g, List<Allele> alleles) {
return new Genotype(g.getSampleName(), alleles, g.getNegLog10PError(), g.filtersWereApplied() ? g.getFilters() : null, g.getAttributes(), g.isPhased());
return new Genotype(g.getSampleName(), alleles, g.getLog10PError(), g.filtersWereApplied() ? g.getFilters() : null, g.getAttributes(), g.isPhased());
}
/**
@ -335,8 +335,8 @@ public class Genotype {
public boolean isFiltered() { return commonInfo.isFiltered(); }
public boolean isNotFiltered() { return commonInfo.isNotFiltered(); }
public boolean filtersWereApplied() { return commonInfo.filtersWereApplied(); }
public boolean hasNegLog10PError() { return commonInfo.hasNegLog10PError(); }
public double getNegLog10PError() { return commonInfo.getNegLog10PError(); }
public boolean hasLog10PError() { return commonInfo.hasLog10PError(); }
public double getLog10PError() { return commonInfo.getLog10PError(); }
public double getPhredScaledQual() { return commonInfo.getPhredScaledQual(); }
public Map<String, Object> getAttributes() { return commonInfo.getAttributes(); }

View File

@ -164,7 +164,7 @@ import java.util.*;
*/
public class VariantContext implements Feature { // to enable tribble intergration
protected CommonInfo commonInfo = null;
public final static double NO_NEG_LOG_10PERROR = CommonInfo.NO_NEG_LOG_10PERROR;
public final static double NO_LOG10_PERROR = CommonInfo.NO_LOG10_PERROR;
public final static String UNPARSED_GENOTYPE_MAP_KEY = "_UNPARSED_GENOTYPE_MAP_";
public final static String UNPARSED_GENOTYPE_PARSER_KEY = "_UNPARSED_GENOTYPE_PARSER_";
@ -235,7 +235,7 @@ public class VariantContext implements Feature { // to enable tribble intergrati
* @param stop the stop reference base (one based)
* @param alleles alleles
* @param genotypes genotypes map
* @param negLog10PError qual
* @param log10PError qual
* @param filters filters: use null for unfiltered and empty set for passes filters
* @param attributes attributes
* @param referenceBaseForIndel padded reference base
@ -243,29 +243,8 @@ public class VariantContext implements Feature { // to enable tribble intergrati
* @deprecated replaced by {@link VariantContextBuilder}
*/
@Deprecated
public VariantContext(String source, String ID, String contig, long start, long stop, Collection<Allele> alleles, GenotypesContext genotypes, double negLog10PError, Set<String> filters, Map<String, Object> attributes, Byte referenceBaseForIndel) {
this(source, ID, contig, start, stop, alleles, genotypes, negLog10PError, filters, attributes, referenceBaseForIndel, false, ALL_VALIDATION);
}
/**
* the complete constructor. Makes a complete VariantContext from its arguments
*
* @param source source
* @param contig the contig
* @param start the start base (one based)
* @param stop the stop reference base (one based)
* @param alleles alleles
* @param genotypes genotypes map
* @param negLog10PError qual
* @param filters filters: use null for unfiltered and empty set for passes filters
* @param attributes attributes
*
* @deprecated replaced by {@link VariantContextBuilder}
*/
@Deprecated
public VariantContext(String source, String ID, String contig, long start, long stop, Collection<Allele> alleles, GenotypesContext genotypes, double negLog10PError, Set<String> filters, Map<String, Object> attributes) {
this(source, ID, contig, start, stop, alleles, genotypes, negLog10PError, filters, attributes, null, false, ALL_VALIDATION);
protected VariantContext(String source, String ID, String contig, long start, long stop, Collection<Allele> alleles, GenotypesContext genotypes, double log10PError, Set<String> filters, Map<String, Object> attributes, Byte referenceBaseForIndel) {
this(source, ID, contig, start, stop, alleles, genotypes, log10PError, filters, attributes, referenceBaseForIndel, false, ALL_VALIDATION);
}
/**
@ -281,7 +260,7 @@ public class VariantContext implements Feature { // to enable tribble intergrati
*/
@Deprecated
public VariantContext(String source, String ID, String contig, long start, long stop, Collection<Allele> alleles) {
this(source, ID, contig, start, stop, alleles, NO_GENOTYPES, CommonInfo.NO_NEG_LOG_10PERROR, null, null, null, false, ALL_VALIDATION);
this(source, ID, contig, start, stop, alleles, NO_GENOTYPES, CommonInfo.NO_LOG10_PERROR, null, null, null, false, ALL_VALIDATION);
}
/**
@ -290,7 +269,7 @@ public class VariantContext implements Feature { // to enable tribble intergrati
* @param other the VariantContext to copy
*/
protected VariantContext(VariantContext other) {
this(other.getSource(), other.getID(), other.getChr(), other.getStart(), other.getEnd() , other.getAlleles(), other.getGenotypes(), other.getNegLog10PError(), other.filtersWereApplied() ? other.getFilters() : null, other.getAttributes(), other.REFERENCE_BASE_FOR_INDEL, false, NO_VALIDATION);
this(other.getSource(), other.getID(), other.getChr(), other.getStart(), other.getEnd() , other.getAlleles(), other.getGenotypes(), other.getLog10PError(), other.filtersWereApplied() ? other.getFilters() : null, other.getAttributes(), other.REFERENCE_BASE_FOR_INDEL, false, NO_VALIDATION);
}
/**
@ -302,7 +281,7 @@ public class VariantContext implements Feature { // to enable tribble intergrati
* @param stop the stop reference base (one based)
* @param alleles alleles
* @param genotypes genotypes map
* @param negLog10PError qual
* @param log10PError qual
* @param filters filters: use null for unfiltered and empty set for passes filters
* @param attributes attributes
* @param referenceBaseForIndel padded reference base
@ -312,7 +291,7 @@ public class VariantContext implements Feature { // to enable tribble intergrati
protected VariantContext(String source, String ID,
String contig, long start, long stop,
Collection<Allele> alleles, GenotypesContext genotypes,
double negLog10PError, Set<String> filters, Map<String, Object> attributes,
double log10PError, Set<String> filters, Map<String, Object> attributes,
Byte referenceBaseForIndel, boolean genotypesAreUnparsed,
EnumSet<Validation> validationToPerform ) {
if ( contig == null ) { throw new IllegalArgumentException("Contig cannot be null"); }
@ -335,7 +314,7 @@ public class VariantContext implements Feature { // to enable tribble intergrati
}
}
this.commonInfo = new CommonInfo(source, negLog10PError, filters, attributes);
this.commonInfo = new CommonInfo(source, log10PError, filters, attributes);
REFERENCE_BASE_FOR_INDEL = referenceBaseForIndel;
// todo -- remove me when this check is no longer necessary
@ -600,8 +579,8 @@ public class VariantContext implements Feature { // to enable tribble intergrati
public boolean isFiltered() { return commonInfo.isFiltered(); }
public boolean isNotFiltered() { return commonInfo.isNotFiltered(); }
public boolean filtersWereApplied() { return commonInfo.filtersWereApplied(); }
public boolean hasNegLog10PError() { return commonInfo.hasNegLog10PError(); }
public double getNegLog10PError() { return commonInfo.getNegLog10PError(); }
public boolean hasLog10PError() { return commonInfo.hasLog10PError(); }
public double getLog10PError() { return commonInfo.getLog10PError(); }
public double getPhredScaledQual() { return commonInfo.getPhredScaledQual(); }
public Map<String, Object> getAttributes() { return commonInfo.getAttributes(); }

View File

@ -29,8 +29,6 @@ import org.broad.tribble.Feature;
import org.broad.tribble.TribbleException;
import org.broad.tribble.util.ParsingUtils;
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.util.*;
@ -69,7 +67,7 @@ public class VariantContextBuilder {
// optional -> these are set to the appropriate default value
private String ID = VCFConstants.EMPTY_ID_FIELD;
private GenotypesContext genotypes = GenotypesContext.NO_GENOTYPES;
private double negLog10PError = VariantContext.NO_NEG_LOG_10PERROR;
private double log10PError = VariantContext.NO_LOG10_PERROR;
private Set<String> filters = null;
private Map<String, Object> attributes = null;
private boolean attributesCanBeModified = false;
@ -116,7 +114,7 @@ public class VariantContextBuilder {
this.genotypes = parent.genotypes;
this.genotypesAreUnparsed = parent.hasAttribute(VariantContext.UNPARSED_GENOTYPE_MAP_KEY);
this.ID = parent.getID();
this.negLog10PError = parent.getNegLog10PError();
this.log10PError = parent.getLog10PError();
this.referenceBaseForIndel = parent.getReferenceBaseForIndel();
this.source = parent.getSource();
this.start = parent.getStart();
@ -279,13 +277,13 @@ public class VariantContextBuilder {
}
/**
* Tells us that the resulting VariantContext should have negLog10PError
* @param negLog10PError
* Tells us that the resulting VariantContext should have log10PError
* @param log10PError
* @return
*/
@Requires("negLog10PError >= 0 || negLog10PError == VariantContext.NO_NEG_LOG_10PERROR")
public VariantContextBuilder negLog10PError(final double negLog10PError) {
this.negLog10PError = negLog10PError;
@Requires("log10PError <= 0 || log10PError == VariantContext.NO_LOG10_PERROR")
public VariantContextBuilder log10PError(final double log10PError) {
this.log10PError = log10PError;
return this;
}
@ -374,7 +372,7 @@ public class VariantContextBuilder {
*/
public VariantContext make() {
return new VariantContext(source, ID, contig, start, stop, alleles,
genotypes, negLog10PError, filters, attributes,
genotypes, log10PError, filters, attributes,
referenceBaseForIndel, genotypesAreUnparsed, toValidate);
}
}

View File

@ -113,7 +113,7 @@ public class VariantContextUtils {
Map<String, Object> attrs = new HashMap<String, Object>(g.getAttributes());
attrs.remove(VCFConstants.PHRED_GENOTYPE_LIKELIHOODS_KEY);
attrs.remove(VCFConstants.GENOTYPE_LIKELIHOODS_KEY);
return new Genotype(g.getSampleName(), g.getAlleles(), g.getNegLog10PError(), g.filtersWereApplied() ? g.getFilters() : null, attrs, g.isPhased());
return new Genotype(g.getSampleName(), g.getAlleles(), g.getLog10PError(), g.filtersWereApplied() ? g.getFilters() : null, attrs, g.isPhased());
}
public static VariantContext createVariantContextWithPaddedAlleles(VariantContext inputVC, boolean refBaseShouldBeAppliedToEndOfAlleles) {
@ -178,14 +178,12 @@ public class VariantContextUtils {
newGenotypeAlleles.add(Allele.NO_CALL);
}
}
genotypes.add(new Genotype(g.getSampleName(), newGenotypeAlleles, g.getNegLog10PError(),
genotypes.add(new Genotype(g.getSampleName(), newGenotypeAlleles, g.getLog10PError(),
g.getFilters(), g.getAttributes(), g.isPhased()));
}
// Do not change the filter state if filters were not applied to this context
Set<String> inputVCFilters = inputVC.getFiltersMaybeNull();
return new VariantContext(inputVC.getSource(), inputVC.getID(), inputVC.getChr(), inputVC.getStart(), inputVC.getEnd(), alleles, genotypes, inputVC.getNegLog10PError(), inputVCFilters, inputVC.getAttributes(),refByte);
return new VariantContextBuilder(inputVC).alleles(alleles).genotypes(genotypes).make();
}
else
return inputVC;
@ -373,12 +371,12 @@ public class VariantContextUtils {
final GenotypesContext genotypes = GenotypesContext.create(vc.getNSamples());
for ( final Genotype g : vc.getGenotypes() ) {
Map<String, Object> genotypeAttributes = subsetAttributes(g.commonInfo, keysToPreserve);
genotypes.add(new Genotype(g.getSampleName(), g.getAlleles(), g.getNegLog10PError(), g.getFilters(),
genotypes.add(new Genotype(g.getSampleName(), g.getAlleles(), g.getLog10PError(), g.getFilters(),
genotypeAttributes, g.isPhased()));
}
return new VariantContext(vc.getSource(), vc.getID(), vc.getChr(), vc.getStart(), vc.getEnd(),
vc.getAlleles(), genotypes, vc.getNegLog10PError(), vc.getFilters(), attributes, vc.getReferenceBaseForIndel());
vc.getAlleles(), genotypes, vc.getLog10PError(), vc.getFilters(), attributes, vc.getReferenceBaseForIndel());
}
public enum GenotypeMergeType {
@ -475,7 +473,7 @@ public class VariantContextUtils {
int depth = 0;
int maxAC = -1;
final Map<String, Object> attributesWithMaxAC = new TreeMap<String, Object>();
double negLog10PError = -1;
double log10PError = 1;
VariantContext vcWithMaxAC = null;
Set<String> addedSamples = new HashSet<String>(first.getNSamples());
GenotypesContext genotypes = GenotypesContext.create();
@ -504,7 +502,7 @@ public class VariantContextUtils {
mergeGenotypes(genotypes, addedSamples, vc, alleleMapping, genotypeMergeOptions == GenotypeMergeType.UNIQUIFY);
negLog10PError = Math.max(negLog10PError, vc.isVariant() ? vc.getNegLog10PError() : -1);
log10PError = Math.min(log10PError, vc.isVariant() ? vc.getLog10PError() : 1);
filters.addAll(vc.getFilters());
@ -610,10 +608,15 @@ public class VariantContextUtils {
final String ID = rsIDs.isEmpty() ? VCFConstants.EMPTY_ID_FIELD : Utils.join(",", rsIDs);
VariantContext merged = new VariantContext(name, ID, loc.getContig(), loc.getStart(), loc.getStop(), alleles, genotypes, negLog10PError, filters, (mergeInfoWithMaxAC ? attributesWithMaxAC : attributes) );
// Trim the padded bases of all alleles if necessary
merged = createVariantContextWithTrimmedAlleles(merged);
final VariantContextBuilder builder = new VariantContextBuilder().source(name).id(ID);
builder.loc(loc.getContig(), loc.getStart(), loc.getStop());
builder.alleles(alleles);
builder.genotypes(genotypes);
builder.log10PError(log10PError);
builder.filters(filters).attributes(mergeInfoWithMaxAC ? attributesWithMaxAC : attributes);
// Trim the padded bases of all alleles if necessary
VariantContext merged = createVariantContextWithTrimmedAlleles(builder.make());
if ( printMessages && remapped ) System.out.printf("Remapped => %s%n", merged);
return merged;
}
@ -648,6 +651,7 @@ public class VariantContextUtils {
return true;
}
public static VariantContext createVariantContextWithTrimmedAlleles(VariantContext inputVC) {
// see if we need to trim common reference base from all alleles
boolean trimVC;
@ -713,8 +717,9 @@ public class VariantContextUtils {
genotypes.add(Genotype.modifyAlleles(genotype, trimmedAlleles));
}
return new VariantContext(inputVC.getSource(), inputVC.getID(), inputVC.getChr(), inputVC.getStart(), inputVC.getEnd(), alleles, genotypes, inputVC.getNegLog10PError(), inputVC.filtersWereApplied() ? inputVC.getFilters() : null, attributes, new Byte(inputVC.getReference().getBases()[0]));
final VariantContextBuilder builder = new VariantContextBuilder(inputVC);
return builder.alleles(alleles).genotypes(genotypes).attributes(attributes).referenceBaseForIndel(new Byte(inputVC.getReference().getBases()[0])).make();
}
return inputVC;
@ -910,7 +915,7 @@ public class VariantContextUtils {
if ( uniqifySamples || alleleMapping.needsRemapping() ) {
final List<Allele> alleles = alleleMapping.needsRemapping() ? alleleMapping.remap(g.getAlleles()) : g.getAlleles();
newG = new Genotype(name, alleles, g.getNegLog10PError(), g.getFilters(), g.getAttributes(), g.isPhased());
newG = new Genotype(name, alleles, g.getLog10PError(), g.getFilters(), g.getAttributes(), g.isPhased());
}
mergedGenotypes.add(newG);
@ -954,8 +959,7 @@ public class VariantContextUtils {
newGenotypes.add(Genotype.modifyAlleles(genotype, newAlleles));
}
return new VariantContext(vc.getSource(), vc.getID(), vc.getChr(), vc.getStart(), vc.getEnd(), alleleMap.values(), newGenotypes, vc.getNegLog10PError(), vc.filtersWereApplied() ? vc.getFilters() : null, vc.getAttributes());
return new VariantContextBuilder(vc).alleles(alleleMap.values()).genotypes(newGenotypes).make();
}
public static VariantContext purgeUnallowedGenotypeAttributes(VariantContext vc, Set<String> allowedAttributes) {

View File

@ -64,7 +64,7 @@ class VariantJEXLContext implements JexlContext {
x.put("CHROM", new AttributeGetter() { public Object get(VariantContext vc) { return vc.getChr(); }});
x.put("POS", new AttributeGetter() { public Object get(VariantContext vc) { return vc.getStart(); }});
x.put("TYPE", new AttributeGetter() { public Object get(VariantContext vc) { return vc.getType().toString(); }});
x.put("QUAL", new AttributeGetter() { public Object get(VariantContext vc) { return 10 * vc.getNegLog10PError(); }});
x.put("QUAL", new AttributeGetter() { public Object get(VariantContext vc) { return -10 * vc.getLog10PError(); }});
x.put("ALLELES", new AttributeGetter() { public Object get(VariantContext vc) { return vc.getAlleles(); }});
x.put("N_ALLELES", new AttributeGetter() { public Object get(VariantContext vc) { return vc.getNAlleles(); }});
x.put("FILTER", new AttributeGetter() { public Object get(VariantContext vc) { return vc.isFiltered() ? "1" : "0"; }});

View File

@ -2,10 +2,7 @@ package org.broadinstitute.sting.utils.genotype.vcf;
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.GenotypesContext;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import org.broadinstitute.sting.utils.variantcontext.*;
import org.broadinstitute.sting.utils.codecs.vcf.*;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.testng.Assert;
@ -136,9 +133,8 @@ public class VCFWriterUnitTest extends BaseTest {
genotypes.add(gt);
}
return new VariantContext("RANDOM", VCFConstants.EMPTY_ID_FIELD, loc.getContig(), loc.getStart(), loc.getStop(), alleles, genotypes, 0, filters, attributes, (byte)'A');
return new VariantContextBuilder("RANDOM", loc.getContig(), loc.getStart(), loc.getStop(), alleles)
.genotypes(genotypes).attributes(attributes).referenceBaseForIndel((byte)'A').make();
}

View File

@ -71,8 +71,8 @@ public class GenotypeUnitTest extends BaseTest {
// public boolean sameGenotype(Genotype other)
// public boolean sameGenotype(Genotype other, boolean ignorePhase)
// public String getSampleName()
// public boolean hasNegLog10PError()
// public double getNegLog10PError()
// public boolean hasLog10PError()
// public double getLog10PError()
// public double getPhredScaledQual()
// public boolean hasAttribute(String key)
// public Object getAttribute(String key)

View File

@ -356,7 +356,7 @@ public class VariantContextBenchmark extends SimpleBenchmark {
// for ( final org.broadinstitute.sting.utils.variantcontext.v13.Genotype g : vc.getGenotypes().values() ) {
// String name = g.getSampleName()+"_"+i;
// gc.put(name, new org.broadinstitute.sting.utils.variantcontext.v13.Genotype(name,
// g.getAlleles(), g.getNegLog10PError(), g.getFilters(), g.getAttributes(), g.isPhased(), g.getLikelihoods().getAsVector()));
// g.getAlleles(), g.getLog10PError(), g.getFilters(), g.getAttributes(), g.isPhased(), g.getLikelihoods().getAsVector()));
// toMerge.add(org.broadinstitute.sting.utils.variantcontext.v13.VariantContext.modifyGenotypes(vc, gc));
// }
// }

View File

@ -91,45 +91,45 @@ public class VariantContextUnitTest extends BaseTest {
// test INDELs
alleles = Arrays.asList(Aref, ATC);
vc = new VariantContext("test", VCFConstants.EMPTY_ID_FIELD, snpLoc,snpLocStart, snpLocStop, alleles, null, CommonInfo.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
vc = new VariantContext("test", VCFConstants.EMPTY_ID_FIELD, snpLoc,snpLocStart, snpLocStop, alleles, null, CommonInfo.NO_LOG10_PERROR, null, null, (byte)'A');
Assert.assertEquals(vc.getType(), VariantContext.Type.INDEL);
alleles = Arrays.asList(ATCref, A);
vc = new VariantContext("test", VCFConstants.EMPTY_ID_FIELD, snpLoc,snpLocStart, snpLocStop+2, alleles, null, CommonInfo.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
vc = new VariantContext("test", VCFConstants.EMPTY_ID_FIELD, snpLoc,snpLocStart, snpLocStop+2, alleles, null, CommonInfo.NO_LOG10_PERROR, null, null, (byte)'A');
Assert.assertEquals(vc.getType(), VariantContext.Type.INDEL);
alleles = Arrays.asList(Tref, TA, TC);
vc = new VariantContext("test", VCFConstants.EMPTY_ID_FIELD, snpLoc,snpLocStart, snpLocStop, alleles, null, CommonInfo.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
vc = new VariantContext("test", VCFConstants.EMPTY_ID_FIELD, snpLoc,snpLocStart, snpLocStop, alleles, null, CommonInfo.NO_LOG10_PERROR, null, null, (byte)'A');
Assert.assertEquals(vc.getType(), VariantContext.Type.INDEL);
alleles = Arrays.asList(ATCref, A, AC);
vc = new VariantContext("test", VCFConstants.EMPTY_ID_FIELD, snpLoc,snpLocStart, snpLocStop+2, alleles, null, CommonInfo.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
vc = new VariantContext("test", VCFConstants.EMPTY_ID_FIELD, snpLoc,snpLocStart, snpLocStop+2, alleles, null, CommonInfo.NO_LOG10_PERROR, null, null, (byte)'A');
Assert.assertEquals(vc.getType(), VariantContext.Type.INDEL);
alleles = Arrays.asList(ATCref, A, Allele.create("ATCTC"));
vc = new VariantContext("test", VCFConstants.EMPTY_ID_FIELD, snpLoc,snpLocStart, snpLocStop+2, alleles, null, CommonInfo.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
vc = new VariantContext("test", VCFConstants.EMPTY_ID_FIELD, snpLoc,snpLocStart, snpLocStop+2, alleles, null, CommonInfo.NO_LOG10_PERROR, null, null, (byte)'A');
Assert.assertEquals(vc.getType(), VariantContext.Type.INDEL);
// test MIXED
alleles = Arrays.asList(TAref, T, TC);
vc = new VariantContext("test", VCFConstants.EMPTY_ID_FIELD, snpLoc,snpLocStart, snpLocStop+1, alleles, null, CommonInfo.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
vc = new VariantContext("test", VCFConstants.EMPTY_ID_FIELD, snpLoc,snpLocStart, snpLocStop+1, alleles, null, CommonInfo.NO_LOG10_PERROR, null, null, (byte)'A');
Assert.assertEquals(vc.getType(), VariantContext.Type.MIXED);
alleles = Arrays.asList(TAref, T, AC);
vc = new VariantContext("test", VCFConstants.EMPTY_ID_FIELD, snpLoc,snpLocStart, snpLocStop+1, alleles, null, CommonInfo.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
vc = new VariantContext("test", VCFConstants.EMPTY_ID_FIELD, snpLoc,snpLocStart, snpLocStop+1, alleles, null, CommonInfo.NO_LOG10_PERROR, null, null, (byte)'A');
Assert.assertEquals(vc.getType(), VariantContext.Type.MIXED);
alleles = Arrays.asList(ACref, ATC, AT);
vc = new VariantContext("test", VCFConstants.EMPTY_ID_FIELD, snpLoc,snpLocStart, snpLocStop+1, alleles, null, CommonInfo.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
vc = new VariantContext("test", VCFConstants.EMPTY_ID_FIELD, snpLoc,snpLocStart, snpLocStop+1, alleles, null, CommonInfo.NO_LOG10_PERROR, null, null, (byte)'A');
Assert.assertEquals(vc.getType(), VariantContext.Type.MIXED);
alleles = Arrays.asList(Aref, T, symbolic);
vc = new VariantContext("test", VCFConstants.EMPTY_ID_FIELD, snpLoc,snpLocStart, snpLocStop, alleles, null, CommonInfo.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
vc = new VariantContext("test", VCFConstants.EMPTY_ID_FIELD, snpLoc,snpLocStart, snpLocStop, alleles, null, CommonInfo.NO_LOG10_PERROR, null, null, (byte)'A');
Assert.assertEquals(vc.getType(), VariantContext.Type.MIXED);
// test SYMBOLIC
alleles = Arrays.asList(Tref, symbolic);
vc = new VariantContext("test", VCFConstants.EMPTY_ID_FIELD, snpLoc,snpLocStart, snpLocStop, alleles, null, CommonInfo.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
vc = new VariantContext("test", VCFConstants.EMPTY_ID_FIELD, snpLoc,snpLocStart, snpLocStop, alleles, null, CommonInfo.NO_LOG10_PERROR, null, null, (byte)'A');
Assert.assertEquals(vc.getType(), VariantContext.Type.SYMBOLIC);
}
@ -200,7 +200,7 @@ public class VariantContextUnitTest extends BaseTest {
@Test
public void testCreatingDeletionVariantContext() {
List<Allele> alleles = Arrays.asList(ATCref, del);
VariantContext vc = new VariantContext("test", VCFConstants.EMPTY_ID_FIELD, delLoc, delLocStart, delLocStop, alleles, null, CommonInfo.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
VariantContext vc = new VariantContext("test", VCFConstants.EMPTY_ID_FIELD, delLoc, delLocStart, delLocStop, alleles, null, CommonInfo.NO_LOG10_PERROR, null, null, (byte)'A');
Assert.assertEquals(vc.getChr(), delLoc);
Assert.assertEquals(vc.getStart(), delLocStart);
@ -227,7 +227,7 @@ public class VariantContextUnitTest extends BaseTest {
@Test
public void testCreatingInsertionVariantContext() {
List<Allele> alleles = Arrays.asList(delRef, ATC);
VariantContext vc = new VariantContext("test", VCFConstants.EMPTY_ID_FIELD, insLoc, insLocStart, insLocStop, alleles, null, CommonInfo.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
VariantContext vc = new VariantContext("test", VCFConstants.EMPTY_ID_FIELD, insLoc, insLocStart, insLocStop, alleles, null, CommonInfo.NO_LOG10_PERROR, null, null, (byte)'A');
Assert.assertEquals(vc.getChr(), insLoc);
Assert.assertEquals(vc.getStart(), insLocStart);
@ -550,7 +550,7 @@ public class VariantContextUnitTest extends BaseTest {
@Test(dataProvider = "getAlleles")
public void testMergeAlleles(GetAllelesTest cfg) {
final List<Allele> altAlleles = cfg.alleles.subList(1, cfg.alleles.size());
final VariantContext vc = new VariantContext("test", VCFConstants.EMPTY_ID_FIELD, snpLoc, snpLocStart, snpLocStop, cfg.alleles, null, CommonInfo.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
final VariantContext vc = new VariantContext("test", VCFConstants.EMPTY_ID_FIELD, snpLoc, snpLocStart, snpLocStop, cfg.alleles, null, CommonInfo.NO_LOG10_PERROR, null, null, (byte)'A');
Assert.assertEquals(vc.getAlleles(), cfg.alleles, "VC alleles not the same as input alleles");
Assert.assertEquals(vc.getNAlleles(), cfg.alleles.size(), "VC getNAlleles not the same as input alleles size");
@ -653,7 +653,7 @@ public class VariantContextUnitTest extends BaseTest {
Assert.assertEquals(cfg.vc.getAttributes(), cfg.copy.getAttributes());
Assert.assertEquals(cfg.vc.getID(), cfg.copy.getID());
Assert.assertEquals(cfg.vc.getGenotypes(), cfg.copy.getGenotypes());
Assert.assertEquals(cfg.vc.getNegLog10PError(), cfg.copy.getNegLog10PError());
Assert.assertEquals(cfg.vc.getLog10PError(), cfg.copy.getLog10PError());
Assert.assertEquals(cfg.vc.getFilters(), cfg.copy.getFilters());
}
@ -705,7 +705,7 @@ public class VariantContextUnitTest extends BaseTest {
Assert.assertEquals(sub.getChr(), vc.getChr());
Assert.assertEquals(sub.getStart(), vc.getStart());
Assert.assertEquals(sub.getEnd(), vc.getEnd());
Assert.assertEquals(sub.getNegLog10PError(), vc.getNegLog10PError());
Assert.assertEquals(sub.getLog10PError(), vc.getLog10PError());
Assert.assertEquals(sub.getFilters(), vc.getFilters());
Assert.assertEquals(sub.getID(), vc.getID());
Assert.assertEquals(sub.getReferenceBaseForIndel(), vc.getReferenceBaseForIndel());

View File

@ -525,7 +525,7 @@ public class VariantContextUtilsUnitTest extends BaseTest {
Genotype expectedValue = expected.get(value.getSampleName());
Assert.assertEquals(value.alleles, expectedValue.alleles, "Alleles in Genotype aren't equal");
Assert.assertEquals(value.getNegLog10PError(), expectedValue.getNegLog10PError(), "GQ values aren't equal");
Assert.assertEquals(value.getLog10PError(), expectedValue.getLog10PError(), "GQ values aren't equal");
Assert.assertEquals(value.hasLikelihoods(), expectedValue.hasLikelihoods(), "Either both have likelihoods or both not");
if ( value.hasLikelihoods() )
Assert.assertEquals(value.getLikelihoods().getAsVector(), expectedValue.getLikelihoods().getAsVector(), "Genotype likelihoods aren't equal");