protwis / protwis

Protwis is the backbone of the GPCRdb. The GPCRdb contains reference data, interactive visualisation and experiment design tools for G protein-coupled receptors (GPCRs).
https://gpcrdb.org
Apache License 2.0
34 stars 68 forks source link

Using API to pull snakeplots #524

Open samhimes92 opened 4 months ago

samhimes92 commented 4 months ago

Hi,

I'm working on creating on interactive visualization using d3. I'd like to use the API to pull snake plot svgs. I started by pulling the snake plot svg from gpcrdb manually.

For example https://gpcrdb.org/protein/oprd_human/ -> download -> svg

It downloads the svg as an XML and it works perfectly for my purposes.

When I use the API , I use a request URL like this, https://gpcrdb.org/services/plot/snake/oprd_human and it downloads a json. When I convert that json to XML, I notice that there are some big differences between it and the XML that I downloaded manually. For example, the XML that I download manually has a ViewBox element, while the one pulled from the API doesn't.

Is there a way to get snakeplot pulled from the API to be the exact same as the one pulled manually from the db?

pszgaspar commented 4 months ago

Hi samhimes92,

Thanks for raising the issue, we will look into it shortly. I transferred the issue to this repository (protwis) as it is code related and the solution will be pushed here.

Best, Gaspar

Jimmy-A-Caroli commented 3 months ago

Hi samhimes92,

we dig into making this viable through API but it seems that it is trickier than expect. What you can download through the API is actually the same input data that gets transferred to a JavaScript applet for the download rendering in the page. Somehow, it is still not straightforward the porting of this JS translation through the API. As you mentioned, the ViewBox element is added thanks to the supporting JS code in the page, while the API pulls the regular XML still raw.

You can use the JS script from our repo, located in static/js under the name of SaveSvgAsPng.js

That should give you the same output once processed. We will continue working on this issues to hopefully have a cleaner output from the API, so that it matches the actual online experience. Hope this helps, Jimmy