Exemple #1
0
        private static ProteinGraph TrimGraph(PDBFile pdbFile, ProteinGraph proteinGraph)
        {
            var trimmedGraph = new ProteinGraph();
            Dictionary <GWNode <ResidueNodeData, SimpleEdgeData, ProteinGraphData>, GWNode <ResidueNodeData, SimpleEdgeData, ProteinGraphData> > dict = new Dictionary <GWNode <ResidueNodeData, SimpleEdgeData, ProteinGraphData>, GWNode <ResidueNodeData, SimpleEdgeData, ProteinGraphData> >();

            foreach (var node in proteinGraph.Nodes)
            {
                if (!node.Data.IsCore)
                {
                    var newNode = trimmedGraph.CreateNode();
                    newNode.Data = node.Data;
                    dict.Add(node, newNode);
                }
                else
                {
                }
            }

            foreach (var edge in proteinGraph.Edges)
            {
                if (!edge.Head.Data.IsCore && !edge.Foot.Data.IsCore)
                {
                    var newEdge = trimmedGraph.CreateEdge(dict[edge.Head], dict[edge.Foot]);
                    newEdge.Data = edge.Data;
                }
            }

            return(trimmedGraph);
        }
Exemple #2
0
        public static Dictionary <string, ProteinGraph> Do(PDBFile file, double neighbourDistance, ResidueNodeCenterDefinition centerdef)
        {
            var dict = new Dictionary <string, ProteinGraph>();

            foreach (var chain in file.Chains)
            {
                var graph = new ProteinGraph();
                graph.Data = new ProteinGraphData();

                graph.Data.PDBFile              = file;
                graph.Data.NeighbourDistance    = neighbourDistance;
                graph.Data.NodeCenterDefinition = centerdef;

                //Compute Nodes:
                foreach (var residue in chain.Residues)
                {
                    if (residue.CAlpha != null)
                    {
                        var node = graph.CreateNode();
                        node.Data        = new ResidueNodeData(residue);
                        node.Data.IsCore = residue.IsCore;
                        node.Data.ZScore = residue.ZScore;
                        switch (centerdef)
                        {
                        case ResidueNodeCenterDefinition.CAlpha:
                            node.Data.SetValuesTo(residue.CAlpha);
                            break;

                        case ResidueNodeCenterDefinition.BalancePoint:
                            node.Data.SetValuesTo(residue.Atoms.BalancePoint());
                            break;

                        default:
                            break;
                        }
                    }
                }

                var nodeList = graph.Nodes.ToList();
                //compute edges:
                for (int i = 0; i < nodeList.Count - 1; i++)
                {
                    for (int k = i + 1; k < nodeList.Count; k++)
                    {
                        var nodeOne = nodeList[i];
                        var nodetwo = nodeList[k];
                        var dist    = nodeOne.Data.Distance(nodetwo.Data);
                        if (dist <= neighbourDistance)
                        {
                            var edge = graph.CreateEdge(nodeOne, nodetwo);
                            edge.Data = new SimpleEdgeData();
                        }
                    }
                }

                dict.Add(chain.Name, graph);
            }
            return(dict);
        }
Exemple #3
0
 public void Compute(ProteinGraph graph)
 {
     Graph = graph;
     foreach (var node in graph.Nodes)
     {
         var totalHydrophobicity = Hydrophobicity.GetHydrophobicity(node.Data.Residue.Code);
         foreach (var neighbour in node.Neighbours)
         {
             totalHydrophobicity += Hydrophobicity.GetHydrophobicity(neighbour.Data.Residue.Code);
         }
         totalHydrophobicity /= (node.Neighbours.Count() + 1);
         logic.Values.Add(node.Data.Residue, (totalHydrophobicity + maxEntry) / (2 * maxEntry));
     }
 }
Exemple #4
0
 public void Compute(ProteinGraph graph, IDictionary <Residue, double> rasaValues)
 {
     Graph = graph;
     foreach (var node in graph.Nodes)
     {
         var rasasum             = rasaValues[node.Data.Residue];
         var totalHydrophobicity = Hydrophobicity.GetHydrophobicity(node.Data.Residue.Code) * rasaValues[node.Data.Residue];
         foreach (var neighbour in node.Neighbours)
         {
             rasasum             += rasaValues[neighbour.Data.Residue];
             totalHydrophobicity += Hydrophobicity.GetHydrophobicity(neighbour.Data.Residue.Code) * rasaValues[neighbour.Data.Residue];
         }
         totalHydrophobicity /= rasasum;
         logic.Values.Add(node.Data.Residue, (totalHydrophobicity + maxEntry) / (2 * maxEntry));
     }
 }
