-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrmtgnet.cpp
134 lines (122 loc) · 3.58 KB
/
rmtgnet.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#include "rmtgnet.h"
#include <mcheck.h>
/**
* Prints the command-line usage instructions for the similarity command
*/
void print_usage() {
printf("\n");
printf("Usage: ./rmtgnet [command]\n");
printf("Available commands:\n");
printf(" similarity Performs pair-wise similarity calculations using an input expression matrix.\n");
printf(" threshold Identifies a threshold for cutting the similarity matrix\n");
printf(" extract Outputs the network edges file\n");
printf(" help Prints these instructions. Include the command to print help\n");
printf(" for a specific command (e.g. rmtgnet help similarity)\n");
printf("\n");
}
/**
* The main subroutine. Parses the input parameters and executes the program
* accordingly.
*/
int main(int argc, char *argv[]) {
// Enable mtrace memory leak checking
//mtrace();
// The return value
int retval = 0;
// make sure we have at least one input argument for the command
if (argc == 1) {
printf("ERROR: Please provide the command to execute.\n\n");
print_usage();
retval = -1;
}
// construct the similarity matrix
else if (strcmp(argv[1], "similarity") == 0) {
RunSimilarity * similarity = new RunSimilarity(argc, argv);
similarity->execute();
delete similarity;
}
// identify the threshold for cutting the similarity matrix
else if (strcmp(argv[1], "threshold") == 0) {
RunThreshold * threshold = new RunThreshold(argc, argv);
threshold->execute();
delete threshold;
}
// extract a given element from the matrix or a network
else if (strcmp(argv[1], "extract") == 0) {
RunExtract * extract = new RunExtract(argc, argv);
extract->execute();
delete extract;
}
// print help documentation
else if (strcmp(argv[1], "help") == 0) {
if (argc == 3) {
if (strcmp(argv[2], "similarity") == 0) {
RunSimilarity::printUsage();
}
if (strcmp(argv[2], "threshold") == 0) {
RunThreshold::printUsage();
}
if (strcmp(argv[2], "extract") == 0) {
RunExtract::printUsage();
}
}
else {
print_usage();
}
}
else {
printf("ERROR: Unknown command.\n\n");
print_usage();
retval = -1;
}
return retval;
}
/**
*
*/
void start_mpi() {
// // MPI variables
// int mpi_err, mpi_num_procs, mpi_id;
//
// // Initialize MPI.
// mpi_err = MPI_Init(&argc, &argv);
//
// // Find out my process ID, and how many processes were started.
// mpi_err |= MPI_Comm_rank(MPI_COMM_WORLD, &mpi_id);
// mpi_err |= MPI_Comm_size(MPI_COMM_WORLD, &mpi_num_procs);
//
// if (mpi_err != 0) {
// printf("MPI initialization failed\n");
// exit(1);
// }
// For testing a single process... should comment out when not testing.
// if (mpi_id + 1 != 5) {
// mpi_err = MPI_Finalize();
// return 1;
// }
// printf("Using %i out of %i processes.\n", mpi_id + 1, mpi_num_procs);
}
/**
*
*/
void end_mpi() {
// Wait until all other processes are completed before closing the manager
// MPI_Status stat;
// char message[10];
// if (mpi_id > 0 ) {
// // All non master processes should report done when completed.
// sprintf(message, "Done");
// MPI_Send(message, strlen(message)+1, MPI_BYTE, 0,1,MPI_COMM_WORLD);
// }
// else {
// // The master process should wait to get 'Done' from each process
// // before terminating
// int proc;
// for (proc = 1; proc < mpi_num_procs; proc++) {
// MPI_Recv(message, sizeof(message), MPI_BYTE, proc, 1, MPI_COMM_WORLD, &stat);
// }
// }
//
// // Terminate MPI.
// mpi_err = MPI_Finalize();
}