I m tring to present the workflow for the positive ion ESI mass spectra, based on the fragmentation of [M+H]+ ions. 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)
I want to add one proton to the N atom with the index of #17 and to ionize the molecule. How to achieve this in rdkit?
Are these functions what you are looking for?
atom = mol.GetAtomWithIdx(17)
atom.SetNumExplicitHs(1)
atom.SetFormalCharge(1)