Search in sources :

Example 66 with CyRootNetwork

use of org.cytoscape.model.subnetwork.CyRootNetwork in project cytoscape-impl by cytoscape.

the class Cy3SessionReaderImpl method extractNetworks.

private void extractNetworks(InputStream is, String entryName) throws Exception {
    CyNetworkReader reader = networkReaderMgr.getReader(is, entryName);
    reader.run(taskMonitor);
    final CyRootNetworkManager rootNetworkManager = serviceRegistrar.getService(CyRootNetworkManager.class);
    final CyNetwork[] netArray = reader.getNetworks();
    for (final CyNetwork net : netArray) {
        // Add its root-network to the lookup map first
        final CyRootNetwork rootNet = rootNetworkManager.getRootNetwork(net);
        if (!networkLookup.containsKey(rootNet.getSUID()))
            ;
        networkLookup.put(rootNet.getSUID(), rootNet);
        networkLookup.put(net.getSUID(), net);
        // Note: do NOT add the root-network to this set!
        networks.add(net);
    }
}
Also used : CyRootNetworkManager(org.cytoscape.model.subnetwork.CyRootNetworkManager) CyNetworkReader(org.cytoscape.io.read.CyNetworkReader) CyNetwork(org.cytoscape.model.CyNetwork) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Example 67 with CyRootNetwork

use of org.cytoscape.model.subnetwork.CyRootNetwork in project cytoscape-impl by cytoscape.

the class GenericXGMMLReader method init.

protected void init(final TaskMonitor tm) {
    readDataMgr.init();
    // TODO: refactor readDataMgr and delete this line
    readDataMgr.setViewFormat(false);
    // Now user has the option to import network into different collection
    final CyRootNetwork networkCollection = getRootNetwork();
    final Map<Object, CyNode> nMap = getNodeMap();
    readDataMgr.setNodeMap(nMap);
    readDataMgr.setParentNetwork(networkCollection);
}
Also used : CyNode(org.cytoscape.model.CyNode) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Example 68 with CyRootNetwork

use of org.cytoscape.model.subnetwork.CyRootNetwork in project cytoscape-impl by cytoscape.

the class NNFNetworkReader method run.

@Override
public void run(TaskMonitor tm) throws IOException {
    final CyRootNetwork rootNetwork = getRootNetwork();
    Map<Object, CyNode> nMap = this.getNodeMap();
    this.parser = new NNFParser(rootNetwork, cyNetworkFactory, nMap, serviceRegistrar);
    try {
        readInput(tm);
    } finally {
        if (inputStream != null) {
            try {
                inputStream.close();
                inputStream = null;
            } catch (Exception e) {
                logger.warn("Cannot close NNF input stream", e);
            }
        }
    }
}
Also used : CyNode(org.cytoscape.model.CyNode) IOException(java.io.IOException) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Example 69 with CyRootNetwork

use of org.cytoscape.model.subnetwork.CyRootNetwork in project cytoscape-impl by cytoscape.

the class HandleGraph method handleCy3Model.

/**
 * Handles "CyNetwork-type" XGMML from Cytoscape 3 session files only.
 * @param tag
 * @param atts
 * @param current
 * @return
 * @throws SAXException
 */
private ParseState handleCy3Model(String tag, Attributes atts, ParseState current) throws SAXException {
    final CyNetwork currentNet;
    boolean register = isRegistered(atts);
    if (manager.graphCount == 1) {
        // Root graph == CyRootNetwork
        currentNet = manager.createRootNetwork();
        register = false;
    } else if (manager.graphCount == 2) {
        // First nested graph == base-network
        final CyRootNetwork rootNet = manager.getRootNetwork();
        currentNet = rootNet.getBaseNetwork();
    } else {
        // Other nested graphs == regular sub-networks
        final CyRootNetwork rootNet = manager.getRootNetwork();
        currentNet = rootNet.addSubNetwork();
    }
    final Object id = getId(atts);
    addCurrentNetwork(id, currentNet, atts, register);
    return current;
}
Also used : CyNetwork(org.cytoscape.model.CyNetwork) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Example 70 with CyRootNetwork

use of org.cytoscape.model.subnetwork.CyRootNetwork in project cytoscape-impl by cytoscape.

the class HandleGraph method handleGenericXGMMLGraph.

/**
 * Handles standalone XGMML graphs, not associated with a session file.
 * @param tag
 * @param atts
 * @param current
 * @return
 * @throws SAXException
 */
private ParseState handleGenericXGMMLGraph(String tag, Attributes atts, ParseState current) throws SAXException {
    final CyNetwork currentNet;
    if (manager.graphCount == 1) {
        // Root (graph) element...
        final CyRootNetwork parentNet = manager.getParentNetwork();
        if (parentNet == null) {
            final CyRootNetwork rootNet = manager.createRootNetwork();
            currentNet = rootNet.getBaseNetwork();
        } else {
            currentNet = parentNet.addSubNetwork();
        }
    } else {
        // Nested graph tag...
        final CyRootNetwork rootNet = manager.getRootNetwork();
        currentNet = rootNet.addSubNetwork();
    }
    final Object id = getId(atts);
    addCurrentNetwork(id, currentNet, atts, true);
    return current;
}
Also used : CyNetwork(org.cytoscape.model.CyNetwork) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Aggregations

CyRootNetwork (org.cytoscape.model.subnetwork.CyRootNetwork)86 CyNetwork (org.cytoscape.model.CyNetwork)39 CySubNetwork (org.cytoscape.model.subnetwork.CySubNetwork)38 CyNode (org.cytoscape.model.CyNode)29 CyEdge (org.cytoscape.model.CyEdge)15 CyRow (org.cytoscape.model.CyRow)15 CyRootNetworkManager (org.cytoscape.model.subnetwork.CyRootNetworkManager)15 Test (org.junit.Test)14 ArrayList (java.util.ArrayList)13 CyTable (org.cytoscape.model.CyTable)11 CyNetworkView (org.cytoscape.view.model.CyNetworkView)11 CyGroup (org.cytoscape.group.CyGroup)7 HashSet (java.util.HashSet)6 Dimension (java.awt.Dimension)4 IOException (java.io.IOException)4 CyNetworkManager (org.cytoscape.model.CyNetworkManager)4 Image (java.awt.Image)3 BufferedImage (java.awt.image.BufferedImage)3 CyApplicationManager (org.cytoscape.application.CyApplicationManager)3 CyEventHelper (org.cytoscape.event.CyEventHelper)3