Skip to content

Commit

Permalink
xcounts: ensuring a header is found either by the user providing a re…
Browse files Browse the repository at this point in the history
…ference genome, the user directly providing a header, or the header already existing in the counts file
  • Loading branch information
andrewdavidsmith committed Jan 9, 2024
1 parent e045ff1 commit fc507c1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/utils/xcounts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,17 +169,20 @@ main_xcounts(int argc, const char **argv) {
uint32_t offset = 0;
string prev_chrom;
bool status_ok = true;
bool found_header = (!genome_file.empty() || !header_file.empty());

MSite site;
while (status_ok && getline(in, line)) {
if (is_counts_header_line(line.s)) {
if (!genome_file.empty()) continue;
if (!genome_file.empty() || !header_file.empty()) continue;
found_header = true;
const string header_line{line.s};
write_counts_header_line(header_line, out);
continue;
}

status_ok = site.initialize(line.s, line.s + line.l);
if (!status_ok) break;
if (!status_ok || !found_header) break;

if (site.chrom != prev_chrom) {
prev_chrom = site.chrom;
Expand All @@ -202,6 +205,10 @@ main_xcounts(int argc, const char **argv) {
<< filename << " to " << outfile << endl;
return EXIT_FAILURE;
}
if (!found_header) {
cerr << "no header provided or found" << endl;
return EXIT_FAILURE;
}
}
catch (const std::exception &e) {
cerr << e.what() << endl;
Expand Down

0 comments on commit fc507c1

Please sign in to comment.