当前位置: 首页>>代码示例>>Java>>正文


Java CyNetwork.getDefaultNodeTable方法代码示例

本文整理汇总了Java中org.cytoscape.model.CyNetwork.getDefaultNodeTable方法的典型用法代码示例。如果您正苦于以下问题:Java CyNetwork.getDefaultNodeTable方法的具体用法?Java CyNetwork.getDefaultNodeTable怎么用?Java CyNetwork.getDefaultNodeTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.cytoscape.model.CyNetwork的用法示例。


在下文中一共展示了CyNetwork.getDefaultNodeTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateColumnList

import org.cytoscape.model.CyNetwork; //导入方法依赖的package包/类
void updateColumnList(SafeSession session) {
    lastAnnotationPath = null;
    this.session = session;

    nodeIdsModel.removeAllElements();

    if (session == null) {
        return;
    }

    CyNetworkView view = session.getNetworkView();
    CyNetwork model = view.getModel();
    CyTable table = model.getDefaultNodeTable();
    SafeUtil.getStringColumnNames(table)
            .forEach(name -> {
                nodeIdsModel.addElement(name);
            });

    nodeIds.setSelectedItem(session.getIdColumn());
}
 
开发者ID:baryshnikova-lab,项目名称:safe-java,代码行数:21,代码来源:AnnotationChooserController.java

示例2: setNetworkView

import org.cytoscape.model.CyNetwork; //导入方法依赖的package包/类
void setNetworkView(CyNetworkView view) {
    if (view == null) {
        setSession(null);
        return;
    }

    long suid = view.getSUID();
    synchronized (sessionMutex) {
        SafeSession session = sessionsBySuid.get(suid);
        if (session == null) {
            session = createNewSession(view);
            sessionsBySuid.put(suid, session);

            CyNetwork network = view.getModel();
            CyTable nodeTable = network.getDefaultNodeTable();
            sessionsBySuid.put(nodeTable.getSUID(), session);
        }
        setSession(session);
    }
}
 
开发者ID:baryshnikova-lab,项目名称:safe-java,代码行数:21,代码来源:SafeController.java

示例3: setEnrichmentLandscape

import org.cytoscape.model.CyNetwork; //导入方法依赖的package包/类
void setEnrichmentLandscape(EnrichmentLandscape landscape) {
    if (session == null) {
        notifyListeners();
        return;
    }

    isEnabled = true;

    Long[] nodeMappings = session.getNodeMappings();
    if (nodeMappings == null) {
        notifyListeners();
        return;
    }

    CyNetworkView view = session.getNetworkView();
    CyNetwork network = view.getModel();
    CyTable nodeTable = network.getDefaultNodeTable();
    nodeTableId = nodeTable.getSUID();

    Arrays.stream(nodeMappings)
          .forEach(suid -> {
              CyRow row = nodeTable.getRow(suid);
              boolean selected = row.get(CyNetwork.SELECTED, Boolean.class);
              if (selected) {
                  nodeSuids.add(suid);
              }
          });

    notifyListeners();
}
 
开发者ID:baryshnikova-lab,项目名称:safe-java,代码行数:31,代码来源:SelectionTracker.java

示例4: selectSignificantNodes

import org.cytoscape.model.CyNetwork; //导入方法依赖的package包/类
private void selectSignificantNodes() {
    SignificancePredicate predicate = getSignificancePredicate();
    int[] rows = filteredTable.getTable()
                              .getSelectedRows();
    TableRowSorter<TableModel> sorter = filteredTable.getSorter();
    Long[] nodeMappings = session.getNodeMappings();

    CyNetworkView view = session.getNetworkView();
    CyNetwork network = view.getModel();
    CyTable nodeTable = network.getDefaultNodeTable();
    CyTable edgeTable = network.getDefaultEdgeTable();

    SafeUtil.clearSelection(nodeTable);
    SafeUtil.clearSelection(edgeTable);

    EnrichmentLandscape landscape = session.getEnrichmentLandscape();
    List<? extends Neighborhood> neighborhoods = landscape.getNeighborhoods();
    neighborhoods.stream()
                 .forEach(n -> {
                     boolean include = Arrays.stream(rows)
                                             .map(i -> sorter.convertRowIndexToModel(i))
                                             .filter(i -> predicate.test(n, i))
                                             .findAny()
                                             .isPresent();

                     Long suid = nodeMappings[n.getNodeIndex()];
                     CyRow row = nodeTable.getRow(suid);
                     row.set(CyNetwork.SELECTED, include);
                 });
}
 
开发者ID:baryshnikova-lab,项目名称:safe-java,代码行数:31,代码来源:AttributeBrowserController.java

示例5: checkIdCoverage

import org.cytoscape.model.CyNetwork; //导入方法依赖的package包/类
void checkIdCoverage(File file) throws IOException {
    CyNetworkView view = session.getNetworkView();
    CyNetwork network = view.getModel();
    CyTable nodeTable = network.getDefaultNodeTable();

    List<String> names = SafeUtil.getStringColumnNames(nodeTable)
                                 .collect(Collectors.toList());
    CyNodeTableVisitor visitor = new CyNodeTableVisitor(nodeTable, names);

    String path = file.getPath();
    AnalyzeAnnotationConsumer consumer = new AnalyzeAnnotationConsumer() {
        @Override
        public void accept(IdMappingResult result) {
            idMappingResult = result;
            IntIntMap coverage = result.coverage;
            int topIndex = Util.getTopKey(coverage, -1);

            columnCoverage = new ObjectIntHashMap<>();
            coverage.forEach((Consumer<? super IntIntCursor>) c -> columnCoverage.addTo(names.get(c.key), c.value));

            nodeIds.setSelectedIndex(topIndex);

            try {
                String canonicalPath = file.getCanonicalPath();
                lastAnnotationPath = canonicalPath;
                notifyListeners(file);
            } catch (IOException e) {
                fail(e, "Unexpected error");
            }
        }
    };

    SimpleTaskFactory taskFactory = new SimpleTaskFactory(() -> new AnalyzeAnnotationTask(path, visitor, consumer));
    taskManager.execute(taskFactory.createTaskIterator());
}
 
开发者ID:baryshnikova-lab,项目名称:safe-java,代码行数:36,代码来源:AnnotationChooserController.java

示例6: handleEvent

import org.cytoscape.model.CyNetwork; //导入方法依赖的package包/类
@Override
public void handleEvent(NetworkViewAboutToBeDestroyedEvent event) {
    synchronized (sessionMutex) {
        CyNetworkView view = event.getNetworkView();
        CyNetwork network = view.getModel();
        CyTable nodeTable = network.getDefaultNodeTable();
        sessionsBySuid.remove(nodeTable.getSUID());

        long suid = view.getSUID();
        SafeSession session = sessionsBySuid.remove(suid);
        if (session != null && this.session == session) {
            setSession(null);
        }
    }
}
 
开发者ID:baryshnikova-lab,项目名称:safe-java,代码行数:16,代码来源:SafeController.java

示例7: BaseExportReportsTask

import org.cytoscape.model.CyNetwork; //导入方法依赖的package包/类
public BaseExportReportsTask(SafeSession session) {

        CyNetworkView view = session.getNetworkView();
        CyNetwork network = view.getModel();
        nodeTable = network.getDefaultNodeTable();
        List<String> names = SafeUtil.getStringColumnNames(nodeTable)
                                     .collect(Collectors.toList());
        nodeNameColumn = new ListSingleSelection<>(names);

        nodeNameColumn.setSelectedValue(CyNetwork.NAME);

        this.session = session;
    }
 
开发者ID:baryshnikova-lab,项目名称:safe-java,代码行数:14,代码来源:BaseExportReportsTask.java

示例8: getColumnsOfType

import org.cytoscape.model.CyNetwork; //导入方法依赖的package包/类
public static List<String> getColumnsOfType(CyNetwork network, Class<?> type, boolean node, boolean addNone, boolean allowList) {
	List<String> columns = new LinkedList<>();
	
	CyTable table;
	if(node)
		table = network.getDefaultNodeTable();
	else 
		table = network.getDefaultEdgeTable();
	
	for(CyColumn column : table.getColumns()) {
		if(column.getName().equalsIgnoreCase("suid")) {
			continue;
		}
		
		if(type.isAssignableFrom(column.getType())) {
			columns.add(column.getName());
		}
		else if(allowList && List.class.equals(column.getType()) && type.isAssignableFrom(column.getListElementType())) {
			columns.add(column.getName());
		}
	}
	
	columns.sort(Comparator.naturalOrder());
	if(addNone) {
		columns.add(0, NONE);
	}
	return columns;
}
 
开发者ID:BaderLab,项目名称:AutoAnnotateApp,代码行数:29,代码来源:CreateAnnotationSetDialog.java

示例9: aggregateAttributes

import org.cytoscape.model.CyNetwork; //导入方法依赖的package包/类
private void aggregateAttributes(CyNetwork originNetwork, SummaryNetwork summaryNetwork) {
	CyTable originNodeTable = originNetwork.getDefaultNodeTable();
	
	CyTable summaryNodeTable = summaryNetwork.network.getDefaultNodeTable();
	summaryNodeTable.createColumn("cluster node count", Integer.class, false);
	
	List<String> columnsToAggregate = new ArrayList<>();
	for(CyColumn column : originNodeTable.getColumns()) {
		String name = column.getName();
		if(summaryNodeTable.getColumn(name) == null) {
			columnsToAggregate.add(name);
			Class<?> listElementType = column.getListElementType();
			if(listElementType == null) {
				summaryNodeTable.createColumn(name, column.getType(), false);
			}
			else {
				summaryNodeTable.createListColumn(name, listElementType, false);
			}
		}
	}
	
	for(SummaryCluster cluster : summaryNetwork.getClusters()) {
		CyNode summaryNode = summaryNetwork.getNodeFor(cluster);
		CyRow row = summaryNodeTable.getRow(summaryNode.getSUID());
		
		row.set("name", cluster.getLabel());
		row.set("cluster node count", cluster.getNodes().size());
		
		for(String columnName : columnsToAggregate) {
			Object result = aggregate(originNetwork, cluster, columnName);
			row.set(columnName, result);
		}
	}
}
 
开发者ID:BaderLab,项目名称:AutoAnnotateApp,代码行数:35,代码来源:SummaryNetworkTask.java

示例10: createTaskIterator

import org.cytoscape.model.CyNetwork; //导入方法依赖的package包/类
@Override
public TaskIterator createTaskIterator() {
	final String tempColumn = UUID.randomUUID().toString();
	CyNetwork network = annotationSet.getParent().getNetwork();
	CyTable nodeTable = network.getDefaultNodeTable();
	
	// Create a temp column of cluster identifiers
	Task createTempColumnTask = TaskTools.taskOf(() -> {
		nodeTable.createColumn(tempColumn, Integer.class, false);
		int i = 0;
		for(Cluster cluster: annotationSet.getClusters()) {
			for(CyNode node : cluster.getNodes()) {
				network.getRow(node).set(tempColumn, i);
			}
			i++;
		}
	});
	
	// Layout the clusters
	Collection<Collection<CyNode>> clusters = annotationSet.getClusters().stream().map(Cluster::getNodes).collect(Collectors.toSet());
	LayoutClustersTaskFactory layoutTaskFactory = layoutTaskFactoryFactory.create(clusters, annotationSet.getParent().getNetworkView(), tempColumn);
	TaskIterator layoutTasks = layoutTaskFactory.createTaskIterator();
	
	// Delete the temp column
	Task deleteTempColumnTask = TaskTools.taskOf(() -> {
		nodeTable.deleteColumn(tempColumn);
	});
	
	
	TaskIterator tasks = new TaskIterator();
	tasks.append(TaskTools.taskMessage("Layout '" + annotationSet.getName() + "'"));
	tasks.append(createTempColumnTask);
	tasks.append(layoutTasks);
	tasks.append(deleteTempColumnTask);
	return tasks;
}
 
