Skip to content

Commit 3350257

Browse files
fix extra suffixes when demultiplexing
This ensures that filenames for reports and unidentified reads do not get extra suffixes, when explicitly named and demultiplexing is enabled
1 parent ded57af commit 3350257

File tree

3 files changed

+75
-8
lines changed

3 files changed

+75
-8
lines changed

src/userconfig.cpp

+8-7
Original file line numberDiff line numberDiff line change
@@ -1384,23 +1384,23 @@ userconfig::get_output_filenames() const
13841384
{
13851385
output_files files;
13861386

1387-
files.settings_json = new_output_file("--out-json", { ".json" }).name;
1388-
files.settings_html = new_output_file("--out-html", { ".html" }).name;
1387+
files.settings_json = new_output_file("--out-json", { ".json" }, false).name;
1388+
files.settings_html = new_output_file("--out-html", { ".html" }, false).name;
13891389

13901390
const std::string ext{ output_files::file_extension(out_file_format) };
13911391
const std::string out1 = (interleaved_output ? "" : ".r1") + ext;
13921392
const std::string out2 = (interleaved_output ? "" : ".r2") + ext;
13931393

13941394
if (is_demultiplexing_enabled()) {
13951395
files.unidentified_1 =
1396-
new_output_file("--out-unidentified1", { ".unidentified", out1 });
1396+
new_output_file("--out-unidentified1", { ".unidentified", out1 }, false);
13971397

13981398
if (paired_ended_mode) {
13991399
if (interleaved_output) {
14001400
files.unidentified_2 = files.unidentified_1;
14011401
} else {
1402-
files.unidentified_2 =
1403-
new_output_file("--out-unidentified2", { ".unidentified", out2 });
1402+
files.unidentified_2 = new_output_file(
1403+
"--out-unidentified2", { ".unidentified", out2 }, false);
14041404
}
14051405
}
14061406
}
@@ -1451,11 +1451,12 @@ userconfig::get_output_filenames() const
14511451

14521452
output_file
14531453
userconfig::new_output_file(const std::string& key,
1454-
const string_vec& values) const
1454+
const string_vec& values,
1455+
const bool sample_file) const
14551456
{
14561457
std::string out;
14571458
if (argparser.is_set(key)) {
1458-
if (!is_demultiplexing_enabled()) {
1459+
if (!sample_file || !is_demultiplexing_enabled()) {
14591460
const auto filename = argparser.value(key);
14601461

14611462
return { filename, infer_output_format(filename) };

src/userconfig.hpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,14 @@ class userconfig
242242
[[nodiscard]] output_format infer_output_format(
243243
const std::string& filename) const;
244244

245+
/**
246+
* Generates filename + format for a output (FQ/SAM/BAM/HTML/JSON) file. If
247+
* sample_file is true, the file is expected to belong to a sample. Otherwise
248+
* it is expected to be a HTML/JSON/unidentified fastq file.
249+
*/
245250
[[nodiscard]] output_file new_output_file(const std::string& key,
246-
const string_vec& values) const;
251+
const string_vec& values,
252+
bool sample_file = true) const;
247253

248254
//! Argument parser setup to parse the arguments expected by AR
249255
argparse::parser argparser{};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"description": "Demultiplexing, trimming, and merging of PE reads with custom basenames and no default basename",
3+
"exhaustive": true,
4+
"arguments": [
5+
"--out-prefix",
6+
"/dev/null",
7+
"--out-json",
8+
"basename_1.json",
9+
"--out-unidentified1",
10+
"basename_1.unidentified.r1.fastq.gz",
11+
"--out-unidentified2",
12+
"basename_1.unidentified.r2.fastq.gz",
13+
"--out-discarded",
14+
"basename_2",
15+
"--out-merged",
16+
"basename_3",
17+
"--out-singleton",
18+
"basename_4",
19+
"--out-file1",
20+
"basename_5",
21+
"--out-file2",
22+
"basename_6",
23+
"--out-html",
24+
"basename_7.html",
25+
"--barcode-list",
26+
"barcodes.txt",
27+
"--merge"
28+
],
29+
"files": {
30+
"input_1": [
31+
"input_1.fastq"
32+
],
33+
"input_2": [
34+
"input_2.fastq"
35+
],
36+
"barcodes": [
37+
"barcodes.txt"
38+
],
39+
"output": [
40+
"basename_1.unidentified.r1.fastq.gz",
41+
"basename_1.unidentified.r2.fastq.gz",
42+
"basename_2.sample_1.discarded.fastq.gz",
43+
"basename_2.sample_2.discarded.fastq.gz",
44+
"basename_3.sample_1.merged.fastq.gz",
45+
"basename_3.sample_2.merged.fastq.gz",
46+
"basename_4.sample_1.singleton.fastq.gz",
47+
"basename_4.sample_2.singleton.fastq.gz",
48+
"basename_5.sample_1.r1.fastq.gz",
49+
"basename_5.sample_2.r1.fastq.gz",
50+
"basename_6.sample_1.r2.fastq.gz",
51+
"basename_6.sample_2.r2.fastq.gz"
52+
],
53+
"json": [
54+
"basename_1.json"
55+
],
56+
"html": [
57+
"basename_7.html"
58+
]
59+
}
60+
}

0 commit comments

Comments
 (0)