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);
        }