Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add unit tests to cleanup.R #77

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
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
5 changes: 4 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,7 @@ Imports:
XVector,
yaml
Suggests:
knitr
knitr,
testthat,
mockery,
readr
7 changes: 4 additions & 3 deletions R/cleanup.R
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,10 @@ removeEmptyRows <- function(prot, by_column = "DomArch") {
prot <- prot %>%
as_tibble() %>%
# filter(grepl("\\*", {{by_column}})) %>% # Keep only rows with Query (*) for GenContext
filter(!grepl("^-$", {{ by_column }})) %>% # remove "-"
filter(!grepl("^NA$", {{ by_column }})) %>% # remove "NA"
filter(!grepl("^$", {{ by_column }})) # remove empty rows
filter(!grepl("^-$", .[[by_column]])) %>% # remove "-"
filter(!grepl("^NA$", .[[by_column]])) %>% # remove "NA"
filter(!grepl("^$", .[[by_column]])) %>% # remove empty rows
filter(!grepl("^\\s*$", .[[by_column]])) # remove rows with only spaces

return(prot)
}
Expand Down
12 changes: 11 additions & 1 deletion R/fa2domain.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ runIPRScan <- function(
# destPartition = "LocalQ",
# destQoS = "shortjobs"
) {
# Validate inputs
if (is.null(filepath_fasta) || filepath_fasta == "") {
stop("filepath_fasta cannot be NULL or empty")
}
if (is.null(filepath_out) || filepath_out == "") {
stop("filepath_out cannot be NULL or empty")
}
if (!all(appl %in% c("Pfam", "Gene3D"))) {
stop("Invalid application specified")
}
# construct interproscan command
cmd_iprscan <- stringr::str_glue(
"iprscan -i {filepath_fasta} -b {filepath_out} --cpu 4 -f TSV ",
Expand Down Expand Up @@ -283,7 +293,7 @@ getDomainsFromFA <- function(
if (verbose) {
msg <- stringr::str_glue(
"accession number: {header} had no domains for the ",
"selected analyes: {paste(analysis, collapse = ',')}\n"
"selected analyses: {paste(analysis, collapse = ',')}\n"
)
warning(msg)
}
Expand Down
31 changes: 31 additions & 0 deletions man/acc2FA.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
library(testthat)
library(MolEvolvR)

test_check("MolEvolvR")
Loading
Loading