Beispiel #1
0
 def shape_data(self, mols):
     fps = [
         GetMorganFingerprintAsBitVect(m.rdmol, 2, nBits=2048) for m in mols
     ]
     fps_arr = np.array(fps).reshape(-1, 2048)
     energies = np.array([m.docking_energy for m in mols]).reshape(-1, 1)
     self.data = (fps_arr, energies)
Beispiel #2
0
 def predict(self, mols):
     fps = [
         GetMorganFingerprintAsBitVect(m.rdmol, 2, nBits=2048) for m in mols
     ]
     fps_arr = np.array(fps).reshape(-1, 2048)
     y = self.model.predict(fps_arr)
     for i in range(len(y)):
         mols[i].predicted_energy = y[i].item()
     return y
Beispiel #3
0
    def create(self, frame):
        """
        Returns
        -------
        """
        
        from rdkit.Chem import MolFromSmiles
        from rdkit.Chem.AllChem import GetMorganFingerprintAsBitVect

        smiles = self._get_smiles(frame)
        mol = MolFromSmiles(smiles)
        fps = GetMorganFingerprintAsBitVect(mol, radius=self.radius, nBits=self.length)
        fps = np.array(fps, dtype='float64')
            
        return {'acronym': self.acronym, 'descriptors': fps}
Beispiel #4
0
def feature_fingerprint_morgan(molecules, radius, bits):
    """
    Generates circular morgan fingerprints for each molecule

    :param molecules: list of RDKit molecules
    :param radius: radius for morgan fingerprint generation
    :param bits: length of bit vector
    :return: list of fingerprints
    """
    feature_vector = []

    for mol in molecules:
        # radius 3 equals ecpf6 https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4510302/
        string_bits = GetMorganFingerprintAsBitVect(mol, radius,
                                                    nBits=bits).ToBitString()
        feature_vector.append(list(map(int, string_bits)))
    return feature_vector
def make_fingerprints(length, verbose, mols, chosen=None):
    if chosen   == 1:
        fp_list = [
            fingerprint(lambda x : GetHashedAtomPairFingerprintAsBitVect(x, nBits = length),
                     "&qfuot;Atom pair (1985)")]
    elif chosen == 2:
        fp_list = [
             fingerprint(lambda x : GetHashedTopologicalTorsionFingerprintAsBitVect(x, nBits = length),
                     "Topological torsion (1987)")]
    elif chosen == 3:
        fp_list = [
             fingerprint(lambda x : GetMorganFingerprintAsBitVect(x, 3, nBits = length),
                     "Morgan circular ")]
    elif chosen == 4:
         fp_list = [
             fingerprint(FingerprintMol, "Estate (1995)")]
    elif chosen == 5:
        fp_list = [
             fingerprint(lambda x: GetAvalonFP(x, nBits=length),
                    "Avalon bit based (2006)")]
    elif chosen == 6:
        fp_list = [
            fingerprint(lambda x: np.append(GetAvalonFP(x, nBits=length), Descriptors.MolWt(x)),
                    "Avalon+mol. weight")]
    elif chosen == 7:
        fp_list = [
            fingerprint(lambda x: GetErGFingerprint(x), "ErG fingerprint (2006)")]
    elif chosen == 8:
        fp_list = [
            fingerprint(lambda x : RDKFingerprint(x, fpSize=length),
                     "RDKit fingerprint")]
    elif chosen == 9:
        fp_list = [
            fingerprint(lambda x : FingerprintMols.FingerprintMol(x),
                     "RDKit fingerprint2")]
    else:
        fp_list = [fingerprint(lambda x : MACCSkeys.GenMACCSKeys(x), "RDKit MACCSkeys")]

    for fp in fp_list:
        if (verbose): print("doing", fp.name)
        fp.apply_fp(mols)

    return fp_list