Discussion:
[Rdkit-discuss] Chem.MolToSmarts(mol) out put
Alexis Parenty
2017-07-14 08:59:36 UTC
Permalink
Dear Rdkiters,


I sometimes get smarts from mol in atomic number notation such as:

[#6]-[#7+]1=[#6]2-[#6]3:[#7]:[#6]:[#6]:[#6]:[#6]:3-[#6]3:[#6]:[#6]:[#6]:[#6]:[#6]:3-[#7]-2-[#6]-[#6]-1


Is there a way to force the method Chem.MolToSmarts(mol) to output a smarts
using alphabetic letters instead of atomic numbers?

The reason I am asking is because I need to remove dummy atoms [*] from
smarts using string manipulation and I would rather use only one method.
Unless I can do that from the mol object?


Many thanks,


Alexis
杨弘宾
2017-07-14 11:41:12 UTC
Permalink
Hi, Alexis,

Why don’t you output the molecule as “Smiles” format since the “Smarts” you wanted to output was really a molecule.

And it is possible to remove the dummy atom via mol object. For example:

In [26]: x = Chem.MolFromSmiles('CC*')

In [27]: x.GetSubstructMatch(Chem.MolFromSmiles('*'))
Out[27]: (2,)

In [28]: mw = Chem.RWMol(x)

In [29]: mw.RemoveAtom(2)

In [30]: Chem.MolToSmiles(mw)
Out[30]: 'CC'

But I don’t know whether it can handle SMARTS. Hope that it is helpful for you.

Hongbin Yang
<>Dear Rdkiters,
[#6]-[#7+]1=[#6]2-[#6]3:[#7]:[#6]:[#6]:[#6]:[#6]:3-[#6]3:[#6]:[#6]:[#6]:[#6]:[#6]:3-[#7]-2-[#6]-[#6]-1
Is there a way to force the method Chem.MolToSmarts(mol) to output a smarts using alphabetic letters instead of atomic numbers?
The reason I am asking is because I need to remove dummy atoms [*] from smarts using string manipulation and I would rather use only one method. Unless I can do that from the mol object?
Many thanks,
Alexis
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot_______________________________________________
Rdkit-discuss mailing list
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
Loading...