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));
}
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);
}
}
Aggregations