public class BlockCompressedIndexedFastaSequenceFile
extends java.lang.Object
Supports two interfaces: the ReferenceSequenceFile for old-style, stateful lookups and a direct getter.
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) |
BlockCompressedIndexedFastaSequenceFile(java.lang.String source,
SeekableStream in,
FastaSequenceIndex index,
SAMSequenceDictionary dictionary,
GZIIndex gziIndex)
Initialize the given indexed fasta sequence file stream.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected SAMSequenceDictionary |
findAndLoadSequenceDictionary(java.nio.file.Path fasta)
Attempts to find and load the sequence dictionary if present.
|
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)
Deprecated.
use findSequenceDictionary(Path) instead.
|
protected static java.nio.file.Path |
findSequenceDictionary(java.nio.file.Path fastaPath)
Attempts to locate the sequence dictionary file adjacent to the reference fasta file.
|
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.
|
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)
public BlockCompressedIndexedFastaSequenceFile(java.lang.String source, SeekableStream in, FastaSequenceIndex index, SAMSequenceDictionary dictionary, GZIIndex gziIndex)
source
- The named source of the reference file (used in error messages).in
- The input stream to read the fasta file from; should not be decompressed already.index
- The fasta index.dictionary
- The sequence dictionary, or null if there isn't one.gziIndex
- The GZI index; may not be null.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 SAMSequenceDictionary findAndLoadSequenceDictionary(java.nio.file.Path fasta)
@Deprecated protected static java.io.File findSequenceDictionary(java.io.File file)
protected static java.nio.file.Path findSequenceDictionary(java.nio.file.Path fastaPath)
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