Skip to content

Commit

Permalink
Merge branch 'main' into param_input_forms
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbinBouwmeester authored Jan 22, 2025
2 parents 84329d6 + f253bf7 commit 0f6a1db
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions proteobench/io/parsing/parse_ion.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,22 +138,21 @@ def aggregate_modification_column(
for m in input_string_modifications.split("; "):
if len(m) == 0:
continue
m_stripped = m.split(" (")[1].rstrip(")")
m_name = m.split(" (")[0]

if m_stripped in special_locations.keys():
if special_locations[m_stripped] == -1:
all_mods.append((m_name, len(input_string_seq)))
else:
all_mods.append((m_name, special_locations[m_stripped]))
mod_location = m.split(" (")[1].rstrip(")")
mod_name = m.split(" (")[0]
if mod_location in special_locations.keys():
if special_locations[mod_location] == -1: # C-Term
all_mods.append(("-[" + mod_name + "]", len(input_string_seq)))
else: # N-Term
all_mods.append(("[" + mod_name + "]-", special_locations[mod_location]))
continue

all_mods.append((m_name, int(m_stripped[1:])))
all_mods.append(("[" + mod_name + "]", int(mod_location[1:])))

all_mods.sort(key=lambda x: x[1], reverse=True)

for name, loc in all_mods:
input_string_seq = input_string_seq[:loc] + f"[{name}]" + input_string_seq[loc:]
input_string_seq = input_string_seq[:loc] + name + input_string_seq[loc:]

return input_string_seq

Expand Down

0 comments on commit 0f6a1db

Please sign in to comment.