Static Public Member Functions | |
static string | usage () |
static string | extractFileName (const string &path) |
static void | printMatrix (double **matrix, int size, vector< string > moleculesName, ostream &os) |
static int | main (int argc, char **argv) |
Este es el programa principal, el cual a través paráetros de la línea de comandos permite generar la matriz de similaridad para un conjunto dado de moleculas, listadas en un archivo
Fecha de creación : 2007-03-18
Definition at line 48 of file TARIS-Matrices.cpp.
static string Programs::TARIS_Matrices::usage | ( | ) | [inline, static] |
Definition at line 50 of file TARIS-Matrices.cpp.
Referenced by main().
00051 { 00052 system("clear") ; 00053 return 00054 "============================\n" 00055 "TARIS-Matrices (" __DATE__ ")\n" 00056 "============================\n" 00057 "\n" 00058 "Produces a text file containing distance and similiraty matrices\n" 00059 "for a given set of molecules, taking as parameters a text file with \n" 00060 "the list of .cube files for each molecule, the initial cutoff, the \n" 00061 "final cutoff and the step-size for the scan\n" 00062 "\n" 00063 "Syntax:\n" 00064 " $ TARIS-Matrices -i list [PARAMETERS]\n" 00065 "\n" 00066 "Required parameters:\n" 00067 " -i list\n" 00068 " This is the name of the file containing the name of the\n" 00069 " cube/gml files to be analyzed\n" 00070 "\n" 00071 "Optional parameters:\n" 00072 " -t format\n" 00073 " Specifies the input data type: cube or gml files\n" 00074 " (default=cube)\n" 00075 " -b cutoffBegin\n" 00076 " Initial cutoff for the scan\n" 00077 " (default=-0.1)\n" 00078 " -e cutoffEnd\n" 00079 " Final cutoff for the scan\n" 00080 " (default=-0.07)\n" 00081 " -s stepSize\n" 00082 " Step-size for the scan\n" 00083 " (default=-0.005)\n" 00084 " -m type\n" 00085 " Type of matrix to be generated: distance, similarity or both\n" 00086 " (default=both)\n" 00087 " -o output\n" 00088 " Name of the output file\n" 00089 " (default=screen)\n" 00090 "\n" 00091 "For example:\n" 00092 " Generating matrices from .cube files\n" 00093 " $ find . -name \"*.cube\" > list\n" 00094 " $ TARIS-Matrices -i list -o matrices.dat\n" 00095 " Generating matrices from .gml files\n" 00096 " $ find . -name \"*.gml\" > list\n" 00097 " $ TARIS-Matrices -i list -type gml -o matrices.dat\n" 00098 "\n" 00099 "Authors:\n" 00100 " Nestor F. Aguirre, Ray M. Marin and Edgar E. Daza\n" 00101 " Universidad Nacional de Colombia\n" 00102 ; 00103 }
static string Programs::TARIS_Matrices::extractFileName | ( | const string & | path | ) | [inline, static] |
Definition at line 105 of file TARIS-Matrices.cpp.
Referenced by main(), and printMatrix().
00106 { 00107 char pathTMP[256] ; 00108 strcpy( pathTMP, path.c_str() ) ; 00109 vector<string> tokens ; 00110 00111 char* pch = strtok( pathTMP, "/." ); 00112 while( pch != NULL ) 00113 { 00114 tokens.push_back( pch ) ; 00115 pch = strtok( NULL, "/." ); 00116 } 00117 00118 return tokens[ tokens.size() - 2 ] ; 00119 }
static void Programs::TARIS_Matrices::printMatrix | ( | double ** | matrix, | |
int | size, | |||
vector< string > | moleculesName, | |||
ostream & | os | |||
) | [inline, static] |
Definition at line 121 of file TARIS-Matrices.cpp.
References extractFileName().
Referenced by main().
00122 { 00123 os.setf( ios::fixed ) ; 00124 os.precision(6) ; 00125 00126 string filename ; 00127 int spaceForName = 15 ; 00128 00129 for (int i = 0; i< size; i++){ 00130 00131 filename = extractFileName( moleculesName[i] ) ; 00132 00133 if( filename.length() <= spaceForName ){ 00134 os << setw(spaceForName) << extractFileName( moleculesName[i] ) << " :\t" ; 00135 }else{ 00136 os << setw(spaceForName-3) << extractFileName( moleculesName[i] ).substr(0, spaceForName-3) << "... :\t" ; 00137 } 00138 00139 for (int j = 0; j< size; j++){ 00140 os << setw(12) << matrix[i][j] ; 00141 } 00142 os << endl ; 00143 } 00144 }
static int Programs::TARIS_Matrices::main | ( | int | argc, | |
char ** | argv | |||
) | [inline, static] |
Definition at line 146 of file TARIS-Matrices.cpp.
References HyperSurface::buildAreaTree(), Tree::distance(), extractFileName(), TarisApplication::extractParameter(), HyperSurface::load(), printMatrix(), and usage().
Referenced by main().
00147 { 00148 00149 if( argc > 1 ){ 00150 00151 string cubeList = TarisApplication::extractParameter( argc, argv, "-i" ) ; 00152 string type = TarisApplication::extractParameter( argc, argv, "-t", "cube" ) ; 00153 double cutoffBegin = atof( TarisApplication::extractParameter( argc, argv, "-b", "-0.1" ) ) ; 00154 double cutoffEnd = atof( TarisApplication::extractParameter( argc, argv, "-e", "-0.07" ) ) ; 00155 double stepSize = atof( TarisApplication::extractParameter( argc, argv, "-s", "0.005" ) ) ; 00156 string matrix = TarisApplication::extractParameter( argc, argv, "-m", "both" ) ; 00157 string outputFileName = TarisApplication::extractParameter( argc, argv, "-o", "screen" ) ; 00158 00159 ifstream file( cubeList.c_str() ) ; 00160 00161 //Este arreglo contiene los nombres de las moleculas 00162 vector< string > moleculesName ; 00163 string filenameTMP ; 00164 00165 while( !file.eof() ) { 00166 00167 file >> filenameTMP ; 00168 moleculesName.push_back( filenameTMP ) ; 00169 } 00170 00171 int size = moleculesName.size() - 1 ; 00172 00173 //Se crea la matriz de distancias 00174 double** distance = new double*[ size ]; 00175 for (int i = 0; i< size; i++){ 00176 distance[i] = new double[ size ] ; 00177 } 00178 00179 //Se crea la matriz de similitud 00180 double** similarity = new double*[ size ]; 00181 for (int i = 0; i< size; i++){ 00182 similarity[i] = new double[ size ] ; 00183 } 00184 00185 vector<Tree> treeVector ; 00186 00187 if( type == "cube" ){ 00188 00189 HyperSurface hs ; 00190 /******************************************************* 00191 * Se genera el arbol de cada molecula y se guarda en 00192 * un vector de arboles treeVector 00193 */ 00194 for (int i=0 ; i<size; i++){ 00195 cout << "BUILDING TREE FOR: (" << i + 1 << ") " << extractFileName( moleculesName[i] ) << endl ; 00196 hs.load( moleculesName[i] ) ; 00197 treeVector.push_back( hs.buildAreaTree( cutoffBegin, cutoffEnd, stepSize ) ) ; 00198 } 00199 00200 }else if( type == "gml" ){ 00201 00202 // Tree treeTMP ; 00203 00204 /******************************************************* 00205 * Se carga el arbol de cada molecula y se guarda en 00206 * un vector de arboles treeVector 00207 */ 00208 for (int i=0 ; i<size; i++){ 00209 Tree treeTMP ; 00210 treeTMP.load( moleculesName[i] ) ; 00211 treeVector.push_back( treeTMP ) ; 00212 // treeTMP.clear() ; 00213 } 00214 00215 }else{ 00216 cout << "Ilegal value for parameter -type; please use \"cube\" or \"gml\"" << endl ; 00217 exit(-1) ; 00218 } 00219 00220 cout << endl ; 00221 cout << "GENERATING DISTANCE MATRIX ... " ; 00222 00223 double max = 0.0 ; 00224 00225 // Se calcula la matriz de distancia 00226 for (int i = 0; i< size; i++){ 00227 00228 if ( i < size-1 ) { 00229 00230 for (int j = i+1; j< size; j++){ 00231 00232 distance[i][j] = Tree::distance( treeVector[i], treeVector[j] ) ; 00233 distance[j][i] = distance[i][j] ; 00234 if(distance[i][j] > max){ 00235 max = distance[i][j] ; 00236 } 00237 } 00238 } 00239 } 00240 00241 cout << "OK" << endl ; 00242 cout << "GENERATING SIMILARITY PERCENTAGE MATRIX ... " ; 00243 00244 // Se calcula la matriz de similitud 00245 if (max >= 1e-6){ 00246 for (int i = 0; i< size; i++){ 00247 for (int j = 0; j< size; j++){ 00248 similarity[i][j] = ( 1-(distance[i][j] / max)) *100.0 ; 00249 } 00250 } 00251 }else{ 00252 for (int i = 0; i< size; i++){ 00253 for (int j = 0; j< size; j++){ 00254 similarity[i][j] = 100.0 ; 00255 } 00256 } 00257 } 00258 00259 cout << "OK" << endl ; 00260 cout << endl ; 00261 00262 if( outputFileName.compare("screen") == 0 ){ 00263 00264 if( matrix.compare("distance") == 0 || matrix.compare("both") == 0 ){ 00265 cout << "DISTANCE MATRIX 'D'" << endl ; 00266 cout << "-------------------" << endl ; 00267 00268 printMatrix( distance, size, moleculesName, cout ) ; 00269 cout << endl ; 00270 cout << "THE MAXIMUM DISTANCE IS: " << max << endl ; 00271 cout << endl ; 00272 } 00273 00274 if( matrix.compare("similarity") == 0 || matrix.compare("both") == 0 ){ 00275 cout << "SIMILARITY PERCENTAGE MATRIX 'S'" << endl ; 00276 cout << "--------------------------------" << endl ; 00277 00278 printMatrix( similarity, size, moleculesName, cout ) ; 00279 } 00280 00281 }else{ 00282 ofstream file( outputFileName.c_str() ) ; 00283 00284 if( matrix.compare("distance") == 0 || matrix.compare("both") == 0 ){ 00285 file << "DISTANCE MATRIX 'D'" << endl ; 00286 file << "-------------------" << endl ; 00287 00288 printMatrix( distance, size, moleculesName, file ) ; 00289 file << endl ; 00290 file << "THE MAXIMUM DISTANCE IS: " << max << endl ; 00291 file << endl ; 00292 } 00293 00294 if( matrix.compare("similarity") == 0 || matrix.compare("both") == 0 ){ 00295 file << "SIMILARITY PERCENTAGE MATRIX 'S'" << endl ; 00296 file << "--------------------------------" << endl ; 00297 00298 printMatrix( similarity, size, moleculesName, file ) ; 00299 } 00300 00301 file.close() ; 00302 } 00303 00304 }else{ 00305 cout << usage() << endl ; 00306 } 00307 00308 return EXIT_SUCCESS; 00309 }