开发者ID:BaderLab,项目名称:AutoAnnotateApp,代码行数:37,代码来源:LayoutAnnotationSetTaskFactory.java

示例11: updateSelectedAttributes

import org.cytoscape.model.CyNetwork; //导入方法依赖的package包/类
void updateSelectedAttributes(TableRowSorter<TableModel> sorter,
                              int[] rows,
                              boolean forceUpdate) {

    if (!forceUpdate && (!allowUpdates || sorter.getViewRowCount() == 0)) {
        return;
    }

    ScoringFunction scoringFunction = getScoringFunction();
    if (scoringFunction == null) {
        return;
    }

    Long[] nodeMappings = session.getNodeMappings();

    CyNetworkView view = session.getNetworkView();
    CyNetwork network = view.getModel();
    CyTable nodeTable = network.getDefaultNodeTable();

    SafeUtil.checkSafeColumns(nodeTable);

    statusLabel.setVisible(true);
    panel.setOpaque(true);

    Runnable action = () -> {
        EnrichmentLandscape landscape = session.getEnrichmentLandscape();
        List<? extends Neighborhood> neighborhoods = landscape.getNeighborhoods();
        neighborhoods.stream()
                     .forEach(n -> {
                         double score = Arrays.stream(rows)
                                              .map(i -> sorter.convertRowIndexToModel(i))
                                              .mapToDouble(i -> scoringFunction.get(n, i))
                                              .reduce(0, (x,
                                                          y) -> Math.abs(x) > Math.abs(y) ? x : y);

                         if (!Double.isFinite(score)) {
                             score = 0;
                         }

                         // Round to 4 places
                         score = Math.round(score * 10000.0) / 10000.0;

                         Long suid = nodeMappings[n.getNodeIndex()];
                         CyRow row = nodeTable.getRow(suid);
                         row.set(StyleFactory.HIGHLIGHT_COLUMN, score);

                         double brightness = Math.abs(score);
                         row.set(StyleFactory.BRIGHTNESSS_COLUMN, brightness);

                         row.set(StyleFactory.COLOR_COLUMN, null);
                     });

        setAttributeBrowserStyle(view);
    };

    SwingUtilities.invokeLater(action);
}
 
开发者ID:baryshnikova-lab,项目名称:safe-java,代码行数:58,代码来源:AttributeBrowserController.java

示例12: selectSignificantNodes

import org.cytoscape.model.CyNetwork; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void selectSignificantNodes() {
    NameValuePair<Integer> analysisType = (NameValuePair<Integer>) analysisTypes.getSelectedItem();
    int typeIndex = analysisType.getValue();

    EnrichmentLandscape landscape = session.getEnrichmentLandscape();
    AnnotationProvider annotationProvider = landscape.getAnnotationProvider();
    int totalAttributes = annotationProvider.getAttributeCount();
    SignificancePredicate isSignificant = Neighborhood.getSignificancePredicate(typeIndex, totalAttributes);
    CompositeMap compositeMap = session.getCompositeMap();

    int[] rows = filteredTable.getTable()
                              .getSelectedRows();
    TableRowSorter<TableModel> sorter = filteredTable.getSorter();
    Long[] nodeMappings = session.getNodeMappings();

    CyNetworkView view = session.getNetworkView();
    CyNetwork network = view.getModel();
    CyTable nodeTable = network.getDefaultNodeTable();
    CyTable edgeTable = network.getDefaultEdgeTable();

    SafeUtil.clearSelection(nodeTable);
    SafeUtil.clearSelection(edgeTable);

    List<? extends Neighborhood> neighborhoods = landscape.getNeighborhoods();
    neighborhoods.stream()
                 .forEach(n -> {
                     boolean include = Arrays.stream(rows)
                                             .map(i -> sorter.convertRowIndexToModel(i))
                                             .mapToObj(i -> domainRows.get(i)
                                                                      .getDomain())
                                             .filter(domain -> IntStream.range(0, domain.getAttributeCount())
                                                                        .map(m -> domain.getAttribute(m))
                                                                        .anyMatch(j -> isSignificant.test(n, j)
                                                                                && compositeMap.isTop(j, typeIndex))

                                             )
                                             .findAny()
                                             .isPresent();

                     Long suid = nodeMappings[n.getNodeIndex()];
                     CyRow row = nodeTable.getRow(suid);
                     row.set(CyNetwork.SELECTED, include);
                 });
}
 
