Skip to content

File npreplay.cxx

File List > src > utility > npreplay.cxx

Go to the documentation of this file

#include "NPApplication.h"
#include "NPException.h"
#include "NPMetadataManager.h"
#include <iomanip>
#include <iostream>
using namespace nptool;

int main(int argc, char** argv) {
  try {
    auto app = nptool::Application::InitApplication(argc, argv, 1);
    if (app->HasFlag("--metadata")) {
      auto metafile_arg = app->GetVectorArg("--metadata");
      if (metafile_arg.size()==1) {

        // OPTION USING SNAKEMAKE ////////////////////////////////////
        std::string command = "snakemake --cores 4 --snakefile /home/paxman/Programs/nptoolv4/src/utility/Snakefile --configfile " + metafile_arg[0];
        system("rm -rf .npreplay/tmp/*"); // clean npreplay touch files
        system((command + " --dag | dot -Tpdf > snakemake_dag.pdf").c_str()); // clean npreplay touch files
        int ret = system(command.c_str());
        if (ret == 0) { std::cout << "Snakemake workflow executed successfully." << std::endl; } 
        else { std::cerr << "Snakemake failed with exit code: " << ret << std::endl; }

//        // Load metadata from *_metadata.yaml file
//        //YAML::Node meta = YAML::LoadFile((std::string&)metafile_arg);
//
//        // --- check input md5 hashes --- //
//  if(meta["inputs"]){
//  } 
//  else {
//    throw(nptool::Error("npreplay", "metadata file incorrectly formatted; no input node"));
//  }
//        
//        // --- check core version --- //
//
//        // --- check plugins --- //

      }
      else {
        throw(nptool::Error("npreplay", "--metadata flag provided with too many arguments, require one *_metadata.yaml"));
      }
    }
    else {
      throw(nptool::Error("npreplay", "npreplay requires --metadata flag"));
    }
  }
  catch (nptool::Warning& ex) {
    nptool::DisplayException(ex);
  }
  catch (nptool::Error& ex) {
    nptool::DisplayException(ex);

    //app->Stop();
    return 1;
  }
  catch (...) {
    return 1;
  }
  return 0;
}