@Deprecated public boolean hasLog10PError() { return hasGQ(); } @Deprecated public double getLog10PError() { return getGQ() / -10.0; }
@Deprecated public boolean hasLog10PError() { return hasGQ(); } @Deprecated public double getLog10PError() { return getGQ() / -10.0; }
@Deprecated public boolean hasLog10PError() { return hasGQ(); } @Deprecated public double getLog10PError() { return getGQ() / -10.0; }
public boolean hasAnyAttribute(final String key) { if (key.equals(VCFConstants.GENOTYPE_KEY)) { return isAvailable(); } else if (key.equals(VCFConstants.GENOTYPE_QUALITY_KEY)) { return hasGQ(); } else if (key.equals(VCFConstants.GENOTYPE_ALLELE_DEPTHS)) { return hasAD(); } else if (key.equals(VCFConstants.GENOTYPE_PL_KEY)) { return hasPL(); } else if (key.equals(VCFConstants.DEPTH_KEY)) { return hasDP(); } else if (key.equals(VCFConstants.GENOTYPE_FILTER_KEY)) { return true; //always available } else { return hasExtendedAttribute(key); } }
public boolean hasAnyAttribute(final String key) { if (key.equals(VCFConstants.GENOTYPE_KEY)) { return isAvailable(); } else if (key.equals(VCFConstants.GENOTYPE_QUALITY_KEY)) { return hasGQ(); } else if (key.equals(VCFConstants.GENOTYPE_ALLELE_DEPTHS)) { return hasAD(); } else if (key.equals(VCFConstants.GENOTYPE_PL_KEY)) { return hasPL(); } else if (key.equals(VCFConstants.DEPTH_KEY)) { return hasDP(); } else { return hasExtendedAttribute(key); } }
public boolean hasAnyAttribute(final String key) { if (key.equals(VCFConstants.GENOTYPE_KEY)) { return isAvailable(); } else if (key.equals(VCFConstants.GENOTYPE_QUALITY_KEY)) { return hasGQ(); } else if (key.equals(VCFConstants.GENOTYPE_ALLELE_DEPTHS)) { return hasAD(); } else if (key.equals(VCFConstants.GENOTYPE_PL_KEY)) { return hasPL(); } else if (key.equals(VCFConstants.DEPTH_KEY)) { return hasDP(); } else if (key.equals(VCFConstants.GENOTYPE_FILTER_KEY)) { return true; //always available } else { return hasExtendedAttribute(key); } }
/** * Add information from this Genotype to this band * @param g a non-null Genotype with GQ and DP attributes */ public void add(final int pos, final Genotype g) { if ( g == null ) throw new IllegalArgumentException("g cannot be null"); if ( ! g.hasGQ() ) throw new IllegalArgumentException("g must have GQ field"); if ( ! g.hasPL() ) throw new IllegalArgumentException("g must have PL field"); if ( pos != stop + 1 ) throw new IllegalArgumentException("adding genotype at pos " + pos + " isn't contiguous with previous stop " + stop); if ( g.getPloidy() != ploidy) throw new IllegalArgumentException("cannot add a genotype with a different ploidy: " + g.getPloidy() + " != " + ploidy); if( minPLs == null ) minPLs = g.getPL(); else { // otherwise take the min with the provided genotype's PLs final int[] PL = g.getPL(); if (PL.length != minPLs.length) throw new IllegalStateException("trying to merge different PL array sizes: " + PL.length + " != " + minPLs.length); for (int i = 0; i < PL.length; i++) if (minPLs[i] > PL[i]) minPLs[i] = PL[i]; } stop = pos; GQs.add(Math.min(g.getGQ(), 99)); // cap the GQs by the max. of 99 emission DPs.add(Math.max(g.getDP(),0)); }
keys.addAll(g.getExtendedAttributes().keySet()); if ( g.isAvailable() ) sawGoodGT = true; if ( g.hasGQ() ) sawGoodQual = true; if ( g.hasDP() ) sawDP = true; if ( g.hasAD() ) sawAD = true;
keys.addAll(g.getExtendedAttributes().keySet()); if ( g.isAvailable() ) sawGoodGT = true; if ( g.hasGQ() ) sawGoodQual = true; if ( g.hasDP() ) sawDP = true; if ( g.hasAD() ) sawAD = true;
keys.addAll(g.getExtendedAttributes().keySet()); if ( g.isAvailable() ) sawGoodGT = true; if ( g.hasGQ() ) sawGoodQual = true; if ( g.hasDP() ) sawDP = true; if ( g.hasAD() ) sawAD = true;
public VCFGenotype(Genotype wrappedGenotype) { vcfGenotype = wrappedGenotype; attributes = new HashMap<String, Object>(); if (vcfGenotype.hasDP()) { attributes.put("DP", vcfGenotype.getDP()); } if (vcfGenotype.hasAD()) { String adString = ""; int[] ad = vcfGenotype.getAD(); for (int i = 0; i < ad.length; i++) { if (i != 0) adString += ","; adString += String.valueOf(ad[i]); } attributes.put("AD", adString); } if (vcfGenotype.hasGQ()) { attributes.put("GQ", vcfGenotype.getGQ()); } if (vcfGenotype.hasPL()) { String plString = ""; int[] pl = vcfGenotype.getPL(); for (int i = 0; i < pl.length; i++) { if (i != 0) plString += ","; plString += String.valueOf(pl[i]); } attributes.put("PL", plString); } attributes.putAll(vcfGenotype.getExtendedAttributes()); }
@Override public Map<String, Object> annotate(final RefMetaDataTracker tracker, final AnnotatorCompatible walker, final ReferenceContext ref, final Map<String, AlignmentContext> stratifiedContexts, final VariantContext vc, final Map<String, PerReadAlleleLikelihoodMap> perReadAlleleLikelihoodMap ) { if ( ! vc.hasGenotypes() ) return null; final Map<String,Object> returnMap = new HashMap<>(); returnMap.put(GATKVCFConstants.NOCALL_CHROM_KEY, vc.getNoCallCount()); final MathUtils.RunningAverage average = new MathUtils.RunningAverage(); for( final Genotype g : vc.getGenotypes() ) { if( g.hasGQ() ) { average.add(g.getGQ()); } } if( average.observationCount() > 0L ) { returnMap.put(GATKVCFConstants.GQ_MEAN_KEY, String.format("%.2f", average.mean())); if( average.observationCount() > 1L ) { returnMap.put(GATKVCFConstants.GQ_STDEV_KEY, String.format("%.2f", average.stddev())); } } return returnMap; }
/** * Cleans up genotype-level annotations that need to be updated * (similar to {@link org.broadinstitute.gatk.tools.walkers.variantutils.GenotypeGVCFs#cleanupGenotypeAnnotations}, * but here we only check for unconfident calls (i.e., those with GQ = 0), which are set to no-call). */ private VariantContext clearUnconfidentGenotypeCalls(final VariantContext VC) { final GenotypesContext oldGTs = VC.getGenotypes(); final List<Genotype> clearedGTs = new ArrayList<>(oldGTs.size()); for ( final Genotype oldGT : oldGTs ) { // set GT to no-call when GQ is 0 if (oldGT.hasGQ() && oldGT.getGQ() == 0) { final int ploidy = oldGT.getPloidy(); final List<Allele> noCallAlleles = GATKVariantContextUtils.noCallAlleles(ploidy); final Genotype noCallGT = new GenotypeBuilder().alleles(noCallAlleles).make(); clearedGTs.add(noCallGT); } else { clearedGTs.add(oldGT); } } return new VariantContextBuilder(VC).genotypes(clearedGTs).make(); } }
private boolean checkGQIsGood(Genotype genotype) { if ( genotype.hasGQ() ) { return genotype.getGQ() >= minGenotypeQuality; } else if ( genotype.hasLikelihoods() ) { double log10gq = GenotypeLikelihoods.getGQLog10FromLikelihoods(genotype.getType().ordinal()-1,genotype.getLikelihoods().getAsVector()); return QualityUtils.phredScaleLog10ErrorRate(log10gq) >= minGenotypeQuality; } return minGenotypeQuality <= 0; }
private void assertGoodVC(final VariantContext vc, final String contig, final int start, final int stop, final boolean nonRef) { Assert.assertEquals(vc.getChr(), contig); Assert.assertEquals(vc.getStart(), start); Assert.assertEquals(vc.getEnd(), stop); if ( nonRef ) { Assert.assertNotEquals(vc.getAlternateAllele(0), GATKVCFConstants.NON_REF_SYMBOLIC_ALLELE); } else { Assert.assertEquals(vc.getNAlleles(), 2); Assert.assertEquals(vc.getAlternateAllele(0), GATKVCFConstants.NON_REF_SYMBOLIC_ALLELE); Assert.assertEquals(vc.getAttributeAsInt(VCFConstants.END_KEY, -1), stop); Assert.assertTrue(vc.hasGenotypes()); Assert.assertTrue(vc.hasGenotype(SAMPLE_NAME)); Assert.assertEquals(vc.getGenotypes().size(), 1); final Genotype g = vc.getGenotype(SAMPLE_NAME); Assert.assertEquals(g.hasAD(), false); Assert.assertEquals(g.hasLikelihoods(), true); Assert.assertEquals(g.hasPL(), true); Assert.assertEquals(g.getPL().length == 3, true); Assert.assertEquals(g.hasDP(), true); Assert.assertEquals(g.hasGQ(), true); } }
final GenotypeBuilder gb = new GenotypeBuilder(g.getSampleName(), refAlleles); if ( g.hasDP() ) gb.DP(g.getDP()); if ( g.hasGQ() ) gb.GQ(g.getGQ()); newGTs.add(gb.make());
public static void assertGenotypesAreEqual(final Genotype actual, final Genotype expected) { Assert.assertEquals(actual.getSampleName(), expected.getSampleName(), "Genotype names"); Assert.assertEquals(actual.getAlleles(), expected.getAlleles(), "Genotype alleles"); Assert.assertEquals(actual.getGenotypeString(), expected.getGenotypeString(), "Genotype string"); Assert.assertEquals(actual.getType(), expected.getType(), "Genotype type"); // filters are the same Assert.assertEquals(actual.getFilters(), expected.getFilters(), "Genotype fields"); Assert.assertEquals(actual.isFiltered(), expected.isFiltered(), "Genotype isFiltered"); // inline attributes Assert.assertEquals(actual.getDP(), expected.getDP(), "Genotype dp"); Assert.assertTrue(Arrays.equals(actual.getAD(), expected.getAD())); Assert.assertEquals(actual.getGQ(), expected.getGQ(), "Genotype gq"); Assert.assertEquals(actual.hasPL(), expected.hasPL(), "Genotype hasPL"); Assert.assertEquals(actual.hasAD(), expected.hasAD(), "Genotype hasAD"); Assert.assertEquals(actual.hasGQ(), expected.hasGQ(), "Genotype hasGQ"); Assert.assertEquals(actual.hasDP(), expected.hasDP(), "Genotype hasDP"); Assert.assertEquals(actual.hasLikelihoods(), expected.hasLikelihoods(), "Genotype haslikelihoods"); Assert.assertEquals(actual.getLikelihoodsString(), expected.getLikelihoodsString(), "Genotype getlikelihoodsString"); Assert.assertEquals(actual.getLikelihoods(), expected.getLikelihoods(), "Genotype getLikelihoods"); Assert.assertTrue(Arrays.equals(actual.getPL(), expected.getPL())); Assert.assertEquals(actual.getPhredScaledQual(), expected.getPhredScaledQual(), "Genotype phredScaledQual"); assertAttributesEquals(actual.getExtendedAttributes(), expected.getExtendedAttributes()); Assert.assertEquals(actual.isPhased(), expected.isPhased(), "Genotype isPhased"); Assert.assertEquals(actual.getPloidy(), expected.getPloidy(), "Genotype getPloidy"); }
public static void assertEquals(final Genotype actual, final Genotype expected) { Assert.assertEquals(actual.getSampleName(), expected.getSampleName(), "Genotype names"); Assert.assertEquals(actual.getAlleles(), expected.getAlleles(), "Genotype alleles"); Assert.assertEquals(actual.getGenotypeString(), expected.getGenotypeString(), "Genotype string"); Assert.assertEquals(actual.getType(), expected.getType(), "Genotype type"); // filters are the same Assert.assertEquals(actual.getFilters(), expected.getFilters(), "Genotype fields"); Assert.assertEquals(actual.isFiltered(), expected.isFiltered(), "Genotype isFiltered"); // inline attributes Assert.assertEquals(actual.getDP(), expected.getDP(), "Genotype dp"); Assert.assertTrue(Arrays.equals(actual.getAD(), expected.getAD())); Assert.assertEquals(actual.getGQ(), expected.getGQ(), "Genotype gq"); Assert.assertEquals(actual.hasPL(), expected.hasPL(), "Genotype hasPL"); Assert.assertEquals(actual.hasAD(), expected.hasAD(), "Genotype hasAD"); Assert.assertEquals(actual.hasGQ(), expected.hasGQ(), "Genotype hasGQ"); Assert.assertEquals(actual.hasDP(), expected.hasDP(), "Genotype hasDP"); Assert.assertEquals(actual.hasLikelihoods(), expected.hasLikelihoods(), "Genotype haslikelihoods"); Assert.assertEquals(actual.getLikelihoodsString(), expected.getLikelihoodsString(), "Genotype getlikelihoodsString"); Assert.assertEquals(actual.getLikelihoods(), expected.getLikelihoods(), "Genotype getLikelihoods"); Assert.assertTrue(Arrays.equals(actual.getPL(), expected.getPL())); Assert.assertEquals(actual.getGQ(), expected.getGQ(), "Genotype phredScaledQual"); assertAttributesEquals(actual.getExtendedAttributes(), expected.getExtendedAttributes()); Assert.assertEquals(actual.isPhased(), expected.isPhased(), "Genotype isPhased"); Assert.assertEquals(actual.getPloidy(), expected.getPloidy(), "Genotype getPloidy"); }
Assert.assertTrue(g.hasDP()); Assert.assertEquals(g.getDP(), expectedDP); Assert.assertTrue(g.hasGQ()); Assert.assertTrue(g.hasPL());