Dear Alfredo,
Although not strictly based on the number of atoms, but on the length of
SMILES string, the simplest way is using Python built-in functions as
follows:
smiles = 'CCC.CC'
fragment = max(smiles.split('.'), key=len)
print (fragment)
Best regards,
Hideyoshi
thank you Paolo for this help, I will study the code and try it,
>
> best regards
>
> Alfredo
>
> Enviado desde BlueMail <http://www.bluemail.me/r?b=13187>
>
> En 28 de junio de 2018, en 17:08, Paolo Tosco <paolo.tosco.m...@gmail.com>
> escribió:
>
> Dear Alfredo,
>
> 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]
>
> Hope that helps, cheers
> p.
>
> On 06/28/18 19:38, Alfredo Quevedo wrote:
>
> Good afternoon,
>
> I would like to filter out small fragments from a list of molecules
> using the below strategy:
>
> from rdkit import Chem
> from rdkit.Chem import AllChem
> from rdkit.Chem import SaltRemover fragment
>
> remover=SaltRemover.SaltRemover()
> mol=Chem.MolFromSmiles('CCC.CC')
> res=remover.StripMol(mol)
> print(res.GetNumAtoms())
>
>
> I am getting 5 atoms as output, so the ´CC´ is not being stripped (the
> script workd ok for salts). Is there any way of filtering non salts
> small fragments?
>
> thank you very much in advance,
>
> regards,
>
> Alfredo
>
>
>
>
>
> ------------------------------
>
>
>
> 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