Search in sources :

Example 6 with CyNetworkReader

use of org.cytoscape.io.read.CyNetworkReader in project cytoscape-impl by cytoscape.

the class LoadNetworkURLTaskFactoryImpl method loadCyNetworks.

@Override
public TaskIterator loadCyNetworks(final URL url) {
    // Code adapted from LoadNetworkURLTask
    // TODO: Refactor to avoid duplication of code
    final String urlString = url.getFile();
    final String[] parts = urlString.split("/");
    final String name = parts[parts.length - 1];
    CyNetworkReader reader = null;
    try {
        reader = serviceRegistrar.getService(CyNetworkReaderManager.class).getReader(url.toURI(), url.toURI().toString());
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
    return new TaskIterator(2, new LoadNetworkTask(reader, name, serviceRegistrar));
}
Also used : TaskIterator(org.cytoscape.work.TaskIterator) CyNetworkReader(org.cytoscape.io.read.CyNetworkReader) URISyntaxException(java.net.URISyntaxException)

Example 7 with CyNetworkReader

use of org.cytoscape.io.read.CyNetworkReader 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)

Aggregations

CyNetworkReader (org.cytoscape.io.read.CyNetworkReader)7 CyNetwork (org.cytoscape.model.CyNetwork)3 CyNetworkView (org.cytoscape.view.model.CyNetworkView)2 TaskIterator (org.cytoscape.work.TaskIterator)2 URISyntaxException (java.net.URISyntaxException)1 Matcher (java.util.regex.Matcher)1 NetworkViewRenderer (org.cytoscape.application.NetworkViewRenderer)1 SessionXGMMLNetworkReader (org.cytoscape.io.internal.read.xgmml.SessionXGMMLNetworkReader)1 SessionXGMMLNetworkViewReader (org.cytoscape.io.internal.read.xgmml.SessionXGMMLNetworkViewReader)1 Edge (org.cytoscape.io.internal.util.session.model.Edge)1 Node (org.cytoscape.io.internal.util.session.model.Node)1 AbstractCyNetworkReader (org.cytoscape.io.read.AbstractCyNetworkReader)1 CyNetworkReaderManager (org.cytoscape.io.read.CyNetworkReaderManager)1 CyEdge (org.cytoscape.model.CyEdge)1 CyNode (org.cytoscape.model.CyNode)1 CyRow (org.cytoscape.model.CyRow)1 CyTable (org.cytoscape.model.CyTable)1 CyRootNetwork (org.cytoscape.model.subnetwork.CyRootNetwork)1 CyRootNetworkManager (org.cytoscape.model.subnetwork.CyRootNetworkManager)1 CySubNetwork (org.cytoscape.model.subnetwork.CySubNetwork)1