Package htsjdk.variant.variantcontext

Examples of htsjdk.variant.variantcontext.VariantContext


        final File gVCF = executeTest("testOneHasAltAndTwoHasRefBlock", spec).first.get(0);
        final List<VariantContext> allVCs = GATKVCFUtils.readVCF(gVCF).getSecond();

        Assert.assertEquals(allVCs.size(), 1);

        final VariantContext first = allVCs.get(0);
        Assert.assertEquals(first.getStart(), 69635);
        Assert.assertEquals(first.getEnd(), 69635);
        Assert.assertEquals(first.getNAlleles(), 3);
        Assert.assertEquals(first.getGenotypes().size(), 2);
    }
View Full Code Here


        final File gVCF = executeTest("testOneHasDeletionAndTwoHasRefBlock", spec).first.get(0);
        final List<VariantContext> allVCs = GATKVCFUtils.readVCF(gVCF).getSecond();

        Assert.assertEquals(allVCs.size(), 3);

        final VariantContext first = allVCs.get(0);
        Assert.assertEquals(first.getStart(), 69772);
        Assert.assertEquals(first.getEnd(), 69776);
        Assert.assertEquals(first.getNAlleles(), 3);
        Assert.assertEquals(first.getGenotypes().size(), 2);

        final VariantContext second = allVCs.get(1);
        Assert.assertEquals(second.getStart(), 69773);
        Assert.assertEquals(second.getEnd(), 69774);
        Assert.assertEquals(second.getGenotypes().size(), 2);

        final VariantContext third = allVCs.get(2);
        Assert.assertEquals(third.getStart(), 69775);
        Assert.assertEquals(third.getEnd(), 69783);
        Assert.assertEquals(third.getGenotypes().size(), 2);
    }
View Full Code Here

            for (int len = 1; len <=numAltAlleles; len++) {
                // add alt allele of length len+1
                alleles.add(Allele.create(Utils.dupString('A', len + 1), false));
            }
            final VariantContext vc = new VariantContextBuilder("test", "chr1", 1000, 1000, alleles).make();
            final boolean result = ugEngine.hasTooManyAlternativeAlleles(vc);
            Assert.assertTrue(result == (vc.getNAlleles() > GenotypeLikelihoods.MAX_ALT_ALLELES_THAT_CAN_BE_GENOTYPED));
        }
    }
