One addition that I would make to the below is that if you are
searching the same molecules repeatedly it is really much faster if
you store them in the database as a binary object (BLOB in postgresql,
not sure what this is called in mysql).

To do this, you construct the molecules from smiles, convert them into
a binary string by calling mol.ToBinary(), and then put that binary
string in the db. To reconstruct the mol from the binary string you
call Chem.Mol(txt) where txt is the string from your database.

-Greg

On Monday, May 30, 2011, Andrew Dalke <da...@dalkescientific.com> wrote:
> Hi Paul,
>
> On May 30, 2011, at 4:42 PM, paul.czodrow...@merck.de wrote:
>> I have some old code which I would like to convert smoothly to rdkit.
>    ...
>> Do I necessarily need to convert MySQL to PostgreSQL? A quick google search
>> shows me that this should be feasible, but I have never done it so far.
>
>
> That frowns code is only on the client side so you don't need to change the 
> database at all.
>
> I've been trying to figure out why your code turns the SMILES from the 
> database into a molecule, to get the canonical SMILES, then reinterprets the 
> canonical SMILES to go back into a molecule.
>
> That's one (or two) conversions too many. The following should work for you:
>
>
> pattern = Chem.MolFromSmarts("....pattern here ...")
>
> db_smiles = db.do('SELECT ligand_id, smiles FROM ligands;')
>
> ligand_ids = []
> for db_smile in db_smiles:
>         mol = Chem.MolFromSmiles(db_smile[1])
>         if mol is not None and mol.HasSubstructMatch(pattern):
>                 ligand_ids.append(db_smile[0])
>
>
> return ligand_ids
>
>
> The check for "mol is not None" is in case the SMILES is invalid, or cannot 
> be perceived by RDKit. The frowns code threw an exception in that case.
>
>
>                                 Andrew
>                                 da...@dalkescientific.com
>
>
>
> ------------------------------------------------------------------------------
> vRanger cuts backup time in half-while increasing security.
> With the market-leading solution for virtual backup and recovery,
> you get blazing-fast, flexible, and affordable data protection.
> Download your free trial now.
> http://p.sf.net/sfu/quest-d2dcopy1
> _______________________________________________
> Rdkit-discuss mailing list
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>

------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger. 
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today. 
http://p.sf.net/sfu/quest-sfdev2dev
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to