fork download
  1. #include <fstream>
  2. #include <iostream>
  3. #include <sstream>
  4. #include <string>
  5. #include <vector>
  6.  
  7. const std::string data_text =
  8. R"(>MCHU - Calmodulin - Human, rabbit, bovine, rat, and chicken
  9. ADQLTEEQIAEFKEAFSLFDKDGDGTITTKELGTVMRSLGQNPTEAELQDMINEVDADGNGTID
  10. FPEFLTMMARKMKDTDSEEEIREAFRVFDKDGNGYISAAELRHVMTNLGEKLTDEEVDEMIREA
  11. DIDGDGQVNYEEFVQMMTAK*
  12. >gi|5524211|gb|AAD44166.1| cytochrome b [Elephas maximus maximus]
  13. LCLYTHIGRNIYYGSYLYSETWNTGIMLLLITMATAFMGYVLPWGQMSFWGATVITNLFSAIPYIGTNLV
  14. EWIWGGFSVDKATLNRFFAFHFILPFTMVALAGVHLTFLHETGSNNPLGLTSDSDKIPFHPYYTIKDFLG
  15. LLILILLLLLLALLSPDMLGDPDNHMPADPLNTPLHIKPEWYFLFAYAILRSVPNKLGGVLALFLSIVIL
  16. GLMPFLHTSKHRSMMLRPLSQALFWTLTMDLLTLTWIGSQPVEYPYTIIGQMASILYFSIILAFLPIAGX
  17. IENY
  18. )";
  19.  
  20. std::istringstream in(data_text);
  21.  
  22. int main()
  23. {
  24. std::string line;
  25. std::vector<std::string> sequences;
  26. bool in_sequence = false;
  27.  
  28. while (getline(in, line))
  29. {
  30. if (in_sequence)
  31. {
  32. if (line.size() && line.front() != '>')
  33. sequences.back() += line;
  34. else if (line.front() == '>')
  35. in_sequence = false;
  36. }
  37. else if (line.size() && line.front() != '>')
  38. {
  39. sequences.push_back(line);
  40. in_sequence = true;
  41. }
  42. }
  43.  
  44. for (auto seq : sequences)
  45. std::cout << seq << "\n\n";
  46. }
  47.  
  48.  
Success #stdin #stdout 0s 3432KB
stdin
Standard input is empty
stdout
ADQLTEEQIAEFKEAFSLFDKDGDGTITTKELGTVMRSLGQNPTEAELQDMINEVDADGNGTIDFPEFLTMMARKMKDTDSEEEIREAFRVFDKDGNGYISAAELRHVMTNLGEKLTDEEVDEMIREADIDGDGQVNYEEFVQMMTAK*

LCLYTHIGRNIYYGSYLYSETWNTGIMLLLITMATAFMGYVLPWGQMSFWGATVITNLFSAIPYIGTNLVEWIWGGFSVDKATLNRFFAFHFILPFTMVALAGVHLTFLHETGSNNPLGLTSDSDKIPFHPYYTIKDFLGLLILILLLLLLALLSPDMLGDPDNHMPADPLNTPLHIKPEWYFLFAYAILRSVPNKLGGVLALFLSIVILGLMPFLHTSKHRSMMLRPLSQALFWTLTMDLLTLTWIGSQPVEYPYTIIGQMASILYFSIILAFLPIAGXIENY