Bootstrap: library
From: millironx/default/htslib:1.13

%post
  # Install dependencies
  apk add --no-cache python3 libcurl

  # Install build dependencies
  apk add --no-cache --virtual .build-deps py-pip g++ musl-dev make python3-dev boost-dev curl-dev

  # Install python package dependencies
  pip install --no-cache-dir biopython==1.79 numpy==1.21.2

  # Make versioning easier
  SHORAH_VERSION=1.99.2

  # Download the source tarball and build
  cd /tmp || exit 1
  wget https://github.com/cbg-ethz/shorah/releases/download/v$SHORAH_VERSION/shorah-$SHORAH_VERSION.tar.bz2 -O shorah-$SHORAH_VERSION.tar.bz2
  tar xjvf shorah-$SHORAH_VERSION.tar.bz2
  cd shorah-$SHORAH_VERSION
  ./configure
  make
  make install
  cd .. || exit 1
  rm -rf shorah-$SHORAH_VERSION*
  cd || exit 1

  # Cleanup build packages
  apk del --no-cache .build-deps

%test
  test_command () {
    if ! command -v "${1}"; then
      echo "command ${1} not found!"
      export FAILED_TESTS=1
    fi
  }

  test_command bash
  test_command ps
  test_command shorah
  test_command b2w
  test_command diri_sampler
  test_command fil

  if [ -n "$FAILED_TESTS" ]; then
    exit 1
  fi

%runscript
  shorah "$@"

%labels
  Author 25492070+MillironX@users.noreply.github.com
  SoftwareVersion 2.0.2
  SingularityDefinitionVersion 1

%help
  ShoRAH
  ======

  ShoRAH is an open source project for the analysis of next generation
  sequencing data. It is designed to analyse genetically heterogeneous samples.
  Its tools are written in different programming languages and provide error
  correction, haplotype reconstruction and estimation of the frequency of the
  different genetic variants present in a mixed sample.

  For more help, see
  - <http://cbg-ethz.github.io/shorah>
  - <https://github.com/MillironX/singularity-builds>
