Skip to content

Question of how to perform Semi-Digestion with pyopenms #8098

Closed

Description

Hi,
I am trying to use pyopenms (3.4.0) to digest protein into peptides in-silico.
Other functions work well on the user guide page, however, the semi digestion (e.g. semi-tryptic) cannot be used when I try the following codes (which was written by me, following the instructions:

import pyopenms as oms
dig = oms.ProteaseDigestion()
dig.setEnzyme("Trypsin/P")
bsa = oms.AASequence.fromString("ACCCCCCCCDRPCCCCCCCCCCKCCCCCCCC")

dig.setSpecificity(1)
result = []
dig.digest(bsa, result)
for seq in result:
    print(seq.toString())

The outputs are the same with the full-tryptic digestion:

ACCCCCCCCDR
PCCCCCCCCCCK
CCCCCCCC

I wonder if there is anything wrong with my usage, and thanks a lot for your response!

Best Wishes,
Jim

Activity

  1. timosachsenberg commented on Jul 2, 2025

    @timosachsenberg
    Contributor

    Hi,

    I had a look at the code, and from what I can tell (perhaps @cbielow can confirm), SPEC_SEMI is only applied after the initial digestion—likely to further filter the digestion products.

    I’m wondering if this behavior is intentional. It might be, given that there are some valid use cases for it in PeptideIndexer.

    For now, I’d suggest generating, for example, the N-terminally cleaved variants from the sequences produced by the standard trypsin digest.

    That said, maybe it’s worth discussing whether we should instead generate these semi-specific sequences directly during the digestion step. This could offer more flexibility and consistency depending on the downstream use case.

  2. added
    toBeConfirmed
    on Jul 2, 2025
  3. timosachsenberg commented on Jul 2, 2025

    @timosachsenberg
    Contributor

    Great, that's really helpful — thanks!

    I believe this can also be implemented fairly easily in the C++ library and exposed via pyOpenMS.
    The more challenging part for me is determining the right level of granularity.

    For example, how should we handle different enzymatic cleavage (N-term vs C-term) and how should this interplay with semi-specific cleavage?
    Do others distinguish between semi-specific cleavage at the N- vs. C-terminus e.g. dependent on the enzyme?

  4. cbielow commented on Jul 2, 2025

    @cbielow
    Contributor

    we could certainly offer semispecific cleavage.
    I think this shortened version would also do (does not include min/max filters etc):

    import pyopenms as oms
    from collections import OrderedDict
    
    def semi_digest(protein: oms.AASequence, enzyme="Trypsin/P", miss_cleavage=0):
        dig = oms.ProteaseDigestion()
        dig.setEnzyme(enzyme)
        dig.setMissedCleavages(miss_cleavage)
        full_digestion = []
        dig.digest(protein, full_digestion)
        full_digestion = [x.toString() for x in full_digestion]
    
        semi_digestion = []
        for full_seq in full_digestion:
            semi_digestion.append(full_seq)
            for i in range(1, len(full_seq)):
                semi_digestion.append(full_seq[i:])
                semi_digestion.append(full_seq[:-i])
    
        return list(OrderedDict.fromkeys(semi_digestion))
    

    From some quick testing, the results are identical (and look complete to me).

    Coding this in OpenMS itself is trivial, but the extra python code required is also just 7 lines. Although I must admit having it in the library feels more user friendly since its probably easy to introduce a bug in this kind of code.

  5. timosachsenberg commented on Jul 3, 2025

    @timosachsenberg
    Contributor

    I think this is a valid point. We need to handle specificity for validation (e.g. in PeptideIndexer) but at the same time also need to be able to guide peptide generation. @cbielow do you have a suggestion how we should do this? Having SPEC_SEMI, SPEC_SEMI_N, SPEC_SEMI_C seems a bit awkward.

  6. added and removed
    toBeConfirmed
    on Jul 22, 2025
  7. cbielow commented on Jul 28, 2025

    @cbielow
    Contributor

    closing, since solved in #8130 (implementation in C++ OpenMS, and also exposed via pyOpenMS)

    Thanks for reporting, and a big shout-out to @Jeremi-Maciejewski for the implementation.

    This code from above

    import pyopenms as oms
    dig = oms.ProteaseDigestion()
    dig.setEnzyme("Trypsin/P")
    bsa = oms.AASequence.fromString("ACCCCCCCCDRPCCCCCCCCCCKCCCCCCCC")
    
    dig.setSpecificity(1)
    result = []
    dig.digest(bsa, result)
    for seq in result:
        print(seq.toString())
    

    will produce semi-specific peptides now, when using a nightly (py)OpenMS build or the upcoming (py)OpenMS 3.5.

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions