Beispiel #1
0
    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
Beispiel #2
0
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
Beispiel #3
0
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
Beispiel #4
0
    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
Beispiel #5
0
    def guess_password(self, target):
        startTime = datetime.datetime.now()

        def fnGetFitness(genes):
            return get_fitness(genes, target)

        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)

        optimalFitness, prediction = get_fitness(target, target)
        best = genetic.get_best(fnGetFitness, optimalFitness, self.geneSet,
                                fnDisplay, fnShowIon, target,
                                self.parent_candidates)
        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