Package htsjdk.variant.variantcontext

Examples of htsjdk.variant.variantcontext.Allele


    @Test(dataProvider = "AssembleIntervalsWithVariantData")
    public void testAssembleRefAndInsertion(final ReadThreadingAssembler assembler, final GenomeLoc loc, final int nReadsToUse, final int variantSite) {
        final byte[] refBases = seq.getSubsequenceAt(loc.getContig(), loc.getStart(), loc.getStop()).getBases();
        for ( int insertionLength = 1; insertionLength < 10; insertionLength++ ) {
            final Allele refBase = Allele.create(refBases[variantSite], false);
            final Allele altBase = Allele.create(new String(refBases).substring(variantSite, variantSite + insertionLength + 1), true);
            final VariantContextBuilder vcb = new VariantContextBuilder("x", loc.getContig(), variantSite, variantSite + insertionLength, Arrays.asList(refBase, altBase));
            testAssemblyWithVariant(assembler, refBases, loc, nReadsToUse, vcb.make());
        }
    }
View Full Code Here


            reads.add(read);
        }

        // create a pileup with all reads having offset 0
        final ReadBackedPileup pileup = new ReadBackedPileupImpl(myLocation, reads, 0);
        Allele base_A = Allele.create(BaseUtils.Base.A.base);
        Allele base_C = Allele.create(BaseUtils.Base.C.base);
        Allele base_T = Allele.create(BaseUtils.Base.T.base);

        PerReadAlleleLikelihoodMap perReadAlleleLikelihoodMap = new PerReadAlleleLikelihoodMap();
        for ( final PileupElement e : pileup ) {
            for ( final Allele allele : Arrays.asList(base_A,base_C,base_T) ) {
                Double likelihood = allele == base_A ? -0.04 : -3.0;
View Full Code Here

            reads.add(read);
        }

        // create a pileup with all reads having offset 0
        final ReadBackedPileup pileup = new ReadBackedPileupImpl(myLocation, reads, 0);
        Allele base_A = Allele.create(BaseUtils.Base.A.base);
        Allele base_C = Allele.create(BaseUtils.Base.C.base);
        Allele base_T = Allele.create(BaseUtils.Base.T.base);

        PerReadAlleleLikelihoodMap perReadAlleleLikelihoodMap = new PerReadAlleleLikelihoodMap();
        int idx = 0;
        for ( final PileupElement e : pileup ) {
            for ( final Allele allele : Arrays.asList(base_A,base_C,base_T) ) {
View Full Code Here

            final double likelihood = bad ? -100.0 : 0.0;

            final byte[] bases = Utils.dupBytes((byte)'A', readLen);
            final byte[] quals = Utils.dupBytes((byte) 40, readLen);

            final Allele allele = Allele.create(Utils.dupString("A", readI+1));

            final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(bases, quals, readLen + "M");
            read.setReadName("readName" + readI);
            map.add(read, allele, likelihood);
            (bad ? badReads : goodReads).add(read);
View Full Code Here

    @DataProvider(name = "MostLikelyAlleleData")
    public Object[][] makeMostLikelyAlleleData() {
        List<Object[]> tests = new ArrayList<Object[]>();

        final Allele a = Allele.create("A");
        final Allele c = Allele.create("C");
        final Allele g = Allele.create("G");

        tests.add(new Object[]{Arrays.asList(a), Arrays.asList(Arrays.asList(0.0)), a, a});
        tests.add(new Object[]{Arrays.asList(a, c), Arrays.asList(Arrays.asList(0.0, -1.0)), a, a});
        tests.add(new Object[]{Arrays.asList(a, c), Arrays.asList(Arrays.asList(-1.0, 0.0)), c, c});
        tests.add(new Object[]{Arrays.asList(a, c, g), Arrays.asList(Arrays.asList(0.0, 0.0, -10.0)), a, a});
View Full Code Here

            final byte[] quals = Utils.dupBytes((byte) 30, 10);
            final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(bases, quals, "10M");
            read.setReadName("readName" + readI);

            for ( int i = 0; i < alleles.size(); i++ ) {
                final Allele allele = alleles.get(i);
                final double likelihood = likelihoods.get(i);
                map.add(read, allele, likelihood);
            }
        }
View Full Code Here

                throw new IllegalStateException("unexpected model: " + model);
        }
    }

    protected void printVerboseData(final String pos, final VariantContext vc, final GenotypeLikelihoodsCalculationModel.Model model) {
        Allele refAllele = null, altAllele = null;
        for ( Allele allele : vc.getAlleles() ) {
            if ( allele.isReference() )
                refAllele = allele;
            else
                altAllele = allele;
View Full Code Here

                throw new IllegalArgumentException("Can only merge single insertion with deletion (or vice versa) but got " + vc1 + " merging with " + vc2);
        } else if ( vc2.isSNP() ) {
            throw new IllegalArgumentException("vc1 is " + vc1 + " but vc2 is a SNP, which implies there's been some terrible bug in the cigar " + vc2);
        }

        final Allele ref, alt;
        final VariantContextBuilder b = new VariantContextBuilder(vc1);
        if ( vc1.isSNP() ) {
            // we have to repair the first base, so SNP case is special cased
            if ( vc1.getReference().equals(vc2.getReference()) ) {
                // we've got an insertion, so we just update the alt to have the prev alt
View Full Code Here

        int hap1 = 0;
        int hap2 = 0;
        double maxElement = Double.NEGATIVE_INFINITY;
        for( int iii = 0; iii < alleles.size(); iii++ ) {
            final Allele iii_allele = alleles.get(iii);
            for( int jjj = 0; jjj <= iii; jjj++ ) {
                final Allele jjj_allele = alleles.get(jjj);

                double haplotypeLikelihood = 0.0;
                for( final Map.Entry<GATKSAMRecord, Map<Allele,Double>> entry : likelihoodReadMap.entrySet() ) {
                    // Compute log10(10^x1/2 + 10^x2/2) = log10(10^x1+10^x2)-log10(2)
                    final double likelihood_iii = entry.getValue().get(iii_allele);
View Full Code Here

     */
    public static MostLikelyAllele getMostLikelyAllele( final Map<Allele,Double> alleleMap, final Set<Allele> onlyConsiderTheseAlleles ) {
        if ( alleleMap == null ) throw new IllegalArgumentException("The allele to likelihood map cannot be null");
        double maxLike = Double.NEGATIVE_INFINITY;
        double prevMaxLike = Double.NEGATIVE_INFINITY;
        Allele mostLikelyAllele = Allele.NO_CALL;
        Allele secondMostLikely = null;

        for (final Map.Entry<Allele,Double> el : alleleMap.entrySet()) {
            if ( onlyConsiderTheseAlleles != null && ! onlyConsiderTheseAlleles.contains(el.getKey()) )
                continue;

View Full Code Here

TOP

Related Classes of htsjdk.variant.variantcontext.Allele

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.