<jupyter_start><jupyter_text>01. define min,max and draw colorbar<jupyter_code>top = 50

vmin = 0.008 #df_map[weight].iloc[:top].min() 
vmax = 0.02 #df_map[weight].iloc[:top].max()

fig, ax = plt.subplots(figsize=(0.2, 10))
fig.subplots_adjust(bottom=0.5)


norm = mpl.colors.Normalize(vmin=vmin, vmax=vmax)

cmap = mpl.colors.LinearSegmentedColormap.from_list("", ["red", "white","green"], N = 1000, gamma = 1.2)
#cmap = mpl.cm.cool

cb1 = mpl.colorbar.ColorbarBase(ax, cmap=cmap,
                                norm=norm, #orientation='horizontal'
                                )
cb1.set_label('average importance')
fig.show()
fig.savefig('./cbar.svg', bbox_inches = 'tight')<jupyter_output><empty_output><jupyter_text>01) clinical drugs https://www.nature.com/articles/nrd.2017.43/tables/1<jupyter_code>dfd = pd.read_csv('../data/drugs_predict_all.csv')
dfd.head(5)
# s = [0, 1, 2]
# dfb = dfd[dfd.index.isin(s)].reset_index(drop=True)
# dfb = dfb.sort_values('MMNF', ascending=False).reset_index(drop=True)
# dfb

dfb = dfd.head(5)
sms = ['CC(=O)Nc1ccc(F)cc1', 'CC#Cc1cncc(C)c1', 'CC(=O)Nc1ccc(F)cc1']

for i in dfb.index:

    s = dfb.iloc[i]
    
    print(i, s.smiles)
    if i == 2:
        core =Chem.MolFromSmiles('CC#Cc1cccnc1')
    else:
        core = Chem.MolFromSmiles('CNC(C)=O')

    ids = "drugs-%s-%s-%s" % (i, s['name'],s.MMNF.round(3))
    bimg, svg, bits = highlight_important_atom(s.smiles, cmap, core_mol = core, vmin = vmin, vmax =  vmax, top = top)
    display.Image(bimg)
    with open('./drugs/%s.svg' % ids , 'w') as f:
        f.write(svg)
dfb = dfd.sort_values('MMNF', ascending=False).tail(3)
dfb.index = [5,6,7]
dfb
dfb.smiles.tolist()
for i in dfb.index:
    s = dfb.loc[i]
    print(i, s.smiles)
    if i==6:
        core = Chem.MolFromSmiles('Fc1ncccc1-c1ccccc1')
        
    elif i == 7:
        core = Chem.MolFromSmiles('C[C@H]1C[C@@]2(CN(C)S(=O)(=O)N2C)CCN1C')
    else:
        core = None
    ids = "drugs-%s-%s-%s" % (i, s['name'],s.MMNF.round(3))
    bimg, svg, bits = highlight_important_atom(s.smiles, cmap, core_mol = core, vmin = vmin, vmax =  vmax, top = top)
    display.Image(bimg)
    with open('./drugs/%s.svg' % ids , 'w') as f:
        f.write(svg)<jupyter_output>5 NC1=N[C@@](c2cccc(-c3cncnc3)c2)(c2ccnc(C(F)F)c2)c2cccc(F)c21<jupyter_text>02.draw scaffold-1<jupyter_code>dfs = pd.read_csv('../data/scaffold_1.csv')
core = Chem.MolFromSmiles('Cc1ccccc1-c1ccc2nc(N)ccc2c1')
for i in dfs.index[:5]:
    s = dfs.iloc[i]
    ids = "scaffold1-%s-%s-%s" % (i, s.ID, s.pIC50.round(3))
    bimg, svg, bits = highlight_important_atom(s.smiles, cmap, core_mol = core, vmin = vmin, vmax =  vmax, top = top)
    display.Image(bimg)
    with open('./scaffold1/%s.svg' % ids , 'w') as f:
        f.write(svg)
        
core = Chem.MolFromSmiles('CCn1c(N)nc2cc(Cl)ccc12')
for i in dfs.index[5:]:
    s = dfs.iloc[i]
    ids = "scaffold1-%s-%s-%s" % (i, s.ID, s.pIC50.round(3))
    bimg, svg, bits = highlight_important_atom(s.smiles, cmap, core_mol = core, vmin = vmin, vmax =  vmax, top = top)
    display.Image(bimg)
    with open('./scaffold1/%s.svg' % ids , 'w') as f:
        f.write(svg)<jupyter_output><empty_output><jupyter_text>03.draw non-inhibitors<jupyter_code>dfs = pd.read_csv('../data/non-inhibitors.csv')

