Skip to content

Semi specific digestion - #8130

Merged
cbielow merged 12 commits into
OpenMS:developfrom
Jeremi-Maciejewski:Semi-specific_digestion
Jul 22, 2025
Merged

cbielow merged 12 commits into
OpenMS:developfrom
Jeremi-Maciejewski:Semi-specific_digestion

Conversation

@Jeremi-Maciejewski

@Jeremi-Maciejewski Jeremi-Maciejewski commented Jul 18, 2025 •

Copy link
Copy Markdown

Description

These changes implement support of performing semi-specific digestion to ProteaseDigestion, as requested in #8098 .
Also exposed via pyOpenMS.

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

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

Summary by CodeRabbit

  • New Features

    • Added support for semi-specific digestion in protease digestion, allowing generation of peptides with only one end at a cleavage site when specificity is set accordingly.
  • Documentation

    • Updated user documentation and code comments to describe semi-specific digestion functionality and provide usage examples.
  • Tests

    • Introduced new unit tests to verify semi-specific digestion and related behaviors.
    • Removed outdated tests for protease digestion.
    • Added test coverage for error handling and edge cases in semi-specific digestion.
  • Chores

    • Added a new contributor to the authors list.
    • Updated digestion specificity in decoy peptide generation to enforce full enzymatic specificity.

Jeremi Maciejewski added 4 commits July 17, 2025 16:06
… use it within its child Protease Digestion; expand ProteaseDigestion_test; expand ProteaseDigestion python binding test and move it from test000.py to new test_ProteaseDigestion.py
@coderabbitai

coderabbitai Bot commented Jul 18, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

The changes introduce support for semi-specific digestion in the ProteaseDigestion module, including a new internal method for generating semi-specific peptides, updates to documentation, and expanded unit tests. The changelog and authorship information are updated, and Python bindings and tests are enhanced to reflect and verify the new semi-specific digestion functionality.

Changes

File(s) Change Summary
AUTHORS Added "Jeremi Maciejewski" to the list of contributors.
CHANGELOG Documented the addition of semi-specific digestion and the new method EnzymaticDigestion.semiSpecificDigestion_().
src/openms/include/OpenMS/CHEMISTRY/EnzymaticDigestion.h
src/openms/source/CHEMISTRY/EnzymaticDigestion.cpp
Added protected/private method semiSpecificDigestion_ to generate semi-specific digestion products; updated authorship.
src/openms/include/OpenMS/CHEMISTRY/ProteaseDigestion.h Expanded documentation for the digest method to clarify semi-specific digestion support and specify exception throwing.
src/openms/source/CHEMISTRY/ProteaseDigestion.cpp Modified digest method to validate specificity values and call semiSpecificDigestion_ when specificity is semi-specific.
src/pyOpenMS/CMakeLists.txt Included new Python test file test_ProteaseDigestion.py in the test suite.
src/pyOpenMS/pxds/ProteaseDigestion.pxd Enhanced docstrings and usage examples to describe semi-specific digestion.
src/pyOpenMS/tests/unittests/test000.py Removed the old testProteaseDigestion unit test function.
src/pyOpenMS/tests/unittests/test_ProteaseDigestion.py Added new comprehensive unit test for ProteaseDigestion, covering semi-specific digestion and related features.
src/tests/class_tests/openms/source/ProteaseDigestion_test.cpp Added C++ tests for semi-specific digestion, including constraints and missed cleavages.
src/tests/class_tests/openms/source/EnzymaticDigestion_test.cpp Added test for semiSpecificDigestion_ method behavior and exception on invalid input; updated authorship.
src/openms/source/CHEMISTRY/DecoyGenerator.cpp Changed protease digestion specificity from SPEC_NONE to SPEC_FULL in reversePeptides and shufflePeptides.
src/tests/class_tests/openms/source/DecoyGenerator_test.cpp Corrected test section name from reversePeptide to reversePeptides.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ProteaseDigestion
    participant EnzymaticDigestion

    User->>ProteaseDigestion: setSpecificity(SPEC_SEMI)
    User->>ProteaseDigestion: digest(sequence)
    ProteaseDigestion->>EnzymaticDigestion: tokenize cleavage sites
    ProteaseDigestion->>EnzymaticDigestion: generate missed cleavage variants
    ProteaseDigestion->>EnzymaticDigestion: semiSpecificDigestion_(positions, ...)
    EnzymaticDigestion-->>ProteaseDigestion: semi-specific peptides
    ProteaseDigestion-->>User: all peptides (fully and semi-specific)
Loading

Estimated code review effort

3 (30–60 minutes)

Poem

In the lab where peptides play,
Semi-specific rules the day!
With Jeremi’s name now in the scroll,
Digestion’s logic is more whole.
New tests arise, old ones retire,
Peptides cleave as users desire—
🐰 Here’s to science hopping higher!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 561f69d and ee62177.

📒 Files selected for processing (1)
  • src/pyOpenMS/tests/unittests/test_ProteaseDigestion.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/pyOpenMS/tests/unittests/test_ProteaseDigestion.py
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@cbielow cbielow 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.

nice addition, thanks!

some comments below

@cbielow
cbielow marked this pull request as ready for review July 18, 2025 09:42

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 3

♻️ Duplicate comments (8)
src/openms/include/OpenMS/CHEMISTRY/ProteaseDigestion.h (1)

52-54: Documentation update looks good.

The expanded documentation clearly explains the semi-specific digestion behavior and provides the specific value (1) for SPEC_SEMI. This addresses the user's need to understand how to enable semi-specific digestion.

However, as mentioned in the past review comment, the documentation for the first digest method (line 49) should also be updated to reference this detailed explanation, as it's just a wrapper method.

src/openms/source/CHEMISTRY/ProteaseDigestion.cpp (1)

142-148: Add validation for specificity values.

The implementation only handles SPEC_SEMI but doesn't validate that the specificity is supported. According to the past review comment, you should test for specificity and throw an exception unless it's SEMI or FULL.

Add validation before the semi-specific block:

+    // Validate specificity
+    if (specificity_ != SPEC_FULL && specificity_ != SPEC_SEMI)
+    {
+      throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
+                                   "Unsupported specificity: " + String(specificity_), String(specificity_));
+    }
+
     // semi-specific variants
     if (specificity_ == SPEC_SEMI)
src/pyOpenMS/tests/unittests/test_ProteaseDigestion.py (1)

39-40: Add test for unsupported specificity.

According to the past review comment, you should test the new exception for unsupported specificity values like SPEC_UNKNOWN.

Add a test for unsupported specificity after line 40:

     # MHAR, LVP, HAR, LV, AR, L, R, MHA, VP, MH, P, M
     assert len(output) == 12
+    
+    # Test unsupported specificity
+    ff.setSpecificity(3)  # SPEC_UNKNOWN
+    try:
+        ff.digest(seq, output)
+        assert False, "Should have thrown exception for unsupported specificity"
+    except Exception as e:
+        assert "Unsupported specificity" in str(e)
src/openms/include/OpenMS/CHEMISTRY/EnzymaticDigestion.h (1)

182-195: Improve method documentation.

The method declaration is well-structured, but the documentation could be more specific about the behavior regarding fully-specific variants and missed cleavages.

According to the past review comments, please clarify:

  1. Will it skip fully specific variants?
  2. Will it take missed cleavages into account?

