def test_full_tdrive(tmpdir, workers, capsys): """ Try and run a full torsiondrive for ethane with a cheap rdkit method. """ with tmpdir.as_cwd(): ethane = Ligand.from_file(get_data("ethane.sdf")) # make the scan data bond = ethane.find_rotatable_bonds()[0] dihedral = ethane.dihedrals[bond.indices][0] dihedral_data = TorsionScan(torsion=dihedral, scan_range=(-165, 180)) qc_spec = QCOptions(program="rdkit", basis=None, method="uff") local_ops = LocalResource(cores=workers, memory=2) tdriver = TorsionDriver( n_workers=workers, grid_spacing=60, ) _ = tdriver.run_torsiondrive( molecule=ethane, dihedral_data=dihedral_data, qc_spec=qc_spec, local_options=local_ops, ) captured = capsys.readouterr() # make sure a fresh torsiondrive is run assert "Starting new torsiondrive" in captured.out
def test_tdrive_restarts(capsys, ethane_state, tmpdir): """ Make sure that an old torsiondrive is continued when possible from the current state file. """ with tmpdir.as_cwd(): ethane_state["grid_spacing"] = [ 60, ] mol = Ligand.from_file(get_data("ethane.sdf")) tdriver = TorsionDriver(n_workers=1, grid_spacing=60) qc_spec = QCOptions(program="rdkit", basis=None, method="uff") local_ops = LocalResource(cores=1, memory=1) geo_opt = tdriver._build_geometry_optimiser() # get the job inputs new_jobs = tdriver._get_new_jobs(td_state=ethane_state) coords = new_jobs["-60"][0] result = optimise_grid_point( geometry_optimiser=geo_opt, qc_spec=qc_spec, local_options=local_ops, molecule=mol, coordinates=coords, dihedral=ethane_state["dihedrals"][0], dihedral_angle=-60, job_id=0, ) _ = tdriver._update_state( td_state=ethane_state, result_data=[ result, ], ) # now start a run and make sure it continues _ = tdriver.run_torsiondrive( molecule=mol, dihedral_data=TorsionScan(torsion=ethane_state["dihedrals"][0], scan_range=(-165, 180)), qc_spec=qc_spec, local_options=local_ops, ) capture = capsys.readouterr() assert ("Compatible TorsionDrive state found restarting torsiondrive!" in capture.out)
def test_full_tdrive(tmpdir): """ Try and run a full torsiondrive for ethane with a cheap rdkit method. """ with tmpdir.as_cwd(): ethane = Ligand.from_file(get_data("ethane.sdf")) # make the scan data bond = ethane.find_rotatable_bonds()[0] dihedral = ethane.dihedrals[bond.indices][0] dihedral_data = TorsionScan(torsion=dihedral, scan_range=(-165, 180)) tdriver = TorsionDriver( program="rdkit", method="uff", basis=None, memory=2, cores=1, n_workers=1, grid_spacing=60, ) _ = tdriver.run_torsiondrive(molecule=ethane, dihedral_data=dihedral_data)