Exemple #5
0
        /// <summary>
        /// Proteins constructor
        /// </summary>
        public Proteins()
            : base()
        {
            //	enable object tracking :
            Parameters.TrackObjects = true;
            Parameters.MsaaLevel = 8;

            //	uncomment to enable debug graphics device:
            //	(MS Platform SDK must be installed)
            //	Parameters.UseDebugDevice	=	true;

            //	add services :
            AddService(new SpriteBatch(this), false, false, 0, 0);
            AddService(new DebugStrings(this), true, true, 9999, 9999);
            AddService(new DebugRender(this), true, true, 9998, 9998);
            AddService(new GraphSystem(this), true, true, 9997, 9997);
            AddService(new GreatCircleCamera(this), true, true, 9996, 9996);
            AddService(new UserInterface(this, "stencil"), true, true, 10000, 10000);

            //	add here additional services :

            //	load configuration for each service :
            LoadConfiguration();

            //	make configuration saved on exit :
            Exiting += Game_Exiting;

            nodeSelected = false;
            selectedNodeIndex = 0;
            //			hotNodes	= new List<int>();
            coldNodes	= new List<int>();
            protGraph	= new ProteinGraph();

            timer = 0;
            timer2 = 0;

            delay = 500;
            delay2 = 3000;

            //COLORS FOR HIGHLIGHT / цвета для активных
            nodeHighlightColorNeg = new Color(221,0,41) ;
            nodeHighlightColorPos = new Color(0,221,180) ;
        }
Exemple #6
0
 public ResidueNode(Residue residue, ProteinGraph graph)
 {
     Graph   = graph;
     Residue = residue;
 }
Exemple #7
0
        public static GWGraph <ICRFNodeData, ICRFEdgeData, ICRFGraphData> CreateGraph(this ProteinGraph graph, IDictionary <ResidueNodeData, double[]> nodescores, IDictionary <SimpleEdgeData, double[, ]> edgescores)
        {
            var clonegraph = new GWGraph <ICRFNodeData, ICRFEdgeData, ICRFGraphData>();

            foreach (var node in graph.Nodes)
            {
                var clone = clonegraph.CreateNode();
                clone.Data = new CRFNodeData()
                {
                    Id = node.Data.Residue.Id, Scores = nodescores[node.Data]
                };
                clonegraph.Nodes.Add(clone);
            }
            foreach (var edge in graph.Edges)
            {
                var newEdge = new GWEdge <ICRFNodeData, ICRFEdgeData, ICRFGraphData>(clonegraph.Nodes.First(n => n.Data.Id.Equals(edge.Head.Data.Residue.Id)),
                                                                                     clonegraph.Nodes.First(n => n.Data.Id.Equals(edge.Foot.Data.Residue.Id)));
                newEdge.Data        = new CRFEdgeData();
                newEdge.Data.Scores = edgescores[edge.Data];
                clonegraph.Edges.Add(newEdge);
            }

            return(clonegraph);
        }
Exemple #8
0
        private static GWGraph <CRFNodeData, CRFEdgeData, CRFGraphData> SetReferenceLabel(ProteinGraph trimmedGraph)
        {
            var nameWithChain  = RandomlySelectedPDBFile.Substring(fileFolder.Length + 1, 6);
            var interfacesList = new List <string>();

            using (var reader = new StreamReader(InterfaceDefLocation))
            {
                var line = "";
                while ((line = reader.ReadLine()) != null)
                {
                    var nuss = nameWithChain;
                    if (line.StartsWith(nameWithChain))
                    {
                        interfacesList.Add(line.Substring(7));
                    }
                }
            }
            foreach (var interfaceEntry in interfacesList)
            {
                var node = trimmedGraph.Nodes.FirstOrDefault(n => n.Data.Residue.Id.Equals(interfaceEntry));
                if (node != null)
                {
                    node.Data.ReferenceLabel = 1;
                }
            }

            //test
            if (GraphVisualization)
            {
                var graph3D = trimmedGraph.Wrap3D(nd => new Node3DWrap <ResidueNodeData>(nd.Data)
                {
                    ReferenceLabel = nd.Data.ReferenceLabel, X = nd.Data.X, Y = nd.Data.Y, Z = nd.Data.Z
                });
                new ShowGraph3D(graph3D).Request(RequestRunType.Background);
                Thread.Sleep(120000);
            }

            var crfGraph = trimmedGraph.Convert <ResidueNodeData, CRFNodeData, SimpleEdgeData, CRFEdgeData,
                                                 ProteinGraphData, CRFGraphData>(nd => new CRFNodeData(nd.Data.Residue.Id)
            {
                X = nd.Data.X, Y = nd.Data.Y, Z = nd.Data.Z, ReferenceLabel = nd.Data.ReferenceLabel, Characteristics = new double[] { nd.Data.ZScore }
            }, ed => new CRFEdgeData(),
                                                                                 gd => new CRFGraphData());

            //crfGraph.SaveAsJSON("testGraph.txt");

            crfGraph.Data.ReferenceLabeling = new int[crfGraph.Nodes.Count()];

            foreach (var node in crfGraph.Nodes)
            {
                crfGraph.Data.ReferenceLabeling[node.GraphId] = node.Data.ReferenceLabel;
            }

            if (GraphVisualization == true)
            {
                var graph3D = crfGraph.Wrap3D(nd => new Node3DWrap <CRFNodeData>(nd.Data)
                {
                    ReferenceLabel = nd.Data.ReferenceLabel, X = nd.Data.X, Y = nd.Data.Y, Z = nd.Data.Z
                }, (ed) => new Edge3DWrap <CRFEdgeData>(ed.Data)
                {
                    Weight = 1.0
                });
                new ShowGraph3D(graph3D).Request();
            }

            return(crfGraph);
        }