Even better ☺
From: Greg Landrum <greg.land...@gmail.com>
Date: Friday 29 June 2018 at 18:04
To: GMCProfile <nikolaus.sti...@novartis.com>
Cc: "rdkit-discuss@lists.sourceforge.net" <rdkit-discuss@lists.sourceforge.net>
Subject: Re: [Rdkit-discuss] elimination of small fragments
How about just GetLargestFragment()?
On Fri, 29 Jun 2018 at 16:45, Stiefl, Nikolaus
<nikolaus.sti...@novartis.com<mailto:nikolaus.sti...@novartis.com>> wrote:
Quick question – mostly to the core developers I guess:
I just checked and have that kind of thing in my code in at least 5 different
places - wouldn’t it make sense to have that kind of functionality as a
convenience function as part of the GetMolFrags method?
Something along the lines of
rdmolops.GetMolFrags(mol, asMols = True, largestFragmentOnly = True)
? Just a thought …
Cheers
Nik
From: Alfredo Quevedo <maquevedo....@gmail.com<mailto:maquevedo....@gmail.com>>
Date: Friday 29 June 2018 at 12:06
To: Andrew Dalke <da...@dalkescientific.com<mailto:da...@dalkescientific.com>>
Cc: Stephen Roughley via Rdkit-discuss
<rdkit-discuss@lists.sourceforge.net<mailto:rdkit-discuss@lists.sourceforge.net>>
Subject: Re: [Rdkit-discuss] elimination of small fragments
thank you much much Andrew for this detailed explanation
regards
Alfredo
Enviado desde
BlueMail<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.bluemail.me_r-3Fb-3D13187&d=DwMFaQ&c=ZbgFmJjg4pdtrnL2HUJUDw&r=ye79geYsJOYow8nmAS-YeajnH05xvpvKYegxy7w7vuo&m=75LbuhLBfnqpbB3VArtJWjFpQrdROqJLMAweVe6ID9Q&s=i8SBAYy6pifuFUux0kfKjgrXeSo64fbM7qq1vf10v_w&e=>
En 29 de junio de 2018, en 07:02, Andrew Dalke
<da...@dalkescientific.com<mailto:da...@dalkescientific.com>> escribió:
On Jun 28, 2018, at 22:08, Paolo Tosco
<paolo.tosco.m...@gmail.com<mailto:paolo.tosco.m...@gmail.com>> wrote:
if you wish to keep only the largest disconnected fragment you may try the
following:
mols = list(rdmolops.GetMolFrags(mol, asMols = True))
if (mols):
mols.sort(reverse = True, key = lambda m: m.GetNumAtoms())
mol = mols[0]
A somewhat simpler .. or at least shorter ... version is:
mols = rdmolops.GetMolFrags(mol, asMols = True)
mol = max(mols, default=mol, key=lambda m: m.GetNumAtoms())
The max() function goes through the molecules that GetMolFrag returns.
If the list is empty, it returns the 'default' value, which is the original
molecule. (This is what Paolo's code does. Another option is to use None as the
default value.)
Otherwise, since 'key' is specified, its value is used as a function to
determine a value for each molecule. That is, for each term 'm' in the list of
'mols', it computes m.GetNumAtoms(), and uses that return value to select an
object with the maximum value.
In this case, it selects a molfrag output molecule with the most atoms.
I think I've just added a topic to cover for the upcoming Python/RDKit training
session in September! :)
For those interested, remember to sign up soon.
Cheers,
Andrew
da...@dalkescientific.com<mailto:da...@dalkescientific.com>
________________________________
Check out the vibrant tech community on one of the world's most
engaging tech sites,
Slashdot.org<https://urldefense.proofpoint.com/v2/url?u=http-3A__Slashdot.org&d=DwMFaQ&c=ZbgFmJjg4pdtrnL2HUJUDw&r=ye79geYsJOYow8nmAS-YeajnH05xvpvKYegxy7w7vuo&m=75LbuhLBfnqpbB3VArtJWjFpQrdROqJLMAweVe6ID9Q&s=h4ZtqIyv1SgsHQdUOLsu4O6hQ8h8t6pkdfVyvnZ08t4&e=>!
http://sdm.link/slashdot<https://urldefense.proofpoint.com/v2/url?u=http-3A__sdm.link_slashdot&d=DwMFaQ&c=ZbgFmJjg4pdtrnL2HUJUDw&r=ye79geYsJOYow8nmAS-YeajnH05xvpvKYegxy7w7vuo&m=75LbuhLBfnqpbB3VArtJWjFpQrdROqJLMAweVe6ID9Q&s=dWUkmyQ6plFLpxwGe7NZWqz46s0w27g19OXXzmG0UtU&e=>
________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net<mailto:Rdkit-discuss@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss<https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.sourceforge.net_lists_listinfo_rdkit-2Ddiscuss&d=DwMFaQ&c=ZbgFmJjg4pdtrnL2HUJUDw&r=ye79geYsJOYow8nmAS-YeajnH05xvpvKYegxy7w7vuo&m=75LbuhLBfnqpbB3VArtJWjFpQrdROqJLMAweVe6ID9Q&s=RIM0cdqho8moISItb75211bxVlxWPUCZCf6dWh4KNtI&e=>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org!
http://sdm.link/slashdot<https://urldefense.proofpoint.com/v2/url?u=http-3A__sdm.link_slashdot&d=DwMFaQ&c=ZbgFmJjg4pdtrnL2HUJUDw&r=ye79geYsJOYow8nmAS-YeajnH05xvpvKYegxy7w7vuo&m=A7rDVIg3atHUoU-oJqjIc2Dtoe0tPudYQEuvWycF0uo&s=IR6a83Iykc2U9efkA-6GKIkjBhscyNNDv4CaXwNcbkM&e=>_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net<mailto:Rdkit-discuss@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss<https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.sourceforge.net_lists_listinfo_rdkit-2Ddiscuss&d=DwMFaQ&c=ZbgFmJjg4pdtrnL2HUJUDw&r=ye79geYsJOYow8nmAS-YeajnH05xvpvKYegxy7w7vuo&m=A7rDVIg3atHUoU-oJqjIc2Dtoe0tPudYQEuvWycF0uo&s=a3wTrovDTDYS6qjT6jBR6ymsnt5gXd6db5UKg7hLiEA&e=>
------------------------------------------------------------------------------
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