Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
csbrasnett committed Oct 20, 2023
1 parent 1ff951d commit 81d9f71
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions vermouth/tests/test_annotate_mut_mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import networkx as nx
import pytest
from contextlib import nullcontext as does_not_raise
import logging
from vermouth.molecule import Molecule
from vermouth.forcefield import ForceField
from vermouth.processors.annotate_mut_mod import (
Expand Down Expand Up @@ -270,7 +272,7 @@ def test_annotate_mutmod_processor(example_mol, modifications, mutations, expect
[(0, 1), (1, 2)],
{1: ['N-ter'], 3: ['C-ter']}
),
(
(
[
{'resname': 'XXX', 'resid': 1},
{'resname': 'ALA', 'resid': 2},
Expand All @@ -289,7 +291,8 @@ def test_nter_cter_modifications(node_data, edge_data, expected):
mol = Molecule(force_field=ForceField(FF_UNIVERSAL_TEST))
mol.add_nodes_from(enumerate(node_data))
mol.add_edges_from(edge_data)
modification = [({'resname': 'cter'}, 'C-ter'), ({'resname': 'nter'}, 'N-ter')]
modification = [({'resname': 'cter', 'resid': 3}, 'C-ter'),
({'resname': 'nter', 'resid': 1}, 'N-ter')]

annotate_modifications(mol, modification, [])

Expand All @@ -300,3 +303,39 @@ def test_nter_cter_modifications(node_data, edge_data, expected):
found[node['resid']] = node['modification']

assert found == expected

@pytest.mark.parametrize('node_data, edge_data, expected', [
(
[
{'resname': 'GLY', 'resid': 1},
{'resname': 'ALA', 'resid': 2},
{'resname': 'ALA', 'resid': 3}
],
[(0, 1), (1, 2)],
False
),
(
[
{'resname': 'ALA', 'resid': 1},
{'resname': 'ALA', 'resid': 2},
{'resname': 'ALA', 'resid': 3}
],
[(0, 1), (1, 2)],
True
)])
def test_mod_resid_not_correct(caplog, node_data, edge_data, expected):
"""
Tests that the modification is found in the expected residue.
"""
mol = Molecule(force_field=ForceField(FF_UNIVERSAL_TEST))
mol.add_nodes_from(enumerate(node_data))
mol.add_edges_from(edge_data)
mutation = [({'resname': 'GLY', 'resid': 1}, 'MET')]

caplog.clear()
annotate_modifications(mol, [], mutation)

if expected:
assert 'GLY with resid 1 not found. No modification made.' in str(caplog.records[0].getMessage())
else:
assert caplog.records == []

0 comments on commit 81d9f71

Please sign in to comment.