Examples of Haplotype


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

        final VariantContext vc2 = new VariantContextBuilder().chr("20").start(2).stop(2).alleles(Arrays.asList(ref, altC)).make();
        final VariantContext vc3 = new VariantContextBuilder().chr("20").start(3).stop(3).alleles(Arrays.asList(ref, altT)).make();
        final VariantContext vc4 = new VariantContextBuilder().chr("20").start(4).stop(4).alleles(Arrays.asList(ref, altC)).make();
        final List<VariantContext> calls = Arrays.asList(vc2, vc3, vc4);

        final Haplotype pos1 = new Haplotype("CAAAA".getBytes());
        pos1.setEventMap(new EventMap(Arrays.asList(vc1)));
        pos1.getEventMap().put(1, vc1);
        final Haplotype pos2 = new Haplotype("ACAAA".getBytes());
        pos2.setEventMap(new EventMap(Arrays.asList(vc2)));
        pos2.getEventMap().put(2, vc2);
        final Haplotype pos3 = new Haplotype("AACAA".getBytes());
        pos3.setEventMap(new EventMap(Arrays.asList(vc3)));
        pos3.getEventMap().put(3, vc3);
        final Haplotype pos4 = new Haplotype("AAACA".getBytes());
        pos4.setEventMap(new EventMap(Arrays.asList(vc4)));
        pos4.getEventMap().put(4, vc4);
        final Haplotype pos24 = new Haplotype("ACACA".getBytes());
        pos24.setEventMap(new EventMap(Arrays.asList(vc2, vc4)));
        pos24.getEventMap().put(2, vc2);
        pos24.getEventMap().put(4, vc4);
        final Haplotype pos34 = new Haplotype("AACCA".getBytes());
        pos34.setEventMap(new EventMap(Arrays.asList(vc3, vc4)));
        pos34.getEventMap().put(3, vc3);
        pos34.getEventMap().put(4, vc4);
        final Haplotype pos234 = new Haplotype("ACCCA".getBytes());
        pos234.setEventMap(new EventMap(Arrays.asList(vc2, vc3, vc4)));
        pos234.getEventMap().put(2, vc2);
        pos234.getEventMap().put(3, vc3);
        pos234.getEventMap().put(4, vc4);

        final Map<VariantContext, Set<Haplotype>> haplotypeMap = new HashMap<>();

        // test no phased variants #1
        final Set<Haplotype> haplotypes2 = new HashSet<>();
View Full Code Here

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

        final Civar civar = Civar.fromCharSequence(civarString);
        final List<Civar> unrolledCivars = civar.optionalizeAll().unroll();
        List<Haplotype> result = new ArrayList<>(unrolledCivars.size());
        for (final Civar c : unrolledCivars) {
            final String baseString = c.applyTo(reference);
            final Haplotype haplotype = new Haplotype(baseString.getBytes(),baseString.equals(reference));
            haplotype.setGenomeLocation(genomeLocParser.createGenomeLoc("chr1",1,reference.length()));
            try {
            haplotype.setCigar(c.toCigar(reference.length()));
            } catch (final RuntimeException ex) {
                c.applyTo(reference);
                c.toCigar(reference.length());
                throw new RuntimeException("" + c + " " + ex.getMessage(),ex);
            }
View Full Code Here

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

                  stringRepresentation = cigar.substring(6);
                  result.addAll(expandAllHaplotypeCombinations(cigar.substring(6), reference));
              } else if (cigar.matches("^.*\\d+.*$")) {
                  result.add(cigarToHaplotype(reference, cigar, 0, true));
              } else {
                  final Haplotype h = new Haplotype(cigar.getBytes());
                  h.setGenomeLocation(genomeLocParser.createGenomeLoc("chr1",1,reference.length()));
                  result.add(h);
              }
          }
          haplotypeList = result;
        }
View Full Code Here

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

    private static final Pattern cigarPattern = Pattern.compile("(\\d+)([=A-Z])");


    private Haplotype cigarToHaplotype(final String reference, final String cigar, final int offset, final boolean global) {
        final String sequence = applyCigar(reference,cigar,offset,global);
        final Haplotype haplotype = new Haplotype(sequence.getBytes(),reference.equals(sequence));
        haplotype.setGenomeLocation(genomeLocParser.createGenomeLoc("chr1",1,reference.length()));
        haplotype.setCigar(Civar.fromCharSequence(cigar).toCigar(reference.length()));
        return haplotype;
    }
