Re: [Rdkit-discuss] Molecule representation

2017-03-08 Thread Dimitri Maziuk
On 03/07/2017 05:42 PM, Markus Metz wrote:
> Dear Stephane:
> Thank you very much.
> I will give it a try.

An alternative:

import os
import sys
import time
import threading
PYMOL_PATH = "/SOME/PLACE/lib64/python"
sys.path.append( PYMOL_PATH )
import pymol

def make_image( infile, outfile ) :

pymol.pymol_argv = ['pymol','-qc']
pymol.finish_launching()
cmd = pymol.cmd

cmd.load( infile )
cmd.hide( "everything" )
cmd.show( "sticks" )

cmd.util.cbaw()

cmd.set( "cartoon_discrete_colors", 1 )
cmd.set( "ray_opaque_background", "off" )
cmd.set( "ray_trace_mode",  1 )
cmd.set( "antialias", 2 )
cmd.set( "ray_trace_color", "grey" )
cmd.set( "cartoon_fancy_helices", 1 )
cmd.set( "cartoon_side_chain_helper", "on" )
cmd.png( outfile, width = 800, dpi = 300, ray = 1 )

while threading.active_count() > 2 :
time.sleep( 2 )
cmd.quit()


HTH,
-- 
Dimitri Maziuk
Programmer/sysadmin
BioMagResBank, UW-Madison -- http://www.bmrb.wisc.edu



signature.asc
Description: OpenPGP digital signature
--
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] Molecule representation

2017-03-07 Thread Greg Landrum
HI Markus,

On Tue, Mar 7, 2017 at 7:00 PM, Markus Metz  wrote:

>
> I am wondering if it is possible to depict 2D structures as ball and stick.
> I have some very simple fragments and I would like to use them for axis
> annotation in a heatmap.
> Currently I generate the png files via MolToFile and read them in again.
> Changing size did not help.
> I also tried to generate the molecules on the fly.
> But so far I am getting only 2D pictures which are not readable. I hope to
> resolve this issue by picking another representation such as ball and stick.
> Does anybody have a suggestion how I might change the molecular
> representation?
> As always I very much appreciate any input somebody may have.
>

Are you trying to get broader lines in the drawings and circles around the
atoms so that they are more visible or are you looking for something else?

One thing you might try is abusing the current code for handling highlights:

from rdkit.Chem import Draw
from IPython.display import SVG
def DrawCartoonMol(mol):
from rdkit.Chem.Draw.MolDrawing import DrawingOptions
ecolors = DrawingOptions.elemDict
d2 = Draw.MolDraw2DSVG(200,200)
dopts = d2.drawOptions()
m2=Draw.PrepareMolForDrawing(mol)

hcolors = {}
for at in m2.GetAtoms():
hcolors[at.GetIdx()] = ecolors.get(at.GetAtomicNum(),(0,0,0))

d2.DrawMolecule(m2,highlightAtoms=list(range(m2.GetNumAtoms())),highlightAtomColors=hcolors)
d2.FinishDrawing()
return d2.GetDrawingText().replace('svg:','')



This produces output like this:
[image: Inline image 1]
It's currently producing SVG, but you could also get PNG out of it.

Not perfect, but it's at least a start.
-greg


-greg
--
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] Molecule representation

2017-03-07 Thread Markus Metz
Dear Stephane:
Thank you very much.
I will give it a try.
Cheers,
Markus

On Tue, Mar 7, 2017 at 3:39 PM, Stéphane Téletchéa <
stephane.teletc...@univ-nantes.fr> wrote:

> Le 07/03/2017 à 19:00, Markus Metz a écrit :
> > Does anybody have a suggestion how I might change the molecular
> > representation?
>
> Dear Markus,
>
> If you want a clever image, you could use pymol in XML-RPC mode
> (https://iwatobipen.wordpress.com/2013/09/16/rdkit-and-pymol/),
> or draw an image with thicker bonds
> (http://asteeves.github.io/blog/2015/01/12/optimizing-in-rdkit/, but
> check also http://asteeves.github.io/blog/2015/01/14/editing-in-rdkit/
> especially the second point for drawing parameters).
>
> I'm not 100% sure it will be perfect for your needs, especially if you
> have large molecules (or a lot of them), but at least you have entry
> pointers to dig with.
>
> Best,
>
> Stéphane
>
> --
> Lecturer, UFIP, UMR 6286 CNRS, Team Protein Design In Silico
> UFR Sciences et Techniques, 2, rue de la Houssinière, Bât. 25, 44322
> Nantes cedex 03, France
> Tél : +33 251 125 636 / Fax : +33 251 125 632
> http://www.ufip.univ-nantes.fr/ - http://www.steletch.org
>
>
> 
> --
> Announcing the Oxford Dictionaries API! The API offers world-renowned
> dictionary content that is easy and intuitive to access. Sign up for an
> account today to start using our lexical data to power your apps and
> projects. Get started today and enter our developer competition.
> http://sdm.link/oxford
> ___
> Rdkit-discuss mailing list
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
--
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


[Rdkit-discuss] Molecule representation

2017-03-07 Thread Markus Metz
Dear all:

I am wondering if it is possible to depict 2D structures as ball and stick.
I have some very simple fragments and I would like to use them for axis
annotation in a heatmap.
Currently I generate the png files via MolToFile and read them in again.
Changing size did not help.
I also tried to generate the molecules on the fly.
But so far I am getting only 2D pictures which are not readable. I hope to
resolve this issue by picking another representation such as ball and stick.
Does anybody have a suggestion how I might change the molecular
representation?
As always I very much appreciate any input somebody may have.

Cheers,

Markus
--
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss