Package htsjdk.variant.variantcontext

Examples of htsjdk.variant.variantcontext.VariantContext


    public static void assertVariantContextStreamsAreEqual(final Iterable<VariantContext> actual, final Iterable<VariantContext> expected) {
        final Iterator<VariantContext> actualIT = actual.iterator();
        final Iterator<VariantContext> expectedIT = expected.iterator();

        while ( expectedIT.hasNext() ) {
            final VariantContext expectedVC = expectedIT.next();
            if ( expectedVC == null )
                continue;

            VariantContext actualVC;
            do {
                Assert.assertTrue(actualIT.hasNext(), "Too few records found in actual");
                actualVC = actualIT.next();
            } while ( actualIT.hasNext() && actualVC == null );
View Full Code Here


        Assert.assertEquals(loc.getStop(), feature.getEnd());
    }

    @Test
    public void testCreationFromVariantContext() {
        final VariantContext feature = new VariantContextBuilder("x", "chr1", 1, 5, Arrays.asList(Allele.create("AAAAA", true))).make();
        final GenomeLoc loc = genomeLocParser.createGenomeLoc(feature);
        Assert.assertEquals(loc.getContig(), feature.getChr());
        Assert.assertEquals(loc.getStart(), feature.getStart());
        Assert.assertEquals(loc.getStop(), feature.getEnd());
    }
View Full Code Here

     * @return
     */
    public Integer map( RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context ) {
        if( tracker != null ) {
            GenomeLoc loc = context.getLocation();
            VariantContext vc = tracker.getFirstValue(variants, loc);

            if ( ProduceBeagleInput.canBeOutputToBeagle(vc) ) {
                // do we want to hold back this site?
                boolean makeMissing = dropSite(vc);

View Full Code Here

    public VariantContext map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
        if ( tracker == null )
            return null;

        VariantContext vc = tracker.getFirstValue(variantCollection.variants, ref.getLocus());
        // ignore places where we don't have a variant
        if ( vc == null )
            return null;

        if ( sampleNames == null )
            sampleNames = new TreeSet<String>(vc.getSampleNames());       

        return addVariantInformationToCall(vc);
    }
View Full Code Here

            HashMap<String, Collection<VariantContext>> mapping = new HashMap<String, Collection<VariantContext>>();

            for (VariantContext vc : tracker.getValues(track, ref.getLocus())) {

                // First, filter the VariantContext to represent only the samples for evaluation
                VariantContext vcsub = vc;

                if (subsetBySample && vc.hasGenotypes())
                    vcsub = getSubsetOfVariantContext(vc, variantEvalWalker.getSampleNamesForEvaluation());

                if ((byFilter || !vcsub.isFiltered())) {
                    addMapping(mapping, VariantEval.getAllSampleName(), vcsub);
                }

                // Now, if stratifying, split the subsetted vc per sample and add each as a new context
                if (vc.hasGenotypes() && trackPerSample) {
                    for (String sampleName : variantEvalWalker.getSampleNamesForEvaluation()) {
                        VariantContext samplevc = getSubsetOfVariantContext(vc, sampleName);

                        if (byFilter || !samplevc.isFiltered()) {
                            addMapping(mapping, sampleName, samplevc);
                        }
                    }
                }
            }
View Full Code Here

     * @return a VariantContext (may be == to vcToAnnotate) with updated overlaps update fields value
     */
    public VariantContext annotateOverlaps(final RefMetaDataTracker tracker, final VariantContext vcToAnnotate) {
        if ( overlapBindings.isEmpty() ) return vcToAnnotate;

        VariantContext annotated = vcToAnnotate;
        final GenomeLoc loc = getLoc(vcToAnnotate);
        for ( final Map.Entry<RodBinding<VariantContext>, String> overlapBinding : overlapBindings.entrySet() ) {
            annotated = annotateOverlap(tracker.getValues(overlapBinding.getKey(), loc), overlapBinding.getValue(), annotated);
        }

View Full Code Here

            // re-compute chromosome counts
            VariantContextUtils.calculateChromosomeCounts(builder, false);

            if ( minimalVCF )
                GATKVariantContextUtils.pruneVariantContext(builder, Arrays.asList(SET_KEY));
            final VariantContext vc = builder.make();
            if( !EXCLUDE_NON_VARIANTS || vc.isPolymorphicInSamples() )
                vcfWriter.add(builder.make());
        }

        return vcs.isEmpty() ? 0 : 1;
    }
View Full Code Here

    private void convertAndWrite(VariantContext vc, ReferenceContext ref) {

        final Interval fromInterval = new Interval(vc.getChr(), vc.getStart(), vc.getStart(), false, String.format("%s:%d", vc.getChr(), vc.getStart()));
        final int length = vc.getEnd() - vc.getStart();
        final Interval toInterval = liftOver.liftOver(fromInterval);
        VariantContext originalVC = vc;

        if ( toInterval != null ) {
            // check whether the strand flips, and if so reverse complement everything
            if ( fromInterval.isPositiveStrand() != toInterval.isPositiveStrand() && vc.isPointEvent() ) {
                vc = GATKVariantContextUtils.reverseComplement(vc);
            }

            vc = new VariantContextBuilder(vc).loc(toInterval.getSequence(), toInterval.getStart(), toInterval.getStart() + length).make();

            if ( RECORD_ORIGINAL_LOCATION ) {
                vc = new VariantContextBuilder(vc)
                        .attribute("OriginalChr", fromInterval.getSequence())
                        .attribute("OriginalStart", fromInterval.getStart()).make();
            }

            if ( originalVC.isSNP() && originalVC.isBiallelic() && GATKVariantContextUtils.getSNPSubstitutionType(originalVC) != GATKVariantContextUtils.getSNPSubstitutionType(vc) ) {
                logger.warn(String.format("VCF at %s / %d => %s / %d is switching substitution type %s/%s to %s/%s",
                        originalVC.getChr(), originalVC.getStart(), vc.getChr(), vc.getStart(),
                        originalVC.getReference(), originalVC.getAlternateAllele(0), vc.getReference(), vc.getAlternateAllele(0)));
            }

            writer.add(vc);
            successfulIntervals++;
        } else {
View Full Code Here

        List<VariantContext> snpEffRecords = tracker.getValues(snpEffRodBinding, ref.getLocus());

        // Within this set, look for a SnpEff record whose ref/alt alleles match the record to annotate.
        // If there is more than one such record, we only need to pick the first one, since the biological
        // effects will be the same across all such records:
        VariantContext matchingRecord = getMatchingSnpEffRecord(snpEffRecords, vc);
        if ( matchingRecord == null ) {
            return null;
        }

        // Parse the SnpEff INFO field annotation from the matching record into individual effect objects:
View Full Code Here

                            // no sample stratification for comps
                            final HashMap<String, Collection<VariantContext>> compSetHash = compVCs.get(compRod);
                            final Collection<VariantContext> compSet = (compSetHash == null || compSetHash.size() == 0) ? Collections.<VariantContext>emptyList() : compVCs.get(compRod).values().iterator().next();

                            // find the comp
                            final VariantContext comp = findMatchingComp(eval, compSet);

                            for ( EvaluationContext nec : getEvaluationContexts(tracker, ref, eval, evalRod.getName(), comp, compRod.getName(), sampleName) ) {

                                // eval against the comp
                                synchronized (nec) {
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.