Hi,
I've tested the code below, and found out that put mol objects into pandas is
just straightforward.
[code]
#SMILES string list into mol objects, and then into dataframe
import pandas as pd
from rdkit import Chem
smiles = ['c1ccccc1', 'c1ccccc1O', 'c1cc(O)ccc1O']
mols = [Chem.MolFromSmiles(s) for s in smiles]
df = pd.DataFrame({'ID': ['Benzene', 'Phenol', 'Hydroquinone'], 'Mol': mols})
df.head()
[/code]
------------------ ???????? ------------------
??????: "????????????"<183310...@qq.com>;
????????: 2020??4??5??(??????) ????6:04
??????: "Paolo
Tosco"<paolo.tosco.m...@gmail.com>;"Rdkit-discuss"<Rdkit-discuss@lists.sourceforge.net>;
????: Re: [Rdkit-discuss] How to sort a list of mol objects
Hi Paolo,
Your previous reply already helped me.
If I need to sort multiple properties, with different directions, What would
the code be?
Would it be easier to put mols into a pandas dataframe? If so, how to do it?
Best regards
Zhenting
---Original---
From: "Paolo Tosco"<paolo.tosco.m...@gmail.com>
Date: Fri, Apr 3, 2020 23:58 PM
To: "Zhenting
Gao"<183310...@qq.com>;"Rdkit-discuss"<Rdkit-discuss@lists.sourceforge.net>;
Subject: Re: [Rdkit-discuss] How to sort a list of mol objects
Hi Zhenting,
you mean sort by a property value?
For example, this would sort your list by decreasing value of the
ACTIVITY property (e.g., assuming it is a pIC50):
mol_list.sort(key=lambda m: float(m.GetProp("ACTIVITY")), reverse=True)
Cheers,
p.
On 03/04/2020 16:38, Zhenting Gao wrote:
Hi,
I create a list of mol objects, now I want to sort these mol
objects, so that I can save the top 100 mols into an SDF file.
Could you help?
Best
Zhenting
4/3/2020
_______________________________________________ Rdkit-discuss
mailing list Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss