I would like to convert smiles string which has Cl or Br atoms convert to new one which has L as Cl and R as Br.
I wrote simple code for my note.
import pandas as pd df = pd.read_table('cdk2.smi', sep=' ') # make replace function with lumbda function rep_func = lambda x: x.replace('Cl', 'L').replace('Br','R') df['repsmi'] = df.SMILES.apply(rep_func) #check for row in df.repsmi: ...: if "L" in row: ...: print(row) ...: else: pass
Result was..
CC(C)C(CO)Nc1nc2c(ncn2C(C)C)c(Nc2cccc(L)c2)n1 CC(C)C(CO)Nc1nc2c(ncn2C(C)C)c(Nc2ccc(C(=O)[O-])c(L)c2)n1 C[NH+]1CCC(c2c(O)cc(O)c3c(=O)cc(-c4ccccc4L)oc32)C(O)C1
OK. If I use vectrize function the performance will be increased.