Package org.broadinstitute.gatk.utils.haplotype

Examples of org.broadinstitute.gatk.utils.haplotype.Haplotype$Event


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

        final String hapBases = "ACTGAAGGTTCC";
        final Haplotype allM = makeHaplotype(hapBases, hapBases.length() + "M");

        // make sure we get back a cigar of the right length
        for ( int i = -1; i < hapBases.length(); i++ ) {
            final GATKSAMRecord read = makeRead(hapBases);
            if ( i != -1 ) read.getReadBases()[i] = (byte)'A';
            tests.add(new Object[]{read, allM, 10, 10, allM.getCigar().toString()});
        }

        // make sure insertions at the front are correctly handled
        for ( int padFront = 1; padFront < 10; padFront++ ) {
            final GATKSAMRecord read = makeRead(Utils.dupString("N", padFront) + hapBases);
            tests.add(new Object[]{read, allM, 10, 10, padFront + "I" + allM.getCigar().toString()});
        }

        // make sure insertions at the back are correctly handled
        for ( int padBack = 1; padBack < 10; padBack++ ) {
            final GATKSAMRecord read = makeRead(hapBases + Utils.dupString("N", padBack));
            tests.add(new Object[]{read, allM, 10, 10, allM.getCigar().toString() + padBack + "I"});
        }

        // make sure refStart and hapStart are respected
        for ( int refStart = 1; refStart < 10; refStart++ ) {
            for ( int hapStart = refStart; hapStart < 10 + refStart; hapStart++ ) {
                final Haplotype hap = new Haplotype(allM.getBases());
                hap.setCigar(allM.getCigar());
                hap.setAlignmentStartHapwrtRef(hapStart);

                final GATKSAMRecord read = makeRead(new String(hap.getBases()));
                tests.add(new Object[]{read, hap, refStart, refStart + hapStart, allM.getCigar().toString()});
            }
        }

        // example case of bad alignment because SW doesn't necessarily left-align indels
        {
            final String hap = "ACTGTGGGTTCCTCTTATTTTATTTCTACATCAATGTTCATATTTAACTTATTATTTTATCTTATTTTTAAATTTCTTTTATGTTGAGCCTTGATGAAAGCCATAGGTTCTCTCATATAATTGTATGTGTATGTATGTATATGTACATAATATATACATATATGTATATGTATGTGTATGTACATAATATATACGTATATGTATGTGTATGTACATAATATATACGTATATGTATGTGTATGTACATAATATATACGTATATGTATGTGTATGTACATAATATATACGTATATGTATGTGTATGTACATAATATATACGTATATGTATGTGTATGTGTATTACATAATATATACATATATGTATATATTATGTATATGTACATAATATATACATATATG";
            final String hapCigar = "399M";
            final String readBases = "ATGTACATAATATATACATATATGTATATGTATGTACATAATATATACGTATATGTATGTGTATGTACATAATATATACGTATATGTATGTGTATGTACATAATATATACGTATATGTATGTGTATGTACATAATATATACGTATATGTATGTGTATGTACATAATATATACGTATATGTATGTGTATGTGTATTACATAATATATACATATATGTATATATTATGTATATGTACATAATAT";
            final GATKSAMRecord read = makeRead(readBases);
            final int refStart = 10130100;
            final int hapStart = 500;
            final String badCigar = "31M6D211M";
            final String goodCigar = "28M6D214M";
            final Haplotype badHap = new Haplotype(hap.getBytes());
            badHap.setCigar(TextCigarCodec.getSingleton().decode(hapCigar));
            badHap.setAlignmentStartHapwrtRef(hapStart);

            final int expectedPos = 10130740;
            tests.add(new Object[]{read, badHap, refStart, expectedPos, goodCigar});
        }
View Full Code Here


        int i = 0;
        final String referenceBases  = "ACTGACTGACTG";
        final String paddedReference = "NNNN" + referenceBases + "NNNN";
        for ( final List<Mutation> mutations : Utils.makePermutations(allMutations, 3, false) ) {
            final MutatedSequence hap = mutateSequence(referenceBases, mutations);
            final Haplotype haplotype = new Haplotype(hap.seq.getBytes());
            final SWPairwiseAlignment align = new SWPairwiseAlignment(paddedReference.getBytes(), hap.seq.getBytes());
            haplotype.setAlignmentStartHapwrtRef(align.getAlignmentStart2wrt1());
            haplotype.setCigar(align.getCigar());

            for ( final List<Mutation> readMutations : Utils.makePermutations(allMutations, 3, false) ) {
                final MutatedSequence readBases = mutateSequence(hap.seq, readMutations);
                final GATKSAMRecord read = makeRead(readBases.seq);
                tests.add(new Object[]{i++, read, paddedReference, haplotype, hap.numMismatches + readBases.numMismatches});
View Full Code Here

        h1bases = "ATCG" + "CCGGCCGGCC" + "ATCGATCG" + "AGCGGGA" + "AGGC";
        basicInsertTest("G", "C", 17, h1Cigar, bases, h1bases);
    }

    private void basicInsertTest(String ref, String alt, int loc, Cigar cigar, String hap, String newHap) {
        final Haplotype h = new Haplotype(hap.getBytes());
        final Allele h1refAllele = Allele.create(ref, true);
        final Allele h1altAllele = Allele.create(alt, false);
        final ArrayList<Allele> alleles = new ArrayList<Allele>();
        alleles.add(h1refAllele);
        alleles.add(h1altAllele);
        final VariantContext vc = new VariantContextBuilder().alleles(alleles).loc("1", loc, loc + h1refAllele.getBases().length - 1).make();
        h.setAlignmentStartHapwrtRef(0);
        h.setCigar(cigar);
        final Haplotype h1 = h.insertAllele(vc.getReference(), vc.getAlternateAllele(0), loc, vc.getStart());
        final Haplotype h1expected = new Haplotype(newHap.getBytes());
        Assert.assertEquals(h1, h1expected);
    }
View Full Code Here

        final Haplotype h1expected = new Haplotype(newHap.getBytes());
        Assert.assertEquals(h1, h1expected);
    }

    private Haplotype makeHCForCigar(final String bases, final String cigar) {
        final Haplotype h = new Haplotype(bases.getBytes());
        h.setCigar(TextCigarCodec.getSingleton().decode(cigar));
        return h;
    }
