Package htsjdk.samtools.util

Examples of htsjdk.samtools.util.Interval


                final int bins = 101;
                final long[] targetBasesByGc  = new long[bins];
                final long[] alignedBasesByGc = new long[bins];

                for (final Map.Entry<Interval,Coverage> entry : this.coverageByTarget.entrySet()) {
                    final Interval interval = entry.getKey();
                    final Coverage cov = entry.getValue();

                    final double gcDouble = this.intervalToGc.get(interval);
                    final int gc = (int) Math.round(gcDouble * 100);

                    targetBasesByGc[gc+= interval.length();
                    alignedBasesByGc[gc] += cov.getTotal();

                    if (out != null) {
                        final double coverage = cov.getTotal() / (double) interval.length();

                        out.println(interval.getSequence() + "\t" +
                                    interval.getStart() + "\t" +
                                    interval.getEnd() + "\t" +
                                    interval.length() + "\t" +
                                    interval.getName() + "\t" +
                                    fmt.format(gcDouble) + "\t" +
                                    fmt.format(coverage) + "\t" +
                                    fmt.format(coverage / this.metrics.MEAN_TARGET_COVERAGE)
                        );
                    }
View Full Code Here


    /** If the current iterator is null or exhausted, move to the next interval. */
    private void advance() {
        while ((currentIterator == null || !currentIterator.hasNext()) && this.intervals.hasNext()) {
            if (currentIterator != null) currentIterator.close();
            final Interval i = this.intervals.next();
            this.currentIterator = this.reader.query(i.getSequence(), i.getStart(), i.getEnd());
        }
    }
View Full Code Here

        final SAMFileWriter samWriter = new SAMFileWriterFactory().makeSAMWriter(builder.getHeader(), false, samFile);
        for (final SAMRecord rec: builder.getRecords()) samWriter.addAlignment(rec);
        samWriter.close();

        // Create an interval list with one ribosomal interval.
        final Interval rRnaInterval = new Interval(sequence, 300, 520, true, "rRNA");
        final IntervalList rRnaIntervalList = new IntervalList(builder.getHeader());
        rRnaIntervalList.add(rRnaInterval);
        final File rRnaIntervalsFile = File.createTempFile("tmp.rRna.", ".interval_list");
        rRnaIntervalsFile.deleteOnExit();
        rRnaIntervalList.write(rRnaIntervalsFile);
View Full Code Here

        final SAMFileWriter samWriter = new SAMFileWriterFactory().makeSAMWriter(builder.getHeader(), false, samFile);
        for (final SAMRecord rec: builder.getRecords()) samWriter.addAlignment(rec);
        samWriter.close();

        // Create an interval list with one ribosomal interval.
        final Interval rRnaInterval = new Interval(sequence, 300, 520, true, "rRNA");
        final IntervalList rRnaIntervalList = new IntervalList(builder.getHeader());
        rRnaIntervalList.add(rRnaInterval);
        final File rRnaIntervalsFile = File.createTempFile("tmp.rRna.", ".interval_list");
        rRnaIntervalsFile.deleteOnExit();
        rRnaIntervalList.write(rRnaIntervalsFile);
View Full Code Here

    @DataProvider(name = "testSegregate")
    public Object[][] testSegregate() {

        return new Object[][]{
                new Object[]{"NNNNNAAAAANNNNNN", 1, CollectionUtil.makeList(
                        new Interval("fake1", 1, 5),
                        new Interval("fake1", 6, 10),
                        new Interval("fake1", 11, 16))},

                new Object[]{"NNNNNAAAAANNNNNN", 5, CollectionUtil.makeList(
                        new Interval("fake1", 1, 5),
                        new Interval("fake1", 6, 10),
                        new Interval("fake1", 11, 16))},

                new Object[]{"NNNNNAAAnANNNNNN", 6, CollectionUtil.makeList(
                        new Interval("fake1", 1, 5),
                        new Interval("fake1", 6, 10),
                        new Interval("fake1", 11, 16))},

                new Object[]{"AnTGCNNNNNACGTCG", 1, CollectionUtil.makeList(
                        new Interval("fake1", 1, 5),
                        new Interval("fake1", 6, 10),
                        new Interval("fake1", 11, 16))},

                new Object[]{"ACTGCNNNNNACGTCG", 4, CollectionUtil.makeList(
                        new Interval("fake1", 1, 5),
                        new Interval("fake1", 6, 10),
                        new Interval("fake1", 11, 16))},

                new Object[]{"ACTGCNNNNNACgctG", 5, CollectionUtil.makeList(
                        new Interval("fake1", 1, 16))},

                new Object[]{"ACNGCNNNNNACnTNG", 5, CollectionUtil.makeList(
                        new Interval("fake1", 1, 16))},

                new Object[]{"ACNGCNNNNNACnTNG", 0, CollectionUtil.makeList(
                        new Interval("fake1", 1, 2),   //acgt
                        new Interval("fake1", 3, 3),   //N
                        new Interval("fake1", 4, 5),
                        new Interval("fake1", 6, 10)//N
                        new Interval("fake1", 11, 12),
                        new Interval("fake1", 13, 13), //N
                        new Interval("fake1", 14, 14),
                        new Interval("fake1", 15, 15), //N
                        new Interval("fake1", 16, 16))},

                new Object[]{"AAAAAAAAAAACnTNG", 0, CollectionUtil.makeList(
                        new Interval("fake1", 1, 12),
                        new Interval("fake1", 13, 13), //N
                        new Interval("fake1", 14, 14),
                        new Interval("fake1", 15, 15), //N
                        new Interval("fake1", 16, 16))},

                new Object[]{"AAAAAAAAAAACATNG", 0, CollectionUtil.makeList(
                        new Interval("fake1", 1, 14),
                        new Interval("fake1", 15, 15), //N
                        new Interval("fake1", 16, 16))},

                new Object[]{"ANCNNGCNNNNNACNTNGN", 1, CollectionUtil.makeList(
                        new Interval("fake1", 1, 3),
                        new Interval("fake1", 4, 5),
                        new Interval("fake1", 6, 7),
                        new Interval("fake1", 8, 12),
                        new Interval("fake1", 13, 18),
                        new Interval("fake1", 19, 19)

                )},
                new Object[]{"ANCNNGCNNNNNACNTNGN", 0, CollectionUtil.makeList(
                        new Interval("fake1", 1, 1),
                        new Interval("fake1", 2, 2),
                        new Interval("fake1", 3, 3),
                        new Interval("fake1", 4, 5),
                        new Interval("fake1", 6, 7),
                        new Interval("fake1", 8, 12),
                        new Interval("fake1", 13, 14),
                        new Interval("fake1", 15, 15),
                        new Interval("fake1", 16, 16),
                        new Interval("fake1", 17, 17),
                        new Interval("fake1", 18, 18),
                        new Interval("fake1", 19, 19)
                )}


        };
    }
View Full Code Here

    }
   
    private static IntervalList composeIntervalList(final IntervalList source, final String chromosome, final int... segmentsByPair) {
        final IntervalList intervals = new IntervalList(source.getHeader());
        for (int i = 0; i < segmentsByPair.length; i += 2) {
            final Interval parentInterval = lookupIntervalContainingLocus(source, chromosome, segmentsByPair[i]);
            intervals.add(new Interval("1", segmentsByPair[i], segmentsByPair[i + 1], parentInterval.isNegativeStrand(), parentInterval.getName()));
        }
        return intervals;
    }
View Full Code Here

TOP

Related Classes of htsjdk.samtools.util.Interval

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.