本文整理汇总了Java中org.cytoscape.model.CyNetwork类的典型用法代码示例。如果您正苦于以下问题:Java CyNetwork类的具体用法?Java CyNetwork怎么用?Java CyNetwork使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CyNetwork类属于org.cytoscape.model包,在下文中一共展示了CyNetwork类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAdjMatrix
import org.cytoscape.model.CyNetwork; //导入依赖的package包/类
public double[][] createAdjMatrix(CyNetwork network) {
List<CyNode> nodeList = network.getNodeList();
int totalnodecount = network.getNodeList().size();
double[][] adjacencyMatrixOfNetwork = new double[totalnodecount][totalnodecount];
List<CyEdge> edges = network.getEdgeList();
for(CyEdge e : edges) {
CyNode a = e.getSource();
CyNode b = e.getTarget();
if(isDirected){ // -1 convention for now
if(adjacencyMatrixOfNetwork[nodeList.indexOf(a)][nodeList.indexOf(b)] == 0 && adjacencyMatrixOfNetwork[nodeList.indexOf(b)][nodeList.indexOf(a)] == 0) {
adjacencyMatrixOfNetwork[nodeList.indexOf(a)][nodeList.indexOf(b)] = 1;
adjacencyMatrixOfNetwork[nodeList.indexOf(b)][nodeList.indexOf(a)] = -1;
} else {
adjacencyMatrixOfNetwork[nodeList.indexOf(a)][nodeList.indexOf(b)] = 1;
adjacencyMatrixOfNetwork[nodeList.indexOf(b)][nodeList.indexOf(a)] = 1;
}
} else{
adjacencyMatrixOfNetwork[nodeList.indexOf(a)][nodeList.indexOf(b)] = 1;
adjacencyMatrixOfNetwork[nodeList.indexOf(b)][nodeList.indexOf(a)] = 1;
}
}
return adjacencyMatrixOfNetwork;
}
示例2: MapColumnTask
import org.cytoscape.model.CyNetwork; //导入依赖的package包/类
public MapColumnTask(CyServiceRegistrar registrar) {
this.applicationManager = registrar.getService(CyApplicationManager.class);
this.mappingManager = registrar.getService(DataSeriesMappingManager.class);
DataSeriesManager dataSeriesManager = registrar.getService(DataSeriesManager.class);
CyNetworkManager networkManager = registrar.getService(CyNetworkManager.class);
targetClass = new ListSingleSelection<>(new TargetClassInfo("Nodes", CyNode.class), new TargetClassInfo("Edges", CyEdge.class));
dataSeries = new ListSingleSelection<>(dataSeriesManager.getAllDataSeries());
existingColumnForMapping = new ListSingleSelection<>();
mapRowNamesWithColumn = new ListSingleSelection<>();
targetNetwork = new ListSingleSelection<>(networkManager.getNetworkSet().stream().toArray(CyNetwork[]::new));
if(applicationManager.getCurrentNetwork() != null)
{
targetNetwork.setSelectedValue(applicationManager.getCurrentNetwork());
}
updateExistingColumnForMapping(CyNode.class);
updateMapRowNamesWithColumn(CyNode.class);
}
示例3: handleEvent
import org.cytoscape.model.CyNetwork; //导入依赖的package包/类
@Override
public void handleEvent(RowsSetEvent e) {
if (!e.containsColumn(CyNetwork.SELECTED) || ignoreSelection)
{
return;
}
CyNetwork currentNetwork = cyApplicationManager.getCurrentNetwork();
if(currentNetwork == null
|| e.getSource().equals(currentNetwork.getTable(CyNode.class, CyNetwork.LOCAL_ATTRS))
|| e.getSource().equals(currentNetwork.getTable(CyEdge.class, CyNetwork.LOCAL_ATTRS)))
{
updateVisual();
//TODO the above is very inefficient, replace with maintaining the list of selected nodes with
// for (RowSetRecord record: e.getColumnRecords(CyNetwork.SELECTED)) {
// Long suid = record.getRow().get(CyIdentifiable.SUID, Long.class);
// Boolean value = (Boolean)record.getValue();
}
}
示例4: mapDataSeriesRowsToTableColumn
import org.cytoscape.model.CyNetwork; //导入依赖的package包/类
@Override
public void mapDataSeriesRowsToTableColumn(CyNetwork network, Class<? extends CyIdentifiable> targetClass, String columnName,
DataSeries<?, ?> ds) {
Map<Class<? extends CyIdentifiable>, Map<String, DataSeries<?, ?>>> networkMappings = mappings.get(network);
if (networkMappings == null)
{
networkMappings = new HashMap<>();
mappings.put(network, networkMappings);
}
Map<String, DataSeries<?, ?>> localMap = networkMappings.get(targetClass);
if(localMap == null)
{
localMap = new HashMap<>();
networkMappings.put(targetClass, localMap);
}
if(localMap.containsKey(columnName))
{
logger.warn("Remapping column '" + columnName +"' for network " + Utils.getNetworkName(network) + " class " + targetClass.getSimpleName());
}
localMap.put(columnName, ds);
fireEvent(new DataSeriesMappingEvent(this, EventType.MAPPING_ADDED, Collections.singletonList(new MappingDescriptor<DataSeries<?,?>>(network, targetClass, columnName, ds))));
}
示例5: getMappedDataSeries
import org.cytoscape.model.CyNetwork; //导入依赖的package包/类
@Override
public <T extends DataSeries<?, ?>> T getMappedDataSeries(CyNetwork network, Class<? extends CyIdentifiable> targetClass,
String columnName, Class<T> seriesClass) {
DataSeries<?, ?> series = getMappedDataSeries(network, targetClass, columnName);
if(series == null)
{
return null;
}
else if(seriesClass.isAssignableFrom(series.getClass()))
{
@SuppressWarnings("unchecked")
T castSeries = (T)series;
return (T)castSeries;
}
else
{
throw new DataSeriesException("Mapped data series " + series.getName() + " does not have expected class (" + seriesClass.getName() + ")");
}
}
示例6: getAllMappings
import org.cytoscape.model.CyNetwork; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public <T extends DataSeries<?, ?>> Map<String, T> getAllMappings(CyNetwork network, Class<? extends CyIdentifiable> targetClass,
Class<T> dataSeriesClass) {
Map<Class<? extends CyIdentifiable>, Map<String, DataSeries<?, ?>>> networkMap = mappings.get(network);
if(networkMap == null)
{
return Collections.EMPTY_MAP;
}
Map<String, DataSeries<?, ?>> localMap = networkMap.get(targetClass);
if(localMap == null)
{
return Collections.EMPTY_MAP;
}
return (Map<String, T>)Maps.filterEntries(localMap, e -> dataSeriesClass.isAssignableFrom(e.getValue().getClass()));
}
示例7: updateEdgeWeightColumnList
import org.cytoscape.model.CyNetwork; //导入依赖的package包/类
private void updateEdgeWeightColumnList() {
weightColumnModel.removeAllElements();
if (session == null) {
return;
}
CyNetworkView view = session.getNetworkView();
CyNetwork model = view.getModel();
CyTable table = model.getDefaultEdgeTable();
table.getColumns()
.stream()
.filter(c -> !CyIdentifiable.SUID.equals(c.getName()) && Number.class.isAssignableFrom(c.getType()))
.map(c -> c.getName())
.sorted(String.CASE_INSENSITIVE_ORDER)
.forEach(name -> weightColumnModel.addElement(name));
weightColumn.setSelectedItem(session.getWeightColumn());
if (weightColumn.getSelectedIndex() == -1 && weightColumnModel.getSize() > 0) {
weightColumn.setSelectedIndex(0);
}
}
示例8: 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());
}
示例9: 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);
}
}
示例10: serializeSession
import org.cytoscape.model.CyNetwork; //导入依赖的package包/类
void serializeSession(CyTable dataTable,
SafeSession session) {
CyNetworkView networkView = session.getNetworkView();
CyNetwork network = networkView.getModel();
CyTable networkTable = network.getDefaultNetworkTable();
CyRow row = networkTable.getRow(network.getSUID());
checkColumn(networkTable, DATA_TABLE_COLUMN, Long.class);
Long suid = dataTable.getSUID();
row.set(DATA_TABLE_COLUMN, suid);
CyRow viewRow = dataTable.getRow(networkView.getSUID());
try (StringWriter writer = new StringWriter()) {
toJson(session, writer);
String json = writer.toString();
viewRow.set(SAFE_DATA_COLUMN, json);
} catch (IOException e) {
e.printStackTrace();
}
}
示例11: exportModel
import org.cytoscape.model.CyNetwork; //导入依赖的package包/类
public void exportModel() {
for(CyNetwork network: networkManager.getNetworkSet()) {
CyTable asTable = createAnnotationSetTable(network);
CyTable clusterTable = createClusterTable(network);
Ids ids = new Ids();
Collection<CyNetworkView> networkViews = networkViewManager.getNetworkViews(network);
for(CyNetworkView networkView : networkViews) {
Optional<NetworkViewSet> nvs = modelManagerProvider.get().getExistingNetworkViewSet(networkView);
if(nvs.isPresent()) {
try {
exportModel(nvs.get(), asTable, clusterTable, ids);
}catch(Exception ex) {
ex.printStackTrace();
}
continue;
}
}
}
}
示例12: createAnnotationSetTable
import org.cytoscape.model.CyNetwork; //导入依赖的package包/类
private CyTable createAnnotationSetTable(CyNetwork network) {
CyTable table = createTable(network, ANNOTATION_SET_TABLE, ANNOTATION_SET_ID);
createColumn(table, NAME, String.class);
createColumn(table, NETWORK_VIEW_SUID, Long.class);
createListColumn(table, LABEL_COLUMN, String.class);
createColumn(table, ACTIVE, Boolean.class);
createColumn(table, SHAPE_TYPE, String.class);
createColumn(table, SHOW_CLUSTERS, Boolean.class);
createColumn(table, SHOW_LABELS, Boolean.class);
createColumn(table, USE_CONSTANT_FONT_SIZE, Boolean.class);
createColumn(table, FONT_SCALE, Integer.class);
createColumn(table, FONT_SIZE, Integer.class);
createColumn(table, OPACITY, Integer.class);
createColumn(table, BORDER_WIDTH, Integer.class);
createColumn(table, FILL_COLOR, Integer.class); // store as RGB int value
createColumn(table, BORDER_COLOR, Integer.class);
createColumn(table, FONT_COLOR, Integer.class);
createColumn(table, LABEL_MAKER_ID, String.class);
createColumn(table, LABEL_MAKER_CONTEXT, String.class);
createColumn(table, CREATION_PARAMS, String.class);
return table;
}
示例13: createLabelColumnCombo
import org.cytoscape.model.CyNetwork; //导入依赖的package包/类
public static JComboBox<String> createLabelColumnCombo(CyNetwork network) {
JComboBox<String> combo = new JComboBox<>();
for(String labelColumn : getColumnsOfType(network, String.class, true, false, true)) {
combo.addItem(labelColumn);
}
// Preselect the best choice for label column, with special case for EnrichmentMap
for(int i = 0; i < combo.getItemCount(); i++) {
String item = combo.getItemAt(i);
if(item.endsWith("GS_DESCR")) { // column created by EnrichmentMap
combo.setSelectedIndex(i);
break;
}
if(item.equalsIgnoreCase("name")) {
combo.setSelectedIndex(i);
break;
}
}
return combo;
}
示例14: createCluster
import org.cytoscape.model.CyNetwork; //导入依赖的package包/类
private void createCluster(AnnotationSet annotationSet) {
LabelMaker labelMaker = labelManager.get().getLabelMaker(annotationSet);
if(!labelMaker.isReady()) {
return;
}
List<CyNode> nodes = CyTableUtil.getNodesInState(networkView.getModel(), CyNetwork.SELECTED, true);
CyNetwork network = networkView.getModel();
// Remove selected nodes from existing clusters. Bug #37
annotationSet.removeNodes(nodes);
String label = labelMaker.makeLabel(network, nodes, annotationSet.getLabelColumn());
Cluster cluster = annotationSet.createCluster(nodes, label, false);
// It was the intention to only allow ModelEvents to be fired from inside the model package.
// But the cluster is already selected and firing the event here is much simpler than
// re-selecting the nodes to get the event to fire.
EventBus eventBus = eventBusProvider.get();
eventBus.post(new ModelEvents.ClustersSelected(annotationSet, Collections.singleton(cluster)));
}
示例15: createAnnotationSetAndCluster
import org.cytoscape.model.CyNetwork; //导入依赖的package包/类
private void createAnnotationSetAndCluster() {
// Automatically create an annotation set
ModelManager modelManager = modelManagerProvider.get();
NetworkViewSet nvs = modelManager.getNetworkViewSet(networkView);
List<CyNode> nodes = CyTableUtil.getNodesInState(networkView.getModel(), CyNetwork.SELECTED, true);
String labelColumn = getLabelColumn();
@SuppressWarnings("rawtypes")
LabelMakerFactory labelMakerFactory = labelManagerProvider.get().getDefaultFactory();
@SuppressWarnings("unchecked")
LabelMaker labelMaker = labelMakerFactory.createLabelMaker(labelMakerFactory.getDefaultContext());
String label = labelMaker.makeLabel(networkView.getModel(), nodes, labelColumn);
String suggestedName = nvs.suggestName();
AnnotationSetBuilder builder = nvs.getAnnotationSetBuilder(suggestedName, labelColumn);
builder.addCluster(nodes, label, false);
AnnotationSet as = builder.build();
nvs.select(as);
}