Re: [Rdkit-discuss] MolToSmiles gives explicit H after ReplaceSubstructs

2021-11-05 Thread Ling Chan
Dear Paolo, Thank you for all the tips. I was not aware of these. In fact I did suspect that that [H] has something to do with the stereochemistry, since the original F made the bond stereo. However, the "[H]" did not go away even after I called AllChem.SanitizeMol(m6)

Re: [Rdkit-discuss] MolToSmiles gives explicit H after ReplaceSubstructs

2021-11-05 Thread Paolo Tosco
Hi Ling, By default hydrogens defining double bond stereochemistry are not removed. You may remove that residual hydrogen by either params = Chem.RemoveHsParameters() params.removeDefiningBondStereo = True Chem.RemoveHs(m6, params) or simply Chem.RemoveAllHs(m6) I think you may obtain the

Re: [Rdkit-discuss] MolToSmiles atom ordering

2021-11-03 Thread Ling Chan
Cool, good to know this special property. Thank you Andrew! Ling Andrew Dalke 於 2021年11月2日週二 下午10:36寫道: > Hi Ling, > > If there are symmetries then a substructure search like will only give > you one mapping, and that might not be the canonical mapping. > > What you're looking for is the

Re: [Rdkit-discuss] MolToSmiles atom ordering

2021-11-02 Thread Andrew Dalke
Hi Ling, If there are symmetries then a substructure search like will only give you one mapping, and that might not be the canonical mapping. What you're looking for is the special property _smilesAtomOutputOrder >>> from rdkit import Chem >>> mol =

Re: [Rdkit-discuss] MolToSmiles atom ordering

2021-11-02 Thread Ling Chan
O.K. Problem solved. Sorry about the spam, folks. I can use GetSubstructMatch, as follows. # sinput is the input smiles # scanon is the output smiles minput = Chem.MolFromSmiles(sinput) scanon=Chem.MolToSmiles(minput) mcanon=Chem.MolFromSmiles(scanon) map_forward =

Re: [Rdkit-discuss] MolToSmiles

2021-10-21 Thread Andrew Dalke
> On Oct 21, 2021, at 04:50, Ling Chan wrote: > > I got the attached sdf. When I did a MolToSmiles, it gives me the following. > > >>> for m in Chem.SDMolSupplier("pdb_structures/1q6k_ligand.sdf"): > ... print (Chem.MolToSmiles(m)) > ... >

Re: [Rdkit-discuss] MolToSmiles preserve atom order

2019-11-18 Thread Andrew Dalke
On Nov 18, 2019, at 17:40, David Cosgrove wrote: > > Point taken. I don’t think you’d be able to get RDKit to spit such SMILES > strings out unless you tortured it pretty hard, however. Did someone mention one of my favorite things to do? :) See:

Re: [Rdkit-discuss] MolToSmiles preserve atom order

2019-11-18 Thread Rafal Roszak
On Mon, 18 Nov 2019 16:40:28 + David Cosgrove wrote: > Point taken. I don’t think you’d be able to get RDKit to spit such SMILES > strings out unless you tortured it pretty hard, however. Export smiles with arbitrary given atom order is diffrent problem. Normally working with mol object you

Re: [Rdkit-discuss] MolToSmiles preserve atom order

