Skip to content

Commit

Permalink
fix indents and length of lines
Browse files Browse the repository at this point in the history
  • Loading branch information
sdgamboa committed Apr 8, 2024
1 parent 4040b28 commit 338836a
Show file tree
Hide file tree
Showing 10 changed files with 872 additions and 788 deletions.
549 changes: 279 additions & 270 deletions R/bacdive.R

Large diffs are not rendered by default.

450 changes: 243 additions & 207 deletions R/bugphyzz.R

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions R/cache.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@
res <- BiocFileCache::bfcquery(cache, rname, "rname", exact = TRUE)
rid <- res$rid
if (length(rid) > 0 && force) {
time <- res$create_time
if (verbose) {
message('Replacing previous version downloaded on ', time, '.')
}
BiocFileCache::bfcremove(cache, rid)
rid <- names(BiocFileCache::bfcadd(cache, rname, url))
time <- res$create_time
if (verbose) {
message('Replacing previous version downloaded on ', time, '.')
}
BiocFileCache::bfcremove(cache, rid)
rid <- names(BiocFileCache::bfcadd(cache, rname, url))
}
if (!length(rid)) {
if (verbose) {
message( "Downloading, ", rname, ".")
}
rid <- names(BiocFileCache::bfcadd(cache, rname, url))
if (verbose) {
message( "Downloading, ", rname, ".")
}
rid <- names(BiocFileCache::bfcadd(cache, rname, url))
}
time <- BiocFileCache::bfcinfo(cache, rid)$create_time
message('Using data downloaded on ', time, '.')
BiocFileCache::bfcrpath(cache, rids = rid)
}

.removeCache <- function() {
cache <- .getCache()
BiocFileCache::removebfc(cache)
cache <- .getCache()
BiocFileCache::removebfc(cache)
}
48 changes: 26 additions & 22 deletions R/fattyAcidComposition.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,38 @@
## TODO Names of the Fatty Acids should be more "user-friendly"
## TODO Maybe a threshold should be decided to consider a FA as present or not.
.fattyAcidComposition <- function(){
link <- .customLinks() |>
dplyr::filter(functionname == "fattyAcidComposition") |>
dplyr::pull(link)
fac_wide <- utils::read.csv(link, check.names = FALSE)
fac_long <- fac_wide |>
tidyr::pivot_longer(
cols = `Br-C10:1`:`Oxo-C19:1`,
names_to = "Attribute_new", values_to = "Attribute_value"
) |>
dplyr::mutate(NCBI_ID = as.character(NCBI_ID))
dplyr::left_join(fac_long, ranks_parents, by = "NCBI_ID") |>
as.data.frame() |>
.addSourceInfo() |>
purrr::modify_at(
.at = c('Attribute', 'Frequency', 'Evidence', 'Confidence_in_curation'),
.f = ~ stringr::str_to_lower(.x)
) |>
dplyr::select(-Attribute) |>
dplyr::rename(Attribute = Attribute_new) |>
.reorderColumns(attr_type = 'numeric')
link <- .customLinks() |>
dplyr::filter(functionname == "fattyAcidComposition") |>
dplyr::pull(link)
fac_wide <- utils::read.csv(link, check.names = FALSE)
fac_long <- fac_wide |>
tidyr::pivot_longer(
cols = `Br-C10:1`:`Oxo-C19:1`,
names_to = "Attribute_new", values_to = "Attribute_value"
) |>
dplyr::mutate(NCBI_ID = as.character(NCBI_ID))
dplyr::left_join(fac_long, ranks_parents, by = "NCBI_ID") |>
as.data.frame() |>
.addSourceInfo() |>
purrr::modify_at(
.at = c(
'Attribute', 'Frequency', 'Evidence', 'Confidence_in_curation'
),
.f = ~ stringr::str_to_lower(.x)
) |>
dplyr::select(-Attribute) |>
dplyr::rename(Attribute = Attribute_new) |>
.reorderColumns(attr_type = 'numeric')
}

## Function to import custom links
.customLinks <- function(keyword = "all"){
fname <-
system.file("extdata/spreadsheet_customlinks.tsv", package = "bugphyzz")
links <- utils::read.table(fname, sep = '\t', header = TRUE)
ifelse(keyword[1] == "all", links, links <-
links[links$physiology %in% keyword,])
ifelse(
keyword[1] == "all", links,
links <- links[links$physiology %in% keyword,]
)
links
}
Loading

0 comments on commit 338836a

Please sign in to comment.