コード例 #1
0
ファイル: string_GA.py プロジェクト: h4RkhW8t53e/String-GA
def sanitize(population,scores,population_size,prune_population):
    if prune_population:
      smiles_list = []
      population_tuples = []
      for score, string in zip(scores,population):
          canonical_smiles = Chem.MolToSmiles(co.string2mol(string))
          if canonical_smiles not in smiles_list:
              smiles_list.append(canonical_smiles)
              population_tuples.append((score, string))
    else:
      population_tuples = list(zip(scores,population))


    population_tuples = sorted(population_tuples, key=lambda x: x[0], reverse=True)[:population_size]
    new_population = [t[1] for t in population_tuples]
    new_scores = [t[0] for t in population_tuples]

    return new_population, new_scores
コード例 #2
0
ファイル: string_mutate.py プロジェクト: roysh/GB-GA
def mutate(mol,mutation_rate):
    if random.random() > mutation_rate:
        return mol
    Chem.Kekulize(mol,clearAromaticFlags=True)
    child = stco.mol2string(mol)
    symbols = get_symbols()
    for i in range(50):
        random_number = random.random()
        mutated_gene = random.randint(0, len(child) - 1)
        random_symbol_number = random.randint(0, len(symbols)-1)
        new_child = list(child)
        random_number = random.random()
        new_child[mutated_gene] = symbols[random_symbol_number]
        new_child_mol = stco.string2mol(new_child)
        #print(child_smiles,Chem.MolToSmiles(child_mol),child_mol,co.mol_OK(child_mol))
        if co.mol_OK(new_child_mol):
            return new_child_mol

    return mol
コード例 #3
0
def logP_max(string, dummy):
    mol = co.string2mol(string)
    score = sc.logP_score(mol)
    return max(0, score)
コード例 #4
0
def rediscovery(string, args):
    mol = co.string2mol(string)
    score = sc.rediscovery(mol, args)
    return score
コード例 #5
0
def absorbance_target(string, args):
    mol = co.string2mol(string)
    score = sc.absorbance_target(mol, args)
    return score
コード例 #6
0
def logP_target(string, args):
    mol = co.string2mol(string)
    score = sc.logP_target(mol, args)
    return score