11 #include "geneorder.h"
12 #include "modelidentifier.h"
13 #include "genesorter.h"
14 #include "sortaction.h"
15 #include "genealgorithms.h"
18 int main(int argc, char** argv){
20 string ann = "default.ann";
22 bool detectModel = true;
23 bool onlyIdentify = false;
25 //Parse command line arguments
27 while ((opt = getopt(argc, argv, "im:n:h")) != -1) {
30 model = Model::modelFactory(optarg);
40 cout << "Usage: " << argv[0] << " [OPTION] [FILE]" << endl
41 << endl << " -m <model> Specifies which model to use for sorting: Whirl, X, Zipper, FatX or Cloud "
42 << endl << " -n <ann> Specifies which artificial neural network to use for identification. '" << ann << "' is used by default"
43 << endl << " -h Prints this help message"
45 << "With no FILE, or if FILE is '-', stdin will be used"
50 cerr << "Usage: " << argv[0] << " [-n <ann>] [-h] [FILE]" << endl;
58 if (optind == argc || *argv[optind] == '-'){
61 file.open(argv[optind]);
63 cerr << "Could not open file: '" << argv[optind] << "'" << endl;
69 //Parse the gene order permutation
71 copy(istream_iterator<int>(*in), istream_iterator<int>(),
73 GeneOrder go(g.begin(),g.end());
76 ModelIdentifier mi(ann);
77 priority_queue<pair<double,Model> > pq = mi.identify(go);
79 model = pq.top().second;
81 while (pq.size() > 0){
82 cout << "Model: " << pq.top().second.name() << " score: " << pq.top().first << endl;
85 cout << "Using model: " << model.name() << endl;
87 cout << "Distance: " << inversionDistance(go) << endl;
88 //copy(go.begin(), go.end(), ostream_iterator<int>(cout, " "));
96 GeneSorter::ActionList al = so.sort(go,model);
100 for (GeneSorter::ActionList::iterator sa = al.begin(); sa != al.end(); ++sa){
101 cout << "Action: " << sa->toString() << " model score: " << model.score(*sa,go) << endl;
102 score += model.score(*sa,go);
104 cout << "Avg score: " << score / al.size() << endl;