Class CySession


  • public final class CySession
    extends Object
    A session is an immutable snapshot of the data contents of Cytoscape. Sessions are only meant for saving and restoring the state of Cytoscape and are not meant to be used interactively for anything besides writing, reading, and restoring from session files.
    Using the data returned from the various methods in a CySession object should be sufficient to recreate all aspects of Cytoscape at the time the session was created.
    Creating an instance of CySession is done following the builder pattern. For example, the following code creates a session that only includes a list of networkViews and Cytoscape properties, but nothing else.
     CySession session = new CySession.Builder().networkViews(viewList).cytoscapeProperties(cyProps).build();
     


    Module: session-api

    To use this in your app, include the following dependency in your POM:

    <dependency>
        <groupId>org.cytoscape</groupId>
        <artifactId>session-api</artifactId>
    </dependency>

    Cytoscape Backwards Compatibility (Final Class): This class is final and therefore can't be extended by users. This means that we may add methods for minor version updates. Methods will only be removed for major version updates.
    • Method Detail

      • getNetworks

        public Set<CyNetwork> getNetworks()
        Returns a set of all CyNetwork objects contained in this Session.
        Returns:
        A set of all CyNetwork objects contained in this Session.
      • getNetworkViews

        public Set<CyNetworkView> getNetworkViews()
        Returns a set of all CyNetworkView objects contained in this Session.
        Returns:
        A set of all CyNetworkView objects contained in this Session.
      • getTables

        public Set<CyTableMetadata> getTables()
        Returns a set of all CyTable objects contained in this Session.
        Returns:
        A set of all CyTable objects contained in this Session.
      • getViewVisualStyleMap

        public Map<CyNetworkView,​String> getViewVisualStyleMap()
        Returns a map of CyNetworkViews to the names of the VisualStyle applied to that network view in this session.
        Returns:
        A map of CyNetworkViews to the names of the VisualStyle applied to that network view in this session.
      • getProperties

        public Set<CyProperty<?>> getProperties()
        Returns a set of CyProperty objects defined for this session.
        Returns:
        A set of session related CyProperty objects. defined for this session.
      • getVisualStyles

        public Set<VisualStyle> getVisualStyles()
        Returns a set containing all VisualStyles defined for this session.
        Returns:
        A Set of VisualStyle objects
      • getAppFileListMap

        public Map<String,​List<File>> getAppFileListMap()
        Returns a map of app names to lists of File objects that are stored as part of the session for the specified app.
        Returns:
        A map of app names to lists of File objects that are stored as part of the session for the specified app.
      • getObject

        public <T extends CyIdentifiable> T getObject​(Long oldSUID,
                                                      Class<T> type)
        When a session is restored, Cytoscape automatically generates new SUIDs. This method returns an object (CyNode, CyEdge, CyNetwork or CyNetworkView) given its former SUID.
        Use this method if the version of the loaded session is 3.0 or higher.
        Parameters:
        oldSUID - The former SUID.
        type - The Class of the object to be returned (CyNode, CyEdge, CyNetwork or CyNetworkView).
        Returns:
        An object (CyNode, CyEdge, CyNetwork or CyNetworkView) given its former SUID.
      • getObject

        public <T extends CyIdentifiable> T getObject​(String oldId,
                                                      Class<T> type)
        When a session is restored, Cytoscape automatically generates new SUIDs. This method returns an object (CyNode, CyEdge, CyNetwork or CyNetworkView) given its former identifier.
        Use this method if the version of the loaded session is 2.x, because older versions of Cytoscape save String IDs, such as node names and the network titles.
        Parameters:
        oldId - The former ID, from Cytocape versions prior than 3.0.
        type - The Class of the object to be returned (CyNode, CyEdge, CyNetwork or CyNetworkView).
        Returns:
        An object (CyNode, CyEdge, CyNetwork or CyNetworkView) given its former identifier.