Search code examples
javacytoscape

Reading the List of Open Networks in Cytoscape


I am trying to get a CyNetwork[] containing all of the networks open in the Cytoscape network tab. My understanding is that I need a CyNetworkReader to call CyNetworkReader.getNetworks() and to get a CyNetworkReader I need a CyNetworkReaderManager. However, I don't know how to get a CyNetworkReaderManager, nor do I know the proper InputStream or input name to use CyNetworkReaderManager.getReader(). Any help would be much appreciated.


Solution

  • Close. Actually, you would need a CyNetworkReader to read in a new network from disk. If you want to get the list of currently loaded networks, you would need to use the CyNetworkManager.getNetworkSet() method. To get a handle on the CyNetworkManager, you just need to get it from OSGi, so in your CyActivator, you would do something like:

    CyNetworkManager cyNetworkManager = getService(CyNetworkManager.class);
    

    That's it.