Changeset 1023


Ignore:
Timestamp:
Apr 7, 2009, 12:35:48 AM (12 years ago)
Author:
Jari Häkkinen
Message:

Addresses #197. In anticipation of abort functionality the underlying binary cannot read/write too much information from standard streams. Now qQN can use files or cin/cout

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/base2/net.sf.basedb.normalizers/trunk/src/c++/bin/qQN.cc

    r1020 r1023  
    4949{
    5050  CommandLine cmd;
    51   OptionArg<std::string> assay(cmd, "assay-data", "assay annotation file");
     51  OptionArg<std::string> assay(cmd, "assay-data", "assay annotations", true);
     52  OptionArg<std::string> indata(cmd, "in-data", "data to be normalized");
     53  OptionArg<std::string> outdata(cmd, "out-data", "normalized data");
    5254  OptionHelp help(cmd);
    5355  help.synopsis()=(std::string("See ") +
     
    7779  }
    7880
     81  if (version.present()) {
     82    std::cout << copyright.str();
     83    return EXIT_SUCCESS;
     84  }
     85
     86  std::ifstream* infile=NULL;
     87  std::streambuf* cin_buffer=NULL;
     88  if (indata.present()) {
     89    infile=new std::ifstream(indata.value().c_str());
     90    cin_buffer = std::cin.rdbuf(); // save cin's input buffer
     91    std::cin.rdbuf(infile->rdbuf());
     92  }
    7993  Matrix m(std::cin,'\t');
     94  if (indata.present()) {
     95    std::cin.rdbuf(cin_buffer); // restore old input buffer
     96    infile->close();
     97    delete infile;
     98  }
     99
    80100  std::vector<double> target(m.rows(),0);
    81101  ( assay.present() ? create_target(target,m,assay.value()) :
     
    85105  Matrix result(m.rows(),m.columns());
    86106  cn(m,result);
     107
     108  std::ofstream* outfile=NULL;
     109  std::streambuf* cout_buffer = std::cout.rdbuf();
     110  if (outdata.present()) {
     111    outfile=new std::ofstream(outdata.value().c_str());
     112    cout_buffer = std::cout.rdbuf(); // save cout's output buffer
     113    std::cout.rdbuf(outfile->rdbuf());
     114  }
    87115  std::cout << result << std::endl;
     116  if (outdata.present()) {
     117    std::cout.rdbuf(cout_buffer); // restore old output buffer
     118    outfile->close();
     119    delete outfile;
     120  }
    88121
    89122  return EXIT_SUCCESS;
Note: See TracChangeset for help on using the changeset viewer.