// UnimesToFasta.cpp #include #include #include #include #include #include #include "FastaWriter.hpp" #include "GzipReader.hpp" #include "SystemError.hpp" #include "UnimesParser.hpp" using namespace NGBW; int main(int argc, char **argv) { try { std::ios_base::sync_with_stdio(false); if(argc != 4) throw std::invalid_argument("usage: unimes-to-fasta dataset outputname inputname"); boost::scoped_ptr output_file; if(std::memcmp(argv[2], "-", 2) != 0) { output_file.reset(new std::ofstream(argv[2])); if(!output_file->good()) { std::string message("can't open "); message.append(argv[2]); throw SystemError("main", message, errno); } } std::ostream &output = output_file ? *output_file : std::cout; FastaWriter writer(argv[1], output); GzipReader reader(argv[3]); UnimesParser parser(reader); FastaRecord record; while (parser.Parse(record)) writer.Write(record); return 0; } catch(const std::exception &err) { std::cerr << err.what() << std::endl; return 1; } catch(...) { std::cerr << "An unknown exception was thrown" << std::endl; return 1; } }