diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..51ca7c924c575d4e6fe6976dc5655a245b852381 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,32 @@ +default: + tags: + - shell + +workflow: + rules: + - if: $CI_PIPELINE_SOURCE == "push" + +test: + rules: + - if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH + script: + - export IMAGE="${DOCKER_ORG}/${DOCKER_REPO}:latest" + - docker build -t $IMAGE . + - docker run --rm $IMAGE tests/test.sh + +test_and_publish: + rules: + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + script: + - export VERSION=$(grep 'version <-' ascii_alignment_pileup.R | cut -f2 -d'"') + - export IMAGE="${DOCKER_ORG}/${DOCKER_REPO}" + - | + docker build \ + -t ${IMAGE}:${VERSION} \ + --build-arg version=$VERSION \ + . + - docker run --rm ${IMAGE}:${VERSION} tests/test.sh + - echo "${DOCKER_TOKEN}" | docker login -u "${DOCKER_USER}" --password-stdin + - docker tag ${IMAGE}:${VERSION} ${IMAGE}:latest + - docker push ${IMAGE}:${VERSION} + - docker push ${IMAGE}:latest diff --git a/Dockerfile b/Dockerfile index e806df88b5abe2cbac1093faa8df1394fb8ffa30..5d0eb0fa5a72101226f08a6c75d433211131a519 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,15 @@ ##### BASE ##### FROM rocker/r-ver:4.2.1 +##### BUILD ARGUMENTS ##### +ARG version=unknown + ##### METADATA ##### MAINTAINER zavolab-biozentrum@unibas.ch LABEL base.image="rocker/r-ver:4.2.1" LABEL version="1" LABEL software="ascii_alignment_pileup.R" -LABEL software.version="1.0.1" +LABEL software.version=$version LABEL software.description="Generates an ASCII-style pileup of read alignments in one or more BAM files against one or more regions specified in a BED file" LABEL software.website="https://git.scicore.unibas.ch/zavolan_group/tools/ascii-alignment-pileup" LABEL software.documentation="https://git.scicore.unibas.ch/zavolan_group/tools/ascii-alignment-pileup" @@ -64,4 +67,3 @@ WORKDIR ${WORKDIR} RUN chown -R ${USER}:${GROUP} ${WORKDIR} \ && chmod 700 ${WORKDIR} USER ${USER} - diff --git a/ascii_alignment_pileup.R b/ascii_alignment_pileup.R index 802b871744552dcbeecce1888df511435fcaa28d..daebf344b20d98d873b6e60808744619adf37bff 100755 --- a/ascii_alignment_pileup.R +++ b/ascii_alignment_pileup.R @@ -29,10 +29,11 @@ against one or more regions specified in a BED file.\n" author <- "Author: Alexander Kanitz" affiliation <- "Affiliation: Biozentrum, University of Basel" email <- "Email: alexander.kanitz@alumni.ethz.ch" -version <- "Version: 1.0.2" +version <- "1.1.0" +version_formatted <- paste("Version:", version, sep=" ") requirements <- c("optparse", "rtracklayer", "GenomicAlignments", "tools") requirements_txt <- paste("Requires:", paste(requirements, collapse=", "), sep=" ") -msg <- paste(description, author, affiliation, email, version, requirements_txt, sep="\n") +msg <- paste(description, author, affiliation, email, version_formatted, requirements_txt, sep="\n") notes <- "Notes: - For the input queries, consider the `--maximum-region-width` parameter, which is provided for safety. While it is possible to increase it, wide regions may diff --git a/tests/expected_output.md5 b/tests/expected_output.md5 new file mode 100644 index 0000000000000000000000000000000000000000..3319e18eb283216515a9aadf2c72fec19bd867e7 --- /dev/null +++ b/tests/expected_output.md5 @@ -0,0 +1 @@ +6b5a66981bd83329219002897be393a6 test.test-mir.min.1.pileup.tab diff --git a/tests/test.sh b/tests/test.sh new file mode 100755 index 0000000000000000000000000000000000000000..0ccc00933907d5ad514d3fe3f3ac757848b3b475 --- /dev/null +++ b/tests/test.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +# Tear down test environment +cleanup () { + rc=$? + rm "test.test-mir.min.1.pileup.tab" + cd $user_dir + echo "Exit status: $rc" +} +trap cleanup EXIT + +# Set up test environment +set -eo pipefail # ensures that script exits at first command that exits with non-zero status +set -u # ensures that script exits when unset variables are used +set -x # facilitates debugging by printing out executed commands +user_dir=$PWD +script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +cd $script_dir + +ascii_alignment_pileup.R \ + --verbose \ + --reference="test_files/test.fa.gz" \ + --annotations="test_files/test.gff" \ + --output-directory="$PWD" \ + "test_files/test.bed" \ + "test_files/test.bam" + +# Check md5 sum of output file +md5sum --check "expected_output.md5" diff --git a/tests/test_files/test.fa.gz b/tests/test_files/test.fa.gz new file mode 100644 index 0000000000000000000000000000000000000000..a0b4215d5cad3e0d702bb14fd619e44f02699d4b Binary files /dev/null and b/tests/test_files/test.fa.gz differ