Package htsjdk.samtools.reference

Examples of htsjdk.samtools.reference.ReferenceSequence


        if ( stop > refReader.getSequenceDictionary().getSequence(read.getReferenceName()).getSequenceLength() ) {
            return null;
        } else {
            // now that we have the start and stop, get the reference sequence covering it
            ReferenceSequence refSeq = refReader.getSubsequenceAt(read.getReferenceName(), start, stop);
            return calcBAQFromHMM(read, refSeq.getBases(), (int)(start - readStart));
        }
    }
View Full Code Here


*/
public class CreateBWTFromReference {
    private byte[] loadReference( File inputFile ) {
        // Read in the first sequence in the input file
        ReferenceSequenceFile reference = ReferenceSequenceFileFactory.getReferenceSequenceFile(inputFile);
        ReferenceSequence sequence = reference.nextSequence();
        return sequence.getBases();
    }
View Full Code Here

        return sequence.getBases();
    }

    private byte[] loadReverseReference( File inputFile ) {
        ReferenceSequenceFile reference = ReferenceSequenceFileFactory.getReferenceSequenceFile(inputFile);
        ReferenceSequence sequence = reference.nextSequence();
        PackUtils.reverse(sequence.getBases());
        return sequence.getBases();
    }
View Full Code Here

        LocusReferenceView view = new LocusReferenceView(dataProvider);

        while (shardIterator.hasNext()) {
            GenomeLoc locus = shardIterator.next();

            ReferenceSequence expectedAsSeq = sequenceFile.getSubsequenceAt(locus.getContig(), locus.getStart(), locus.getStop());
            char expected = Character.toUpperCase(StringUtil.bytesToString(expectedAsSeq.getBases()).charAt(0));
            char actual = view.getReferenceContext(locus).getBaseAsChar();

            Assert.assertEquals(actual, expected, String.format("Value of base at position %s in shard %s does not match expected", locus.toString(), shard.getGenomeLocs())
            );
        }
View Full Code Here

        // Read with no aligned bases?  Return an empty array.
        if(stop - start + 1 == 0)
            return new byte[0];

        ReferenceSequence subsequence = reference.getSubsequenceAt(genomeLoc.getContig(), start, stop);

        int overhang = (int)(genomeLoc.getStop() - stop);
        if ( overhang > 0 ) {
            if ( overhang > BUFFER ) // todo -- this is a bit dangerous
                throw new ReviewedGATKException("Insufficient buffer size for Xs overhanging genome -- expand BUFFER");
            byte[] all = new byte[subsequence.getBases().length + overhang];
            System.arraycopy(subsequence.getBases(), 0, all, 0, subsequence.getBases().length);
            System.arraycopy(Xs, 0, all, subsequence.getBases().length, overhang);
            return all;
        } else {
            // fast path
            return subsequence.getBases();
        }
    }
View Full Code Here

        // Read in the first sequence in the input file
        String inputFileName = argv[0];
        File inputFile = new File(inputFileName);
        ReferenceSequenceFile reference = ReferenceSequenceFileFactory.getReferenceSequenceFile(inputFile);
        ReferenceSequence sequence = reference.nextSequence();

        // Target file for output
        PackUtils.writeReferenceSequence( new File(argv[1]), sequence.getBases() );

        // Reverse the bases in the reference
        PackUtils.reverse(sequence.getBases());

        // Target file for output
        PackUtils.writeReferenceSequence( new File(argv[2]), sequence.getBases() );
    }
View Full Code Here

        SAMSequenceRecord contig = uncached.getSequenceDictionary().getSequence(0);
        for ( int i = 0; i < contig.getSequenceLength(); i += STEP_SIZE ) {
            int start = i;
            int stop = start + querySize;
            if ( stop <= contig.getSequenceLength() ) {
                ReferenceSequence cachedVal = caching.getSubsequenceAt(contig.getSequenceName(), start, stop);
                ReferenceSequence uncachedVal = uncached.getSubsequenceAt(contig.getSequenceName(), start, stop);

                Assert.assertEquals(cachedVal.getName(), uncachedVal.getName());
                Assert.assertEquals(cachedVal.getContigIndex(), uncachedVal.getContigIndex());
                Assert.assertEquals(cachedVal.getBases(), uncachedVal.getBases());
            }
        }

        // asserts for efficiency.  We are going to make contig.length / STEP_SIZE queries
        // at each of range: start -> start + querySize against a cache with size of X.
View Full Code Here

        for ( int i = 0; i < contig.getSequenceLength(); i += 10 ) {
            int start = i;
            int stop = start + querySize;
            if ( stop <= contig.getSequenceLength() ) {
                ReferenceSequence grabMiddle = caching.getSubsequenceAt(contig.getSequenceName(), middleStart, middleStop);
                ReferenceSequence cachedVal = caching.getSubsequenceAt(contig.getSequenceName(), start, stop);
                ReferenceSequence uncachedVal = uncached.getSubsequenceAt(contig.getSequenceName(), start, stop);

                Assert.assertEquals(cachedVal.getName(), uncachedVal.getName());
                Assert.assertEquals(cachedVal.getContigIndex(), uncachedVal.getContigIndex());
                Assert.assertEquals(cachedVal.getBases(), uncachedVal.getBases());
            }
        }
    }
View Full Code Here

        //
        if (clipSequencesArgs != null) {
            int i = 0;
            for (String toClip : clipSequencesArgs) {
                i++;
                ReferenceSequence rs = new ReferenceSequence("CMDLINE-" + i, -1, StringUtil.stringToBytes(toClip));
                addSeqToClip(rs.getName(), rs.getBases());
            }
        }

        if (clipSequenceFile != null) {
            ReferenceSequenceFile rsf = ReferenceSequenceFileFactory.getReferenceSequenceFile(new File(clipSequenceFile));

            while (true) {
                ReferenceSequence rs = rsf.nextSequence();
                if (rs == null)
                    break;
                else {
                    addSeqToClip(rs.getName(), rs.getBases());
                }
            }
        }

View Full Code Here

    public Integer map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
        final String locusContigName = ref.getLocus().getContig();
        if ( ! locusContigName.equals(contigName) ) {
            contigName = locusContigName;
            ReferenceSequence refSeq = uncachedRef.getSequence(contigName);
            contigStart = 1;
            contigEnd = contigStart + refSeq.length() - 1;
            uncachedBases = uncachedRef.getSubsequenceAt(contigName, contigStart, contigEnd).getBases();
            logger.info(String.format("Loading contig %s (%d-%d)", contigName, contigStart, contigEnd));
        }

        final byte refBase = ref.getBase();
View Full Code Here

TOP

Related Classes of htsjdk.samtools.reference.ReferenceSequence

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.