smithlabcode / falco

A C++ drop-in replacement of FastQC to assess the quality of sequence read data
https://falco.readthedocs.io
GNU General Public License v3.0
90 stars 10 forks source link

Floating point exception if fastq is empty #56

Open nick-youngblut opened 8 months ago

nick-youngblut commented 8 months ago

When running falco in a sequencing processing pipeline, some fastq files can be empty. In such cases, falco (v.1.2.1) throws an error:

Floating point exception

It would be helpful if falco just provided a warning if the fastq is empty. This could be an option (e.g., falco --just-warn).

tamuanand commented 2 months ago

I am facing the same issues. It would be great if the program does not die and instead it should exit gracefully with exit code 0 - currently it exits with exit code 136

It would be great if this feature is implemented

andrewdavidsmith commented 2 months ago

@tamuanand Can you confirm the version of Falco you are using? The most recent is 1.2.2.

tamuanand commented 2 months ago

Yes - I am using 1.2.2 - installed via conda

falco --version
falco 1.2.2
andrewdavidsmith commented 2 months ago

Seems fixable, but I need to know how to reproduce the problem. Can you provide any additional info?

tamuanand commented 2 months ago

I need to know how to reproduce the problem

Something like this

touch 123_R1.fastq.gz 123_R2.fastq.gz

falco 123_R1.fastq.gz 123_R2.fastq.gz

[limits]        using file <path_to>/falco/Configuration/limits.txt
[adapters]      using file <path_to>/falco/Configuration/adapter_list.txt
[contaminants]  using file <path_to>/falco/Configuration/contaminant_list.txt
[Tue May  7 11:09:44 2024] Started reading file 123_R1.fastq.gz
[Tue May  7 11:09:44 2024] reading file as gzipped FASTQ format
[running falco|===================================================|9223372036854775808%]
[Tue May  7 11:09:45 2024] Finished reading file
[Tue May  7 11:09:45 2024] Writing summary to ./123_R1.fastq.gz_summary.txt
[Tue May  7 11:09:45 2024] Writing text report to ./123_R1.fastq.gz_fastqc_data.txt
[Tue May  7 11:09:45 2024] Writing HTML report to ./123_R1.fastq.gz_fastqc_report.html
Floating point exception
andrewdavidsmith commented 2 months ago

@tamuanand Thanks -- this helps. I'll see what I can do.

tamuanand commented 2 months ago

Thanks @andrewdavidsmith

andrewdavidsmith commented 2 months ago

@tamuanand @nick-youngblut This particular error is masking some others that probably need to be resolved at the same time. If it were just the floating point issue, I could fix it right away, but once it gets past that point, others emerge. Thanks for your patience.

tamuanand commented 1 month ago

@andrewdavidsmith - a suggestion

andrewdavidsmith commented 1 month ago

@tamuanand I will probably do something like that, because clearly empty input files can't be allowed. Some related issues have emerged. I think the best thing is for me to try and close this issue using your suggestion as soon as possible, and open another for the problems that emerged while looking into this.

If you want to do the check yourself and make a PR, that's fine. Let me know asap because I might fix this later today. This is roughly what I would do:

static size_t
falco_filesize(const string &filename) {
  struct stat sb;
  stat(filename.c_str(), &sb);
  return sb.st_size;
}

and then where the check happens:

if (falco_filesize(some_input_filename) == 0)
  throw runtime_error("empty input file: " + input_filename);
lskatz commented 1 month ago

I would also like to see a more appropriate error message for this one :)