public class IndexedFastaSequenceFile
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected SAMSequenceDictionary |
sequenceDictionary |
Constructor and Description |
---|
IndexedFastaSequenceFile(java.io.File file)
Open the given indexed fasta sequence file.
|
IndexedFastaSequenceFile(java.io.File file,
FastaSequenceIndex index)
Open the given indexed fasta sequence file.
|
IndexedFastaSequenceFile(java.nio.file.Path path)
Open the given indexed fasta sequence file.
|
IndexedFastaSequenceFile(java.nio.file.Path path,
FastaSequenceIndex index)
Open the given indexed fasta sequence file.
|
IndexedFastaSequenceFile(java.lang.String source,
SeekableStream in,
FastaSequenceIndex index,
SAMSequenceDictionary dictionary)
Initialise the given indexed fasta sequence file stream.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
canCreateIndexedFastaReader(java.io.File fastaFile)
Deprecated.
|
static boolean |
canCreateIndexedFastaReader(java.nio.file.Path fastaFile)
Deprecated.
|
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 channel 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 IndexedFastaSequenceFile(java.io.File file, FastaSequenceIndex index)
file
- The file to open.index
- Pre-built FastaSequenceIndex, for the case in which one does not exist on disk.java.io.FileNotFoundException
- If the fasta or any of its supporting files cannot be found.public IndexedFastaSequenceFile(java.io.File file) throws java.io.FileNotFoundException
file
- The file to open.java.io.FileNotFoundException
- If the fasta or any of its supporting files cannot be found.public IndexedFastaSequenceFile(java.nio.file.Path path, FastaSequenceIndex index)
path
- The file to open.index
- Pre-built FastaSequenceIndex, for the case in which one does not exist on disk.public IndexedFastaSequenceFile(java.nio.file.Path path) throws java.io.FileNotFoundException
path
- The file to open.java.io.FileNotFoundException
- If the fasta or any of its supporting files cannot be found.public IndexedFastaSequenceFile(java.lang.String source, SeekableStream in, FastaSequenceIndex index, SAMSequenceDictionary dictionary)
source
- The named source of the reference file (used in error messages).in
- The input stream to read the fasta file from.index
- The fasta index.dictionary
- The sequence dictionary, or null if there isn't one.@Deprecated public static boolean canCreateIndexedFastaReader(java.io.File fastaFile)
ReferenceSequenceFileFactory.canCreateIndexedFastaReader(Path)
instead.@Deprecated public static boolean canCreateIndexedFastaReader(java.nio.file.Path fastaFile)
ReferenceSequenceFileFactory.canCreateIndexedFastaReader(Path)
instead.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