Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Converting Smiles to Fingerprint with pandas iterrows/apply-function:
Im trying to iterate my function over a column but it doesn't work properly. Could you guys show me where I have to correct my code?

Thats my Code
def SmilesToFPS(smiles):
    mol = Chem.MolFromSmiles(smiles)
    fps = FingerprintMols.FingerprintMol(mol)
    #fpSize=1024, minPath=1, maxPath=7,
     #    bitsPerHash=2, useHs=True, 
      #    tgtDensity=0.0, minSize=0, 
       #    branchedPaths=True, useBondOrder=True, 
        #      atomInvariants=0, fromAtoms=0, atomBits=None, bitInfo=None)
    return print(fps.ToBitString()) 

for index, row in df_3.iterrows():

#for i, number in df_3['SmilesCode'].iteritems(): 
#this doesn't work.thats why I used .iterrows
        fingerprints = SmilesToFPS(smiles)

        fingerprints = 'ERROR'
    print('\r', row['SmilesCode'], fingerprints, end='')


df_4 = pd.DataFrame({'SmilesCode' : smiles_list, 'Fingerprints' : fingerprint_list})
I expect a Bitstring for every SmilesCode but I only get Errors for every row/SmilesCode. The defined function does work tho but not if I use it to iterate over my desired column!
If I use the apply() function from pandas:

df_modDfObj = df_3.apply(SmilesToFPS)
I get this error code:

ArgumentError: Python argument types in rdkit.Chem.rdmolops.RDKFingerprint(NoneType, int, int, int, int, int, float, int) did not match C++ signature: RDKFingerprint(RDKit::ROMol mol, unsigned int minPath=1, unsigned int maxPath=7, unsigned int fpSize=2048, unsigned int nBitsPerHash=2, bool useHs=True, double tgtDensity=0.0, unsigned int minSize=128, bool branchedPaths=True, bool useBondOrder=True, boost::python::api::object atomInvariants=0, boost::python::api::object fromAtoms=0, boost::python::api::object atomBits=None, boost::python::api::object bitInfo=None)

Im trying to iterate my function over a column but it doesn't work properly. Could you guys show me where I have to correct my code?

Thank you guys for your help!

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  How do I apply a Gaussian blur to a particular edge of geometry in Matplotlib? hbolandi 0 111 Feb-02-2020, 06:08 PM
Last Post: hbolandi
  How to apply VLookup formula jonzee 2 164 Jan-12-2020, 04:16 PM
Last Post: Clunk_Head
  Issue in .apply function fullstop 0 117 Dec-17-2019, 01:29 PM
Last Post: fullstop
  Apply a function with pandas Jompie96 2 319 Jun-13-2019, 07:04 PM
Last Post: Jompie96
  help with converting C# function to Python korenron 17 2,158 May-19-2019, 10:26 AM
Last Post: Gribouillis
  zklib fingerprint attendance problem daemonsh 1 983 Jul-29-2018, 04:30 PM
Last Post: daemonsh

Forum Jump:

Users browsing this thread: 1 Guest(s)