-
- // seek to beginning of sequence data
- if ( fseeko(Stream, referenceData.Offset, SEEK_SET) != 0 ) {
- cerr << "FASTA error : could not sek in file" << endl;
- return false;
- }
-
- // retrieve sequence
- string sequence = "";
- if ( !GetNextSequence(sequence) ) {
- cerr << "FASTA error : could not retrieve base from FASTA file" << endl;
+
+ // calculate seek position & attempt jump
+ const int64_t lines = position / referenceData.LineLength;
+ const int64_t lineOffset = position % referenceData.LineLength;
+ const int64_t seekTo = referenceData.Offset + (lines*referenceData.ByteLength) + lineOffset;
+ if ( fseek64(Stream, seekTo, SEEK_SET) != 0 ) {
+ cerr << "FASTA error : could not seek in file" << endl;