/** * Does the PL field have a value? * @return true if there's a PL field value */ public boolean hasPL() { return getPL() != null; }
/** * @return Returns true if this Genotype has PL field values */ public boolean hasLikelihoods() { return getPL() != null; }
/** * @return Returns true if this Genotype has PL field values */ public boolean hasLikelihoods() { return getPL() != null; }
/** * Does the PL field have a value? * @return true if there's a PL field value */ public boolean hasPL() { return getPL() != null; }
/** * @return Returns true if this Genotype has PL field values */ @Ensures("(result && getLikelihoods() != null) || (! result && getLikelihoods() == null)") public boolean hasLikelihoods() { return getPL() != null; }
/** * Does the PL field have a value? * @return true if there's a PL field value */ @Ensures("(result == false && getPL() == null) || (result == true && getPL() != null)") public boolean hasPL() { return getPL() != null; }
/** * Returns the GenotypesLikelihoods data associated with this Genotype, or null if missing * @return null or a GenotypesLikelihood object for this sample's PL field */ public GenotypeLikelihoods getLikelihoods() { return hasLikelihoods() ? GenotypeLikelihoods.fromPLs(getPL()) : null; }
/** * Returns the GenotypesLikelihoods data associated with this Genotype, or null if missing * @return null or a GenotypesLikelihood object for this sample's PL field */ public GenotypeLikelihoods getLikelihoods() { return hasLikelihoods() ? GenotypeLikelihoods.fromPLs(getPL()) : null; }
private Genotype makeGwithPLs(String sample, Allele a1, Allele a2, double[] pls) { Genotype gt = new GenotypeBuilder(sample, Arrays.asList(a1, a2)).PL(pls).make(); if (pls != null && pls.length > 0) { Assert.assertNotNull(gt.getPL()); Assert.assertTrue(gt.getPL().length > 0); for (int i : gt.getPL()) { Assert.assertTrue(i >= 0); } Assert.assertNotEquals(Arrays.toString(gt.getPL()), "[0]"); } return gt; }
private Genotype makeGwithPLs(String sample, Allele a1, Allele a2, double[] pls) { Genotype gt = new GenotypeBuilder(sample, Arrays.asList(a1, a2)).PL(pls).make(); if ( pls != null && pls.length > 0 ) { Assert.assertNotNull(gt.getPL()); Assert.assertTrue(gt.getPL().length > 0); for ( int i : gt.getPL() ) { Assert.assertTrue(i >= 0); } Assert.assertNotEquals(Arrays.toString(gt.getPL()),"[0]"); } return gt; }
/** * Returns the GenotypesLikelihoods data associated with this Genotype, or null if missing * @return null or a GenotypesLikelihood object for this sample's PL field */ @Ensures("(hasLikelihoods() && result != null) || (! hasLikelihoods() && result == null)") public GenotypeLikelihoods getLikelihoods() { return hasLikelihoods() ? GenotypeLikelihoods.fromPLs(getPL()) : null; }
@Test(enabled = true, dataProvider = "TestCombineGLs") public void testCombineGLsPrecise(final int altIndex, final int nAlts, final Genotype testg, final Genotype expected) { final IndependentAllelesDiploidExactAFCalculator calc = (IndependentAllelesDiploidExactAFCalculator) AFCalculatorImplementation.EXACT_INDEPENDENT.newInstance(); final Genotype combined = calc.combineGLsPrecise(testg, altIndex, nAlts); Assert.assertEquals(combined.getPL(), expected.getPL(), "Combined PLs " + Utils.join(",", combined.getPL()) + " != expected " + Utils.join(",", expected.getPL())); }
@Test(enabled = true, dataProvider = "TestCombineGLs") public void testCombinePrecise(final int altIndex, final int nAlts, final Genotype testg, final Genotype expected) { final IndependentAllelesDiploidExactAFCalculator calc = (IndependentAllelesDiploidExactAFCalculator) AFCalculatorImplementation.EXACT_INDEPENDENT.newInstance(); final Genotype combined = calc.combineGLsPrecise(testg, altIndex, nAlts); Assert.assertEquals(combined.getPL(), expected.getPL(), "Combined PLs " + Utils.join(",", combined.getPL()) + " != expected " + Utils.join(",", expected.getPL())); }
public PNonRefData scale(final int scaleFactor) { if ( canScale ) { final int[] PLs = new int[g.getPL().length]; for ( int i = 0; i < PLs.length; i++ ) PLs[i] = g.getPL()[i] * ((int)Math.log10(scaleFactor)+1); final Genotype scaledG = new GenotypeBuilder(g).PL(PLs).make(); final double scaledPNonRef = pNonRef < 0.5 ? pNonRef / scaleFactor : 1 - ((1-pNonRef) / scaleFactor); return new PNonRefData(vc, scaledG, scaledPNonRef, tolerance, true); } else { return this; } } }
@Test public void testGLnotOverridePL() { final VariantContext variant; try (final VCFFileReader reader = new VCFFileReader( new File("src/test/resources/htsjdk/variant/test_withGLandPL.vcf"), false)) { variant = reader.iterator().next(); } Assert.assertEquals(variant.getGenotype(0).getPL(), new int[]{45, 0, 50}); } }
public static void assertEquals(final GenotypesContext actual, final GenotypesContext expected) { if (expected == null) { Assert.assertNull(actual); return; } Assert.assertEquals(actual.getSampleNamesOrderedByName(), expected.getSampleNamesOrderedByName(), "Sample names differ"); for (final String name : expected.getSampleNamesOrderedByName()) { Assert.assertEquals(actual.get(name).getAlleles(), expected.get(name).getAlleles(), "Alleles differ for sample " + name); Assert.assertEquals(actual.get(name).getAD(), expected.get(name).getAD()); Assert.assertEquals(actual.get(name).getPL(), expected.get(name).getPL()); } }
@Test private void testInputIndel() { VariantContext inputIndel = makeVC("1", Arrays.asList(Aref, ATC), makeG("s1",ATC,ATC,40,20,0), makeG("s2",Aref,ATC,18,0,24), makeG("s3",Aref,ATC,22,0,12)); List<VariantContext> supplTest1 = new ArrayList<>(1); supplTest1.add(new VariantContextBuilder(makeVC("2",Arrays.asList(Aref,T,C))).attribute(GATKVCFConstants.MLE_ALLELE_COUNT_KEY,Arrays.asList(5,4)).attribute(VCFConstants.ALLELE_NUMBER_KEY,10).make()); VariantContext test1result = PosteriorLikelihoodsUtils.calculatePosteriorGLs(inputIndel,supplTest1,0,0.001,true,false,false); System.out.println(test1result); int[] GPs = _mleparse( (List<Integer>)test1result.getGenotype(0).getAnyAttribute(GATKVCFConstants.PHRED_SCALED_POSTERIORS_KEY)); int[] PLs = test1result.getGenotype(0).getPL(); Assert.assertEquals(PLs,GPs); }
public String toString() { return String.format("[%s %s%s%s%s%s%s%s]", getSampleName(), getGenotypeString(false), toStringIfExists(VCFConstants.GENOTYPE_QUALITY_KEY, getGQ()), toStringIfExists(VCFConstants.DEPTH_KEY, getDP()), toStringIfExists(VCFConstants.GENOTYPE_ALLELE_DEPTHS, getAD()), toStringIfExists(VCFConstants.GENOTYPE_PL_KEY, getPL()), toStringIfExists(VCFConstants.GENOTYPE_FILTER_KEY, getFilters()), sortedString(getExtendedAttributes())); }
public String toString() { return String.format("[%s %s%s%s%s%s%s%s]", getSampleName(), getGenotypeString(false), toStringIfExists(VCFConstants.GENOTYPE_QUALITY_KEY, getGQ()), toStringIfExists(VCFConstants.DEPTH_KEY, getDP()), toStringIfExists(VCFConstants.GENOTYPE_ALLELE_DEPTHS, getAD()), toStringIfExists(VCFConstants.GENOTYPE_PL_KEY, getPL()), toStringIfExists(VCFConstants.GENOTYPE_FILTER_KEY, getFilters()), sortedString(getExtendedAttributes())); }
public String toString() { return String.format("[%s %s%s%s%s%s%s%s]", getSampleName(), getGenotypeString(false), toStringIfExists(VCFConstants.GENOTYPE_QUALITY_KEY, getGQ()), toStringIfExists(VCFConstants.DEPTH_KEY, getDP()), toStringIfExists(VCFConstants.GENOTYPE_ALLELE_DEPTHS, getAD()), toStringIfExists(VCFConstants.GENOTYPE_PL_KEY, getPL()), toStringIfExists(VCFConstants.GENOTYPE_FILTER_KEY, getFilters()), sortedString(getExtendedAttributes())); }