public class BlockCompressedIndexedFastaSequenceFile
extends java.lang.Object
Supports two interfaces: the ReferenceSequenceFile for old-style, stateful lookups and a direct getter.
Modifier and Type | Field and Description |
---|---|
protected SAMSequenceDictionary |
sequenceDictionary |
Constructor and Description |
---|
BlockCompressedIndexedFastaSequenceFile(java.nio.file.Path path) |
BlockCompressedIndexedFastaSequenceFile(java.nio.file.Path path,
FastaSequenceIndex index) |
BlockCompressedIndexedFastaSequenceFile(java.nio.file.Path path,
FastaSequenceIndex index,
GZIIndex gziIndex) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected static java.nio.file.Path |
findFastaIndex(java.nio.file.Path fastaFile) |
protected static java.nio.file.Path |
findRequiredFastaIndexFile(java.nio.file.Path fastaFile) |
protected static java.io.File |
findSequenceDictionary(java.io.File file) |
protected static java.nio.file.Path |
findSequenceDictionary(java.nio.file.Path path) |
protected java.lang.String |
getAbsolutePath()
Returns the full path to the reference file.
|
FastaSequenceIndex |
getIndex() |
protected java.nio.file.Path |
getPath()
Returns the path to the reference file.
|
ReferenceSequence |
getSequence(java.lang.String contig)
Retrieves the complete sequence described by this contig.
|
SAMSequenceDictionary |
getSequenceDictionary()
Returns the list of sequence records associated with the reference sequence if found
otherwise null.
|
protected java.lang.String |
getSource()
Returns the named source of the reference file.
|
ReferenceSequence |
getSubsequenceAt(java.lang.String contig,
long start,
long stop)
Gets the subsequence of the contig in the range [start,stop]
|
boolean |
isIndexed()
default implementation -- override if index is supported
|
ReferenceSequence |
nextSequence()
Gets the next sequence if available, or null if not present.
|
protected int |
readFromPosition(java.nio.ByteBuffer buffer,
long position)
Reads a sequence of bytes from this sequence file into the given buffer,
starting at the given file position.
|
void |
reset()
Reset the iterator over the index.
|
protected static void |
sanityCheckDictionaryAgainstIndex(java.lang.String fastaFile,
SAMSequenceDictionary sequenceDictionary,
FastaSequenceIndex index)
Do some basic checking to make sure the dictionary and the index match.
|
java.lang.String |
toString()
Returns the full path to the reference file, or the source if no path was specified.
|
protected SAMSequenceDictionary sequenceDictionary
public BlockCompressedIndexedFastaSequenceFile(java.nio.file.Path path) throws java.io.FileNotFoundException
java.io.FileNotFoundException
public BlockCompressedIndexedFastaSequenceFile(java.nio.file.Path path, FastaSequenceIndex index)
public BlockCompressedIndexedFastaSequenceFile(java.nio.file.Path path, FastaSequenceIndex index, GZIIndex gziIndex)
protected int readFromPosition(java.nio.ByteBuffer buffer, long position) throws java.io.IOException
buffer
- the buffer into which bytes are to be transferredposition
- the position to start reading atjava.io.IOException
- if an I/O error occurs while readingpublic void close() throws java.io.IOException
java.io.IOException
protected static java.nio.file.Path findRequiredFastaIndexFile(java.nio.file.Path fastaFile) throws java.io.FileNotFoundException
java.io.FileNotFoundException
protected static java.nio.file.Path findFastaIndex(java.nio.file.Path fastaFile)
protected static void sanityCheckDictionaryAgainstIndex(java.lang.String fastaFile, SAMSequenceDictionary sequenceDictionary, FastaSequenceIndex index)
fastaFile
- Used for error reporting only.sequenceDictionary
- sequence dictionary to check against the index.index
- index file to check against the dictionary.public FastaSequenceIndex getIndex()
public ReferenceSequence nextSequence()
public void reset()
public final boolean isIndexed()
isIndexed
in interface ReferenceSequenceFile
public ReferenceSequence getSequence(java.lang.String contig)
getSequence
in interface ReferenceSequenceFile
contig
- contig whose data should be returned.public ReferenceSequence getSubsequenceAt(java.lang.String contig, long start, long stop)
getSubsequenceAt
in interface ReferenceSequenceFile
contig
- Contig whose subsequence to retrieve.start
- inclusive, 1-based start of region.stop
- inclusive, 1-based stop of region.protected static java.io.File findSequenceDictionary(java.io.File file)
protected static java.nio.file.Path findSequenceDictionary(java.nio.file.Path path)
protected java.nio.file.Path getPath()
protected java.lang.String getSource()
public SAMSequenceDictionary getSequenceDictionary()
getSequenceDictionary
in interface ReferenceSequenceFile
protected java.lang.String getAbsolutePath()
public java.lang.String toString()
toString
in interface ReferenceSequenceFile
toString
in class java.lang.Object