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
from pubchempy import *
Chem.Draw.DrawingOptions.bondLineWidth=3
Chem.Draw.DrawingOptions.atomLabelFontSize=16
ibu=Chem.MolFromSmiles('CC(C)CC1=CC=C(C=C1)C(C)C(=O)O')
AllChem.Compute2DCoords(ibu)
display(ibu)
print (Lipinksy.NumHDonors(ibu))
print (Lipinksy.NumHAcceptors(ibu))
print (Lipinksy.rdMolDescriptors.CalcExactMolWt(ibu))
print (Lipinksy.rdMolDescriptors.CalcCrippenDescriptors(ibu)[0])
ibu_mod = Chem.MolFromSmiles('C#CC1=CC=C(C=C1)C(C)C(=O)O')
AllChem.Compute2DCoords(ibu_mod)
display(ibu_mod)
strings = np.genfromtxt('C:/Users/mikhail/Desktop/golovin/1.txt', dtype = np.str)
smiles = []
for line in strings:
if len(line[1]) < 30 and not '.' in line[1]:
smiles.append(line[1])
len(smiles)
template = Chem.MolFromSmiles('N1C=C(N=N1)C1=CC=C(C=C1)C(C)C(=O)O')
AllChem.Compute2DCoords(template)
display(template)
new_smiles = []
for smi in smiles[:len(smiles)]:
if 'N=[N+]=[N-]' in smi:
new_smiles.append(smi.replace('N=[N+]=[N-]','N1C=C(N=N1)C1=CC=C(C=C1)C(C)C(=O)O'))
else:
continue
Lip_rules = []
for smi in new_smiles:
try:
mol = Chem.MolFromSmiles(smi)
if (Lipinksy.NumHDonors(mol) < 5 and
Lipinksy.rdMolDescriptors.CalcExactMolWt(mol) < 500 and
Lipinksy.rdMolDescriptors.CalcCrippenDescriptors(mol)[0] < 5 and
Lipinksy.NumHAcceptors(mol) <= 10):
Lip_rules.append(smi)
except:
pass
len(Lip_rules)
import random
numbers = random.sample(range(len(Lip_rules)), 10)
for i in numbers:
img=Chem.MolFromSmiles(Lip_rules[i])
print(Lip_rules[i])
display(img)
number = random.randint(0, len(Lip_rules))
random_smile = Lip_rules[number]
random_mol = Chem.MolFromSmiles(random_smile)
print(random_smile)
display(random_mol)
m3d=Chem.AddHs(random_mol)
Chem.AllChem.EmbedMolecule(m3d)
AllChem.MMFFOptimizeMolecule(m3d,maxIters=500,nonBondedThresh=200 )
import nglview as nv
nv.show_rdkit(m3d)
#shows nothing, wtf