Skip to content

Commit d74486f

Browse files
committed
write BAM file pairing properly with --select if there are exactly two files in --select
1 parent 3ad6bea commit d74486f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/ProcessReads.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,20 @@ void MasterProcessor::writeOutput(std::vector<SplitCode::Results>& rv,
727727
size_t ostr_len = ostr.length();
728728
if (assigned2) {
729729
if (outbam && r.ofile.empty()) {
730-
writeBam(ostr, nl, jmax == 2 ? jj+1 : 0);
730+
int pairing = (jmax == 2 ? jj+1 : 0);
731+
if (opt.select_output_files.size() > 0) {
732+
int num_select_output_files = 0;
733+
int pairing_ = 0;
734+
for (int i = 0; i < opt.select_output_files.size(); i++) {
735+
if (opt.select_output_files[i]) num_select_output_files++;
736+
if (opt.select_output_files[j] && i == j) {
737+
if (num_select_output_files == 1) pairing_ = 1;
738+
else pairing_ = 2;
739+
}
740+
}
741+
if (num_select_output_files == 2) pairing = pairing_;
742+
}
743+
writeBam(ostr, nl, pairing);
731744
} else if (use_pipe && !outbam) {
732745
if (!opt.no_output_) {
733746
if (!hasChild) fwrite(ostr.c_str(), 1, ostr_len, stdout);

0 commit comments

Comments
 (0)