Commit 064a0a48 authored by mvalle's avatar mvalle
Browse files

Restructured few error messages.


git-svn-id: https://svn.vital-it.ch/svn/hp2c/trunk/Codeml_Variants/Fastcodeml@5344 95c5a404-1f88-0410-a6b0-c3f062b6f34a
parent 40acf8ea
......@@ -100,7 +100,7 @@ bool Genes::compareCodons(const char* aCodon1, const char* aCodon2) const
void Genes::checkNameCoherence(const std::vector<std::string>& aNames) const
{
// Should at least have the same number of species
if(aNames.size() != mDnaSpecies.size()) throw FastCodeMLFatal("Different number of species in tree and genes");
if(aNames.size() != mDnaSpecies.size()) throw FastCodeMLFatal("Different number of species in tree and genes.");
// Create correspondence between species names
std::vector<std::string>::const_iterator is1=aNames.begin();
......@@ -114,7 +114,7 @@ void Genes::checkNameCoherence(const std::vector<std::string>& aNames) const
{
if(*is1 == *is2) {found = true; break;}
}
if(!found) throw FastCodeMLFatal("Mismatch between species in tree and genes");
if(!found) throw FastCodeMLFatal("Mismatch between species in tree and genes.");
}
}
......@@ -136,7 +136,7 @@ void Genes::readFile(const char* aFilename, bool aCleanData)
if(ncodons >= std::numeric_limits<size_t>::max()/10U)
{
std::ostringstream o;
o << "File " << aFilename << " too many basis. Max " << std::numeric_limits<size_t>::max()/10U << std::endl;
o << "File \"" << aFilename << "\" has too many basis. Max " << std::numeric_limits<size_t>::max()/10U;
throw FastCodeMLFatal(o);
}
......@@ -155,7 +155,7 @@ void Genes::readFile(const char* aFilename, bool aCleanData)
// Check if at least one site remains
size_t valid_codons = std::count(codon_multiplicity.begin(), codon_multiplicity.end(), 1);
if(valid_codons == 0) throw FastCodeMLFatal("Not a single valid codon read");
if(valid_codons == 0) throw FastCodeMLFatal("Not a single valid codon read.");
// Print statistics
if(mVerboseLevel >= VERBOSE_INFO_OUTPUT)
......
......@@ -157,7 +157,7 @@ void Newick::readFile(const char *aFilename)
if(!in)
{
std::ostringstream o;
o << "Cannot open " << aFilename << std::endl;
o << "Cannot open tree file \"" << aFilename << '"' << std::endl;
throw FastCodeMLFatal(o);
}
......@@ -176,7 +176,7 @@ void Newick::readFile(const char *aFilename)
if(p1 == std::string::npos)
{
std::ostringstream o;
o << "File " << aFilename << " is empty (cannot find starting parenthesis)" << std::endl;
o << "File \"" << aFilename << "\" is empty (cannot find starting parenthesis)." << std::endl;
throw FastCodeMLFatal(o);
}
......@@ -185,7 +185,7 @@ void Newick::readFile(const char *aFilename)
if(p2 == std::string::npos)
{
std::ostringstream o;
o << "File " << aFilename << " is empty (cannot find ending semicolon)" << std::endl;
o << "File \"" << aFilename << "\" is empty (cannot find ending semicolon)." << std::endl;
throw FastCodeMLFatal(o);
}
......
......@@ -13,7 +13,7 @@ void Phylip::loadData(const char* aFilename, std::vector<std::string>& aSpecies,
if(!in)
{
std::ostringstream o;
o << "Cannot open " << aFilename << std::endl;
o << "Cannot open gene file \"" << aFilename << '"';
throw FastCodeMLFatal(o);
}
......@@ -22,7 +22,7 @@ void Phylip::loadData(const char* aFilename, std::vector<std::string>& aSpecies,
{
in.close();
std::ostringstream o;
o << "File " << aFilename << " is empty" << std::endl;
o << "File \"" << aFilename << "\" is empty";
throw FastCodeMLFatal(o);
}
......@@ -35,7 +35,7 @@ void Phylip::loadData(const char* aFilename, std::vector<std::string>& aSpecies,
{
in.close();
std::ostringstream o;
o << "File " << aFilename << " is malformed" << std::endl;
o << "File \"" << aFilename << "\" is malformed";
throw FastCodeMLFatal(o);
}
......@@ -45,7 +45,7 @@ void Phylip::loadData(const char* aFilename, std::vector<std::string>& aSpecies,
{
in.close();
std::ostringstream o;
o << "File " << aFilename << " is malformed" << std::endl;
o << "File \"" << aFilename << "\" is malformed";
throw FastCodeMLFatal(o);
}
......@@ -88,7 +88,7 @@ void Phylip::loadData(const char* aFilename, std::vector<std::string>& aSpecies,
if(nspecies != aSpecies.size())
{
std::ostringstream o;
o << "File " << aFilename << " has number of species mismatch" << std::endl;
o << "File \"" << aFilename << "\" has number of species mismatch";
throw FastCodeMLFatal(o);
}
......@@ -98,7 +98,7 @@ void Phylip::loadData(const char* aFilename, std::vector<std::string>& aSpecies,
if(aSequences[n].length() != nbasis)
{
std::ostringstream o;
o << "File " << aFilename << " gene " << n << " has wrong number of nucleotides" << std::endl;
o << "File \"" << aFilename << "\" gene " << n << " has wrong number of nucleotides";
throw FastCodeMLFatal(o);
}
}
......@@ -107,7 +107,7 @@ void Phylip::loadData(const char* aFilename, std::vector<std::string>& aSpecies,
if(nbasis % 3)
{
std::ostringstream o;
o << "File " << aFilename << " number of basis is not multiple of 3" << std::endl;
o << "File \"" << aFilename << "\" number of basis is not multiple of 3";
throw FastCodeMLFatal(o);
}
}
......
......@@ -90,45 +90,47 @@ int main(int aRgc, char **aRgv)
if(cmd.mVerboseLevel >= VERBOSE_INFO_OUTPUT)
{
std::cerr << std::endl;
std::cerr << "Tree file: " << cmd.mTreeFile << std::endl;
std::cerr << "Gene file: " << cmd.mGeneFile << std::endl;
std::cerr << "Verbose level: " << cmd.mVerboseLevel << " (" << decodeVerboseLevel(cmd.mVerboseLevel) << ')' << std::endl;
if(cmd.mSeed) std::cerr << "Seed: " << cmd.mSeed << std::endl;
if(cmd.mBranchFromFile) std::cerr << "Branch: From tree file" << std::endl;
else if(cmd.mBranch != UINT_MAX) std::cerr << "Branch: " << cmd.mBranch << std::endl;
if(cmd.mIgnoreFreq) std::cerr << "Codon freq.: Ignore" << std::endl;
if(cmd.mDoNotReduceForest) std::cerr << "Reduce forest: Do not reduce" << std::endl;
else std::cerr << "Reduce forest: Aggressive" << std::endl;
if(cmd.mInitH0fromH1) std::cerr << "Starting val.: From H1" << std::endl;
else if(cmd.mInitFromParams) std::cerr << "Starting val.: Times from tree file and params from const (see below)" << std::endl;
else if(cmd.mTimesFromFile) std::cerr << "Starting val.: Times from tree file" << std::endl;
if(cmd.mNoMaximization) std::cerr << "Maximization: No" << std::endl;
if(cmd.mExportComputedTimes != UINT_MAX) std::cerr << "Graph times: From H" << cmd.mExportComputedTimes << std::endl;
if(cmd.mTrace) std::cerr << "Trace: On" << std::endl;
if(cmd.mCleanData) std::cerr << "Clean data: On" << std::endl;
else std::cerr << "Clean data: Off" << std::endl;
if(cmd.mGraphFile) std::cerr << "Graph file: " << cmd.mGraphFile << std::endl;
std::cerr << "Optimizer: " << cmd.mOptimizationAlgo << std::endl;
if(cmd.mDeltaValueForGradient > 0.0) std::cerr << "Delta value: " << cmd.mDeltaValueForGradient << std::endl;
if(cmd.mResultsFile) std::cerr << "Results file: " << cmd.mResultsFile << std::endl;
std::cerr << "Tree file: " << cmd.mTreeFile << std::endl;
std::cerr << "Gene file: " << cmd.mGeneFile << std::endl;
std::cerr << "Verbose level: " << cmd.mVerboseLevel << " (" << decodeVerboseLevel(cmd.mVerboseLevel) << ')' << std::endl;
if(cmd.mSeed) std::cerr << "Seed: " << cmd.mSeed << std::endl;
if(cmd.mBranchFromFile) std::cerr << "Branch: From tree file" << std::endl;
else if(cmd.mBranch != UINT_MAX) std::cerr << "Branch: " << cmd.mBranch << std::endl;
if(cmd.mIgnoreFreq) std::cerr << "Codon freq.: Ignore" << std::endl;
if(cmd.mDoNotReduceForest) std::cerr << "Reduce forest: Do not reduce" << std::endl;
else std::cerr << "Reduce forest: Aggressive" << std::endl;
if(cmd.mInitH0fromH1) std::cerr << "Starting val.: From H1" << std::endl;
else if(cmd.mInitFromParams) std::cerr << "Starting val.: Times from tree file and params from const (see below)" << std::endl;
else if(cmd.mTimesFromFile) std::cerr << "Starting val.: Times from tree file" << std::endl;
if(cmd.mNoMaximization) std::cerr << "Maximization: No" << std::endl;
if(cmd.mTrace) std::cerr << "Trace: On" << std::endl;
if(cmd.mCleanData) std::cerr << "Clean data: On" << std::endl;
else std::cerr << "Clean data: Off" << std::endl;
if(cmd.mGraphFile) std::cerr << "Graph file: " << cmd.mGraphFile << std::endl;
if(cmd.mGraphFile && cmd.mExportComputedTimes != UINT_MAX)
std::cerr << "Graph times: From H" << cmd.mExportComputedTimes << std::endl;
if(!cmd.mNoMaximization) std::cerr << "Optimizer: " << cmd.mOptimizationAlgo << std::endl;
if(cmd.mDeltaValueForGradient > 0.0) std::cerr << "Delta value: " << cmd.mDeltaValueForGradient << std::endl;
std::cerr << "Relative error: " << cmd.mRelativeError << std::endl;
if(cmd.mResultsFile) std::cerr << "Results file: " << cmd.mResultsFile << std::endl;
#ifdef _OPENMP
if(num_threads > 1)
{
std::cerr << "Num. threads: " << num_threads << std::endl
<< "Num. cores: " << omp_get_num_procs() << std::endl;
std::cerr << "Num. threads: " << num_threads << std::endl
<< "Num. cores: " << omp_get_num_procs() << std::endl;
}
else
#endif
{
std::cerr << "Num. threads: 1 serial" << std::endl
<< "Num. cores: 1" << std::endl;
std::cerr << "Num. threads: 1 serial" << std::endl
<< "Num. cores: 1" << std::endl;
}
#ifdef USE_MPI
if(hlc.numJobs() > 2) std::cerr << "Num. MPI proc: 1 (master) + " << hlc.numJobs()-1 << " (workers)" << std::endl;
else std::cerr << "Num. MPI proc: Insufficient, single task execution" << std::endl;
if(hlc.numJobs() > 2) std::cerr << "Num. MPI proc: 1 (master) + " << hlc.numJobs()-1 << " (workers)" << std::endl;
else std::cerr << "Num. MPI proc: Insufficient, single task execution" << std::endl;
#endif
std::cerr << "Compiled with: ";
std::cerr << "Compiled with: ";
#ifdef _OPENMP
std::cerr << "USE_OPENMP ";
#endif
......@@ -416,22 +418,22 @@ int main(int aRgc, char **aRgv)
}
catch(const FastCodeMLFatal& e)
{
std::cerr << std::endl << e.what() << std::endl;
std::cerr << std::endl << e.what() << std::endl << std::endl;
return 1;
}
catch(const FastCodeMLMemoryError& e)
{
std::cerr << std::endl << e.what() << std::endl;
std::cerr << std::endl << e.what() << std::endl << std::endl;
return 1;
}
catch(const std::bad_alloc& e)
{
std::cerr << std::endl << e.what() << std::endl;
std::cerr << std::endl << e.what() << std::endl << std::endl;
return 1;
}
catch(...)
{
std::cerr << std::endl << "Default exception" << std::endl;
std::cerr << std::endl << "Default exception caught." << std::endl << std::endl;
return 1;
}
......
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