use of org.cytoscape.model.subnetwork.CySubNetwork in project cytoscape-impl by cytoscape.
the class GroupUtil method updateGroupAttribute.
private void updateGroupAttribute(final CyNetwork net, final CyGroup group) {
CyNode node = group.getGroupNode();
List<CyNode> nodeList;
// to add it so that it will get serialized
if (!net.containsNode(node)) {
// Node not in this network. Add it and mark it....
CySubNetwork subNet = (CySubNetwork) net;
// Temporarily add this to the network so we can serialize it
subNet.addNode(node);
// Remember it...
if (addedNodes.containsKey(net))
nodeList = addedNodes.get(net);
else
nodeList = new ArrayList<CyNode>();
nodeList.add(node);
addedNodes.put(net, nodeList);
}
CyTable hiddenTable = net.getTable(CyNode.class, CyNetwork.HIDDEN_ATTRS);
if (hiddenTable.getColumn(GROUP_ATTRIBUTE) == null)
hiddenTable.createColumn(GROUP_ATTRIBUTE, Boolean.class, false);
hiddenTable.getRow(node.getSUID()).set(GROUP_ATTRIBUTE, Boolean.TRUE);
}
use of org.cytoscape.model.subnetwork.CySubNetwork in project cytoscape-impl by cytoscape.
the class GroupUtil method updateMetaEdges.
private void updateMetaEdges(final CyNetwork net, final CyNode groupNode) {
CyRootNetwork rootNetwork = ((CySubNetwork) net).getRootNetwork();
// Find all of the edges from the group node and if they are
// meta-edges, mark them as such
List<CyEdge> edgeList = net.getAdjacentEdgeList(groupNode, CyEdge.Type.ANY);
for (CyEdge edge : edgeList) {
String interaction = net.getRow(edge).get(CyEdge.INTERACTION, String.class);
if (interaction.startsWith("meta-")) {
createColumn(rootNetwork.getTable(CyEdge.class, CyNetwork.HIDDEN_ATTRS), ISMETA_EDGE_ATTR, Boolean.class);
rootNetwork.getRow(edge, CyNetwork.HIDDEN_ATTRS).set(ISMETA_EDGE_ATTR, Boolean.TRUE);
}
}
}
use of org.cytoscape.model.subnetwork.CySubNetwork in project cytoscape-impl by cytoscape.
the class GroupUtil method updateCollapsedGroupsAttribute.
private void updateCollapsedGroupsAttribute(final CyGroup group) {
// Get our subnetwork
CySubNetwork np = (CySubNetwork) group.getGroupNode().getNetworkPointer();
CyTable hiddenTable = np.getTable(CyNetwork.class, CyNetwork.HIDDEN_ATTRS);
// We use our embedded network table for this
CyRow netRow = hiddenTable.getRow(np.getSUID());
CyColumn stateColumn = hiddenTable.getColumn(GROUP_COLLAPSED_ATTRIBUTE);
if (stateColumn == null)
hiddenTable.createListColumn(GROUP_COLLAPSED_ATTRIBUTE, Long.class, true);
CyColumn groupShownColumn = hiddenTable.getColumn(GROUP_NODE_SHOWN_ATTRIBUTE);
if (groupShownColumn == null)
hiddenTable.createListColumn(GROUP_NODE_SHOWN_ATTRIBUTE, Long.class, true);
List<Long> collapsedList = new ArrayList<Long>();
List<Long> groupNodeShownList = new ArrayList<Long>();
for (CyNetwork net : group.getNetworkSet()) {
if (group.isCollapsed(net)) {
collapsedList.add(net.getSUID());
} else if (net.containsNode(group.getGroupNode())) {
// We're not collapsed, but we're still showing the group node.
groupNodeShownList.add(net.getSUID());
}
}
netRow.set(GROUP_COLLAPSED_ATTRIBUTE, collapsedList);
netRow.set(GROUP_NODE_SHOWN_ATTRIBUTE, groupNodeShownList);
return;
}
use of org.cytoscape.model.subnetwork.CySubNetwork in project cytoscape-impl by cytoscape.
the class ReadCache method getNetworkTables.
/**
* @return All network tables, except DEFAULT_ATTRS and SHARED_DEFAULT_ATTRS ones.
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public Set<CyTable> getNetworkTables() {
final Set<CyTable> tables = new HashSet<>();
final Set<CyNetwork> networks = new HashSet<>();
final Class<?>[] types = new Class[] { CyNetwork.class, CyNode.class, CyEdge.class };
if (networkByIdMap.values() != null)
networks.addAll(networkByIdMap.values());
final CyNetworkTableManager netTblMgr = serviceRegistrar.getService(CyNetworkTableManager.class);
for (final CyNetwork n : networks) {
for (final Class t : types) {
Map<String, CyTable> tblMap = new HashMap<>(netTblMgr.getTables(n, t));
tblMap.remove(CyNetwork.DEFAULT_ATTRS);
if (tblMap != null)
tables.addAll(tblMap.values());
if (n instanceof CySubNetwork) {
// Don't forget the root-network tables.
tblMap = new HashMap<String, CyTable>(netTblMgr.getTables(((CySubNetwork) n).getRootNetwork(), t));
tblMap.remove(CyRootNetwork.DEFAULT_ATTRS);
tblMap.remove(CyRootNetwork.SHARED_DEFAULT_ATTRS);
if (tblMap != null)
tables.addAll(tblMap.values());
}
}
}
return tables;
}
use of org.cytoscape.model.subnetwork.CySubNetwork in project clusterMaker2 by RBVI.
the class NodeCluster method getSubNetwork.
/* Method to get the subnetwork formed by the nodes in the cluster
*
* @param net parent network
* @param nodes
*/
public CySubNetwork getSubNetwork(final CyNetwork net, final CyRootNetwork root, final SavePolicy policy) {
// final CyRootNetwork root = rootNetworkMgr.getRootNetwork(net);
final Set<CyEdge> edges = new HashSet<CyEdge>();
for (CyNode n : this) {
Set<CyEdge> adjacentEdges = new HashSet<CyEdge>(net.getAdjacentEdgeList(n, CyEdge.Type.ANY));
// Get only the edges that connect nodes that belong to the subnetwork:
for (CyEdge e : adjacentEdges) {
if (this.contains(e.getSource()) && this.contains(e.getTarget())) {
edges.add(e);
}
}
}
final CySubNetwork subNet = root.addSubNetwork(this, edges, policy);
/*
// Save it for later disposal
Set<CySubNetwork> snSet = createdSubNetworks.get(root);
if (snSet == null) {
snSet = new HashSet<CySubNetwork>();
createdSubNetworks.put(root, snSet);
}
snSet.add(subNet);
*/
return subNet;
}
Aggregations