Commit 13375bc1 authored by Mathieu Giraud's avatar Mathieu Giraud

core/tools.{h,cpp}, vidjil.cpp: extract new_ofgzstream()

parent 57b08241
......@@ -473,3 +473,19 @@ string extractGeneName(string label){
}
return result;
}
/*
Opens a ostream, possibly gz-compressed
*/
std::ostream* new_ofgzstream(const char *f, bool gz)
{
if (gz)
{
return new ogzstream(f);
}
else
{
return new ofstream(f);
}
}
\ No newline at end of file
......@@ -43,6 +43,7 @@ typedef string junction ;
#include <cassert>
#include <vector>
#include "bioreader.hpp"
#include "../lib/gzstream.h"
#include "kmeraffect.h"
#include "../lib/json_fwd.hpp"
using json = nlohmann::json;
......@@ -281,6 +282,11 @@ void output_label_average(ostream &out, string label, long long int nb, double a
void json_add_warning(json &clone, string code, string msg, string level=LEVEL_WARN);
/*
Opens a ostream, possibly gz-compressed
*/
std::ostream* new_ofgzstream(const char *f, bool gz);
//////////////////////////////////////////////////
// Template code
......
......@@ -58,7 +58,6 @@
#include "lib/CLI11.hpp"
#include "lib/json.hpp"
#include "lib/CLI11_json.hpp"
#include "lib/gzstream.h"
#include "vidjil.h"
......@@ -1764,17 +1763,7 @@ int main (int argc, char **argv)
cout << "\t(only metadata, no clone output)" << endl;
}
std::ostream *out_json;
if (out_gz)
{
out_json = new ogzstream(f_json.c_str());
}
else
{
out_json = new ofstream(f_json.c_str());
}
std::ostream *out_json = new_ofgzstream(f_json.c_str(), out_gz);
SampleOutputVidjil *outputVidjil = static_cast<SampleOutputVidjil *>(&output);
outputVidjil -> out(*out_json, !no_vidjil);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment