ropensci / EDIutils

An API Client for the Environmental Data Initiative Repository
https://docs.ropensci.org/EDIutils/
Other
10 stars 2 forks source link

`validate_file_names` returns "Invalid data.files entered" #12

Closed earnaud closed 2 years ago

earnaud commented 4 years ago

Hi,

when I am using EMLassemblyline::template_taxonomic_coverage(), an error occurs on validate_file_names:

Templating taxonomic coverage ...
Error in EDIutils::validate_file_names(path = fun.args$data.path, data.files = fun.args$taxa.table) : 
  Invalid data.files entered: /home/pndb-elie/dataPackagesOutput/emlAssemblyLine/test_emldp/decomp.csv

I use a path in the path argument and let data.files take its default value (aka path). By manual tests, I see that this error occurs at the condition:

sum(use_i) == length(data.files)

But sum_i has length equals to the vector of files in path directory. So it could not have length equals to data.files. I think the condition could be re-written:

length(which(sum(use_i))) == length(data.files)
clnsmth commented 4 years ago

Hi @earnaud. I'm unable to reproduce this error. Would you mind forwarding the function call?

A potential issue is that taxa.table doesn't accept the full file name (i.e. /this/is/my/path/decomp.csv), it should be only the file name (e.g. decomp.csv).

We could perhaps change this if there's a strong argument for it.

earnaud commented 4 years ago

Hi @clnsmth,

Here is a caption of my screen after having tested template_taxonomic_coverage() with my inputs from MetaShARK:

Browse[1]> rv$taxa.table
[1] "/home/pndb-elie/dataPackagesOutput/emlAssemblyLine/test_emldp/Nitrogen_fixation.csv"
Browse[1]> rv$taxa.table <- basename(rv$taxa.table)
Browse[1]> template_taxonomic_coverage(
+         paste(
+           savevar$emlal$selectDP$dp_path,
+           savevar$emlal$selectDP$dp_name,
+           "data_objects",
+           sep = "/"
+         ),
+         taxa.table = rv$taxa.table,
+         taxa.col = rv$taxa.col,
+         taxa.name.type = rv$taxa.name.type,
+         taxa.authority = rv$taxa.authority
+       )
Templating taxonomic coverage ...
Error in validate_arguments(fun.name = "template_taxonomic_coverage",  : 
  Input argument "taxa.name.type" must be "scientific", "common", or "both".
Browse[1]> template_taxonomic_coverage(
+         paste(
+           savevar$emlal$selectDP$dp_path,
+           savevar$emlal$selectDP$dp_name,
+           "data_objects",
+           sep = "/"
+         ),
+         paste(
+           savevar$emlal$selectDP$dp_path,
+           savevar$emlal$selectDP$dp_name,
+           "data_objects",
+           sep = "/"
+         ),
+         taxa.table = rv$taxa.table,
+         taxa.col = rv$taxa.col,
+         taxa.name.type = rv$taxa.name.type,
+         taxa.authority = rv$taxa.authority
+       )
Templating taxonomic coverage ...
Error in validate_arguments(fun.name = "template_taxonomic_coverage",  : 
  Input argument "taxa.name.type" must be "scientific", "common", or "both".

Here are my inputs:

$taxa.authority
[1] "Catalogue of Life (COL)"

$taxa.table
[1] "Nitrogen_fixation.csv"

$taxa.col
[1] "YEAR"

$complete
[1] TRUE

$taxa.name.type
[1] "scientific name" "common name"    
clnsmth commented 4 years ago

Try taxa.name.type = "both"

earnaud commented 4 years ago

Hi again ! I found what was messing up concerning this issue, and it was my bad: I confused "data.path" argument in {EMLassemblyline}'s function and "data.files" argument in {EDIutils}'s function.

earnaud commented 4 years ago

Well .. sorry: it actually does not work.

Warning: Error in EDIutils::validate_file_names: Invalid data.files entered: /home/pndb-elie/dataPackagesOutput/emlAssemblyLine/Test_emldp/Test/data_objects/decomp.csv
  [No stack trace available]

> file.exists("/home/pndb-elie/dataPackagesOutput/emlAssemblyLine/Test_emldp/Test/data_objects/decomp.csv")
[1] TRUE
clnsmth commented 4 years ago

Hmmm ... this error message suggests an outdated version of validate_file_names(). Does a fresh install of EDIutils fix this?

clnsmth commented 2 years ago

This function is deprecated in the new release on the main branch. The previous version of EDIutils is on the deprecated branch and will be permanently deleted on 2022-06-01.