Package htsjdk.samtools
Class BAMFileSpan
java.lang.Object
htsjdk.samtools.BAMFileSpan
- All Implemented Interfaces:
SAMFileSpan
,Serializable
,Cloneable
An ordered list of chunks, capable of representing a set of discontiguous
regions in the BAM file. FileSpans are mutable within the package, but perceived
as immutable outside the package.
Some operations on FileSpans assume that the spans are sorted. In these cases,
sort order will be validated.
- See Also:
-
Constructor Summary
ConstructorDescriptionCreate a new empty list of chunks.BAMFileSpan
(Chunk chunk) Convenience constructor to construct a BAM file span from a single chunk.BAMFileSpan
(List<Chunk> chunks) Create a new chunk list from the given list of chunks. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
add
(BAMFileSpan span) Merge one span into anotherprotected void
Adds a new chunk to this list.clone()
Deep clone the given chunk list.Gets the constituent chunks stored in this span.Gets a file span over the data immediately following this span.long
Find the first offset in the chunk listprotected Chunk
Checks that there is only a single chunk for this span and returns it.boolean
isEmpty()
Does this chunk list map to any position within the BAM file?static BAMFileSpan
merge
(BAMFileSpan[] spans) removeContentsAfter
(SAMFileSpan fileSpan) Creates a new file span by removing all chunks after the given file span ends.removeContentsBefore
(SAMFileSpan fileSpan) Creates a new file span by removing all chunks before the given file span starts.protected static SAMFileSpan
toChunkList
(long[] coordinateArray) The list of chunks is often represented as an array of longs where every even-numbered index is a start coordinate and every odd-numbered index is a stop coordinate.long[]
Convert the chunk list to an array of offsets, paired in [start,end) format.toString()
Creates a string representation of this chunk list.
-
Constructor Details
-
BAMFileSpan
public BAMFileSpan()Create a new empty list of chunks. -
BAMFileSpan
Convenience constructor to construct a BAM file span from a single chunk.- Parameters:
chunk
- Chunk to use as the sole region in this span.
-
BAMFileSpan
Create a new chunk list from the given list of chunks.- Parameters:
chunks
- Constituent chunks.
-
-
Method Details
-
isEmpty
public boolean isEmpty()Does this chunk list map to any position within the BAM file?- Specified by:
isEmpty
in interfaceSAMFileSpan
- Returns:
- True iff the ChunkList points to any data within the BAM.
-
clone
Deep clone the given chunk list. -
removeContentsBefore
Creates a new file span by removing all chunks before the given file span starts. If a chunk in the chunk list starts before and ends after the given chunk, the first portion of the chunk will be deleted.- Specified by:
removeContentsBefore
in interfaceSAMFileSpan
- Parameters:
fileSpan
- The filespan before which to eliminate.- Returns:
- A new BAMFileSpan which contains the portion of the chunk list after the given chunk.
-
removeContentsAfter
Creates a new file span by removing all chunks after the given file span ends. If a chunk in the chunk list starts before and ends after the given chunk, the second portion of the chunk will be deleted.- Parameters:
fileSpan
- The filespan after which to eliminate.- Returns:
- A new BAMFileSpan which contains the portion of the chunk list before the given chunk.
-
getContentsFollowing
Gets a file span over the data immediately following this span.- Specified by:
getContentsFollowing
in interfaceSAMFileSpan
- Returns:
- The a pointer to data immediately following this span.
-
add
Merge one span into another- Parameters:
span
- - span with chunks to add to this one
-
add
Adds a new chunk to this list. Visible only within the BAm.- Parameters:
chunk
- Chunk to add.
-
toCoordinateArray
public long[] toCoordinateArray()Convert the chunk list to an array of offsets, paired in [start,end) format.- Returns:
- Array of offsets.
-
getFirstOffset
public long getFirstOffset()Find the first offset in the chunk list- Returns:
- The first offset in the span
-
getChunks
Gets the constituent chunks stored in this span.- Returns:
- An unmodifiable list of chunks.
-
getSingleChunk
Checks that there is only a single chunk for this span and returns it.- Returns:
- The single chunk stored in this span
-
toChunkList
The list of chunks is often represented as an array of longs where every even-numbered index is a start coordinate and every odd-numbered index is a stop coordinate. Convert from that format back to a list of chunks.- Parameters:
coordinateArray
- List of chunks to convert.- Returns:
- A list of chunks.
-
toString
Creates a string representation of this chunk list. -
merge
- Returns:
- A single BAMFileSpan that is an intelligent merge of the input spans, i.e. contiguous, overlapping and contained chunks are intelligently merged, and the chunks are sorted.
-