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


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

2017-02-08 Thread Markus Metz
Dear RDKit community:

I am facing the situation that I would like to attach indices to atoms in a
molecule defined by a substructure. The substitution pattern is of
importance. Therefore I needed to include the wildcards atoms in my
substructure. If I get the atom indices of this substructure, the matched
atoms are still included and will be used for attaching indices (see at the
end of the attached notebook for an example)

I found a solution how to get rid off the non ring atom. That was
straightforward. For the attached atom which is part of another ring I
needed to do something differently. I determined the atom indices in each
ring with GetRingInfo and then I determined which of these rings is part of
the tuple of the atom indices of the pattern. Once determined I can do what
I need.

The question to you is: Is there another more elegant way of doing it? May
be I missed something from the python API?

I would appreciate any input.

Cheers,
Markus


AtomMapping.ipynb
Description: Binary data
--
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