diff --git a/LifeSciences/README.md b/LifeSciences/README.md index 41730400ea05910ba52ce61f9b9ba5ee329df11d..96e7fd3ea5854aaf0d8d1b2c19fa3c2ceec86d17 100644 --- a/LifeSciences/README.md +++ b/LifeSciences/README.md @@ -17,3 +17,4 @@ Life Sciences Software List: - repositories: ambertools-21 - repositories: deepTools-2.0.0 - repositories: AutoDock-4.2.6 +- repositories: gridss-2.13.2 diff --git a/LifeSciences/gridss-2.13.2/build.sh b/LifeSciences/gridss-2.13.2/build.sh new file mode 100644 index 0000000000000000000000000000000000000000..b16268f53588f1c7a372d48cb82fa5de023a19bc --- /dev/null +++ b/LifeSciences/gridss-2.13.2/build.sh @@ -0,0 +1,138 @@ +#!/bin/bash +# 此脚本用来编译安装gridss-2.13.2软件 +# gridss-2.13.2软件介绍 +# GRIDSS是一个模块软件套件,其中包含可用于检测基因组重排的工具。 +# Usage: +# bash /path/to/build.sh /path/to/build /path/to/install +# 使用build.sh 脚本样例 bash /path/to/build.sh /path/to/build /path/to/install +# 使用build.sh 需要root权限或者sudo权限,否则无法安装依赖 +# +############################################################## + +source "$( + cd "$(dirname "$0")" || exit 1 + pwd +)/common.sh" + +function install_development() { + sudo yum install -y m4 bc zlib-devel zlib environment-modules systemd-devel + source /etc/profile + module purge +} + +function install_bisheng() { + bash "$1"/bisheng-compiler-2.1.0.sh "$2" "$3" + module use "$3"/bisheng-compiler-2.1.0 + module load "$3"/bisheng-compiler-2.1.0/bisheng_modulefiles +} + +function install_jdk() { + bash "$1"/bisheng-jdk-8u322.sh "$2" "$3" + module use "$3"/bisheng-jdk-8u322 + module load "$3"/bisheng-jdk-8u322/jdk_modulefiles +} + +function install_bwa() { + bash "$1"/bwa-0.7.17.sh "$2" "$3" + module use "$3"/bwa-0.7.17 + module load "$3"/bwa-0.7.17/bwa_modulefiles +} + +function install_R() { + bash "$1"/R-4.2.0.sh "$2" "$3" + module use "$3"/R-4.2.0 + module load "$3"/R-4.2.0/R-4.2.0_modulefiles +} + +function install_samtools() { + bash "$1"/samtools-1.15.1.sh "$2" "$3" + module use "$3"/samtools-1.15.1 + module load "$3"/samtools-1.15.1/samtools_modulefiles +} + +function install_gridss() { + bash "$4"/gridss-2.13.2.sh "$1" "$2" + mkdir -p "$3"/gridss-2.13.2-hpc && cp -r "$2"/* "$3"/gridss-2.13.2-hpc/ +} + +function copy_common_and_R_shell() { + rm -rf "$2"/gridss-2.13.2-hpc/R-4.2.0 + cp "$1"/dependency/R-4.2.0.sh "$1"/common.sh "$2"/gridss-2.13.2-hpc/ + sed -i '6 c\)/common.sh"' "$2"/gridss-2.13.2-hpc/R-4.2.0.sh +} + +function write_gridss_run() { + cat >"$1/gridss-2.13.2-hpc/run.sh" </dev/null + +current_dir="\$(cd "\$(dirname "\${BASH_SOURCE[0]}")" && pwd -P)" +for f in "\${current_dir}"/*; do + if [[ -d "\${f}" && -f "\$(ls "\${f}"/*modulefiles 2>&1)" ]]; then + module use "\${f}" && module load "\${f}"/*modulefiles + fi +done + +# 编译 R 并初始化其环境变量 +mkdir "\${current_dir}"/build +bash "\${current_dir}"/R-4.2.0.sh "\${current_dir}"/build "\${current_dir}" +module use "\${current_dir}"/R-4.2.0 +module load "\${current_dir}"/R-4.2.0/R-4.2.0_modulefiles +rm -rf "\${current_dir}"/build + +echo -e "\033[1;32;1mgridss environment initialization completed.\033[0m" + +EOF + + chmod +x "$1"/gridss-2.13.2-hpc/run.sh +} + +function tar_pkg() { + echo "# 正在打包 gridss 文件 路径为$1" + cd "$1" && tar -zcf gridss-2.13.2-hpc.tar.gz gridss-2.13.2-hpc + echo -e "\033[1;32;1m# gridss 已经打包成功 文件路径为$1/gridss-2.13.2-hpc.tar.gz\033[0m" +} + +function main() { + set_script_dir + + # $1(构建路径)、$2(安装路径)检测 + is_check_build_install_directory "$1" "$2" "build.sh" + + # 构建路径 + buildpath=$(create_dir "$1") + + # 安装路径 + installpath=$(create_dir "$2") + + # 依赖路径 + dep_dir="${SCRIPT_DIR}"/dependency + + # 打包路径 + pkg_dir="${SCRIPT_DIR}"/pkg + + install_development + install_bisheng "$dep_dir" "$buildpath" "$installpath" + install_jdk "$dep_dir" "$buildpath" "$installpath" + install_bwa "$dep_dir" "$buildpath" "$installpath" + install_samtools "$dep_dir" "$buildpath" "$installpath" + install_R "$dep_dir" "$buildpath" "$installpath" + install_gridss "$buildpath" "$installpath" "$pkg_dir" "${SCRIPT_DIR}" + set -e + copy_common_and_R_shell "${SCRIPT_DIR}" "$pkg_dir" + write_gridss_run "$pkg_dir" + tar_pkg "$pkg_dir" + echo " # ------------------------------------------------------------------------" + echo "# 运行软件前请执行以下命令" + echo -e "\033[1;32;1m# source ""${pkg_dir}""/gridss-2.13.2-hpc/run.sh\033[0m" + echo "# 来加载 gridss 运行时环境变量" + echo "# ------------------------------------------------------------------------" + rm -rf "$buildpath" "$installpath" +} + +main "$@" diff --git a/LifeSciences/gridss-2.13.2/common.sh b/LifeSciences/gridss-2.13.2/common.sh new file mode 100644 index 0000000000000000000000000000000000000000..6b0cf21cd82bdc77dd5b797c70a4a532bcd1c4ae --- /dev/null +++ b/LifeSciences/gridss-2.13.2/common.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +function is_check_build_install_directory() { + if [[ $# -ne 3 ]]; then + echo "The format is as follows:" + echo "bash $3 buildpath installpath" + echo ":param buildpath: 应用构建绝对路径" + echo ":param installpath: 应用安装绝对路径" + exit 1 + fi + + [[ ! "$1" =~ ^/.* || "$1" = "/" ]] && echo "请输入正确的构建路径" && exit 1 + [[ ! "$2" =~ ^/.* || "$2" = "/" ]] && echo "请输入正确的安装路径" && exit 1 + echo "# ------------------------------------------------------------------------" + echo "# $3 正在运行" +} + +function is_check_build_equal() { + local buildpath + local installpath + buildpath="$1" + installpath="$2" + [[ "${buildpath}" =~ .*/$ ]] && buildpath=${buildpath%/*} + [[ "${installpath}" =~ .*/$ ]] && installpath=${installpath%/*} + [[ "${buildpath}" == "${installpath}" ]] && echo "构建路径与安装路径需为不同路径" && exit 1 + echo "# 构建路径为$1" + echo "# 安装路径为$2" +} + +function create_dir() { + local path + path="$1" + [[ "$path" =~ .*/$ ]] && path=${path%/*} + if [[ ! -d "${path}" && ! -f "${path}" ]]; then + mkdir -p "${path}" + elif [[ -n "$(ls -A "$1")" ]]; then + path=$path$(date "+%y%m%d%H%M%S") && mkdir -p "${path}" + fi + echo "${path}" +} + +function set_script_dir() { + local REL_SCRIPT_DIR + REL_SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")" || return 1 + SCRIPT_DIR="$(cd "${REL_SCRIPT_DIR}" && pwd)" || return 1 +} diff --git a/LifeSciences/gridss-2.13.2/dependency/R-4.2.0.sh b/LifeSciences/gridss-2.13.2/dependency/R-4.2.0.sh new file mode 100644 index 0000000000000000000000000000000000000000..296de8cf88075cd7e1bb8dde6226c6549f1c5678 --- /dev/null +++ b/LifeSciences/gridss-2.13.2/dependency/R-4.2.0.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +source "$( + cd "$(dirname "$0")" || exit 1 + pwd +)/../common.sh" + +function install_development() { + sudo yum install -y wget tar environment-modules readline-devel libXt-devel \ + bzip2-devel xz-devel libcurl-devel glibc-headers gcc-c++ pcre* -y + source /etc/profile +} + +function download_R() { + echo "# R正在下载" + wget -t 0 -T 20 -c -P "$1" http://mirror.bjtu.edu.cn/cran/src/base/R-4/R-4.2.0.tar.gz + if [[ $? -eq 0 ]]; then + echo -e "\033[1;32;1m# R已经下载成功\033[0m" + else + echo -e "\033[31m# R下载失败,请重新执行脚本\033[0m" + exit 1 + fi +} + +function install_R() { + echo "# R 正在安装" + tar -xzf "$1"/R-4.2.0.tar.gz -C "$1" && rm -rf "$1"/R-4.2.0.tar.gz + cd "$1"/R-4.2.0 + FC=flang CC=clang CXX=clang++ ./configure --enable-R-shlib=yes --with-tcltk --prefix="$2"/R-4.2.0 + make -j"$(nproc)" && make install + echo -e "\033[1;32;1m# R 已经安装完毕\033[0m" +} + +function write_R_module() { + cat >"$1/R-4.2.0/R-4.2.0_modulefiles" <"$1/bisheng-compiler-2.1.0/bisheng_modulefiles" <"$1/bisheng-jdk-8u322/jdk_modulefiles" <"$1/bwa-0.7.17/bwa_modulefiles" <"$1/samtools-1.15.1/samtools_modulefiles" <"$1/gridss-2.13.2/gridss_modulefiles" <