MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / parseString_

Method parseString_

src/openms/source/CHEMISTRY/NASequence.cpp:355–412  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 }

Callers

nothing calls this directly

Calls 13

getInstanceFunction · 0.85
stringClass · 0.85
setFivePrimeModMethod · 0.80
getRibonucleotideMethod · 0.80
backMethod · 0.80
setThreePrimeModMethod · 0.80
StringClass · 0.50
clearMethod · 0.45
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected