# Interface ReferenceSequenceFile

All Superinterfaces:
  `AutoCloseable, Closeable`

All Known Implementing Classes:
  `BlockCompressedIndexedFastaSequenceFile, FastaSequenceFile, IndexedFastaSequenceFile`

public interface ReferenceSequenceFile extends Closeable
An interface for working with files of reference sequences regardless of the file format being used.

## Method Summary

Modifier and Type
Method
Description
`void`
`close()`
`ReferenceSequence`
`getSequence(String contig)`
Retrieves the complete sequence described by this contig.
`SAMSequenceDictionary`
`getSequenceDictionary()`
Must return a sequence dictionary with at least the following fields completed for each sequence: name, length.
`default ReferenceSequence`
`getSubsequenceAt(Locatable locatable)`
Gets the subsequence of the contig in the locatable.
`ReferenceSequence`
`getSubsequenceAt(String contig, long start, long stop)`
Gets the subsequence of the contig in the range [start,stop]
`boolean`
`isIndexed()`
`ReferenceSequence`
`nextSequence()`
Retrieves the next whole sequences from the file.
`void`
`reset()`
Resets the ReferenceSequenceFile so that the next call to nextSequence() will return the first sequence in the file.
`String`
`toString()`

## Method Details

### getSequenceDictionary

SAMSequenceDictionary getSequenceDictionary()
Must return a sequence dictionary with at least the following fields completed for each sequence: name, length.

Returns:
  a list of sequence records representing the sequences in this reference file

### nextSequence

ReferenceSequence nextSequence()
Retrieves the next whole sequences from the file.

Returns:
  a ReferenceSequence or null if at the end of the file

### reset

void reset()
Resets the ReferenceSequenceFile so that the next call to nextSequence() will return the first sequence in the file.

### isIndexed

boolean isIndexed()

Returns:
  true if getSequence and getSubsequenceAt methods are allowed.

### getSequence

ReferenceSequence getSequence(String contig)
Retrieves the complete sequence described by this contig.

Parameters:
  `contig` - contig whose data should be returned.
Returns:
  The full sequence associated with this contig.
Throws:
  `UnsupportedOperationException` - if !sIndexed.

### getSubsequenceAt

ReferenceSequence getSubsequenceAt(String contig, long start, long stop)
Gets the subsequence of the contig in the range [start,stop]

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.
Throws:
  `UnsupportedOperationException` - if !sIndexed.

### getSubsequenceAt

default ReferenceSequence getSubsequenceAt(Locatable locatable)
Gets the subsequence of the contig in the locatable. Shortcut to `getSubsequenceAt(locatable.getContig(), locatable.getStart(), locatable.getEnd());`

Parameters:
  `locatable` - the interval to retrieve.
Returns:
  The partial reference sequence associated with this location.
Throws:
  `UnsupportedOperationException` - if !sIndexed.

### toString

String toString()

Overrides:
  `toString` in class `Object`
Returns:
  Reference name, file name, or something other human-readable representation.

### close

void close() throws IOException

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `Closeable`
Throws:
  `IOException`