forked from ahmadia/homebrew-science
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgarli.rb
166 lines (142 loc) · 6.03 KB
/
garli.rb
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
class Garli < Formula
desc "genetic algorithm for rapid likelihood inference of phylogenies"
homepage "https://code.google.com/p/garli/"
url "https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/garli/garli-2.01.tar.gz"
sha256 "e7fd4c115f9112fd9a019dcb6314e3a9d989f56daa0f833a28dc8249e50988ef"
revision 2
# tag "bioinformatics"
bottle :disable, "needs to be rebuilt with latest open-mpi"
option "with-brewed-ncl", "Use Homebrew's NCL instead of building a separate copy"
depends_on "ncl" if build.with? "brewed-ncl"
depends_on :mpi => :recommended
# Fix template instantiation errors by making GCC infer types rather than
# explicitly specifying the types. Patch emailed to upstream 12-Jun-2016.
patch :DATA
fails_with :clang do
build 703
cause "error: invalid operands to binary expression ('const ReconNode' and 'const ReconNode')"
end
def install
# Garli needs to link to NCL, which Homebrew provides. However Garli
# needs NCL to be built with the same compiler and very specific build
# options. Since Garli *must* be built with GCC (see `fails_with` block)
# and brewed NCL is built with Clang, we build our own copy in `libexec`.
#
# Example visibility issues with mismatched Garli/NCL builds:
#
# Undefined symbols for architecture x86_64:
# "non-virtual thunk to NxsCharactersBlock::GetMaxIndex() const", referenced from:
# vtable for NxsCharactersBlock in adaptation.o
# vtable for NxsCharactersBlock in condlike.o
# ...
#
# ld: symbol(s) not found for architecture x86_64
# collect2: error: ld returned 1 exit status
args = %W[--disable-dependency-tracking --prefix=#{prefix}]
args.push "--enable-mpi" if build.with? "mpi"
if build.with? "brewed-ncl"
args.push "--with-ncl=#{Formula["ncl"].opt_prefix}"
else
args.push "--with-ncl=#{libexec}/ncl"
system "tar", "xf", "ncl-2.1.18.tar.gz"
cd "ncl-2.1.18" do
system "./configure", "--prefix=#{libexec}/ncl", "--disable-shared", "--enable-static", "CXXFLAGS=-DNCL_CONST_FUNCS"
system "make", "install"
end
end
system "./configure", *args
system "make", "install"
pkgshare.install "doc"
pkgshare.install "example"
end
def caveats; <<-EOS.undent
The manual and examples have been installed to:
#{opt_pkgshare}/doc
#{opt_pkgshare}/example
EOS
end
test do
system "#{bin}/Garli", "--version"
(testpath/"aln.phy").write <<-EOS.undent
10 60
Cow ATGGCATATCCCATACAACTAGGATTCCAAGATGCAACATCACCAATCATAGAAGAACTA
Carp ATGGCACACCCAACGCAACTAGGTTTCAAGGACGCGGCCATACCCGTTATAGAGGAACTT
Chicken ATGGCCAACCACTCCCAACTAGGCTTTCAAGACGCCTCATCCCCCATCATAGAAGAGCTC
Human ATGGCACATGCAGCGCAAGTAGGTCTACAAGACGCTACTTCCCCTATCATAGAAGAGCTT
Loach ATGGCACATCCCACACAATTAGGATTCCAAGACGCGGCCTCACCCGTAATAGAAGAACTT
Mouse ATGGCCTACCCATTCCAACTTGGTCTACAAGACGCCACATCCCCTATTATAGAAGAGCTA
Rat ATGGCTTACCCATTTCAACTTGGCTTACAAGACGCTACATCACCTATCATAGAAGAACTT
Seal ATGGCATACCCCCTACAAATAGGCCTACAAGATGCAACCTCTCCCATTATAGAGGAGTTA
Whale ATGGCATATCCATTCCAACTAGGTTTCCAAGATGCAGCATCACCCATCATAGAAGAGCTC
Frog ATGGCACACCCATCACAATTAGGTTTTCAAGACGCAGCCTCTCCAATTATAGAAGAATTA
;
end;
EOS
cp pkgshare/"example"/"basic"/"garli.conf.nuc.test", testpath/"garli.conf"
inreplace "garli.conf", "zakonEtAl2006.11tax.nex", "aln.phy"
if build.with? "mpi"
system "mpirun", "-np", "2", "#{bin}/Garli", "-2"
else
system "#{bin}/Garli", "-1"
end
end
end
__END__
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 597d8c0..5257dba 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -21,6 +21,7 @@
#include <iostream>
#include <limits.h>
#include <math.h>
+#include <utility>
using namespace std;
@@ -635,6 +636,6 @@ void ConfigReader::MakeAllSection(){
map<std::string, std::string> ops = sections["general"];
ops.insert(sections["master"].begin(), sections["master"].end());
string name="all";
- sections.insert(make_pair<std::string, Options>(name, ops));
+ sections.insert(make_pair(name, ops));
}
diff --git a/src/tree.cpp b/src/tree.cpp
index c9d3017..29c2406 100644
--- a/src/tree.cpp
+++ b/src/tree.cpp
@@ -8365,7 +8365,7 @@ pair<FLOAT_TYPE, FLOAT_TYPE> Tree::OptimizeSingleSiteTreeScale(FLOAT_TYPE optPre
#endif
if(FloatingPointEquals(lnL, ZERO_POINT_ZERO, max(1.0e-8, GARLI_FP_EPS * 2.0))){
- return make_pair<FLOAT_TYPE, FLOAT_TYPE>(-ONE_POINT_ZERO, ZERO_POINT_ZERO);
+ return make_pair(-ONE_POINT_ZERO, ZERO_POINT_ZERO);
}
int pass=1;
@@ -8396,7 +8396,7 @@ pair<FLOAT_TYPE, FLOAT_TYPE> Tree::OptimizeSingleSiteTreeScale(FLOAT_TYPE optPre
Score();
FLOAT_TYPE s = lnL/siteCount;
ScaleWholeTree(1.0/1.1);
- if(fabs(prev - s) < max(1.0e-8, GARLI_FP_EPS * 2.0)) return make_pair<FLOAT_TYPE, FLOAT_TYPE>(-ONE_POINT_ZERO, prev);
+ if(fabs(prev - s) < max(1.0e-8, GARLI_FP_EPS * 2.0)) return make_pair(-ONE_POINT_ZERO, prev);
}
scale=ONE_POINT_ZERO + incr;
@@ -8416,7 +8416,7 @@ pair<FLOAT_TYPE, FLOAT_TYPE> Tree::OptimizeSingleSiteTreeScale(FLOAT_TYPE optPre
if(estImprove < optPrecision && d2 < ZERO_POINT_ZERO){
ScaleWholeTree(ONE_POINT_ZERO/effectiveScale);
//cout << pass << endl;
- return make_pair<FLOAT_TYPE, FLOAT_TYPE>(effectiveScale, prev);
+ return make_pair(effectiveScale, prev);
}
if(d2 < ZERO_POINT_ZERO){
@@ -8445,13 +8445,13 @@ pair<FLOAT_TYPE, FLOAT_TYPE> Tree::OptimizeSingleSiteTreeScale(FLOAT_TYPE optPre
scale=t;
effectiveScale *= scale;
- if(effectiveScale > 100.0) return make_pair<FLOAT_TYPE, FLOAT_TYPE>(100.0, prev);
+ if(effectiveScale > 100.0) return make_pair(100.0, prev);
ScaleWholeTree(scale);
if(effectiveScale < 1e-4){
//The rate is essentially zero. Invariant sites should be getting caught
//before even calling this func, so this probably won't be visited
ScaleWholeTree(1.0/effectiveScale);
- return make_pair<FLOAT_TYPE, FLOAT_TYPE>(effectiveScale, prev);
+ return make_pair(effectiveScale, prev);
}
Score();