Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyteomics/proforma.py
Original file line number Diff line number Diff line change
Expand Up @@ -3835,7 +3835,7 @@ def __getitem__(self, i: Union[int, slice]):
# not the actual modification definition. Update the first occurrence of the
# localization marker with a group id marked modification tag.
if all(not isinstance(v, LocalizationMarker) for _, v in tag_hits):
i = tag_hits[0]
i = tag_hits[0][0]
val: TagBase
for val in self.find_tags_by_id(group_id, include_position=False):
if not isinstance(val, LocalizationMarker):
Expand Down
10 changes: 10 additions & 0 deletions tests/test_proforma.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ def test_slice(self):
assert i[1:].n_term is None
assert i[1:].c_term is not None

def test_slice_grouped_modification(self):
# Regression test: slicing a sequence with a grouped modification tag
# (e.g. "#g1") used to raise a TypeError because the tag position tuple
# returned by find_tags_by_id was used directly as a sequence index.
seq = "EMEVT[#g1]S[#g1]ES[#g1]PEK"
i = ProForma.parse(seq)
sub = i[2:9]
self.assertEqual(str(sub), "EVT[#g1]S[#g1]ES[#g1]P")
self.assertEqual(sub.group_ids, ['#g1'])

def test_charge_adducts(self):
sequences = ['PEPTIDE/1[+2Na+,-H+]', 'PEPTIDE/-1[+e-]', 'PEPTIDE/1[+2H+,+e-]']
charges = [1, -1, 1]
Expand Down
Loading