Programmatically export network from Cytoscape

13 views
Skip to first unread message

Tushar Choudhary

unread,
Jun 11, 2024, 10:03:51 AMJun 11
to cytoscape-app-dev
Hi,
I am trying to build a plugin for cytoscape which requires me to export the network from cytoscape desktop application to cytoscapejs JSON format.
What i want to do is when the  user clicks on the layouts that my plugin will offer, the program will automatically export the network from cytoscape desktop application and i want to then use that exported JSON file for my further operations.

I can't seem to find a direct API call which can do the same, i have stumbled upon the JSON plugin which i believe handles all JSON exports but i want to do it programmatically.

Any insights will be largely helpful

Regards
Tushar Choudhary

Scooter Morris

unread,
Jun 13, 2024, 12:31:38 AMJun 13
to cytoscape-app-dev
It is a bit opaque, but certainly doable with the API.  The tricky part is how to use the existing Cytoscape.js writer.  To do this, you'll need to get the service from OSGi.  The service class is CyNetworkViewWriterFactory and to make sure you get the right one, the ID is cytoscapejsNetworkWriterFactory, so it would be something like:


String filter = "("+ID+"=cytoscapejsNetworkWriterFactory)"
CyNetworkViewWriterFactory writeCyJs = serviceRegistrar.getService(CyNewtorkViewWriterFactory.class, filter);

// Open your output stream
CyWriter jsonWriter = writeCyjs.createWriter(outputStream, networkView);
jsonWriter.run();


Assuming you've already gotten the CyServiceRegistrar service.  The trick is to be able to use the filter to get the correct network view writer factory.  Hope this helps!

-- scooter

Tushar Choudhary

unread,
Jun 13, 2024, 8:01:09 AMJun 13
to cytoscap...@googlegroups.com
Hi Scooter,
Thank you for your prompt response. It worked! The only caveat was to resolve the dependency which I eventually figured out. It is working as expected. Further I am going to try and import a JSON file programmatically and hopefully I will figure it out using this as reference.

Regards

--
You received this message because you are subscribed to a topic in the Google Groups "cytoscape-app-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cytoscape-app-dev/tUEISVXLfGE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cytoscape-app-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cytoscape-app-dev/ba41d97a-1a67-4aa5-99e6-c4b7b9e38a41n%40googlegroups.com.


--

Tushar Choudhary

unread,
Jun 23, 2024, 11:38:46 AMJun 23
to cytoscape-app-dev
Hi,
I am trying to develop an application where i want to do some operations on the json network data exported from cytoscape. For this i am using the "JSON" java library. But when i add it as a maven dependency in the pom.xml of my app cytoscape does not detect it as an app after i copy the jar to `CytoscapeConfiguration/3/apps/installed`. Below is what i added to the pom.xml file. The app works as expected when it does not have this dependency. It would be a great help if someone could let me know what i am doing wrong here.

<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20210307</version>
</dependency>

Christopher Churas

unread,
Jun 25, 2024, 5:28:54 PMJun 25
to cytoscap...@googlegroups.com
Hi,
You could look in ~/CytoscapeConfiguration/3/framework-cytoscape.log file and look for error messages.

chris

You received this message because you are subscribed to the Google Groups "cytoscape-app-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cytoscape-app-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cytoscape-app-dev/3a434450-28fb-4881-b8b9-9c4f71470a34n%40googlegroups.com.

Tushar Choudhary

unread,
Jun 26, 2024, 8:54:01 AMJun 26
to cytoscap...@googlegroups.com
Hi,
Thank you for the suggestion. I looked at the logs and concluded that it was a versioning issue since cytoscape impl also uses json.org. After i changed the version to match the one used in "cytoscape impl" the issue was fixed.

Regards

Reply all
Reply to author
Forward
0 new messages