Package htsjdk.variant.variantcontext

Examples of htsjdk.variant.variantcontext.VariantContext


    public boolean selectSiteInSamples(VariantContext vc) {
        if ( samples == null || samples.isEmpty() )
            return true;
        // want to include a site in the given samples if it is *likely* to be variant (via the EXACT model)
        // first subset to the samples
        VariantContext subContext = vc.subContextFromSamples(samples);

        if ( ! subContext.isPolymorphicInSamples() )
            return false;

        // now check to see (using EXACT model) whether this should be variant
        // do we want to apply a prior? maybe user-spec?
        if ( flatPriors == null ) {
View Full Code Here


                perReadAlleleLikelihoodMap.clear();
                final Map<String, AlignmentContext> stratifiedContexts = getFilteredAndStratifiedContexts(refContext, rawContext, model);
                if ( stratifiedContexts == null )
                    results.add(defaultResult);
                else {
                    final VariantContext vc = calculateLikelihoods(tracker, refContext, stratifiedContexts, AlignmentContextUtils.ReadOrientation.COMPLETE, null, true, model, perReadAlleleLikelihoodMap);
                    if ( vc != null )
                        results.add(calculateGenotypes(tracker, refContext, rawContext, stratifiedContexts, vc, model, true, perReadAlleleLikelihoodMap));
// todo - uncomment if we want to also emit a null ref call (with no QUAL) if there's no evidence for REF and if EMIT_ALL_SITES is set
//                    else if (UAC.OutputMode == OUTPUT_MODE.EMIT_ALL_SITES)
//                        results.add(generateEmptyContext(tracker, refContext, null, rawContext));
View Full Code Here

                                                    final Map<String, AlignmentContext> stratifiedContexts,
                                                    final RefMetaDataTracker tracker,
                                                    final ReferenceContext refContext, List<Allele> allAllelesToUse,
                                                    final GenotypeLikelihoodsCalculationModel.Model model,
                                                    final Map<String, PerReadAlleleLikelihoodMap> perReadAlleleLikelihoodMap) {
        final VariantContext vc = calculateLikelihoods(tracker, refContext, stratifiedContexts,orientation,
                allAllelesToUse, false, model, perReadAlleleLikelihoodMap);
        final int defaultPloidy = configuration.genotypeArgs.samplePloidy;
        final int maxAltAlleles = configuration.genotypeArgs.MAX_ALTERNATE_ALLELES;
        return afCalculatorProvider.getInstance(vc, defaultPloidy, maxAltAlleles).getLog10PNonRef(vc, defaultPloidy, maxAltAlleles, getAlleleFrequencyPriors(vc,defaultPloidy,model));
    }
View Full Code Here

        if ( modelsToUse.size() != 2 )
            throw new IllegalStateException("GGA mode assumes that we have initialized both the SNP and indel models but found " + modelsToUse);

        // if we're genotyping given alleles then we need to choose the model corresponding to the variant type requested
        final VariantContext vcInput = GenotypingGivenAllelesUtils.composeGivenAllelesVariantContextFromRod(tracker, rawContext.getLocation(), false, logger, configuration.alleles);

        if ( vcInput == null ) {
            return Collections.emptyList(); // no work to be done
        } else if ( vcInput.isSNP() )  {
            return Collections.singletonList(modelsToUse.get(SNP_MODEL));
        } else if ( vcInput.isIndel() || vcInput.isMixed() ) {
            return Collections.singletonList(modelsToUse.get(INDEL_MODEL));
        } else {
            return Collections.emptyList(); // No support for other types yet
        }
    }
View Full Code Here

    protected void addVC(final VariantContext vc, final boolean merge) {
        if ( vc == null ) throw new IllegalArgumentException("vc cannot be null");

        if ( containsKey(vc.getStart()) ) {
            if ( merge ) {
                final VariantContext prev = get(vc.getStart());
                put(vc.getStart(), makeBlock(prev, vc));
            } else {
                throw new IllegalStateException("Will not merge previously bound variant contexts as merge is false at " + vc);
            }
        } else
View Full Code Here

                ref = vc2.getReference();
                alt = vc1.getAlternateAllele(0);
                b.stop(vc2.getEnd());
            }
        } else {
            final VariantContext insertion = vc1.isSimpleInsertion() ? vc1 : vc2;
            final VariantContext deletion  = vc1.isSimpleInsertion() ? vc2 : vc1;
            ref = deletion.getReference();
            alt = insertion.getAlternateAllele(0);
            b.stop(deletion.getEnd());
        }

        return b.alleles(Arrays.asList(ref, alt)).make();
    }
