75 template<
typename TBackend>
100 f_.readStart(FASTA_file);
106 return chunk_offset_;
117 chunk_offset_ += data_fg_.size();
118 data_fg_.swap(data_bg_);
120 return !data_fg_.empty();
132 data_bg_.reserve(suggested_size);
134 for (
int i = 0; i < suggested_size; ++i)
136 std::streampos spos = f_.position();
137 if (!f_.readNext(p))
break;
138 data_bg_.push_back(std::move(p));
139 offsets_.push_back(spos);
141 return !data_bg_.empty();
147 return data_fg_.size();
159 return data_fg_[pos];
178 if (chunk_offset_ <= pos && pos < chunk_offset_ + chunkSize())
180 protein = data_fg_[pos - chunk_offset_];
184 if (pos >= offsets_.size())
188 std::streampos spos = f_.position();
189 if (!f_.setPosition(offsets_[pos]))
return false;
190 bool r = f_.readNext(protein);
191 f_.setPosition(spos);
198 return f_.atEnd() && offsets_.empty();
219 return offsets_.size();
264 if (!activate_count_)
303 protein = data_[pos];
310 return data_.empty();
327 const std::vector<FASTAFile::FASTAEntry>&
data_;
328 int activate_count_ = 0;
329 int cache_count_ = 0;
std::vector< FASTAFile::FASTAEntry > data_bg_
prefetched (background) data; will become the next active data
Definition: FASTAContainer.h:226
A more convenient string class.
Definition: String.h:57
const std::vector< FASTAFile::FASTAEntry > & data_
reference to existing data
Definition: FASTAContainer.h:327
bool readAt(FASTAFile::FASTAEntry &protein, size_t pos) const
fast access to an entry
Definition: FASTAContainer.h:301
Int overflow exception.
Definition: Exception.h:254
size_t size() const
calls size() on underlying vector
Definition: FASTAContainer.h:314
size_t getChunkOffset() const
how many entries were read and got swapped out already
Definition: FASTAContainer.h:104
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
bool activateCache()
no-op (since data is already fully available as vector)
Definition: FASTAContainer.h:262
bool readAt(FASTAFile::FASTAEntry &protein, size_t pos)
Retrieve a FASTA entry at global position (must not be behind the currently active chunk...
Definition: FASTAContainer.h:175
void reset()
required for template parameters!
Definition: FASTAContainer.h:320
const FASTAFile::FASTAEntry & chunkAt(size_t pos) const
fast access to chunked (i.e. all) entries
Definition: FASTAContainer.h:295
std::vector< std::streampos > offsets_
internal byte offsets into FASTA file for random access reading of previous entries.
Definition: FASTAContainer.h:224
template parameter for vector-based FASTA access
Definition: FASTAContainer.h:76
FASTAContainer(const std::vector< FASTAFile::FASTAEntry > &data)
C'tor for already existing data (by reference).
Definition: FASTAContainer.h:247
bool cacheChunk(int suggested_size)
Prefetch a new cache in the background, with up to suggestedSize entries (or fewer upon reaching EOF)...
Definition: FASTAContainer.h:129
bool cacheChunk(int)
no-op (since data is already fully available as vector)
Definition: FASTAContainer.h:275
std::vector< FASTAFile::FASTAEntry > data_fg_
active (foreground) data
Definition: FASTAContainer.h:225
size_t chunk_offset_
number of entries before the current chunk
Definition: FASTAContainer.h:227
void reset()
resets reading of the FASTA file, enables fresh reading of the FASTA from the beginning ...
Definition: FASTAContainer.h:202
FASTAContainer(const String &FASTA_file)
C'tor with FASTA filename.
Definition: FASTAContainer.h:93
size_t size() const
NOT the number of entries in the FASTA file, but merely the number of already read entries (since we ...
Definition: FASTAContainer.h:217
size_t chunkSize() const
number of entries in active cache
Definition: FASTAContainer.h:145
const FASTAFile::FASTAEntry & chunkAt(size_t pos) const
Retrieve a FASTA entry at cache position pos (fast)
Definition: FASTAContainer.h:157
FASTA entry type (identifier, description and sequence)
Definition: FASTAFile.h:76
size_t getChunkOffset() const
always 0, since this specialization requires/supports no chunking
Definition: FASTAContainer.h:253
This class serves for reading in and writing FASTA files.
Definition: FASTAFile.h:64
FASTAFile f_
FASTA file connection.
Definition: FASTAContainer.h:223
bool activateCache()
Swaps in the background cache of entries, read previously via cacheChunk()
Definition: FASTAContainer.h:115
bool empty() const
is the FASTA file empty?
Definition: FASTAContainer.h:196
bool empty() const
calls empty() on underlying vector
Definition: FASTAContainer.h:308
size_t chunkSize() const
active data spans the full range, i.e. size of container
Definition: FASTAContainer.h:289