Hello everyone, please i need help
I want to generate the xyz coordinates of all possible functionalized naphthalene molecules where the functionalized positions are the (1,4,6,9) positions and the possible functional groups are (COOH, C(CN)2, Br, Me, COCH3 and NO2)" with python. I wrote this code:
from rdkit import Chem
from rdkit.Chem import AllChem
naphtalene = Chem.MolFromSmiles("c1c2ccccc2ccc1")
functional_groups = [Chem.MolFromSmiles("C(=O)O"), Chem.MolFromSmiles("C(CN)C#N"), Chem.MolFromSmiles("Br"), Chem.MolFromSmiles("C"), Chem.MolFromSmiles("C(=O)C"), Chem.MolFromSmiles("N(=O)[O]")]
patterns = []
for i in [0, 3, 5, 8]:
for fg in functional_groups:
patt = Chem.MolFromSmiles("" + Chem.MolToSmiles(fg))
m = AllChem.ReplaceSubstructs(naphtalene, patt, replaceAll = False)[0]
m = AllChem.ReplaceSubstructs(m, Chem.MolFromSmiles(""), Chem.MolFromSmiles("[H]"), replaceAll = False, replacementConnectionPoint = 0, useChirality = false)[0]
AllChem.Compute2DCoords(m)
patterns.append(m)
for p in patterns:
AllChem.EmbedMolecule(p)
print(Chem.MolToMolBlock(p))
But I get error
[00:36:31] Explicit valence for atom # 1 O, 3, is greater than permitted
ArgumentError Traceback (most recent call last)
Cell In [32], line 5
3 for fg in functional_groups:
4 patt = Chem.MolFromSmiles("" + Chem.MolToSmiles(fg))
----> 5 m = AllChem.ReplaceSubstructs(naphtalene, patt, replaceAll = False)[0]
6 m = AllChem.ReplaceSubstructs(m, Chem.MolFromSmiles(""), Chem.MolFromSmiles("[H]"), replaceAll = False, replacementConnectionPoint = 0, useChirality = false)[0]
7 AllChem.Compute2DCoords(m)
ArgumentError: Python argument types in
rdkit.Chem.rdmolops.ReplaceSubstructs(Mol, NoneType)
did not match C++ signature:
ReplaceSubstructs(RDKit::ROMol mol, RDKit::ROMol query, RDKit::ROMol replacement, bool replaceAll=False, unsigned int replacementConnectionPoint=0, bool useChirality=False)
Hello everyone, please i need help I want to generate the xyz coordinates of all possible functionalized naphthalene molecules where the functionalized positions are the (1,4,6,9) positions and the possible functional groups are (COOH, C(CN)2, Br, Me, COCH3 and NO2)" with python. I wrote this code:
from rdkit import Chem from rdkit.Chem import AllChem naphtalene = Chem.MolFromSmiles("c1c2ccccc2ccc1") functional_groups = [Chem.MolFromSmiles("C(=O)O"), Chem.MolFromSmiles("C(CN)C#N"), Chem.MolFromSmiles("Br"), Chem.MolFromSmiles("C"), Chem.MolFromSmiles("C(=O)C"), Chem.MolFromSmiles("N(=O)[O]")] patterns = [] for i in [0, 3, 5, 8]: for fg in functional_groups: patt = Chem.MolFromSmiles("" + Chem.MolToSmiles(fg)) m = AllChem.ReplaceSubstructs(naphtalene, patt, replaceAll = False)[0] m = AllChem.ReplaceSubstructs(m, Chem.MolFromSmiles(""), Chem.MolFromSmiles("[H]"), replaceAll = False, replacementConnectionPoint = 0, useChirality = false)[0] AllChem.Compute2DCoords(m) patterns.append(m) for p in patterns: AllChem.EmbedMolecule(p) print(Chem.MolToMolBlock(p))
But I get error
[00:36:31] Explicit valence for atom # 1 O, 3, is greater than permitted
ArgumentError Traceback (most recent call last) Cell In [32], line 5 3 for fg in functional_groups: 4 patt = Chem.MolFromSmiles("" + Chem.MolToSmiles(fg)) ----> 5 m = AllChem.ReplaceSubstructs(naphtalene, patt, replaceAll = False)[0] 6 m = AllChem.ReplaceSubstructs(m, Chem.MolFromSmiles(""), Chem.MolFromSmiles("[H]"), replaceAll = False, replacementConnectionPoint = 0, useChirality = false)[0] 7 AllChem.Compute2DCoords(m)
ArgumentError: Python argument types in rdkit.Chem.rdmolops.ReplaceSubstructs(Mol, NoneType) did not match C++ signature: ReplaceSubstructs(RDKit::ROMol mol, RDKit::ROMol query, RDKit::ROMol replacement, bool replaceAll=False, unsigned int replacementConnectionPoint=0, bool useChirality=False)
I don't know how to fix the problem