def test_run_antechamber_charges(): molecule_name = "acetate" input_filename = utils.get_data_filename("chemicals/acetate/acetate.mol2") with utils.enter_temp_directory(): # Prevents creating tons of GAFF files everywhere. gaff_mol2_filename, frcmod_filename = utils.run_antechamber( molecule_name, input_filename, charge_method=None, net_charge=-1 )
def test_parse_ligand_filename(): molecule_name = "sustiva" input_filename = utils.get_data_filename("chemicals/sustiva/sustiva.mol2") name, ext = utils.parse_ligand_filename(input_filename) eq(name, "sustiva") eq(ext, ".mol2")
def test_drugs(): database_filename = utils.get_data_filename("chemicals/drugs/Zdd.mol2.gz") ifs = openeye.oechem.oemolistream(database_filename) for molecule in ifs.GetOEGraphMols(): with utils.enter_temp_directory(): molecule_name, tripos_mol2_filename = utils.molecule_to_mol2(molecule) yield lambda : utils.test_molecule(molecule_name, tripos_mol2_filename) # Cute trick to iteratively run this test over entire database.
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.GetOEGraphMols(): 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)
def test_smiles_conversion(): pdb_filename = utils.get_data_filename("chemicals/proteins/1vii.pdb") smiles = "Cc1ccccc1" # Also known as toluene. temperature = 300 * u.kelvin friction = 0.3 / u.picosecond timestep = 0.01 * u.femtosecond protein_traj = md.load(pdb_filename) protein_traj.center_coordinates() protein_top = protein_traj.top.to_openmm() protein_xyz = protein_traj.openmm_positions(0) ligand_trajectories, ffxml = utils.smiles_to_mdtraj_ffxml([smiles]) ligand_traj = ligand_trajectories[0] ligand_traj.center_coordinates() eq(ligand_traj.n_atoms, 15) eq(ligand_traj.n_frames, 1) # Move the pre-centered ligand sufficiently far away from the protein to avoid a clash. min_atom_pair_distance = ( ((ligand_traj.xyz[0] ** 2.0).sum(1) ** 0.5).max() + ((protein_traj.xyz[0] ** 2.0).sum(1) ** 0.5).max() + 0.3 ) ligand_traj.xyz += np.array([1.0, 0.0, 0.0]) * min_atom_pair_distance ligand_xyz = ligand_traj.openmm_positions(0) ligand_top = ligand_traj.top.to_openmm() forcefield = app.ForceField("amber10.xml", ffxml, "tip3p.xml") model = app.modeller.Modeller(protein_top, protein_xyz) model.add(ligand_top, ligand_xyz) model.addSolvent(forcefield, padding=0.4 * u.nanometer) system = forcefield.createSystem( model.topology, nonbondedMethod=app.PME, nonbondedCutoff=1.0 * u.nanometers, constraints=app.HAngles ) integrator = mm.LangevinIntegrator(temperature, friction, timestep) simulation = app.Simulation(model.topology, system, integrator) simulation.context.setPositions(model.positions) print("running") simulation.step(1)
def test_drugs(): 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) n_molecules = 3404 if os.environ.get("TRAVIS", None) == 'true': n_molecules = 25 # If running on travis, only test the first 25 molecules due to speed. 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 lambda : utils.test_molecule("LIG", mol2_filename)
def test_drugs(): 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) n_molecules = 3404 CHARGE_METHOD = "bcc" if os.environ.get("TRAVIS", None) == 'true': n_molecules = 25 # If running on travis, only test the first 25 molecules due to speed. CHARGE_METHOD = None # Travis is actually too slow to do a single bcc calculation! 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))
def test_load_freesolv_gaffmol2_vs_sybylmol2_vs_obabelpdb(): 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() CHARGE_METHOD = "bcc" if os.environ.get("TRAVIS", None) == 'true': CHARGE_METHOD = None # Travis is actually too slow to do a single bcc calculation! 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))
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)
def test_run_tleap(): 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. gaff_mol2_filename, frcmod_filename = utils.run_antechamber(molecule_name, input_filename, charge_method=None) prmtop, inpcrd = utils.run_tleap(molecule_name, gaff_mol2_filename, frcmod_filename)