Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ligand test fixes #123

Merged
merged 2 commits into from
Apr 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ benchmarks/
_build
# vscode
.vscode/
.env

3 changes: 2 additions & 1 deletion devtools/conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ requirements:
- hdf4 >4.2.11 # Pinned because of issue with netcdf4
- joblib
- lxml
- parmed
- parmed <=2.7.3
- pytest
- pytest-runner
- pymbar
Expand All @@ -45,6 +45,7 @@ requirements:
- openmoltools >=0.7.5
- openmmtools >=0.9.3
- ambermini >=15.0.4
- parmed <=2.7.3
- joblib
- lxml
- parmed
Expand Down
28 changes: 22 additions & 6 deletions protons/tests/test_ligands.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from os import path, remove

try:
from protons.app.ligands import generate_protons_ffxml, _TitratableForceFieldCompiler, _write_ffxml
from protons.app.ligands import generate_protons_ffxml, _TitratableForceFieldCompiler, _write_ffxml, retrieve_epik_info
ligands_success = True
except ImportError:
ligands_success = False
Expand Down Expand Up @@ -62,10 +62,8 @@ def test_running_epik(self):
assert path.isfile(unique_filename), "No Epik output file was produced"
remove(unique_filename) # clean up after ourselves
remove(log_name)

generate_protons_ffxml(get_test_data("imatinib.mae", "testsystems/imatinib_explicit"),
"/tmp/protons-imatinib-parameterization-test-implicit.xml",
pH=7.4)
epik_data = retrieve_epik_info(unique_filename)
assert len(epik_data) > 0, "No Epik data was extracted."

def test_reading_validated_xml_file_using_forcefield(self):
"""
Expand Down Expand Up @@ -108,9 +106,27 @@ def test_parametrize_molecule(self):
unique_filename = "{}.ffxml".format(str(uuid4()))
protons_app.ligands.generate_protons_ffxml(TestTrypsinLigandParameterization.preprocessed_mol2,
isomer_dicts, unique_filename, 7.8, resname="1D")
assert path.isfile(unique_filename), "No Epik output file was produced"
assert path.isfile(unique_filename), "Protons FFXML file was not generated"
results = self._check_num_elements(unique_filename, ["Atom", "Bond", "Protons/State"])
assert results['Atom'] >0, "No atoms were found, this template is broken"
assert results['Bond'] >0, "No bonds were found, this template is broken"
assert results["Protons/State"] == 8, "There should be 8 states in this template."

remove(unique_filename) # clean up after ourselves

@staticmethod
def _check_num_elements(path_to_xml, elements: list=None) -> int:
"""Check if a forcefield template has atoms and bonds defined."""
with open(path_to_xml, 'r') as xmlfile:
xml = xmlfile.read()
tree = etree.fromstring(xml)

results = dict()
for key in elements:
results[key] = len(tree.xpath('/ForceField/Residues/Residue/{}'.format(key))[:])

return results

def test_reading_validated_xml_file_using_forcefield(self):
"""Read the xmlfile using app.ForceField

Expand Down