dsehnal / LiteMol

A library/plugin for handling 3D structural molecular data (not only) in the browser.
Other
155 stars 36 forks source link

Open LiteMol Viewer programatically with parameters #2

Open nclopezo opened 7 years ago

nclopezo commented 7 years ago

Hi,

I noticed that it is possible to load data from a URL or from a file in SDF format. I would like to programatically open the viewer with the source of this data as a parameter. I would like to generate links from compounds in ChEMBL using the SDF data of the compound.

For example, I can generate a url to obtain the SDF data, something similar to this: ftp://ftp.ebi.ac.uk/pub/databases/msd/pdbechem/files/sdf_r/AIN.sdf

Now I would like to open the viewer with this data. Something like: https://webchemdev.ncbr.muni.cz/LiteMol/Viewer/?load_sdf_from_url=ftp://ftp.ebi.ac.uk/pub/databases/msd/pdbechem/files/sdf_r/AIN.sdf

And that would open the viewer, load the SDF data and render the molecule. Is that possible somehow?

I also tried to use the embedded element from here but it only accepts PBD IDs.

Thanks

dsehnal commented 7 years ago

Hi David,

I've added the support for this to the viewer app (https://github.com/dsehnal/LiteMol/blob/master/src/Viewer/App/App.ts)

However, there are a few details that you need to consider:

Here's a demo http://webchemdev.ncbr.muni.cz/LiteMol/Viewer/?loadFromURL=https%3A%2F%2Ffiles.rcsb.org%2Fligands%2Fview%2FAIN_ideal.sdf&loadFromURLFormat=SDF

You should be able to modify one of the examples/create custom plugin spec to suit your needs based on the Viewer implementation of the feature.

If you need more help, please let me know.

David

nclopezo commented 7 years ago

Hi David,

Thank you for your answer.

On Thu, Nov 3, 2016 at 1:01 PM, David Sehnal notifications@github.com wrote:

Hi David,

I've added the support for this to the viewer app ( https://github.com/dsehnal/LiteMol/blob/master/src/Viewer/App/App.ts)

However, there are a few details that you need to consider:

  • The server you download the data from needs to support cross server origin. So ftp is a no-go unless you add a "service" on your web that downloads it and then re-sends it. I was unable to find compound models in SDF format from PDBe that would support x-origin, but RCSB does.
  • You need to "URL encode" the URLs (can be done in JS using the encodeURIComponent function).

Here's a demo http://webchemdev.ncbr.muni.cz/LiteMol/Viewer/? loadFromURL=https%3A%2F%2Ffiles.rcsb.org%2Fligands%2Fview%2FAIN_ideal.sdf& loadFromURLFormat=SDF

You should be able to modify one of the examples/create custom plugin spec to suit your needs based on the Viewer implementation of the feature.

Do you mean here that it will be possible to include this feature in the custom html tag?

> If you need more help, please let me know. > > David > > — > You are receiving this because you authored the thread. > Reply to this email directly, view it on GitHub > https://github.com/dsehnal/LiteMol/issues/2#issuecomment-258135621, or mute > the thread > https://github.com/notifications/unsubscribe-auth/AB2tWldYLLuNhe4iSn74RrGN-RJG61gsks5q6dsPgaJpZM4KoR57 > . ## David Mendez
dsehnal commented 7 years ago

I've notified the person who takes care of the component library plugin and included you.