Skip to content

Commit

Permalink
added test for file coming from itp
Browse files Browse the repository at this point in the history
  • Loading branch information
csbrasnett committed Oct 9, 2024
1 parent 6db1bae commit 59c9827
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion polyply/src/apply_modifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def apply_mod(meta_molecule, modifications):

target_residue = meta_molecule.nodes[target_resid - 1]
# takes care to skip all residues that come from an itp file
if not target_residue.get('from_itp', 'False'):
if target_residue.get('from_itp'):
LOGGER.info("meta_molecule has come from itp. Will not attempt to modify.")
continue
# checks that the resname is a protein resname as defined above
Expand Down
31 changes: 31 additions & 0 deletions polyply/tests/test_apply_modifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import polyply.src.ff_parser_sub
import networkx as nx
from vermouth.molecule import Interaction
from polyply.src.meta_molecule import MetaMolecule


@pytest.mark.parametrize('input_mods, expected',(
Expand Down Expand Up @@ -142,6 +143,36 @@ def test_apply_mod(input_itp, molname, expected, caplog, text):
meta=interaction.meta)
assert _interaction in meta_mol.molecule.interactions[interaction_type]

def test_from_itp(caplog):

caplog.set_level(logging.INFO)
#make the meta molecule from the itp and ff files
file_name = TEST_DATA / "itp" / "ALA5.itp"

ff = vermouth.forcefield.ForceField(name='martini3')

ff_lines = []
for file in ['aminoacids.ff', 'modifications.ff']:
with open(TEST_DATA/ "ff" / file) as f:
ff_lines += f.readlines()
polyply.src.ff_parser_sub.read_ff(ff_lines, ff)

meta_mol = MetaMolecule.from_itp(ff, file_name, "pALA")

for node in meta_mol.nodes:
meta_mol.nodes[node]['from_itp'] = 'True'

termini = _patch_protein_termini(meta_mol)
apply_mod(meta_mol, termini)

expected_msg = "meta_molecule has come from itp. Will not attempt to modify."
for record in caplog.records:
if record.message == expected_msg:
assert True
break
else:
continue

@pytest.mark.parametrize('modifications, expected, text',
(
(
Expand Down

0 comments on commit 59c9827

Please sign in to comment.