20 std::vector<size_t> pos;
30 throw IOException (
"PhredPhd::read: fail to open stream");
34 std::string name, sequence =
"";
36 std::vector<size_t> p;
38 flag =
parseFile_(input, name, sequence, q, p);
41 throw Exception(
"PhredPhd::read: sequence without name!");
56 bool PhredPhd::parseFile_(std::istream& input, std::string& name, std::string& sequence, std::vector<int>& qual, std::vector<size_t>& pos)
const
58 bool readSeqFlag =
false;
64 std::getline(input, temp,
'\n');
68 if (st.
getToken(0) ==
"BEGIN_SEQUENCE")
73 while (flag !=
"END_SEQUENCE" && !input.eof())
75 getline(input, temp,
'\n');
81 if (flag ==
"BEGIN_DNA")
83 readSeqFlag =
parseDNA_(input, sequence, qual, pos);
94 bool PhredPhd::parseDNA_(std::istream& input, std::string& sequence, std::vector<int>& qual, std::vector<size_t>& pos)
const
96 bool readSeqFlag =
false;
97 std::string line_buffer;
102 while (flag !=
"END_DNA" && !input.eof())
104 std::getline(input, line_buffer,
'\n');
113 pos.push_back(TextTools::to<size_t>(st.
getToken(2)));
void setName(const std::string &name) override
Set the name of this sequence.
bool nextSequence(std::istream &input, Sequence &seq) const
bool parseDNA_(std::istream &input, std::string &sequence, std::vector< int > &qual, std::vector< size_t > &pos) const
Parse the DNA part of the file.
bool parseFile_(std::istream &input, std::string &name, std::string &sequence, std::vector< int > &qual, std::vector< size_t > &pos) const
Global file parser.
A SequenceWithAnnotation class with quality scores attached.
void setQualities(const std::vector< int > &quality)
Set the whole quality scores.
A basic implementation of the Sequence interface.
void setContent(const std::string &sequence) override
Set the whole content of the sequence.
size_t numberOfRemainingTokens() const
bool hasMoreToken() const
const std::string & getToken(size_t pos) const
int toInt(const std::string &s, char scientificNotation='e')
std::string toUpper(const std::string &s)
This alphabet is used to deal NumericAlphabet.