Biorithm  1.1
 All Classes Functions Variables Typedefs Friends
mcode.h
00001 /**************************************************************************
00002  * Copyright (c) 2002-2011 T. M. Murali                                   *
00003  * Copyright (c) 2007-2011 Naveed Massjouni                               *
00004  *                                                                        *
00005  * This file is part of Biorithm.                                         *
00006  *                                                                        *
00007  * Biorithm is free software: you can redistribute it and/or modify       *
00008  * it under the terms of the GNU General Public License as published by   *
00009  * the Free Software Foundation, either version 3 of the License, or      *
00010  * (at your option) any later version.                                    *
00011  *                                                                        *
00012  * Biorithm is distributed in the hope that it will be useful,            *
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of         *
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
00015  * GNU General Public License for more details.                           *
00016  *                                                                        *
00017  * You should have received a copy of the GNU General Public License      *
00018  * along with Biorithm.  If not, see <http://www.gnu.org/licenses/>.      *
00019  *                                                                        *
00020  **************************************************************************/
00021 
00028 #ifndef MCODE_H
00029 #define MCODE_H
00030 
00031 //#define DEBUG 0
00032 
00033 #include <algorithm>
00034 #include <iostream>
00035 #include <list>
00036 #include <map>
00037 #include <set>
00038 #include <string>
00039 #include <vector>
00040 
00041 #define WITH_GTEST 0
00042 #if WITH_GTEST
00043 #include "gtest/gtest_prod.h"
00044 #endif //WITH_GTEST
00045 
00046 #include "graph.h"
00047 using namespace  std;
00048 
00049 typedef MyNode Node;
00050 typedef MyNode::EdgeIterator EdgeIterator;
00051 typedef MyEdge Edge;
00052 typedef MyGraph Graph;
00053 typedef MyGraph::MyConstNodeIterator ConstNodeIterator;
00054 typedef MyNodeId NodeId; // string
00055 
00056 // Class: MCODE
00057 // This class implements the MCODE clustering algorithm.
00058 // G. D. Bader and C. W. Hogue, "An automated method for finding molecular complexes in large protein interaction networks." BMC Bioinformatics, vol. 4, no. 1, January 2003.
00059 class MCODE {
00060 
00061 #if WITH_GTEST
00062   // Declare friends so we can unit test private methods.
00063   FRIEND_TEST(MCODETest, TestDensity);
00064   FRIEND_TEST(MCODETest, TestMaxKCore);
00065   FRIEND_TEST(MCODETest, TestWeighNode);
00066 #endif // WITH_GTEST
00067 
00068 private:
00069         map<NodeId, double> nodeWeightsMap;
00070         list<NodeId> sortedNodes;
00071         set<NodeId> seenNodesSet;
00072 
00078   void maxKCore(const Graph& graph, int &k, Graph &kcore);
00079 
00086   void maxKCoreFaster(const Graph &graph, int &k, Graph &kcore);
00087 
00097         double weighNode(const Graph&, NodeId nodeId);
00098 
00104         void weighNodes(const Graph&);
00105 
00114         double computeDensity(const Graph&);
00115 
00122         set<NodeId> getNeighbours(const Graph& graph, NodeId nodeId);
00123 
00131         void findComplex(const Graph& graph, double vwp, NodeId nodeId,
00132                 set<NodeId>& complexNodes, double seedWeight);
00133 
00134 
00135 public:
00136 
00147   double computeGraphScore(const MyGraph &graph);
00148 
00178   vector<Graph> findComplexes(const Graph& graph, double vwp,
00179                               map< string, double> *nodeWeights = NULL);
00180 };
00181 
00182 #endif // MCODE_H
00183 
00184 // vim:fdm=indent:fdn=1
 All Classes Functions Variables Typedefs Friends