public class IndexedFastaSequenceFile
extends java.lang.Object
implements java.io.Closeable
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.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
canCreateIndexedFastaReader(java.io.File fastaFile) |
static boolean |
canCreateIndexedFastaReader(java.nio.file.Path fastaFile) |
void |
close() |
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.
|
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()
Retrieves the sequence dictionary for the fasta 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.
|
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()
A simple toString implementation for debugging.
|
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 boolean isIndexed()
isIndexed
in interface ReferenceSequenceFile
public static boolean canCreateIndexedFastaReader(java.io.File fastaFile)
public static boolean canCreateIndexedFastaReader(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 SAMSequenceDictionary getSequenceDictionary()
getSequenceDictionary
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.public ReferenceSequence nextSequence()
nextSequence
in interface ReferenceSequenceFile
public void reset()
reset
in interface ReferenceSequenceFile
public java.lang.String toString()
toString
in interface ReferenceSequenceFile
public void close() throws java.io.IOException
close
in interface ReferenceSequenceFile
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
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 getAbsolutePath()