2019-11-18 Thread David Cosgrove
Hi Rocco, Point taken. I don’t think you’d be able to get RDKit to spit such SMILES strings out unless you tortured it pretty hard, however. Dave On Mon, 18 Nov 2019 at 16:36, Rocco Moretti wrote: > Actually, it is possible to get arbitrary orders, if you (ab)use the '.' > component ("zero

Re: [Rdkit-discuss] MolToSmiles preserve atom order

2019-11-18 Thread Rocco Moretti
Actually, it is possible to get arbitrary orders, if you (ab)use the '.' component ("zero order bond") directive and the numeric bonding ("ring closure") directives: >>> Chem.MolToSmiles( Chem.MolFromSmiles("O1.Cl2.C12" ) ) 'OCCl' Whether you want to do things that way is another question. On

Re: [Rdkit-discuss] MolToSmiles preserve atom order

2019-11-18 Thread David Cosgrove
Hi Rafal, It is not always possible to preserve the atom ordering in the SMILES string because there is an implied bond between contiguous symbols in the SMILES. I think, for example, that the molecule with the SMILES OCCl couldn’t have the order in the molecule object O first, Cl second, C third,

Re: [Rdkit-discuss] MolToSmiles(), atom indexes

2019-02-01 Thread Jean-Marc Nuzillard
Dear Jose Manuel, Many thanks for your quick answer and for your script. All  the best, Jean-Marc Le 01/02/2019 à 13:20, Jose Manuel Gally a écrit : Dear Jean-Marc, I believe this can be achieved by using the Mol property "_smilesAtomOutputOrder", which is set only after using the

Re: [Rdkit-discuss] MolToSmiles(), atom indexes

2019-02-01 Thread Jose Manuel Gally
Dear Jean-Marc, I believe this can be achieved by using the Mol property "_smilesAtomOutputOrder", which is set only after using the function Chem.MolToSmiles. Please find attached a very simple example of how it can be extracted. Cheers, Jose Manuel On 01.02.19 13:03, Jean-Marc Nuzillard

Re: [Rdkit-discuss] MolToSmiles

2016-12-19 Thread Greg Landrum
I agree with Andrew's suggestion. The optional list argument defaulting to None exactly how I would solve it and fits (I think) with at least most of the RDKit. -greg On Mon, Dec 19, 2016 at 9:14 PM +0100, "Brian Kelley" wrote: I'm happy to do that as long

Re: [Rdkit-discuss] MolToSmiles

2016-12-19 Thread Andrew Dalke
On Dec 19, 2016, at 6:22 PM, Brian Kelley wrote: > I had thought about making a CanonicalAtomOrder function that does this as > well, or perhaps making a MolToSmiles variant. I learned about this function from Noel's blog post at

Re: [Rdkit-discuss] MolToSmiles

2016-12-19 Thread Brian Kelley
I would vote for make a more obvious way to get to these values. I have had the need to do this when working with external depictors (i.e. mol -> smiles -> depict with atom highlighting is one use case) I just couldn't think of a valid API way of doing this. Attaching these values to the

Re: [Rdkit-discuss] MolToSmiles

2016-12-19 Thread Greg Landrum
On Mon, Dec 19, 2016 at 9:43 AM, Maciek Wójcikowski wrote: > > There is also CanonicalRankAtoms [http://www.rdkit.org/Python_ > Docs/rdkit.Chem.rdmolfiles-module.html#CanonicalRankAtoms] which seams to > be forgotten. > One thing to be aware of here is that this provides

Re: [Rdkit-discuss] MolToSmiles

2016-12-19 Thread Maciek Wójcikowski
Hi Jean-Marc and others, There is also CanonicalRankAtoms [ http://www.rdkit.org/Python_Docs/rdkit.Chem.rdmolfiles-module.html#CanonicalRankAtoms] which seams to be forgotten. Pozdrawiam, | Best regards, Maciek Wójcikowski mac...@wojcikowski.pl 2016-12-18 23:14 GMT+01:00 Jean-Marc

Re: [Rdkit-discuss] MolToSmiles

2016-12-18 Thread Jean-Marc Nuzillard
Thank you Andrew, Brian and David for your answers. mol.GetProp("_smilesAtomOutputOrder") does the job. I also expected a.GetProp("molAtomMapNumber") could do it for each atom a. All the best, Jean-Marc Le 18/12/2016 à 19:04, Andrew Dalke a écrit : > On Dec 18, 2016, at 6:32 PM, Brian Kelley

Re: [Rdkit-discuss] MolToSmiles

2016-12-18 Thread Andrew Dalke
On Dec 18, 2016, at 6:32 PM, Brian Kelley wrote: > >>> m.GetProp("_smilesAtomOutputOrder") > '[3,2,1,0,]' > > Note that this returns the list as a string which is sub-optimal. > GetPropsAsDict will convert these to proper python objects, however, this is > considered a private member so you

Re: [Rdkit-discuss] MolToSmiles

2016-12-18 Thread David Cosgrove
Hi Jean-Marc, There is a property of the molecule created when it is read that contains this information. I forget what it is called, but if you call the molecule's GetPropNames function you should see something obvious in the values returned. You can then call GetProp with that property name

Re: [Rdkit-discuss] MolToSmiles

2016-12-18 Thread Brian Kelley
Jean-Marc, This is very non-obvious, but here is how you can do it from python: >>> from rdkit import Chem >>> m = Chem.MolFromSmiles("NCCC") >>> Chem.MolToSmiles(m) 'CCCN' >>> m.GetProp("_smilesAtomOutputOrder") '[3,2,1,0,]' Note that this returns the list as a string which is