Skip to content

Commit

Permalink
Merge pull request #93 from CCBR/install-script
Browse files Browse the repository at this point in the history
Create install script for pipeline usage within ccbrpipeliner
  • Loading branch information
slsevilla authored Oct 19, 2023
2 parents 36aed6f + 852c79f commit 44abef9
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 18 deletions.
33 changes: 15 additions & 18 deletions carlisle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ SNAKEMAKE_VERSION="snakemake/7.19.1"
SINGULARITY_VERSION="singularity/3.10.5"

set -eo pipefail
module purge

SCRIPTNAME="$0"
SCRIPTBASENAME=$(readlink -f $(basename $0))
Expand All @@ -28,29 +27,27 @@ tools_specific_yaml="tools_biowulf.yaml"
# essential files
# these are relative to the workflows' base folder
# these are copied into the WORKDIR
ESSENTIAL_FILES="config/config.yaml config/samples.tsv config/contrasts.tsv config/fqscreen_config.conf config/multiqc_config.yaml resources/cluster_* resources/tools_*"
ESSENTIAL_FOLDERS="workflow/scripts"
ESSENTIAL_FILES="config/config.yaml config/samples.tsv config/contrasts.tsv config/fqscreen_config.conf config/multiqc_config.yaml"
ESSENTIAL_FOLDERS="workflow/scripts annotation"
# set extra singularity bindings
EXTRA_SINGULARITY_BINDS="-B /data/CCBR_Pipeliner/,/lscratch"

function get_git_commitid_tag() {
# This function gets the latest git commit id and tag
# Input is PIPELINE_HOME folder which is a git folder
cd $1
gid=$(git rev-parse HEAD)
tag=$(git describe --tags $gid 2>/dev/null)
echo -ne "$gid\t$tag"
}

# ## setting PIPELINE_HOME
PIPELINE_HOME=$(readlink -f $(dirname "$0"))
echo "Pipeline Dir: $PIPELINE_HOME"
# set snakefile
SNAKEFILE="${PIPELINE_HOME}/workflow/Snakefile"

# get github commit tag
GIT_COMMIT_TAG=$(get_git_commitid_tag $PIPELINE_HOME)
echo "Git Commit/Tag: $GIT_COMMIT_TAG"
function get_version_from_path() {
PIPELINE_HOME=$1
VERSION="$(echo $PIPELINE_HOME | grep -oP 'v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?' - )"
echo -ne $VERSION
}

# get version from directory name
# regex source: https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
#echo "Version: $VERSION"
echo "Version: $(get_version_from_path $PIPELINE_HOME)"

function usage() {
# This function prints generic usage of the wrapper script.
Expand Down Expand Up @@ -104,8 +101,8 @@ function init() {
done

# rename config dependent on partition used
cp $WORKDIR/config/$cluster_specific_yaml $WORKDIR/config/cluster.yaml
cp $WORKDIR/config/$tools_specific_yaml $WORKDIR/config/tools.yaml
cp ${PIPELINE_HOME}/resources/$cluster_specific_yaml $WORKDIR/config/cluster.yaml
cp ${PIPELINE_HOME}/resources/$tools_specific_yaml $WORKDIR/config/tools.yaml

# copy essential folders
for f in $ESSENTIAL_FOLDERS;do
Expand Down Expand Up @@ -443,4 +440,4 @@ function main(){
}

# call the main function
main "$@"
main "$@"
38 changes: 38 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
# usage:
# ./install.sh new/path/to/install
# examples
# ./install.sh .v2.4.0
# /data/CCBR_Pipeliner/Pipelines/CARLISLE/dev/install.sh /data/CCBR_Pipeliner/Pipelines/CARLISLE/.v2.5.0-a
set -euo pipefail

VERSION=$1
mkdir -p ${VERSION}/bin
INSTALL_PATH=$(readlink -f ${VERSION}/bin)
DIRNAME=$(readlink -f $(dirname $0))

if [ -n "$(ls -A $INSTALL_PATH 2>/dev/null)" ]
then
echo "ERROR: directory not empty: ${INSTALL_PATH}"
echo $(ls $INSTALL_PATH)
exit 1
fi

# copy essential files & directories

## carlisle CLI script
cp $DIRNAME/carlisle $INSTALL_PATH/

## all config & workflow scripts;
for subdir in annotation config workflow resources .test
do
mkdir -p ${INSTALL_PATH}/$subdir
cp -r ${DIRNAME}/$subdir/* ${INSTALL_PATH}/$subdir
done

# export path
if [[ ":$PATH:" != *":${INSTALL_PATH}:"* ]];then
export PATH="${PATH}:${INSTALL_PATH}"
fi

echo "${INSTALL_PATH}"

0 comments on commit 44abef9

Please sign in to comment.