Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
39 lines (27 sloc) 1.03 KB
from __future__ import print_function
__author__ = 'isikm'
import pandas as pd
from openeye import oechem
df_drugbank_smiles=pd.DataFrame.from_csv('df_drugbank_smiles.csv', encoding='utf-8')
# Count number of F in each row using SMARTS matching
for i, row in enumerate(df_drugbank_smiles.iterrows()):
smiles = df_drugbank_smiles.loc[i,"smiles"]
mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, str(smiles))
# create a substructure search object
ss = oechem.OESubSearch(queried_substructure)
oechem.OEPrepareSearch(mol, ss)
# loop over matches to count
for index, match in enumerate(ss.Match(mol)):
if ss.SingleMatch(mol) == True:
matched_ss_list.append((index, match))
count = len(matched_ss_list)
# print(count, match)
# add number of matches to dataframe
df_drugbank_smiles.loc[i,"F"] = count
#write to csv
df_drugbank_smiles.to_csv("df_drugbank_smiles.csv", encoding='utf-8')
You can’t perform that action at this time.