Package org.broadinstitute.gatk.utils.haplotype

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


            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


        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

        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

     *
     * @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

        test.overallGCP = overallGCP;
        test.haplotypes = haplotypes;
        batchRequests.add(test);
        for (int jjj = 0; jjj < numHaplotypes; jjj++) {
            final boolean recacheReadValues = (jjj == 0);
            final Haplotype haplotype = haplotypes.get(jjj);
            enqueuePrepare(haplotype.getBases(), readBases);
            if (enqueue(haplotype.getBases(), readBases, readQuals, insertionGOP, deletionGOP, overallGCP, 0, recacheReadValues) == 0)
                throw new RuntimeException("FPGA queue overflow in batchAdd");
        }
    }
View Full Code Here

        final int numHaplotypes = test.haplotypes.size();
        results = new double[numHaplotypes];
        for (int jjj = 0; jjj < numHaplotypes; jjj++) {
            results[jjj] = resultQueue.pop();
            if (results[jjj]<-60.0) {
                final Haplotype haplotype = test.haplotypes.get(jjj);
                results[jjj]=softHmm(haplotype.getBases(), test.readBases, test.readQuals, test.insertionGOP, test.deletionGOP, test.overallGCP, 0, true);
            }
        }
        return results;
    }
View Full Code Here

        if ( haplotypeMap == null ) throw new IllegalArgumentException("The input allele to haplotype map cannot be null");

        final LinkedHashMap<Allele, Haplotype> trimmedHaplotypeMap = new LinkedHashMap<>();
        for (final Allele a: haplotypeMap.keySet()) {

            final Haplotype haplotype = haplotypeMap.get(a);

            if (stopLocationInRefForHaplotypes > haplotype.getStopPosition())
                stopLocationInRefForHaplotypes = haplotype.getStopPosition();

            if (startLocationInRefForHaplotypes < haplotype.getStartPosition())
                startLocationInRefForHaplotypes = haplotype.getStartPosition();
            else if (startLocationInRefForHaplotypes > haplotype.getStopPosition())
                startLocationInRefForHaplotypes = haplotype.getStopPosition();

            final long indStart = startLocationInRefForHaplotypes - haplotype.getStartPosition();
            final long indStop =  stopLocationInRefForHaplotypes - haplotype.getStartPosition();
            if ( indStart >= indStop )
                continue;

            // commented out here because we need to make this method static for unit testing
            //if (DEBUG)
            //    System.out.format("indStart: %d indStop: %d WinStart:%d WinStop:%d start: %d stop: %d\n",
            //            indStart, indStop, ref.getWindow().getStart(), ref.getWindow().getStop(), startLocationInRefForHaplotypes, stopLocationInRefForHaplotypes);

            // get the trimmed haplotype-bases array and create a new haplotype based on it. Pack this into the new map
            final byte[] trimmedHaplotypeBases = Arrays.copyOfRange(haplotype.getBases(), (int)indStart, (int)indStop);
            final Haplotype trimmedHaplotype = new Haplotype(trimmedHaplotypeBases, haplotype.isReference());
            trimmedHaplotypeMap.put(a, trimmedHaplotype);
        }
        return trimmedHaplotypeMap;
    }
View Full Code Here

                    final ReadLikelihoods.Matrix<Haplotype> dummySampleLikelihoods = rl.sampleMatrix(0);
                    pairHMM.computeLikelihoods(rl.sampleMatrix(0), Collections.singletonList(processedRead), readGCPArrayMap);

                    // Pack the original pilup element, each allele, and each associated log10 likelihood into a final map, and add each likelihood to the array
                    for (final Allele a: trimmedHaplotypeMap.keySet()){
                        final Haplotype h = trimmedHaplotypeMap.get(a);
                        final int hIndex = rl.alleleIndex(h);
                        final double readLikelihood = dummySampleLikelihoods.get(hIndex,0);
                        readLikelihoods[readIdx][j++] = readLikelihood;
                        perReadAlleleLikelihoodMap.add(p,a,readLikelihood);
                    }
View Full Code Here

    @Test
    public void trimHaplotypesToNullAlleleTest() {
        // we need a case where start and stop > haplotype coordinates
        final int start = 100, stop = 100;
  final Haplotype h = new Haplotype(new byte[]{(byte)'A'}, new UnvalidatingGenomeLoc("1", 0, 10, 10));
  final Map<Allele, Haplotype> input = new HashMap<Allele, Haplotype>(1);
  input.put(Allele.create("A"), h);

  final Map<Allele, Haplotype> output = PairHMMIndelErrorModel.trimHaplotypes(input, start, stop, null);
        Assert.assertTrue(output.isEmpty());
View Full Code Here

        read.setBaseQualities(Utils.dupBytes((byte)30, read.getReadLength()));
        return read;
    }

    private Haplotype makeHaplotype(final String bases, final String cigar) {
        final Haplotype hap = new Haplotype(bases.getBytes());
        hap.setCigar(TextCigarCodec.getSingleton().decode(cigar));
        return hap;
    }
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.