public List <int> DeactivateAll() { List <int> switched = new List <int>(); for (int i = 0; i < Nodes.Count; ++i) { ProteinNode prot = (ProteinNode)Nodes[i]; if (prot.Active) { switched.Add(i); } prot.Deactivate(); } return(switched); }
public List <int> UnblockAll() { List <int> switched = new List <int>(); for (int i = 0; i < Nodes.Count; ++i) { ProteinNode prot = (ProteinNode)Nodes[i]; if (prot.Blocked) { switched.Add(i); } prot.Blocked = false; } return(switched); }
public void Propagate(GraphSystem graphSystem, float time) { List <Tuple <int, SignalType> > updatedSignals = new List <Tuple <int, SignalType> >(); graphSystem.DehighlightNodes(); List <int> activateNodes = new List <int>(); List <int> blockNodes = new List <int>(); List <int> activateEdges = new List <int>(); List <int> blockEdges = new List <int>(); List <int> decoupleEdges = new List <int>(); List <int> coupleEdges = new List <int>(); // activate input proteins: foreach (int i in inputs) { GetProtein(i).Activate(); } highlight(graphSystem); foreach (ProteinNode prot in Nodes) { if (prot.Active) { var outInteractions = GetOutcomingInteractions(prot.Name); foreach (var tuple in outInteractions) { var outInteraction = tuple.Item1; int outInteractionId = tuple.Item2; ProteinNode nextProt = GetProtein(outInteraction.End2); if (outInteraction.Type == "-") { // uncomment to add blocking sparks: // graphSystem.AddSpark(outInteraction.End1, outInteraction.End2, time, HighlightNodesColorNeg); blockNodes.Add(outInteraction.End2); blockEdges.Add(outInteractionId); } else if (outInteraction.Type == "+") { graphSystem.AddSpark(outInteraction.End1, outInteraction.End2, time, HighlightNodesColorPos); activateNodes.Add(outInteraction.End2); foreach (var t in GetInteractions(prot.Name, nextProt.Name)) { activateEdges.Add(t.Item2); } } else if (outInteraction.Type == "b") { if (outInteraction.Value > decoupleStrength) { decoupleEdges.Add(outInteractionId); } else { coupleEdges.Add(outInteractionId); } } } } } // launch new sparks: graphSystem.RefreshSparks(); // activate and block nodes: changeNodeStates(blockNodes, activateNodes, graphSystem); // couple and decouple nodes: List <Tuple <List <int>, float> > edgeLists = new List <Tuple <List <int>, float> >(); edgeLists.Add(new Tuple <List <int>, float>(coupleEdges, coupleStrength)); edgeLists.Add(new Tuple <List <int>, float>(decoupleEdges, decoupleStrength)); changeEdgeValues(edgeLists, graphSystem); // paint edges: graphSystem.PaintAllEdges(EdgeNeutralColor); graphSystem.PaintEdges(activateEdges, EdgePosColor); graphSystem.PaintEdges(blockEdges, EdgeNegColor); }