Search in sources :

Example 1 with ClusterTaskFactory

use of edu.ucsf.rbvi.clusterMaker2.internal.api.ClusterTaskFactory in project clusterMaker2 by RBVI.

the class GetNetworkClusterTask method run.

public void run(TaskMonitor monitor) {
    if (network == null)
        network = clusterManager.getNetwork();
    if (algorithm == null) {
        monitor.showMessage(TaskMonitor.Level.ERROR, "Algorithm must be specified");
        return;
    }
    ClusterTaskFactory algTF = clusterManager.getAlgorithm(algorithm);
    if (algTF == null) {
        monitor.showMessage(TaskMonitor.Level.ERROR, "Can't find algorithm: '" + algorithm + "'");
        return;
    }
    if (!algTF.getTypeList().contains(ClusterTaskFactory.ClusterType.NETWORK) && !algTF.getTypeList().contains(ClusterTaskFactory.ClusterType.FILTER)) {
        monitor.showMessage(TaskMonitor.Level.ERROR, "Algorithm: '" + algorithm + "' is not a network clusterer");
        return;
    }
    if (!algTF.isAvailable(network)) {
        monitor.showMessage(TaskMonitor.Level.ERROR, "No data for algorithm: '" + algorithm + "' in this network");
        return;
    }
    algName = algTF.getShortName();
    String clusterAttribute = network.getRow(network, CyNetwork.LOCAL_ATTRS).get(ClusterManager.CLUSTER_ATTRIBUTE, String.class);
    boolean isFuzzy = network.getTable(CyNode.class, CyNetwork.LOCAL_ATTRS).getColumn(clusterAttribute).getType().equals(List.class);
    clusterMap = new HashMap<Integer, List<CyNode>>();
    for (CyNode node : (List<CyNode>) network.getNodeList()) {
        // For each node -- see if it's in a cluster.  If so, add it to our map
        if (ModelUtils.hasAttribute(network, node, clusterAttribute)) {
            if (isFuzzy) {
                List<Integer> clusterList = network.getRow(node).getList(clusterAttribute, Integer.class);
                for (Integer cluster : clusterList) addNodeToMap(clusterMap, cluster, node);
            } else {
                Integer cluster = network.getRow(node).get(clusterAttribute, Integer.class);
                addNodeToMap(clusterMap, cluster, node);
            }
        }
    }
}
Also used : ClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.api.ClusterTaskFactory) CyNode(org.cytoscape.model.CyNode) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with ClusterTaskFactory

use of edu.ucsf.rbvi.clusterMaker2.internal.api.ClusterTaskFactory in project clusterMaker2 by RBVI.

the class GetClusterTask method run.

public void run(TaskMonitor monitor) {
    if (network == null)
        network = clusterManager.getNetwork();
    if (algorithm == null) {
        monitor.showMessage(TaskMonitor.Level.ERROR, "Algorithm must be specified");
        return;
    }
    ClusterTaskFactory algTF = clusterManager.getAlgorithm(algorithm);
    if (algTF == null) {
        monitor.showMessage(TaskMonitor.Level.ERROR, "Can't find algorithm: '" + algorithm + "'");
    }
    if (!algTF.getTypeList().contains(ClusterTaskFactory.ClusterType.ATTRIBUTE)) {
        monitor.showMessage(TaskMonitor.Level.ERROR, "Algorithm: '" + algorithm + "' is not an attribute clusterer");
        return;
    }
    if (!algTF.isAvailable(network)) {
        monitor.showMessage(TaskMonitor.Level.ERROR, "No data for algorithm: '" + algorithm + "' in this network");
        return;
    }
    algName = algTF.getShortName();
    if (ModelUtils.hasAttribute(network, network, ClusterManager.CLUSTER_TYPE_ATTRIBUTE))
        clusterType = network.getRow(network).get(ClusterManager.CLUSTER_TYPE_ATTRIBUTE, String.class);
    if (ModelUtils.hasAttribute(network, network, ClusterManager.CLUSTER_PARAMS_ATTRIBUTE))
        clusterParams = network.getRow(network).getList(ClusterManager.CLUSTER_PARAMS_ATTRIBUTE, String.class);
    if (type.getSelectedValue().equals("node"))
        getEisenClusters(ClusterManager.NODE_ORDER_ATTRIBUTE, ClusterManager.CLUSTER_NODE_ATTRIBUTE);
    else
        getEisenClusters(ClusterManager.ARRAY_ORDER_ATTRIBUTE, ClusterManager.CLUSTER_ATTR_ATTRIBUTE);
}
Also used : ClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.api.ClusterTaskFactory)

Aggregations

ClusterTaskFactory (edu.ucsf.rbvi.clusterMaker2.internal.api.ClusterTaskFactory)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CyNode (org.cytoscape.model.CyNode)1