Skip to content

Commit

Permalink
Merge pull request #602 from csbrasnett/mutate-check
Browse files Browse the repository at this point in the history
fix error raising for mod not found
  • Loading branch information
pckroon authored Jun 21, 2024
2 parents 7e59d59 + 8dde16f commit 85c867c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
3 changes: 1 addition & 2 deletions vermouth/processors/annotate_mut_mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,9 @@ def annotate_modifications(molecule, modifications, mutations, resspec_counts):
# Get the name of the chain in the molecule that we're looking at
residue = {key: residue_graph.nodes[0].get(key)
for key in 'chain resid resname insertion_code'.split()}
chain = residue['chain']
extra = False
for mutmod, key, library in associations:
for resspec, mod in mutmod:
extra = False
mod_found = _resiter(mod, residue_graph, resspec, library, key, molecule)
if not mod_found:
#if no mod found, return that there's a problem
Expand Down
35 changes: 24 additions & 11 deletions vermouth/tests/test_annotate_mut_mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def test_nter_cter_modifications(node_data, edge_data, expected):
assert found == expected

@pytest.mark.parametrize('node_data, edge_data, mutation, expected', [
(
(# test 0
[
{'chain': 'A', 'resname': 'GLY', 'resid': 1},
{'chain': 'A', 'resname': 'ALA', 'resid': 2},
Expand All @@ -314,7 +314,7 @@ def test_nter_cter_modifications(node_data, edge_data, expected):
[({'resname': 'GLY', 'resid': 1, 'chain': 'A'}, 'MET')],
False
),
(
(# test 1
[
{'chain': 'A', 'resname': 'ALA', 'resid': 1},
{'chain': 'A', 'resname': 'ALA', 'resid': 2},
Expand All @@ -324,7 +324,7 @@ def test_nter_cter_modifications(node_data, edge_data, expected):
[({'resname': 'GLY', 'resid': 1, 'chain': 'A'}, 'MET')],
True
),
(
(# test 2
[
{'chain': 'A', 'resname': 'ALA', 'resid': 1},
{'chain': 'A', 'resname': 'ALA', 'resid': 2},
Expand All @@ -334,7 +334,7 @@ def test_nter_cter_modifications(node_data, edge_data, expected):
[({'resname': 'GLY', 'resid': 1}, 'MET')],
True
),
(
(# test 3
[
{'chain': 'A', 'resname': 'ALA', 'resid': 1},
{'chain': 'A', 'resname': 'ALA', 'resid': 2},
Expand All @@ -344,7 +344,7 @@ def test_nter_cter_modifications(node_data, edge_data, expected):
[({'resname': 'ALA', 'resid': 1}, 'MET')],
False
),
(
(# test 4
[
{'chain': 'A', 'resname': 'ALA', 'resid': 1},
{'chain': 'A', 'resname': 'ALA', 'resid': 2},
Expand All @@ -357,7 +357,7 @@ def test_nter_cter_modifications(node_data, edge_data, expected):
[({'resname': 'ALA', 'chain': 'A'}, 'GLY')],
False
),
(
(# test 5
[
{'chain': 'A', 'resname': 'ALA', 'resid': 1},
{'chain': 'A', 'resname': 'ALA', 'resid': 2},
Expand All @@ -370,7 +370,7 @@ def test_nter_cter_modifications(node_data, edge_data, expected):
[({'resname': 'GLY', 'resid': 1}, 'ALA')],
True
),
(
(# test 6
[
{'chain': 'A', 'resname': 'ALA', 'resid': 1},
{'chain': 'A', 'resname': 'ALA', 'resid': 2},
Expand All @@ -383,7 +383,7 @@ def test_nter_cter_modifications(node_data, edge_data, expected):
[({'resname': 'GLY', 'resid': 1, 'chain': 'A'}, 'ALA')],
True
),
(
(# test 7
[
{'chain': 'A', 'resname': 'ALA', 'resid': 1},
{'chain': 'A', 'resname': 'ALA', 'resid': 2},
Expand All @@ -396,7 +396,7 @@ def test_nter_cter_modifications(node_data, edge_data, expected):
[({'resname': 'ALA', 'resid': 1}, 'GLY')],
False
),
(
(# test 8
[
{'chain': 'A', 'resname': 'ALA', 'resid': 1},
{'chain': 'A', 'resname': 'ALA', 'resid': 2},
Expand All @@ -409,7 +409,7 @@ def test_nter_cter_modifications(node_data, edge_data, expected):
[({'resname': 'GLY', 'chain': 'A'}, 'ALA')],
True
),
(
(# test 9
[
{'chain': 'A', 'resname': 'ALA', 'resid': 1},
{'chain': 'A', 'resname': 'ALA', 'resid': 2},
Expand All @@ -422,7 +422,7 @@ def test_nter_cter_modifications(node_data, edge_data, expected):
[({'resid': 1, 'resname': 'ASN'}, 'ALA')],
False
),
(
(# test 10
[
{'chain': 'A', 'resname': 'ALA', 'resid': 1},
{'chain': 'A', 'resname': 'ALA', 'resid': 2},
Expand All @@ -434,6 +434,19 @@ def test_nter_cter_modifications(node_data, edge_data, expected):
[(0, 1), (1, 2), (3, 4), (4, 5)],
[({'chain':'B', 'resname': 'ASN'}, 'ALA')],
False
),
( # test 11
[
{'chain': 'A', 'resname': 'GLY', 'resid': 1},
{'chain': 'A', 'resname': 'ALA', 'resid': 2},
{'chain': 'A', 'resname': 'SER', 'resid': 3},
{'chain': 'B', 'resname': 'GLY', 'resid': 1},
{'chain': 'B', 'resname': 'ALA', 'resid': 2},
{'chain': 'B', 'resname': 'SER', 'resid': 3}
],
[(0, 1), (1, 2), (3, 4), (4, 5)],
[({'chain': 'A', 'resname': 'ALA', 'resid': 2}, 'GLY')],
False
)
])
def test_mod_resid_not_correct(caplog, node_data, edge_data, mutation, expected):
Expand Down

0 comments on commit 85c867c

Please sign in to comment.