1414from openmm import unit
1515from numpy .testing import assert_almost_equal
1616
17- from .conftest import ALL_PDB_LOADERS
17+ from .conftest import PLB_files
1818
1919
2020@pytest .fixture
@@ -94,11 +94,8 @@ class TestProteinComponent(GufeTokenizableTestsMixin):
9494 def instance (self , PDB_181L_path ):
9595 return self .cls .from_pdb_file (PDB_181L_path , name = "Steve" )
9696
97- # From
98- @pytest .mark .parametrize ('in_pdb_path' , ALL_PDB_LOADERS .keys ())
99- def test_from_pdb_file (self , in_pdb_path ):
100- in_pdb_io = ALL_PDB_LOADERS [in_pdb_path ]()
101- p = self .cls .from_pdb_file (in_pdb_io , name = "Steve" )
97+ def test_from_pdb_file (self , PDB_files ):
98+ p = self .cls .from_pdb_file (PDB_files , name = "Steve" )
10299
103100 assert isinstance (p , ProteinComponent )
104101 assert p .name == "Steve"
@@ -177,21 +174,16 @@ def test_to_pdb_input_types(self, PDB_181L_OpenMMClean_path, tmp_path,
177174 output_func = p .to_pdb_file
178175 )
179176
180- @pytest .mark .parametrize ('in_pdb_path' , ALL_PDB_LOADERS .keys ())
181- def test_to_pdb_round_trip (self , in_pdb_path , tmp_path ):
182- in_pdb_io = ALL_PDB_LOADERS [in_pdb_path ]()
183-
184- p = self .cls .from_pdb_file (in_pdb_io , name = "Wuff" )
185- out_file_name = "tmp_" + in_pdb_path + ".pdb"
177+ def test_to_pdb_round_trip (self , PDB_files , tmp_path ):
178+ p = self .cls .from_pdb_file (PDB_files , name = "Wuff" )
179+ out_file_name = "tmp_foo.pdb"
186180 out_file = tmp_path / out_file_name
187181
188182 p .to_pdb_file (str (out_file ))
189183
190- ref_in_pdb_io = ALL_PDB_LOADERS [in_pdb_path ]()
191-
192184 # generate openMM reference file:
193- openmm_pdb = pdbfile .PDBFile (ref_in_pdb_io )
194- out_ref_file_name = "tmp_" + in_pdb_path + "_openmm_ref .pdb"
185+ openmm_pdb = pdbfile .PDBFile (PDB_files )
186+ out_ref_file_name = "tmp_foo_openmm_ref .pdb"
195187 out_ref_file = tmp_path / out_ref_file_name
196188
197189 pdbfile .PDBFile .writeFile (openmm_pdb .topology , openmm_pdb .positions , file = open (str (out_ref_file ), "w" ))
@@ -213,33 +205,23 @@ def test_dummy_from_dict(self, PDB_181L_OpenMMClean_path):
213205
214206 assert p == p2
215207
216- # parametrize
217- @pytest .mark .parametrize ('in_pdb_path' , ALL_PDB_LOADERS .keys ())
218- def test_to_openmm_positions (self , in_pdb_path ):
219- in_pdb_io = ALL_PDB_LOADERS [in_pdb_path ]()
220- ref_in_pdb_io = ALL_PDB_LOADERS [in_pdb_path ]()
221-
222- openmm_pdb = pdbfile .PDBFile (ref_in_pdb_io )
208+ def test_to_openmm_positions (self , PDB_files ):
209+ openmm_pdb = pdbfile .PDBFile (PDB_files )
223210 openmm_pos = openmm_pdb .positions
224211
225- p = self .cls .from_pdb_file (in_pdb_io , name = "Bob" )
212+ p = self .cls .from_pdb_file (PDB_files , name = "Bob" )
226213 gufe_openmm_pos = p .to_openmm_positions ()
227214
228215 v1 = gufe_openmm_pos .value_in_unit (unit .nanometer )
229216 v2 = openmm_pos .value_in_unit (unit .nanometer )
230217
231218 assert_almost_equal (actual = v1 , desired = v2 , decimal = 6 )
232219
233- # parametrize
234- @pytest .mark .parametrize ('in_pdb_path' , ALL_PDB_LOADERS .keys ())
235- def test_to_openmm_topology (self , in_pdb_path ):
236- in_pdb_io = ALL_PDB_LOADERS [in_pdb_path ]()
237- ref_in_pdb_io = ALL_PDB_LOADERS [in_pdb_path ]()
238-
239- openmm_pdb = pdbfile .PDBFile (ref_in_pdb_io )
220+ def test_to_openmm_topology (self , PDB_files ):
221+ openmm_pdb = pdbfile .PDBFile (PDB_files )
240222 openmm_top = openmm_pdb .topology
241223
242- p = self .cls .from_pdb_file (in_pdb_io , name = "Bob" )
224+ p = self .cls .from_pdb_file (PDB_files , name = "Bob" )
243225 gufe_openmm_top = p .to_openmm_topology ()
244226 assert_topology_equal (openmm_top , gufe_openmm_top )
245227
@@ -290,7 +272,9 @@ def test_protein_total_charge(self, PDB_181L_path):
290272 assert m1 .total_charge == 7
291273
292274 def test_protein_total_charge_thromb (self ):
293- m1 = self .cls .from_pdb_file (ALL_PDB_LOADERS ["thrombin_protein" ]())
275+ f = PLB_files .fetch ('thrombin/01_protein/crd/protein.pdb' )
276+
277+ m1 = self .cls .from_pdb_file (f )
294278
295279 assert m1 .total_charge == 6
296280
0 commit comments