Commit a1a6de2f authored by mvalle's avatar mvalle
Browse files

Added print parameters.

Changed messages from Tree balancing.
Changed few BEB message formats.


git-svn-id: https://svn.vital-it.ch/svn/hp2c/trunk/Codeml_Variants/Fastcodeml@5328 95c5a404-1f88-0410-a6b0-c3f062b6f34a
parent 6ca0ee3e
......@@ -293,7 +293,7 @@ void BayesTest::computeBEB(const std::vector<double>& aVars, size_t aFgBranch, c
fh += codon_class_proportion[igrid*BEB_DIMS+k]*mPriors[iw[igrid*BEB_DIMS+k]*mNumSites+site];
if(fh < 1e-300)
{
if(mVerbose >= VERBOSE_ONLY_RESULTS) std::cerr << "strange: f[" << site << "] = " << fh << " very small." << std::endl;
if(mVerbose >= VERBOSE_ONLY_RESULTS) std::cerr << "Strange: f[" << site << "] = " << fh << " very small." << std::endl;
continue;
}
lnfXs[igrid] += log(fh)*site_multiplicity[site];
......@@ -328,7 +328,7 @@ void BayesTest::computeBEB(const std::vector<double>& aVars, size_t aFgBranch, c
// Print
if(mVerbose >= VERBOSE_ONLY_RESULTS)
{
std::cerr << "\n\nPosterior on the grid\n\n";
std::cerr << std::endl << "Posterior on the grid" << std::endl << std::endl;
const char* paras[5] = {"p0","p1","w0","w2","w3"};
for(unsigned int j=2; j < BEB_DIMS; ++j)
......@@ -339,7 +339,7 @@ void BayesTest::computeBEB(const std::vector<double>& aVars, size_t aFgBranch, c
std::cerr << std::endl;
}
std::cerr << "\nPosterior for p0-p1 (see the ternary graph)\n\n";
std::cerr << std::endl << "Posterior for p0-p1 (see the ternary graph)" << std::endl << std::endl;
double sum_postp0p1 = 0.;
for(unsigned int k=0; k<BEB_N1D*BEB_N1D; ++k)
......@@ -352,8 +352,7 @@ void BayesTest::computeBEB(const std::vector<double>& aVars, size_t aFgBranch, c
sum_postp0p1 += postp0p1[k];
}
std::cerr << std::endl;
std::cerr << "Sum of density on p0-p1 = " << std::setw(9) << std::setprecision(3) << sum_postp0p1 << std::endl << std::endl;
std::cerr << std::endl << "Sum of density on p0-p1 = " << std::setprecision(4) << sum_postp0p1 << std::endl << std::endl;
}
fX = log(fX)+scale2;
......@@ -385,7 +384,8 @@ void BayesTest::computeBEB(const std::vector<double>& aVars, size_t aFgBranch, c
{
fhk[codon_class] /= fh;
double t = log(fhk[codon_class]) + lnfXs[igrid]; /* t is log of term on grid */
// t is log of term on grid
double t = log(fhk[codon_class]) + lnfXs[igrid];
if(t > scale1 + 50)
{
// Change scale factor scale1
......@@ -396,16 +396,6 @@ void BayesTest::computeBEB(const std::vector<double>& aVars, size_t aFgBranch, c
}
}
for(unsigned int j=0; j<BEB_DIMS; ++j) mSiteClassProb[j*mNumSites+site] *= exp(scale1-fX);
#if 0
// For debug
if(mVerbose >= VERBOSE_ONLY_RESULTS)
{
std::cerr << "Site " << std::setw(4) << site;
for(unsigned int k=0; k < BEB_DIMS; ++k) std::cerr << std::setw(20) << std::setprecision(12) << mSiteClassProb[k*mNumSites+site];
std::cerr << std::endl;
}
#endif
}
}
......
......@@ -27,6 +27,66 @@
static const double VERY_LOW_LIKELIHOOD = -1e14;
void BranchSiteModel::printFinalVars(std::ostream& aOut) const
{
// To nicely format num branch lengths per line
static const unsigned int VARS_PER_LINE = 8;
unsigned int count_per_line = 0;
static const std::streamsize VARS_PRECISION = 7;
static const std::streamsize VARS_WIDTH = 11;
// Write the data with an uniform precision
std::streamsize prec = aOut.precision(VARS_PRECISION);
aOut.setf(std::ios::fixed, std::ios::floatfield);
// Print all variables formatted to be readable
double v0 = 0;
std::vector<double>::const_iterator ix(mVar.begin());
const std::vector<double>::const_iterator end(mVar.end());
for(int k = -static_cast<int>(mNumTimes); ix != end; ++ix,++k)
{
switch(k)
{
case 0:
if(count_per_line) aOut << std::endl;
v0 = *ix;
break;
case 1:
{
double p[4];
getProportions(v0, *ix, p);
aOut << std::endl;
aOut << "p0:" << std::setw(VARS_WIDTH) << p[0];
aOut << " p1:" << std::setw(VARS_WIDTH) << p[1];
aOut << " p2a:" << std::setw(VARS_WIDTH) << p[2];
aOut << " p2b:" << std::setw(VARS_WIDTH) << p[3];
aOut << std::endl;
}
break;
case 2:
aOut << "w0:" << std::setw(VARS_WIDTH) << *ix;
break;
case 3:
aOut << " k: " << std::setw(VARS_WIDTH) << *ix;
break;
case 4:
aOut << " w2: " << std::setw(VARS_WIDTH) << *ix;
break;
default:
aOut << std::setw(VARS_WIDTH) << *ix;
++count_per_line;
if(count_per_line == VARS_PER_LINE)
{
count_per_line = 0;
aOut << std::endl;
}
break;
}
}
aOut << std::endl;
aOut.precision(prec);
}
void BranchSiteModel::printVar(const std::vector<double>& aVars, double aLnl, std::ostream& aOut) const
{
// Write the data with an uniform precision
......
......@@ -93,6 +93,12 @@ public:
///
void printVar(const std::vector<double>& aVars, double aLnl=DBL_MAX, std::ostream& aOut=std::cerr) const;
/// Formatted print of the maximized variables
///
/// @param[in] aOut The stream on which the variables should be printed
///
void printFinalVars(std::ostream& aOut=std::cerr) const;
/// Compute the maximum likelihood for the given forest
///
/// @param[in] aFgBranch The number of the internal branch to be marked as foreground
......
......@@ -182,7 +182,7 @@ void TreeAndSetsDependencies::optimizeDependencies(void)
void TreeAndSetsDependencies::print(const char* aTitle) const
{
// Do nothing if the debug level is insufficient
if(mVerbose < VERBOSE_INFO_OUTPUT) return;
if(mVerbose < VERBOSE_MORE_DEBUG) return;
// If present print the title
std::cerr << std::endl;
......
......@@ -340,14 +340,19 @@ int main(int aRgc, char **aRgv)
else
std::cerr << "(Doesn't pass LRT, skipping)";
std::cerr << " Function calls: " << h0.getNumEvaluations() << " ";
std::cerr << std::endl << std::endl;
h0.printFinalVars(std::cerr);
std::cerr << std::endl;
}
if(cmd.mComputeHypothesis != 0)
{
std::cerr << "LnL1: ";
std::cerr << std::setprecision(15) << std::fixed << lnl1;
std::cerr << " Function calls: " << h1.getNumEvaluations();
std::cerr << std::endl << std::endl;
h1.printFinalVars(std::cerr);
std::cerr << std::endl;
}
std::cerr << std::endl;
}
// If requested set the time in the forest and export to a graph visualization tool
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment