Skip to content

Commit

Permalink
fixed #23
Browse files Browse the repository at this point in the history
  • Loading branch information
khoroshevskyi committed Jan 16, 2025
1 parent fc9152e commit b34c486
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 10 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ include bedboss/tokens/*
include bedboss/tokens/*
include bedboss/bbuploader/*
include bedboss/refgenome_validator/chrom_sizes/*
include bedboss/scripts/*
5 changes: 4 additions & 1 deletion bedboss/bedboss.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ def requirements_check() -> None:
"""
_LOGGER.info("Checking requirements...")
subprocess.run(
["bash", f"{os.path.dirname(os.path.abspath(__file__))}/requirements_test.sh"]
[
"bash",
f"{os.path.dirname(os.path.abspath(__file__))}/scripts/requirements_test.sh",
]
)


Expand Down
4 changes: 3 additions & 1 deletion bedboss/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,9 @@ def install_requirements():
import subprocess

r_path = os.path.abspath(
os.path.join(os.path.dirname(os.path.realpath(__file__)), "installRdeps.R")
os.path.join(
os.path.dirname(os.path.realpath(__file__)), "scripts", "installRdeps.R"
)
)

subprocess.run(
Expand Down
Empty file added bedboss/scripts/__init__.py
Empty file.
43 changes: 43 additions & 0 deletions bedboss/scripts/check_R_req.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
check_required_packages <- function() {
# ANSI escape codes for colors
red <- "\033[31m"
green <- "\033[32m"
reset <- "\033[0m"

# List of required R packages
required_packages <- c(
"optparse", "devtools", "ensembldb", "ExperimentHub", "AnnotationHub",
"AnnotationFilter", "BSgenome", "GenomicFeatures", "GenomicDistributions",
"GenomicDistributionsData", "GenomeInfoDb", "tools", "R.utils", "LOLA", "conflicted"
)

# Check if each package is installed
missing_packages <- required_packages[!sapply(required_packages, requireNamespace, quietly = TRUE)]

# Get the installed packages
installed_packages <- required_packages[sapply(required_packages, requireNamespace, quietly = TRUE)]

# If there are missing packages, print them
if (length(missing_packages) > 0) {
cat(paste0(red, "The following packages are missing:\n", reset))
cat(paste0(red, missing_packages, collapse = "\n"), "\n", reset) # Print missing packages vertically
} else {
cat(paste0(green, "All R required packages are installed.\n", reset))
}

# Print installed packages vertically
cat(paste0(green, "\nThe following packages are installed:\n", reset))
cat(paste0(green, installed_packages, collapse = "\n"), "\n", reset) # Print installed packages vertically

# Return missing packages
return(missing_packages)
}

# Call the function
missing_packages <- check_required_packages()

# Optionally handle missing packages
if (length(missing_packages) > 0) {
quit(status = 1)
}
quit(status = 0)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,36 @@ if ! is_executable "wigToBigWig"; then
INSTALL_WARNINGS=$((INSTALL_WARNINGS+1))
fi


if is_executable "R"; then
# Old requirements check
#if is_executable "R"; then
#
# echo -e "-----------------------------------------------------------"
# echo -e "Checking required R packages for bedstat... "
# echo -e "-----------------------------------------------------------"
# declare -a requiredRPackages=("optparse ""devtools" "ensembldb" "ExperimentHub" "AnnotationHub" "AnnotationFilter" "BSgenome" "GenomicFeatures" "GenomicDistributions" "GenomicDistributionsData" "GenomeInfoDb" "ensembldb" "tools" "R.utils" "LOLA" "conflicted")
# for package in "${requiredRPackages[@]}"; do
# if ! r_check_req $package; then
# INSTALL_ERROR=$((INSTALL_ERROR+1))
# fi
#done
#fi

if is_executable "Rscript"; then
echo -e "-----------------------------------------------------------"
echo -e "Checking required R packages for bedstat... "
echo -e "-----------------------------------------------------------"
declare -a requiredRPackages=("optparse ""devtools" "ensembldb" "ExperimentHub" "AnnotationHub" "AnnotationFilter" "BSgenome" "GenomicFeatures" "GenomicDistributions" "GenomicDistributionsData" "GenomeInfoDb" "ensembldb" "tools" "R.utils" "LOLA" "conflicted")
for package in "${requiredRPackages[@]}"; do
if ! r_check_req $package; then
INSTALL_ERROR=$((INSTALL_ERROR+1))
fi
done

SCRIPT_DIR=$(dirname "$(realpath "$0")")
# echo "The script is located at: $SCRIPT_DIR"
Rscript "$SCRIPT_DIR/check_R_req.R"

if [ $? -eq 0 ]; then
echo "All required packages are installed."
else
echo $(fail "ERROR: Some R required packages are missing. Please install them.")
INSTALL_ERROR=$((INSTALL_ERROR+1))
fi

fi

echo "Number of WARNINGS: $INSTALL_WARNINGS"
Expand Down

0 comments on commit b34c486

Please sign in to comment.