Re: [Rdkit-discuss] Bond tags in SVGs

2019-03-12 Thread Greg Landrum
HI Lukas,

I haven't done the build yet. I will see if I can manage to do one tomorrow.

These changes have been merged onto the trunk and will definitely be in the
release.

-greg


On Tue, Mar 12, 2019 at 10:42 AM Lukas Pravda  wrote:

> Hi Greg,
>
>
>
> I was wondering If you managed to create the Mac build you were talking
> about some time ago. Also I wonder If this functionality is going to be
> part of the next RDKit release?
>
>
>
> Best,
>
> Lukas
>
>
>
> *From: *Greg Landrum 
> *Date: *Tuesday, 5 February 2019 at 14:45
> *To: *Lukas Pravda 
> *Cc: *RDKIT mailing list 
> *Subject: *Re: [Rdkit-discuss] Bond tags in SVGs
>
>
>
> Sure. I don't have my Mac with me, so that'll need to wait until I'm back
> in Basel on the weekend.
>
>
>
> -greg
>
>
>
>
>
>
>
> On Tue, Feb 5, 2019 at 2:39 PM Lukas Pravda  wrote:
>
> If it is not too much trouble to ask, please build it for mac os (10.14.3)
> python 3.6.x.
>
>
>
> Thanks!
>
> Lukas
>
>
>
> *From: *Greg Landrum 
> *Date: *Tuesday, 5 February 2019 at 13:40
> *To: *Lukas Pravda 
> *Cc: *RDKIT mailing list 
> *Subject: *Re: [Rdkit-discuss] Bond tags in SVGs
>
>
>
>
>
>
>
> On Tue, Feb 5, 2019 at 12:23 PM Lukas Pravda  wrote:
>
>
>
> Thanks for this. It looks excellent!! Is there a way how I can test this?
> Other than cloning and compiling the repository? So far I have been using
> rdkit solely from python and its conda builds, so don’t really know how to
> test it.
>
>
>
> At the moment you would need to get a copy of the repo and build it. I can
> do a build so that it's conda-installable though. Which OS are you using?
>
>
>
> If I understand this correctly, the atom and bond class ids are added only
> after TagAtoms() is called, or are they added at the ‘DrawMolecule()’
> stage?
>
>
>
> Bond classes are added as the bonds are written. Atom classes can only be
> added at the TagAtoms() stage - there's not an object in the SVG for many
> atoms without TagAtoms() being called.
>
>
>
> I can imagine a lot of possible scenarios and use cases with this new
> functionality. However, in order to make the function TagAtoms()
> sufficiently general, a bit more control over the javascript used in the
> events would be needed. As a possible suggestions, I can imagine to pass as
> the third parameter a lambda selector, which would in turn feed the JS
> function with parameters to display names/charges/whatever. Also it would
> be nice to have a mean how to pass dict of key-val properties for both
> atoms and bonds so that you can incorporate related data into the svg.
>
>
>
> Having said that, in my opinion if svgs end up as a part of
> html/javascript application, it is the best to expose this interactivity
> directly from the client, rather than ‘pre-generating’ the behaviour on the
> server. So I’m not sure If it is worth investing time into mimicking this
> functionality in C++/python code, Whoever is in a need of generating
> interactive svgs, can directly consume the svg string and modify it
> according to their needs.
>
>
>
> Yeah, that's more or less what I was thinking. We want to write something
> that can be reasonably easily modified after the fact to produce something
> useful.
>
>
>
>
>
> To sum up, I think it should enough just to tag positions and identifiers
> of atoms/bonds exactly as you do and possibly further extend them with a
> mean how to pass some extra data to all of it. Then users can modify svgs
> whichever way they want, but others might think differently.
>
>
>
> Excellent!
>
>
>
> -greg
>
>
>
>
>
> Best,
>
> Lukas
>
> *From: *Greg Landrum 
> *Date: *Sunday, 3 February 2019 at 17:49
> *To: *Lukas Pravda 
> *Cc: *RDKIT mailing list 
> *Subject: *Re: [Rdkit-discuss] Bond tags in SVGs
>
>
>
> Hi Lukas,
>
>
>
> I had a chance to do a bit of work on this recently and I'd be interested
> to hear your feedback.
>
>
>
> Bonds are now tagged with their bond IDs (using classes) and the
> "TagAtoms()" function now adds clickable transparent circles above each
> atom. These are also tagged with atom IDs using classes. TagAtoms() also
> lets you add callback functions for events associated with the atom
> circles. At the moment these are simply called with the atom id, but
> there's almost certainly a better way to do that. Suggestions are very
> welcome.
>
>
>
> Here's a gist showing what's currently on the branch:
> https://gist.github.com/greglandrum/d23517cb449003252cf09b5bd14d8637
>
>
>
>
>
> On Tue, Dec 4, 2018 at 6:46 PM Lukas Pravda  wrote:
>
> Hi Greg,
>
>
>
> that’s what I have been thinking, unlucky. Essentially, I want to color
> the molecule in web-browser with various annotations and make it
> interactive. For that part I’m converting it internally to the d3.js
> internal representation (https://d3js.org/) and connecting it to its
> environment. For most of the parts I’m just fine with the position of atoms
> in svg using the tag property.
>
>
>
> What I wanted to avoid is to replicate rdkit svg drawing code in
> javascript so that I 

Re: [Rdkit-discuss] Bond tags in SVGs

2019-03-12 Thread Lukas Pravda
Hi Greg,

 

I was wondering If you managed to create the Mac build you were talking about 
some time ago. Also I wonder If this functionality is going to be part of the 
next RDKit release?

 

Best,

Lukas

 

From: Greg Landrum 
Date: Tuesday, 5 February 2019 at 14:45
To: Lukas Pravda 
Cc: RDKIT mailing list 
Subject: Re: [Rdkit-discuss] Bond tags in SVGs

 

Sure. I don't have my Mac with me, so that'll need to wait until I'm back in 
Basel on the weekend.

 

-greg

 

 

 

On Tue, Feb 5, 2019 at 2:39 PM Lukas Pravda  wrote:

If it is not too much trouble to ask, please build it for mac os (10.14.3) 
python 3.6.x.

 

Thanks!

Lukas

 

From: Greg Landrum 
Date: Tuesday, 5 February 2019 at 13:40
To: Lukas Pravda 
Cc: RDKIT mailing list 
Subject: Re: [Rdkit-discuss] Bond tags in SVGs

 

 

 

On Tue, Feb 5, 2019 at 12:23 PM Lukas Pravda  wrote:

 

Thanks for this. It looks excellent!! Is there a way how I can test this? Other 
than cloning and compiling the repository? So far I have been using rdkit 
solely from python and its conda builds, so don’t really know how to test it.

 

At the moment you would need to get a copy of the repo and build it. I can do a 
build so that it's conda-installable though. Which OS are you using?

 

If I understand this correctly, the atom and bond class ids are added only 
after TagAtoms() is called, or are they added at the ‘DrawMolecule()’ stage? 

 

Bond classes are added as the bonds are written. Atom classes can only be added 
at the TagAtoms() stage - there's not an object in the SVG for many atoms 
without TagAtoms() being called. 

 

I can imagine a lot of possible scenarios and use cases with this new 
functionality. However, in order to make the function TagAtoms() sufficiently 
general, a bit more control over the javascript used in the events would be 
needed. As a possible suggestions, I can imagine to pass as the third parameter 
a lambda selector, which would in turn feed the JS function with parameters to 
display names/charges/whatever. Also it would be nice to have a mean how to 
pass dict of key-val properties for both atoms and bonds so that you can 
incorporate related data into the svg. 

 

Having said that, in my opinion if svgs end up as a part of html/javascript 
application, it is the best to expose this interactivity directly from the 
client, rather than ‘pre-generating’ the behaviour on the server. So I’m not 
sure If it is worth investing time into mimicking this functionality in 
C++/python code, Whoever is in a need of generating interactive svgs, can 
directly consume the svg string and modify it according to their needs.

 

Yeah, that's more or less what I was thinking. We want to write something that 
can be reasonably easily modified after the fact to produce something useful.

 

 

To sum up, I think it should enough just to tag positions and identifiers of 
atoms/bonds exactly as you do and possibly further extend them with a mean how 
to pass some extra data to all of it. Then users can modify svgs whichever way 
they want, but others might think differently.

 

Excellent!

 

-greg

 

 

Best,

Lukas

From: Greg Landrum 
Date: Sunday, 3 February 2019 at 17:49
To: Lukas Pravda 
Cc: RDKIT mailing list 
Subject: Re: [Rdkit-discuss] Bond tags in SVGs

 

Hi Lukas,

 

I had a chance to do a bit of work on this recently and I'd be interested to 
hear your feedback.

 

Bonds are now tagged with their bond IDs (using classes) and the "TagAtoms()" 
function now adds clickable transparent circles above each atom. These are also 
tagged with atom IDs using classes. TagAtoms() also lets you add callback 
functions for events associated with the atom circles. At the moment these are 
simply called with the atom id, but there's almost certainly a better way to do 
that. Suggestions are very welcome.

 

Here's a gist showing what's currently on the branch: 
https://gist.github.com/greglandrum/d23517cb449003252cf09b5bd14d8637

 

 

On Tue, Dec 4, 2018 at 6:46 PM Lukas Pravda  wrote:

Hi Greg, 

 

that’s what I have been thinking, unlucky. Essentially, I want to color the 
molecule in web-browser with various annotations and make it interactive. For 
that part I’m converting it internally to the d3.js internal representation 
(https://d3js.org/) and connecting it to its environment. For most of the parts 
I’m just fine with the position of atoms in svg using the tag property.

 

What I wanted to avoid is to replicate rdkit svg drawing code in javascript so 
that I don’t want to consume the dump of rdkit.Mol object. What I wanted to do 
instead is to use existing svg images and parse them into d3.js, so I know 
which paths belong to which bond.

 

At this point my only idea is to color bonds individually and based on the 
overlay/proximity use kd-tree to reverse-engineer which bonds the paths belong 
to, which is a bit overkill in my view.

 

Lukas  

 

 

From: Greg Landrum 
Date: Tuesday, 4 December 2018 at 17:24
To: Lukas