Skip to content

Commit

Permalink
fixed resid specification and added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
csbrasnett committed Apr 8, 2024
1 parent da16846 commit 0a52393
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 12 deletions.
7 changes: 4 additions & 3 deletions vermouth/processors/annotate_mut_mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ def _resiter(mod, residue_graph, resspec, library, key, molecule):
molecule.nodes[node_idx][key] = molecule.nodes[node_idx].get(key, []) + [mod]
return mod_found


def annotate_modifications(molecule, modifications, mutations):
"""
Annotate nodes in molecule with the desired modifications and mutations
Expand Down Expand Up @@ -251,8 +250,10 @@ def annotate_modifications(molecule, modifications, mutations):

for mutmod, key, library in associations:
for resspec, mod in mutmod:
# Ie. the target residue is chain specific
if (resspec.get('chain') is not None) and (resspec.get('chain') == chain):
# Ie. the target residue is chain or residue specific
condition0 = ((resspec.get('chain') is not None) and (resspec.get('chain') == chain))
condition1 = ((resspec.get('chain') is None) and (resspec.get('resid') is not None))
if condition0 or condition1:
mod_found = _resiter(mod, residue_graph, resspec, library, key, molecule)
if not mod_found:
LOGGER.warning('Residue specified by "{}" for mutation "{}" not found. ',
Expand Down
41 changes: 32 additions & 9 deletions vermouth/tests/test_annotate_mut_mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,14 +324,24 @@ def test_nter_cter_modifications(node_data, edge_data, expected):
True
),
(
[
{'chain': 'A', 'resname': 'ALA', 'resid': 1},
{'chain': 'A', 'resname': 'ALA', 'resid': 2},
{'chain': 'A', 'resname': 'ALA', 'resid': 3}
],
[(0, 1), (1, 2)],
[({'resname': 'GLY', 'resid': 1}, 'MET')],
False
[
{'chain': 'A', 'resname': 'ALA', 'resid': 1},
{'chain': 'A', 'resname': 'ALA', 'resid': 2},
{'chain': 'A', 'resname': 'ALA', 'resid': 3}
],
[(0, 1), (1, 2)],
[({'resname': 'GLY', 'resid': 1}, 'MET')],
True
),
(
[
{'chain': 'A', 'resname': 'ALA', 'resid': 1},
{'chain': 'A', 'resname': 'ALA', 'resid': 2},
{'chain': 'A', 'resname': 'ALA', 'resid': 3}
],
[(0, 1), (1, 2)],
[({'resname': 'ALA', 'resid': 1}, 'MET')],
False
),
(
[
Expand All @@ -356,7 +366,20 @@ def test_nter_cter_modifications(node_data, edge_data, expected):
{'chain': 'B', 'resname': 'ALA', 'resid': 3}
],
[(0, 1), (1, 2), (3, 4), (4, 5)],
[({'resname': 'GLY', 'resid': '1'}, 'ALA')],
[({'resname': 'GLY', 'resid': 1}, 'ALA')],
True
),
(
[
{'chain': 'A', 'resname': 'ALA', 'resid': 1},
{'chain': 'A', 'resname': 'ALA', 'resid': 2},
{'chain': 'A', 'resname': 'ALA', 'resid': 3},
{'chain': 'B', 'resname': 'ALA', 'resid': 1},
{'chain': 'B', 'resname': 'ALA', 'resid': 2},
{'chain': 'B', 'resname': 'ALA', 'resid': 3}
],
[(0, 1), (1, 2), (3, 4), (4, 5)],
[({'resname': 'ALA', 'resid': 1}, 'GLY')],
False
),
(
Expand Down

0 comments on commit 0a52393

Please sign in to comment.