Java Code Examples for htsjdk.samtools.SAMFileHeader#getSequenceIndex()

The following examples show how to use htsjdk.samtools.SAMFileHeader#getSequenceIndex() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BamSlicer.java    From hmftools with GNU General Public License v3.0 6 votes vote down vote up
private static QueryInterval[] createIntervals(@NotNull final List<GenomeRegion> regions, @NotNull final SAMFileHeader header)
{
    final QueryInterval[] queryIntervals = new QueryInterval[regions.size()];

    for (int i = 0; i < regions.size(); ++i)
    {
        final GenomeRegion region = regions.get(i);
        int sequenceIndex = header.getSequenceIndex(region.chromosome());

        if (sequenceIndex < 0)
            return null;


        queryIntervals[i] = new QueryInterval(sequenceIndex, (int) region.start(), (int) region.end());
    }

    return queryIntervals;
}
 
Example 2
Source File: SAMSlicer.java    From hmftools with GNU General Public License v3.0 5 votes vote down vote up
@NotNull
private static QueryInterval[] createIntervals(@NotNull final Collection<GenomeRegion> regions, @NotNull final SAMFileHeader header) {
    final List<QueryInterval> queryIntervals = Lists.newArrayList();
    for (final GenomeRegion region : regions) {
        int sequenceIndex = header.getSequenceIndex(region.chromosome());
        if (sequenceIndex > -1) {
            queryIntervals.add(new QueryInterval(sequenceIndex, (int) region.start(), (int) region.end()));
        }
    }
    return QueryInterval.optimizeIntervals(queryIntervals.toArray(new QueryInterval[queryIntervals.size()]));
}
 
Example 3
Source File: SamSlicer.java    From hmftools with GNU General Public License v3.0 5 votes vote down vote up
@NotNull
private static QueryInterval[] createIntervals(@NotNull final Collection<GenomeRegion> regions, @NotNull final SAMFileHeader header) {
    final List<QueryInterval> queryIntervals = Lists.newArrayList();
    for (final GenomeRegion region : regions) {
        int sequenceIndex = header.getSequenceIndex(region.chromosome());
        if (sequenceIndex > -1) {
            queryIntervals.add(new QueryInterval(sequenceIndex, (int) region.start(), (int) region.end()));
        }
    }
    return QueryInterval.optimizeIntervals(queryIntervals.toArray(new QueryInterval[queryIntervals.size()]));
}
 
Example 4
Source File: BAMQueryFilteringIterator.java    From cramtools with Apache License 2.0 5 votes vote down vote up
public BAMQueryFilteringIterator(final CloseableIterator<SAMRecord> iterator, final String sequence,
		final int start, final int end, final QueryType queryType, SAMFileHeader fileHeader) {
	this.wrappedIterator = iterator;
	mReferenceIndex = fileHeader.getSequenceIndex(sequence);
	mRegionStart = start;
	if (queryType == QueryType.STARTING_AT) {
		mRegionEnd = mRegionStart;
	} else {
		mRegionEnd = (end <= 0) ? Integer.MAX_VALUE : end;
	}
	mQueryType = queryType;
	mNextRecord = advance();
}