Re: [Rdkit-discuss] Check If Atom Is in Two Small Rings

2017-04-11 Thread Jonathan Saboury
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:
small_rings.append(ring)
small_ring_atoms = []
for small_ring in small_rings:
for ring_atom in small_ring:
if ring_atom in small_ring_atoms:
return False
else:
small_ring_atoms.append(ring_atom)
return True
--
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] Check If Atom Is in Two Small Rings

2017-04-11 Thread Brian Kelley
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")

>>> list(m.GetRingInfo().AtomRings())

[(0, 3, 2, 1), (4, 5, 6, 3)]

# get all 4 membered rings

>>> rings = [set(r) for r in m.GetRingInfo().AtomRings() if len(r) == 4]

# from the first ring, see if there are any intersections

>>> s = rings[0]

>>> for r in rings[1:]:

...   p = s.intersection(r)

...   if p: print p

...

set([3])

Cheers,
 Brian

On Tue, Apr 11, 2017 at 4:19 PM, Peter S. Shenkin  wrote:

> 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 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 Tue, Apr 11, 2017 at 1:03 PM, Brian Kelley 
>> wrote:
>>
>>> 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 
>>> wrote:
>>>
 Hello All,

 I'm trying to make a function to check if a mol has an atom that is
 part of two small rings (3 or 4 atoms). Using GetRingInfo()/NumAtomRings()
 I can find out how many ring systems each atom is in, but not the details
 of the rings. atom.IsInRingSize(size) returns a bool so I couldn't use
 that. I'm using the python api.

 Any suggestions? Thanks!

 - Jonathan

 
 --
 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
>>>
>>>
>>
>> 
>> --
>> 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] Check If Atom Is in Two Small Rings

2017-04-11 Thread Peter S. Shenkin
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 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 Tue, Apr 11, 2017 at 1:03 PM, Brian Kelley 
> wrote:
>
>> 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 
>> wrote:
>>
>>> Hello All,
>>>
>>> I'm trying to make a function to check if a mol has an atom that is part
>>> of two small rings (3 or 4 atoms). Using GetRingInfo()/NumAtomRings() I can
>>> find out how many ring systems each atom is in, but not the details of the
>>> rings. atom.IsInRingSize(size) returns a bool so I couldn't use that. I'm
>>> using the python api.
>>>
>>> Any suggestions? Thanks!
>>>
>>> - Jonathan
>>>
>>> 
>>> --
>>> 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
>>
>>
>
> 
> --
> 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] Check If Atom Is in Two Small Rings

2017-04-11 Thread Curt Fischer
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 Tue, Apr 11, 2017 at 1:03 PM, Brian Kelley  wrote:

> 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 
> wrote:
>
>> Hello All,
>>
>> I'm trying to make a function to check if a mol has an atom that is part
>> of two small rings (3 or 4 atoms). Using GetRingInfo()/NumAtomRings() I can
>> find out how many ring systems each atom is in, but not the details of the
>> rings. atom.IsInRingSize(size) returns a bool so I couldn't use that. I'm
>> using the python api.
>>
>> Any suggestions? Thanks!
>>
>> - Jonathan
>>
>> 
>> --
>> 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
>
>
--
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] Check If Atom Is in Two Small Rings

2017-04-11 Thread Brian Kelley
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  wrote:

> Hello All,
>
> I'm trying to make a function to check if a mol has an atom that is part
> of two small rings (3 or 4 atoms). Using GetRingInfo()/NumAtomRings() I can
> find out how many ring systems each atom is in, but not the details of the
> rings. atom.IsInRingSize(size) returns a bool so I couldn't use that. I'm
> using the python api.
>
> Any suggestions? Thanks!
>
> - Jonathan
>
> 
> --
> 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


[Rdkit-discuss] Check If Atom Is in Two Small Rings

2017-04-11 Thread Jonathan Saboury
Hello All,

I'm trying to make a function to check if a mol has an atom that is part of
two small rings (3 or 4 atoms). Using GetRingInfo()/NumAtomRings() I can
find out how many ring systems each atom is in, but not the details of the
rings. atom.IsInRingSize(size) returns a bool so I couldn't use that. I'm
using the python api.

Any suggestions? Thanks!

- Jonathan
--
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] official Tripos MOL2 file format PDF document

2017-04-11 Thread Francois BERENGER
Hello,

Not directly related to rdkit, but if someone that have
the original PDF of this file format could place it
online permanently, that would be wonderful.

The official URL at tripos.com is dead since quite some time
apparently.
And that's bad because it's a quite popular file format
and its specification should be permanently archived.

Thanks a lot,
Francois.

--
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] tautomers in rdkit

2017-04-11 Thread Peter S. Shenkin
Just from the slides, it's not clear that Roger had a solution; the slides
seem to just suggest an approach. Am I missing something here?

That is, he defined the invariants that all tautomers of a compound have to
share and expressed it as a SMARTS + constraints; but I didn't see that he
provided a methodology to derive a canonical matching SMILES from a SMARTS
+ constraints. True, if two structures match the SMARTS + constraints, they
are likely tautomers. (I can't think of why they wouldn't be, but maybe
it's not always the case.) So that part provides deduplication of an input
stream, which is good, but no way to derive and store a canonical
representation.

Again, perhaps I'm missing something, but if so, what?

-P.

On Tue, Apr 11, 2017 at 2:43 AM, MARIA BRANDL 
wrote:

> Dear all,
>
>
> Is there going to be an attempt at coding Roger Sayle's  "Alternative
> Approach" to tautomers described in
> RDKit: Six Not-So-Easy Pieces [RDKit UGM 2016]
> 
>  into
> RDKit ?
>
>
> I have managed to get reasonable tautomers out of Resonance.cpp using:
>
> suppl = 
> rdchem.ResonanceMolSupplier(m,rdchem.ResonanceFlags.ALLOW_CHARGE_SEPARATION
> | \
>   
> rdchem.ResonanceFlags.ALLOW_INCOMPLETE_OCTETS
> | \
>   
> rdchem.ResonanceFlags.UNCONSTRAINED_CATIONS
> | \
>   rdchem.ResonanceFlags.
> UNCONSTRAINED_ANIONS)
>
>  with some post-filtering for e.g. carbocations, but feel that it may be
> more efficient to put user defined constraints on each atom during the
> backtracking loops, as Roger suggests.
>
> Looking forward to hearing your thoughts on this.
>
> Best regards,
>
> Maria Brandl
>
> 
> --
> 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


[Rdkit-discuss] tautomers in rdkit

2017-04-11 Thread MARIA BRANDL
Dear all,

Is there going to be an attempt at coding Roger Sayle's  "Alternative Approach" 
to tautomers described inRDKit: Six Not-So-Easy Pieces [RDKit UGM 2016] into 
RDKit ?


I have managed to get reasonable tautomers out of Resonance.cpp using:
suppl = 
rdchem.ResonanceMolSupplier(m,rdchem.ResonanceFlags.ALLOW_CHARGE_SEPARATION | \ 
                                         
rdchem.ResonanceFlags.ALLOW_INCOMPLETE_OCTETS | \                               
           rdchem.ResonanceFlags.UNCONSTRAINED_CATIONS | \                      
                    rdchem.ResonanceFlags.UNCONSTRAINED_ANIONS)
 with some post-filtering for e.g. carbocations, but feel that it may be more 
efficient to put user defined constraints on each atom during the backtracking 
loops, as Roger suggests.
Looking forward to hearing your thoughts on this.
Best regards,
Maria Brandl--
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