You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Question of how to perform Semi-Digestion with pyopenms #8098
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!
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.
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?
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.
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.
Activity
timosachsenberg commentedon Jul 2, 2025
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.
timosachsenberg commentedon Jul 2, 2025
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?
cbielow commentedon Jul 2, 2025
we could certainly offer semispecific cleavage.
I think this shortened version would also do (does not include min/max filters etc):
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.
timosachsenberg commentedon Jul 3, 2025
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.
cbielow commentedon Jul 28, 2025
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
will produce semi-specific peptides now, when using a nightly (py)OpenMS build or the upcoming (py)OpenMS 3.5.