from rdkit import Chem
from rdkit.Chem import AllChem
from rdkit import RDConfig
from rdkit.Chem.Draw import IPythonConsole
from rdkit.Chem import Draw
import numpy as np
from IPython.display import display,Image
import rdkit.Chem.Lipinski as Lipinksy
ibu=Chem.MolFromSmiles('CC(C)CC1=CC=C(C=C1)C(C)C(=O)O')
AllChem.Compute2DCoords(ibu)
display(ibu)
#параметры для правила Лепински
print('Параметры для правила Лепински')
print(Lipinksy.NumHDonors(ibu))
print(Lipinksy.NumHAcceptors(ibu))
print(Lipinksy.rdMolDescriptors.CalcExactMolWt(ibu))
print(Lipinksy.rdMolDescriptors.CalcCrippenDescriptors(ibu)[0])
Параметры для правила Лепински 1 1 206.130679816 3.073200000000001
ibu=Chem.MolFromSmiles('C#CC(C)CC1=CC=C(C=C1)C(C)C(=O)O')
AllChem.Compute2DCoords(ibu)
display(ibu)
ibu=Chem.MolFromSmiles('N1C=C(N=N1)C(C)CC1=CC=C(C=C1)C(C)C(=O)O')
AllChem.Compute2DCoords(ibu)
display(ibu)
import pubchempy as pcp
structures = []
per_page = 10**5
for smiles in ["N=N=N", "NN#N", "N#NN"]:
for i in range(200):
try:
a = pcp.get_properties(
properties="CanonicalSMILES",
identifier=smiles, namespace="smiles",
searchtype="substructure",
RingsNotEmbedded=True,
listkey_count=per_page, listkey_start=i*per_page
)
except:
break
print("Retrieved page {} of {} search".format(i+1, smiles))
structures.extend(a)
Retrieved page 1 of N=N=N search Retrieved page 2 of N=N=N search Retrieved page 3 of N=N=N search Retrieved page 1 of NN#N search Retrieved page 1 of N#NN search
compounds = {str(i['CID']).strip():i['CanonicalSMILES'].strip() for i in structures}
smiles = list(compounds.values())
# Всего соединений
len(compounds)
262245
res = []
for smi in smiles:
if len(res) > 25:
break
if '=N[N+]#N' in smi:
newsmi=smi.replace('=N[N+]#N','N1C=C(N=N1)C(C)CC1=CC=C(C=C1)C(C)C(=O)O')
else:
continue
try:
newmol=Chem.MolFromSmiles(newsmi)
if (Lipinksy.NumHDonors(newmol)<=5) and (Lipinksy.NumHAcceptors(newmol)<=10) and (Lipinksy.rdMolDescriptors.CalcExactMolWt(newmol) < 500) and (Lipinksy.rdMolDescriptors.CalcCrippenDescriptors(newmol)[0] <= 5):
AllChem.Compute2DCoords(newmol)
res.append(newmol)
except:
pass
from IPython.display import display
to_print = [res[8], res[1], res[2], res[10], res[11], res[21], res[22], res[23], res[25]]
display(Draw.MolsToGridImage(to_print, useSVG=True, molsPerRow=3, subImgSize=(300, 200)))
from rdkit.Chem.Draw import SimilarityMaps
fp = SimilarityMaps.GetMorganFingerprint(res[4], fpType='bv')
fig, maxweight = SimilarityMaps.GetSimilarityMapForFingerprint(ibu, res[5], SimilarityMaps.GetMorganFingerprint)
import nglview as nv
m3d=Chem.AddHs(res[5])
Chem.AllChem.EmbedMolecule(m3d)
AllChem.MMFFOptimizeMolecule(m3d,maxIters=500,nonBondedThresh=200 )
display(m3d)