Skip to content

read swath window file with no header try #2 - #6077

Merged
timosachsenberg merged 10 commits into
OpenMS:developfrom
jcharkow:feature/noSwathHeader
May 4, 2022
Merged

timosachsenberg merged 10 commits into
OpenMS:developfrom
jcharkow:feature/noSwathHeader

Conversation

@jcharkow

Copy link
Copy Markdown
Collaborator

Reopen #6070 with alternative branch so that code formatting does not fail

In response to #6055 allow
openSwath to be able to read window files with no header.

Description

Please include a summary of the change and which issue is fixed.

Checklist:

  • Make sure that you are listed in the AUTHORS file
  • Add relevant changes and new features to the CHANGELOG file
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes
  • Updated or added python bindings for changed or new classes. (Tick if no updates were necessary.)

How can I get additional information on failed tests during CI:

If your PR is failing you can check out

Note:

  • Once you opened a PR try to minimize the number of pushes to it as every push will trigger CI (automated builds and test) and is rather heavy on our infrastructure (e.g., if several pushes per day are performed).

Advanced commands (admins / reviewer only):

  • /reformat (experimental) applies the clang-format style changes as additional commit
  • setting the label "NoJenkins" will skip tests for this PR on jenkins (saves resources e.g., on edits that do not affect tests)
  • commenting with rebuild jenkins will retrigger Jenkins-based CI builds

In response to OpenMS#6055 allow
openSwath to be able to read window files with no header.
@timosachsenberg

Copy link
Copy Markdown
Contributor

/reformat

@timosachsenberg

Copy link
Copy Markdown
Contributor

hmm there still seems to be wrong with the reformat script. not sure why it e.g. reformated SiriusAdapterAlgorithm at all

@timosachsenberg

Copy link
Copy Markdown
Contributor

sorry can you revert the last commit by the linter?

@timosachsenberg

Copy link
Copy Markdown
Contributor

I will revert

@jpfeuffer

Copy link
Copy Markdown
Contributor

Probably a GitHub bug since it tagged your comment for a completely different commit. Please raise an issue there or with their customer support

This reverts commit 83875b6.
@jcharkow

jcharkow commented May 2, 2022

Copy link
Copy Markdown
Collaborator Author

Is this ready to be merged?

@jpfeuffer jpfeuffer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check the logging. Unless there are problems with multithreading, please use OPENMS_LOG_...

std::getline(data, line); // possible header (or first line)
if (std::any_of(line.begin(), line.end(), [](char const &c) { return std::isalpha(c); }))
{ // if any of the characters are alphabetical then there is a header
std::cout << "Read Swath window header: '" << line << "'\n";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::cout << "Read Swath window header: '" << line << "'\n";
OPENMS_LOG_INFO << "Read Swath window header: '" << line << "'\n";

jcharkow added 2 commits May 2, 2022 13:56
previous check would not detect examples like 4e2 as a valid swath
window (and would put this as a header instead). Allow "e" characters to
be supported.

Also revert back to std::cout because OPENMS_LOG_INFO does not seem to
be working.
#include <OpenMS/CONCEPT/Types.h>
#include <OpenMS/CONCEPT/Exception.h>
#include <OpenMS/DATASTRUCTURES/String.h>
#include <OpenMS/SYSTEM/SysInfo.h>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: we sort headers by name

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By filename or filepath?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Path

// Check for presence of header
std::getline(data, line);
try { // If string can be successfully converted to double (excluding initial spaces) then the first line is not a header
StringUtils::split(line.trim(), ' ', headerSubstrings);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in OpenMS we mainly use tab separated files not space separated.
Would it make sense to make this consistent here?
or allow both?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test file seems to use space separation (as oppose to tabs) so I think we should keep the space separation. I tried to address this issue here 10064a2

{ // If string can be successfully converted to double (excluding initial spaces) then the first line is not a header
StringUtils::split(line.trim(), ' ', headerSubstrings);
StringUtils::toDouble(headerSubstrings[0]);
std::cout << "Swath Header not found \n";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happened to OpenMS log? :D

jcharkow added 3 commits May 3, 2022 11:06
when use std::endl instead of \n the OPENMS LOG statements work
…to feature/noSwathHeader

fix ordering of the include statements
allow for headers separated by tab deliminators to also be
accepted
@timosachsenberg

Copy link
Copy Markdown
Contributor

Thanks. Looks good from my side.

@timosachsenberg
timosachsenberg merged commit 71a1a27 into OpenMS:develop May 4, 2022
@timosachsenberg

Copy link
Copy Markdown
Contributor

FYI: https://cdash.openms.de/viewBuildError.php?buildid=36147 I can fix it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants