def test_two_molecules(individual, protein, ligand): individual.genes['Ligand'] = Molecule(parent=individual, path=datapath(ligand)) individual.genes['Protein'] = Molecule(parent=individual, path=datapath(protein)) individual.__ready__() individual.__expression_hooks__() with expressed(individual): assert individual.expressed is True
def test_vina(individual, protein, ligand, affinity): individual.genes['Protein'] = Molecule(parent=individual, path=datapath(protein)) individual.genes['Ligand'] = Molecule(parent=individual, path=datapath(ligand)) individual.__ready__() individual.__expression_hooks__() objective = Vina(weight=-1.0) with expressed(individual): assert affinity == objective.evaluate(individual)
def do(self, proteinpath, ligandpath, objective, obj_kwargs): from gaudi.base import MolecularIndividual, expressed from gaudi.genes.molecule import Molecule individual = MolecularIndividual(dummy=True) individual.genes['Protein'] = protein = Molecule(path=proteinpath) individual.genes['Ligand'] = ligand = Molecule(path=ligandpath) individual.__ready__() individual.__expression_hooks__() obj = objective(**obj_kwargs) with expressed(individual): score = obj.evaluate(individual) individual.genes['Protein'].compound.destroy() individual.genes['Ligand'].compound.destroy() del individual return score
def test_nwchem(individual, ligand, energy): individual.genes['Ligand'] = Molecule(parent=individual, path=datapath(ligand)) individual.__ready__() individual.__expression_hooks__() objective = NWChem(targets=['Ligand'], title='test', weight=-1.0) with expressed(individual): assert abs(energy - objective.evaluate(individual)) < 0.0001
def search_gene(individual, path, **kwargs): individual.genes['Molecule'] = Molecule(parent=individual, path=datapath(path)) individual.genes['Search'] = search = Search.with_validation( parent=individual, precision=3, **kwargs) individual.__ready__() individual.__expression_hooks__() return search
def rotamers(individual, path, position, seed): individual.genes['Molecule'] = Molecule(parent=individual, path=datapath(path)) individual.genes['Rotamers'] = rotamers = Rotamers(parent=individual, with_original=True, residues=[('Molecule', position)]) individual.__ready__() individual.__expression_hooks__() rotamers.allele = [seed] return rotamers
def energy(individual, path): individual.genes['Molecule'] = Molecule(parent=individual, path=datapath(path)) individual.__ready__() individual.__expression_hooks__() objective = Energy() with expressed(individual): return objective.evaluate(individual)
def nma_gene(individual, path, **kwargs): individual.genes['Molecule'] = Molecule(parent=individual, path=datapath(path)) individual.genes['NMA'] = nma = NormalModes.with_validation( parent=individual, precision=3, **kwargs) individual.__ready__() individual.__expression_hooks__() return nma
def dsx(individual, protein, ligand, **kwargs): individual.genes['Protein'] = Molecule(parent=individual, path=datapath(protein)) individual.genes['Ligand'] = Molecule(parent=individual, path=datapath(ligand)) individual.__ready__() individual.__expression_hooks__() options = dict(weight=-1.0, terms=[True, False, False, True, False], proteins=['Protein'], ligands=['Ligand'], sorting=1, cofactor_mode=0, with_metals=False) options.update(kwargs) objective = DSX(**options) with expressed(individual): return objective.evaluate(individual)
def test_molecule(individual, path, atoms): absolute_path = os.path.abspath(datapath(path)) individual.genes['Molecule'] = Molecule(parent=individual, path=absolute_path) individual.__ready__() individual.__expression_hooks__() assert individual.genes['Molecule'].compound.mol.numAtoms == atoms assert individual.genes['Molecule'].compound.mol.openedAs[0] == absolute_path with expressed(individual): assert individual.expressed is True
def test_molecule(individual, individual2, path1, path2, threshold): absolute_path1 = os.path.abspath(datapath(path1)) absolute_path2 = os.path.abspath(datapath(path2)) individual.genes['Molecule'] = Molecule(parent=individual, path=absolute_path1) individual.__ready__() individual.__expression_hooks__() individual2.genes['Molecule'] = Molecule(parent=individual2, path=absolute_path2) individual2.__ready__() individual2.__expression_hooks__() with expressed(individual, individual2): sqrmsd = _rmsd_squared( individual.genes['Molecule']._expressed_coordinates, individual2.genes['Molecule']._expressed_coordinates) assert abs(sqrmsd - threshold * threshold) < 0.01 assert rmsd(individual, individual2, ['Molecule'], threshold)
def interactions(individual, path, which): individual.genes['Molecule'] = Molecule(parent=individual, path=datapath(path)) individual.__ready__() individual.__expression_hooks__() kwargs = dict(probes=['Molecule'], radius=10 * random(), which=which) objective = Contacts(**kwargs) with expressed(individual): return objective.evaluate(individual)
def torsions(individual, path, angle, **kwargs): individual.genes['Molecule'] = Molecule(parent=individual, path=datapath(path)) individual.genes['Torsion'] = torsion = Torsion(parent=individual, target='Molecule', **kwargs) individual.__ready__() individual.__expression_hooks__() torsion.allele = [angle] * torsion.max_bonds return torsion
def trajectory_setup(individual, molecule, traj, frame, max_frame): individual.genes['Molecule'] = Molecule(parent=individual, path=datapath(molecule)) gene = Trajectory(parent=individual, path=datapath(traj), max_frame=max_frame, target='Molecule') individual.genes['Trajectory'] = gene individual.__ready__() individual.__expression_hooks__() gene.allele = frame return gene
def test_coordination_uncorrected(individual, path, metal, ligands, geometry, score): individual.genes['Molecule'] = Molecule(parent=individual, path=datapath(path)) individual.__ready__() individual.__expression_hooks__() objective = Coordination(probe=('Molecule', metal), residues=[('Molecule', '*')], atom_elements=('C N O S'.split()), geometry=geometry, weight=-1.0) with expressed(individual): sphere = objective.coordination_sphere(individual)[:objective.n_vertices] assert len(sphere) == len(ligands) assert sorted(ligands) == sorted([a.serialNumber for (d, a) in sphere]) fitness = objective.evaluate(individual) assert abs(fitness - score) < 0.0001
def test_topology(individual, path, atoms, bonds, residues): individual.genes['Molecule'] = Molecule(parent=individual, path=datapath(path)) individual.__ready__() individual.__expression_hooks__() objective = Energy() with expressed(individual): molecules = objective.molecules(individual) topology = objective.chimera_molecule_to_openmm_topology(*molecules) assert topology.getNumAtoms() == sum(m.numAtoms for m in molecules) assert len(list(topology.bonds())) == sum(m.numBonds for m in molecules) assert topology.getNumResidues() == sum(m.numResidues for m in molecules)