From d9c6879cbe5b5d648c1a0fdcb38e85d55a82e8d5 Mon Sep 17 00:00:00 2001 From: laumalo Date: Mon, 2 Nov 2020 10:12:53 +0100 Subject: [PATCH] Modified test_writer --- offpele/tests/test_templates.py | 63 +++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 15 deletions(-) diff --git a/offpele/tests/test_templates.py b/offpele/tests/test_templates.py index 1173378a..6c534685 100644 --- a/offpele/tests/test_templates.py +++ b/offpele/tests/test_templates.py @@ -48,21 +48,54 @@ def test_writer(self): LIGAND_PATH = 'ligands/BNZ.pdb' FORCEFIELD_NAME = 'openff_unconstrained-1.1.1.offxml' - TEMPLATE_EXAMPLE = 'ghfdh' - - ligand_path = get_data_file_path(LIGAND_PATH) - molecule = Molecule(ligand_path) - molecule.parameterize(FORCEFIELD_NAME) - impact = Impact(molecule) - impact.write('molz') - - with open(TEMPLATE_EXAMPLE, 'r') as f1: - contentA = set(f1) - with open('molz', 'r') as f2: - contentB = set(f2) - assert contentA == contentB - - + TEMPLATE_METZ = '/home/lauramalo/repos/offpele/offpele/tests/reference_templates/metz' + TEMPLATE_MATZ = '/home/lauramalo/repos/offpele/offpele/tests/reference_templates/malz' + TEMPLATE_ETLZ = '/home/lauramalo/repos/offpele/offpele/tests/reference_templates/etlz' + + # Generates the tempalte for methane + pdb_path = get_data_file_path('ligands/methane.pdb') + m = Molecule(pdb_path) + m.parameterize('openff_unconstrained-1.2.1.offxml') + impact = Impact(m) + impact.write('metz') + + # Compare the reference template and the generated template + with open(TEMPLATE_METZ, 'r') as f1: + dataA = f1.readlines()[3:] + with open('metz', 'r') as f2: + dataB = f2.readlines()[3:] + assert dataA == dataB + + # Generates the template for malonate + pdb_path = get_data_file_path('ligands/malonate.pdb') + m = Molecule(pdb_path) + m.parameterize('openff_unconstrained-1.2.1.offxml') + impact = Impact(m) + impact.write('malz') + + # Compare the reference template and the generated template + with open(TEMPLATE_MATZ, 'r') as f1: + dataA = f1.readlines()[3:] + with open('malz', 'r') as f2: + dataB = f2.readlines()[3:] + assert dataA == dataB + + # Generates the template for ethylene + pdb_path = get_data_file_path('ligands/ethylene.pdb') + m = Molecule(pdb_path, tag='ETL') # Note that in this case we are assigning a tag to the molecule which will be used in the Impact template + m.parameterize('openff_unconstrained-1.2.1.offxml') + impact = Impact(m) + impact.write('etlz') + + # Compare the reference template and the generated template + with open(TEMPLATE_ETLZ, 'r') as f1: + dataA = f1.readlines()[3:] + with open('etlz', 'r') as f2: + dataB = f2.readlines()[3:] + assert dataA == dataB + + +