Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ Suggests:
rmarkdown,
writexl,
testthat (>= 3.0.0)
Config/roxygen2/version: 8.0.0
Config/roxygen2/version: 8.1.0
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export(.extractAMRtable)
export(.updateBVBRCdata)
export(CDHIT2duckdb)
export(buildClusterFeatureMap)
export(buildDyadFeatureMap)
export(cleanData)
export(cleanMetaData)
export(exportProcessedData)
Expand Down
71 changes: 35 additions & 36 deletions R/data_processing.R
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,6 @@ CDHIT2duckdb <- function(duckdb_path,
#' @returns A list of paths to the database hmm files.
#'
#' @keywords internal
#' @examples
.prepareHmmerDatabases <- function(
hmmer_db_dir,
databases = c("Pfam", "COG", "AMRFinder"),
Expand Down Expand Up @@ -1281,17 +1280,17 @@ CDHIT2duckdb <- function(duckdb_path,

#' The function to run HMMER with docker
#'
#' @param JOB_NAME
#' @param FASTA
#' @param DB
#' @param Total_proteins
#' @param output_path
#' @param db_paths
#' @param docker_image
#' @param threads
#' @param n_workers
#' @param JOB_NAME protein_chunk id
#' @param FASTA fasta sequences
#' @param DB HMM database
#' @param Total_proteins protein sequence count
#' @param output_path path for saving hmmer outputs
#' @param db_paths path to HMM database
#' @param docker_image hmmer docker image (ideally from dockerhub)
#' @param threads number of threads
#' @param n_workers number of parallel workers
#'
#' @returns
#' @returns the filename of the parquet file with hmmer output post parsing
#'
#' @keywords internal
.runHmmerJob <- function(JOB_NAME, FASTA, DB, Total_proteins,
Expand Down Expand Up @@ -1375,19 +1374,16 @@ CDHIT2duckdb <- function(duckdb_path,

#' Wrapper for preparing HMM databases and running HMMER on protein sequences from duckdb and writing them.
#'
#' @param duckdb_path
#' @param output_path
#' @param threads
#' @param hmmer_db_dir
#' @param databases
#' @param docker_image
#' @param num_of_splits
#' @param n_workers
#'
#' @returns
#' @param duckdb_path path to the duckdb with protein sequences and list
#' @param output_path path where HMMER output will be saved
#' @param threads number of threads
#' @param hmmer_db_dir path to the directory where HMM databases are/will be downloaded
#' @param databases list of HMM databases
#' @param docker_image the docker image of HMMER
#' @param num_of_splits The number of splits of the protein sequence file for parallel processing
#' @param n_workers The number of parallel runs
#'
#' @keywords internal
#' @examples
.runHMMER <- function(duckdb_path,
output_path,
threads = 8L,
Expand Down Expand Up @@ -2203,16 +2199,18 @@ CDHIT2duckdb <- function(duckdb_path,
}


# Clean BV-BRC metadata, then save as Parquet files
#'
#' @param duckdb_path
#' @param path
#' @param ref_file_path
#' Clean BV-BRC metadata, then save as Parquet files
#'
#' @returns
#' @param duckdb_path Path to the **per-selection DuckDB** produced by
#' [prepareGenomes()] (e.g., `"data/<Bug>/<Abbrev>.duckdb"`). This DB must
#' already contain the tables written by [prepareGenomes()] and the upstream
#' genome-processing steps.
#' @param path the path to working directory
#' @param ref_file_path Directory containing reference TSVs used by
#' [cleanMetaData()] and [cleanData()] for metadata harmonization.
#' Default: `"data_raw/"`.
#'
#' @export
#'
#' @examples
cleanMetaData <- function(duckdb_path, path, ref_file_path = "data_raw/") {
duckdb_path <- normalizePath(duckdb_path)
# If no explicit path is provided (or a generic one), choose results/<bug>/ when
Expand Down Expand Up @@ -2358,15 +2356,15 @@ cleanMetaData <- function(duckdb_path, path, ref_file_path = "data_raw/") {
invisible(TRUE)
}

# Clean feature matrices, then save as Parquet files
#' Clean feature matrices, then save as Parquet files
#'
#' @param duckdb_path
#' @param path
#' @param duckdb_path Path to the **per-selection DuckDB** produced by
#' [prepareGenomes()] (e.g., `"data/<Bug>/<Abbrev>.duckdb"`). This DB must
#' already contain the tables written by [prepareGenomes()] and the upstream
#' genome-processing steps.
#' @param path the path to working directory
#'
#' @returns
#' @export
#'
#' @examples
cleanData <- function(duckdb_path, path) {
duckdb_path <- normalizePath(duckdb_path)
# If no explicit path is provided (or a generic one), choose results/<bug>/ when
Expand Down Expand Up @@ -2513,6 +2511,7 @@ cleanData <- function(duckdb_path, path) {
names_to = "annotation",
values_to = "value"
) |>
dplyr::rename(!!database := annotation) |>
dplyr::filter(!is.na(value) & value != "") |>
dplyr::mutate(value = as.integer(value)) |>
writeCompressedParquet(count_parquet)
Expand Down
Loading