diff --git a/modules/viquas/Dockerfile b/modules/viquas/Dockerfile new file mode 100644 index 0000000..f35ead5 --- /dev/null +++ b/modules/viquas/Dockerfile @@ -0,0 +1,58 @@ +FROM ubuntu:bionic + +ENV R_VERSION=3.6.3 +ENV ROCKER_VERSION=4.1.1 +ENV R_HOME=/usr/local/lib/R +ENV TZ=Etc/UTC +ENV SAMTOOLS_VERSION=1.2 + +# Install R basic dependencies +RUN apt-get update && \ + apt-get install --no-install-recommends -y \ + sed \ + curl \ + ca-certificates +RUN curl -L "https://github.com/rocker-org/rocker-versioned2/archive/refs/tags/R${ROCKER_VERSION}.tar.gz" | tar xvz +RUN ./rocker-versioned2-R${ROCKER_VERSION}/scripts/install_R.sh +RUN rm -rf rocker-versioned2-R${ROCKER_VERSION} + +# Install BioPerl +RUN apt-get update && \ + apt-get install --no-install-recommends -y \ + curl \ + perl \ + cpanminus \ + build-essential \ + make \ + libexpat1-dev \ + libssl-dev \ + zlib1g-dev +RUN cpanm -n -v Bio::Seq Bio::SeqIO Perl4::CoreLibs + +# Install R packages +RUN install2.r --error --skipinstalled BiocManager +RUN R -e "BiocManager::install(c('Biostrings', 'seqinr'))" + +# Install samtools +RUN apt-get update && \ + apt-get install --no-install-recommends -y libncurses5-dev +RUN curl -L "https://github.com/samtools/samtools/releases/download/${SAMTOOLS_VERSION}/samtools-${SAMTOOLS_VERSION}.tar.bz2" | tar xvj +RUN cd samtools-${SAMTOOLS_VERSION} && make && make install && cd .. +RUN rm -rf samtools-${SAMTOOLS_VERSION} + +# Cleanup +RUN apt-get remove -y \ + build-essential \ + make + +# Install Viquas +RUN apt-get update && apt-get install --no-install-recommends -y curl +RUN mkdir /viquas && curl -L "https://master.dl.sourceforge.net/project/viquas/ViQuaS1.3.tar.gz" | tar xvz -C /viquas --strip-components=1 +RUN apt-get remove -y curl + +# Add wrapper script +COPY viquas /usr/bin/viquas +RUN chmod +x /usr/bin/viquas +RUN mkdir /work + +ENTRYPOINT [ "viquas" ] diff --git a/modules/viquas/viquas b/modules/viquas/viquas new file mode 100755 index 0000000..410d59d --- /dev/null +++ b/modules/viquas/viquas @@ -0,0 +1,55 @@ +#!/bin/sh +USAGE=" + USAGE: + viquas reference.fsa reads.bam [o r perform_richness diversity_region_length] +" + +NUM_ARGS=$# +case $NUM_ARGS in + 2) + ;; + 6) + ;; + *) + echo "${USAGE}" + echo "Incorrect number of arguments: expecting 2 or 6" + exit 1 +esac + +PWD_BACKUP=$PWD + +if [ ! -f "${1}" ]; then + echo "Error: ${1} is not a file" + exit 1 +fi + +if [ ! -f "${2}" ]; then + echo "Error: ${2} is not a file" + exit 1 +fi + +REFERENCE_FILE=$(basename "${1}") +BAM_FILE=$(basename "${2}") + +cp "${1}" /viquas +cp "${2}" /viquas + +cd /viquas || exit 1 + +case $NUM_ARGS in + 2) + Rscript /viquas/ViQuaS.R "${REFERENCE_FILE}" "${BAM_FILE}" + ;; + 6) + Rscript /viquas/ViQuaS.R "${REFERENCE_FILE}" "${BAM_FILE}" "${@[3:]}" + ;; + *) + echo "${USAGE}" + echo "Incorrect number of arguments: expecting 2 or 6" + exit 1 +esac + +mv /viquas/ViQuaS-Spectrum.fa "${PWD_BACKUP}" +mv /viquas/ViQuaS-Richness.txt "${PWD_BACKUP}" 2> /dev/null + +cd "${PWD_BACKUP}" || exit 1