Awesome! Thank you all so much!!!
Here is my implementation of the function for reference:
def passed_NA2SR(mol): #no atom shared by two small rings
rings = mol.GetRingInfo().AtomRings()
small_rings = []
for ring in rings:
if len(ring) < 5:
Peter, quite correct.
To do that, you'll need to do operations on the rings themselves:
>>> m = Chem.MolFromSmiles("C1CC12CCC2")
>>> list(m.GetRingInfo().AtomRings())
[(0, 1, 2), (3, 4, 5, 2)]
And set operations are probably your friend
>>> m = Chem.MolFromSmiles("C1CCC12CCC2")
>>>
But Brian's solution won't help Jonathan find atoms that are in two
three-membered or two four-membered rings, which I thought Jonathan also
wanted, based on the wording of the original query.
-P.
On Tue, Apr 11, 2017 at 4:12 PM, Curt Fischer
wrote:
> Brian's solution
Brian's solution is obviously better (shorter, uses less functions) than
mine. (Although mine assumes that you want atoms that are part of
_exactly_ two rings, not atoms that are part of _at least_ two rings as
Brian's does. Probably Brian's solution is what you want but worth noting.)
CF
On
You are so close!
>>> from rdkit import Chem
>>> m = Chem.MolFromSmiles("C1CC12CCC2")
>>> for atom in m.GetAtoms():
... if atom.IsInRingSize(3) and atom.IsInRingSize(4): print atom.GetIdx()
...
2
>>>
Cheers,
Brian
On Tue, Apr 11, 2017 at 1:38 PM, Jonathan Saboury
5 matches
Mail list logo