From f819e7d1cd8d0a5f9b1d7023deaae0b9bb9c9c24 Mon Sep 17 00:00:00 2001 From: ake <40662956+ake123@users.noreply.github.com> Date: Sat, 10 Aug 2024 10:18:00 +0300 Subject: [PATCH] correction to DESCRIPTION file (#596) --- DESCRIPTION | 54 ++++++++++++++++----------------- inst/assets/bibliography.bib | 2 +- oma_packages/extract_packages.R | 38 +++++++++++++++++++---- oma_packages/oma_packages.csv | 6 ++-- 4 files changed, 63 insertions(+), 37 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 260799172..f273bdf7b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -27,49 +27,58 @@ biocViews: Depends: R (>= 4.0.0) Imports: + ape, + BiocManager, + BiocParallel, + Biostrings, + ComplexHeatmap, + dplyr, + ggplot2, + glue, + grid, + igraph, + knitr, + Maaslin2, + mia, + miaTime, + miaViz, + microbiome, + microbiomeDataSets, + phyloseq, + purrr, + reshape2, + scales, + sessioninfo, + stringr, + tidyverse, + vegan, + xgboost Suggests: ALDEx2, ANCOMBC, - ape, biclust, BiocBook, - BiocManager, - BiocParallel, - Biostrings, bluster, caret, circlize, cluster, cobiclust, - ComplexHeatmap, corpcor, curatedMetagenomicData, dada2, dendextend, devtools, DirichletMultinomial, - dplyr, DT, factoextra, forcats, fido, - ggplot2, ggpubr, ggtree, glmnet, - glue, - grid, gtools, gsEasy, - igraph, kableExtra, - knitr, - Maaslin2, - mia, - miaTime, - miaViz, - microbiome, - microbiomeDataSets, MicrobiomeStat, mikropml, MMUPHin, @@ -79,31 +88,22 @@ Suggests: NbClust, NMF, patchwork, - phyloseq, plotly, - purrr, qgraph, RColorBrewer, rebook, - reshape2, reticulate, rgl, ROCR, - scales, scater, sechm, - sessioninfo, shadowtext, SpiecEasi, SPRING, stats, - stringr, SuperLearner, - tidyverse, topGO, - vegan, - WGCNA, - xgboost + WGCNA Remotes: github::microbiome/mia, github::microbiome/miaViz, diff --git a/inst/assets/bibliography.bib b/inst/assets/bibliography.bib index cdf058409..2d520ae57 100644 --- a/inst/assets/bibliography.bib +++ b/inst/assets/bibliography.bib @@ -18,7 +18,7 @@ @Article{Deng2024 year = {2024}, volume = 18, number = {1}, - pages = {wrae106} + pages = {wrae106}, doi = {10.1093/ismejo/wrae106} } diff --git a/oma_packages/extract_packages.R b/oma_packages/extract_packages.R index 9f5d0e53d..9dd61daee 100644 --- a/oma_packages/extract_packages.R +++ b/oma_packages/extract_packages.R @@ -1,7 +1,19 @@ -packages <- function() { - lines <- readLines("../DESCRIPTION") +extract_packages <- function(description_file_path = "~/OMA/DESCRIPTION", output_file_path = "~/OMA/oma_packages/oma_packages.csv") { + # Check if the DESCRIPTION file exists + if (!file.exists(description_file_path)) { + stop(paste("DESCRIPTION file not found at path:", description_file_path)) + } + + # Read the DESCRIPTION file + lines <- tryCatch(readLines(description_file_path), error = function(e) { + message("Error reading DESCRIPTION file: ", e$message) + return(NULL) + }) + + if (is.null(lines)) return() # Exit if file could not be read - extract_packages <- function(lines, section_name) { + # Function to extract packages from a given section + extract_packages_from_section <- function(lines, section_name) { section_index <- grep(paste0("^", section_name, ":"), lines) if (length(section_index) > 0) { start_index <- section_index + 1 @@ -14,12 +26,26 @@ packages <- function() { packages <- trimws(packages) return(packages[packages != ""]) } else { + message("Section '", section_name, "' not found in DESCRIPTION file.") return(character(0)) } } - suggests_packages <- extract_packages(lines, "Suggests") - write.table(suggests_packages, "oma_packages.csv", row.names = FALSE, col.names = FALSE, sep = ",", quote = FALSE) + # Extract packages from the Imports and Suggests sections + imports_packages <- extract_packages_from_section(lines, "Imports") + suggests_packages <- extract_packages_from_section(lines, "Suggests") + + # Combine the packages into a single vector and sort alphabetically + combined_packages <- sort(c(imports_packages, suggests_packages)) + + # Write the combined packages to a CSV file without headers + tryCatch({ + write.table(combined_packages, output_file_path, row.names = FALSE, col.names = FALSE, sep = ",", quote = FALSE) + message("Combined packages written to ", output_file_path) + }, error = function(e) { + message("Error writing combined packages to CSV file: ", e$message) + }) } -packages() +# Call the function with the default path to the DESCRIPTION file and output file path +extract_packages() diff --git a/oma_packages/oma_packages.csv b/oma_packages/oma_packages.csv index 2b5a7962d..d9dc21a89 100644 --- a/oma_packages/oma_packages.csv +++ b/oma_packages/oma_packages.csv @@ -21,16 +21,16 @@ DirichletMultinomial dplyr DT factoextra -forcats fido +forcats ggplot2 ggpubr ggtree glmnet glue grid -gtools gsEasy +gtools igraph kableExtra knitr @@ -45,8 +45,8 @@ mikropml MMUPHin MOFA2 multiview -NetCoMi NbClust +NetCoMi NMF patchwork phyloseq