@Override protected void complete(TaskMonitor tm) throws Exception { tm.setProgress(0.4); tm.setTitle("Set network tables"); tm.setStatusMessage("Setting network tables..."); mergeNetworkTables(); tm.setProgress(0.5); tm.setTitle("Restore virtual columns"); tm.setStatusMessage("Restoring virtual columns..."); restoreVirtualColumns(); tm.setProgress(0.6); tm.setTitle("Extract network views"); tm.setStatusMessage("Extracting network views..."); // Read the session file again, this time to extract the network views networksExtracted = true; readSessionFile(tm); tm.setProgress(0.8); tm.setTitle("Update SUID columns"); tm.setStatusMessage("Updating SUID columns..."); updateSUIDColumns(); super.complete(tm); }
@Override public void run(TaskMonitor taskMonitor) { taskMonitor.setProgress(0.0); taskMonitor.setTitle("PRWP with Priors ranking of clusters"); taskMonitor.showMessage(TaskMonitor.Level.INFO, "Fetching clusters..."); taskMonitor.setProgress(0.1); List<NodeCluster> clusters = ClusterUtils.fetchClusters(network); taskMonitor.setProgress(0.5); initVariables(); clusters.forEach(NodeCluster::initNodeScores); taskMonitor.showMessage(TaskMonitor.Level.INFO, "Setting node scores in clusters"); addNodes(); taskMonitor.setProgress(0.6); taskMonitor.showMessage(TaskMonitor.Level.INFO, "Setting edge scores in clusters"); addEdges(); taskMonitor.setProgress(0.7); taskMonitor.showMessage(TaskMonitor.Level.INFO, "Calculating PageRank scores"); PageRank<PRNode, PREdge> pageRank = performPageRank(); taskMonitor.setProgress(0.8); taskMonitor.showMessage(TaskMonitor.Level.INFO, "Inserting scores into clusters"); insertScores(clusters, pageRank); taskMonitor.setProgress(0.9); taskMonitor.showMessage(TaskMonitor.Level.INFO, "Insert cluster information in tables"); ClusterUtils.insertResultsInColumns(network, clusters, SHORTNAME); taskMonitor.setProgress(1.0); taskMonitor.showMessage(TaskMonitor.Level.INFO, "Done..."); }
@Override public void run(TaskMonitor monitor) throws Exception { // TODO Auto-generated method stub monitor.setTitle("Building the User Interface"); DynNetworkView<T> view = dynNetViewManager.getDynNetworkView(cyNetworkView); DynNetwork<T> dynamicnetwork = view.getNetwork(); GraphMetricsPanel<T, C> graphMetricsPanel = new GraphMetricsPanel<T, C>(this.cyActivator, dynamicnetwork); this.cyActivator .getCyServiceRegistrar() .registerService(graphMetricsPanel, CytoPanelComponent.class, new Properties()); }
@Override public void run(TaskMonitor taskMonitor) throws Exception { taskMonitor.setTitle("Loading Gene Association File"); taskMonitor.setStatusMessage("Importing annotation file. Please wait..."); taskMonitor.setProgress(-1.0); this.ontologyDAG = OntologyDAGManager.getOntologyDAG(ontologyDagName); if (ontologyDAG == null) logger.warn("Could not find associated Ontology DAG."); else { termIDList = ontologyDAG.getDefaultNodeTable().getColumn(CyNetwork.NAME).getValues(String.class); } BufferedReader bufRd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8").newDecoder())); String line = null; String[] parts; while ((line = bufRd.readLine()) != null) { // Validate. if (line.contains(COMPATIBLE_VERSION)) break; } // Create result table table = serviceRegistrar .getService(CyTableFactory.class) .createTable(tableName, CyNetwork.NAME, String.class, true, true); createColumns(); while ((line = bufRd.readLine()) != null) { if (line.startsWith("!")) continue; parts = line.split(GA_DELIMITER); // GA is a fixed format file. Read only valid lines. if (parts.length >= EXPECTED_COL_COUNT) { parseGA(parts); } } bufRd.close(); is.close(); is = null; tables = new CyTable[1]; tables[0] = table; serviceRegistrar.getService(CyTableManager.class).addTable(table); }
@Override public void run(TaskMonitor tm) throws Exception { tm.setTitle("Loading network from table"); tm.setProgress(0.0); tm.setStatusMessage("Loading network..."); Workbook workbook = null; // Load Spreadsheet data for preview. if (fileType != null && (fileType.equalsIgnoreCase(SupportedFileType.EXCEL.getExtension()) || fileType.equalsIgnoreCase(SupportedFileType.OOXML.getExtension())) && workbook == null) { try { workbook = WorkbookFactory.create(is); } catch (InvalidFormatException e) { throw new IllegalArgumentException( "Could not read Excel file. Maybe the file is broken?", e); } finally { if (is != null) is.close(); } } try { if (this.fileType.equalsIgnoreCase(SupportedFileType.EXCEL.getExtension()) || this.fileType.equalsIgnoreCase(SupportedFileType.OOXML.getExtension())) { String networkName = ntmp.getName(); if (networkName == null) networkName = workbook.getSheetName(0); final Sheet sheet = workbook.getSheet(networkName); reader = new ExcelNetworkSheetReader( networkName, sheet, ntmp, nMap, rootNetwork, serviceRegistrar); } else { reader = new NetworkTableReader(inputName, is, ntmp, nMap, rootNetwork, serviceRegistrar); } } catch (Exception ioe) { tm.showMessage(TaskMonitor.Level.ERROR, "Unable to read table: " + ioe.getMessage()); return; } loadNetwork(tm); tm.setProgress(1.0); }
@Override public void run(TaskMonitor taskMonitor) throws Exception { taskMonitor.setTitle("Updating Organism Interactome Data Files"); taskMonitor.setProgress(-1); taskMonitor.setStatusMessage("Downloading data from BioGRID..."); BiogridDataLoader task = new BiogridDataLoader(props, dataSource, settingFileLocation); task.extract(true); final String version = task.getVersion(); taskMonitor.setProgress(1.0d); taskMonitor.setStatusMessage( "Organism network data files has been updated to BioGRID version " + version + ". Please restart Cytoscape to use new data."); }
/** Executes Task. */ public void run(TaskMonitor taskMonitor) throws Exception { taskMonitor.setTitle("Loading Network"); taskMonitor.setProgress(0); taskMonitor.setStatusMessage("Reading in Network Data..."); try { CyNetworkReaderManager readerManager = factory.getCyNetworkViewReaderManager(); CyNetworkReader reader = readerManager.getReader(url.toURI(), url.getFile()); if (reader == null) { JOptionPane.showMessageDialog( factory.getCySwingApplication().getJFrame(), "Unable to connect to URL " + url, "URL Connect Error", JOptionPane.ERROR_MESSAGE); return; } taskMonitor.setStatusMessage("Creating Cytoscape Network..."); reader.run(taskMonitor); CyNetwork[] networks = reader.getNetworks(); CyNetwork cyNetwork = networks[0]; // TODO: Does CPath2 listen for this? // Object[] ret_val = new Object[2]; // ret_val[0] = cyNetwork; // ret_val[1] = url.toString(); // // Cytoscape.firePropertyChange(Cytoscape.NETWORK_LOADED, null, ret_val); if (cyNetwork != null) { informUserOfGraphStats(cyNetwork, taskMonitor); } else { StringBuffer sb = new StringBuffer(); sb.append("Could not read network from: "); sb.append(url); sb.append("\nThis file may not be a valid file format."); throw new IOException(sb.toString()); } taskMonitor.setProgress(1.0); } catch (Exception e) { throw new Exception("Unable to load network.", e); } }
@Override public void run(TaskMonitor taskMonitor) throws Exception { parentTaskMonitor = taskMonitor; long start = System.currentTimeMillis(); taskMonitor.setProgress(0.01d); taskMonitor.setTitle("Loading PSI-MI 2.5.x XML File "); taskMonitor.setStatusMessage("Loading data file in PSI-MI 2.5 XML format."); // support to add network into existing collection this.initNodeMap(); PsimiXmlReader reader = new PsimiXmlReader(); EntrySet result = reader.read(inputStream); taskMonitor.setProgress(0.4d); taskMonitor.setStatusMessage("Data Loaded. Mapping Data to Network..."); if (cancelFlag) { inputStream.close(); reader = null; result = null; return; } // network = cyNetworkFactory.createNetwork(); String networkCollectionName = this.rootNetworkList.getSelectedValue().toString(); if (networkCollectionName.equalsIgnoreCase(CRERATE_NEW_COLLECTION_STRING)) { // This is a new network collection, create a root network and a subnetwork, which is a base // subnetwork network = cyNetworkFactory.createNetwork(); } else { // Add a new subNetwork to the given collection network = this.name2RootMap.get(networkCollectionName).addSubNetwork(); } mapper = new PSIMI25EntryMapper(network, result); mapper.map(); taskMonitor.setProgress(1.0d); logger.info( "PSI-MI XML Data Import finihsed in " + (System.currentTimeMillis() - start) + " msec."); }
@Override public void run(final TaskMonitor taskMonitor) { taskMonitor.setTitle("Adding variations..."); taskMonitor.setProgress(0.0d); if (!mergeStrategy.isRetain()) { final Lock nodesReadLock = model.nodes().getReadWriteLock().readLock(); final Lock featuresReadLock = model.features().getReadWriteLock().readLock(); final Lock variationsWriteLock = model.variations().getReadWriteLock().writeLock(); nodesReadLock.lock(); featuresReadLock.lock(); variationsWriteLock.lock(); try { for (int i = 0, size = model.features().size(); i < size; i++) { Feature feature = model.features().get(i); taskMonitor.setStatusMessage( "Retrieving variations associated with feature " + feature + "..."); final List<Variation> variations = model.getVariationService().variations(feature); taskMonitor.setStatusMessage( resultStatusMessage(variations.size(), "variation", "feature", feature)); // todo: merge strategy for (Variation variation : variations) { if (!model.variations().contains(variation)) { model.variations().add(variation); } } // todo: count doesn't consider existing variations for (CyNode node : model.nodesFor(feature)) { addCount(node, model.getNetwork(), "variation_count", variations.size()); } taskMonitor.setProgress(i / (double) size); } } finally { nodesReadLock.unlock(); featuresReadLock.unlock(); variationsWriteLock.unlock(); } } taskMonitor.setProgress(1.0d); }
public void run(TaskMonitor taskMonitor) throws Exception { taskMonitor.setTitle("Exiting Chimera"); structureManager.exitChimera(); }
@Override public void run(TaskMonitor taskMonitor) throws Exception { desktopApp.getJFrame().getGlassPane().setVisible(true); taskMonitor.setTitle("Gene Set / Mutation Analysis"); taskMonitor.setStatusMessage("Loading file..."); taskMonitor.setProgress(.25d); try { Map<String, Integer> geneToSampleNumber = null; Map<String, String> geneToSampleString = null; Map<String, Set<String>> sampleToGenes = null; Set<String> selectedGenes = null; if (format.equals("MAF")) { sampleToGenes = new MATFileLoader().loadSampleToGenes(file.getAbsolutePath(), chooseHomoGenes); selectedGenes = CancerAnalysisUtilitites.selectGenesInSamples(sampleCutoffValue, sampleToGenes); } else if (format.equals("GeneSample")) { geneToSampleNumber = new HashMap<String, Integer>(); geneToSampleString = new HashMap<String, String>(); loadGeneSampleFile(file, geneToSampleNumber, geneToSampleString); selectedGenes = selectGenesBasedOnSampleCutoff(geneToSampleNumber, sampleCutoffValue); } else if (format.equals("GeneSet")) { selectedGenes = loadGeneSetFile(file); } // Check if it is possible to construct the network // given the sample size. if (useLinkers) { taskMonitor.setStatusMessage("Checking FI Network size..."); FINetworkService fiService = PlugInScopeObjectManager.getManager().getNetworkService(); Integer cutoff = fiService.getNetworkBuildSizeCutoff(); if (cutoff != null && selectedGenes.size() >= cutoff) { JOptionPane.showMessageDialog( desktopApp.getJFrame(), "The size of the gene set is too big. Linker genes should not be used!\n" + "Please try again without using linker genes.", "Error in Building Network", JOptionPane.ERROR_MESSAGE); desktopApp.getJFrame().getGlassPane().setVisible(false); return; } } CytoPanel controlPane = desktopApp.getCytoPanel(CytoPanelName.WEST); int selectedIndex = controlPane.getSelectedIndex(); taskMonitor.setStatusMessage("Constructing FI Network..."); taskMonitor.setProgress(.50d); CyNetwork network = constructFINetwork(selectedGenes, file.getName()); network.getDefaultNetworkTable().getRow(network.getSUID()).set("name", file.getName()); if (network == null) { JOptionPane.showMessageDialog( desktopApp.getJFrame(), "Cannot find any functional interaction among provided genes.\n" + "No network can be constructed.\n" + "Note: only human gene names are supported.", "Empty Network", JOptionPane.INFORMATION_MESSAGE); desktopApp.getJFrame().getGlassPane().setVisible(false); return; } netManager.addNetwork(network); // Fix for missing default value persistence in CyTables // Should be remedied in the 3.1 api CyTable nodeTable = network.getDefaultNodeTable(); for (Object name : network.getNodeList()) { CyNode node = (CyNode) name; Long nodeSUID = node.getSUID(); nodeTable.getRow(nodeSUID).set("isLinker", false); } controlPane.setSelectedIndex(selectedIndex); if (sampleToGenes != null) { geneToSampleNumber = new HashMap<String, Integer>(); geneToSampleString = new HashMap<String, String>(); Map<String, Set<String>> geneToSamples = InteractionUtilities.switchKeyValues(sampleToGenes); geneToSamples.keySet().retainAll(selectedGenes); for (String gene : geneToSamples.keySet()) { Set<String> samples = geneToSamples.get(gene); geneToSampleNumber.put(gene, samples.size()); geneToSampleString.put(gene, InteractionUtilities.joinStringElements(";", samples)); } } taskMonitor.setStatusMessage("Formatting network attributes..."); taskMonitor.setProgress(.65d); CyTableManager tableManager = new CyTableManager(); CyNetworkView view = viewFactory.createNetworkView(network); tableManager.storeFINetworkVersion(view); tableManager.storeDataSetType(network, CyTableFormatter.getSampleMutationData()); viewManager.addNetworkView(view); if (geneToSampleNumber != null && !geneToSampleNumber.isEmpty()) { tableManager.loadNodeAttributesByName(view, "sampleNumber", geneToSampleNumber); } if (geneToSampleString != null && !geneToSampleString.isEmpty()) { tableManager.loadNodeAttributesByName(view, "samples", geneToSampleString); } // Check if linker genes are to be used. if (useLinkers) { taskMonitor.setStatusMessage("Fetching linker genes..."); Map<String, Boolean> geneToIsLinker = new HashMap<String, Boolean>(); for (Object name : network.getNodeList()) { CyNode node = (CyNode) name; Long suid = node.getSUID(); String nodeName = network.getDefaultNodeTable().getRow(suid).get("name", String.class); geneToIsLinker.put(nodeName, !selectedGenes.contains(nodeName)); } tableManager.loadNodeAttributesByName(view, "isLinker", geneToIsLinker); } if (fetchFIAnnotations) { taskMonitor.setStatusMessage("Fetching FI annotations..."); new FIAnnotationHelper().annotateFIs(view, new RESTFulFIService(), tableManager); } if (view.getModel().getEdgeCount() != 0) { for (CyEdge edge : view.getModel().getEdgeList()) { tableManager.storeEdgeName(edge, view); } } BundleContext context = PlugInScopeObjectManager.getManager().getBundleContext(); ServiceReference visHelperRef = context.getServiceReference(FIVisualStyle.class.getName()); if (visHelperRef != null) { FIVisualStyleImpl styleHelper = (FIVisualStyleImpl) context.getService(visHelperRef); styleHelper.setVisualStyle(view); styleHelper.setLayout(); } // BundleContext context = // PlugInScopeObjectManager.getManager().getBundleContext(); // ServiceReference styleHelperRef = // context.getServiceReference(FIVisualStyleImpl.class.getName()); // FIVisualStyleImpl styleHelper = (FIVisualStyleImpl) // context.getService(styleHelperRef); taskMonitor.setProgress(1.0d); } catch (Exception e) { JOptionPane.showMessageDialog( desktopApp.getJFrame(), "Error in Loading File: " + e.getMessage(), "Error in Loading", JOptionPane.ERROR_MESSAGE); desktopApp.getJFrame().getGlassPane().setVisible(false); } desktopApp.getJFrame().getGlassPane().setVisible(false); }
@SuppressWarnings("unchecked") @Override protected void doLayout(TaskMonitor taskMonitor) { if (!context.m_cancel && networkView != null && dynView != null) { taskMonitor.setTitle("Compute Dynamic Kamada Kawai Force Layout"); taskMonitor.setStatusMessage("Running energy minimization..."); taskMonitor.setProgress(0); // int size = (int) (4*50*Math.sqrt(nodesToLayOut.size())); int size = (int) (dynView.getCurrentVisualStyle().getDefaultValue(BasicVisualLexicon.NODE_SIZE) * Math.sqrt(nodesToLayOut.size())); // int size =(int) // dynView.getCurrentVisualStyle().getDefaultValue(BasicVisualLexicon.NETWORK_HEIGHT).floatValue(); snap = new DynNetworkSnapshotImpl<T>(dynView, context.m_attribute_name); kklayout = new KKLayout<T>(snap, new Dimension(4 * size, 4 * size)); List<Double> events = context.m_event_list; // Full KK evaluation to initialize the network at time t=0 kklayout.setAdjustForGravity(true); kklayout.setExchangeVertices(context.m_exchange_nodes); kklayout.setAutoscaling(context.m_autoscale); kklayout.setMaxIterations(1000); // Compute incremental KK. The number of iterations is proportional to the time to the next // event. double t0, t1; for (int t = 0; t < events.size() - 1; t++) { t0 = events.get(Math.max(0, t - context.m_past_events)); t1 = events.get(Math.min(events.size() - 1, t + 1 + context.m_future_events)); snap.setInterval((DynInterval<T>) new DynIntervalDouble(t0, t1), t, 1000, 1000); if (!context.m_attribute_name.equals("none")) kklayout.setDistance(new DijkstraShortestPath<T>(snap, snap.getWeightMap(), 100)); else kklayout.setDistance(new UnweightedShortestPath<T>(snap)); kklayout.initialize(); kklayout.run(); updateGraph((DynInterval<T>) new DynIntervalDouble(events.get(t), events.get(t + 1))); kklayout.setMaxIterations( (int) (context.m_iteration_rate * (events.get(t + 1) - events.get(t)))); if (t % 10 == 0) taskMonitor.setProgress(((double) t) / (double) events.size()); taskMonitor.setStatusMessage("Running energy minimization... " + t + "/" + events.size()); } // Finalize layout layout.finalize(); taskMonitor.setProgress(1); // Set the current network view initializePositions(size); layout.initNodePositions(timeInterval); view.fitContent(); view.updateView(); } }
public void run(TaskMonitor monitor) { monitor.setTitle("Performing MCL cluster"); this.monitor = monitor; if (network == null) network = clusterManager.getNetwork(); context.setNetwork(network); NodeCluster.init(); DistanceMatrix matrix = context.edgeAttributeHandler.getMatrix(); if (matrix == null) { monitor.showMessage( TaskMonitor.Level.ERROR, "Can't get distance matrix: no attribute value?"); return; } // Update our tunable results clusterAttributeName = context.getClusterAttribute(); createGroups = context.advancedAttributes.createGroups; if (canceled) return; // Cluster the nodes runMCL = new RunMCL( matrix, context.inflation_parameter, context.iterations, context.clusteringThresh, context.maxResidual, context.maxThreads, monitor); runMCL.setDebug(debug); if (canceled) return; monitor.showMessage(TaskMonitor.Level.INFO, "Clustering..."); // results = runMCL.run(monitor); List<NodeCluster> clusters = runMCL.run(network, monitor); if (clusters == null) return; // Canceled? monitor.showMessage(TaskMonitor.Level.INFO, "Removing groups"); // Remove any leftover groups from previous runs removeGroups(network, GROUP_ATTRIBUTE); monitor.showMessage(TaskMonitor.Level.INFO, "Creating groups"); params = new ArrayList<String>(); context.edgeAttributeHandler.setParams(params); List<List<CyNode>> nodeClusters = createGroups(network, clusters, GROUP_ATTRIBUTE); results = new AbstractClusterResults(network, nodeClusters); monitor.showMessage(TaskMonitor.Level.INFO, "MCL results:\n" + results); if (context.vizProperties.showUI) { monitor.showMessage(TaskMonitor.Level.INFO, "Creating network"); insertTasksAfterCurrentTask( new NewNetworkView(network, clusterManager, true, context.vizProperties.restoreEdges)); } }