3

I want to automate saving a view in cytoscape using the py2cytoscape package.

from py2cytoscape import cyrest

cytoscape = cyrest.cyclient()
cytoscape.network.load_file("FILENAME.cyjs")
cytoscape.vizmap.apply(styles="default")
cytoscape.network.set_current(network="FILENAME")
cytoscape.layout.apply_preferred()
cytoscape.view.set_current(network="FILENAME")
cytoscape.view.fit_content()
cytoscape.network.deselect(nodeList='all', edgeList='all')

cytoscape.view.export(options="PDF", OutputFile="FILENAME")

Output below:

ValueError: {'status': 500, 'type': 'urn:cytoscape:ci:cyrest-core:v1:handle-json-command:errors:2', 'message': 'java.lang.NullPointerException', 'link': 'file:/Users/mgruzynski/CytoscapeConfiguration/3/framework-cytoscape.log'}

I tried to follow (Exporting high resolution image files): https://github.com/cytoscape/cytoscape-automation/blob/master/for-scripters/Python/advanced-cancer-networks-and-data.ipynb, but am getting the errors shown above.

Pika Supports Ukraine
  • 3,612
  • 10
  • 26
  • 42
Mike
  • 227
  • 1
  • 3
  • 17
  • Should edit your post with at least a detail question so we know what you are trying to ask help for. – Xion Jan 28 '19 at 23:16
  • As pointed out in the error, there might be more information in the log. Can you attach that? – Scooter Morris Jan 31 '19 at 16:52
  • this was fixed by just putting a time wait in so that cytoscape can catch up to the python code. – Mike Feb 01 '19 at 18:02
  • Thanks for sharing the answer, but please consider writing this as an answer below and accepting it, so that people with the same problem can find the solution faster and more detailed (please remember to add the relevant code too). Thank you! – Stephan T. Feb 11 '19 at 06:15

1 Answers1

0

There have been small changes with Cytoscape 3.7.1

Please install py2cytoscape from the development branch

pip uninstall py2cytoscape
pip install git+https://github.com/cytoscape/py2cytoscape.git --user

and then use

cytoscape.view.export(options="PDF", outputFile="FILENAME")