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

Method getSequences

src/openms/source/FORMAT/SequestOutfile.cpp:479–539  ·  view source on GitHub ↗

retrieve the sequences

Source from the content-addressed store, hash-verified

477
478 // retrieve the sequences
479 void
480 SequestOutfile::getSequences(
481 const String& database_filename,
482 const map<String, Size>& ac_position_map,
483 vector<String>& sequences,
484 vector<pair<String, Size> >& found,
485 map<String, Size>& not_found)
486 {
487 ifstream database_file(database_filename.c_str());
488 if (!database_file)
489 {
490 throw Exception::FileNotFound(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, database_filename);
491 }
492
493 String line, accession, accession_type, sequence;
494 not_found = ac_position_map;
495 map<String, Size>::iterator nf_i = not_found.end();
496 while (getline(database_file, line) && !not_found.empty())
497 {
498 if (!line.empty() && (line[line.length() - 1] < 33))
499 {
500 line.resize(line.length() - 1);
501 }
502
503 line.trim();
504
505 // empty and comment lines are skipped
506 if (line.empty() || line.hasPrefix(";"))
507 {
508 continue;
509 }
510 // the sequence belonging to the predecessing protein ('>') is stored, so
511 // when a new protein ('>') is found, save the sequence of the old
512 // protein
513 if (line.hasPrefix(">"))
514 {
515 getACAndACType(line, accession, accession_type);
516 if (nf_i != not_found.end())
517 {
518 sequences.push_back(sequence);
519 found.emplace_back(*nf_i);
520 not_found.erase(nf_i);
521 }
522 nf_i = not_found.find(accession); // for the first protein in the database, there's no predecessing protein
523 sequence.clear();
524 }
525 else if (nf_i != not_found.end())
526 {
527 sequence.append(line);
528 }
529 }
530 if (nf_i != not_found.end())
531 {
532 sequences.push_back(sequence);
533 found.emplace_back(*nf_i);
534 not_found.erase(nf_i);
535 }
536

Callers

nothing calls this directly

Calls 11

emplace_backMethod · 0.80
endMethod · 0.45
emptyMethod · 0.45
resizeMethod · 0.45
hasPrefixMethod · 0.45
push_backMethod · 0.45
eraseMethod · 0.45
findMethod · 0.45
clearMethod · 0.45
appendMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected