Package htsjdk.samtools.reference
Class FastaSequenceFile
- java.lang.Object
-
- htsjdk.samtools.reference.FastaSequenceFile
-
- All Implemented Interfaces:
ReferenceSequenceFile,Closeable,AutoCloseable
public class FastaSequenceFile extends Object
Implementation of ReferenceSequenceFile for reading from FASTA files.
-
-
Field Summary
Fields Modifier and Type Field Description protected SAMSequenceDictionarysequenceDictionary
-
Constructor Summary
Constructors Constructor Description FastaSequenceFile(File file, boolean truncateNamesAtWhitespace)Constructs a FastaSequenceFile that reads from the specified file.FastaSequenceFile(String source, SeekableStream seekableStream, SAMSequenceDictionary dictionary, boolean truncateNamesAtWhitespace)Constructs a FastaSequenceFile that reads from the specified stream (which must not be compressed, i.e.FastaSequenceFile(Path path, boolean truncateNamesAtWhitespace)Constructs a FastaSequenceFile that reads from the specified file.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()It's good to call this to free up memory.protected static FilefindSequenceDictionary(File file)protected static PathfindSequenceDictionary(Path path)protected StringgetAbsolutePath()Returns the full path to the reference file.protected PathgetPath()Returns the path to the reference file.ReferenceSequencegetSequence(String contig)default implementation -- override if index is supportedSAMSequenceDictionarygetSequenceDictionary()Returns the list of sequence records associated with the reference sequence if found otherwise null.protected StringgetSource()Returns the named source of the reference file.ReferenceSequencegetSubsequenceAt(String contig, long start, long stop)default implementation -- override if index is supportedbooleanisIndexed()default implementation -- override if index is supportedReferenceSequencenextSequence()Retrieves the next whole sequences from the file.voidreset()Resets the ReferenceSequenceFile so that the next call to nextSequence() will return the first sequence in the file.StringtoString()Returns the full path to the reference file, or the source if no path was specified.
-
-
-
Field Detail
-
sequenceDictionary
protected SAMSequenceDictionary sequenceDictionary
-
-
Constructor Detail
-
FastaSequenceFile
public FastaSequenceFile(File file, boolean truncateNamesAtWhitespace)
Constructs a FastaSequenceFile that reads from the specified file.
-
FastaSequenceFile
public FastaSequenceFile(Path path, boolean truncateNamesAtWhitespace)
Constructs a FastaSequenceFile that reads from the specified file.
-
FastaSequenceFile
public FastaSequenceFile(String source, SeekableStream seekableStream, SAMSequenceDictionary dictionary, boolean truncateNamesAtWhitespace)
Constructs a FastaSequenceFile that reads from the specified stream (which must not be compressed, i.e. the caller is responsible for decompressing the stream).
-
-
Method Detail
-
close
public void close()
It's good to call this to free up memory.
-
nextSequence
public ReferenceSequence nextSequence()
Description copied from interface:ReferenceSequenceFileRetrieves the next whole sequences from the file.- Returns:
- a ReferenceSequence or null if at the end of the file
-
reset
public void reset()
Description copied from interface:ReferenceSequenceFileResets the ReferenceSequenceFile so that the next call to nextSequence() will return the first sequence in the file.
-
getPath
protected Path getPath()
Returns the path to the reference file.
-
getSource
protected String getSource()
Returns the named source of the reference file.
-
getSequenceDictionary
public SAMSequenceDictionary getSequenceDictionary()
Returns the list of sequence records associated with the reference sequence if found otherwise null.- Specified by:
getSequenceDictionaryin interfaceReferenceSequenceFile- Returns:
- a list of sequence records representing the sequences in this reference file
-
getAbsolutePath
protected String getAbsolutePath()
Returns the full path to the reference file.
-
toString
public String toString()
Returns the full path to the reference file, or the source if no path was specified.- Specified by:
toStringin interfaceReferenceSequenceFile- Overrides:
toStringin classObject- Returns:
- Reference name, file name, or something other human-readable representation.
-
isIndexed
public boolean isIndexed()
default implementation -- override if index is supported- Specified by:
isIndexedin interfaceReferenceSequenceFile- Returns:
- true if getSequence and getSubsequenceAt methods are allowed.
-
getSequence
public ReferenceSequence getSequence(String contig)
default implementation -- override if index is supported- Specified by:
getSequencein interfaceReferenceSequenceFile- Parameters:
contig- contig whose data should be returned.- Returns:
- The full sequence associated with this contig.
-
getSubsequenceAt
public ReferenceSequence getSubsequenceAt(String contig, long start, long stop)
default implementation -- override if index is supported- Specified by:
getSubsequenceAtin interfaceReferenceSequenceFile- Parameters:
contig- Contig whose subsequence to retrieve.start- inclusive, 1-based start of region.stop- inclusive, 1-based stop of region.- Returns:
- The partial reference sequence associated with this range.
-
-