dfs = pd.read_csv('../data/non-inhibitors.csv')

for i in dfs.index:
    s = dfs.iloc[i]
    core = Chem.MolFromSmiles(s.scaffold)
    #print(i)

    ids = "scaffold2-%s-%s-%s-%s" % (s.group, i, s.ID, s.pIC50.round(3))
    bimg, svg, bits = highlight_important_atom(s.smiles, cmap, core_mol = core, vmin = vmin, vmax =  vmax, top = top)
    display.Image(bimg)
    with open('./non_inhibitor/%s.svg' % ids , 'w') as f:
        f.write(svg)<jupyter_output>RDKit ERROR: [17:14:28] SMARTS Parse Error: syntax error while parsing: ?
RDKit ERROR: [17:14:28] SMARTS Parse Error: Failed parsing SMARTS '?' for input: '?'<jupyter_text>04.draw inhibitors<jupyter_code>dfs = pd.read_csv('../data/inhibitors.csv')
dfs
dfs = pd.read_csv('../data/inhibitors.csv')

for i in dfs.index:
    s = dfs.iloc[i]
    core = Chem.MolFromSmiles(s.scaffold)
    print(i)

    ids = "scaffold-%s-%s-%s-%s" % (s.group, i, s.ID, s.pIC50.round(3))
    bimg, svg, bits = highlight_important_atom(s.smiles, cmap, core_mol = core, vmin = vmin, vmax =  vmax, top = top)
    display.Image(bimg)
    with open('./inhibitor/%s.svg' % ids , 'w') as f:
        f.write(svg)<jupyter_output>0<jupyter_text>scaffold-21<jupyter_code>dfs = pd.read_csv('../data/scaffold_21.csv')
dfs
dfs.iloc[:5].smiles.tolist()
for i in dfs.index[:5]:
    core = Chem.MolFromSmiles('CC(O)C(Cc1ccccc1)NC(C)=O')
    print(i)
    s = dfs.iloc[i]
    ids = "scaffold2-%s-%s-%s" % (i, s.ID, s.pIC50.round(3))
    bimg, svg, bits = highlight_important_atom(s.smiles, cmap, core_mol = core, vmin = vmin, vmax =  vmax, top = top)
    display.Image(bimg)
    with open('./scaffold21/%s.svg' % ids , 'w') as f:
        f.write(svg)
for i in dfs.index[5:]:
    core = Chem.MolFromSmiles('CC(Cc1ccccc1)NC1=NC(C)(C)Cc2ccccc12')
    print(i)
    s = dfs.iloc[i]
    ids = "scaffold2-%s-%s-%s" % (i, s.ID, s.pIC50.round(3))
    bimg, svg, bits = highlight_important_atom(s.smiles, cmap, core_mol = core, vmin = vmin, vmax =  vmax, top = top)
    display.Image(bimg)
    with open('./scaffold21/%s.svg' % ids , 'w') as f:
        f.write(svg)
dfs = pd.read_csv('../data/scaffold_22.csv')
dfs
dfs.iloc[3:].smiles.tolist()
for i in dfs.index[3:]:
    core = Chem.MolFromSmiles('O=C(C1C[NH2+]CC1c1ccccc1)N1CCCCC1')
    print(i)
    s = dfs.iloc[i]
    ids = "scaffold2-%s-%s-%s" % (i, s.ID, s.pIC50.round(3))
    bimg, svg, bits = highlight_important_atom(s.smiles, cmap, core_mol = core, vmin = vmin, vmax =  vmax, top = top)
    display.Image(bimg)
    with open('./scaffold22/%s.svg' % ids , 'w') as f:
        f.write(svg)
core = Chem.MolFromSmiles('CN1C(N)=NC(C1=O)(c1ccccc1)c1cccc(c1)-c1cccnc1')
#core = None
for i in dfs.index[5:]:
    s = dfs.iloc[i]
    ids = "scaffold2-%s-%s-%s" % (i, s.ID, s.pIC50.round(3))
    bimg, svg, bits = highlight_important_atom(s.smiles, cmap, core_mol = core, vmin = vmin, vmax =  vmax, top = top)
    display.Image(bimg)
    with open('./scaffold2/%s.svg' % ids , 'w') as f:
        f.write(svg)<jupyter_output>RDKit ERROR: [20:50:30] SMARTS Parse Error: syntax error while parsing: ?
RDKit ERROR: [20:50:30] SMARTS Parse Error: Failed parsing SMARTS '?' for input: '?'<jupyter_text>scaffold 3<jupyter_code>dfs = pd.read_csv('../data/scaffold_3.csv')
dfs
core = Chem.MolFromSmiles('Clc1ccc2C(NCCc3ccccc3)=NCCc2c1')

for i in dfs.index[:5]:
    print(i)
    s = dfs.iloc[i]
    ids = "scaffold3-%s-%s-%s" % (i, s.ID, s.pIC50.round(3))
    bimg, svg, bits = highlight_important_atom(s.smiles, cmap, core_mol = core, vmin = vmin, vmax =  vmax, top = top)
    display.Image(bimg)
    with open('./scaffold3/%s.svg' % ids , 'w') as f:
        f.write(svg)
core = Chem.MolFromSmiles('CC(=O)NC(Cc1ccccc1)C(O)C[NH2+]C1CC2(CCC2)Oc2ncc(CC(C)(C)C)cc12')

for i in dfs.index[5:]:
    print(i)
    s = dfs.iloc[i]
    ids = "scaffold3-%s-%s-%s" % (i, s.ID, s.pIC50.round(3))
    bimg, svg, bits = highlight_important_atom(s.smiles, cmap, core_mol = core, vmin = vmin, vmax =  vmax, top = top)
    display.Image(bimg)
    with open('./scaffold3/%s.svg' % ids , 'w') as f:
        f.write(svg)<jupyter_output>5<jupyter_text>One Smiles<jupyter_code>Clc1cc2nc(n(c2cc1)CCCC(=O)NC(C)C)N
Clc1cc2nc(n(c2cc1)CCCO)N

s = 'Fc1ncccc1-c1cc(ccc1)C1(N=C(N)N(C)C1=O)c1cn(nc1)CCC(C)C'
bimg, svg, bits = highlight_important_atom(s,cmap,  vmin = vmin,  vmax = vmax,  top = top)
display.Image(bimg)


smiles = "O=C(NCC1CCCCC1)CCc1cc2c(nc1N)cccc2" #"Clc1cc2nc(n(c2cc1)CCCC(=O)N(CC1CCCCC1)C)N"#"O=C(N(C)C1CCCCC1)CCc1cc2cc(ccc2nc1N)-c1ccccc1C"
# 
# smiles = "Clc1cc2nc(n(c2cc1)CCCC(=O)N(CC1CCCCC1)C)N"

# smiles = "O=C(N(C)C1CCCCC1)CCc1cc2cc(ccc2nc1N)-c1ccccc1C"

# smiles = "Clc1ccccc1-c1n(Cc2nc(N)ccc2)c(cc1)-c1ccc(Oc2cncnc2)cc1"
# smiles = "Clc1ccccc1-c1n(Cc2nc(N)ccc2)c(cc1)-c1ccc(Nc2cncnc2)cc1"

smiles = "O1CC[C@@H](NC(=O)[C@@H](Cc2cc3cc(ccc3nc2N)-c2ccccc2C)C)CC1(C)C"
smiles = "O=C(NCCC(C)(C)C)C(Cc1cc2cc(ccc2nc1N)-c1ccccc1C)C"<jupyter_output><empty_output><jupyter_text>01) Helogen Group<jupyter_code>smt2.get("MACCSFP87")
smt2.get("MACCSFP107")
smt2.get("MACCSFP134")
smt2.get("MACCSFP42")
smt1.get("PubChemFP287")
smt1.get("PubChemFP364")
smt1.get("PubChemFP364")
smt1.get("PubChemFP363")<jupyter_output><empty_output><jupyter_text>02) Chalcogen group<jupyter_code>smt2.get("MACCSFP127")
smt2.get("MACCSFP143")
Chem.MolFromSmarts(smt2.get("MACCSFP143")[0])<jupyter_output><empty_output><jupyter_text>03)Donor, Acceptor<jupyter_code>smt2.get("MACCSFP53")
smt2.get("MACCSFP84")
smt2.get("MACCSFP131")
smt1.get("PubChemFP16")
smt3.get('PharmacoErGFP4')
smt3.get('PharmacoErGFP5')
smt3.get('PharmacoErGFP24')
smt3.get('PharmacoErGFP26')
smt3.get('PharmacoErGFP103')
smt3.get('PharmacoErGFP104')
smt3_map.get('Donor')
smt3_map.get('Acceptor')<jupyter_output><empty_output><jupyter_text>04) Group4: Aromatic Ring<jupyter_code>smt1.get("PubChemFP797")
smt1.get("PubChemFP696")
smt1.get("PubChemFP697")
smt1.get("PubChemFP712")
smt1.get("PubChemFP734")<jupyter_output><empty_output><jupyter_text>05) Group5: -N-O-<jupyter_code>smt2.get("MACCSFP110")
smt2.get("MACCSFP92")
smt1.get("PubChemFP536")
smt1.get("PubChemFP451")
smt2.get("MACCSFP154")
smt1.get("PubChemFP420")
smt1.get("PubChemFP439") #31, 29
smt1.get("PubChemFP443") #32, 29
smt1.get("PubChemFP579") #33, 28
smt1.get("PubChemFP685") #34, 28
smt1.get("PubChemFP684") #34, 29
smt1.get("PubChemFP692") #35, 29
smt1.get("PubChemFP704") #35, 30<jupyter_output><empty_output><jupyter_text>06) Group6: Phamarcophore<jupyter_code>#smt3_map.get('Hydrophobic')
smt3.get('PharmacoErGFP286') #3, 32
smt3.get('PharmacoErGFP144') #3, 33
smt3.get('PharmacoErGFP287') #4, 30
smt3.get('PharmacoErGFP283') #4, 34
smt3.get('PharmacoErGFP149') #5, 26
smt3.get('PharmacoErGFP289') #5, 27
smt3.get('PharmacoErGFP148') #5, 29
smt3.get('PharmacoErGFP146') #5, 31
smt3.get('PharmacoErGFP44') #6, 32
smt3.get('PharmacoErGFP42') #7, 33
smt3.get('PharmacoErGFP41') #7, 34
Donor = ["[N;!H0;v3,v4&+1]", "[O,S;H1;+0]", "[n&H1&+0]"]


Acceptor = ["[O,S;H1;v2;!$(*-*=[O,N,P,S])]",  "[O;H0;v2]", "[O,S;v1;-]", 
            "[N;v3;!$(N-*=[O,N,P,S])]", "[n&H0&+0]", "[o;+0;!$([o]:n);!$([o]:c:n)]"]


Positive = ["[#7;+]", "[N;H2&+0][$([C,a]);!$([C,a](=O))]", 
            "[N;H1&+0]([$([C,a]);!$([C,a](=O))])[$([C,a]);!$([C,a](=O))]", 
            "[N;H0&+0]([C;!$(C(=O))])([C;!$(C(=O))])[C;!$(C(=O))]"]

Negative = ["[C,S](=[O,S,P])-[O;H1,-1]"]

Hydrophobic = ["[C;D3,D4](-[CH3])-[CH3]", "[S;D2](-C)-C"]

Aromatic = ["a"]
Chem.MolFromSmarts('[#6]=[#8]')
Chem.MolFromSmarts(smt3_map.get('Positive')[0])
Chem.MolFromSmarts(smt3_map.get('Positive')[2])
Chem.MolFromSmarts(smt3_map.get('Positive')[3])
fp = "MACCSFP127" #,"PubChemFP734"
svg, hit_ats, bimg, patt, mol = plot_fp(fp, i = -10)
with open('./%s.svg' % fp , 'w') as f:
    f.write(svg)<jupyter_output>/home/sxh/anaconda3/envs/rdkit2020/lib/python3.6/site-packages/ipykernel_launcher.py:43: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
{'fraction_non_alphanumeric': 0.20743415837223642, 'fraction_numerical': 0.05549194045626707, 'mean_word_length': 4.560235063663075, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 51, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '14', 'dir': 'jupyter-structured-clean-dedup', 'id': '55789', 'license': 'MIT', 'n_tokens_mistral': 5790, 'n_tokens_neox': 5428, 'n_words': 770, 'path': 'paper/07_BACE_HPs/01_highlight/05_draw_inhibitors_highlights.ipynb', 'repo_name': 'riversdark/bidd-molmap', 'size': '11353'}