View Full Code Here

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

            this.expected = expected;
        }
       
        public Map<Integer,VariantContext> calcAlignment() {
            final SWPairwiseAlignment alignment = new SWPairwiseAlignment(ref, hap, new Parameters(3,-1,-4, -1));
            final Haplotype h = new Haplotype(hap, false, alignment.getAlignmentStart2wrt1(), alignment.getCigar());
            return HaplotypeCallerGenotypingEngine.generateVCsFromAlignment(h, ref, genomeLocParser.createGenomeLoc("4", 1, 1 + ref.length), "name");
        }
View Full Code Here

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

            final double[] sortedLikelihoods = new double[sortedHaplotypes.size()];
            unsorted.loadRead(read);
            sorted.loadRead(read);
            final Map<Haplotype,Double> unsortedResults = new HashMap<>(haplotypes.size());
            for (int i = 0; i < sortedHaplotypes.size(); i++) {
                final Haplotype h = sortedHaplotypes.get(i);
                final byte[] haplotypeBases = h.getBases().clone();
                unsorted.loadHaplotypeBases(haplotypeBases);
                double lk = unsorted.calculateLocalLikelihood(0, read.getReadLength(), 0, haplotypeBases.length, false);
                unsortedLikelihoods[i] = lk;
            }
            sorted.calculateLocalLikelihoods(0, read.getReadLength(), haplotypeCollection);
View Full Code Here

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

            final double[] unsortedLikelihoods = new double[sortedHaplotypes.size()];
            final double[] sortedLikelihoods = new double[sortedHaplotypes.size()];
            unsorted.loadRead(read);
            sorted.loadRead(read);
            for (int i = 0; i < sortedHaplotypes.size(); i++) {
                final Haplotype h = sortedHaplotypes.get(i);
                final byte[] haplotypeBases = h.getBases().clone();
                final byte[] haplotypeBases2 = haplotypeBases.clone();
                int commonPrefixEnd = 0;


                if (lastHaplotypeBases != null) {
View Full Code Here

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

        Assert.assertEquals(haplotypes.size(),(int) Math.pow(2,variants));

        final Map<String,Integer> haplotypeNumberByString = new HashMap<>();
        for (int i = 0; i < haplotypes.size(); i++) {
            final Haplotype hap = haplotypes.get(i);
            final Civar civar = haplotypeCivars.get(i);
            Assert.assertEquals(hap.getBaseString(),civar.applyTo(as.getReference()));
            if (i == 0) {
                Assert.assertEquals(hap.getBaseString(), as.getReference());
            } else {
                Assert.assertNotEquals(hap.getBaseString(),as.getReference());
            }
            Assert.assertFalse(haplotypeNumberByString.containsKey(hap.getBaseString()));
            haplotypeNumberByString.put(hap.getBaseString(), i);
        }

        final int[] hapReadsNotInReference = new int[haplotypes.size()];

        for (int i = 0; i < readCount; i++) {
View Full Code Here

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

        needToUpdateHaplotypeStructures = false;
        haplotypeRouteByHaplotype = new LinkedHashMap<>(haplotypes.size());
        final Iterator<Haplotype> haplotypeIterator = haplotypes.iterator();
        final Set<Haplotype> nonFoundHaplotypes = new HashSet<>(haplotypes.size());
        while (haplotypeIterator.hasNext()) {
            final Haplotype haplotype = haplotypeIterator.next();
            final HaplotypeRoute haplotypeRoute = buildHaplotypeRoute(haplotype);
            if (haplotypeRoute == null) {
                haplotypeIterator.remove();
                nonFoundHaplotypes.add(haplotype);
                if (haplotype.isReference()) {
                    referenceHaplotype = null;
                    referenceRoute = null;
                    referenceVertices = Collections.emptySet();
                    referenceBases = null;
                }
            } else {
                if (haplotype.isReference()) {
                    referenceHaplotype = haplotype;
                    referenceRoute = haplotypeRoute;
                    referenceVertices = haplotypeRoute.vertexSet();
                    referenceBases = haplotypeRoute.getBases();
                }
View Full Code Here

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

     *
     * @return never {@code null}.
     */
    public Haplotype haplotype() {
        if (haplotype != null) return haplotype;
        haplotype = new Haplotype(bases(),isReference());
        if (score() > 0)
            throw new IllegalStateException("score cannot be greater than 0: " + score());
        haplotype.setScore(score());
        return haplotype;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.