Skip to content

Commit 35f3207

Browse files
author
Walker Pett
committed
Reverting last several commits
1 parent c82dd7e commit 35f3207

30 files changed

+211
-467
lines changed

.gitignore

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
*.o
22
*.d
33
data/
4-
.project
5-
.cproject
6-
.settings/

sources/AACodonMutSelFinitePhyloProcess.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -314,12 +314,12 @@ class AACodonMutSelFinitePhyloProcess : public virtual AACodonMutSelFiniteSubsti
314314
chronosuffstat.Stop();
315315

316316
chronounfold.Start();
317-
bool err = GlobalUnfold();
317+
GlobalUnfold();
318318
chronounfold.Stop();
319319

320320
chronototal.Stop();
321321
//cerr << "ok\n";
322-
return err;
322+
return 1;
323323
}
324324

325325

sources/AACodonMutSelSBDPPhyloProcess.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -328,12 +328,12 @@ class AACodonMutSelSBDPPhyloProcess : public virtual AACodonMutSelSBDPSubstituti
328328
//cerr << "GlobalUnfold\n";
329329
//cerr.flush();
330330
chronounfold.Start();
331-
bool err = GlobalUnfold();
331+
GlobalUnfold();
332332
chronounfold.Stop();
333333

334334
chronototal.Stop();
335335
//cerr << "ok\n";
336-
return err;
336+
return 1;
337337
}
338338

339339

sources/AAMutSelDPPhyloProcess.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,9 @@ class AAMutSelDPPhyloProcess : public virtual AAMutSelDPSubstitutionProcess, pub
241241
AAMutSelDPProfileProcess::Move(tuning,1,10);
242242
chronototal.Stop();
243243
chronosuffstat.Stop();
244-
bool err = GlobalUnfold();
244+
GlobalUnfold();
245245
//cerr << "ok\n";
246-
return err;
246+
return 1;
247247
}
248248

249249

sources/AAMutSelFinitePhyloProcess.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,12 @@ class AAMutSelFinitePhyloProcess : public virtual AAMutSelFiniteSubstitutionProc
271271
chronosuffstat.Stop();
272272

273273
chronounfold.Start();
274-
bool err = GlobalUnfold();
274+
GlobalUnfold();
275275
chronounfold.Stop();
276276

277277
chronototal.Stop();
278278
//cerr << "ok\n";
279-
return err;
279+
return 1;
280280
}
281281

282282

sources/AAMutSelSBDPPhyloProcess.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,12 @@ class AAMutSelSBDPPhyloProcess : public virtual AAMutSelSBDPSubstitutionProcess,
266266
chronosuffstat.Stop();
267267

268268
chronounfold.Start();
269-
bool err = GlobalUnfold();
269+
GlobalUnfold();
270270
chronounfold.Stop();
271271

272272
chronototal.Stop();
273273
//cerr << "ok\n";
274-
return err;
274+
return 1;
275275
}
276276

277277

sources/CodonMutSelFinitePhyloProcess.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,12 @@ class CodonMutSelFinitePhyloProcess : public virtual CodonMutSelFiniteSubstituti
296296
chronosuffstat.Stop();
297297

298298
chronounfold.Start();
299-
bool err = GlobalUnfold();
299+
GlobalUnfold();
300300
chronounfold.Stop();
301301

302302
chronototal.Stop();
303303
//cerr << "ok\n";
304-
return err;
304+
return 1;
305305
}
306306

307307

sources/CodonMutSelSBDPPhyloProcess.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,12 @@ class CodonMutSelSBDPPhyloProcess : public virtual CodonMutSelSBDPSubstitutionPr
277277
chronosuffstat.Stop();
278278

279279
chronounfold.Start();
280-
bool err = GlobalUnfold();
280+
GlobalUnfold();
281281
chronounfold.Stop();
282282

283283
chronototal.Stop();
284284
//cerr << "ok\n";
285-
return err;
285+
return 1;
286286
}
287287

288288

sources/GeneralPathSuffStatMatrixPhyloProcess.cpp

+3-29
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,7 @@ void GeneralPathSuffStatMatrixPhyloProcess::Unfold() {
4545
CreateCondSiteLogL();
4646
CreateConditionalLikelihoods();
4747

48-
MESSAGE signal = SUCCESS;
49-
try
50-
{
51-
UpdateConditionalLikelihoods();
52-
}
53-
catch(...)
54-
{
55-
signal = FAILURE;
56-
}
57-
MPI_Send(&signal,1,MPI_INT,0,TAG1,MPI_COMM_WORLD);
48+
UpdateConditionalLikelihoods();
5849
}
5950

