| 147 | } |
| 148 | |
| 149 | bool FASTAFile::readNext(FASTAEntry &protein) |
| 150 | { |
| 151 | if (infile_.eof()) |
| 152 | { |
| 153 | return false; |
| 154 | } |
| 155 | |
| 156 | seq_.clear(); // Note: it is fine to clear() after std::move as it will turn the "valid but unspecified state" into a specified (the empty) one |
| 157 | id_.clear(); |
| 158 | description_.clear(); |
| 159 | |
| 160 | if (!readEntry_(id_, description_, seq_)) |
| 161 | { |
| 162 | if (entries_read_ == 0) |
| 163 | { |
| 164 | seq_ = "The first entry could not be read!"; |
| 165 | } |
| 166 | else |
| 167 | { |
| 168 | seq_ = "Only " + String(entries_read_) + " proteins could be read. Parsing next record failed."; |
| 169 | } |
| 170 | throw Exception::ParseError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "", |
| 171 | "Error while parsing FASTA file! " + seq_ + " Please check the file!"); |
| 172 | } |
| 173 | ++entries_read_; |
| 174 | |
| 175 | protein.identifier = std::move(id_); |
| 176 | protein.description = std::move(description_); |
| 177 | protein.sequence = std::move(seq_); |
| 178 | |
| 179 | return true; |
| 180 | } |
| 181 | |
| 182 | std::streampos FASTAFile::position() |
| 183 | { |
no test coverage detected