You can use “addCoords=True” in your addHs call. http://rdkit.org/docs/source/rdkit.Chem.rdmolops.html#rdkit.Chem.rdmolops.AddHs <http://rdkit.org/docs/source/rdkit.Chem.rdmolops.html#rdkit.Chem.rdmolops.AddHs>
Sunhwan > On Aug 21, 2020, at 6:11 AM, Puck van Gerwen <puck.vanger...@gmail.com> wrote: > > Hi Paolo, > > That works, thank you. I have a related question - after reading in molecules > with their coordinates, I remove hydrogens to make them implicit. I later > want to add the hydrogens back on and only optimise these, leaving the heavy > atoms alone. I tried to do this with an ethyne molecule where I read the > coordinates from an sdf file, removed the hydrogens, and added them back on > again. They are all added to the origin. I am trying and failing to optimise > the hydrogen positions without modifying the heavy atoms. This is what I have > so far: > > # C atoms in positions 0 and 1 > a = mol.GetConformer().GetAtomPosition(0) > b = mol.GetConformer().GetAtomPosition(1) > cmap = {0 : a, 1 : b} > AllChem.EmbedMolecule(mol, core=mol, coordMap=cmap) > > AllChem.MMFFOptimizeMolecule(mol) > > When I print out the coordinates I can see the heavy atoms have also been > modified. Would you be able to help me out here? > > Best regards, > Puck > > On Thu, 20 Aug 2020 at 13:26, Paolo Tosco <paolo.tosco.m...@gmail.com > <mailto:paolo.tosco.m...@gmail.com>> wrote: > Hi Puck, > > When you read a SDF file using a SDMolSupplier RDKit will retain 3D > coordinates. You can access them from the mol Conformer (a molecule can have > multiple Conforrmers; one is generated for you when you read a set of > coordinates): > > mol.GetConformer().GetAtomPosition(atom_idx) > > If you wish to retain hydrogen atoms, make sure to set removeHs=False when > creating the supplier. > > Cheers, > p. > > On 20 Aug 2020, at 12:54, Puck van Gerwen <puck.vanger...@gmail.com > <mailto:puck.vanger...@gmail.com>> wrote: > >> Dear rdkit, >> >> I am wondering whether after reading a molecule from an sdf file, it is >> possible to keep the original 3d coordinates that were in that sdf file? I >> will modify the molecules (fragment bonds and saturate with hydrogen) but as >> much as possible I want to keep the original coordinates. For example, if I >> had H3C-CH=CH2 and I break the first bond to remove H3C (to saturate to CH4) >> leaving CH=CH2 (to saturate to H2C=CH2), would it be possible to keep the >> original C coordinates rather than generate conformations and so on? >> >> I appreciate the assistance. >> Best regards, >> -- >> Puck van Gerwen >> Doktorandin / PhD candidate >> Departement Chemie >> Klingelbergstrasse 80 >> CH-4056 Basel >> https://www.chemspacelab.org/ <https://www.chemspacelab.org/> >> _______________________________________________ >> Rdkit-discuss mailing list >> Rdkit-discuss@lists.sourceforge.net >> <mailto:Rdkit-discuss@lists.sourceforge.net> >> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss >> <https://lists.sourceforge.net/lists/listinfo/rdkit-discuss> > > > -- > Puck van Gerwen > Doktorandin / PhD candidate > Departement Chemie > Klingelbergstrasse 80 > CH-4056 Basel > https://www.chemspacelab.org/ <https://www.chemspacelab.org/> > _______________________________________________ > Rdkit-discuss mailing list > Rdkit-discuss@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
_______________________________________________ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss