Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zoom parameter has no effect in export_image #90

Closed
nilsoberg opened this issue Jul 14, 2022 · 4 comments
Closed

Zoom parameter has no effect in export_image #90

nilsoberg opened this issue Jul 14, 2022 · 4 comments

Comments

@nilsoberg
Copy link
Contributor

The export_image function in the py4cytoscape code has a zoom parameter. It doesn’t seem to be acknowledged by 3.10 using a recent version of py4cytoscape. When using py4cytoscape with Cytoscape 3.8, the code doesn’t seem to respect that parameter either, or at least there is no apparent effect when I change it.

Related to #81

@bdemchak
Copy link
Collaborator

Thanks, Nils ...

This Zoom case caused a lot of discussion in the Cytoscape Automation group, and there is a pending solution proposed in issue #89. Feel free to browse it.

In the meantime, I think all of your concerns may be addressable using the new Cytoscape v10 export functions ... there is one function per file type. Supposing PNG, you can try the new function via Swagger (do you know how to do this?) and /v1/commands/view/export png. To demonstrate the parameters, I used:

{
"allGraphicsDetails": "true",
"hideLabels": "true",
"outputFile": "C:/Users/CyDeveloper/PycharmProjects/py4cytoscape/tests/output/View2.png",
"transparentBackground": "true",
"view": "CURRENT",
"zoom": "200.0"
}

For your Zoom experiment, try 100 for "no zoom" and 200 for "zoom in". On my PC, your large_ssn.xgmml renders 45KB for zoom 100 and 118KB for zoom 200.

I suspect that your export_image() problem may be because you're specifying both a height/width and a zoom. I suspect they conflict and are redundant. Also, specifying height and width is problematic because Cytoscape will likely override one of them in the interest of maintaining aspect ratio. So, all in all, it's probably better to just allow a zoom argument, which is what the Cytoscape v10 functions do.

Comments?

@nilsoberg
Copy link
Contributor Author

This looks interesting.

I am not sure how to use Swagger -- is that through a JSON object passed to the REST API?

@bdemchak
Copy link
Collaborator

Hi, Nils --

OK ... you're in for a treat. I'll give three equivalent ways of checking out Cytoscape functions that aren't covered in py4cytoscape (or are too new to have py4cytoscape functions).

  1. The first involves the Cytoscape Commands dialog, which you can view by clicking on Cytoscape's "Command Line" icon in the lower left of the Cytoscape window. From there, you can enter the command "help", and you'll see all of the namespaces for Cytoscape commands. If you enter "help view", you'll see all of the view-oriented commands, including "view export png". If you enter "help view export png", you'll see the parameters for the new "view export png" command. You can enter a command like this to get a PNG:

view export png outputFile="C:/Users/CyDeveloper/PycharmProjects/py4cytoscape/tests/output/bdtest.png" view="CURRENT" zoom="200.0"

From the help text, you can see a number of other parameters you'll find useful.

  1. You can do the same thing from py4cytoscape by using the commands_post() function:
import py4cytoscape as py4
py4.commands_post('view export png outputFile="C:/Users/CyDeveloper/PycharmProjects/py4cytoscape/tests/output/bdtest.png" view="CURRENT" zoom="200.0"')

A full explanation of this style is here.

  1. You can use the browser-based Swagger tool to call CyREST to do the same thing. Look here for an understanding of how Swagger allows you to call REST APIs. See these two sections:

Improved documentation infrastructure and content standards

New interactive CyREST call prototyping

Actually, the whole paper is germane, in case you have time for a good read. This is what the Swagger window looks like:

image

@nilsoberg2
Copy link

Thank you very much for this information. I have questions, but unfortunately, I will be away for a few weeks so I'll get back to you when I return.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants