30 fail(
"PIR/FASTA files start with '>'");
32 std::vector<FastaSeq>
r;
36 for (
size_t pos=0, end=0; end != std::string::npos; pos = end + 1) {
37 end = str.find(
'\n', pos);
38 if (str[pos] ==
'>') {
43 if (
pir && end != std::string::npos)
44 end = str.find(
'\n', end+1);
45 r.back().header = str.substr(pos+1, end-(pos+1));
47 std::string& seq =
r.back().seq;
48 for (
size_t i = pos;
i < std::min(end, str.size()); ++
i) {
50 if (std::isspace(c)) {
57 fail(
"'*' is interpreted as sequence terminator, here it is followed by: ", c);
59 fail(
"blank lines can be followed only by a line starting with '>'");
61 if ((
'a' <= (c | 0x20) && (c | 0x20) <=
'z') || c ==
'-' ||
64 }
else if (c ==
'*') {
67 }
else if (c ==
'(') {
69 fail(
"nested parentheses are not allowed");
70 }
else if (c ==
')') {
72 fail(
"')' without matching '('");
74 fail(
"unexpected character in sequence: ", c);
81 fail(
"unmatched '('");