Package htsjdk.samtools

Examples of htsjdk.samtools.SAMRecord


    public void testInOrder() {
        iter = new ArtificialPatternedSAMIterator(startingChr,endingChr,readCount,0,header, ArtificialPatternedSAMIterator.PATTERN.IN_ORDER_READS);
        if (!iter.hasNext()) {
            fail("no reads in the ArtificialPatternedSAMIterator");
        }
        SAMRecord last = iter.next();
        while (iter.hasNext()) {
            SAMRecord rec = iter.next();
            if (!(rec.getReferenceIndex() > last.getReferenceIndex()) && (rec.getAlignmentStart() <= last.getAlignmentStart())) {
                fail("read " + rec.getReadName() + " out of order compared to last read, " + last.getReadName());
            }
            last = rec;
        }

    }
View Full Code Here


        int outOfOrderCount = 0;
        iter = new ArtificialPatternedSAMIterator(startingChr,endingChr,readCount,0,header, ArtificialPatternedSAMIterator.PATTERN.RANDOM_READS);
        if (!iter.hasNext()) {
            fail("no reads in the ArtificialPatternedSAMIterator");
        }
        SAMRecord last = iter.next();
        while (iter.hasNext()) {
            SAMRecord rec = iter.next();
            if (!(rec.getReferenceIndex() > last.getReferenceIndex()) && (rec.getAlignmentStart() <= last.getAlignmentStart())) {
                ++outOfOrderCount;
            }
            last = rec;
        }
        assertTrue(outOfOrderCount > 0);
View Full Code Here

    @Test
    public void testAllDuplicatesNoPairs() {
        List<SAMRecord> list = new ArrayList<SAMRecord>();
        for (int x = 0; x < 10; x++) {
            SAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "SWEET_READ" + x, 0, 1, 100);
            read.setDuplicateReadFlag(true);
            list.add(read);
        }
        Set<List<SAMRecord>> myPairings = obj.uniqueReadSets(list);
        Assert.assertEquals(myPairings.size(), 1);
        Assert.assertEquals(myPairings.iterator().next().size(), 10); // dup's
View Full Code Here

    @Test
    public void testNoDuplicatesNoPairs() {
        List<SAMRecord> list = new ArrayList<SAMRecord>();
        for (int x = 0; x < 10; x++) {
            SAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "SWEET_READ" + x, 0, 1, 100);
            read.setDuplicateReadFlag(false);
            list.add(read);
        }

        Set<List<SAMRecord>> myPairing = obj.uniqueReadSets(list);
        Assert.assertEquals(myPairing.size(), 10); // unique
View Full Code Here

    @Test
    public void testFiftyFiftyNoPairs() {
        List<SAMRecord> list = new ArrayList<SAMRecord>();
        for (int x = 0; x < 5; x++) {
            SAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "SWEET_READ" + x, 0, 1, 100);
            read.setDuplicateReadFlag(true);
            list.add(read);
        }
        for (int x = 10; x < 15; x++)
            list.add(ArtificialSAMUtils.createArtificialRead(header, String.valueOf(x), 0, x, 100));
View Full Code Here

    @Test
    public void testAllDuplicatesAllPairs() {
        List<SAMRecord> list = new ArrayList<SAMRecord>();
        for (int x = 0; x < 10; x++) {
            SAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "SWEET_READ"+ x, 0, 1, 100);
            read.setDuplicateReadFlag(true);
            read.setMateAlignmentStart(100);
            read.setMateReferenceIndex(0);
            read.setReadPairedFlag(true);
            list.add(read);
        }

        Set<List<SAMRecord>> myPairing = obj.uniqueReadSets(list);
        Assert.assertEquals(myPairing.size(), 1)// unique
View Full Code Here

    @Test
    public void testNoDuplicatesAllPairs() {
        List<SAMRecord> list = new ArrayList<SAMRecord>();
        for (int x = 0; x < 10; x++) {
            SAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "SWEET_READ"+ x, 0, 1, 100);
            if (x == 0) read.setDuplicateReadFlag(true); // one is a dup but (next line)
            read.setMateAlignmentStart(100); // they all have a shared start and mate start so they're dup's
            read.setMateReferenceIndex(0);
            read.setReadPairedFlag(true);
            list.add(read);
        }

        Set<List<SAMRecord>> myPairing = obj.uniqueReadSets(list);
        Assert.assertEquals(myPairing.size(), 1)// unique
View Full Code Here

    @Test
    public void testAllDuplicatesAllPairsDifferentPairedEnd() {
        List<SAMRecord> list = new ArrayList<SAMRecord>();
        for (int x = 0; x < 10; x++) {
            SAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "SWEET_READ" + x, 0, 1, 100);
            if (x == 0) read.setDuplicateReadFlag(true); // one is a dup
            read.setMateAlignmentStart(100 + x);
            read.setMateReferenceIndex(0);
            read.setReadPairedFlag(true);
            list.add(read);
        }

        Set<List<SAMRecord>> myPairing = obj.uniqueReadSets(list);
        Assert.assertEquals(myPairing.size(), 10)// unique
View Full Code Here

            // Do a first-pass validation of the record state iteration by making sure we get back everything we
            // put in, in the same order, doing any requested removals of read states along the way
            while ( recordStateIterator.hasNext() ) {
                AlignmentStateMachine readState = recordStateIterator.next();
                recordStateCount++;
                SAMRecord readFromPerSampleReadStateManager = readState.getRead();

                Assert.assertTrue(originalReadsIterator.hasNext());
                SAMRecord originalRead = originalReadsIterator.next();

                // The read we get back should be literally the same read in memory as we put in
                Assert.assertTrue(originalRead == readFromPerSampleReadStateManager);

                // If requested, remove a read state every removalInterval states
                if ( removalInterval > 0 && recordStateCount % removalInterval == 0 ) {
                    recordStateIterator.remove();
                    numReadStatesRemoved++;
                }
            }

            Assert.assertFalse(originalReadsIterator.hasNext());

            // If we removed any read states, do a second pass through the read states to make sure the right
            // states were removed
            if ( numReadStatesRemoved > 0 ) {
                Assert.assertEquals(perSampleReadStateManager.size(), reads.size() - numReadStatesRemoved);

                originalReadsIterator = reads.iterator();
                recordStateIterator = perSampleReadStateManager.iterator();
                int readCount = 0;
                int readStateCount = 0;

                // Match record states with the reads that should remain after removal
                while ( recordStateIterator.hasNext() ) {
                    AlignmentStateMachine readState = recordStateIterator.next();
                    readStateCount++;
                    SAMRecord readFromPerSampleReadStateManager = readState.getRead();

                    Assert.assertTrue(originalReadsIterator.hasNext());

                    SAMRecord originalRead = originalReadsIterator.next();
                    readCount++;

                    if ( readCount % removalInterval == 0 ) {
                        originalRead = originalReadsIterator.next(); // advance to next read, since the previous one should have been discarded
                        readCount++;
View Full Code Here

        readSecondContig = createMappedRead("secondContig", 3);
        readSecondContig.setReferenceName(secondContig.getContig());

        /* This read says it's aligned, but to a contig not in the header. */
        SAMRecord readUnknownContig = createMappedRead("unknownContig", 4);
        readUnknownContig.setReferenceName("unknownContig");

        readUnknownStart = createMappedRead("unknownStart", 1);
        readUnknownStart.setAlignmentStart(SAMRecord.NO_ALIGNMENT_START);

        readNoReference = createUnmappedRead("unmappedNoReference");
View Full Code Here

TOP

Related Classes of htsjdk.samtools.SAMRecord

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.