Skip to content

refactor(DigestionEnzyme): move sense-based constructor to DigestionE…#174

Open
TheClaervoyant wants to merge 2 commits into
cbielow:developfrom
TheClaervoyant:clean-digestion-enzyme
Open

refactor(DigestionEnzyme): move sense-based constructor to DigestionE…#174
TheClaervoyant wants to merge 2 commits into
cbielow:developfrom
TheClaervoyant:clean-digestion-enzyme

Conversation

@TheClaervoyant

Copy link
Copy Markdown

…nzymeProtein, danke Git
Ich habe mein gesamtes Repo gesmited und neu gebuilded und die Files dann nachträglich meine Files gemoved. Should work now

Description

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

Click to expand If your PR is failing you can check out
  • The details of the action statuses at the end of the PR or the "Checks" tab.
  • http://cdash.seqan.de/index.php?project=OpenMS and look for your PR. Use the "Show filters" capability on the top right to search for your PR number.
    If you click in the column that lists the failed tests you will get detailed error messages.

Advanced commands (admins / reviewer only)

Click to expand
  • /reformat (experimental) applies the clang-format style changes as additional commit. Note: your branch must have a different name (e.g., yourrepo:feature/XYZ) than the receiving branch (e.g., OpenMS:develop). Otherwise, reformat fails to push.
  • 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

⚠️ 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).

@github-actions

Copy link
Copy Markdown

Welcome @TheClaervoyant and thank you for your contribution to OpenMS! To help us better understand our userbase and contributors, we would appreciate if you could complete the survey at the link below. Completing this survey will help us get to your PR sooner. Thank you for your participation!

Survey

@cbielow cbielow left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

nice change.
some minor things to consider.

//@{
//@{
/// default constructor
DigestionEnzyme();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

why make this public?
This default enzyme is not functional.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Changed it to protected. DigestionEnzyme Protein and DigestionEnzymeRNA need it. But to not access it from outside i made it protected

{
public:

enum Sense {C_TERM,N_TERM};

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
enum Sense {C_TERM,N_TERM};
enum class Sense {C_TERM,N_TERM};

Comment on lines +56 to +61
explicit DigestionEnzymeProtein(const String& name,
String cut_before,
Sense sense,
const String& nocut_after = "",
const std::set<String>& synonyms = std::set<String>(),
String regex_description = "");

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

  1. make all Strings of the form "const String&". There is no point in moving, since this is not high performance code, and the strings are short, so SSO (small string optimization) should kick in anyway.

  2. add @param comments. e.g. its important to understand that e.g. cut_before is treated as a set of amino acids where cutting can occur, and not as a string. e.g. trypsin would be 'KR', or 'RK' (order does not matter)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done. I think. I removed move were I could


Int omssa_id_;

String buildRegex_(String& cut_before, const String& nocut_after,const DigestionEnzymeProtein::Sense& sense);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
String buildRegex_(String& cut_before, const String& nocut_after,const DigestionEnzymeProtein::Sense& sense);
String buildRegex_(String cut_before, const String& nocut_after,const DigestionEnzymeProtein::Sense& sense);

you don't want to add 'X' and have that reflected in the caller.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Also adapted

Comment on lines +224 to +249
if (cut_before.empty())
{
throw Exception::MissingInformation(
__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
"No cleavage position given when trying to construct a DigestionEnzyme.");
}

for(char c : cut_before)
{
if (c > 'Z' || c < 'A')
{
throw Exception::InvalidParameter(
__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
"Amino Acids for cleavage contain unknown character: " + String(c));
}
}

for(char c : nocut_after)
{
if (c > 'Z' || c < 'A')
{
throw Exception::InvalidParameter(
__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
"Amino Acids to stop cleavage contain unknown character: " + String(c));
}
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

document these exceptions in the constructor using

@throw Exception::InvalidParameter if ....

TEST_EQUAL(enzyme.getSynonyms().size(),2)

// Test incorrect keys.
TEST_NOT_EQUAL(enzyme.setValueFromFile("test","Tryp-Like"),true)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
TEST_NOT_EQUAL(enzyme.setValueFromFile("test","Tryp-Like"),true)
TEST_FALSE(enzyme.setValueFromFile("test","Tryp-Like"))

Comment on lines +71 to +72
TEST_EQUAL(enzyme == "Verify",true)
TEST_NOT_EQUAL(enzyme == "Accept",true)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

...

Comment on lines +103 to +104
DigestionEnzyme enzyme;
enzyme.setName("TestEnzyme");

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

a default enzyme should not be allowed IMHO

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I removed this Test. In order to initialise an empty Enzyme tho, I used DigestionEnzymeProtein, since this is possible there. I just test the base functions, however. Imo the best middleground between needed test and good readability.

Comment on lines +286 to +287
DigestionEnzymeProtein n_term_test("N-Term_Style", "D", DigestionEnzymeProtein::Sense::N_TERM, "E");
TEST_EQUAL(n_term_test.getRegEx(), "(?<![E])(?=[DX])")

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

add a test where 'X' is already present (but not as a suffix)

Comment on lines +304 to +305
DigestionEnzymeProtein with_x("AlreadyX", "KX", DigestionEnzymeProtein::Sense::C_TERM);
TEST_EQUAL(with_x.getRegEx(), "(?<=[KX])")

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

nice.
Add another one where 'X' is a prefix

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I made both, I think, however, that they are redundant. We do not want an X other than as a Suffix, since an X anywhere would mean "This Protease can cut at undefined Enzymes" which practically includes everyone. Thus somehow rendering it useless. Both are included, but both will throw an Exception.

…DigestionEnzyme protected (classes like DEP and DERNA need it). Removed empty test from DigestionEnzyme_test. Used DigestionEnzymeProtein for Default Initialization. DigestionEnzymeProtein checks whether X is in cut_before. If its not a Suffix, throw Exception, since cutting anywhere is not a realistic Protease (X means any Amino Acid and cut_before is a SET as to where to cleave)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants