Search in sources :

Example 1 with CyIdentifiableNameComparator

use of edu.ucsf.rbvi.clusterMaker2.internal.utils.CyIdentifiableNameComparator in project clusterMaker2 by RBVI.

the class CyMatrixFactory method makeMatrix.

public static CyMatrix makeMatrix(CyNetwork network, String[] attributes, boolean selectedOnly, boolean ignoreMissing, boolean transpose, boolean assymetric, MatrixType type) {
    // Create our local copy of the weightAtributes array
    String[] attributeArray = new String[attributes.length];
    if (attributes.length >= 1 && attributes[0].startsWith("node.")) {
        // Get rid of the leading type information
        for (int i = 0; i < attributes.length; i++) {
            attributeArray[i] = attributes[i].substring(5);
        }
        List<CyNode> nodeList = ModelUtils.getSortedNodeList(network, selectedOnly);
        Map<CyNode, Map<String, Double>> nodeCondMap = getNodeCondMap(network, nodeList, attributeArray, ignoreMissing);
        CyMatrix matrix = makeTypedMatrix(network, nodeCondMap.size(), attributeArray.length, transpose, type);
        matrix.setAssymetricalEdge(false);
        return makeAttributeMatrix(network, matrix, nodeList, nodeCondMap, attributeArray, transpose);
    } else if (attributes.length == 1 && attributes[0].startsWith("edge.")) {
        String weight = attributes[0].substring(5);
        if (!assymetric) {
            // Get the list of nodes and edges of interest
            List<CyEdge> edgeList = getEdgeList(network, selectedOnly);
            List<CyNode> nodeList = getNodesFromEdges(network, edgeList, weight, ignoreMissing);
            Collections.sort(nodeList, new CyIdentifiableNameComparator(network));
            CyMatrix matrix = makeTypedMatrix(network, nodeList.size(), nodeList.size(), false, type);
            matrix.setAssymetricalEdge(false);
            return makeSymmetricalMatrix(network, matrix, nodeList, edgeList, weight);
        } else {
            List<CyEdge> edgeList = getEdgeList(network, selectedOnly);
            List<CyNode> targetNodeList = new ArrayList<CyNode>();
            List<CyNode> sourceNodeList = getNodesFromEdges(network, edgeList, targetNodeList, weight, ignoreMissing);
            Collections.sort(targetNodeList, new CyIdentifiableNameComparator(network));
            Collections.sort(sourceNodeList, new CyIdentifiableNameComparator(network));
            CyMatrix matrix = makeTypedMatrix(network, sourceNodeList.size(), targetNodeList.size(), false, type);
            matrix.setAssymetricalEdge(true);
            return makeAssymmetricalMatrix(network, matrix, sourceNodeList, targetNodeList, edgeList, weight);
        }
    }
    return null;
}
Also used : CyMatrix(edu.ucsf.rbvi.clusterMaker2.internal.api.CyMatrix) CyIdentifiableNameComparator(edu.ucsf.rbvi.clusterMaker2.internal.utils.CyIdentifiableNameComparator) CyNode(org.cytoscape.model.CyNode) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

CyMatrix (edu.ucsf.rbvi.clusterMaker2.internal.api.CyMatrix)1 CyIdentifiableNameComparator (edu.ucsf.rbvi.clusterMaker2.internal.utils.CyIdentifiableNameComparator)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 CyNode (org.cytoscape.model.CyNode)1