开发者ID:baryshnikova-lab,项目名称:safe-java,代码行数:46,代码来源:DomainBrowserController.java

示例13: applyColors

import org.cytoscape.model.CyNetwork; //导入方法依赖的package包/类
void applyColors(CompositeMap compositeMap,
                 int typeIndex,
                 IntSet filteredDomains) {

    Long[] nodeMappings = session.getNodeMappings();

    CyNetworkView view = session.getNetworkView();
    CyNetwork network = view.getModel();
    CyTable nodeTable = network.getDefaultNodeTable();

    SafeUtil.checkSafeColumns(nodeTable);

    List<? extends Domain> domains = compositeMap.getDomains(typeIndex);

    EnrichmentLandscape landscape = session.getEnrichmentLandscape();
    AnnotationProvider annotationProvider = landscape.getAnnotationProvider();
    int totalAttributes = annotationProvider.getAttributeCount();
    SignificancePredicate isSignificant = Neighborhood.getSignificancePredicate(typeIndex, totalAttributes);
    ScoringFunction score = Neighborhood.getScoringFunction(typeIndex);

    ColorFunction coloring = d -> (int) Math.round(Math.min(1, d * 1.5) * 255);

    statusLabel.setVisible(true);
    panel.setOpaque(true);

    Runnable action = () -> {
        List<? extends Neighborhood> neighborhoods = landscape.getNeighborhoods();
        neighborhoods.stream()
                     .forEach(n -> {
                         Long suid = nodeMappings[n.getNodeIndex()];
                         CyRow row = nodeTable.getRow(suid);

                         double[] color = computeColor(compositeMap, domains, filteredDomains, isSignificant, score,
                                                       n, typeIndex);
                         if (color == null) {
                             row.set(StyleFactory.COLOR_COLUMN, null);
                             row.set(StyleFactory.BRIGHTNESSS_COLUMN, 0D);
                             row.set(StyleFactory.HIGHLIGHT_COLUMN, null);
                         } else {
                             int red = coloring.get(color[0]);
                             int green = coloring.get(color[1]);
                             int blue = coloring.get(color[2]);

                             String hexColor = String.format("#%02x%02x%02x", red, green, blue);
                             row.set(StyleFactory.COLOR_COLUMN, hexColor);

                             double brightness = (color[0] + color[1] + color[2]) / 3;
                             brightness = Math.round(brightness * 10000.0) / 10000.0;
                             row.set(StyleFactory.BRIGHTNESSS_COLUMN, brightness);
                             row.set(StyleFactory.HIGHLIGHT_COLUMN, null);
                         }
                     });

        setDomainBrowserStyle(view);
    };

    SwingUtilities.invokeLater(action);
}
 
开发者ID:baryshnikova-lab,项目名称:safe-java,代码行数:59,代码来源:DomainBrowserController.java

示例14: aggregate

import org.cytoscape.model.CyNetwork; //导入方法依赖的package包/类
private Object aggregate(CyNetwork originNetwork, SummaryCluster cluster, String columnName) {
	CyTable originNodeTable = originNetwork.getDefaultNodeTable();
	CyColumn originColumn = originNodeTable.getColumn(columnName);
	
	Aggregator<?> aggregator;
	Class<?> listElementType = originColumn.getListElementType();
	if(listElementType == null)
		aggregator = groupSettingsManager.getDefaultAggregation(originColumn.getType());
	else
		aggregator = groupSettingsManager.getDefaultListAggregation(listElementType);
	
	if(aggregator == null)
		return null;
	
	// HACK ATTACK!
	// ... but seriously, why does aggregator.aggregate() take a CyGroup parameter???, 
	// it should just be Collection<CyNode>!!, then Aggregators would be more general
	
	final Long mockSuid = Long.MAX_VALUE - 1;
	
	// mock the CyGroup
	CyGroup mockGroup = Mockito.mock(CyGroup.class);
	Mockito.when(mockGroup.getNodeList()).thenReturn(new ArrayList<>(cluster.getNodes()));
	CyNode mockGroupNode = Mockito.mock(CyNode.class);
	Mockito.when(mockGroupNode.getSUID()).thenReturn(mockSuid);
	Mockito.when(mockGroup.getGroupNode()).thenReturn(mockGroupNode);
	
	// need to return a mock CyRow when the aggregator asks for the group node row
	CyTable mockTable = Mockito.mock(CyTable.class);
	CyRow mockRow = Mockito.mock(CyRow.class);
	Mockito.when(mockTable.getRow(Matchers.any())).thenAnswer(invocation -> {
		Long suid = (Long) invocation.getArguments()[0];
		return suid.equals(mockSuid) ? mockRow : originNodeTable.getRow(suid);
	});
	
	try {
		return aggregator.aggregate(mockTable, mockGroup, originColumn);
	}
	catch(Exception e) {
		// anything could go wrong when using mocks to hack the aggregator
		return null;
	}
}
 
开发者ID:BaderLab,项目名称:AutoAnnotateApp,代码行数:44,代码来源:SummaryNetworkTask.java

示例15: actionPerformed

import org.cytoscape.model.CyNetwork; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) 
{
	MarrsProject project = projectMgr.getProject();
	CyNetwork myNet = mapper.createOrGetNetwork();
	
	String filter = project.getQueryParameterFilter(mq, "ID");			
	if ("uri-list".equals (filter))
	{
		// active nodes is the union of selected nodes and the right-clicked node.
		List<CyNode> activeNodes = new ArrayList<CyNode>();
		activeNodes.addAll (CyTableUtil.getNodesInState(myNet,"selected",true));
		if (!activeNodes.contains (clickedNode))
		{
			activeNodes.add (clickedNode);
		}
		
		CyTable nodeTable = myNet.getDefaultNodeTable();
		
		StringBuilder builder = new StringBuilder();
		String sep = "<";
	
		for (CyNode n : activeNodes)
		{
			String nid = nodeTable.getRow(n.getSUID()).get("id", String.class);
			builder.append (sep);
			builder.append (nid);
			sep = ">, <";
		}
		builder.append (">");
		
		project.setQueryParameter("ID", builder.toString());
	}
	else if ("uri".equals(filter))
	{
		project.setQueryParameter("ID", "<" + id + ">");
	}
	else if ("uri-bracketed".equals(filter))
	{
		project.setQueryParameter("ID", "<" + id + ">");
	}
	else
	{
		project.setQueryParameter("ID", id);
	}
	
	String qtext;
	try {
		QueryStatus result = ProjectDlg.run(mapper, project, frame, mq);
		if (!result.userCancelled && (result.resultNum == 0))
			JOptionPane.showMessageDialog(frame, "Zero results");
	} catch (MarrsException e2) {
		JOptionPane.showMessageDialog(frame, "<html>Error fetching results<br>" + StringUtils.escapeHtml(e2.getMessage()), "Error preparing query", JOptionPane.ERROR_MESSAGE);
	}
	catch (StreamException e1) {
		JOptionPane.showMessageDialog(frame, "<html>Error fetching results<br>" + StringUtils.escapeHtml(e1.getMessage()), "Error executing query", JOptionPane.ERROR_MESSAGE);
	}
	System.out.println ("Query done");
}
 
开发者ID:generalbioinformatics,项目名称:general-sparql-cy3,代码行数:60,代码来源:MarrsNodeViewContextMenuFactory.java


注:本文中的org.cytoscape.model.CyNetwork.getDefaultNodeTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。