refactor(DigestionEnzyme): move sense-based constructor to DigestionE…#174
refactor(DigestionEnzyme): move sense-based constructor to DigestionE…#174TheClaervoyant wants to merge 2 commits into
Conversation
|
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! |
cbielow
left a comment
There was a problem hiding this comment.
nice change.
some minor things to consider.
| //@{ | ||
| //@{ | ||
| /// default constructor | ||
| DigestionEnzyme(); |
There was a problem hiding this comment.
why make this public?
This default enzyme is not functional.
There was a problem hiding this comment.
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}; |
There was a problem hiding this comment.
| enum Sense {C_TERM,N_TERM}; | |
| enum class Sense {C_TERM,N_TERM}; |
| 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 = ""); |
There was a problem hiding this comment.
-
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.
-
add @param comments. e.g. its important to understand that e.g.
cut_beforeis 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)
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
| 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.
| 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)); | ||
| } | ||
| } |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
| TEST_NOT_EQUAL(enzyme.setValueFromFile("test","Tryp-Like"),true) | |
| TEST_FALSE(enzyme.setValueFromFile("test","Tryp-Like")) |
| TEST_EQUAL(enzyme == "Verify",true) | ||
| TEST_NOT_EQUAL(enzyme == "Accept",true) |
| DigestionEnzyme enzyme; | ||
| enzyme.setName("TestEnzyme"); |
There was a problem hiding this comment.
a default enzyme should not be allowed IMHO
There was a problem hiding this comment.
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.
| DigestionEnzymeProtein n_term_test("N-Term_Style", "D", DigestionEnzymeProtein::Sense::N_TERM, "E"); | ||
| TEST_EQUAL(n_term_test.getRegEx(), "(?<![E])(?=[DX])") |
There was a problem hiding this comment.
add a test where 'X' is already present (but not as a suffix)
| DigestionEnzymeProtein with_x("AlreadyX", "KX", DigestionEnzymeProtein::Sense::C_TERM); | ||
| TEST_EQUAL(with_x.getRegEx(), "(?<=[KX])") |
There was a problem hiding this comment.
nice.
Add another one where 'X' is a prefix
There was a problem hiding this comment.
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)
…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
How can I get additional information on failed tests during CI
Click to expand
If your PR is failing you can check outIf 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.rebuild jenkinswill retrigger Jenkins-based CI builds