use of org.cytoscape.phenomescape.internal.PhenomeExpressSubnetwork in project PhenomeScape by soulj.
the class ConnectedComponentAnalyser method traverseReachable.
private PhenomeExpressSubnetwork traverseReachable(Integer index, HashMap<Integer, Protein> index2Protein, AMatrix matrix, Set<Integer> aTraversed) {
LinkedList<Integer> toTraverse = new LinkedList<Integer>();
aTraversed.add(index);
toTraverse.add(index);
PhenomeExpressSubnetwork subnetwork = new PhenomeExpressSubnetwork(node2Protein);
Protein protein = index2Protein.get(index);
subnetwork.getNodeList().add(protein.getNode());
subnetwork.setSubnetworkScore(subnetwork.getSubnetworkScore() + protein.getScore());
while (!toTraverse.isEmpty()) {
final Integer currentNode = toTraverse.removeFirst();
final AVector neighbours = matrix.getRow(currentNode);
for (int i = 0; i < neighbours.length(); i++) {
if (neighbours.get(i) != 0.0) {
if (!aTraversed.contains(i)) {
toTraverse.add(i);
protein = index2Protein.get(i);
subnetwork.getNodeList().add(protein.getNode());
subnetwork.setSubnetworkScore(subnetwork.getSubnetworkScore() + protein.getScore());
aTraversed.add(i);
}
}
}
}
return subnetwork;
}
use of org.cytoscape.phenomescape.internal.PhenomeExpressSubnetwork in project PhenomeScape by soulj.
the class ConnectedComponentAnalyser method ccFromAdjMatrix.
public ArrayList<PhenomeExpressSubnetwork> ccFromAdjMatrix(AMatrix cooccuranceMat, ProteinNetwork proteinNetwork) {
HashMap<Integer, Protein> index2Protein = proteinNetwork.getIndex2ProteinMap();
int notVisitedCount = cooccuranceMat.rowCount();
Set<Integer> traversed = new HashSet<Integer>(notVisitedCount);
ArrayList<PhenomeExpressSubnetwork> components = new ArrayList<PhenomeExpressSubnetwork>();
for (int i = 0; i < cooccuranceMat.rowCount(); i++) {
if (cooccuranceMat.getRow(i).elementSum() > 0) {
if (!traversed.contains(i)) {
PhenomeExpressSubnetwork newComponent = traverseReachable(Integer.valueOf(i), index2Protein, cooccuranceMat, traversed);
components.add(newComponent);
}
}
}
return components;
}
Aggregations