Example #1
0
void enumerate(int limit,
               int timeLimit,
               int threads,
               int state_tree_limit,
               std::ifstream& inFile,
               const std::string& intervalFile,
               int lowerbound,
               bool monoclonal,
               const std::string& purityString,
               bool writeCliqueFile,
               bool readCliqueFile,
               const std::string& cliqueFile,
               int offset,
               const IntSet& whiteList,
               SolutionSet& sols)
{
  CharacterMatrix M;
  
  try
  {
    g_lineNumber = 0;
    inFile >> M;
  }
  catch (std::runtime_error& e)
  {
    std::cerr << "Character matrix file. " << e.what() << std::endl;
    exit(1);
  }
  
  if (!intervalFile.empty())
  {
    std::ifstream inFile2(intervalFile.c_str());
    if (inFile2.good())
    {
      try
      {
        M.setIntervals(inFile2);
      }
      catch (std::runtime_error& e)
      {
        std::cerr << "Interval file. " << e.what() << std::endl;
        exit(1);
      }
    }
  }
  
  StlDoubleVector purityValues;
  if (purityString != "" && !parse_purity_vector(purityString, M.m(), purityValues))
  {
    return;
  }
//  if (monoclonal && purityString == "")
//  {
//    std::cerr << "Expected purity values" << std::endl;
//    return;
//  }
  
  if (g_verbosity >= VERBOSE_ESSENTIAL)
  {
    std::cerr << "Intializing copy-state matrix ..." << std::endl;
  }
  M.init();
  
  if (monoclonal)
  {
    M.applyHeuristic();
  }
  
  CompatibilityGraph* pComp = NULL;
  if (!readCliqueFile)
  {
    if (g_verbosity >= VERBOSE_ESSENTIAL)
    {
      std::cerr << std::endl << "Initializing compatibility graph ..." << std::endl;
    }
    pComp = new CompatibilityGraph(M);
    pComp->init(IntPairSet(), -1);
  }
  else
  {
    std::ifstream inFile(cliqueFile);
    pComp = new CompatibilityGraph(M);
    pComp->init(inFile);
  }
  
  if (writeCliqueFile)
  {
    std::ofstream outFile(cliqueFile);
    if (outFile.good())
    {
      pComp->write(outFile);
    }
  }
  
  NoisyCnaEnumerate alg(M, purityValues, *pComp, lowerbound);
  alg.init(state_tree_limit);
  alg.enumerate(limit, timeLimit, threads, state_tree_limit, monoclonal, offset, whiteList);

  sols = alg.sols();
  delete pComp;
  
  if (g_verbosity >= VERBOSE_ESSENTIAL)
  {
    std::cerr << "Generated " << sols.solutionCount() << " solutions" << std::endl;
  }
  inFile.close();
}