-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqtmain.cpp
More file actions
91 lines (85 loc) · 2.77 KB
/
qtmain.cpp
File metadata and controls
91 lines (85 loc) · 2.77 KB
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
//---------------------------------------------------------------------------
/*
TestNewickVector, GUI tool to test NewickVector
Copyright (C) 2011 Richel Bilderbeek
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolTestNewickVector.htm
//---------------------------------------------------------------------------
/// \mainpage TestNewickVector documentation
///
/// TestNewickVector, GUI tool to test NewickVector
///
/// Copyright (C) 2010 Richel Bilderbeek\n
/// programmed at the 4th September of 2010\n
/// From http://www.richelbilderbeek.nl/ToolTestTwoNewickVector.htm\n
/// Licenced under GPL 3.0\n
///
/// \author Richel Bilderbeek
/// \version 2.0
/// \date 2011-02-21
///
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#include <iomanip>
#include <QApplication>
#include "qttestnewickvectordialog.h"
#include "newick.h"
#include "newickvector.h"
#pragma GCC diagnostic pop
int main(int argc, char *argv[])
{
if (argc == 1)
{
QApplication a(argc, argv);
ribi::QtTestNewickVectorDialog w;
w.show();
return a.exec();
}
if (argc != 3)
{
std::cout
<< "Incorrect number of arguments:\n"
<< '\n'
<< "No arguments: start GUI version:\n"
<< " " << argv[0] << '\n'
<< "Two arguments: start command-line version:\n"
<< " - newick\n"
<< " - theta\n"
<< " \'" << argv[0] << " (2,(2,2)) " << (5.0 / 2.0) << "\'";
return 1;
}
const std::string newick = argv[1];
if (!ribi::newick::IsNewick(newick))
{
std::cout
<< "Invalid Newick format. Use for example:\n"
<< " \'" << argv[0] << " (2,(2,2)) " << (5.0 / 2.0) << "\'\n";
return 1;
}
try
{
boost::lexical_cast<double>(argv[2]);
}
catch (boost::bad_lexical_cast&)
{
std::cout
<< "Invalid theta format. Use for example:\n"
<< " \'" << argv[0] << " (2,(2,2)) " << (5.0 / 2.0) << "\'\n";
return 1;
}
const double theta = boost::lexical_cast<double>(argv[2]);
const double p = ribi::CalculateProbabilityNewickVector(newick,theta);
std::cout << std::setprecision(99) << p << '\n';
return 0; //To satisfy the compiler
}