Re: [Rdkit-discuss] How to determine if atoms are part of the same ring?

2017-02-10 Thread Markus Metz
Dear Andrew:

Thank you very much for your input.
I was able to refine and correct my approach with your suggestions.

Cheers,
Markus


On Wed, Feb 8, 2017 at 12:23 PM, Andrew Dalke 
wrote:

> On Feb 8, 2017, at 19:22, Markus Metz  wrote:
> > The question to you is: Is there another more elegant way of doing it?
> May be I missed something from the python API?
>
> I don't quite follow what you are looking for, though I have managed to
> condense your code somewhat, into:
>
> updatedMapping = None
> for ring in m.GetRingInfo().AtomRings():
> if set(ring).issubset(maps):
> updatedMapping = ring
>
> if updatedMapping is not None:
> updatedMapping = sorted(updatedMapping)
> for i, atom_idx in enumerate(updatedMapping, 1):
> m.GetAtomWithIdx(atom_idx).SetProp("molAtomMapNumber", str(i))
>
>
> Is it that you do not want to number the "*" atoms? In that case you can
> ask the query structure for the atoms with atomic number 0:
>
> >>> for atom in corea.GetAtoms():
> ...print(atom.GetAtomicNum())
> ...
> 0
> 6
> 6
> 6
> 6
> 6
> 6
> 0
>
> and ignore numbering the atoms at those positions.
>
> Or that you don't want to include ring atoms which aren't ring atoms in
> the query structure?
>
> In which case you can ask the query structure for its rings:
>
> >>> corea.GetRingInfo().AtomRings()
> ((1, 6, 5, 4, 3, 2),)
>
> and use that to guide which atoms should/should not be numbered.
>
> Cheers,
>
> Andrew
> da...@dalkescientific.com
>
>
>
> 
> --
> 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
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
--
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
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] How to determine if atoms are part of the same ring?

2017-02-08 Thread Andrew Dalke
On Feb 8, 2017, at 19:22, Markus Metz  wrote:
> The question to you is: Is there another more elegant way of doing it? May be 
> I missed something from the python API?

I don't quite follow what you are looking for, though I have managed to 
condense your code somewhat, into:

updatedMapping = None
for ring in m.GetRingInfo().AtomRings():
if set(ring).issubset(maps):
updatedMapping = ring

if updatedMapping is not None:
updatedMapping = sorted(updatedMapping)
for i, atom_idx in enumerate(updatedMapping, 1):
m.GetAtomWithIdx(atom_idx).SetProp("molAtomMapNumber", str(i))


Is it that you do not want to number the "*" atoms? In that case you can ask 
the query structure for the atoms with atomic number 0:

>>> for atom in corea.GetAtoms():
...print(atom.GetAtomicNum())
...
0
6
6
6
6
6
6
0

and ignore numbering the atoms at those positions.

Or that you don't want to include ring atoms which aren't ring atoms in the 
query structure?

In which case you can ask the query structure for its rings:

>>> corea.GetRingInfo().AtomRings()
((1, 6, 5, 4, 3, 2),)

and use that to guide which atoms should/should not be numbered.

Cheers,

Andrew
da...@dalkescientific.com



--
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
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss