BigelowLab / edna-dada2

Maine eDNA dada2
0 stars 0 forks source link

low priority: friendly error if no files in input_files #23

Closed robinsleith closed 3 years ago

robinsleith commented 3 years ago

I just had a scenario where files did not end in the default pattern listed here

https://github.com/BigelowLab/dadautils/blob/700293a558e090a3ff3884d6ffae633c784d6c4b/R/filepairs.R#L160

This did not cause an error until the cutadapt step (because empty input_files were passed to the function). Could we test the length of input_files$forward and if it is 0 throw an error hinting people to check the default patterns in list_filepairs

btupper commented 3 years ago

Sure thing... do this at the molecule script level.

path <- "/path/foo"
fp <- list_filepairs(path, pattern = "baz.nope.gz")
if (all( count_filepairs(fp) == 0 )) {
  msg <- sprintf("no files found in %s", path)
  charlier::error(msg)
  stop(msg)
}
robinsleith commented 3 years ago

beautiful, added it!