Package htsjdk.variant.variantcontext

Examples of htsjdk.variant.variantcontext.Genotype


    static MongoVariantContext createMVC(int allele0, int allele1, String callsetName, VariantContext variantContext, TruthStatus truthStatus, boolean isComplexEvent) {
        List<Allele> alleleList = variantContext.getAlleles();

        MongoGenotype mgt = new MongoGenotype(allele0, allele1);
        Genotype gt = mgt.toGenotype(alleleList);
        MongoVariantContext mvc = MongoVariantContext.create(callsetName, variantContext, truthStatus, gt);
        mvc.setReviewed(true);
        mvc.setChr(chromoNameToStandard(mvc.getChr()));
        mvc.setIsComplexEvent(isComplexEvent);
        mvc.setConfidence(NA12878KnowledgeBase.InputCallsetConfidence.REVIEW.confidence);
View Full Code Here


        //use that data.
        for (String sampleName : variant.getSampleNamesOrderedByName()) {
            boolean isPref = sampleName.equalsIgnoreCase(prefSampleName);
            if (isPref || mutationString == null) {
                mutationString = ParsingUtils.join("/", ParsingUtils.sortList(variant.getAlleles()));
                Genotype genotype = variant.getGenotype(sampleName);
                gtt = genotype.getType();
                if (isPref) break;
            } else {
                //If we have several samples with different mutations, don't know which
                //to pick. Make that obvious to the user
                if (gtt != variant.getGenotype(sampleName).getType()) {
View Full Code Here

            if ( currentBlock != null && ! currentBlock.isContiguous(vc) ) {
                // we've made a non-contiguous step (across interval, onto another chr), so finalize
                emitCurrentBlock();
            }

            final Genotype g = vc.getGenotype(0);
            if ( g.isHomRef() && vc.hasAlternateAllele(GATKVariantContextUtils.NON_REF_SYMBOLIC_ALLELE) && vc.isBiallelic() ) {
                // create bands
                final VariantContext maybeCompletedBand = addHomRefSite(vc, g);
                if ( maybeCompletedBand != null ) underlyingWriter.add(maybeCompletedBand);
            } else {
                // g is variant, so flush the bands and emit vc
View Full Code Here

    }

    @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()));
    }
View Full Code Here

    }

    @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()));
    }
View Full Code Here

        final VariantContextBuilder vcAC = new VariantContextBuilder(root).alleles(Arrays.asList(A, C));
        final VariantContextBuilder vcAG = new VariantContextBuilder(root).alleles(Arrays.asList(A, G));
        final VariantContextBuilder vcACG = new VariantContextBuilder(root).alleles(Arrays.asList(A, C, G));
        final VariantContextBuilder vcAGC = new VariantContextBuilder(root).alleles(Arrays.asList(A, G, C));

        final Genotype gACG = makePL( 0, 1, 2, 3, 4, 5);
        final Genotype gAGC = makePL( 0, 4, 5, 1, 3, 2);
        final Genotype gACcombined = makePL(0, 2, 5);
        final Genotype gACcombined2 = makePL(0, 1, 4);
        final Genotype gAGcombined = makePL(0, 4, 9);

        // biallelic
        tests.add(new Object[]{vcAC.genotypes(gACcombined).make(), Arrays.asList(vcAC.genotypes(gACcombined).make())});

        // tri-allelic
View Full Code Here

                Assert.assertFalse(refModel.hasLog10PError());
                Assert.assertEquals(refModel.getAlternateAlleles().size(), 1);
                Assert.assertEquals(refModel.getAlternateAllele(0), GATKVariantContextUtils.NON_REF_SYMBOLIC_ALLELE);
                Assert.assertTrue(refModel.hasGenotype(sample));

                final Genotype g = refModel.getGenotype(sample);
                Assert.assertTrue(g.hasAD());
                Assert.assertTrue(g.hasDP());
                Assert.assertEquals(g.getDP(), expectedDP);
                Assert.assertTrue(g.hasGQ());
                Assert.assertTrue(g.hasPL());
            }

            final VariantContext vc = call == null ? refModel : call;
            if ( curPos.getStart() == vc.getStart() ) {
                for ( int pos = vc.getStart(); pos <= vc.getEnd(); pos++ ) {
View Full Code Here

        if  (sampleCount == 0)
            return getInstance(defaultPloidy,maximumAltAlleles);

        final GenotypesContext genotypes = variantContext.getGenotypes();

        final Genotype firstGenotype = genotypes.get(0);
        int ploidy = firstGenotype.getPloidy();
        if (ploidy <= 0) ploidy = defaultPloidy;
        for (int i = 1 ; i < sampleCount; i++) {
            final Genotype genotype = genotypes.get(i);
            final int declaredPloidy = genotype.getPloidy();
            final int actualPloidy = declaredPloidy <= 0 ? defaultPloidy : declaredPloidy;
            if (actualPloidy != ploidy) {
                ploidy = AFCalculatorImplementation.UNBOUND_PLOIDY;
                break;
            }
View Full Code Here

                Assert.assertEquals(allSampleVC.getFilters(), onlyHG01879VC.getFilters());
                Assert.assertEquals(allSampleVC.getAlleles(), onlyHG01879VC.getAlleles());
                Assert.assertEquals(allSampleVC.getAttributes(), onlyHG01879VC.getAttributes());
                Assert.assertEquals(allSampleVC.getPhredScaledQual(), onlyHG01879VC.getPhredScaledQual());

                final Genotype allG = allSampleVC.getGenotype("HG01879");
                final Genotype onlyG = onlyHG01879VC.getGenotype("HG01879");
                Assert.assertEquals(allG.getAD(), onlyG.getAD());
                Assert.assertEquals(allG.getDP(), onlyG.getDP());
                Assert.assertEquals(allG.getAlleles(), onlyG.getAlleles());
                Assert.assertEquals(allG.getPL(), onlyG.getPL());
                Assert.assertEquals(allG.toString(), onlyG.toString());
            }
        }
    }
View Full Code Here


    private void updateViolations(String familyId, String motherId, String fatherId, String childId, VariantContext vc){

            int count;
            Genotype gMom = vc.getGenotype(motherId);
            Genotype gDad = vc.getGenotype(fatherId);
            Genotype gChild = vc.getGenotype(childId);

            if (gMom == null || gDad == null || gChild == null){
                if(abortOnSampleNotFound)
                    throw new IllegalArgumentException(String.format("Variant %s:%d: Missing genotypes for family %s: mom=%s dad=%s family=%s", vc.getChr(), vc.getStart(), familyId, motherId, fatherId, childId));
                else
                    return;
            }
            //Count No calls
            if(allCalledOnly && (!gMom.isCalled() || !gDad.isCalled() || !gChild.isCalled())){
                nocall++;
            }
            else if (!gMom.isCalled() && !gDad.isCalled() || !gChild.isCalled()){
                nocall++;
            }
            //Count lowQual. Note that if min quality is set to 0, even values with no quality associated are returned
            else if (minGenotypeQuality>0 && (gMom.getPhredScaledQual()   < minGenotypeQuality ||
                gDad.getPhredScaledQual()   < minGenotypeQuality ||
                gChild.getPhredScaledQual() < minGenotypeQuality )) {
                lowQual++;
            }
            else{
                //Count all families per loci called
                familyCalled++;
                //If the family is all homref, not too interesting
                if(!(gMom.isHomRef() && gDad.isHomRef() && gChild.isHomRef()))
                {
                    varFamilyCalled++;
                    if(isViolation(gMom, gDad, gChild)){
                        violationFamilies.add(familyId);
                        violations_total++;
                    }
                }
                count = inheritance.get(gMom.getType()).get(gDad.getType()).get(gChild.getType());
                inheritance.get(gMom.getType()).get(gDad.getType()).put(gChild.getType(),count+1);

            }
    }
View Full Code Here

TOP

Related Classes of htsjdk.variant.variantcontext.Genotype

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.