Update the documentation to be more explicit:

   /**
     @brief Generates semi-specific digestion products

-    Function handling semi-specific digestion (specificity == 1).
+    Function handling semi-specific digestion (specificity_ == Specificity::SPEC_SEMI).
     It is intended for calling after tokenizing and missed cleavages variants generation.
+    
+    This function generates semi-specific variants by allowing non-specific cleavage 
+    at one end while maintaining enzymatic specificity at the other end. It does not 
+    generate fully-specific variants (those are handled separately) and respects the 
+    missed cleavages settings.
src/tests/class_tests/openms/source/ProteaseDigestion_test.cpp (2)

238-242: Improve lambda function signature.

The lambda function declaration can be improved as suggested in the past review comment.

Apply the suggested improvement:

-    auto compare_aa = [&ref](AASequence seq) -> bool
+    auto compare_aa = [&ref](const AASequence& seq) -> bool

261-261: Consider using TEST_TRUE/TEST_FALSE macros.

As suggested in the past review comments, you could use the OpenMS test macros for better consistency.

Consider replacing the explicit boolean comparisons:

-    TEST_EQUAL(std::find_if(out.begin(),out.end(),compare_aa) != out.end(), true);
+    TEST_TRUE(std::find_if(out.begin(),out.end(),compare_aa) != out.end());
-    TEST_NOT_EQUAL(std::find_if(out.begin(),out.end(),compare_aa) != out.end(), true);
+    TEST_FALSE(std::find_if(out.begin(),out.end(),compare_aa) != out.end());

Also applies to: 267-267

src/openms/source/CHEMISTRY/EnzymaticDigestion.cpp (2)

135-136: Remove unnecessary std::abs call.

Since the lambda is called with positions where x < y by design (forward iteration starts from beginning, backward from end), the std::abs call is redundant.

-      if (min_length <= std::abs((int)y - (int)x) &&
-          max_length >= std::abs((int)y - (int)x))
+      if (min_length <= (y - x) &&
+          max_length >= (y - x))

144-144: Add safety check for cleavage_positions size.

The increment operations on iterators could cause undefined behavior if cleavage_positions has fewer than 2 elements. Consider adding a check at the beginning of the function.

 Size EnzymaticDigestion::semiSpecificDigestion_(const std::vector<int>& cleavage_positions, std::vector<std::pair<Size, Size>>& output, Size min_length, Size max_length) const
 {
+  if (cleavage_positions.size() < 2)
+  {
+    return 0;
+  }
   int mc = missed_cleavages_;
   Size wrong = 0;
🧹 Nitpick comments (5)
CHANGELOG (2)

32-34: Style: keep wording and enumeration value out of the public changelog.

“SPEC_SEMI (1)” leaks the concrete enum value and clutters the entry. Other bullets only name the symbolic constant.
Proposed wording:

-    - add support for semi-specific digestion in objects where specificity is set to SPEC_SEMI (1)
+    - add support for semi-specific digestion when specificity is set to `SPEC_SEMI`

This keeps the changelog concise and future-proof if the enum values ever change.


45-46: Minor consistency tweak: match existing naming pattern.

Elsewhere the changelog uses “::” for fully-qualified symbols (e.g. EnzymaticDigestion::isValidProduct).
For consistency consider:

- - Added `EnzymaticDigestion.semiSpecificDigestion_()`
+ - Added `EnzymaticDigestion::semiSpecificDigestion_()`

Purely cosmetic, but keeps symbol references uniform across sections.

src/pyOpenMS/pxds/ProteaseDigestion.pxd (2)

20-22: Use the enumeration constant instead of magic value in docs
The term “semi-specific” is clear, yet referring to it via the raw value 1 risks divergence if the enum ever changes. Prefer the symbolic constant exposed by the bindings (e.g. EnzymaticDigestion.SPEC_SEMI) in the docs to keep the example self-explanatory.

-#  If specificity is set to semi-specific, digestion also returns semi-specific products,
-#  i.e. with only one end at actual cleavage sites.
+#  If specificity is set to ``EnzymaticDigestion.SPEC_SEMI`` (value ``1``),
+#  digestion also returns semi-specific products, i.e. peptides with exactly one
+#  terminus at a canonical cleavage site.

51-55: Replace hard-coded “1” with the enum constant in the code snippet
Using the explicit enum improves readability and guards against future enum re-ordering.

-#        dig.setSpecificity(1)
+#        dig.setSpecificity(EnzymaticDigestion.SPEC_SEMI)
src/pyOpenMS/tests/unittests/test_ProteaseDigestion.py (1)

47-50: Improve boolean comparison style.

The static analysis correctly flags these equality comparisons with boolean literals as poor style.

Apply these changes to improve readability:

-    assert ff.isValidProduct(seq, 0, 4) == True
+    assert ff.isValidProduct(seq, 0, 4)
-    assert ff.isValidProduct(seq, 3, 4) == False
+    assert not ff.isValidProduct(seq, 3, 4)
-    assert ff.isValidProduct(seq, 1, 3) == True
+    assert ff.isValidProduct(seq, 1, 3)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 60cd3f8 and 086c3b5.

📒 Files selected for processing (11)
  • AUTHORS (1 hunks)
  • CHANGELOG (2 hunks)
  • src/openms/include/OpenMS/CHEMISTRY/EnzymaticDigestion.h (2 hunks)
  • src/openms/include/OpenMS/CHEMISTRY/ProteaseDigestion.h (1 hunks)
  • src/openms/source/CHEMISTRY/EnzymaticDigestion.cpp (2 hunks)
  • src/openms/source/CHEMISTRY/ProteaseDigestion.cpp (1 hunks)
  • src/pyOpenMS/CMakeLists.txt (1 hunks)
  • src/pyOpenMS/pxds/ProteaseDigestion.pxd (2 hunks)
  • src/pyOpenMS/tests/unittests/test000.py (1 hunks)
  • src/pyOpenMS/tests/unittests/test_ProteaseDigestion.py (1 hunks)
  • src/tests/class_tests/openms/source/ProteaseDigestion_test.cpp (3 hunks)
🧰 Additional context used
🧠 Learnings (1)
src/pyOpenMS/tests/unittests/test000.py (2)

undefined

<retrieved_learning>
Learnt from: FreezB11
PR: #7969
File: src/pyOpenMS/pxds/TMTThirtyTwoPlexQuantitationMethod.pxd:1-3
Timestamp: 2025-06-16T15:49:26.504Z
Learning: In OpenMS Python bindings (.pxd files), derived quantitation method classes like TMTThirtyTwoPlexQuantitationMethod only need to declare their constructors. All other public methods (getName, getChannelInformation, getNumberOfChannels, getIsotopeCorrectionMatrix, getReferenceChannel) are inherited from the base IsobaricQuantitationMethod class and don't need to be redeclared explicitly.
</retrieved_learning>

<retrieved_learning>
Learnt from: FreezB11
PR: #7969
File: src/pyOpenMS/pxds/TMTThirtyTwoPlexQuantitationMethod.pxd:4-4
Timestamp: 2025-06-16T15:48:09.667Z
Learning: In OpenMS .pxd files, the established pattern for extern from statements is to include angle brackets inside the string literal, like cdef extern from "<OpenMS/PATH/TO/FILE.h>" namespace "OpenMS":. This is consistent across all existing quantitation method .pxd files and other .pxd files in the OpenMS codebase.
</retrieved_learning>

🧬 Code Graph Analysis (2)
src/openms/source/CHEMISTRY/ProteaseDigestion.cpp (1)
src/openms/source/CHEMISTRY/EnzymaticDigestion.cpp (2)
  • semiSpecificDigestion_ (118-175)
  • semiSpecificDigestion_ (118-118)
src/openms/include/OpenMS/CHEMISTRY/EnzymaticDigestion.h (1)
src/openms/source/CHEMISTRY/EnzymaticDigestion.cpp (2)
  • semiSpecificDigestion_ (118-175)
  • semiSpecificDigestion_ (118-118)
🪛 Ruff (0.12.2)
src/pyOpenMS/tests/unittests/test_ProteaseDigestion.py

11-11: Undefined name report

(F821)


31-31: Undefined name AASequence

(F821)


47-47: Avoid equality comparisons to True; use ff.isValidProduct(seq, 0, 4): for truth checks

Replace with ff.isValidProduct(seq, 0, 4)

(E712)


48-48: Avoid equality comparisons to False; use not ff.isValidProduct(seq, 3, 4): for false checks

Replace with not ff.isValidProduct(seq, 3, 4)

(E712)


50-50: Avoid equality comparisons to True; use ff.isValidProduct(seq, 1, 3): for truth checks

Replace with ff.isValidProduct(seq, 1, 3)

(E712)

🔇 Additional comments (7)
AUTHORS (1)

55-56: Author entry looks good – alphabetical order preserved.

Entry is correctly inserted between "Jang Jang Jin" and "Jihyung Kim".
No further action required.

src/pyOpenMS/CMakeLists.txt (1)

573-579: Do not remove test000.py—it contains active tests

test000.py isn’t an obsolete placeholder but a large, catch-all test module with dozens of active def test_*() functions (e.g., test_AcquisitionInfo(), test_MapConversion(), test_BSpline2d(), etc.). Removing it would drop substantial coverage.

• src/pyOpenMS/tests/unittests/test000.py defines many critical tests and must remain.
• Your new test_ProteaseDigestion.py is fine—just ensure its tests don’t duplicate those already in test000.py.
• If you want to break up test000.py for clarity, consider refactoring its contents into smaller, feature-specific files rather than deleting it outright.

Likely an incorrect or invalid review comment.

src/pyOpenMS/tests/unittests/test000.py (1)

3-10: Header metadata looks fine – nothing actionable.

Only header/comment lines were touched. No functional changes in the test suite to review here.

src/openms/include/OpenMS/CHEMISTRY/EnzymaticDigestion.h (1)

6-6: Author addition looks good.

The addition of "Jeremi Maciejewski" to the authors list is appropriate for this contribution.

src/tests/class_tests/openms/source/ProteaseDigestion_test.cpp (2)

16-16: Algorithm include addition is appropriate.

The <algorithm> include is needed for the std::find_if function used in the new tests.


231-290: Excellent comprehensive test coverage.

The semi-specific digestion tests are thorough and cover all the important scenarios:

  • Compatibility with unspecific cleavage
  • Presence of fully-specific and semi-specific variants
  • Correct cleavage site iteration order
  • Missed cleavages handling
  • Length constraints application

This provides good confidence in the implementation correctness.

src/openms/source/CHEMISTRY/EnzymaticDigestion.cpp (1)

6-6: Author attribution looks good.

Adding the contributor to the file header is appropriate for tracking contributions.

Expanded and reworded documentation, added some input data checks and exceptions to `ProteaseDigestion.digest()` and `EnzymaticDigestion.semiSpecificDigestion_()`, added some tests.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 0

♻️ Duplicate comments (1)
src/pyOpenMS/tests/unittests/test_ProteaseDigestion.py (1)

9-16: Fix missing imports to resolve runtime errors.

The static analysis correctly identifies missing imports that will cause runtime errors.

Add the missing imports at the top of the file:

+from functools import wraps
+from pyopenms.testutils import report
 import pyopenms
-
-def report(f):
-    @wraps(f)
-    def wrapper(*a, **kw):
-        print("run ", f.__name__)
-        f(*a, **kw)
-    return wrapper
🧹 Nitpick comments (3)
src/tests/class_tests/openms/source/EnzymaticDigestion_test.cpp (2)

285-310: Good start, but consider expanding test coverage.

The test correctly uses a temporary subclass to expose the protected method and properly tests the exception case for empty cleavage positions. However, the test coverage could be more comprehensive.

Consider adding more test cases to verify:

  • Normal operation with valid cleavage positions
  • Edge cases with single cleavage position
  • Boundary conditions for min/max length parameters
+    // Test normal operation
+    std::vector<int> valid_positions = {0, 3, 7};
+    TEST_EQUAL(tmp.tmpSemiSpecificDigestion_(valid_positions, output, 1, 100) > 0, true);
+    
+    // Test single cleavage position
+    std::vector<int> single_position = {0, 5};
+    output.clear();
+    TEST_EQUAL(tmp.tmpSemiSpecificDigestion_(single_position, output, 1, 100) > 0, true);

303-303: Fix type inconsistency for OpenMS conventions.

Use Size instead of size_t to maintain consistency with OpenMS conventions and the method signature.

-    std::vector<std::pair<size_t,size_t>> output = {};
+    std::vector<std::pair<Size,Size>> output = {};
src/pyOpenMS/tests/unittests/test_ProteaseDigestion.py (1)

54-57: Improve boolean comparison style.

Follow PEP 8 conventions by using truthiness instead of explicit boolean comparisons.

-    assert ff.isValidProduct(seq, 0, 4) == True
+    assert ff.isValidProduct(seq, 0, 4)
-    assert ff.isValidProduct(seq, 3, 4) == False
+    assert not ff.isValidProduct(seq, 3, 4)
     ff.setSpecificity(1)
-    assert ff.isValidProduct(seq, 1, 3) == True
+    assert ff.isValidProduct(seq, 1, 3)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 086c3b5 and 36fdbbf.

📒 Files selected for processing (7)
  • src/openms/include/OpenMS/CHEMISTRY/EnzymaticDigestion.h (2 hunks)
  • src/openms/include/OpenMS/CHEMISTRY/ProteaseDigestion.h (2 hunks)
  • src/openms/source/CHEMISTRY/EnzymaticDigestion.cpp (2 hunks)
  • src/openms/source/CHEMISTRY/ProteaseDigestion.cpp (2 hunks)
  • src/pyOpenMS/tests/unittests/test_ProteaseDigestion.py (1 hunks)
  • src/tests/class_tests/openms/source/EnzymaticDigestion_test.cpp (2 hunks)
  • src/tests/class_tests/openms/source/ProteaseDigestion_test.cpp (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/openms/include/OpenMS/CHEMISTRY/ProteaseDigestion.h
  • src/openms/include/OpenMS/CHEMISTRY/EnzymaticDigestion.h
  • src/openms/source/CHEMISTRY/EnzymaticDigestion.cpp
  • src/tests/class_tests/openms/source/ProteaseDigestion_test.cpp
  • src/openms/source/CHEMISTRY/ProteaseDigestion.cpp
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/tests/class_tests/openms/source/EnzymaticDigestion_test.cpp (2)
src/openms/source/CHEMISTRY/EnzymaticDigestion.cpp (2)
  • semiSpecificDigestion_ (118-183)
  • semiSpecificDigestion_ (118-118)
src/openms/source/CONCEPT/Exception.cpp (1)
  • InvalidValue (224-228)
src/pyOpenMS/tests/unittests/test_ProteaseDigestion.py (2)
src/pyOpenMS/tests/unittests/test000.py (2)
  • report (38-43)
  • wrapper (40-42)
src/openms/source/CHEMISTRY/ProteaseDigestion.cpp (12)
  • setEnzyme (21-25)
  • setEnzyme (21-21)
  • digest (71-85)
  • digest (71-71)
  • digest (87-158)
  • digest (87-87)
  • peptideCount (48-69)
  • peptideCount (48-48)
  • isValidProduct (27-35)
  • isValidProduct (27-32)
  • isValidProduct (37-46)
  • isValidProduct (37-42)
🪛 Ruff (0.12.2)
src/pyOpenMS/tests/unittests/test_ProteaseDigestion.py

12-12: Undefined name wraps

(F821)


54-54: Avoid equality comparisons to True; use ff.isValidProduct(seq, 0, 4): for truth checks

Replace with ff.isValidProduct(seq, 0, 4)

(E712)


55-55: Avoid equality comparisons to False; use not ff.isValidProduct(seq, 3, 4): for false checks

Replace with not ff.isValidProduct(seq, 3, 4)

(E712)


57-57: Avoid equality comparisons to True; use ff.isValidProduct(seq, 1, 3): for truth checks

Replace with ff.isValidProduct(seq, 1, 3)

(E712)

🔇 Additional comments (3)
src/tests/class_tests/openms/source/EnzymaticDigestion_test.cpp (1)

6-6: LGTM! Author information properly updated.

The addition of "Jeremi Maciejewski" to the authors list aligns with the PR objectives and follows the proper format.

src/pyOpenMS/tests/unittests/test_ProteaseDigestion.py (2)

38-38: No additional import needed for AASequence.

The usage pyopenms.AASequence.fromString() is correct since pyopenms is imported. The past review comment suggesting a separate import for AASequence is not necessary.


19-63: Excellent test coverage for ProteaseDigestion functionality.

The test comprehensively covers the ProteaseDigestion class functionality, including:

  • Constructor and enzyme setup
  • Both full-specific and semi-specific digestion modes
  • Peptide counting and validation
  • Missed cleavage handling

The test logic is well-structured and aligns with the PR objectives for semi-specific digestion support.

Jeremi Maciejewski added 4 commits July 18, 2025 15:26
Fixed invalid (not implemented)  use of SPEC_NONE with `ProteaseDigestion::digest()` by functions `DecoyGenerator::reversePeptides()` and `DecoyGenerator::shufflePeptides()`.
These now use `SPEC_FULL`, which should produce identical results as before - but perhaps this was not the behaviour intended?

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 36fdbbf and 7601ad9.

📒 Files selected for processing (5)
  • src/openms/source/CHEMISTRY/DecoyGenerator.cpp (2 hunks)
  • src/pyOpenMS/pxds/ProteaseDigestion.pxd (2 hunks)
  • src/pyOpenMS/tests/unittests/test_ProteaseDigestion.py (1 hunks)
  • src/tests/class_tests/openms/source/DecoyGenerator_test.cpp (1 hunks)
  • src/tests/class_tests/openms/source/ProteaseDigestion_test.cpp (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/tests/class_tests/openms/source/DecoyGenerator_test.cpp
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/tests/class_tests/openms/source/ProteaseDigestion_test.cpp
  • src/pyOpenMS/pxds/ProteaseDigestion.pxd
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/pyOpenMS/tests/unittests/test_ProteaseDigestion.py (3)
src/pyOpenMS/tests/unittests/test000.py (2)
  • report (38-43)
  • wrapper (40-42)
src/openms/source/CHEMISTRY/ProteaseDigestion.cpp (12)
  • setEnzyme (21-25)
  • setEnzyme (21-21)
  • digest (71-85)
  • digest (71-71)
  • digest (87-158)
  • digest (87-87)
  • peptideCount (48-69)
  • peptideCount (48-48)
  • isValidProduct (27-35)
  • isValidProduct (27-32)
  • isValidProduct (37-46)
  • isValidProduct (37-42)
src/openms/source/CHEMISTRY/EnzymaticDigestion.cpp (12)
  • setEnzyme (61-65)
  • setEnzyme (61-61)
  • getEnzymeName (67-70)
  • getEnzymeName (67-67)
  • setSpecificity (87-90)
  • setSpecificity (87-87)
  • isValidProduct (190-193)
  • isValidProduct (190-190)
  • getMissedCleavages (51-54)
  • getMissedCleavages (51-51)
  • setMissedCleavages (56-59)
  • setMissedCleavages (56-56)
🪛 GitHub Check: CodeFactor
src/pyOpenMS/tests/unittests/test_ProteaseDigestion.py

[notice] 56-56: src/pyOpenMS/tests/unittests/test_ProteaseDigestion.py#L56
Multiple spaces before operator. (E221)


[notice] 56-56: src/pyOpenMS/tests/unittests/test_ProteaseDigestion.py#L56
Multiple spaces after keyword. (E271)

🪛 Ruff (0.12.2)
src/pyOpenMS/tests/unittests/test_ProteaseDigestion.py

56-56: SyntaxError: Expected an expression

🔇 Additional comments (8)
src/openms/source/CHEMISTRY/DecoyGenerator.cpp (4)

45-45: LGTM: Enforcing full specificity for decoy generation.

This change correctly enforces full enzymatic specificity during peptide reversal for decoy generation, ensuring that cleavage sites are respected and maintaining biological relevance of the decoy peptides.


73-73: LGTM: Consistent specificity enforcement in shuffling.

This change mirrors the specificity enforcement in the reversePeptides function, ensuring consistent behavior across both decoy generation methods. Full specificity is appropriate here to maintain proper enzymatic cleavage patterns.


45-45: LGTM: Improved specificity enforcement for consistent decoy generation.

The change from SPEC_NONE to SPEC_FULL ensures that decoy peptides maintain the same enzymatic cleavage specificity as the original peptides, which is crucial for maintaining the quality and consistency of decoy generation.


73-73: LGTM: Consistent specificity enforcement across decoy generation methods.

This change mirrors the improvement in reversePeptides() and ensures that shuffled decoy peptides also maintain proper enzymatic specificity, providing consistency across all decoy generation approaches.

src/pyOpenMS/tests/unittests/test_ProteaseDigestion.py (4)

44-48: Excellent test coverage for semi-specific digestion.

This test correctly validates the semi-specific digestion functionality by:

  1. Setting specificity to semi-specific mode (1)
  2. Testing that the number of peptides increases significantly (from 2 to 12)
  3. Covering the expected peptide products from the sequence "MHARLVP"

The test aligns perfectly with the PR objectives for implementing semi-specific digestion support.


57-58: Good validation of specificity-dependent behavior.

The test properly demonstrates that isValidProduct behavior changes based on the specificity setting, showing that semi-specific mode (1) accepts products that full specificity (2) would reject.


20-64: Comprehensive test structure with good coverage.

The test function provides excellent coverage of the ProteaseDigestion class functionality:

  • Constructor and method availability checks
  • Enzyme setting and retrieval
  • Digestion with different specificity modes
  • Peptide counting and validation
  • Missed cleavage handling

The docstring clearly documents what's being tested, making it easy to understand the test scope.


20-64: Excellent test coverage for ProteaseDigestion functionality.

The test comprehensively covers the key methods and the new semi-specific digestion feature. The expected peptide counts (2 for full specificity, 12 for semi-specific) appear reasonable for the test sequence "MHARLVP", and the test structure is well-organized with clear documentation.

@cbielow cbielow 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.

nice. almost there :)

Comment thread CHANGELOG Resolved
…tion_; missing documentation; additional tests; fix pyOpenMS tests

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f768e94 and 0764851.

📒 Files selected for processing (1)
  • src/pyOpenMS/tests/unittests/test_ProteaseDigestion.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.12.2)
src/pyOpenMS/tests/unittests/test_ProteaseDigestion.py

55-55: Undefined name true

(F821)


55-55: Undefined name false

(F821)


55-55: Undefined name false

(F821)


56-56: Undefined name true

(F821)


56-56: Undefined name false

(F821)


56-56: Undefined name false

(F821)


58-58: Undefined name true

(F821)


58-58: Undefined name false

(F821)


58-58: Undefined name false

(F821)

🔇 Additional comments (5)
src/pyOpenMS/tests/unittests/test_ProteaseDigestion.py (5)

1-11: LGTM! Imports and file header are correct.

The imports are properly structured and the file header follows the project conventions.


12-17: Well-implemented decorator function.

The report decorator properly uses functools.wraps to preserve function metadata and follows standard Python decorator patterns.


19-37: Excellent test structure and documentation.

The test function is well-documented with a comprehensive docstring and follows good testing practices with method existence checks and enzyme setup verification.


38-54: Comprehensive test coverage for digestion functionality.

The test effectively covers both fully-specific and semi-specific digestion modes. The expected peptide counts (2 vs 12) align well with the semi-specific digestion feature being introduced.


60-64: Proper testing of missed cleavages functionality.

The getter/setter test for missed cleavages is well-implemented and verifies the functionality correctly.

@Jeremi-Maciejewski
Jeremi-Maciejewski force-pushed the Semi-specific_digestion branch from 0764851 to 561f69d Compare July 21, 2025 14:36
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.

2 participants