6051
void GeneralPathSuffStatMatrixPhyloProcess::Collapse() {
@@ -76,7 +67,7 @@ void GeneralPathSuffStatMatrixPhyloProcess::Collapse() {
7667
CreateSuffStat();
7768
}
7869

79-
bool GeneralPathSuffStatMatrixPhyloProcess::GlobalUnfold() {
70+
void GeneralPathSuffStatMatrixPhyloProcess::GlobalUnfold() {
8071

8172
assert(myid == 0);
8273
DeleteSuffStat();
@@ -87,24 +78,7 @@ bool GeneralPathSuffStatMatrixPhyloProcess::GlobalUnfold() {
8778
MESSAGE signal = UNFOLD;
8879
MPI_Bcast(&signal,1,MPI_INT,0,MPI_COMM_WORLD);
8980

90-
bool fail = false;
91-
MPI_Status stat;
92-
for(int i = 1; i < nprocs; i++)
93-
{
94-
MPI_Recv(&signal,1,MPI_INT,i,TAG1,MPI_COMM_WORLD,&stat);
95-
fail = fail || (signal == FAILURE);
96-
}
97-
98-
if(fail)
99-
{
100-
//cerr << "warning: numerical error in pruning likelihood\n";
101-
}
102-
else
103-
{
104-
GlobalUpdateConditionalLikelihoods();
105-
}
106-
107-
return fail;
81+
GlobalUpdateConditionalLikelihoods();
10882
}
10983

11084

sources/GeneralPathSuffStatMatrixPhyloProcess.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class GeneralPathSuffStatMatrixPhyloProcess : public virtual MatrixPhyloProcess,
5151
map<int,double>& GetSiteWaitingTime(int site) {return sitewaitingtime[site];}
5252

5353
// should also create the matrices
54-
bool GlobalUnfold();
54+
void GlobalUnfold();
5555
// void GlobalCollapse();
5656

5757
void CreateSuffStat();

sources/GeneralPathSuffStatRASCATGTRFiniteGammaPhyloProcess.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,14 @@ class GeneralPathSuffStatRASCATGTRFiniteGammaPhyloProcess : public virtual Gener
255255

256256

257257
// cerr << "unfold\n";
258-
int err = GlobalUnfold();
258+
GlobalUnfold();
259259
// cerr << "unfold ok\n";
260260

261261
chronototal.Stop();
262262

263263
// Trace(cerr);
264264

265-
return err;
265+
return 1;
266266
}
267267

268268
double LengthRelRateMove(double tuning, int nrep) {

sources/GeneralPathSuffStatRASCATGTRSBDPGammaPhyloProcess.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -270,14 +270,14 @@ class GeneralPathSuffStatRASCATGTRSBDPGammaPhyloProcess : public virtual General
270270

271271

272272
// cerr << "unfold\n";
273-
int err = GlobalUnfold();
273+
GlobalUnfold();
274274
// cerr << "unfold ok\n";
275275

276276
chronototal.Stop();
277277

278278
// Trace(cerr);
279279

280-
return err;
280+
return 1;
281281
}
282282

283283
void ToStreamHeader(ostream& os) {

sources/MatrixPhyloProcess.cpp

+20-18
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,30 @@ along with PhyloBayes. If not, see <http://www.gnu.org/licenses/>.
2424

2525

2626
void MatrixPhyloProcess::Unfold() {
27-
27+
if (condflag) {
28+
cerr << "error in PhyloProcess::Unfold\n";
29+
exit(1);
30+
}
31+
/*
32+
static bool first = true;
33+
if (first) {
34+
first = false;
35+
}
36+
else {
37+
DeleteSuffStat();
38+
}
39+
*/
2840
DeleteSuffStat();
2941
DeleteMappings();
42+
ActivateSumOverRateAllocations();
3043

31-
if (!condflag) {
32-
ActivateSumOverRateAllocations();
33-
34-
CreateMatrices();
44+
CreateMatrices();
3545

36-
CreateCondSiteLogL();
37-
CreateConditionalLikelihoods();
38-
}
46+
// UpdateSubstitutionProcess();
3947

40-
MESSAGE signal = SUCCESS;
41-
try
42-
{
43-
UpdateConditionalLikelihoods();
44-
}
45-
catch(...)
46-
{
47-
signal = FAILURE;
48-
}
49-
MPI_Send(&signal,1,MPI_INT,0,TAG1,MPI_COMM_WORLD);
48+
CreateCondSiteLogL();
49+
CreateConditionalLikelihoods();
50+
UpdateConditionalLikelihoods();
5051
}
5152

5253
void MatrixPhyloProcess::UpdateConditionalLikelihoods() {
@@ -62,6 +63,7 @@ void MatrixPhyloProcess::UpdateConditionalLikelihoods() {
6263
// CheckLikelihood();
6364
}
6465

66+
6567
void MatrixPhyloProcess::Collapse() {
6668

6769
if (! condflag) {

sources/Model.h

+13-50
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ along with PhyloBayes. If not, see <http://www.gnu.org/licenses/>.
3535
#include "Parallel.h"
3636
#include <iostream>
3737
#include <fstream>
38-
#include <limits>
3938

4039
using namespace std;
4140

@@ -182,16 +181,9 @@ class Model {
182181
}
183182

184183
process->SetTopoBurnin(topoburnin);
185-
process->SetErrorHandling(true);
186-
187-
if(myid == 0 && nprocs > process->GetNsite())
188-
{
189-
cerr << "error: More processors than sites";
190-
exit(1);
191-
}
192184
}
193185

194-
Model(string inname, int myid, int nprocs, bool catch_errors) {
186+
Model(string inname, int myid, int nprocs) {
195187

196188
name = inname;
197189

@@ -259,13 +251,6 @@ class Model {
259251
// cerr << "RESTORE SETSIZE\n";
260252
process->SetSize(size);
261253
// cerr << "reset size to " << process->GetSize() << '\n';
262-
process->SetErrorHandling(catch_errors);
263-
264-
if(myid == 0 && nprocs > process->GetNsite())
265-
{
266-
cerr << "error: More processors than sites";
267-
exit(1);
268-
}
269254
}
270255

271256
void ToStream(ostream& os, bool header) {
@@ -286,22 +271,12 @@ class Model {
286271
process->WaitLoop();
287272
}
288273

289-
void Move(double tuning, int nrep) {
274+
double Move(double tuning, int nrep) {
275+
double total = 0;
290276
for (int rep=0; rep<nrep; rep++) {
291-
stringstream backup;
292-
process->ToStream(backup);
293-
while(process->Move(tuning))
294-
{
295-
//cerr << "warning: numerical error in move, retrying...\n";
296-
backup.clear();
297-
backup.seekg(0);
298-
process->FromStream(backup);
299-
MESSAGE signal = BCAST_TREE;
300-
MPI_Bcast(&signal,1,MPI_INT,0,MPI_COMM_WORLD);
301-
process->GlobalBroadcastTree();
302-
process->GlobalUnfold();
303-
}
277+
total += process->Move(tuning);
304278
}
279+
return total / nrep;
305280
}
306281

307282
int RunningStatus() {
@@ -317,16 +292,14 @@ class Model {
317292
}
318293

319294
void Run(int burnin) {
320-
stringstream ss;
321295

322296
if (burnin != 0) {
323297
if (GetSize() < burnin) {
324298
process->SetBurnin(true);
325299
}
326300
}
327301
ofstream ros((name + ".run").c_str());
328-
ss << 1 << '\n';
329-
ros << ss.str();
302+
ros << 1 << '\n';
330303
ros.close();
331304

332305
while (RunningStatus() && ((until == -1) || (GetSize() < until))) {
@@ -341,37 +314,27 @@ class Model {
341314
ofstream os((name + ".treelist").c_str(), ios_base::app);
342315
process->SetNamesFromLengths();
343316
process->RenormalizeBranchLengths();
344-
ss.str("");
345-
GetTree()->ToStream(ss);
317+
GetTree()->ToStream(os);
346318
process->DenormalizeBranchLengths();
347-
os << ss.str();
348319
os.close();
349320

350321
ofstream tos((name + ".trace").c_str(), ios_base::app);
351-
ss.str("");
352-
Trace(ss);
353-
tos << ss.str();
322+
Trace(tos);
354323
tos.close();
355324

356325
ofstream mos((name + ".monitor").c_str());
357-
ss.str("");
358-
process->Monitor(ss);
359-
mos << ss.str();
326+
process->Monitor(mos);
360327
mos.close();
361328

362329
ofstream pos((name + ".param").c_str());
363-
pos.precision(numeric_limits<double>::digits10);
364-
ss.str("");
365-
ToStream(ss,true);
366-
pos << ss.str();
330+
pos.precision(12);
331+
ToStream(pos,true);
367332
pos.close();
368333

369334
if (saveall) {
370335
ofstream cos((name + ".chain").c_str(),ios_base::app);
371-
cos.precision(numeric_limits<double>::digits10);
372-
ss.str("");
373-
ToStream(ss,false);
374-
cos << ss.str();
336+
cos.precision(12);
337+
ToStream(cos,false);
375338
cos.close();
376339
}
377340

0 commit comments

Comments
 (0)