View Full Code Here

            for ( int trimStop = trimStart; trimStop <= loc.getStop(); trimStop++ ) {
                final int start = trimStart - loc.getStart();
                final int stop = start + (trimStop - trimStart) + 1;
                final GenomeLoc trimmedLoc = new UnvalidatingGenomeLoc("20", 0, start + loc.getStart(), stop + loc.getStart() - 1);
                final String expectedBases = fullBases.substring(start, stop);
                final Haplotype full = new Haplotype(fullBases.getBytes(), loc);
                final Haplotype trimmed = new Haplotype(expectedBases.getBytes(), trimmedLoc);

                final int hapStart = 10;
                full.setAlignmentStartHapwrtRef(hapStart);
                full.setCigar(TextCigarCodec.getSingleton().decode(full.length() + "M"));

                trimmed.setAlignmentStartHapwrtRef(hapStart + start);
                trimmed.setCigar(TextCigarCodec.getSingleton().decode(trimmed.length() + "M"));

                tests.add(new Object[]{full, trimmedLoc, trimmed});
            }
        }

        final Haplotype full = new Haplotype("ACT".getBytes(), new UnvalidatingGenomeLoc("20", 0, 10, 14));
        full.setAlignmentStartHapwrtRef(10);
        full.setCigar(TextCigarCodec.getSingleton().decode("1M2D2M"));
        tests.add(new Object[]{full, new UnvalidatingGenomeLoc("20", 0, 11, 12), null});
        tests.add(new Object[]{full, new UnvalidatingGenomeLoc("20", 0, 10, 12), null});
        tests.add(new Object[]{full, new UnvalidatingGenomeLoc("20", 0, 11, 13), null});

        return tests.toArray(new Object[][]{});
View Full Code Here

        return tests.toArray(new Object[][]{});
    }

    @Test(dataProvider = "TrimmingData")
    public void testTrim(final Haplotype full, final GenomeLoc trimTo, final Haplotype expected) {
        final Haplotype actual = full.trim(trimTo);
        if ( expected != null ) {
            Assert.assertEquals(actual.getBases(), expected.getBases());
            Assert.assertEquals(actual.getStartPosition(), trimTo.getStart());
            Assert.assertEquals(actual.getStopPosition(), trimTo.getStop());
            Assert.assertEquals(actual.getCigar(), expected.getCigar());
            Assert.assertEquals(actual.getAlignmentStartHapwrtRef(), expected.getAlignmentStartHapwrtRef());
        } else {
            Assert.assertNull(actual);
        }
    }
View Full Code Here

    }

    @Test(expectedExceptions = IllegalArgumentException.class)
    public void testBadTrimLoc() {
        final GenomeLoc loc = new UnvalidatingGenomeLoc("20", 0, 10, 20);
        final Haplotype hap = new Haplotype("ACGTAACCGGT".getBytes(), loc);
        hap.trim(new UnvalidatingGenomeLoc("20", 0, 1, 20));
    }
View Full Code Here

        hap.trim(new UnvalidatingGenomeLoc("20", 0, 1, 20));
    }

    @Test(expectedExceptions = IllegalStateException.class)
    public void testBadTrimNoLoc() {
        final Haplotype hap = new Haplotype("ACGTAACCGGT".getBytes());
        hap.trim(new UnvalidatingGenomeLoc("20", 0, 1, 20));
    }
View Full Code Here

            if (result == null)
                result = defaultCase(theEObject);
            return result;
        }
        case Bpmn2Package.EVENT: {
            Event event = (Event) theEObject;
            T result = caseEvent(event);
            if (result == null)
                result = caseFlowNode(event);
            if (result == null)
                result = caseInteractionNode(event);
View Full Code Here

    ProcessInstanceEntity processInstanceImpl = processInstanceManager.findProcessInstanceById(processInstanceId, processDefinition);
    TokenEntity tokenEntity = processInstanceImpl.getTokenMap().get(tokenId);
    processInstanceImpl.getContextInstance().setTransientVariableMap(transientVariables);
   
    if(nodeId==null){
      Event event=(Event)tokenEntity.getFlowNode();
      if(event instanceof BoundaryEvent){
        BoundaryEvent boundaryEvent=(BoundaryEvent)event;
        Activity activity =boundaryEvent.getAttachedToRef();
        boolean isCancelActivity=boundaryEvent.isCancelActivity();
        if(isCancelActivity){
View Full Code Here

TOP

Related Classes of org.broadinstitute.gatk.utils.haplotype.Haplotype$Event

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.