Re: [Rdkit-discuss] Bond tags in SVGs

2019-03-13 Thread Greg Landrum
Hi Lukas,

I did a Mac build for python 3.6 this morning and put it in my channel with
a beta label.
You can install it like this:
conda install -c greglandrum/label/beta rdkit

Please let me know if you hit any problems
-greg


On Tue, Mar 12, 2019 at 11:40 AM Greg Landrum 
wrote:

> 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: *Luka

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:

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

Re: [Rdkit-discuss] Bond tags in SVGs

2019-02-05 Thread Peter St. John
Just wanted to chime in that I'm also excited by this functionality!

an alternative to the SVG classes would be to nest atoms and bonds in svg
groups;






You could also put the atoms and bonds in their own groups if it was easy:


...
...


 
...


That being said, I'm not sure that does much more for someone writing in
d3.js functionality that you couldn't do with the existing code. So if
trying to do that messes up the rest of the drawing code ignore the comment
:)


Thanks for the work on this!
-- Peter


On Tue, Feb 5, 2019 at 7:46 AM Greg Landrum  wrote:

> 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
>> circ

Re: [Rdkit-discuss] Bond tags in SVGs

2019-02-05 Thread Greg Landrum
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.
>

Re: [Rdkit-discuss] Bond tags in SVGs

2019-02-05 Thread Lukas Pravda
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 Pravda 
Cc: RDKIT mailing list 
Subject: Re: [Rdkit-discuss] Bond tags in SVGs

 

Hi Lukas,

 

There's not currently a way to do this at the moment. The closest you can get 
is by calling AddMoleculeMetadata():

 

In [6]: d = Draw.MolDraw2DSVG(200,200)

 

In [8]: d.DrawMolecule(nm)

 

In [10]: d.AddMoleculeMetadata(nm)

 

In [11]: d.FinishDrawing()

 

In [12]: svg = d.GetDrawingText()

 

In [14]: print(svg)





 







http://www.rdkit.org/xml; version="0.9">















 

This gets you t

Re: [Rdkit-discuss] Bond tags in SVGs

2019-02-05 Thread Greg Landrum
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 Pravda 
> *Cc: *RDKIT mailing list 
> *Subject: *Re: [Rdkit-discuss] Bond tags in SVGs
>
>
>
> Hi Lukas,
>
>
>
> There's not currently a way to do this at the moment. The closest you can
> get is by calling AddMoleculeMetadata():
>
>
>
> In [6]: d = Draw.MolDraw2DSVG(200,200)
>
>
>
> In

Re: [Rdkit-discuss] Bond tags in SVGs

2019-02-05 Thread Lukas Pravda
Hi Greg,

 

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.

 

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? 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.

 

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.

 

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 Pravda 
Cc: RDKIT mailing list 
Subject: Re: [Rdkit-discuss] Bond tags in SVGs

 

Hi Lukas,

 

There's not currently a way to do this at the moment. The closest you can get 
is by calling AddMoleculeMetadata():

 

In [6]: d = Draw.MolDraw2DSVG(200,200)

 

In [8]: d.DrawMolecule(nm)

 

In [10]: d.AddMoleculeMetadata(nm)

 

In [11]: d.FinishDrawing()

 

In [12]: svg = d.GetDrawingText()

 

In [14]: print(svg)





 







http://www.rdkit.org/xml; version="0.9">















 

This gets you the information you need to connect bond indices to the atoms, 
but I suspect that's not what you're looking for.

 

In general you are guaranteed that the order of the bonds in the output SVG is 
the same as the order in the input molecule, but you can have multiple paths 
for a given bond. For example here, where the end atoms have different colors:

 

In [25]: print(svg)





 





OH



http://www.rdkit.org/xml; version="0.9">











 

What are you looking to be able to do? That may make it easier to either come 
up with a work around or figure out what a new feature addition might look like.

 

-greg

 

 

 

 

