Skip to content
This repository was archived by the owner on Oct 17, 2022. It is now read-only.

Commit 3655360

Browse files
Change to only print a header if one is specified on command line.
1 parent 29c474d commit 3655360

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/utils/merge-methcounts.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,17 @@ main(int argc, const char **argv) {
218218
string outfile;
219219
bool VERBOSE;
220220
bool TABULAR = false;
221+
222+
string header_info;
223+
221224
/****************** COMMAND LINE OPTIONS ********************/
222225
OptionParser opt_parse(strip_path(argv[0]),
223226
"merge multiple methcounts files",
224227
"<methcounts-files>");
225228
opt_parse.add_opt("output", 'o', "output file name (default: stdout)",
226229
false, outfile);
230+
opt_parse.add_opt("header", 'h',"header to print (ignored for tabular)",
231+
false, header_info);
227232
opt_parse.add_opt("verbose", 'v',"print more run info", false, VERBOSE);
228233
opt_parse.add_opt("tabular", 't', "output as table", false, TABULAR);
229234

@@ -264,19 +269,20 @@ main(int argc, const char **argv) {
264269
for (size_t i = 0; i < methcounts_files.size(); i++){
265270
methcounts_files[i] = remove_extension(methcounts_files[i]);
266271
}
267-
if (!TABULAR){
268-
out << "#";
269-
transform(methcounts_files.begin(), methcounts_files.end(),
270-
std::ostream_iterator<string>(out, ", "),
271-
std::ptr_fun(&strip_path));
272-
out<< endl;
273-
}
274-
else {
272+
273+
// Print the header if the user specifies or if the output is to
274+
// be in tabular format
275+
if (!TABULAR && !header_info.empty())
276+
out << "#" << header_info << endl;
277+
278+
if (TABULAR) {
279+
// tabular format does not include the '#' character
275280
transform(methcounts_files.begin(), methcounts_files.end(),
276281
std::ostream_iterator<string>(out, "\t"),
277282
std::ptr_fun(&strip_path));
278283
out << endl;
279284
}
285+
280286
vector<Site> sites;
281287
vector<bool> outdated(infiles.size(), true);
282288

0 commit comments

Comments
 (0)