forked from OpenMS/OpenMS
-
Notifications
You must be signed in to change notification settings - Fork 5
refactor(DigestionEnzyme): move sense-based constructor to DigestionE… #174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
TheClaervoyant
wants to merge
2
commits into
cbielow:develop
Choose a base branch
from
TheClaervoyant:clean-digestion-enzyme
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,12 +3,13 @@ | |
| // | ||
| // -------------------------------------------------------------------------- | ||
| // $Maintainer: Xiao Liang $ | ||
| // $Authors: Xiao Liang $ | ||
| // $Authors: Xiao Liang, Alen Šarić $ | ||
| // -------------------------------------------------------------------------- | ||
| // | ||
|
|
||
| #include <OpenMS/CHEMISTRY/DigestionEnzymeProtein.h> | ||
|
|
||
| #include <algorithm> | ||
| #include <iostream> | ||
|
|
||
| using namespace std; | ||
|
|
@@ -42,24 +43,33 @@ namespace OpenMS | |
| DigestionEnzymeProtein::DigestionEnzymeProtein(const String& name, | ||
| const String& cleavage_regex, | ||
| const std::set<String>& synonyms, | ||
| String regex_description, | ||
| const String& regex_description, | ||
| EmpiricalFormula n_term_gain, | ||
| EmpiricalFormula c_term_gain, | ||
| String psi_id, | ||
| String xtandem_id, | ||
| const String& psi_id, | ||
| const String& xtandem_id, | ||
| Int comet_id, | ||
| Int msgf_id, | ||
| Int omssa_id) : | ||
| DigestionEnzyme(name, cleavage_regex, synonyms, std::move(regex_description)), | ||
| DigestionEnzyme(name, cleavage_regex, synonyms,regex_description), | ||
| n_term_gain_(std::move(n_term_gain)), | ||
| c_term_gain_(std::move(c_term_gain)), | ||
| psi_id_(std::move(psi_id)), | ||
| xtandem_id_(std::move(xtandem_id)), | ||
| psi_id_(psi_id), | ||
| xtandem_id_(xtandem_id), | ||
| comet_id_(comet_id), | ||
| msgf_id_(msgf_id), | ||
| omssa_id_(omssa_id) | ||
| { | ||
| } | ||
| DigestionEnzymeProtein::DigestionEnzymeProtein(const String& name, | ||
| const String& cut_before, | ||
| Sense sense, | ||
| const String& nocut_after, | ||
| const std::set<String>& synonyms, | ||
| const String& regex_description): | ||
| DigestionEnzyme(name, buildRegex_(cut_before, nocut_after, sense), synonyms, regex_description) | ||
| { | ||
| } | ||
|
|
||
| DigestionEnzymeProtein::~DigestionEnzymeProtein() = default; | ||
|
|
||
|
|
@@ -210,6 +220,70 @@ namespace OpenMS | |
| return false; | ||
| } | ||
|
|
||
| String DigestionEnzymeProtein::buildRegex_(String cut_before, const String& nocut_after, const DigestionEnzymeProtein::Sense& sense) | ||
| { | ||
| 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)); | ||
| } | ||
| } | ||
|
|
||
| if (!cut_before.hasSuffix("X")) | ||
| { | ||
| if(cut_before.find('X') != std::string::npos){ | ||
| throw Exception::InvalidParameter(__FILE__,__LINE__,OPENMS_PRETTY_FUNCTION,"cut_before must not contain X in the set of cleavage points, as this creates a Protease which would cleave everywhere."); | ||
| } | ||
| cut_before += "X"; | ||
| } | ||
|
|
||
|
Comment on lines
+252
to
+259
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this is copied, but we may as well do it right when touching it: Also document (in the C'tor) that 'X' is added to the cleavage site |
||
| String result = ""; | ||
| if (sense == DigestionEnzymeProtein::Sense::C_TERM) | ||
| { | ||
| result = "(?<=[" + cut_before + "])"; | ||
| if (!nocut_after.empty()) | ||
| { | ||
| result += "(?!" + nocut_after + "])"; | ||
| } | ||
| } | ||
| else if (sense == DigestionEnzymeProtein::Sense::N_TERM) | ||
| { | ||
| if (!nocut_after.empty()) | ||
| { | ||
| result = "(?<![" + nocut_after + "])"; | ||
| } | ||
| result += "(?=[" + cut_before + "])"; | ||
| } | ||
| else | ||
| { | ||
| throw Exception::MissingInformation( | ||
| __FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, | ||
| "Cannot infer cleavage sense. Has to be N or C."); | ||
| } | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| ostream& operator<<(ostream& os, const DigestionEnzymeProtein& enzyme) | ||
| { | ||
| os << static_cast<const DigestionEnzyme&>(enzyme) << " " | ||
|
|
@@ -218,4 +292,3 @@ namespace OpenMS | |
| } | ||
|
|
||
| } | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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