コード例 #1
0
def _drug_tester(n_molecules=3404, charge_method="bcc"):
    """Helper function for running various versions of the drug parameterization benchmark."""
    assert n_molecules <= 3404, "The maximum number of molecules is 3404."
    assert charge_method in ["bcc", None
                             ], "Charge method must be either None or 'bcc'"

    path = tempfile.mkdtemp()
    database_filename = utils.get_data_filename("chemicals/drugs/Zdd.mol2.gz")
    cmd = "gunzip -c %s > %s/Zdd.mol2" % (database_filename, path)
    os.system(cmd)
    cmd = """awk '/MOLECULE/{close(x);x="%s/molecule_"i++".mol2"}{print > x}' %s/Zdd.mol2""" % (
        path, path)
    os.system(cmd)

    for k in range(n_molecules):
        molecule_name = "molecule_%d" % k
        mol2_filename = "%s/%s.mol2" % (path, molecule_name)
        cmd = """sed -i "s/<0>/LIG/" %s""" % mol2_filename
        os.system(
            cmd
        )  # Have to remove the <0> because it leads to invalid XML in the forcefield files.
        with utils.enter_temp_directory():
            yield utils.tag_description(
                lambda: utils.test_molecule(
                    "LIG", mol2_filename, charge_method=CHARGE_METHOD),
                "Testing drugs %s with charge method %s" %
                (molecule_name, CHARGE_METHOD))
コード例 #2
0
ファイル: test_freesolv.py プロジェクト: juliebehr/gaff2xml
def _tester_load_freesolv_gaffmol2_vs_sybylmol2_vs_obabelpdb(
        charge_method="bcc"):
    with utils.enter_temp_directory():

        tar_filename = utils.get_data_filename(
            "chemicals/freesolv/freesolve_v0.3.tar.bz2")
        tar = tarfile.open(tar_filename, mode="r:bz2")
        tar.extractall()
        tar.close()

        database = pickle.load(open("./v0.3/database.pickle"))
        for key in database:
            for directory in ["mol2files_gaff", "mol2files_sybyl"]:
                gaff_filename = os.path.abspath("./v0.3/%s/%s.mol2" %
                                                (directory, key))

                cmd = """sed -i "s/<0>/LIG/" %s""" % gaff_filename
                os.system(
                    cmd
                )  # Have to remove the <0> because it leads to invalid XML in the forcefield files.

                t_gaff = md.load(gaff_filename)

                with utils.enter_temp_directory():
                    yield utils.tag_description(
                        lambda: utils.test_molecule(
                            "LIG", gaff_filename, charge_method=charge_method),
                        "Testing freesolv %s %s with charge model %s" %
                        (directory, key, charge_method))
コード例 #3
0
def test_drugs():
    import openeye.oechem
    database_filename = utils.get_data_filename("chemicals/drugs/Zdd.mol2.gz")
    ifs = openeye.oechem.oemolistream(database_filename)
    for molecule in ifs.GetOEMols():
        with utils.enter_temp_directory():
            molecule_name, tripos_mol2_filename = utils.molecule_to_mol2(molecule)
            yield utils.tag_description(lambda : utils.test_molecule(molecule_name, tripos_mol2_filename), "Testing drugs %s" % molecule_name)
コード例 #4
0
def test_common_molecules():
    import openeye.oechem
    for molecule_name in molecules:
        molecule = openmoltools.openeye.iupac_to_oemol(molecule_name)
        molecule = openmoltools.openeye.get_charges(molecule)
        with utils.enter_temp_directory():
            tripos_mol2_filename = 'molecule.mol2'
            molecule_name, tripos_mol2_filename = utils.molecule_to_mol2(molecule, tripos_mol2_filename=tripos_mol2_filename)
            yield utils.tag_description(lambda : utils.test_molecule('molecule', tripos_mol2_filename), "Testing molecule %s" % molecule_name)
コード例 #5
0
def test_drugs():
    import openeye.oechem
    database_filename = utils.get_data_filename("chemicals/drugs/Zdd.mol2.gz")
    ifs = openeye.oechem.oemolistream(database_filename)
    for molecule in ifs.GetOEMols():
        with utils.enter_temp_directory():
            molecule_name, tripos_mol2_filename = utils.molecule_to_mol2(
                molecule)
            yield utils.tag_description(
                lambda: utils.test_molecule(molecule_name, tripos_mol2_filename
                                            ),
                "Testing drugs %s" % molecule_name)
コード例 #6
0
def _drug_tester(n_molecules=3404, charge_method="bcc"):
    """Helper function for running various versions of the drug parameterization benchmark."""
    assert n_molecules <= 3404, "The maximum number of molecules is 3404."
    assert charge_method in ["bcc", None], "Charge method must be either None or 'bcc'"

    path = tempfile.mkdtemp()
    database_filename = utils.get_data_filename("chemicals/drugs/Zdd.mol2.gz")
    cmd = "gunzip -c %s > %s/Zdd.mol2" % (database_filename, path)
    os.system(cmd)
    cmd = """awk '/MOLECULE/{close(x);x="%s/molecule_"i++".mol2"}{print > x}' %s/Zdd.mol2""" % (path, path)
    os.system(cmd)

    for k in range(n_molecules):
        molecule_name = "molecule_%d" % k
        mol2_filename = "%s/%s.mol2" % (path, molecule_name)
        cmd = """sed -i "s/<0>/LIG/" %s""" % mol2_filename
        os.system(cmd)  # Have to remove the <0> because it leads to invalid XML in the forcefield files.
        with utils.enter_temp_directory():
            yield utils.tag_description(lambda : utils.test_molecule("LIG", mol2_filename, charge_method=CHARGE_METHOD), "Testing drugs %s with charge method %s" % (molecule_name, CHARGE_METHOD))
コード例 #7
0
def _tester_load_freesolv_gaffmol2_vs_sybylmol2_vs_obabelpdb(charge_method="bcc"):
    with utils.enter_temp_directory():

        tar_filename = utils.get_data_filename("chemicals/freesolv/freesolve_v0.3.tar.bz2")
        tar = tarfile.open(tar_filename, mode="r:bz2")
        tar.extractall()
        tar.close()

        database = pickle.load(open("./v0.3/database.pickle"))
        for key in database:
            for directory in ["mol2files_gaff", "mol2files_sybyl"]:
                gaff_filename = os.path.abspath("./v0.3/%s/%s.mol2" % (directory, key))

                cmd = """sed -i "s/<0>/LIG/" %s""" % gaff_filename
                os.system(cmd)  # Have to remove the <0> because it leads to invalid XML in the forcefield files.

                t_gaff = md.load(gaff_filename)

                with utils.enter_temp_directory():
                    yield utils.tag_description(
                        lambda: utils.test_molecule("LIG", gaff_filename, charge_method=charge_method),
                        "Testing freesolv %s %s with charge model %s" % (directory, key, charge_method),
                    )
コード例 #8
0
def test_run_test_molecule():
    molecule_name = "sustiva"
    input_filename = utils.get_data_filename("chemicals/sustiva/sustiva.mol2")
    with utils.enter_temp_directory():  # Prevents creating tons of GAFF files everywhere.
        utils.test_molecule(molecule_name, input_filename)
コード例 #9
0
ファイル: test_utils.py プロジェクト: pengfeili1/openmoltools
def test_run_test_molecule():
    molecule_name = "sustiva"
    input_filename = utils.get_data_filename("chemicals/sustiva/sustiva.mol2")
    with utils.enter_temp_directory(
    ):  # Prevents creating tons of GAFF files everywhere.
        utils.test_molecule(molecule_name, input_filename)