View Full Code Here

    private void writeAndPurgeAllEqualVariants(final List<VariantContext> sourceVCs1, final List<VariantContext> sourceVCs2, final String status) {

        int currentIndex1 = 0, currentIndex2 = 0;
        int size1 = sourceVCs1.size(), size2 = sourceVCs2.size();
        VariantContext current1 = (currentIndex1 < size1 ? sourceVCs1.get(currentIndex1): null);
        VariantContext current2 = (currentIndex2 < size2 ? sourceVCs2.get(currentIndex2): null);

        while ( current1 != null && current2 != null ) {

            final GenomeLoc loc1 = getToolkit().getGenomeLocParser().createGenomeLoc(current1);
            final GenomeLoc loc2 = getToolkit().getGenomeLocParser().createGenomeLoc(current2);

            if ( loc1.equals(loc2) ||
                    (loc1.getStart() == loc2.getStart() && (current1.getAlternateAlleles().size() > 1 || current2.getAlternateAlleles().size() > 1)) ) {
                // test the alleles
                if ( determineAndWriteOverlap(current1, current2, status) ) {
                    sourceVCs1.remove(currentIndex1);
                    sourceVCs2.remove(currentIndex2);
                    size1--;
View Full Code Here

    }

    private void writeDifferences(final List<VariantContext> source1Alleles, final List<VariantContext> source2Alleles) {
        int currentIndex1 = 0, currentIndex2 = 0;
        final int size1 = source1Alleles.size(), size2 = source2Alleles.size();
        VariantContext current1 = source1Alleles.get(0);
        VariantContext current2 = source2Alleles.get(0);

        while ( currentIndex1 < size1 || currentIndex2 < size2 ) {
            if ( current1 == null ) {
                writeOne(current2, source2, null);
                currentIndex2++;
                current2 = (currentIndex2 < size2 ? source2Alleles.get(currentIndex2): null);
            } else if ( current2 == null ) {
                writeOne(current1, source1, null);
                currentIndex1++;
                current1 = (currentIndex1 < size1 ? source1Alleles.get(currentIndex1): null);
            } else {

                final GenomeLoc loc1 = getToolkit().getGenomeLocParser().createGenomeLoc(current1);
                final GenomeLoc loc2 = getToolkit().getGenomeLocParser().createGenomeLoc(current2);

                if ( loc1.getStart() == loc2.getStart() || loc1.overlapsP(loc2) ) {
                    String status;
                    if ( loc1.getStart() == loc2.getStart() ) {
                        final String allele1 = current1.getAlternateAllele(0).getBaseString();
                        final String allele2 = current2.getAlternateAllele(0).getBaseString();
                        if ( allele1.indexOf(allele2) != -1 || allele2.indexOf(allele1) != -1 )
                            status = ONE_ALLELE_SUBSET_OF_OTHER_STATUS;
                        else
                            status = SAME_START_DIFFERENT_ALLELES_STATUS;
                    } else {
View Full Code Here

        codecAnn.readHeader(lineIteratorAnn);

        while( lineIterator.hasNext() && lineIteratorAnn.hasNext() ) {
            final String line = lineIterator.next();
            Assert.assertFalse(line == null);
            final VariantContext vc = codec.decode(line);

            final String lineAnn = lineIteratorAnn.next();
            Assert.assertFalse(lineAnn == null);
            final VariantContext vcAnn = codecAnn.decode(lineAnn);

            Assert.assertTrue(vc.hasAttribute("FS"));
            Assert.assertTrue(vcAnn.hasAttribute("FS"));
            Assert.assertEquals(vc.getAttributeAsDouble("FS", 0.0), vcAnn.getAttributeAsDouble("FS", -1.0));
        }

        Assert.assertFalse(lineIterator.hasNext());
        Assert.assertFalse(lineIteratorAnn.hasNext());
    }
View Full Code Here

        codecAnn.readHeader(lineIteratorAnn);

        while( lineIterator.hasNext() && lineIteratorAnn.hasNext() ) {
            final String line = lineIterator.next();
            Assert.assertFalse(line == null);
            final VariantContext vc = codec.decode(line);

            final String lineAnn = lineIteratorAnn.next();
            Assert.assertFalse(lineAnn == null);
            final VariantContext vcAnn = codecAnn.decode(lineAnn);

      Assert.assertTrue(vc.hasAttribute("QD"));
      Assert.assertTrue(vcAnn.hasAttribute("QD"));
        }

        Assert.assertFalse(lineIterator.hasNext());
        Assert.assertFalse(lineIteratorAnn.hasNext());
    }
View Full Code Here

        final File onlyHG01879VCF = executeTest("testOnlyEmitSample", onlyHG01879).first.get(0);
        final List<VariantContext> onlyHG01879VCs = GATKVCFUtils.readVCF(onlyHG01879VCF).getSecond();

        Assert.assertEquals(allSampleVCs.size(), onlyHG01879VCs.size());
        for ( int i = 0; i < allSampleVCs.size(); i++ ) {
            final VariantContext allSampleVC = allSampleVCs.get(i);
            final VariantContext onlyHG01879VC = onlyHG01879VCs.get(i);

            if ( allSampleVC == null ) {
                Assert.assertNull(onlyHG01879VC);
            } else {
                Assert.assertNotNull(onlyHG01879VC);

                Assert.assertTrue(allSampleVC.getGenotypes().size() > 1, "All samples should have had more than 1 genotype, but didn't");
                Assert.assertEquals(onlyHG01879VC.getGenotypes().size(), 1, "Should have found a single sample genotype, but didn't");
                Assert.assertEquals(onlyHG01879VC.hasGenotype("HG01879"), true);

                Assert.assertEquals(allSampleVC.getStart(), onlyHG01879VC.getStart());
                Assert.assertEquals(allSampleVC.getChr(), onlyHG01879VC.getChr());
                Assert.assertEquals(allSampleVC.getEnd(), onlyHG01879VC.getEnd());
                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 initialize(StratifiedEvalTestProvider cfg) {
        VEwalker.createStratificationStates(cfg.stratificationObjects, cfg.evaluationObjects);

        final RefMetaDataTracker tracker = new RefMetaDataTracker();
        final ReferenceContext ref = null;
        final VariantContext comp = null;
        final String compName = null, sampleName = null;

        // increment eval counts for each stratification of divisors of i from from 1...maxI
        for ( int i = 1; i <= cfg.maxI; i++ ) {
            final String evalName = String.valueOf(i); // terrible hack to stratify by divisor
View Full Code Here

        // We only need to check if current vc if polymorphic in that set of samples

        if ( samples == null || samples.isEmpty() )
            return true;

        VariantContext subContext =  vc.subContextFromSamples(samples);
        if ( subContext.isPolymorphicInSamples() ) {
            return true;
        }

        return false;
    }
View Full Code Here

TOP

Related Classes of htsjdk.variant.variantcontext.VariantContext

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.