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

Method getColumns

src/openms/source/FORMAT/SequestOutfile.cpp:397–476  ·  view source on GitHub ↗

get the columns from a line

Source from the content-addressed store, hash-verified

395
396 // get the columns from a line
397 bool
398 SequestOutfile::getColumns(
399 const String& line,
400 vector<String>& substrings,
401 Size number_of_columns,
402 Size reference_column)
403 {
404 String buffer;
405
406 if (line.empty())
407 {
408 return false;
409 }
410 line.split(' ', substrings);
411
412 // remove any empty strings
413 substrings.erase(remove(substrings.begin(), substrings.end(), ""), substrings.end());
414
415 for (vector<String>::iterator s_i = substrings.begin(); s_i != substrings.end(); )
416 {
417 // if there are three columns, the middle one being a '/', they are merged
418 if (s_i + 1 != substrings.end())
419 {
420 if (((*(s_i + 1)) == "/") && (s_i + 2 != substrings.end()))
421 {
422 s_i->append(*(s_i + 1));
423 s_i->append(*(s_i + 2));
424 substrings.erase(s_i + 2);
425 substrings.erase(s_i + 1);
426 }
427 // if there are two columns, and the first ends with, or the second starts with a '/', they are merged
428 else if ((*(s_i + 1))[0] == '/')
429 {
430 s_i->append(*(s_i + 1));
431 substrings.erase(s_i + 1);
432 }
433 else if ((*(s_i))[s_i->length() - 1] == '/')
434 {
435 s_i->append(*(s_i + 1));
436 substrings.erase(s_i + 1);
437 }
438 // if there are two columns and the second is a number preceded by a '+', they are merged
439 else if ((*(s_i + 1))[0] == '+')
440 {
441 bool is_digit(true);
442 for (Size i = 1; i < (s_i + 1)->length(); ++i)
443 {
444 is_digit &= (bool)isdigit((*(s_i + 1))[i]);
445 }
446 if (is_digit && ((s_i + 1)->length() - 1))
447 {
448 s_i->append(*(s_i + 1));
449 substrings.erase(s_i + 1);
450 }
451 else
452 {
453 ++s_i;
454 }

Callers 1

Calls 7

emptyMethod · 0.45
splitMethod · 0.45
eraseMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
appendMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected