class GuessIonTests(unittest.TestCase): geneSet = genetic.generate_geneset() df = genetic.load_data("saltInfo.csv") df = df['anion_SMILES'].unique() ohPickMe = random.sample(range(df.shape[0]), 1) anion = Chem.MolFromSmiles(df[ohPickMe[0]]) def test_1_density(self): target = random.sample(range(800, 1500), 1)[0] self.guess_password(target) def test_benchmark(self): genetic.Benchmark.run(self.test_1_density) def guess_password(self, target): startTime = datetime.datetime.now() def fnGetFitness(genes): return get_fitness(self.anion, genes, target) def fnDisplay(candidate, mutation): display(candidate, mutation, startTime) def fnShowIon(genes, target, mutation_attempts): show_ion(genes, target, mutation_attempts) optimalFitness = 0.99 best = genetic.get_best(fnGetFitness, optimalFitness, self.geneSet, fnDisplay, fnShowIon, target) return best
def _guess_password(target, anion_smiles, parent_candidates, models, deslists, seed=None, hull=None): """ for interacting with the main engine. Contains helper functions to pass to the engine what it expects """ startTime = datetime.datetime.now() anion = Chem.MolFromSmiles(anion_smiles) def fnGetFitness(genes): return _get_fitness(anion, genes, target, models, deslists) def fndisplay(candidate, mutation): _display(candidate, mutation, startTime) def fnShowIon(genes, target, mutation_attempts, sim_score, molecular_relative): _show_ion(genes, target, mutation_attempts, sim_score, molecular_relative, models, deslists, anion_smiles) optimalFitness = 0.95 geneSet = genetic.generate_geneset() best = genetic.get_best(fnGetFitness, optimalFitness, geneSet, fndisplay, fnShowIon, target, parent_candidates, seed=seed, convex_strategy=hull) return best
class GuessIonTests(unittest.TestCase): geneSet = genetic.generate_geneset() df = salty.load_data("cationInfo.csv") parent_candidates = df['smiles'].unique() df = salty.load_data("anionInfo.csv") df = df['smiles'].unique() random.seed(1234) ohPickMe = random.sample(range(df.shape[0]), 1) anion = Chem.MolFromSmiles(df[ohPickMe[0]]) def test_1_density(self): target = 1250 self.guess_password(target) def test_benchmark(self): genetic.Benchmark.run(self.test_1_density) def guess_password(self, target): startTime = datetime.datetime.now() def fnGetFitness(genes, target): return get_fitness(self.anion, genes, target) def fnDisplay(candidate, mutation, target): display(candidate, mutation, startTime) def fnShowIon(genes, target, mutation_attempts, sim_score, molecular_relative): show_ion(genes, target, mutation_attempts, sim_score, molecular_relative, self.anion) optimalFitness = 0.9 best = genetic.get_best(fnGetFitness, optimalFitness, self.geneSet, fnDisplay, fnShowIon, target, self.parent_candidates, seed=123) cation = best.Mol anion = self.anion # Uncomment PDB lines to wrote PDB file # cation = Chem.AddHs(best.Mol) # Chem.EmbedMolecule(cation, Chem.ETKDG()) # Chem.UFFOptimizeMolecule(cation) # Chem.rdmolfiles.MolToPDBFile(cation, "cation_test.pdb") # anion = Chem.AddHs(self.anion) # Chem.EmbedMolecule(anion, Chem.ETKDG()) # Chem.UFFOptimizeMolecule(anion) # Chem.rdmolfiles.MolToPDBFile(anion, "anion_test.pdb") return cation, anion
def _guess_password(target, anion_smiles, parent_candidates, models, deslists, seed=None, hull=None, simplex=None, exp_data=None, verbose=0, hull_bounds=[0, 1], inner_search=True, parent_cap=25, mutation_cap=1000): """ for interacting with the main engine. Contains helper functions to pass to the engine what it expects """ startTime = datetime.datetime.now() anion = Chem.MolFromSmiles(anion_smiles) def fnGetFitness(genes): return _get_fitness(anion, genes, target, models, deslists) def fndisplay(candidate, mutation): genes = candidate.Genes scr, pre = _get_fitness(anion, genes, target, models, deslists) _display(candidate, mutation, startTime, scr, pre, target) def fnShowIon(genes, target, mutation_attempts, sim_score, molecular_relative): _show_ion(genes, target, mutation_attempts, sim_score, molecular_relative, models, deslists, anion_smiles, exp_data) optimalFitness = 0.95 geneSet = genetic.generate_geneset() best = genetic.get_best(fnGetFitness, optimalFitness, geneSet, fndisplay, fnShowIon, target, parent_candidates, seed=seed, hull=hull, simplex=simplex, verbose=verbose, hull_bounds=hull_bounds, inner_search=inner_search, parent_cap=parent_cap, mutation_cap=mutation_cap) return best
def _guess_password(target, anion, parent_candidates, model_ID): """ for interacting with the main engine. Contains helper functions to pass to the engine what it expects """ startTime = datetime.datetime.now() def fnGetFitness(genes): return _get_fitness(anion, genes, target, model_ID) def fndisplay(candidate, mutation): _display(candidate, mutation, startTime) def fnShowIon(genes, target, mutation_attempts, sim_score, molecular_relative): _show_ion(genes, target, mutation_attempts, sim_score, molecular_relative, model_ID, anion) optimalFitness = 0.99 geneSet = genetic.generate_geneset() best = genetic.get_best(fnGetFitness, optimalFitness, geneSet, fndisplay, fnShowIon, target, parent_candidates) return best
class GuessIonTests(unittest.TestCase): geneSet = genetic.generate_geneset() df = salty.load_data("cationInfo.csv") df = df.loc[df["name"].str.contains("imid", case=False)]
class GuessIonTests(unittest.TestCase): geneSet = genetic.generate_geneset() def test_1_similarity_map(self): df = genetic.load_data("saltInfo.csv") df = df.loc[df["cation_name"].str.contains("imid", case=False)]