Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) 301

 

 

 

 

 

 

Technical facts

 

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: ProjectRampalTest.pro

 

QT       += core
CONFIG   += console
CONFIG   -= app_bundle
#Disallow release version
#CONFIG   += debug
#CONFIG   -= release
#Under Windows, under release mode, add this dumb config,
#otherwise, it will still be in debug mode (beats me why)
CONFIG -= debug
#Message showing what the application is thinking
unix: CONFIG(debug  ,debug|release):message("Building Ubuntu debug")
unix: CONFIG(release,debug|release):message("Building Ubuntu release: SHOULD NOT HAPPEN")
win32:CONFIG(debug  ,debug|release):message("Building Windows debug")
win32:CONFIG(release,debug|release):message("Building Windows release: SHOULD NOT HAPPEN")
#Application name
#Debug flag for keeping/removing assert
CONFIG(release,debug|release):DEFINES += NDEBUG
#Add the path of the BigInt library and BinaryNewickVector
INCLUDEPATH +=                         \
  ../../../Classes/CppBinaryNewickVector  \
  ../../../Classes/CppNewick  \
  ../../../Classes/CppStopwatch \
  ../../../Libraries/bigint-2010.04.30
#Libraries
win32:LIBS += C:/Qt/2010.02.1/qt/lib/libboost_filesystem.lib
unix:LIBS += -lboost_filesystem
#Using BigInt library by including its source
SOURCES += \
    dialogrampaltest.cpp \
    ProjectRampalTest.cpp \
    test.cpp \
    ../../../Classes/CppBinaryNewickVector/binarynewickvector.cpp \
    ../../../Libraries/bigint-2010.04.30/BigInteger.cc \
    ../../../Libraries/bigint-2010.04.30/BigIntegerAlgorithms.cc \
    ../../../Libraries/bigint-2010.04.30/BigIntegerUtils.cc \
    ../../../Libraries/bigint-2010.04.30/BigUnsigned.cc \
    ../../../Libraries/bigint-2010.04.30/BigUnsignedInABase.cc \
    ../../../Classes/CppNewick/newick.cpp
HEADERS += \
    test.h \
    dialogrampaltest.h \
    ../../../Classes/CppBinaryNewickVector/binarynewickvector.h \
    ../../../Classes/CppStopwatch/stopwatch.h \
    ../../../Classes/CppNewick/newick.h
FORMS += \
    dialogrampaltest.ui
RESOURCES += \
    ProjectRampal.qrc

 

 

 

 

 

MyAssert.h

 

#ifndef BILDERBIKKEL_ASSERT_H
#define BILDERBIKKEL_ASSERT_H
//---------------------------------------------------------------------------
#include <cassert>

//From http://www.richelbilderbeek.nl/CppAssert.htm
#ifdef NDEBUG_BILDERBIKKEL
  #define Assert(x) ((void)0)
#else
  #include <cstdlib>
  #include <fstream>
  #include <iostream>
  #include <stdexcept>

  #define Assert(x)                      \
  if (!(x))                              \
  {                                      \
    std::cout                            \
      << "ERROR!! Assertion "            \
      <<  std::string (#x)               \
      <<  " failed\n on line "           \
      <<  (__LINE__)                     \
      <<  "\n in file "                  \
      <<  __FILE__                       \
      << std::endl;                      \
    std::ofstream f("assert_out.txt");   \
    f                                    \
      << "ERROR!! Assertion "            \
      <<  std::string (#x)               \
      <<  " failed\n on line "           \
      <<  (__LINE__)                     \
      <<  "\n in file "                  \
      <<  __FILE__                       \
      << std::endl;                      \
    f.close();                           \
    std::exit(1234);                     \
    throw std::logic_error(              \
      "Assertion failed");               \
  }

#endif
//---------------------------------------------------------------------------
#endif // BILDERBIKKEL_ASSERT_H

 

 

 

 

 

MyTrace.h

 

#ifndef BILDERBIKKEL_TRACE_H
#define BILDERBIKKEL_TRACE_H
//---------------------------------------------------------------------------
#include <cassert>

//From http://www.richelbilderbeek.nl/CppAssert.htm
#ifdef NTRACE_BILDERBIKKEL
  #define Trace(x) ((void)0)
#else
  #include <fstream>
  #include <iostream>
  #include <stdexcept>

  #define Trace(x)                    \
  {                                   \
    std::ofstream f("trace_out.txt"); \
    f                                 \
      << "TRACE \'"            \
      <<  std::string (#x)               \
      <<  "\' line "           \
      <<  (__LINE__)                     \
      <<  " in file '"                  \
      <<  __FILE__                       \
      <<  "': "                       \
      <<  std::string (x)               \
      <<  "'"                       \
      << std::endl;                      \
    f.close();                           \
    }  \
    std::cout                            \
      << "TRACE \'"            \
      <<  std::string (#x)               \
      <<  "\' line "           \
      <<  (__LINE__)                     \
      <<  " in file '"                  \
      <<  __FILE__                       \
      <<  "': "                       \
      <<  std::string (x)               \
      <<  "'"                       \
      << std::endl;                      \

#endif
//---------------------------------------------------------------------------
#endif // BILDERBIKKEL_TRACE_H

 

 

 

 

 

ProjectRampalGui.cpp

 

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop
//---------------------------------------------------------------------------
USEFORM("UnitFormAnalyse.cpp", FormAnalyse);
//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
        try
        {
                 Application->Initialize();
                 Application->Title = "The Rampal Etienne Project multi-run GUI";
                 Application->CreateForm(__classid(TFormAnalyse), &FormAnalyse);
                 Application->Run();
        }
        catch (Exception &exception)
        {
                 Application->ShowException(&exception);
        }
        catch (...)
        {
                 try
                 {
                         throw Exception("");
                 }
                 catch (Exception &exception)
                 {
                         Application->ShowException(&exception);
                 }
        }
        return 0;
}
//---------------------------------------------------------------------------

 

 

 

 

 

ProjectRampalTest.cpp

 

//---------------------------------------------------------------------------
/*
  The Rampal Etienne Project, calculates the probability of a phylogeny
  (C) 2009 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
//---------------------------------------------------------------------------
#include <algorithm>
#include <cmath>
#include <cctype>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <stdexcept>
#include <string>
#include <vector>
//---------------------------------------------------------------------------
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/shared_ptr.hpp>
//---------------------------------------------------------------------------
#include <QApplication>
//---------------------------------------------------------------------------
#include "binarynewickvector.h"
#include "dialogrampaltest.h"
#include "newick.h"
#include "test.h"
//---------------------------------------------------------------------------
//From htpp://www.richelbilderbeek.nl/CppGetRandomUniform.htm
double GetRandomUniform()
{
  return static_cast<double>(std::rand())/static_cast<double>(RAND_MAX);
}
//---------------------------------------------------------------------------
template <typename T>
const T AskUserForInput()
{
  T t;
  std::getline(std::cin,t);
  return t;
}
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/CppAskUserForDouble.htm
const std::string AskUserForNewick()
{
  while (1)
  {
    std::cout << "Please enter a newick or press enter to quit:\n";
    const std::string s = AskUserForInput<std::string>();
    if (s.empty()) return std::string();
    try
    {
      BinaryNewickVector n(s);
      return s;
    }
    catch(std::invalid_argument& e)
    {
      std::cout << "Invalid input: " << e.what() << "\n";
    }
  }
}
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/CppAskUserForDouble.htm
double AskUserForTheta()
{
  while (1)
  {
    std::cout << "Please enter a value for theta or press enter to quit:\n";
    const std::string s = AskUserForInput<std::string>();
    if (s.empty()) return 0.0;
    try
    {
      const double x = boost::lexical_cast<double>(s);
      if (x <= 0.0)
      {
        std::cout << "Theta must be a positive non-zero value\n";
        continue;
      }
      return x;
    }
    catch(...)
    {
      std::cout << "Theta must be a positive non-zero value\n";
    }
  }
}
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/CppRandomizeTimer.htm
void RandomizeTimer()
{
  std::srand(std::time(0));
}
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/CppStrToLower.htm
const std::string StrToLower(std::string s)
{
  std::transform(s.begin(), s.end(), s.begin(),std::ptr_fun<int,int>(std::tolower));
  return s;
}
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/CppGetPath.htm
//Returns the path, without a trailing backslash '\'
const std::string GetPath(const std::string& fileName)
{
  #ifndef USE_WINDOWS
  const int endOfPathIndex = fileName.rfind("/",fileName.size());
  #else
  const int endOfPathIndex = fileName.rfind("\\",fileName.size());
  #endif
  assert(endOfPathIndex < static_cast<int>(fileName.size()));
  return fileName.substr(0,endOfPathIndex);
}
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/CppGetCurrentFolder.htm
const std::string GetCurrentFolder(const std::string& s)
{
  return GetPath(s);
}
//---------------------------------------------------------------------------
void ShowCorrectUse()
{
  std::cout
    << "Incorrect use of ProjectTestMain\n"
    << "\n"
    << "ProjectTestMain [theta input parameter] [newick input parameter] [test parameters]\n"
    << "\n"
    << "Theta input parameters: \n"
    << "  -any positive non-zero value, for example '10.0'\n"
    << "  -m: manual input of thetas\n"
    << "  -r: random theta\n"
    << "\n"
    << "Input parameters: \n"
    << "  -any newick string, for example '(1,(2,3))\n"
    << "  -m: manual input of newick strings\n"
    << "  -r: random newick strings\n"
    << "\n"
    << "Test parameters: \n"
    << " i &  1: use Ravindran\n"
    << " i &  2: use SortedNewick\n"
    << " i &  4: use SmartSortedNewick\n"
    << " i &  8: use RampalMain_Endversion2\n"
    << " i & 16: use TestTwoDigitNewickDebug\n"
    << " i & 32: use TestTwoDigitNewickRelease\n"
    << " 63: use all\n"
    << std::endl;
}
//---------------------------------------------------------------------------
///ProjectRampalTest is the testing facility of ProjectRampal.
///A newly developed brach of the project can be tested with
///this program in terms of obtaining the right output and speed.
///ProjectRampalTest forbids the use of a release mode,
///because its purpose is to test the code.
int main(int argc, char* argv[])
{
  if (argc == 1)
  {
    QApplication a(argc, argv);
    DialogRampalTest d;
    d.show();
    return a.exec();
  }

  std::cout << GetCurrentFolder(argv[0]) << "/" << argv[0]
    << " (version 300.0)\n";
  #ifdef NDEBUG
    std::cout
      << "ProjectTest cannot be run in no-debug mode!\n"
      << "Please recompile without the NDEBUG #define"
      << std::endl;
    return 1;
  #endif

  if (argc!=4) { ShowCorrectUse(); return 0; }

  const std::string argv1 = StrToLower(argv[1]);
  const std::string argv2 = StrToLower(argv[2]);
  //Check if the fourth argument is an integer
  try
  {
    boost::lexical_cast<int>(argv[3]);
  }
  catch (boost::bad_lexical_cast&)
  {
    ShowCorrectUse();
    return 1;
  }
  const int argv3 = boost::lexical_cast<int>(argv[3]);
  //Test sanity of input
  //First parameter: theta
  {
    try { boost::lexical_cast<double>(argv1); } //Is it a double?
    catch(...)
    {
      if (argv1!="-m" && argv1!="-r") { ShowCorrectUse(); return 0; }
    }
  }
  //Second parameter: phylogeny
  {
    try { BinaryNewickVector n(argv2); } //Is it a newick?
    catch(...)
    {
      if (argv2!="-m" && argv2!="-r" ) { ShowCorrectUse(); return 0; }
    }
  }
  //Third parameter: test
  {
    if (argv3 <= 0 || argv3 > 63) { ShowCorrectUse(); return 0; }
  }
  //Input is sane

  RandomizeTimer();

  std::ofstream file("Results.txt");
  file << "Results of " << argv[0] << " " << argv[1] << " " << argv[2] << " " << argv[3] << "\n";
  file.close();

  std::cout << std::setprecision(10);

  while (1)
  {
    //Obtain theta
    //Theta input parameters:
    // -any positive non-zero value, for example '10.0'
    // -f: theta values from file 'test_thetas.txt'
    // -m: manual input of thetas
    double theta = 0.0;
    if (argv1 == "-m")
    {
      theta = AskUserForTheta();
      if (theta==0.0) break;
    }
    else if (argv1 == "-r")
    {
      theta = GetRandomUniform() * 100.0;
    }
    else
    {
      theta = boost::lexical_cast<double>(argv1);
    }

    //Obtain newick
    std::string newick;
    //Input parameters:
    // -any newick string, for example '(1,(2,3))'
    // -m: manual input of newick strings
    // -p: predefined newick strings
    // -r: random newick strings
    if (argv2 == "-m")
    {
      newick = AskUserForNewick();
      if (newick.empty()) break;
    }
    else if (argv2 == "-r")
    {
      newick = Newick::CreateRandomNewick(7,7);
    }
    else
    {
      newick = argv2;
    }

    std::ofstream file("Results.txt", std::ios_base::app);
    file << std::setprecision(99);

    //Create all tests
    std::vector<boost::shared_ptr<Test> > tests
      = Test::CreateTests(newick,theta,argv3);

    //Execute all tests
    BOOST_FOREACH(boost::shared_ptr<Test> t,tests)
    {
      t->Execute();
    }

    //Show test results
    std::cout
      << '\n'
      << "Theta: '" << theta << "'\n"
      << "Newick: '" << newick << "'\n"
      << "Number of combinations: "
      << Newick::CalcNumOfCombinations(BinaryNewickVector(newick).Get())
      << "\n\n\n\n\n"
      << "TestName\t\t\tProbability\tTime\n";

    BOOST_FOREACH(boost::shared_ptr<Test> t,tests)
    {
      std::cout
        << t->GetTestName()
        << "\t" << t->GetProbability()
        //<< '\t' << t->GetEwensProbability()
        << '\t' << t->GetTime()
        << '\n';
      file
        << t->GetTestName()
        << '\t' << t->GetNewick()
        << '\t' << t->GetProbability()
        << '\t' << t->GetEwensProbability()
        << '\t' << t->GetTime()
        << '\n';
    }

    //Probably we're done,
    //except if the user wants to input another value manually
    if (argv1!="-m" && argv2!="-m") break;
  }
}
//---------------------------------------------------------------------------























//---------------------------------------------------------------------------
const std::vector<std::string> CreateTestNewicks()
{
  std::vector<std::string> v;
  v.push_back("((2,2),2)");
  v.push_back("((2,2),3)");
  v.push_back("((2,3),3)");
  v.push_back("((3,3),3)");
  v.push_back("((5,5),5)");
  v.push_back("(((2,2),2),2)");
  v.push_back("(((2,2),2),3)");
  v.push_back("(((2,2),3),3)");
  v.push_back("(((2,3),3),3)");
  v.push_back("(((3,3),3),3)");
  v.push_back("(((5,5),5),5)");
  v.push_back("((100,100),10)");
  v.push_back("((100,100),20)");
  v.push_back("((100,100),30)");
  v.push_back("((100,100),40)");
  v.push_back("((100,100),50)");
  v.push_back("((100,100),60)");
  v.push_back("((100,100),70)");
  v.push_back("((100,100),80)");
  v.push_back("((100,100),90)");
  v.push_back("((10,100),100)");
  v.push_back("((20,100),100)");
  v.push_back("((30,100),100)");
  v.push_back("((40,100),100)");
  v.push_back("((50,100),100)");
  v.push_back("((60,100),100)");
  v.push_back("((70,100),100)");
  v.push_back("((80,100),100)");
  v.push_back("((90,100),100)");
  v.push_back("((1000,100),10)");
  v.push_back("((1000,100),20)");
  v.push_back("((1000,100),30)");
  v.push_back("((1000,100),40)");
  v.push_back("((1000,100),50)");
  v.push_back("((1000,100),60)");
  v.push_back("((1000,100),70)");
  v.push_back("((1000,100),80)");
  v.push_back("((1000,100),90)");
  v.push_back("((100,100),100)");
  v.push_back("((10,1000),100)");
  v.push_back("((10,100),1000)");
  v.push_back("((20,1000),100)");
  v.push_back("((20,100),1000)");
  v.push_back("((30,1000),100)");
  v.push_back("((30,100),1000)");
  v.push_back("((40,1000),100)");
  v.push_back("((40,100),1000)");
  v.push_back("((50,1000),100)");
  v.push_back("((50,100),1000)");
  v.push_back("((60,1000),100)");
  v.push_back("((60,100),1000)");
  v.push_back("((70,1000),100)");
  v.push_back("((70,100),1000)");
  v.push_back("((80,1000),100)");
  v.push_back("((80,100),1000)");
  v.push_back("((90,1000),100)");
  v.push_back("((90,100),1000)");
  v.push_back("((1000,100),100)");
  v.push_back("((100,100),1000)");
  v.push_back("((((2,2),2),2),2)");
  v.push_back("((((2,2),2),2),3)");
  v.push_back("((((2,2),2),3),3)");
  v.push_back("((((2,2),3),3),3)");
  v.push_back("((((2,3),3),3),3)");
  v.push_back("((((3,3),3),3),3)");
  v.push_back("((((5,5),5),5),5)");
  v.push_back("(((((2,2),2),2),2),2)");
  v.push_back("(((((2,2),2),2),2),3)");
  v.push_back("(((((2,2),2),2),3),3)");
  v.push_back("(((((2,2),2),3),3),3)");
  v.push_back("(((((2,2),3),3),3),3)");
  v.push_back("(((((2,3),3),3),3),3)");
  v.push_back("(((((3,3),3),3),3),3)");
  v.push_back("(((((5,5),5),5),5),5)");
  v.push_back("((((((2,2),2),2),2),2),2)");
  v.push_back("((((((2,2),2),2),2),2),3)");
  v.push_back("((((((2,2),2),2),2),3),3)");
  v.push_back("((((((2,2),2),2),3),3),3)");
  v.push_back("((((((2,2),2),3),3),3),3)");
  v.push_back("((((((2,2),3),3),3),3),3)");
  v.push_back("((((((2,3),3),3),3),3),3)");
  v.push_back("((((((3,3),3),3),3),3),3)");
  v.push_back("((((((5,5),5),5),5),5),5)");
  v.push_back("(((((((2,2),2),2),2),2),2),2)");
  v.push_back("(((((((2,2),2),2),2),2),2),3)");
  v.push_back("(((((((2,2),2),2),2),2),3),3)");
  v.push_back("(((((((2,2),2),2),2),3),3),3)");
  v.push_back("(((((((2,2),2),2),3),3),3),3)");
  v.push_back("(((((((2,2),2),3),3),3),3),3)");
  v.push_back("(((((((2,2),3),3),3),3),3),3)");
  v.push_back("(((((((2,3),3),3),3),3),3),3)");
  v.push_back("(((((((3,3),3),3),3),3),3),3)");
  v.push_back("(((((((5,5),5),5),5),5),5),5)");
  v.push_back("((((((((2,2),2),2),2),2),2),2),2)");
  v.push_back("((((((((2,2),2),2),2),2),2),2),3)");
  v.push_back("((((((((2,2),2),2),2),2),2),3),3)");
  v.push_back("((((((((2,2),2),2),2),2),3),3),3)");
  v.push_back("((((((((2,2),2),2),2),3),3),3),3)");
  v.push_back("((((((((2,2),2),2),3),3),3),3),3)");
  v.push_back("((((((((2,2),2),3),3),3),3),3),3)");
  v.push_back("((((((((2,2),3),3),3),3),3),3),3)");
  v.push_back("((((((((2,3),3),3),3),3),3),3),3)");
  v.push_back("((((((((3,3),3),3),3),3),3),3),3)");
  v.push_back("((((((((5,5),5),5),5),5),5),5),5)");
  v.push_back("(((((((((2,2),2),2),2),2),2),2),2),2)");
  v.push_back("(((((((((2,2),2),2),2),2),2),2),3),3)");
  v.push_back("(((((((((2,2),2),2),2),2),2),3),3),3)");
  v.push_back("(((((((((2,2),2),2),2),2),3),3),3),3)");
  v.push_back("(((((((((2,2),2),2),2),3),3),3),3),3)");
  v.push_back("(((((((((2,2),2),2),3),3),3),3),3),3)");
  v.push_back("(((((((((2,2),2),3),3),3),3),3),3),3)");
  v.push_back("(((((((((2,2),3),3),3),3),3),3),3),3)");
  v.push_back("(((((((((2,3),3),3),3),3),3),3),3),3)");
  v.push_back("(((((((((5,5),5),5),5),5),5),5),5),5)");
  v.push_back("((((((((((2,2),2),2),2),2),2),2),2),2),2)");
  v.push_back("((((((((((2,2),2),2),2),2),2),2),3),3),3)");
  v.push_back("((((((((((2,2),2),2),2),2),2),3),3),3),3)");
  v.push_back("((((((((((2,2),2),2),2),2),3),3),3),3),3)");
  v.push_back("((((((((((2,2),2),2),2),3),3),3),3),3),3)");
  v.push_back("((((((((((2,2),2),2),3),3),3),3),3),3),3)");
  v.push_back("((((((((((2,2),2),3),3),3),3),3),3),3),3)");
  v.push_back("((((((((((2,2),3),3),3),3),3),3),3),3),3)");
  v.push_back("(((((((((((2,2),2),2),2),2),2),2),2),2),2),2)");
  v.push_back("(((((((((((2,2),2),2),2),2),2),2),3),3),3),3)");
  v.push_back("(((((((((((2,2),2),2),2),2),2),3),3),3),3),3)");
  v.push_back("(((((((((((2,2),2),2),2),2),3),3),3),3),3),3)");
  v.push_back("(((((((((((2,2),2),2),2),3),3),3),3),3),3),3)");
  v.push_back("((((((((((((2,2),2),2),2),2),2),2),2),2),2),2),2)");
  v.push_back("((((((((((((2,2),2),2),2),2),2),2),3),3),3),3),3)");
  v.push_back("(((((((((((((2,2),2),2),2),2),2),2),2),2),2),2),2),2)");
  v.push_back("((((((((((((((2,2),2),2),2),2),2),2),2),2),2),2),2),2),2)");
  return v;
}
//---------------------------------------------------------------------------

 

 

 

 

 

dialogrampaltest.h

 

#ifndef DIALOGRAMPALTEST_H
#define DIALOGRAMPALTEST_H
//---------------------------------------------------------------------------
#include <string>
#include <vector>
//---------------------------------------------------------------------------
#include <QDialog>
//---------------------------------------------------------------------------
#include "BigIntegerLibrary.hh"
//---------------------------------------------------------------------------
namespace Ui {
  class DialogRampalTest;
}
//---------------------------------------------------------------------------
class DialogRampalTest : public QDialog
{
  Q_OBJECT

public:
  explicit DialogRampalTest(QWidget *parent = 0);
  ~DialogRampalTest();

struct Row
{
  std::string m_test_name;
  double m_probability;
  double m_time;
  std::string m_newick;
  BigInteger m_complexity;
};

protected:
  void changeEvent(QEvent *e);
  void resizeEvent(QResizeEvent *);

private:
  Ui::DialogRampalTest *ui;
  std::vector<Row> m_data;
  bool m_valid_input;
  int GetFlags() const;
  int GetNumTestsChecked() const;
  void ShowData();

private slots:
  void onAnyChange();
  void onBenchmark();
  void onStart();

};
//---------------------------------------------------------------------------
const std::vector<std::string> GetHardBiologicalNewicks();
//---------------------------------------------------------------------------
const std::vector<std::string> GetHardNewicks();
//---------------------------------------------------------------------------
const std::vector<std::string> GetLightBiologicalNewicks();
//---------------------------------------------------------------------------
const std::vector<std::string> GetLightNewicks();
//---------------------------------------------------------------------------
const std::vector<std::string> GetManyNewicks();
//---------------------------------------------------------------------------
const std::vector<std::string> GetMediumNewicks();
//---------------------------------------------------------------------------
#endif // DIALOGRAMPALTEST_H

 

 

 

 

 

dialogrampaltest.cpp

 

//---------------------------------------------------------------------------
#include <fstream>
#include <vector>
//---------------------------------------------------------------------------
#include <boost/foreach.hpp>
#include <boost/numeric/conversion/cast.hpp>
#include <boost/shared_ptr.hpp>
//---------------------------------------------------------------------------
#include <QDesktopWidget>
//---------------------------------------------------------------------------
#include "binarynewickvector.h"
#include "dialogrampaltest.h"
#include "newick.h"
#include "ui_dialogrampaltest.h"
#include "test.h"
//---------------------------------------------------------------------------
DialogRampalTest::DialogRampalTest(QWidget *parent) :
    QDialog(parent,Qt::Window),
    ui(new Ui::DialogRampalTest),
    m_valid_input(false)
{
  ui->setupUi(this);
  QObject::connect(ui->button_start,SIGNAL(clicked()),
    this,SLOT(onStart()));
  QObject::connect(ui->button_benchmark,SIGNAL(clicked()),
    this,SLOT(onBenchmark()));
  QObject::connect(ui->edit_newick,SIGNAL(textChanged(QString)),
    this,SLOT(onAnyChange()));
  QObject::connect(ui->edit_theta,SIGNAL(textChanged(QString)),
    this,SLOT(onAnyChange()));

  //Set table header
  {
    QTableWidgetItem * const i
      = new QTableWidgetItem("Test name");
    ui->table->setHorizontalHeaderItem(0,i);
  }
  {
    QTableWidgetItem * const i
      = new QTableWidgetItem("Probability");
    ui->table->setHorizontalHeaderItem(1,i);
  }
  {
    QTableWidgetItem * const i
      = new QTableWidgetItem("Time (sec)");
    ui->table->setHorizontalHeaderItem(2,i);
  }
  {
    QTableWidgetItem * const i
      = new QTableWidgetItem("Newick");
    ui->table->setHorizontalHeaderItem(3,i);
  }
  {
    QTableWidgetItem * const i
      = new QTableWidgetItem("Complexity");
    ui->table->setHorizontalHeaderItem(4,i);
  }


  //Put the dialog in the screen center
  const QRect screen = QApplication::desktop()->screenGeometry();
  this->move( screen.center() - this->rect().center() );

  onAnyChange();
}
//---------------------------------------------------------------------------
DialogRampalTest::~DialogRampalTest()
{
  delete ui;
}
//---------------------------------------------------------------------------
void DialogRampalTest::changeEvent(QEvent *e)
{
  QDialog::changeEvent(e);
  switch (e->type()) {
  case QEvent::LanguageChange:
    ui->retranslateUi(this);
    break;
  default:
    break;
  }
}
//---------------------------------------------------------------------------
void DialogRampalTest::resizeEvent(QResizeEvent *)
{
  const int n_cols = ui->table->columnCount();
  //-18 because of header column
  const int width = (ui->table->width() - 18) / n_cols;
  for (int i=0; i!=n_cols; ++i)
  {
    ui->table->setColumnWidth(i,width);
  }
}
//---------------------------------------------------------------------------
void DialogRampalTest::onAnyChange()
{
  try
  {
    const std::string s = ui->edit_newick->text().toStdString();
    BinaryNewickVector n(s);
  }
  catch (std::exception&)
  {
    ui->label_input_feedback->setText("Invalid Newick");
    m_valid_input = false;
    return;
  }
  try
  {
    const std::string s = ui->edit_theta->text().toStdString();
    const double t = boost::lexical_cast<double>(s);
    if (t <= 0.0)
    {
      ui->label_input_feedback->setText("Invalid theta");
      return;
    }
  }
  catch(boost::bad_lexical_cast&)
  {
    ui->label_input_feedback->setText("Invalid theta");
    m_valid_input = false;
    return;
  }
  //Calculate complexity
  {
    const std::string s = ui->edit_newick->text().toStdString();
    const BinaryNewickVector n(s);
    const BigInteger complexity = Newick::CalcComplexity(n.Get());
    const std::string c_str = bigIntegerToString(complexity);
    ui->label_input_feedback->setText(
          QString("Newick complexity: ")
        + QString(c_str.c_str()) );
  }
  m_valid_input = true;
}
//---------------------------------------------------------------------------
void DialogRampalTest::onBenchmark()
{
  //Create fresh file
  std::ofstream file("test_output.txt");
  file.close();
  //Obtain the Newicks to be tested
  assert(ui->box_benchmark_type->count()==6);
  typedef const std::vector<std::string> (*function_pointer)();
  function_pointer newick_getter = 0;
  switch(ui->box_benchmark_type->currentIndex())
  {
    case 0: newick_getter = GetLightNewicks; break;
    case 1: newick_getter = GetMediumNewicks; break;
    case 2: newick_getter = GetHardNewicks; break;
    case 3: newick_getter = GetManyNewicks; break;
    case 4: newick_getter = GetLightBiologicalNewicks; break;
    case 5: newick_getter = GetHardBiologicalNewicks; break;
    default: assert(!"Should not get here");
  }
  const std::vector<std::string> newicks = newick_getter();
  const double theta = 10.0;
  const int flags = GetFlags();
  m_data.resize(0);

  BOOST_FOREACH(const std::string& newick, newicks)
  {
    //Test each Newick
    //Create tests
    const std::vector<boost::shared_ptr<Test> > tests
      = Test::CreateTests(newick,theta,flags);
    BOOST_FOREACH(const boost::shared_ptr<Test> t,tests)
    {
      t->Execute();
      Row d;
      d.m_complexity = t->GetComplexity();
      d.m_newick = t->GetNewick();
      d.m_probability = t->GetProbability();
      d.m_test_name = t->GetTestName();
      d.m_time = t->GetTime();
      //Write to file
      file.open("test_output.txt",std::ios::app);
      file
        << t->GetTestName() << '\t'
        << t->GetProbability() << '\t'
        << t->GetTime() << '\t'
        << t->GetNewick() << '\t'
        << theta << '\t'
        << t->GetComplexity() << '\n';
      file.close();
      m_data.push_back(d);
      this->ShowData();
      QApplication::processEvents();
      //this->update();
    }
  }
  //this->ShowData();
}
//---------------------------------------------------------------------------
void DialogRampalTest::onStart()
{
  if (!m_valid_input) return;

  std::ofstream file("test_output.txt");
  const std::string s = ui->edit_newick->text().toStdString();
  const double theta
    = boost::lexical_cast<double>(
      (ui->edit_theta->text().toStdString()));
  //Create all tests
  const std::vector<boost::shared_ptr<Test> > tests
    = Test::CreateTests(s,theta,GetFlags());
  //Execute all tests
  m_data.resize(0);
  BOOST_FOREACH(const boost::shared_ptr<Test> t,tests)
  {
    t->Execute();
    Row d;
    d.m_complexity = t->GetComplexity();
    d.m_newick = t->GetNewick();
    d.m_probability = t->GetProbability();
    d.m_test_name = t->GetTestName();
    d.m_time = t->GetTime();
    file
      << t->GetTestName() << '\t'
      << t->GetProbability() << '\t'
      << t->GetTime() << '\t'
      << t->GetNewick() << '\t'
      << theta << '\t'
      << t->GetComplexity() << '\n';
    m_data.push_back(d);
  }
  this->ShowData();
}
//---------------------------------------------------------------------------
int DialogRampalTest::GetFlags() const
{
  int flags = 0;
  if (ui->box_ravindran->isChecked()             ) flags+= 1;
  if (ui->box_endversion2->isChecked()           ) flags+= 2;
  if (ui->box_twodigitnewick_debug->isChecked()  ) flags+= 4;
  if (ui->box_twodigitnewick_release->isChecked()) flags+= 8;
  return flags;
}
//---------------------------------------------------------------------------
int DialogRampalTest::GetNumTestsChecked() const
{
  int cnt = 0;
  if (ui->box_ravindran->isChecked()             ) ++cnt;
  if (ui->box_endversion2->isChecked()           ) ++cnt;
  if (ui->box_twodigitnewick_debug->isChecked()  ) ++cnt;
  if (ui->box_twodigitnewick_release->isChecked()) ++cnt;
  return cnt;
}
//---------------------------------------------------------------------------
void DialogRampalTest::ShowData()
{
  ui->table->clearContents();
  ui->table->setRowCount(
    boost::numeric_cast<int>(m_data.size()));
  int row = 0;
  BOOST_FOREACH(const Row& d, m_data)
  {
    {
      QTableWidgetItem * const i = new QTableWidgetItem(
        QString(d.m_test_name.c_str()));
      ui->table->setItem(row, 0, i);
    }
    {
      QTableWidgetItem * const i = new QTableWidgetItem(
        QString(boost::lexical_cast<std::string>(
          d.m_probability).c_str()));
      ui->table->setItem(row, 1, i);
    }
    {
      QTableWidgetItem * const i = new QTableWidgetItem(
        QString(boost::lexical_cast<std::string>(
          d.m_time).c_str()));
      ui->table->setItem(row, 2, i);
    }
    {
      QTableWidgetItem * const i = new QTableWidgetItem(
        QString(boost::lexical_cast<std::string>(
          d.m_newick).c_str()));
      ui->table->setItem(row, 3, i);
    }
    {
      QTableWidgetItem * const i = new QTableWidgetItem(
        QString(boost::lexical_cast<std::string>(
          d.m_complexity).c_str()));
      ui->table->setItem(row, 4, i);
    }
    ++row;
  }
}
//---------------------------------------------------------------------------
const std::vector<std::string> GetHardBiologicalNewicks()
{
  std::vector<std::string> v;
  v.push_back("((1,(1,(((((1,(1,((1,1),(3,1)))),1),((((1,((1,((1,1),(45,6))),(((1,1),(4,1)),2))),1),2),1)),1),2))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,(2,2))),1),((((1,((1,(1,(35,7))),((4,4),1))),1),4),1)),1),1))),((1,(1,1)),1))");
  v.push_back("((1,(1,((((((2,1),(1,((1,1),1))),1),((((1,((1,(5,(36,10))),((2,2),1))),1),(1,5)),1)),1),1))),(1,1))");
  v.push_back("((1,(1,((((((1,1),(1,(2,(3,1)))),1),((((1,((1,(1,(36,10))),((5,6),1))),1),2),1)),1),1))),1)");
  v.push_back("((1,(1,(((((1,(1,(2,3))),1),((((1,((1,((1,1),(34,10))),((4,(4,1)),3))),1),(1,1)),1)),1),1))),(2,1))");
  v.push_back("((1,(1,(((((((1,1),1),(1,(2,1))),1),((((1,((1,(3,(47,14))),((6,4),(1,1)))),1),(1,1)),1)),1),2))),(1,1))");
  v.push_back("((1,(1,((((((1,1),(1,(3,((1,1),1)))),1),((((1,((1,(2,(45,8))),((5,2),1))),1),(2,5)),1)),1),1))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,((1,1),((1,1),1)))),1),((((1,((1,((2,1),(35,10))),((4,(5,1)),2))),1),8),1)),1),1))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,(1,(1,1)))),1),((((1,((1,(2,(66,13))),((8,(5,1)),1))),1),(1,5)),1)),1),1))),(1,1))");
  v.push_back("((1,(1,(((((2,(1,(2,((1,1),1)))),1),((((1,((1,(2,(57,8))),((4,(1,2)),2))),1),6),1)),1),1))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,(2,3))),1),((((1,((1,(3,(41,10))),((4,(1,1)),(1,2)))),1),5),1)),1),1))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,((1,1),2))),1),((((1,((1,(1,(44,12))),((3,5),1))),1),(3,9)),(1,1))),1),1))),1)");
  v.push_back("((1,(1,(((((1,(2,(1,(4,1)))),1),((((1,((1,((1,1),(61,8))),((3,(4,1)),2))),1),(1,5)),1)),1),1))),((1,1),1))");
  v.push_back("((1,(1,(((((1,(1,(2,((1,1),3)))),1),((((1,((1,((2,1),(39,8))),((7,3),1))),1),(2,3)),(1,1))),1),1))),((1,1),1))");
  v.push_back("((1,(1,(((((1,(1,(1,3))),1),((((1,((1,((2,2),(37,9))),(4,2))),1),(4,2)),1)),1),1))),(2,1))");
  v.push_back("((1,(1,((((((1,1),(1,(1,2))),1),((((1,((1,(1,(38,12))),((4,5),2))),1),(1,3)),1)),1),2))),(3,1))");
  v.push_back("((1,(1,((((((1,1),(1,(2,((1,(1,1)),1)))),1),((((1,((1,(3,(53,13))),8)),1),(2,3)),2)),1),1))),((1,(1,1)),1))");
  v.push_back("((1,(1,(((((2,(1,(3,((1,1),2)))),1),((((1,((1,((1,1),(50,9))),((6,(2,1)),3))),1),2),1)),1),1))),((1,(1,1)),1))");
  v.push_back("((1,(1,(((((1,(1,((1,1),(2,1)))),1),((((1,((1,((2,1),(47,7))),((8,4),1))),1),(1,8)),1)),1),1))),(2,1))");
  v.push_back("((1,(1,(((((1,(1,(2,(3,1)))),1),((((1,((1,(2,(26,7))),((7,3),1))),1),(3,3)),1)),1),1))),(2,1))");
  v.push_back("((1,(1,((((((1,1),(1,(6,((1,3),1)))),1),((((1,((1,((2,2),(39,12))),((3,(2,1)),1))),1),3),1)),1),1))),((1,(1,1)),1))");
  v.push_back("((1,(1,(((((1,(1,(1,((1,1),1)))),1),((((1,((1,((6,2),(47,7))),((4,(6,1)),1))),1),(1,4)),1)),1),2))),((1,(1,1)),1))");
  v.push_back("((1,(1,(((((1,(2,(1,(2,1)))),1),((((1,((1,(2,(49,7))),((7,2),3))),1),(1,6)),1)),1),1))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,(1,((1,(1,1)),1)))),1),((((1,((1,((2,2),(43,12))),((5,6),(1,2)))),1),1),2)),1),1))),2)");
  v.push_back("((1,(1,((((((1,1),(1,(2,((1,3),1)))),1),((((1,((1,(1,(68,13))),((6,5),3))),1),(1,2)),1)),1),1))),(1,1))");
  v.push_back("((1,(1,((((((2,1),(1,((1,1),2))),1),((((1,((1,((1,2),(59,9))),((11,2),(1,1)))),1),(1,7)),1)),1),1))),((1,1),1))");
  v.push_back("((1,(1,((((((1,1),(1,(2,((1,(2,1)),1)))),1),((((1,((1,((1,2),(42,7))),((8,4),1))),1),(2,3)),1)),1),2))),1)");
  v.push_back("((1,(1,(((((((1,3),1),(1,(1,((1,1),1)))),1),((((1,((1,((2,1),(48,14))),((4,4),4))),1),(3,1)),1)),1),1))),((1,(1,1)),1))");
  v.push_back("((1,(1,(((((1,(1,(1,1))),1),((((1,((1,(5,(36,12))),((4,4),4))),1),8),1)),1),1))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,(3,((1,(1,2)),1)))),1),((((1,((1,(3,(33,12))),((4,3),1))),1),(2,3)),(1,1))),1),1))),2)");
  v.push_back("((1,(1,(((((1,(1,((3,1),((1,1),1)))),1),((((1,((1,((1,1),(49,10))),((9,4),2))),1),(1,5)),1)),1),1))),(2,1))");
  v.push_back("((1,(1,(((((1,(1,((1,1),(3,1)))),1),((((1,((1,(1,(32,11))),((5,4),1))),1),(2,8)),(3,1))),1),1))),(1,1))");
  v.push_back("((1,(1,(((((2,(1,((1,1),(3,1)))),1),((((1,((1,(1,(54,12))),((7,4),1))),1),(1,6)),2)),1),1))),(1,1))");
  v.push_back("((1,(1,(((((((2,1),1),(1,(1,((1,1),1)))),1),((((1,((1,(2,(48,11))),((5,6),2))),1),(1,4)),1)),1),1))),2)");
  v.push_back("((1,(1,((((((2,1),(1,((2,2),((1,1),1)))),1),((((1,((1,((2,2),(61,14))),((4,3),1))),1),(1,3)),(1,1))),1),1))),((1,1),1))");
  v.push_back("((1,(1,(((((1,(1,((1,1),((1,1),1)))),1),((((1,((1,((1,4),(59,17))),((4,(1,1)),(1,1)))),1),(2,8)),1)),1),3))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,((1,2),((1,1),1)))),1),((((1,((1,((4,2),(45,7))),((5,4),(1,1)))),1),(2,6)),((1,1),1))),1),1))),(1,1))");
  v.push_back("((1,(1,(((((1,(2,((1,1),1))),1),((((1,((1,(3,(33,10))),((6,3),(1,1)))),1),(1,5)),2)),1),2))),2)");
  v.push_back("((1,(1,(((((((2,1),1),(1,(3,(2,1)))),1),((((1,((1,((1,1),(50,7))),((6,4),2))),1),(1,4)),1)),1),1))),(1,1))");
  v.push_back("((1,(1,(((((2,(1,((1,2),2))),1),((((1,((1,((2,2),(62,8))),((10,(2,1)),(1,1)))),1),(1,4)),1)),1),1))),(1,1))");
  v.push_back("((1,(1,(((((3,(2,((2,1),((1,(1,1)),1)))),1),((((1,((1,((1,2),(41,20))),((4,1),2))),1),(1,8)),1)),1),1))),1)");
  v.push_back("((1,(1,(((((1,(1,(1,((1,1),1)))),1),((((1,((1,((4,1),(44,16))),((7,3),1))),1),(2,7)),1)),1),1))),2)");
  v.push_back("((1,(1,((((((2,1),(1,(1,((1,(1,1)),1)))),1),((((1,((1,((1,3),(57,18))),((2,(7,1)),2))),1),4),((1,1),1))),1),1))),((1,2),1))");
  v.push_back("((1,(1,((((((2,1),(1,(4,((1,2),1)))),1),((((1,((1,((4,1),(58,11))),((10,1),1))),1),(1,1)),1)),1),1))),((1,2),1))");
  v.push_back("((1,(1,(((((2,(1,(1,((1,(1,1)),1)))),1),((((1,((1,((1,4),(42,7))),((5,4),1))),1),5),1)),1),2))),(2,1))");
  v.push_back("((1,(1,(((((1,(1,(1,((1,(1,1)),1)))),1),((((1,((1,(5,(60,14))),((4,5),(1,1)))),1),(1,4)),2)),1),1))),((1,(2,1)),1))");
  v.push_back("((1,(1,(((((3,(1,(1,(2,1)))),1),((((1,((1,(1,(53,11))),((4,(2,1)),(2,1)))),1),(1,3)),2)),1),3))),(1,1))");
  v.push_back("((1,(1,(((((2,(1,(2,((1,2),1)))),1),((((1,((1,(2,(47,13))),((7,2),1))),1),(1,3)),1)),1),2))),(2,1))");
  v.push_back("((1,(1,(((((1,(1,((1,1),1))),1),((((1,((1,((2,1),(53,8))),((7,2),3))),1),(3,5)),2)),1),1))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,(1,(2,1)))),1),((((1,((1,((2,2),(40,7))),((4,7),2))),1),3),1)),1),2))),((1,2),1))");
  v.push_back("((1,(1,((((((1,1),(1,((1,1),(2,1)))),1),((((1,((1,((1,2),(52,5))),((6,(5,2)),(1,2)))),1),(1,4)),1)),1),1))),(3,1))");
  v.push_back("((1,(1,(((((1,(1,((3,1),((1,1),1)))),1),((((1,((1,((3,1),(62,20))),((10,(1,1)),2))),1),(1,4)),1)),1),1))),((1,2),1))");
  v.push_back("((1,(1,((((((2,1),(1,(2,(1,1)))),1),((((1,((1,((3,2),(56,10))),((5,(5,1)),1))),1),3),(1,1))),1),1))),2)");
  v.push_back("((1,(1,(((((((2,1),1),(1,(3,((1,(3,3)),1)))),1),((((1,((1,((3,1),(48,9))),((1,(1,1)),3))),1),(1,4)),((1,2),1))),1),1))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,(1,5))),1),((((1,((1,(1,(44,11))),((7,3),2))),1),(1,3)),(2,1))),1),2))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,((1,2),((1,1),1)))),1),((((1,((1,((5,1),(66,13))),((8,6),2))),1),(1,2)),1)),1),1))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,(4,(2,1)))),1),((((1,((1,(4,(55,7))),((8,2),(1,1)))),1),(1,3)),1)),1),2))),2)");
  v.push_back("((1,(1,((((((1,1),(1,(1,3))),1),((((1,((1,((2,1),(55,12))),((7,3),1))),1),8),3)),1),1))),((1,1),1))");
  v.push_back("((1,(1,(((((1,(1,((1,2),((1,(2,1)),1)))),1),((((1,((1,(2,(50,13))),((6,5),2))),1),(3,2)),1)),1),1))),((1,1),1))");
  v.push_back("((1,(1,((((4,1),((((1,((1,((1,2),(57,5))),((4,4),1))),1),(2,8)),2)),1),1))),((1,2),1))");
  v.push_back("((1,(1,((((((1,1),(1,(2,((1,2),1)))),1),((((1,((1,(4,(63,11))),((3,(5,1)),1))),1),(1,7)),2)),1),1))),1)");
  v.push_back("((1,(1,(((((((1,1),1),(1,(2,((1,1),1)))),1),((((1,((1,((1,3),(55,13))),((5,6),1))),1),(1,7)),(2,1))),1),1))),((1,(1,1)),1))");
  v.push_back("((1,(1,((((((2,1),(1,((1,1),((1,1),1)))),1),((((1,((1,((2,3),(48,15))),((5,(1,1)),2))),1),(3,5)),((1,1),1))),1),1))),((1,(1,1)),1))");
  v.push_back("((1,(1,(((((1,(1,(2,(2,1)))),1),((((1,((1,((3,4),(49,9))),((4,4),1))),1),5),1)),1),1))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,(2,(4,1)))),1),((((1,((1,(3,(53,7))),((4,(4,1)),1))),1),(3,5)),1)),1),1))),1)");
  v.push_back("((1,(1,(((((((1,1),1),(1,((1,1),(2,1)))),1),((((1,((1,(2,(75,16))),((5,6),1))),1),(1,5)),1)),1),1))),(3,1))");
  v.push_back("((1,(1,((((((1,1),(2,(1,(1,1)))),1),((((1,((1,((1,1),(49,20))),((6,1),(1,1)))),1),4),3)),1),5))),2)");
  v.push_back("((1,(1,(((((1,(1,(2,(2,1)))),1),((((1,((1,(4,(38,10))),((5,(3,1)),3))),1),7),1)),1),1))),((1,1),1))");
  v.push_back("((1,(1,(((((1,(1,(1,((1,(1,1)),1)))),1),((((1,((1,((2,3),(38,9))),((10,8),2))),1),5),1)),1),1))),1)");
  v.push_back("((1,(1,(((((2,(1,((1,1),(1,1)))),1),((((1,((1,((1,2),(72,10))),((5,6),3))),1),(1,5)),(1,1))),1),1))),((1,1),1))");
  v.push_back("((1,(1,((((((1,1),(1,((1,1),((1,(2,1)),1)))),1),((((1,((1,((3,1),(41,11))),((6,(6,2)),2))),1),(2,2)),1)),1),1))),((1,1),1))");
  v.push_back("((1,(1,(((((2,(1,(1,(1,2)))),1),((((1,((1,(2,(35,15))),((7,5),1))),1),(1,5)),1)),1),2))),2)");
  v.push_back("((1,(1,((((((1,1),(1,((1,1),(1,1)))),1),((((1,((1,((5,2),(59,15))),((7,4),1))),1),(1,5)),1)),1),2))),((1,(1,1)),1))");
  v.push_back("((1,(1,((((((2,1),(1,(2,(1,1)))),1),((((1,((1,(1,(52,18))),((4,5),2))),1),(1,5)),1)),1),1))),((1,2),1))");
  v.push_back("((1,(1,(((((2,(1,(1,(2,1)))),1),((((1,((1,((1,3),(52,15))),((3,2),(2,1)))),1),(2,4)),1)),1),2))),1)");
  v.push_back("((1,(1,((((((1,1),(2,((1,1),((1,(2,1)),1)))),1),((((1,((1,((4,1),(42,11))),((7,3),2))),1),4),2)),1),1))),((1,1),1))");
  v.push_back("((1,(1,(((((1,(1,(4,((1,(1,1)),1)))),1),((((1,((1,(2,(58,13))),((8,3),1))),1),(1,8)),1)),1),1))),2)");
  v.push_back("((1,(1,(((((((1,1),1),(1,(1,((1,2),1)))),1),((((1,((1,((1,3),(44,12))),((3,(3,2)),2))),1),4),2)),1),1))),(3,1))");
  v.push_back("((1,(1,((((((1,2),(1,((1,1),3))),1),((((1,((1,((3,1),(39,9))),((4,(5,1)),1))),1),(3,5)),1)),1),1))),((1,1),1))");
  v.push_back("((1,(1,(((((2,(1,((1,1),(3,1)))),1),((((1,((1,((1,1),(59,16))),((9,2),2))),1),(1,5)),1)),1),1))),2)");
  v.push_back("((1,(1,(((((1,(1,(2,2))),1),((((1,((1,(1,(44,5))),((8,3),2))),1),(3,3)),3)),1),2))),(1,1))");
  v.push_back("((1,(1,((((((2,1),(1,(2,((1,4),1)))),1),((((1,((1,(3,(48,14))),((12,(1,1)),(1,1)))),1),1),2)),1),2))),2)");
  v.push_back("((1,(1,(((((2,(1,(2,((1,(1,2)),1)))),1),((((1,((1,((2,1),(55,7))),((3,3),2))),1),(2,9)),1)),1),1))),((1,1),1))");
  v.push_back("((1,(1,(((((1,(1,(1,((1,5),1)))),1),((((1,((1,((1,3),(41,12))),((3,3),4))),1),(1,4)),1)),1),1))),(3,1))");
  v.push_back("((1,(1,((((((3,1),(1,((1,1),((1,(1,1)),1)))),1),((((1,((1,(1,(78,19))),((4,(10,1)),2))),1),(1,7)),1)),1),1))),((1,1),1))");
  v.push_back("((1,(1,(((((1,(2,(1,((1,2),1)))),1),((((1,((1,(1,(37,14))),((3,(3,1)),(1,3)))),1),(1,6)),2)),1),4))),((1,(1,1)),1))");
  v.push_back("((1,(1,(((((2,(1,(2,((1,2),1)))),1),((((1,((1,((3,1),(54,7))),((4,2),(1,3)))),1),(1,6)),1)),1),2))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,(2,2))),1),((((1,((1,(3,(53,9))),((7,(6,1)),(1,1)))),1),(3,4)),1)),1),1))),((1,(1,1)),1))");
  v.push_back("((1,(1,((((((1,1),(1,(2,(2,1)))),1),((((1,((1,(1,(71,12))),((10,(3,1)),2))),1),(2,4)),1)),1),2))),(1,1))");
  v.push_back("((1,(1,(((((((1,1),1),(1,(1,((1,1),1)))),1),((((1,((1,(2,(55,8))),((6,7),2))),1),(5,5)),1)),1),1))),((1,(1,1)),1))");
  v.push_back("((1,(1,(((((1,(1,((1,1),((1,(1,2)),1)))),1),((((1,((1,((2,3),(43,12))),((1,7),1))),1),(2,6)),(1,1))),1),2))),((1,2),1))");
  v.push_back("((1,(1,(((((1,(1,(1,((1,5),1)))),1),((((1,((1,((4,2),(44,6))),((4,(3,1)),2))),1),(2,2)),1)),1),1))),(3,1))");
  v.push_back("((1,(1,(((((1,(2,(1,((1,1),1)))),1),((((1,((1,(5,(41,7))),((5,7),1))),1),(3,11)),1)),1),1))),(1,1))");
  v.push_back("((1,(1,((((((2,1),(1,(1,((1,(2,1)),1)))),1),((((1,((1,((1,3),(65,16))),((9,(5,1)),(1,1)))),1),(1,4)),(1,1))),1),1))),((1,1),1))");
  v.push_back("((1,(1,(((((2,(1,(1,((1,3),1)))),1),((((1,((1,((1,1),(67,5))),((5,7),1))),1),(3,4)),1)),1),3))),((1,1),1))");
  v.push_back("((1,(1,(((((1,(1,(1,4))),1),((((1,((1,((4,1),(48,16))),((3,6),1))),1),(1,3)),1)),1),3))),2)");
  v.push_back("((1,(1,((((((1,2),(3,(1,((1,2),1)))),1),((((1,((1,((3,1),(57,10))),((3,3),3))),1),(1,3)),1)),1),1))),2)");
  v.push_back("((1,(1,(((((((1,1),1),(1,((2,3),(2,1)))),1),((((1,((1,(2,(46,9))),((4,(2,2)),(1,1)))),1),(2,9)),1)),1),1))),(1,1))");
  v.push_back("((1,(1,(((((1,(2,((1,1),3))),1),((((1,((1,((1,1),(46,5))),((9,3),(2,1)))),1),(2,9)),1)),1),1))),((1,2),1))");
  v.push_back("((1,(1,((((((3,1),(1,((1,1),((1,(2,1)),1)))),1),((((1,((1,((3,2),(68,16))),((5,2),(1,1)))),1),7),1)),1),1))),((1,(1,1)),1))");
  return v;
}
//---------------------------------------------------------------------------
const std::vector<std::string> GetHardNewicks()
{
  std::vector<std::string> v;
  v.push_back("((4,4),4)");
  v.push_back("(((4,4),4),4)");
  v.push_back("((((4,4),4),4),4)");
  v.push_back("(((((4,4),4),4),4),4)");
  v.push_back("((((((4,4),4),4),4),4),4)");
  v.push_back("(((((((4,4),4),4),4),4),4),4)");
  v.push_back("((((((((4,4),4),4),4),4),4),4),4)");
  v.push_back("(((((((((4,4),4),4),4),4),4),4),4),4)");
  v.push_back("((((((((((4,4),4),4),4),4),4),4),4),4),4)");
  v.push_back("(((((((((((4,4),4),4),4),4),4),4),4),4),4),4)");
  v.push_back("((((((((((((4,4),4),4),4),4),4),4),4),4),4),4),4)");
  v.push_back("(((((((((((((4,4),4),4),4),4),4),4),4),4),4),4),4),4)");
  v.push_back("((((((((((((((4,4),4),4),4),4),4),4),4),4),4),4),4),4),4)");
  v.push_back("(((((((((((((((4,4),4),4),4),4),4),4),4),4),4),4),4),4),4),4)");
  v.push_back("((((((((((((((((4,4),4),4),4),4),4),4),4),4),4),4),4),3),3),3),3)");
  return v;
}
//---------------------------------------------------------------------------
const std::vector<std::string> GetLightBiologicalNewicks()
{
  std::vector<std::string> v;
  v.push_back("((1,(1,((((((1,1),(1,1)),1),((((1,((1,(1,(10,3))),((3,2),1))),1),2),1)),1),1))),1)");
  v.push_back("((1,(1,(((((1,(1,(2,1))),1),((((1,((1,(1,(18,3))),((1,(2,2)),2))),1),1),1)),1),1))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,(1,((1,(1,4)),1)))),1),((((1,((1,(2,(11,5))),((1,1),1))),1),2),1)),1),1))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,(1,((1,1),1)))),1),((((1,((1,((1,1),(12,6))),(4,1))),1),(1,2)),2)),1),1))),((1,1),1))");
  v.push_back("((1,(1,(((((1,(1,((2,1),(1,1)))),1),((((1,((1,(2,(32,6))),((1,2),(1,1)))),1),(1,1)),1)),1),1))),1)");
  v.push_back("((1,(1,(((((1,2),1),((((1,((1,((1,1),(17,3))),(4,1))),1),7),1)),1),1))),(1,1))");
  v.push_back("((1,(1,((((((1,1),(1,(1,2))),1),((((1,((1,(1,(29,3))),((5,1),1))),1),(2,1)),1)),1),1))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,1)),1),((((1,((1,((1,1),(30,7))),((6,(1,1)),(1,2)))),1),(1,1)),(1,1))),1),1))),1)");
  v.push_back("((1,(1,(((((1,(1,(1,1))),1),((((1,((1,(2,(19,3))),(4,1))),1),3),1)),1),1))),(2,1))");
  v.push_back("((1,(1,(((((1,(1,(1,(1,1)))),1),((((1,((1,((1,1),(18,4))),((2,2),1))),1),7),1)),1),1))),2)");
  v.push_back("((1,(1,(((((1,(1,(1,2))),1),((((1,((1,(1,(11,7))),((4,(2,1)),1))),1),3),1)),1),1))),1)");
  v.push_back("((1,(1,(((((2,(1,((1,2),1))),1),((((1,((1,(2,(22,4))),((1,2),(1,1)))),1),(1,1)),1)),1),1))),2)");
  v.push_back("((1,(1,((((2,1),((((1,((1,(1,(16,9))),((2,4),1))),1),2),1)),1),1))),((1,1),1))");
  v.push_back("((1,(1,(((((2,(1,(1,(1,1)))),1),((((1,((1,(3,(37,12))),((2,1),1))),1),(1,1)),1)),1),1))),((1,1),1))");
  v.push_back("((1,(1,(((((1,(1,(2,(1,1)))),1),((((1,((1,((1,1),(19,3))),((3,1),1))),1),(3,3)),(1,1))),1),1))),1)");
  v.push_back("((1,(1,(((((((1,1),1),(1,(1,((1,1),1)))),1),((((1,((1,(1,(27,5))),((4,2),1))),1),3),1)),1),1))),1)");
  v.push_back("((1,(1,(((((1,(1,(2,2))),1),((((1,((1,(2,(37,5))),((2,(2,1)),1))),1),(1,1)),1)),1),1))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,(1,((1,1),2)))),1),((((1,((1,(1,(23,8))),((3,3),1))),1),(1,2)),1)),1),1))),1)");
  v.push_back("((1,(1,(((((1,(1,(1,(1,2)))),1),((((1,((1,((1,1),(26,4))),((2,3),1))),1),3),1)),1),1))),2)");
  v.push_back("((1,(1,((((((1,1),(1,(1,((1,(2,1)),1)))),1),((((1,((1,(1,(13,7))),((2,3),3))),1),(1,2)),1)),1),1))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,(2,((1,1),1)))),1),((((1,((1,(2,(28,5))),((2,1),2))),1),1),2)),1),1))),2)");
  v.push_back("((1,(1,(((((1,(2,((1,1),2))),1),((((1,((1,(1,(23,7))),((3,2),1))),1),(1,1)),1)),1),1))),(2,1))");
  v.push_back("((1,(1,(((((1,(1,(2,((1,(1,1)),1)))),1),((((1,((1,((1,1),(35,7))),((5,1),1))),1),2),1)),1),1))),((1,1),1))");
  v.push_back("((1,(1,(((((1,(1,(1,1))),1),((((1,((1,((2,1),(24,4))),((3,3),1))),1),3),1)),1),1))),2)");
  v.push_back("((1,(1,(((((1,(1,(1,(3,1)))),1),((((1,((1,(1,(34,7))),(1,2))),1),7),(1,1))),1),1))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,(1,(1,1)))),1),((((1,((1,(2,(26,8))),((4,3),1))),1),1),1)),2),1))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,(1,2))),1),((((1,((1,(2,(31,7))),((3,2),1))),1),2),1)),1),1))),((1,1),1))");
  v.push_back("((1,(1,(((((1,(1,(1,1))),1),((((1,((1,(1,(29,9))),((3,(1,1)),1))),1),(1,3)),2)),1),2))),1)");
  v.push_back("((1,(1,(((((2,(1,(2,2))),1),((((1,((1,(1,(13,7))),((3,1),2))),1),1),1)),1),1))),(2,1))");
  v.push_back("((1,(1,(((((1,(1,(2,((1,1),1)))),1),((((1,((1,(1,(35,11))),((3,(1,1)),1))),1),(1,2)),1)),1),1))),2)");
  v.push_back("((1,(1,(((((1,(1,2)),1),((((1,((1,(1,(32,10))),((3,3),1))),1),1),1)),1),1))),((1,2),1))");
  v.push_back("((1,(1,(((((1,(1,(1,((1,2),1)))),1),((((1,((1,(1,(31,9))),((1,3),1))),1),3),2)),1),1))),((1,(1,1)),1))");
  v.push_back("((1,(1,(((((1,(1,(1,((1,2),1)))),1),((((1,((1,(1,(27,3))),((3,3),1))),1),(1,2)),(1,1))),1),2))),(2,1))");
  v.push_back("((1,(1,(((((1,(1,(2,(2,1)))),1),((((1,((1,(2,(23,4))),((3,2),1))),1),3),1)),1),1))),1)");
  v.push_back("((1,(1,(((((1,(1,(1,(1,1)))),1),((((1,((1,(2,(16,3))),((2,2),(1,1)))),1),(2,3)),3)),1),1))),(2,1))");
  v.push_back("((1,(1,(((((1,(1,(2,2))),1),((((1,((1,(1,(19,7))),((2,2),2))),1),(1,1)),1)),1),1))),2)");
  v.push_back("((1,(1,(((((1,(1,(1,((1,(1,1)),1)))),1),((((1,((1,((1,1),(32,5))),((3,6),(1,1)))),1),2),1)),1),1))),(2,1))");
  v.push_back("((1,(1,(((((1,(1,((1,1),((1,(1,1)),1)))),1),((((1,((1,(1,(32,13))),((1,(2,2)),1))),1),(3,2)),1)),1),1))),1)");
  v.push_back("((1,(1,((((((1,1),(1,(2,1))),1),((((1,((1,(1,(23,4))),((3,4),2))),1),2),1)),1),1))),2)");
  v.push_back("((1,(1,(((((((1,1),1),(1,(2,1))),1),((((1,((1,((4,2),(25,2))),((2,1),2))),1),(1,3)),1)),1),1))),1)");
  v.push_back("((1,(1,(((((1,(1,((1,1),((1,1),1)))),1),((((1,((1,((4,1),(30,9))),((4,3),1))),1),1),1)),1),1))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,(1,2))),1),((((1,((1,(2,19)),((5,2),2))),1),4),(1,1))),1),1))),2)");
  v.push_back("((1,(1,((((((2,1),(1,(1,(2,1)))),1),((((1,((1,(4,(44,6))),((1,(1,1)),3))),1),(1,1)),(1,1))),1),1))),(1,1))");
  v.push_back("((1,(1,(((((2,(1,((1,1),((1,(1,1)),1)))),1),((((1,((1,(1,(31,8))),((6,1),1))),1),1),2)),1),2))),1)");
  v.push_back("((1,(1,(((((1,(1,(1,3))),1),((((1,((1,(2,(23,6))),(4,1))),1),2),1)),1),1))),(2,1))");
  v.push_back("((1,(1,(((((1,(1,(1,((1,(1,1)),2)))),1),((((1,((1,(1,(27,8))),(4,2))),1),5),1)),1),1))),1)");
  v.push_back("((1,(1,(((((((1,2),1),(1,3)),1),((((1,((1,(2,(23,9))),((4,1),1))),1),(1,2)),1)),1),1))),1)");
  v.push_back("((1,(1,((((((1,1),(1,((1,1),(2,1)))),1),((((1,((1,(2,(40,10))),((2,4),1))),1),1),1)),1),1))),((1,1),1))");
  v.push_back("((1,(1,(((((1,(1,(1,(1,1)))),1),((((1,((1,((2,2),(35,8))),((2,2),1))),1),(1,4)),1)),1),1))),1)");
  v.push_back("((1,(1,(((((1,(1,(1,((1,2),1)))),1),((((1,((1,((1,2),(27,7))),((2,2),2))),1),(1,1)),1)),1),1))),(2,1))");
  v.push_back("((1,(1,((((((1,1),(1,(1,((1,2),1)))),1),((((1,((1,((2,1),(33,5))),((1,(2,1)),1))),1),(2,6)),1)),1),1))),(1,1))");
  v.push_back("((1,(1,(((((2,(1,((1,1),((1,1),1)))),1),((((1,((1,(1,(38,4))),((2,3),(1,3)))),1),(1,3)),(1,1))),1),1))),1)");
  v.push_back("((1,(1,(((((1,(1,((1,2),((1,1),1)))),1),((((1,((1,(2,(22,4))),((2,(3,1)),3))),1),(1,3)),1)),1),1))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,(1,3))),1),((((1,((1,(2,(21,2))),((4,2),2))),1),3),2)),1),1))),1)");
  v.push_back("((1,(1,(((((1,(1,((2,2),(1,1)))),1),((((1,((1,(1,(36,8))),((2,2),1))),1),2),2)),1),1))),(1,1))");
  v.push_back("((1,(1,((((((1,1),(1,(2,((1,2),1)))),1),((((1,((1,(1,(25,9))),((4,1),1))),1),(1,6)),1)),1),1))),1)");
  v.push_back("((1,(1,(((((1,(1,(1,((1,(1,1)),1)))),1),((((1,((1,((1,1),(22,9))),((5,3),1))),1),5),1)),1),1))),((1,1),1))");
  v.push_back("((1,(1,(((((3,3),1),((((1,((1,(1,(21,8))),((3,1),3))),1),(1,1)),1)),1),1))),2)");
  v.push_back("((1,(1,(((((1,(1,(2,((1,4),1)))),1),((((1,((1,(4,(28,10))),((1,1),1))),1),(1,1)),1)),1),1))),(2,1))");
  v.push_back("((1,(1,(((((1,(1,(2,((1,(1,1)),1)))),1),((((1,((1,((2,1),(46,3))),((1,4),1))),1),(1,4)),1)),1),1))),2)");
  v.push_back("((1,(1,(((((1,(1,(3,(2,1)))),1),((((1,((1,(2,(35,11))),1)),1),(1,2)),(3,1))),1),1))),1)");
  v.push_back("((1,(1,(((((3,(1,(1,((1,1),1)))),1),((((1,((1,(2,(25,4))),((2,1),(2,1)))),1),5),1)),1),2))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,(1,((1,1),1)))),1),((((1,((1,(3,(42,6))),((3,3),1))),1),3),1)),1),1))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,(1,1))),1),((((1,((1,((1,1),(37,5))),((7,2),1))),1),(1,3)),(3,1))),1),1))),((1,1),1))");
  v.push_back("((1,(1,(((((2,(1,(1,1))),1),((((1,((1,(3,(20,7))),((3,2),1))),1),2),2)),1),1))),1)");
  v.push_back("((1,(1,(((((1,(1,((2,1),2))),1),((((1,((1,((3,1),(18,6))),((4,1),2))),1),(2,1)),(1,1))),1),1))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,((1,2),((1,1),1)))),1),((((1,((1,((1,4),(30,6))),((3,1),1))),1),(1,5)),1)),1),1))),((1,1),1))");
  v.push_back("((1,(1,(((((1,(1,((1,1),((1,(1,1)),1)))),1),((((1,((1,(2,(26,7))),((5,2),1))),1),7),1)),1),1))),(1,1))");
  v.push_back("((1,(1,(((((2,(1,(1,((1,2),1)))),1),((((1,((1,((2,1),(31,9))),((2,1),1))),1),(1,2)),2)),1),1))),((1,1),1))");
  v.push_back("((1,(1,(((((1,(1,(1,1))),1),((((1,((1,(1,(33,9))),((7,2),2))),1),2),1)),1),1))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,(2,(1,1)))),1),((((1,((1,(1,(40,12))),((4,1),1))),1),3),1)),1),1))),2)");
  v.push_back("((1,(1,((((((1,1),(1,((1,1),1))),1),((((1,((1,(1,(29,8))),((6,3),1))),1),4),1)),1),1))),1)");
  v.push_back("((1,(2,((((((2,1),(1,((1,1),((1,(1,1)),1)))),1),((((1,((1,((1,1),(34,6))),((3,(1,1)),(1,1)))),1),3),3)),1),1))),((1,1),1))");
  v.push_back("((1,(1,(((((1,(1,(1,((1,4),1)))),1),((((1,((1,((1,1),(44,10))),((1,3),1))),1),5),1)),1),1))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,((1,1),1))),1),((((1,((1,((3,1),(44,5))),((2,(3,1)),(3,1)))),1),2),1)),1),1))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,(1,2))),1),((((1,((1,(1,(34,7))),((4,(1,3)),1))),1),2),1)),1),2))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,(1,((1,2),1)))),1),((((1,((1,(2,(15,5))),((4,3),2))),1),3),1)),1),1))),1)");
  v.push_back("((1,(1,(((((2,(1,(1,2))),1),((((1,((1,(1,(16,4))),((1,(4,1)),(2,2)))),1),5),1)),1),1))),((1,1),1))");
  v.push_back("((1,(1,((((((3,1),(1,(1,(3,1)))),1),((((1,((1,(2,(26,5))),((2,2),1))),1),(1,3)),1)),1),1))),1)");
  v.push_back("((1,(1,(((((1,(1,((1,1),((1,(1,2)),1)))),1),((((1,((1,(1,(42,9))),((3,2),3))),1),(1,2)),(1,1))),1),1))),((1,1),1))");
  v.push_back("((1,(1,((((((2,1),(1,(1,((1,(1,1)),1)))),1),((((1,((1,((1,2),(15,5))),((5,3),(1,1)))),1),(1,3)),1)),1),1))),((1,2),1))");
  v.push_back("((1,(1,(((((1,(1,(1,(4,1)))),1),((((1,((1,(3,(28,5))),((1,(3,1)),1))),1),2),1)),1),1))),2)");
  v.push_back("((1,(1,(((((1,(1,((2,2),(1,2)))),1),((((1,((1,(1,(29,6))),((4,3),1))),1),1),1)),1),1))),((1,(1,1)),1))");
  v.push_back("((1,(1,(((((2,(1,(2,2))),1),((((1,((1,(3,(20,5))),(4,1))),1),(3,1)),1)),1),1))),((1,1),1))");
  v.push_back("((1,(1,(((((1,(1,((2,2),4))),1),((((1,((1,((1,1),(36,9))),((1,(1,1)),1))),1),3),1)),1),1))),(2,1))");
  v.push_back("((1,(1,(((((1,(1,(1,1))),1),((((1,((1,((1,1),(33,13))),((5,4),1))),1),2),1)),1),1))),(2,1))");
  v.push_back("((1,(1,(((((1,(1,(1,(1,1)))),1),((((1,((1,((2,1),(47,10))),((3,(1,1)),1))),1),(1,5)),2)),1),1))),((1,1),1))");
  v.push_back("((1,(1,(((((1,(1,2)),1),((((1,((1,((2,1),(13,3))),((5,2),(1,2)))),1),3),2)),1),2))),(1,1))");
  v.push_back("((1,(1,(((((2,(1,(1,((1,2),1)))),1),((((1,((1,(1,(30,7))),((3,1),(1,2)))),1),4),1)),1),1))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,(1,(2,2)))),1),((((1,((1,(2,(23,8))),((3,1),1))),1),(1,2)),1)),1),1))),(3,1))");
  v.push_back("((1,(1,(((((1,(1,(1,((1,(2,1)),1)))),1),((((1,((1,((4,1),(42,5))),((4,1),1))),1),(1,4)),1)),1),1))),1)");
  v.push_back("((1,(1,(((((1,(1,(2,((1,2),1)))),1),((((1,((1,(2,(21,6))),((6,2),1))),1),3),1)),1),1))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,((2,1),2))),1),((((1,((1,(2,(29,6))),((2,2),1))),1),(1,4)),1)),1),1))),((1,1),1))");
  v.push_back("((1,(1,(((((((1,1),1),(1,(1,((1,2),1)))),1),((((1,((1,(3,(47,6))),((4,1),1))),1),(1,5)),1)),1),1))),(1,1))");
  v.push_back("((1,(1,(((((1,(1,1)),1),((((1,((1,(1,(51,10))),((3,2),(1,2)))),1),(2,1)),1)),1),1))),2)");
  v.push_back("((1,(1,(((((1,(1,(2,2))),1),((((1,((1,(2,(22,2))),((2,6),1))),1),5),1)),1),1))),2)");
  v.push_back("((1,(1,((((((1,1),(1,(1,(1,1)))),1),((((1,((1,(1,(46,10))),((2,2),2))),1),(1,4)),1)),1),1))),(2,1))");
  v.push_back("((1,(1,(((((1,(1,(1,((1,3),1)))),1),((((1,((1,((1,1),(18,7))),((6,1),1))),1),(1,3)),1)),1),1))),(3,1))");
  v.push_back("((2,(1,(((((1,(1,((1,1),1))),1),((((1,((1,((3,1),(28,8))),((2,(2,2)),3))),1),(1,1)),1)),1),1))),((1,1),1))");
  v.push_back("((1,(1,(((((1,(1,(3,(1,1)))),1),((((1,((1,((3,1),(23,7))),((3,2),1))),1),(1,2)),1)),1),1))),(2,1))");
  return v;
}
//---------------------------------------------------------------------------
const std::vector<std::string> GetLightNewicks()
{
  std::vector<std::string> v;
  v.push_back("((2,2),2)");
  v.push_back("(((2,2),2),2)");
  v.push_back("((((2,2),2),2),2)");
  v.push_back("(((((2,2),2),2),2),2)");
  v.push_back("((((((2,2),2),2),2),2),2)");
  v.push_back("(((((((2,2),2),2),2),2),2),2)");
  v.push_back("((((((((2,2),2),2),2),2),2),2),2)");
  v.push_back("(((((((((2,2),2),2),2),2),2),2),2),2)");
  v.push_back("((((((((((2,2),2),2),2),2),2),2),2),2),2)");
  v.push_back("(((((((((((2,2),2),2),2),2),2),2),2),2),2),2)");
  v.push_back("((((((((((((2,2),2),2),2),2),2),2),2),2),2),2),2)");
  v.push_back("(((((((((((((2,2),2),2),2),2),2),2),2),2),2),2),2),2)");
  v.push_back("((((((((((((((2,2),2),2),2),2),2),2),2),2),2),2),2),2),2)");
  v.push_back("(((((((((((((((2,2),2),2),2),2),2),2),2),2),2),2),2),2),2),2)");
  return v;
}
//---------------------------------------------------------------------------
/*
const std::vector<std::string> GetManyNewicks()
{
  std::vector<std::string> v;
  {
    std::vector<std::string> w = GetLightNewicks();
    std::copy(w.begin(),w.end(),std::back_inserter(v));
  }
  {
    std::vector<std::string> w = GetMediumNewicks();
    std::copy(w.begin(),w.end(),std::back_inserter(v));
  }
  {
    std::vector<std::string> w = GetHardNewicks();
    std::copy(w.begin(),w.end(),std::back_inserter(v));
  }
  return v;
}
*/
//---------------------------------------------------------------------------
const std::vector<std::string> GetMediumNewicks()
{
  std::vector<std::string> v;
  v.push_back("((3,3),3)");
  v.push_back("(((3,3),3),3)");
  v.push_back("((((3,3),3),3),3)");
  v.push_back("(((((3,3),3),3),3),3)");
  v.push_back("((((((3,3),3),3),3),3),3)");
  v.push_back("(((((((3,3),3),3),3),3),3),3)");
  v.push_back("((((((((3,3),3),3),3),3),3),3),3)");
  v.push_back("(((((((((3,3),3),3),3),3),3),3),3),3)");
  v.push_back("((((((((((3,3),3),3),3),3),3),3),3),3),3)");
  v.push_back("(((((((((((3,3),3),3),3),3),3),3),3),3),3),3)");
  v.push_back("((((((((((((3,3),3),3),3),3),3),3),3),3),3),3),3)");
  return v;
}
//---------------------------------------------------------------------------
const std::vector<std::string> GetManyNewicks()
{
  std::vector<std::string> v;
  v.push_back("((90,1000),100)");
  v.push_back("((90,100),1000)");
  v.push_back("((90,100),100)");
  v.push_back("((80,1000),100)");
  v.push_back("((80,100),1000)");
  v.push_back("((80,100),100)");
  v.push_back("((70,1000),100)");
  v.push_back("((70,100),1000)");
  v.push_back("((70,100),100)");
  v.push_back("((60,1000),100)");
  v.push_back("((60,100),1000)");
  v.push_back("((60,100),100)");
  v.push_back("((50,1000),100)");
  v.push_back("((50,100),1000)");
  v.push_back("((50,100),100)");
  v.push_back("((5,5),5)");
  v.push_back("((40,1000),100)");
  v.push_back("((40,100),1000)");
  v.push_back("((40,100),100)");
  v.push_back("((30,1000),100)");
  v.push_back("((30,100),1000)");
  v.push_back("((30,100),100)");
  v.push_back("((3,3),3)");
  v.push_back("((20,1000),100)");
  v.push_back("((20,100),1000)");
  v.push_back("((20,100),100)");
  v.push_back("((2,3),3)");
  v.push_back("((2,2),3)");
  v.push_back("((2,2),2)");
  v.push_back("((1000,100),90)");
  v.push_back("((1000,100),80)");
  v.push_back("((1000,100),70)");
  v.push_back("((1000,100),60)");
  v.push_back("((1000,100),50)");
  v.push_back("((1000,100),40)");
  v.push_back("((1000,100),30)");
  v.push_back("((1000,100),20)");
  v.push_back("((1000,100),100)");
  v.push_back("((1000,100),10)");
  v.push_back("((100,100),90)");
  v.push_back("((100,100),80)");
  v.push_back("((100,100),70)");
  v.push_back("((100,100),60)");
  v.push_back("((100,100),50)");
  v.push_back("((100,100),40)");
  v.push_back("((100,100),30)");
  v.push_back("((100,100),20)");
  v.push_back("((100,100),1000)");
  v.push_back("((100,100),100)");
  v.push_back("((100,100),10)");
  v.push_back("((10,1000),100)");
  v.push_back("((10,100),1000)");
  v.push_back("((10,100),100)");
  v.push_back("(((5,5),5),5)");
  v.push_back("(((3,3),3),3)");
  v.push_back("(((2,3),3),3)");
  v.push_back("(((2,2),3),3)");
  v.push_back("(((2,2),2),3)");
  v.push_back("(((2,2),2),2)");
  v.push_back("((((5,5),5),5),5)");
  v.push_back("((((3,3),3),3),3)");
  v.push_back("((((2,3),3),3),3)");
  v.push_back("((((2,2),3),3),3)");
  v.push_back("((((2,2),2),3),3)");
  v.push_back("((((2,2),2),2),3)");
  v.push_back("((((2,2),2),2),2)");
  v.push_back("(((((5,5),5),5),5),5)");
  v.push_back("(((((3,3),3),3),3),3)");
  v.push_back("(((((2,3),3),3),3),3)");
  v.push_back("(((((2,2),3),3),3),3)");
  v.push_back("(((((2,2),2),3),3),3)");
  v.push_back("(((((2,2),2),2),3),3)");
  v.push_back("(((((2,2),2),2),2),3)");
  v.push_back("(((((2,2),2),2),2),2)");
  v.push_back("((((((5,5),5),5),5),5),5)");
  v.push_back("((((((3,3),3),3),3),3),3)");
  v.push_back("((((((2,3),3),3),3),3),3)");
  v.push_back("((((((2,2),3),3),3),3),3)");
  v.push_back("((((((2,2),2),3),3),3),3)");
  v.push_back("((((((2,2),2),2),3),3),3)");
  v.push_back("((((((2,2),2),2),2),3),3)");
  v.push_back("((((((2,2),2),2),2),2),3)");
  v.push_back("((((((2,2),2),2),2),2),2)");
  v.push_back("(((((((5,5),5),5),5),5),5),5)");
  v.push_back("(((((((3,3),3),3),3),3),3),3)");
  v.push_back("(((((((2,3),3),3),3),3),3),3)");
  v.push_back("(((((((2,2),3),3),3),3),3),3)");
  v.push_back("(((((((2,2),2),3),3),3),3),3)");
  v.push_back("(((((((2,2),2),2),3),3),3),3)");
  v.push_back("(((((((2,2),2),2),2),3),3),3)");
  v.push_back("(((((((2,2),2),2),2),2),3),3)");
  v.push_back("(((((((2,2),2),2),2),2),2),3)");
  v.push_back("(((((((2,2),2),2),2),2),2),2)");
  v.push_back("((((((((5,5),5),5),5),5),5),5),5)");
  v.push_back("((((((((3,3),3),3),3),3),3),3),3)");
  v.push_back("((((((((2,3),3),3),3),3),3),3),3)");
  v.push_back("((((((((2,2),3),3),3),3),3),3),3)");
  v.push_back("((((((((2,2),2),3),3),3),3),3),3)");
  v.push_back("((((((((2,2),2),2),3),3),3),3),3)");
  v.push_back("((((((((2,2),2),2),2),3),3),3),3)");
  v.push_back("((((((((2,2),2),2),2),2),3),3),3)");
  v.push_back("((((((((2,2),2),2),2),2),2),3),3)");
  v.push_back("((((((((2,2),2),2),2),2),2),2),3)");
  v.push_back("((((((((2,2),2),2),2),2),2),2),2)");
  v.push_back("(((((((((5,5),5),5),5),5),5),5),5),5)");
  v.push_back("(((((((((2,3),3),3),3),3),3),3),3),3)");
  v.push_back("(((((((((2,2),3),3),3),3),3),3),3),3)");
  v.push_back("(((((((((2,2),2),3),3),3),3),3),3),3)");
  v.push_back("(((((((((2,2),2),2),3),3),3),3),3),3)");
  v.push_back("(((((((((2,2),2),2),2),3),3),3),3),3)");
  v.push_back("(((((((((2,2),2),2),2),2),3),3),3),3)");
  v.push_back("(((((((((2,2),2),2),2),2),2),3),3),3)");
  v.push_back("(((((((((2,2),2),2),2),2),2),2),3),3)");
  v.push_back("(((((((((2,2),2),2),2),2),2),2),2),2)");
  v.push_back("((((((((((2,2),3),3),3),3),3),3),3),3),3)");
  v.push_back("((((((((((2,2),2),3),3),3),3),3),3),3),3)");
  v.push_back("((((((((((2,2),2),2),3),3),3),3),3),3),3)");
  v.push_back("((((((((((2,2),2),2),2),3),3),3),3),3),3)");
  v.push_back("((((((((((2,2),2),2),2),2),3),3),3),3),3)");
  v.push_back("((((((((((2,2),2),2),2),2),2),3),3),3),3)");
  v.push_back("((((((((((2,2),2),2),2),2),2),2),3),3),3)");
  v.push_back("((((((((((2,2),2),2),2),2),2),2),2),2),2)");
  v.push_back("(((((((((((2,2),2),2),2),3),3),3),3),3),3),3)");
  v.push_back("(((((((((((2,2),2),2),2),2),3),3),3),3),3),3)");
  v.push_back("(((((((((((2,2),2),2),2),2),2),3),3),3),3),3)");
  v.push_back("(((((((((((2,2),2),2),2),2),2),2),3),3),3),3)");
  v.push_back("(((((((((((2,2),2),2),2),2),2),2),2),2),2),2)");
  v.push_back("((((((((((((2,2),2),2),2),2),2),2),3),3),3),3),3)");
  v.push_back("((((((((((((2,2),2),2),2),2),2),2),2),2),2),2),2)");
  v.push_back("(((((((((((((2,2),2),2),2),2),2),2),2),2),2),2),2),2)");
  v.push_back("((((((((((((((2,2),2),2),2),2),2),2),2),2),2),2),2),2),2)");
  return v;
}
//---------------------------------------------------------------------------

 

 

 

 

 

test.h

 

//---------------------------------------------------------------------------
/*
  The Rampal Etienne Project, calculates the probability of a phylogeny
  (C) 2009 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
//---------------------------------------------------------------------------
#ifndef UnitTestH
#define UnitTestH
//---------------------------------------------------------------------------
#include <string>
//---------------------------------------------------------------------------
#include <boost/shared_ptr.hpp>
//---------------------------------------------------------------------------
#include "BigIntegerLibrary.hh"
//---------------------------------------------------------------------------
struct Test
{
  Test(const std::string& any_newick, const double any_theta)
    : m_newick_str(any_newick),
      m_theta(any_theta),
      m_time(0.0),
      m_probability(0.0)
  {
    //Do nothing
  }
  virtual ~Test() {};
  virtual bool Execute() = 0;
  virtual const std::string GetTestName() const = 0;
  double GetProbability() const { return m_probability; }
  const std::string GetEwensProbability() const; //Ewensprobability = probability * num_of_combinations
  int GetTime() const { return m_time; }
  const BigInteger GetComplexity() const;

  const std::string& GetNewick() const { return m_newick_str; }
  double GetTheta() const { return m_theta; }

  bool Execute(
    const std::string& exe_filename,
    const std::string& full_command,
    const std::string& output_filename);

  private:
  const std::string m_newick_str;
  const double m_theta;
  double m_time;
  double m_probability;

  public:
  //helper functions
  static std::vector<boost::shared_ptr<Test> > CreateTests(
    const std::string& newick,
    const double theta,
    const int flags);
  static bool FileExists(const std::string& filename);
  static const std::vector<std::string> FileToVector(const std::string& fileName);
  static double ReadDoubleFromFile(const std::string& fileName);
};
//---------------------------------------------------------------------------
struct TestRavindran : public Test
{
  TestRavindran(const std::string& any_newick, const double any_theta)
  : Test(any_newick,any_theta) {}
  ~TestRavindran() {}
  bool Execute();
  const std::string GetTestName() const { return "Ravindran                    "; }
};
//---------------------------------------------------------------------------
struct TestEndversion2: public Test
{
  TestEndversion2(const std::string& any_newick, const double any_theta)
  : Test(any_newick,any_theta) {}
  ~TestEndversion2() {}
  bool Execute();
  const std::string GetTestName() const { return "TestProjectRampal_Endversion2"; }
};
//---------------------------------------------------------------------------
struct TestTwoDigitNewickDebug: public Test
{
  TestTwoDigitNewickDebug(const std::string& any_newick, const double any_theta)
  : Test(any_newick,any_theta) {}
  ~TestTwoDigitNewickDebug() {}
  bool Execute();
  const std::string GetTestName() const { return "TestTwoDigitNewickDebug"; }
};
//---------------------------------------------------------------------------
struct TestTwoDigitNewickRelease: public Test
{
  TestTwoDigitNewickRelease(const std::string& any_newick, const double any_theta)
  : Test(any_newick,any_theta) {}
  ~TestTwoDigitNewickRelease() {}
  bool Execute();
  const std::string GetTestName() const { return "TestTwoDigitNewickRelease"; }
};
//---------------------------------------------------------------------------
struct TestManyDigitNewickDebug: public Test
{
  TestManyDigitNewickDebug(const std::string& any_newick, const double any_theta)
  : Test(any_newick,any_theta) {}
  ~TestManyDigitNewickDebug() {}
  bool Execute();
  const std::string GetTestName() const { return "TestManyDigitNewickRelease"; }
};
//---------------------------------------------------------------------------
#endif

 

 

 

 

 

test.cpp

 

//---------------------------------------------------------------------------
/*
  The Rampal Etienne Project, calculates the probability of a phylogeny
  (C) 2009 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
//---------------------------------------------------------------------------
#include <fstream>
#include <vector>
//---------------------------------------------------------------------------
#include <boost/numeric/conversion/cast.hpp>
#include <boost/timer.hpp>
//---------------------------------------------------------------------------
#include "binarynewickvector.h"
#include "newick.h"
#include "stopwatch.h"
#include "test.h"
//---------------------------------------------------------------------------
///Create all tests according to the flags given.
///Test parameters:\n
///i &  1: use Ravindran\n
///i &  2: use SortedNewick\n
///i &  4: use SmartSortedNewick\n
///i &  8: use RampalMain_Endversion2\n
///i & 16: use TestTwoDigitNewickDebug\n
///i & 32: use TestTwoDigitNewickRelease\n
///63: use all\n
std::vector<boost::shared_ptr<Test> > Test::CreateTests(
  const std::string& newick,
  const double theta,
  const int flags)
{
  std::vector<boost::shared_ptr<Test> > v;
  if (flags & 1)
  {
    boost::shared_ptr<Test> t(new TestRavindran(newick,theta));
    v.push_back(t);
  }
  if (flags & 2)
  {
    boost::shared_ptr<Test> t(new TestEndversion2(newick,theta));
    assert(t);
    v.push_back(t);
  }
  if (flags & 4)
  {
    boost::shared_ptr<Test> t(new TestTwoDigitNewickDebug(newick,theta));
    assert(t);
    v.push_back(t);
  }
  if (flags & 8)
  {
    boost::shared_ptr<Test> t(new TestTwoDigitNewickRelease(newick,theta));
    assert(t);
    v.push_back(t);
  }
  return v;
}
//---------------------------------------------------------------------------
///FileExists checks if a certain file exists
///From http://www.richelbilderbeek.nl/CppFileExists.htm
bool Test::FileExists(const std::string& filename)
{
  std::fstream f;
  f.open(filename.c_str(),std::ios::in);
  return f.is_open();
}
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/CppFileToVector.htm
const std::vector<std::string> Test::FileToVector(const std::string& fileName)
{
  assert(FileExists(fileName)==true);
  std::vector<std::string> myVector;
  std::ifstream in(fileName.c_str());
  std::string myString;
  for (int i=0; !in.eof(); ++i)
  {
    std::getline(in,myString);
    myVector.push_back(myString);
  }
  return myVector;
}
//---------------------------------------------------------------------------
const BigInteger Test::GetComplexity() const
{
  const BinaryNewickVector n(GetNewick());
  return Newick::CalcComplexity(n.Get());
}
//---------------------------------------------------------------------------
//Ewensprobability = probability * num_of_combinations
const std::string Test::GetEwensProbability() const
{
  const BigInteger n_combinations
    = Newick::CalcNumOfCombinations(
        BinaryNewickVector(GetNewick()).Get());
  try
  {
    const int i = n_combinations.toInt();
    const double d = boost::numeric_cast<double>(i);
    const double ewens_probability = d * GetProbability();
    return boost::lexical_cast<std::string>(ewens_probability);
  }
  catch (...)
  {
    const std::string s
      = bigIntegerToString(n_combinations)
      + std::string(" * ")
      + boost::lexical_cast<std::string>(GetProbability());
    return s;
  }
}
//---------------------------------------------------------------------------
bool Test::Execute(
  const std::string& exe_filename,
  const std::string& full_command,
  const std::string& output_filename)
{
  std::clog << "Starting '" << GetTestName() << "' for '"
    << this->GetNewick() << "'\n";

  if (!FileExists(exe_filename))
  {
    std::cerr << "Executable file '" << exe_filename << "' not found\n";
  }
  assert(FileExists(exe_filename));

  const Stopwatch s;

  const int sys_error = std::system(full_command.c_str());

  if (sys_error == 0)
  {
    m_time = s.elapsed();
    assert(FileExists(result_filename));
    m_probability = ReadDoubleFromFile(output_filename);
    return true;
  }
  else
  {
    m_time = 0;
    m_probability = 0.0;
    return false;
  }
}
//---------------------------------------------------------------------------
///ReadDoubleFromFile reads the first line of a file
///and converts it to a double.
///From http://www.richelbilderbeek.nl/CppReadDoubleFromFile.htm
double Test::ReadDoubleFromFile(const std::string& fileName)
{
  const std::vector<std::string> v = FileToVector(fileName);
  assert(v.empty()==false);
  const double d = std::atof(v[0].c_str());
  return d;
}
//---------------------------------------------------------------------------
//Returns if the test was successful
bool TestRavindran::Execute()
{
  std::clog << "Starting TestRavindranLinux for '"
    << this->GetNewick() << "'\n";

  if (GetComplexity() > 1000000) return false;

  //Write parameters to file
  {
    std::ofstream file("theta.txt");
    file << GetTheta();
  }
  {
    //Older version expects a /n at end
    std::ofstream file("phylogeny.txt");
    file << GetNewick() << "\n\n";
  }

  #ifdef WIN32
  const std::string exe_filename = "../Exes/phy_prob_12.exe";
  const std::string full_command = "../Exes/phy_prob_12.exe";
  #else
  const std::string exe_filename = "../Exes/phy_prob_linux";
  const std::string full_command = "./../Exes/phy_prob_linux";
  #endif

  return Test::Execute(
    exe_filename,
    full_command,
    "expected_probability.txt");
}
//---------------------------------------------------------------------------
///Just call the executable ProjectRampalMain_Endversion2
///with the parameters
bool TestEndversion2::Execute()
{
  #ifndef WIN32
  const std::string exe_filename = "../Exes/ProjectRampalMain_Endversion2";
  #else
  const std::string exe_filename = "../Exes/ProjectRampal.exe";
  #endif

  const std::string command_full =
  #ifndef WIN32
    std::string("./") +
  #endif
    exe_filename
    + " "
    + boost::lexical_cast<std::string>(GetTheta())
    + " \""
    + GetNewick()
    + "\"";

  const std::string output_filename = "Result_probability.txt";

  return Test::Execute(exe_filename,command_full,output_filename);
}
//---------------------------------------------------------------------------
///Just call the executable TestTwoDigitNewickDebug
///with the parameters
bool TestTwoDigitNewickDebug::Execute()
{
  #ifndef WIN32
  const std::string exe_filename = "../Exes/TestTwoDigitNewickUbuntuDebug";
  #else
  const std::string exe_filename = "../Exes/TestTwoDigitNewickWinDebug.exe";
  #endif

  const std::string command_full =
  #ifndef WIN32
    std::string("./") +
  #endif
    exe_filename
    + " "
    + boost::lexical_cast<std::string>(GetTheta())
    + " \""
    + GetNewick()
    + "\"";
  const std::string output_filename = "Result_probability.txt";
  return Test::Execute(exe_filename,command_full,output_filename);

  /*
  std::clog << "Starting TestTwoDigitNewickDebug for '"
    << this->GetNewick() << "'\n";
  const std::string filename
  #ifndef WIN32
    = "../../../Tools/ToolTestTwoDigitNewick-build-desktop/TestTwoDigitNewickUbuntuDebug";
  #else
    = "../../../Tools/ToolTestTwoDigitNewick/debug/TestNewickVectorWinDebug.exe";
  #endif
  if (!FileExists(filename))
  {
    std::cerr << "File '" << filename << "' not found\n";
  }
  assert(FileExists(filename));

  const std::string command =
  #ifndef WIN32
    std::string("./") +
  #endif
    filename
    + " "
    + boost::lexical_cast<std::string>(GetTheta())
    + " \""
    + GetNewick()
    + "\"";

  const Stopwatch s;

  const int sys_error = std::system(command.c_str());
  if (sys_error == 0)
  {
    time = s.elapsed();
    const std::string result_filename = "Result_probability.txt";
    assert(FileExists(result_filename));
    probability = ReadDoubleFromFile(result_filename);
    return true;
  }
  else
  {
    time = 0;
    probability = 0.0;
    return false;
  }
  */
}
//---------------------------------------------------------------------------
///Just call the executable TestTwoDigitNewickRelease
///with the parameters
bool TestTwoDigitNewickRelease::Execute()
{
  #ifndef WIN32
  const std::string exe_filename = "../Exes/TestTwoDigitNewickUbuntuRelease";
  #else
  const std::string exe_filename = "../Exes/TestTwoDigitNewickWinRelease.exe";
  #endif

  const std::string command_full =
  #ifndef WIN32
    std::string("./") +
  #endif
    exe_filename
    + " "
    + boost::lexical_cast<std::string>(GetTheta())
    + " \""
    + GetNewick()
    + "\"";
  const std::string output_filename = "Result_probability.txt";
  return Test::Execute(exe_filename,command_full,output_filename);
  /*
  std::clog << "Starting TestTwoDigitNewickRelease for '"
    << this->GetNewick() << "'\n";
  const std::string filename
  #ifndef WIN32
    = "../../../Tools/ToolTestTwoDigitNewick-build-desktop/TestTwoDigitNewickUbuntuRelease";
  #else
    = "../../../Tools/ToolTestTwoDigitNewick/release/TestNewickVectorWinRelease.exe";
  #endif
  assert(FileExists(filename));
  if (!FileExists(filename))
  {
    std::cerr << "File '" << filename << "' not found\n";
  }
  const std::string command =
  #ifndef WIN32
    std::string("./") +
  #endif
    filename
    + " "
    + boost::lexical_cast<std::string>(GetTheta())
    + " \""
    + GetNewick()
    + "\"";

  const Stopwatch s;

  const int sys_error = std::system(command.c_str());

  if (sys_error == 0)
  {
    m_time = s.elapsed();
    const std::string result_filename = "Result_probability.txt";
    assert(FileExists(result_filename));
    m_probability = ReadDoubleFromFile(result_filename);
    return true;
  }
  else
  {
    m_time = 0;
    m_probability = 0.0;
    return false;
  }
  */
}
//---------------------------------------------------------------------------
///Just call the executable TestTwoDigitNewickDebug
///with the parameters
bool TestManyDigitNewickDebug::Execute()
{
  #ifndef WIN32
  const std::string exe_filename = "../Exes/TestManyDigitNewickUbuntuDebug";
  #else
  const std::string exe_filename = "../Exes/TestManyDigitNewickWinDebug.exe";
  #endif

  const std::string command_full =
  #ifndef WIN32
    std::string("./") +
  #endif
    exe_filename
    + " "
    + boost::lexical_cast<std::string>(GetTheta())
    + " \""
    + GetNewick()
    + "\"";

  const std::string output_filename = "Result_probability.txt";

  return Test::Execute(exe_filename,command_full,output_filename);
}
//---------------------------------------------------------------------------

 

 

 

 

 

zip.sh

 

#!/bin/sh
#pack2port packs all the files to port into a single .zip file,
#minicking the same folder structure
#Folder structure
# *
#   * Classes
#     * CppStopwatch
#   * Libraries
#     * bigint-2010.04.30
#   * Projects
#     * ProjectRampal
#       * 300                    
#   * Tools
#     * ToolTestNewickVector    
#     * ToolTestTwoDigitNewick
echo "Removing old zip archive"
rm 300.zip
rm *.o
rm ProjectRampalTest.pro.user

echo "Mimicking file structure"
mkdir temp_zip
mkdir temp_zip/Classes
mkdir temp_zip/Classes/CppStopwatch
mkdir temp_zip/Libraries
mkdir temp_zip/Libraries/bigint-2010.04.30
mkdir temp_zip/Projects
mkdir temp_zip/Projects/ProjectRampal
mkdir temp_zip/Projects/ProjectRampal/300
mkdir temp_zip/Tools
mkdir temp_zip/Tools/ToolTestNewickVector
mkdir temp_zip/Tools/ToolTestTwoDigitNewick

echo "Copying files"
cp ../../../Classes/CppStopwatch/*.* temp_zip/Classes/CppStopwatch
cp ../../../Libraries/bigint-2010.04.30/*.* temp_zip/Libraries/bigint-2010.04.30
cp *.* temp_zip/Projects/ProjectRampal/300
cp ../../../Tools/ToolTestNewickVector/*.* temp_zip/Tools/ToolTestNewickVector
cp ../../../Tools/ToolTestTwoDigitNewick/*.* temp_zip/Tools/ToolTestTwoDigitNewick

echo "Compressing files"
cd temp_zip
zip -r 300 Classes
zip -r 300 Libraries
zip -r 300 Projects
zip -r 300 Tools
cd ..
cp temp_zip/300.zip 300.zip

echo "Cleaning up"
#Classes
rm temp_zip/Classes/CppStopwatch/*.*
rmdir temp_zip/Classes/CppStopwatch
rmdir temp_zip/Classes
#Libraries
rm temp_zip/Libraries/bigint-2010.04.30/*.*
rmdir temp_zip/Libraries/bigint-2010.04.30
rmdir temp_zip/Libraries
#Projects
rm temp_zip/Projects/ProjectRampal/300/*.*
rmdir temp_zip/Projects/ProjectRampal/300
rmdir temp_zip/Projects/ProjectRampal
rmdir temp_zip/Projects
#Tools
rm temp_zip/Tools/ToolTestNewickVector/*.*
rm temp_zip/Tools/ToolTestTwoDigitNewick/*.*
rmdir temp_zip/Tools/ToolTestNewickVector
rmdir temp_zip/Tools/ToolTestTwoDigitNewick
rmdir temp_zip/Tools
#temp_zip
rm temp_zip/*.*
rmdir temp_zip

echo "Done"

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml