Beispiel #1
0
def FingerprintMol(mol):
  """ generates the EState fingerprints for the molecule

  Concept from the paper: Hall and Kier JCICS _35_ 1039-1045 (1995)

  two numeric arrays are returned:
    The first (of ints) contains the number of times each possible atom type is hit
    The second (of floats) contains the sum of the EState indices for atoms of
      each type.

  """
  if AtomTypes.esPatterns is None:
    AtomTypes.BuildPatts()
  esIndices = EStateIndices(mol)

  nPatts = len(AtomTypes.esPatterns)
  counts = numpy.zeros(nPatts,numpy.int)
  sums = numpy.zeros(nPatts,numpy.float)

  for i,(name,pattern) in enumerate(AtomTypes.esPatterns):
    matches = mol.GetSubstructMatches(pattern,uniquify=1)
    counts[i] = len(matches)
    for match in matches:
      sums[i] += esIndices[match[0]]
  return counts,sums
def finger_print(chunk):
    """
    Create a dictionary with the e-state fingerprint for the molecule in mol (rdkit mol)

    Input:
    mol; rdkit mol object
    name; structure name
    e_opt; energy gap (target)
    """
    if AtomTypes.esPatterns is None:
        AtomTypes.BuildPatts()

    name_list = [name for name, _ in AtomTypes.esPatterns]
    df = pd.DataFrame(columns=['name', 'smiles'] + name_list)

    for row_index, row in chunk.iterrows():
        name = (row["name"])
        smiles = (row["smiles"])

        mol = Chem.MolFromSmiles(smiles)
        try:

            types = AtomTypes.TypeAtoms(mol)
            es = EStateIndices(mol)
            counts, sums = Fingerprinter.FingerprintMol(mol)

            if AtomTypes.esPatterns is None:
                AtomTypes.BuildPatts()

            name_list = [name for name, _ in AtomTypes.esPatterns]

            data = {'name': name, 'smiles': smiles}
            data2 = {k: v for k, v in zip(name_list, sums)}

            data.update(data2)
            df = df.append(data, ignore_index=True)

        except AttributeError:
            print(i, formula)
        continue
    return df
Beispiel #3
0
def finger_print(mol, name, e_opt):
    """ 
    Create a dictionary with the e-state fingerprint for the molecule in mol (rdkit mol)
    
    Input:
    mol; rdkit mol object
    name; structure name
    e_opt; energy gap (target)
    """

    types = AtomTypes.TypeAtoms(mol)
    es = EStateIndices(mol)
    counts, sums = Fingerprinter.FingerprintMol(mol)

    if AtomTypes.esPatterns is None:
        AtomTypes.BuildPatts()

    name_list = [name for name, _ in AtomTypes.esPatterns]

    data = {'name': name, 'E_opt': e_opt}
    data2 = {k: v for k, v in zip(name_list, sums)}

    data.update(data2)
    return data
Beispiel #4
0
    runs the shell command cmd
    """
    if shell:
        p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)

    else:
        cmd = cmd.split()
        p = subprocess.Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)

    output, err = p.communicate()

    return output.decode('utf-8')


if AtomTypes.esPatterns is None:
    AtomTypes.BuildPatts()

name_list = [name for name, _ in AtomTypes.esPatterns]

df2 = pd.DataFrame(columns=['name', 'E_opt'] +
                   name_list)  #create the name, target, features

df = pd.read_pickle("./egap_subpc.pkl")

for row_index, row in df.iterrows():
    #if row_index < 10:
    #if row_index < 1000:
    Atom = (row["Atom"])
    name = (row["name"])
    E_opt = (row["E_opt"])