Skip to content

Commit f2fa5e8

Browse files
committed
address ai comments
1 parent 266a926 commit f2fa5e8

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

openms_python/py_aasequence.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from typing import Optional, Literal
66
import pyopenms as oms
7+
import warnings
78

89

910
class Py_AASequence:
@@ -334,8 +335,9 @@ def __lt__(self, other: Py_AASequence) -> bool:
334335
return NotImplemented
335336
return self.sequence < other.sequence
336337
def count(self, residue: str) -> int:
337-
"""Count occurrences of a residue, to be consistent with str.count()."""
338-
return self._sequence.count(residue)
338+
"""Count occurrences of a residue, to be consistent with str.count(), note currently does not account for modifications"""
339+
warnings.warn("count method does not account for modifications")
340+
return self.unmodified_sequence.count(residue)
339341

340342
# ==================== Additional Utilities ====================
341343

tests/test_py_aasequence.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,3 +289,9 @@ def test_slicing():
289289
assert aa_seq[1:4].sequence == 'EPT'
290290
assert aa_seq[-2:].sequence == 'M(Oxidation)R'
291291

292+
def test_count():
293+
aa_seq = Py_AASequence.from_string('PEPTIDEM(Oxidation)R')
294+
assert aa_seq.count('E') == 2
295+
assert aa_seq.count('P') == 2
296+
assert aa_seq.count('K') == 0
297+

0 commit comments

Comments
 (0)