示例#1
0
 void highlight(GraphSystem graphSystem)
 {
     List<int> highPlus = new List<int>();
     List<int> highMinus = new List<int>();
     foreach (ProteinNode node in Nodes)
     {
         if (node.Active) highPlus.Add(GetIdByName(node.Name));
         else if (node.Blocked) highMinus.Add(GetIdByName(node.Name));
     }
     graphSystem.HighlightNodes(highPlus, HighlightNodesColorPos);
     graphSystem.HighlightNodes(highMinus, HighlightNodesColorNeg);
 }
示例#2
0
 void changeEdgeValues(IEnumerable<Tuple<List<int>, float>> edgeIds, GraphSystem gs)
 {
     var graph = gs.GetGraph();
     foreach (var tuple in edgeIds)
     {
         foreach (int id in tuple.Item1)
         {
             graph.Edges[id].Value = tuple.Item2;
             // to keep track of edge values without the need to get the graph from GraphSystem:
             this.Edges[id].Value = tuple.Item2;
         }
     }
     gs.UpdateGraph(graph);
 }
示例#3
0
        void changeNodeStates(IEnumerable<int> blockNodes, IEnumerable<int> activateNodes, GraphSystem gs)
        {
            DeactivateAll();
            UnblockAll();

            foreach (var i in activateNodes)
            {
                GetProtein(i).Activate();
            }
            foreach (var i in blockNodes)
            {
                GetProtein(i).Deactivate();
                GetProtein(i).Blocked = true;
            }
        }
示例#4
0
        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);
        }