waldronlab / bugsigdbr

R-side access to published microbial signatures from BugSigDB
https://bioconductor.org/packages/bugsigdbr
GNU General Public License v3.0
4 stars 2 forks source link

Add version argument #23

Closed jwokaty closed 2 years ago

jwokaty commented 2 years ago

Closes #20.

lgeistlinger commented 2 years ago

This looks all great @jwokaty! I am not sure whether we ultimately need the httr dependency and associated dependency stack though. I'd like to keep the package as lightweight as possible.

jwokaty commented 2 years ago

I thought it would be better to check if the URL is valid and provide a helpful error message to the user. Is there a better way to do this than using httr? (I am still new to R and maybe just don't know a lighter way of doing it.)

Also, would we update devel and release with this code?

lgeistlinger commented 2 years ago

Hi @jwokaty I think this small modification below would be a sufficient sanity check for our purposes and avoids the httr dependency (and also the stringr dependency).

if (grepl("^10.5281/zenodo\\.", version)) {
        version <- sub("^10.5281/zenodo\\.", "", version)
        url <- paste0("https://zenodo.org/record/", version,
                      "/files/full_dump.csv")
        rname <- paste("bugsigdb-zenodo", version, sep = "-")
    } else if (version == "devel") {
        url <- "https://tinyurl.com/3nvzm3fx"
        rname <- paste("bugsigdb", version, sep = "-")
    } else if(grepl("^[0-9a-z]{7}$", version)){
        url <- paste0("https://raw.githubusercontent.com/waldronlab/BugSigDBExports/",
                      version, "/full_dump.csv")
        rname <- paste("bugsigdb-github", version, sep = "-")
    } else {
      stop(paste("Version", version, "does not exist. The version must be a",
                 "DOI, such as '10.5281/zenodo.5819260', a Github hash,",
                 "such as '30383a9', or 'devel'.", sep = " "))
    }
lgeistlinger commented 2 years ago

And I'd say we push to devel only for the beginning and see how it goes. After a while we can either port back to release or just wait for the next release which is also not too far away anymore.