On Mon, Dec 3, 2018 at 6:57 PM Lukas Pravda  wrote:

Hi all,

 

I was wondering if there is a way how you can tag  elements (bonds) in 
the svg created by rdkit.

 

i.e. transform something like this: 





 

Into:





 

Re: [Rdkit-discuss] Bond tags in SVGs

2019-02-02 Thread Greg Landrum
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 Pravda 
> *Cc: *RDKIT mailing list 
> *Subject: *Re: [Rdkit-discuss] Bond tags in SVGs
>
>
>
> Hi Lukas,
>
>
>
> There's not currently a way to do this at the moment. The closest you can
> get is by calling AddMoleculeMetadata():
>
>
>
> In [6]: d = Draw.MolDraw2DSVG(200,200)
>
>
>
> In [8]: d.DrawMolecule(nm)
>
>
>
> In [10]: d.AddMoleculeMetadata(nm)
>
>
>
> In [11]: d.FinishDrawing()
>
>
>
> In [12]: svg = d.GetDrawingText()
>
>
>
> In [14]: print(svg)
>
> 
>
> 
>   xmlns='http://www.w3.org/2000/svg'
>
>   xmlns:rdkit='http://www.rdkit.org/xml'
>
>   xmlns:xlink='http://www.w3.org/1999/xlink'
>
>   xml:space='preserve'
>
> width='200px' height='200px' >
>
>  height='200' x='0' y='0'> 
>
>  style='fill:none;fill-rule:evenodd;stroke:#00;stroke-width:2px;stroke-linecap:butt;stroke-linejoi
>
> n:miter;stroke-opacity:1' />
>
>  style='fill:none;fill-rule:evenodd;stroke:#00;stroke-width:2px;stroke-linecap:butt;stroke-linejoi
>
> n:miter;stroke-opacity:1' />
>
> 
>
> http://www.rdkit.org/xml; version="0.9">
>
>  drawing-y="126.243" x="-1.29904" y="-0.25" z="0" />
>
>  drawing-y="73.7568" x="0" y="0.5" z="0" />
>
>  drawing-y="126.243" x="1.29904" y="-0.25" z="0" />
>
> 
>
> 
>
> 
>
> 
>
>
>
> This gets you the information you need to connect bond indices to the
> atoms, but I suspect that's not what you're looking for.
>
>
>
> In general you are guaranteed that the order of the bonds in the output
> SVG is the same as the order in the input molecule, but you can have
> multiple paths for a given bond. For example here, where the end atoms have
> different colors:
>
>
>
> In [25]: print(svg)
>
> 
>
> 
>   xmlns='http://www.w3.org/2000/svg'
>
>   xmlns:rdkit='http://www.rdkit.org/xml'
>
>   xmlns:xlink='http://www.w3.org/1999/xlink'
>
>   xml:space='preserve'
>
> width='200px' height='200px' >
>
>  height='200' x='0' y='0'> 
>
>  style='fill:none;fill-rule:evenodd;stroke:#00;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:mi
>
> ter;stroke-opacity:1' />
>
>  style='fill:none;fill-rule:evenodd;stroke:#FF;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:mi
>
> ter;stroke-opacity:1' />
>
>  style='font-size:15px;font-style:normal;font-weight:normal;fill-opacity:1;stroke:none;font-family:sans-serif;text
>
> -anchor:start;fill:#FF' >OH
>
> 
>
> http://www.rdkit.org/xml; version="0.9">
>
>  drawing-y="100" x="-0.75" y="5.55112e-17" z="0" />
>
>  x="0.75&quo

Re: [Rdkit-discuss] Bond tags in SVGs

2018-12-04 Thread Lukas Pravda
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 Pravda 
Cc: RDKIT mailing list 
Subject: Re: [Rdkit-discuss] Bond tags in SVGs

 

Hi Lukas,

 

There's not currently a way to do this at the moment. The closest you can get 
is by calling AddMoleculeMetadata():

 

In [6]: d = Draw.MolDraw2DSVG(200,200)

 

In [8]: d.DrawMolecule(nm)

 

In [10]: d.AddMoleculeMetadata(nm)

 

In [11]: d.FinishDrawing()

 

In [12]: svg = d.GetDrawingText()

 

In [14]: print(svg)





 







http://www.rdkit.org/xml; version="0.9">















 

This gets you the information you need to connect bond indices to the atoms, 
but I suspect that's not what you're looking for.

 

In general you are guaranteed that the order of the bonds in the output SVG is 
the same as the order in the input molecule, but you can have multiple paths 
for a given bond. For example here, where the end atoms have different colors:

 

In [25]: print(svg)





 





OH



http://www.rdkit.org/xml; version="0.9">











 

What are you looking to be able to do? That may make it easier to either come 
up with a work around or figure out what a new feature addition might look like.

 

-greg

 

 

 

 

On Mon, Dec 3, 2018 at 6:57 PM Lukas Pravda  wrote:

Hi all,

 

I was wondering if there is a way how you can tag  elements (bonds) in 
the svg created by rdkit.

 

i.e. transform something like this: 





 

Into:





 

Or similar. I’ve found possibility of tagging atoms in the SVG using 
Draw.rdMolDraw2D.MolDraw2DSVG.drawOptions() method that exposes property 
includeAtomTags. This then renders following additional elements into the SVG:

rdkit:atom idx="4" label="O-" x="153.479" y="82.8259" />

 

But I have not seen anything like this for bonds (latest release of RDKIT and 
python). Thanks, in advance for any hints. I was wondering about using 
highlightBondLists and then based on the svg infer the bond annotation, but 
that seems to be a bit of an overkill.

 

Cheers,

Lukas

 

 

___
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


Re: [Rdkit-discuss] Bond tags in SVGs

2018-12-04 Thread Greg Landrum
Hi Lukas,

There's not currently a way to do this at the moment. The closest you can
get is by calling AddMoleculeMetadata():

In [6]: d = Draw.MolDraw2DSVG(200,200)

In [8]: d.DrawMolecule(nm)

In [10]: d.AddMoleculeMetadata(nm)

In [11]: d.FinishDrawing()

In [12]: svg = d.GetDrawingText()

In [14]: print(svg)


 



http://www.rdkit.org/xml; version="0.9">









This gets you the information you need to connect bond indices to the
atoms, but I suspect that's not what you're looking for.

In general you are guaranteed that the order of the bonds in the output SVG
is the same as the order in the input molecule, but you can have multiple
paths for a given bond. For example here, where the end atoms have
different colors:

In [25]: print(svg)


 


OH

http://www.rdkit.org/xml; version="0.9">







What are you looking to be able to do? That may make it easier to either
come up with a work around or figure out what a new feature addition might
look like.

-greg





On Mon, Dec 3, 2018 at 6:57 PM Lukas Pravda  wrote:

> Hi all,
>
>
>
> I was wondering if there is a way how you can tag  elements (bonds)
> in the svg created by rdkit.
>
>
>
> i.e. transform something like this:
>
> 
>
> 
>
>
>
> Into:
>
> 
>
> 
>
>
>
> Or similar. I’ve found possibility of tagging atoms in the SVG using
> Draw.rdMolDraw2D.MolDraw2DSVG.drawOptions() method that exposes property
> includeAtomTags. This then renders following additional elements into the
> SVG:
>
> rdkit:atom idx="4" label="O-" x="153.479" y="82.8259" />
>
>
>
> But I have not seen anything like this for bonds (latest release of RDKIT
> and python). Thanks, in advance for any hints. I was wondering about using
> *highlightBondLists* and then based on the svg infer the bond annotation,
> but that seems to be a bit of an overkill.
>
>
>
> Cheers,
>
> Lukas
>
>
>
>
> ___
> 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