Here’s some more general code
Best regards, Jan
smiles_list = ["CCO","CCS","CC=O","Cc1ccncc1",'NCC(C)=C','CC(N)=N','o1cccc1']
reaction_list =
['[C;H2:1]=[C,N:2]>>[CH3:1][*+:2]','[C;H1:1]=[C,N:2]>>[CH2:1][*+:2]','[C;H0:1]=[C,N:2]>>[CH1:1][*+:2]',
'[N;H2:1]>>[*H3+:1]','[O,S,N;H1:1]>>[*H2+:1]','[O,S,N,F,Cl;H0:1]>>[*H1+:1]']
ions = []
ion_smiles = []
for smiles in smiles_list:
mol = Chem.MolFromSmiles(smiles)
Chem.Kekulize(mol,clearAromaticFlags=True)
for i,reaction in enumerate(reaction_list):
rxn = AllChem.ReactionFromSmarts(reaction)
ps = rxn.RunReactants((mol,))
for x in ps:
smiles = Chem.MolToSmiles(x[0],isomericSmiles=True)
# First three reactions can create wrong protonation state on N
if i <= 2:
smiles = smiles.replace("NH2+","N+")
if smiles not in ion_smiles:
ion_smiles.append(smiles)
print smiles
ions.append(Chem.MolFromSmiles(smiles))
On 25 Mar 2019, at 10.12, HC.Ji
<[email protected]<mailto:[email protected]>> wrote:
I m tring simulate the fragmentation of ESI mass spectra based on the [M+H]+
ions. Thus, I want to simulate the ionisation by the addition of one proton to
heteroatoms. For example,
from rdkit.Chem import AllChem
from rdkit.Chem.Draw import rdMolDraw2D
from IPython.display import SVG
# read mol
mol = Chem.MolFromSmiles('O=C(O)C1=CC(=NNC2=CC=C(C=C2)C(=O)NCCC(=O)O)C=CC1=O')
# draw the mol
dr = rdMolDraw2D.MolDraw2DSVG(800,800)
dr.SetFontSize(0.3)
op = dr.drawOptions()
for i in range(mol.GetNumAtoms()) :
op.atomLabels[i] = mol.GetAtomWithIdx(i).GetSymbol() + str((i+1))
AllChem.Compute2DCoords(mol)
dr.DrawMolecule(mol)
dr.FinishDrawing()
svg = dr.GetDrawingText()
SVG(svg)
If I want to add one proton to the N atom with the index of #17 and to ionize
the molecule, what should I do in rdkit?
_______________________________________________
Rdkit-discuss mailing list
[email protected]<mailto:[email protected]>
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss