| 353 | } |
| 354 | |
| 355 | void NASequence::parseString_(const String& s, NASequence& nas) |
| 356 | { |
| 357 | nas.clear(); |
| 358 | |
| 359 | if (s.empty()) |
| 360 | return; |
| 361 | |
| 362 | static RibonucleotideDB* rdb = RibonucleotideDB::getInstance(); |
| 363 | |
| 364 | String::ConstIterator str_it = s.begin(); |
| 365 | if (*str_it == 'p') // special case for 5' phosphate |
| 366 | { |
| 367 | nas.setFivePrimeMod(rdb->getRibonucleotide("5'-p")); |
| 368 | ++str_it; |
| 369 | } |
| 370 | else if (*str_it == '*') // special case for 5' phosphorothioate |
| 371 | { |
| 372 | nas.setFivePrimeMod(rdb->getRibonucleotide("5'-p*")); |
| 373 | ++str_it; |
| 374 | } |
| 375 | String::ConstIterator stop = s.end(); |
| 376 | if ((s.size() > 1) && (s.back() == 'p')) // special case for 3' phosphate |
| 377 | { |
| 378 | nas.setThreePrimeMod(rdb->getRibonucleotide("3'-p")); |
| 379 | --stop; |
| 380 | } |
| 381 | else if ((s.size() > 1) && (s.back() == 'c')) // special case for 3' cyclo-phosphate |
| 382 | { |
| 383 | nas.setThreePrimeMod(rdb->getRibonucleotide("3'-c")); |
| 384 | --stop; |
| 385 | } |
| 386 | for (; str_it != stop; ++str_it) |
| 387 | { |
| 388 | // skip spaces |
| 389 | if (*str_it == ' ') |
| 390 | continue; |
| 391 | |
| 392 | // default case: add unmodified, standard ribonucleotide |
| 393 | if (*str_it != '[') |
| 394 | { |
| 395 | try |
| 396 | { |
| 397 | ConstRibonucleotidePtr r = rdb->getRibonucleotide(string(1, *str_it)); |
| 398 | nas.seq_.push_back(r); |
| 399 | } |
| 400 | catch (Exception::ElementNotFound&) |
| 401 | { |
| 402 | String msg = "Cannot convert string to nucleic acid sequence: invalid character '" + String(*str_it) + "'"; |
| 403 | throw Exception::ParseError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, s, msg); |
| 404 | } |
| 405 | } |
| 406 | else // if (*str_it == '[') // non-standard ribonucleotide |
| 407 | { |
| 408 | // parse modified ribonucleotide and add it to the sequence: |
| 409 | str_it = parseMod_(str_it, s, nas); |
| 410 | } |
| 411 | } |
| 412 | } |
nothing calls this directly
no test coverage detected