View Full Code Here

    protected boolean updateToBlockSubstitutionIfBetter(final List<VariantContext> neighbors) {
        if (neighbors.size() < MIN_NUMBER_OF_EVENTS_TO_COMBINE_INTO_BLOCK_SUBSTITUTION)
            return false;
        // TODO -- need more tests to decide if this is really so good

        final VariantContext first = neighbors.get(0);
        final int refStartOffset = first.getStart() - refLoc.getStart();
        final int refEndOffset = neighbors.get(neighbors.size() - 1).getEnd() - refLoc.getStart();

        final byte[] refBases = Arrays.copyOfRange(ref, refStartOffset, refEndOffset + 1);
        final byte[] hapBases = AlignmentUtils.getBasesCoveringRefInterval(refStartOffset, refEndOffset, haplotype.getBases(), haplotype.getAlignmentStartHapwrtRef(), haplotype.getCigar());

        final VariantContextBuilder builder = new VariantContextBuilder(first);
        builder.stop(first.getStart() + refBases.length - 1);
        builder.alleles(Arrays.asList(Allele.create(refBases, true), Allele.create(hapBases)));
        final VariantContext block = builder.make();

        // remove all merged events
        for ( final VariantContext merged : neighbors ) {
            if ( remove(merged.getStart()) == null )
                throw new IllegalArgumentException("Expected to remove variant context from the event map but remove said there wasn't any element there: " + merged);
View Full Code Here

    @Requires({"leftMost != null", "maxBPBetweenEvents >= 0"})
    @Ensures({"result != null", "! result.isEmpty()"})
    protected List<VariantContext> getNeighborhood(final VariantContext leftMost, final int maxBPBetweenEvents) {
        final List<VariantContext> neighbors = new LinkedList<VariantContext>();

        VariantContext left = leftMost;
        for ( final VariantContext vc : getVariantContexts() ) {
            if ( vc.getStart() < leftMost.getStart() )
                continue;

            if ( vc.getStart() - left.getEnd() < maxBPBetweenEvents ) {
                // this vc is within max distance to the end of the left event, so accumulate it
                neighbors.add(vc);
                left = vc;
            }
        }
View Full Code Here

        if ( otherSize > 0 && otherSize != size ) {
            final Allele otherAlt = Allele.create(op.equals("D") ? Utils.dupBytes((byte) 'A', size-otherSize+1) : Utils.dupBytes((byte) 'A', otherSize+1), false);
            alleles.add(otherAlt);
        }

        final VariantContext vc = new VariantContextBuilder("test", "1", 10, 10 + ref.length() - 1, alleles).make();

        boolean hasTooLargeIndel = SelectVariants.containsIndelLargerThan(vc, max);
        Assert.assertEquals(hasTooLargeIndel, size > max);
    }
View Full Code Here

    public void testIndelAtEndOfContig() {

        final List<Allele> alleles = new ArrayList<>(2);
        alleles.add(Allele.create("AAAAA", true));
        alleles.add(Allele.create("A", false));
        final VariantContext vc = new VariantContextBuilder("test", "1", 10, 14, alleles).make();

        final FilterLiftedVariants filter = new FilterLiftedVariants();

        Assert.assertFalse(filter.filterOrWrite(new byte[]{'A'}, vc));
    }
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.