Ejemplo n.º 1
0
def test_optimise_grid_point_and_update(tmpdir, ethane_state):
    """
    Try and perform a single grid point optimisation.
    """
    with tmpdir.as_cwd():
        mol = Ligand.from_file(get_data("ethane.sdf"))
        tdriver = TorsionDriver(n_workers=1)
        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,
        )
        new_state = tdriver._update_state(
            td_state=ethane_state,
            result_data=[
                result,
            ],
        )
        next_jobs = tdriver._get_new_jobs(td_state=new_state)
        assert "-75" in next_jobs
        assert "-45" in next_jobs
Ejemplo n.º 2
0
def test_get_new_jobs(ethane_state):
    """
    Make sure that for a given initial state we can get the next jobs to be done.
    """
    tdriver = TorsionDriver()
    new_jobs = tdriver._get_new_jobs(td_state=ethane_state)
    assert "-60" in new_jobs
    assert new_jobs["-60"][0] == pytest.approx([
        -1.44942051524959,
        0.015117815022160003,
        -0.030235630044320005,
        1.44942051524959,
        -0.015117815022160003,
        0.030235630044320005,
        -2.2431058039129903,
        -0.18897268777700002,
        1.8708296089923,
        -2.16562700192442,
        1.78768162637042,
        -0.82203119182995,
        -2.1920831782132,
        -1.5325684978714702,
        -1.18863820611733,
        2.1920831782132,
        1.5306787709937002,
        1.18863820611733,
        2.2431058039129903,
        0.18897268777700002,
        -1.8708296089923,
        2.16562700192442,
        -1.78957135324819,
        0.82014146495218,
    ])
Ejemplo n.º 3
0
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)