#!/usr/bin/env bash

# bd_rhapsody processing-workflows-quantile-filtering
# 
# This wrapper script is auto-generated by viash 0.9.7 and is thus a derivative
# work thereof. This software comes with ABSOLUTELY NO WARRANTY from Data
# Intuitive.
# 
# The component may contain files which fall under a different license. The
# authors of this component should specify the license in the header of such
# files, or include a separate license file detailing the licenses of all included
# files.
# 
# Component authors:
#  * Robrecht Cannoodt (author, maintainer)
#  * Weiwei Schultz (contributor)

set -e

if [ -z "$VIASH_TEMP" ]; then
  VIASH_TEMP=${VIASH_TEMP:-$VIASH_TMPDIR}
  VIASH_TEMP=${VIASH_TEMP:-$VIASH_TEMPDIR}
  VIASH_TEMP=${VIASH_TEMP:-$VIASH_TMP}
  VIASH_TEMP=${VIASH_TEMP:-$TMPDIR}
  VIASH_TEMP=${VIASH_TEMP:-$TMP}
  VIASH_TEMP=${VIASH_TEMP:-$TEMPDIR}
  VIASH_TEMP=${VIASH_TEMP:-$TEMP}
  VIASH_TEMP=${VIASH_TEMP:-/tmp}
fi

# define helper functions
# ViashQuote: put quotes around non flag values
# $1     : unquoted string
# return : possibly quoted string
# examples:
#   ViashQuote --foo      # returns --foo
#   ViashQuote bar        # returns 'bar'
#   Viashquote --foo=bar  # returns --foo='bar'
function ViashQuote {
  if [[ "$1" =~ ^-+[a-zA-Z0-9_\-]+=.+$ ]]; then
    echo "$1" | sed "s#=\(.*\)#='\1'#"
  elif [[ "$1" =~ ^-+[a-zA-Z0-9_\-]+$ ]]; then
    echo "$1"
  else
    echo "'$1'"
  fi
}
# ViashRemoveFlags: Remove leading flag
# $1     : string with a possible leading flag
# return : string without possible leading flag
# examples:
#   ViashRemoveFlags --foo=bar  # returns bar
function ViashRemoveFlags {
  echo "$1" | sed 's/^--*[a-zA-Z0-9_\-]*=//'
}
# ViashSourceDir: return the path of a bash file, following symlinks
# usage   : ViashSourceDir ${BASH_SOURCE[0]}
# $1      : Should always be set to ${BASH_SOURCE[0]}
# returns : The absolute path of the bash file
function ViashSourceDir {
  local source="$1"
  while [ -h "$source" ]; do
    local dir="$( cd -P "$( dirname "$source" )" >/dev/null 2>&1 && pwd )"
    source="$(readlink "$source")"
    [[ $source != /* ]] && source="$dir/$source"
  done
  cd -P "$( dirname "$source" )" >/dev/null 2>&1 && pwd
}
# ViashFindTargetDir: return the path of the '.build.yaml' file, following symlinks
# usage   : ViashFindTargetDir 'ScriptPath'
# $1      : The location from where to start the upward search
# returns : The absolute path of the '.build.yaml' file
function ViashFindTargetDir {
  local source="$1"
  while [[ "$source" != "" && ! -e "$source/.build.yaml" ]]; do
    source=${source%/*}
  done
  echo $source
}
# see https://en.wikipedia.org/wiki/Syslog#Severity_level
VIASH_LOGCODE_EMERGENCY=0
VIASH_LOGCODE_ALERT=1
VIASH_LOGCODE_CRITICAL=2
VIASH_LOGCODE_ERROR=3
VIASH_LOGCODE_WARNING=4
VIASH_LOGCODE_NOTICE=5
VIASH_LOGCODE_INFO=6
VIASH_LOGCODE_DEBUG=7
VIASH_VERBOSITY=$VIASH_LOGCODE_NOTICE

# ViashLog: Log events depending on the verbosity level
# usage: ViashLog 1 alert Oh no something went wrong!
# $1: required verbosity level
# $2: display tag
# $3+: messages to display
# stdout: Your input, prepended by '[$2] '.
function ViashLog {
  local required_level="$1"
  local display_tag="$2"
  shift 2
  if [ $VIASH_VERBOSITY -ge $required_level ]; then
    >&2 echo "[$display_tag]" "$@"
  fi
}

# ViashEmergency: log events when the system is unstable
# usage: ViashEmergency Oh no something went wrong.
# stdout: Your input, prepended by '[emergency] '.
function ViashEmergency {
  ViashLog $VIASH_LOGCODE_EMERGENCY emergency "$@"
}

# ViashAlert: log events when actions must be taken immediately (e.g. corrupted system database)
# usage: ViashAlert Oh no something went wrong.
# stdout: Your input, prepended by '[alert] '.
function ViashAlert {
  ViashLog $VIASH_LOGCODE_ALERT alert "$@"
}

# ViashCritical: log events when a critical condition occurs
# usage: ViashCritical Oh no something went wrong.
# stdout: Your input, prepended by '[critical] '.
function ViashCritical {
  ViashLog $VIASH_LOGCODE_CRITICAL critical "$@"
}

# ViashError: log events when an error condition occurs
# usage: ViashError Oh no something went wrong.
# stdout: Your input, prepended by '[error] '.
function ViashError {
  ViashLog $VIASH_LOGCODE_ERROR error "$@"
}

# ViashWarning: log potentially abnormal events
# usage: ViashWarning Something may have gone wrong.
# stdout: Your input, prepended by '[warning] '.
function ViashWarning {
  ViashLog $VIASH_LOGCODE_WARNING warning "$@"
}

# ViashNotice: log significant but normal events
# usage: ViashNotice This just happened.
# stdout: Your input, prepended by '[notice] '.
function ViashNotice {
  ViashLog $VIASH_LOGCODE_NOTICE notice "$@"
}

# ViashInfo: log normal events
# usage: ViashInfo This just happened.
# stdout: Your input, prepended by '[info] '.
function ViashInfo {
  ViashLog $VIASH_LOGCODE_INFO info "$@"
}

# ViashDebug: log all events, for debugging purposes
# usage: ViashDebug This just happened.
# stdout: Your input, prepended by '[debug] '.
function ViashDebug {
  ViashLog $VIASH_LOGCODE_DEBUG debug "$@"
}

# find source folder of this component
VIASH_META_RESOURCES_DIR=`ViashSourceDir ${BASH_SOURCE[0]}`

# find the root of the built components & dependencies
VIASH_TARGET_DIR=`ViashFindTargetDir $VIASH_META_RESOURCES_DIR`

# define meta fields
VIASH_META_NAME="bd_rhapsody"
VIASH_META_FUNCTIONALITY_NAME="bd_rhapsody"
VIASH_META_EXECUTABLE="$VIASH_META_RESOURCES_DIR/$VIASH_META_NAME"
VIASH_META_CONFIG="$VIASH_META_RESOURCES_DIR/.config.vsh.yaml"
VIASH_META_TEMP_DIR="$VIASH_TEMP"



# initialise variables
VIASH_MODE='run'
VIASH_ENGINE_ID='docker'

######## Helper functions for setting up Docker images for viash ########
# expects: ViashDockerBuild

# ViashDockerInstallationCheck: check whether Docker is installed correctly
#
# examples:
#   ViashDockerInstallationCheck
function ViashDockerInstallationCheck {
  ViashDebug "Checking whether Docker is installed"
  if [ ! command -v docker &> /dev/null ]; then
    ViashCritical "Docker doesn't seem to be installed. See 'https://docs.docker.com/get-docker/' for instructions."
    exit 1
  fi

  ViashDebug "Checking whether the Docker daemon is running"
  local save=$-; set +e
  local docker_version=$(docker version --format '{{.Client.APIVersion}}' 2> /dev/null)
  local out=$?
  [[ $save =~ e ]] && set -e
  if [ $out -ne 0 ]; then
    ViashCritical "Docker daemon does not seem to be running. Try one of the following:"
    ViashCritical "- Try running 'dockerd' in the command line"
    ViashCritical "- See https://docs.docker.com/config/daemon/"
    exit 1
  fi
}

# ViashDockerRemoteTagCheck: check whether a Docker image is available 
# on a remote. Assumes `docker login` has been performed, if relevant.
#
# $1                  : image identifier with format `[registry/]image[:tag]`
# exit code $?        : whether or not the image was found
# examples:
#   ViashDockerRemoteTagCheck python:latest
#   echo $?                                     # returns '0'
#   ViashDockerRemoteTagCheck sdaizudceahifu
#   echo $?                                     # returns '1'
function ViashDockerRemoteTagCheck {
  docker manifest inspect $1 > /dev/null 2> /dev/null
}

# ViashDockerLocalTagCheck: check whether a Docker image is available locally
#
# $1                  : image identifier with format `[registry/]image[:tag]`
# exit code $?        : whether or not the image was found
# examples:
#   docker pull python:latest
#   ViashDockerLocalTagCheck python:latest
#   echo $?                                     # returns '0'
#   ViashDockerLocalTagCheck sdaizudceahifu
#   echo $?                                     # returns '1'
function ViashDockerLocalTagCheck {
  [ -n "$(docker images -q $1)" ]
}

# ViashDockerPull: pull a Docker image
#
# $1                  : image identifier with format `[registry/]image[:tag]`
# exit code $?        : whether or not the image was found
# examples:
#   ViashDockerPull python:latest
#   echo $?                                     # returns '0'
#   ViashDockerPull sdaizudceahifu
#   echo $?                                     # returns '1'
function ViashDockerPull {
  ViashNotice "Checking if Docker image is available at '$1'"
  if [ $VIASH_VERBOSITY -ge $VIASH_LOGCODE_INFO ]; then
    docker pull $1 && return 0 || return 1
  else
    local save=$-; set +e
    docker pull $1 2> /dev/null > /dev/null
    local out=$?
    [[ $save =~ e ]] && set -e
    if [ $out -ne 0 ]; then
      ViashWarning "Could not pull from '$1'. Docker image doesn't exist or is not accessible."
    fi
    return $out
  fi
}

# ViashDockerPush: push a Docker image
#
# $1                  : image identifier with format `[registry/]image[:tag]`
# exit code $?        : whether or not the image was found
# examples:
#   ViashDockerPush python:latest
#   echo $?                                     # returns '0'
#   ViashDockerPush sdaizudceahifu
#   echo $?                                     # returns '1'
function ViashDockerPush {
  ViashNotice "Pushing image to '$1'"
  local save=$-; set +e
  local out
  if [ $VIASH_VERBOSITY -ge $VIASH_LOGCODE_INFO ]; then
    docker push $1
    out=$?
  else
    docker push $1 2> /dev/null > /dev/null
    out=$?
  fi
  [[ $save =~ e ]] && set -e
  if [ $out -eq 0 ]; then
    ViashNotice "Container '$1' push succeeded."
  else
    ViashError "Container '$1' push errored. You might not be logged in or have the necessary permissions."
  fi
  return $out
}

# ViashDockerPullElseBuild: pull a Docker image, else build it
#
# $1                  : image identifier with format `[registry/]image[:tag]`
# ViashDockerBuild    : a Bash function which builds a docker image, takes image identifier as argument.
# examples:
#   ViashDockerPullElseBuild mynewcomponent
function ViashDockerPullElseBuild {
  local save=$-; set +e
  ViashDockerPull $1
  local out=$?
  [[ $save =~ e ]] && set -e
  if [ $out -ne 0 ]; then
    ViashDockerBuild $@
  fi
}

# ViashDockerSetup: create a Docker image, according to specified docker setup strategy
#
# $1          : image identifier with format `[registry/]image[:tag]`
# $2          : docker setup strategy, see DockerSetupStrategy.scala
# examples:
#   ViashDockerSetup mynewcomponent alwaysbuild
function ViashDockerSetup {
  local image_id="$1"
  local setup_strategy="$2"
  if [ "$setup_strategy" == "alwaysbuild" -o "$setup_strategy" == "build" -o "$setup_strategy" == "b" ]; then
    ViashDockerBuild $image_id --no-cache $(ViashDockerBuildArgs "$engine_id")
  elif [ "$setup_strategy" == "alwayspull" -o "$setup_strategy" == "pull" -o "$setup_strategy" == "p" ]; then
    ViashDockerPull $image_id
  elif [ "$setup_strategy" == "alwayspullelsebuild" -o "$setup_strategy" == "pullelsebuild" ]; then
    ViashDockerPullElseBuild $image_id --no-cache $(ViashDockerBuildArgs "$engine_id")
  elif [ "$setup_strategy" == "alwayspullelsecachedbuild" -o "$setup_strategy" == "pullelsecachedbuild" ]; then
    ViashDockerPullElseBuild $image_id $(ViashDockerBuildArgs "$engine_id")
  elif [ "$setup_strategy" == "alwayscachedbuild" -o "$setup_strategy" == "cachedbuild" -o "$setup_strategy" == "cb" ]; then
    ViashDockerBuild $image_id $(ViashDockerBuildArgs "$engine_id")
  elif [[ "$setup_strategy" =~ ^ifneedbe ]]; then
    local save=$-; set +e
    ViashDockerLocalTagCheck $image_id
    local outCheck=$?
    [[ $save =~ e ]] && set -e
    if [ $outCheck -eq 0 ]; then
      ViashInfo "Image $image_id already exists"
    elif [ "$setup_strategy" == "ifneedbebuild" ]; then
      ViashDockerBuild $image_id --no-cache $(ViashDockerBuildArgs "$engine_id")
    elif [ "$setup_strategy" == "ifneedbecachedbuild" ]; then
      ViashDockerBuild $image_id $(ViashDockerBuildArgs "$engine_id")
    elif [ "$setup_strategy" == "ifneedbepull" ]; then
      ViashDockerPull $image_id
    elif [ "$setup_strategy" == "ifneedbepullelsebuild" ]; then
      ViashDockerPullElseBuild $image_id --no-cache $(ViashDockerBuildArgs "$engine_id")
    elif [ "$setup_strategy" == "ifneedbepullelsecachedbuild" ]; then
      ViashDockerPullElseBuild $image_id $(ViashDockerBuildArgs "$engine_id")
    else
      ViashError "Unrecognised Docker strategy: $setup_strategy"
      exit 1
    fi
  elif [ "$setup_strategy" == "push" -o "$setup_strategy" == "forcepush" -o "$setup_strategy" == "alwayspush" ]; then
    ViashDockerPush "$image_id"
  elif [ "$setup_strategy" == "pushifnotpresent" -o "$setup_strategy" == "gentlepush" -o "$setup_strategy" == "maybepush" ]; then
    local save=$-; set +e
    ViashDockerRemoteTagCheck $image_id
    local outCheck=$?
    [[ $save =~ e ]] && set -e
    if [ $outCheck -eq 0 ]; then
      ViashNotice "Container '$image_id' exists, doing nothing."
    else
      ViashNotice "Container '$image_id' does not yet exist."
      ViashDockerPush "$image_id"
    fi
  elif [ "$setup_strategy" == "donothing" -o "$setup_strategy" == "meh" ]; then
    ViashNotice "Skipping setup."
  else
    ViashError "Unrecognised Docker strategy: $setup_strategy"
    exit 1
  fi
}

# ViashDockerCheckCommands: Check whether a docker container has the required commands
#
# $1                  : image identifier with format `[registry/]image[:tag]`
# $@                  : commands to verify being present
# examples:
#   ViashDockerCheckCommands bash:4.0 bash ps foo
function ViashDockerCheckCommands {
  local image_id="$1"
  shift 1
  local commands="$@"
  local save=$-; set +e
  local missing # mark 'missing' as local in advance, otherwise the exit code of the command will be missing and always be '0'
  missing=$(docker run --rm --entrypoint=sh "$image_id" -c "for command in $commands; do command -v \$command >/dev/null 2>&1; if [ \$? -ne 0 ]; then echo \$command; exit 1; fi; done")
  local outCheck=$?
  [[ $save =~ e ]] && set -e
  if [ $outCheck -ne 0 ]; then
  	ViashError "Docker container '$image_id' does not contain command '$missing'."
  	exit 1
  fi
}

# ViashDockerBuild: build a docker image
# $1                               : image identifier with format `[registry/]image[:tag]`
# $...                             : additional arguments to pass to docker build
# $VIASH_META_TEMP_DIR             : temporary directory to store dockerfile & optional resources in
# $VIASH_META_NAME                 : name of the component
# $VIASH_META_RESOURCES_DIR        : directory containing the resources
# $VIASH_VERBOSITY                 : verbosity level
# exit code $?                     : whether or not the image was built successfully
function ViashDockerBuild {
  local image_id="$1"
  shift 1

  # create temporary directory to store dockerfile & optional resources in
  local tmpdir=$(mktemp -d "$VIASH_META_TEMP_DIR/dockerbuild-$VIASH_META_NAME-XXXXXX")
  local dockerfile="$tmpdir/Dockerfile"
  function clean_up {
    rm -rf "$tmpdir"
  }
  trap clean_up EXIT

  # store dockerfile and resources
  ViashDockerfile "$VIASH_ENGINE_ID" > "$dockerfile"

  # generate the build command
  local docker_build_cmd="docker build -t '$image_id' $@ '$VIASH_META_RESOURCES_DIR' -f '$dockerfile'"

  # build the container
  ViashNotice "Building container '$image_id' with Dockerfile"
  ViashInfo "$docker_build_cmd"
  local save=$-; set +e
  if [ $VIASH_VERBOSITY -ge $VIASH_LOGCODE_INFO ]; then
    eval $docker_build_cmd
  else
    eval $docker_build_cmd &> "$tmpdir/docker_build.log"
  fi

  # check exit code
  local out=$?
  [[ $save =~ e ]] && set -e
  if [ $out -ne 0 ]; then
    ViashError "Error occurred while building container '$image_id'"
    if [ $VIASH_VERBOSITY -lt $VIASH_LOGCODE_INFO ]; then
      ViashError "Transcript: --------------------------------"
      cat "$tmpdir/docker_build.log"
      ViashError "End of transcript --------------------------"
    fi
    exit 1
  fi
}

######## End of helper functions for setting up Docker images for viash ########

# ViashDockerFile: print the dockerfile to stdout
# $1    : engine identifier
# return : dockerfile required to run this component
# examples:
#   ViashDockerFile
function ViashDockerfile {
  local engine_id="$1"

  if [[ "$engine_id" == "docker" ]]; then
    cat << 'VIASHDOCKER'
FROM bdgenomics/rhapsody:2.2.1
ENTRYPOINT []
RUN apt-get update && \
  DEBIAN_FRONTEND=noninteractive apt-get install -y procps && \
  rm -rf /var/lib/apt/lists/*

RUN pip install --upgrade pip && \
  pip install --upgrade --no-cache-dir "cwlref-runner" "cwl-runner" "ruamel.yaml" "biopython" "gffutils"

LABEL org.opencontainers.image.authors="Robrecht Cannoodt, Weiwei Schultz"
LABEL org.opencontainers.image.description="Companion container for running component mapping bd_rhapsody"
LABEL org.opencontainers.image.created="2026-06-09T16:27:53Z"
LABEL org.opencontainers.image.source="https://github.com/openpipelines-bio/openpipeline"
LABEL org.opencontainers.image.revision="38f5f83d11f837ab6c211a98f36979405dd99e58"
LABEL org.opencontainers.image.version="processing-workflows-quantile-filtering"

VIASHDOCKER
  fi
}

# ViashDockerBuildArgs: return the arguments to pass to docker build
# $1    : engine identifier
# return : arguments to pass to docker build
function ViashDockerBuildArgs {
  local engine_id="$1"

  if [[ "$engine_id" == "docker" ]]; then
    echo ""
  fi
}

# ViashAbsolutePath: generate absolute path from relative path
# borrowed from https://stackoverflow.com/a/21951256
# $1     : relative filename
# return : absolute path
# examples:
#   ViashAbsolutePath some_file.txt   # returns /path/to/some_file.txt
#   ViashAbsolutePath /foo/bar/..     # returns /foo
function ViashAbsolutePath {
  local thePath
  local parr
  local outp
  local len
  if [[ ! "$1" =~ ^/ ]]; then
    thePath="$PWD/$1"
  else
    thePath="$1"
  fi
  echo "$thePath" | (
    IFS=/
    read -a parr
    declare -a outp
    for i in "${parr[@]}"; do
      case "$i" in
      ''|.) continue ;;
      ..)
        len=${#outp[@]}
        if ((len==0)); then
          continue
        else
          unset outp[$((len-1))]
        fi
        ;;
      *)
        len=${#outp[@]}
        outp[$len]="$i"
      ;;
      esac
    done
    echo /"${outp[*]}"
  )
}
# ViashDockerAutodetectMount: auto configuring docker mounts from parameters
# $1                             : The parameter value
# returns                        : New parameter
# $VIASH_DIRECTORY_MOUNTS        : Added another parameter to be passed to docker
# $VIASH_DOCKER_AUTOMOUNT_PREFIX : The prefix to be used for the automounts
# examples:
#   ViashDockerAutodetectMount /path/to/bar      # returns '/viash_automount/path/to/bar'
#   ViashDockerAutodetectMountArg /path/to/bar   # returns '--volume="/path/to:/viash_automount/path/to"'
function ViashDockerAutodetectMount {
  local abs_path=$(ViashAbsolutePath "$1")
  local mount_source
  local base_name
  if [ -d "$abs_path" ]; then
    mount_source="$abs_path"
    base_name=""
  else
    mount_source=`dirname "$abs_path"`
    base_name=`basename "$abs_path"`
  fi
  local mount_target="$VIASH_DOCKER_AUTOMOUNT_PREFIX$mount_source"
  if [ -z "$base_name" ]; then
    echo "$mount_target"
  else
    echo "$mount_target/$base_name"
  fi
}
function ViashDockerAutodetectMountArg {
  local abs_path=$(ViashAbsolutePath "$1")
  local mount_source
  local base_name
  if [ -d "$abs_path" ]; then
    mount_source="$abs_path"
    base_name=""
  else
    mount_source=`dirname "$abs_path"`
    base_name=`basename "$abs_path"`
  fi
  local mount_target="$VIASH_DOCKER_AUTOMOUNT_PREFIX$mount_source"
  ViashDebug "ViashDockerAutodetectMountArg $1 -> $mount_source -> $mount_target"
  echo "--volume=\"$mount_source:$mount_target\""
}
function ViashDockerStripAutomount {
  local abs_path=$(ViashAbsolutePath "$1")
  echo "${abs_path#$VIASH_DOCKER_AUTOMOUNT_PREFIX}"
}
# initialise variables
VIASH_DIRECTORY_MOUNTS=()

# configure default docker automount prefix if it is unset
if [ -z "${VIASH_DOCKER_AUTOMOUNT_PREFIX+x}" ]; then
  VIASH_DOCKER_AUTOMOUNT_PREFIX="/viash_automount"
fi

# initialise docker variables
VIASH_DOCKER_RUN_ARGS=(-i --rm)


# ViashHelp: Display helpful explanation about this executable
function ViashHelp {
  echo "bd_rhapsody processing-workflows-quantile-filtering"
  echo ""
  echo "BD Rhapsody Sequence Analysis CWL pipeline v2.2.1"
  echo "This pipeline performs analysis of single-cell multiomic sequence read (FASTQ)"
  echo "data. The supported"
  echo "sequencing libraries are those generated by the BD Rhapsody assay kits,"
  echo "including: Whole Transcriptome"
  echo "mRNA, Targeted mRNA, AbSeq Antibody-Oligonucleotides, Single-Cell Multiplexing,"
  echo "TCR/BCR, and"
  echo "ATAC-Seq"
  echo ""
  echo "The CWL pipeline file is obtained by cloning 'https://bitbucket.org/CRSwDev/cwl'"
  echo "and removing all objects with class 'DockerRequirement' from the YAML."
  echo ""
  echo "Inputs:"
  echo "    --reads"
  echo "        type: file, multiple values allowed, file must exist"
  echo "        example:"
  echo "WTALibrary_S1_L001_R1_001.fastq.gz;WTALibrary_S1_L001_R2_001.fastq.gz"
  echo "        Reads (optional) - Path to your FASTQ.GZ formatted read files from"
  echo "        libraries that may include:"
  echo "        - WTA mRNA"
  echo "        - Targeted mRNA"
  echo "        - AbSeq"
  echo "        - Sample Multiplexing"
  echo "        - VDJ"
  echo "        You may specify as many R1/R2 read pairs as you want."
  echo ""
  echo "    --reads_atac"
  echo "        type: file, multiple values allowed, file must exist"
  echo "        example:"
  echo "ATACLibrary_S2_L001_R1_001.fastq.gz;ATACLibrary_S2_L001_R2_001.fastq.gz;ATACLibrary_S2_L001_I2_001.fastq.gz"
  echo "        Path to your FASTQ.GZ formatted read files from ATAC-Seq libraries."
  echo "        You may specify as many R1/R2/I2 files as you want."
  echo ""
  echo "References:"
  echo "    Assay type will be inferred from the provided reference(s)."
  echo "    Do not provide both reference_archive and targeted_reference at the same"
  echo "    time."
  echo "    Valid reference input combinations:"
  echo "      - reference_archive: WTA only"
  echo "      - reference_archive & abseq_reference: WTA + AbSeq"
  echo "      - reference_archive & supplemental_reference: WTA + extra transgenes"
  echo "      - reference_archive & abseq_reference & supplemental_reference: WTA +"
  echo "    AbSeq + extra transgenes"
  echo "      - reference_archive: WTA + ATAC or ATAC only"
  echo "      - reference_archive & supplemental_reference: WTA + ATAC + extra"
  echo "    transgenes"
  echo "      - targeted_reference: Targeted only"
  echo "      - targeted_reference & abseq_reference: Targeted + AbSeq"
  echo "      - abseq_reference: AbSeq only"
  echo "    The reference_archive can be generated with the bd_rhapsody_make_reference"
  echo "    component."
  echo "    Alternatively, BD also provides standard references which can be downloaded"
  echo "    from these locations:"
  echo "      - Human:"
  echo "   "
  echo "https://bd-rhapsody-public.s3.amazonaws.com/Rhapsody-WTA/Pipeline-version2.x_WTA_references/RhapRef_Human_WTA_2023-02.tar.gz"
  echo "      - Mouse:"
  echo "   "
  echo "https://bd-rhapsody-public.s3.amazonaws.com/Rhapsody-WTA/Pipeline-version2.x_WTA_references/RhapRef_Mouse_WTA_2023-02.tar.gz"
  echo ""
  echo "    --reference_archive"
  echo "        type: file, file must exist"
  echo "        example: RhapRef_Human_WTA_2023-02.tar.gz"
  echo "        Path to Rhapsody WTA Reference in the tar.gz format."
  echo "        Structure of the reference archive:"
  echo "        - \`BD_Rhapsody_Reference_Files/\`: top level folder"
  echo "          - \`star_index/\`: sub-folder containing STAR index, that is files"
  echo "        created with \`STAR --runMode genomeGenerate\`"
  echo "          - GTF for gene-transcript-annotation e.g."
  echo "        \"gencode.v43.primary_assembly.annotation.gtf\""
  echo ""
  echo "    --targeted_reference"
  echo "        type: file, multiple values allowed, file must exist"
  echo "        example: BD_Rhapsody_Immune_Response_Panel_Hs.fasta"
  echo "        Path to the targeted reference file in FASTA format."
  echo ""
  echo "    --abseq_reference"
  echo "        type: file, multiple values allowed, file must exist"
  echo "        example: AbSeq_reference.fasta"
  echo "        Path to the AbSeq reference file in FASTA format.  Only needed if BD"
  echo "        AbSeq Ab-Oligos are used."
  echo ""
  echo "    -s, --supplemental_reference"
  echo "        type: file, multiple values allowed, file must exist"
  echo "        example: supplemental_reference.fasta"
  echo "        Path to the supplemental reference file in FASTA format.  Only needed if"
  echo "        there are additional transgene sequences to be aligned against in a WTA"
  echo "        assay experiment."
  echo ""
  echo "Outputs:"
  echo "    Outputs for all pipeline runs"
  echo ""
  echo "    -o, --output_dir"
  echo "        type: file, required parameter, output, file must exist"
  echo "        example: output_dir"
  echo "        The unprocessed output directory containing all the outputs from the"
  echo "        pipeline."
  echo ""
  echo "    --output_seurat"
  echo "        type: file, output, file must exist"
  echo "        example: output_seurat.rds"
  echo "        Single-cell analysis tool inputs. Seurat (.rds) input file containing"
  echo "        RSEC molecules data table and all cell annotation metadata."
  echo ""
  echo "    --output_mudata"
  echo "        type: file, output, file must exist"
  echo "        example: output_mudata.h5mu"
  echo ""
  echo "    --metrics_summary"
  echo "        type: file, output, file must exist"
  echo "        example: metrics_summary.csv"
  echo "        Metrics Summary. Report containing sequencing, molecules, and cell"
  echo "        metrics."
  echo ""
  echo "    --pipeline_report"
  echo "        type: file, output, file must exist"
  echo "        example: pipeline_report.html"
  echo "        Pipeline Report. Summary report containing the results from the"
  echo "        sequencing analysis pipeline run."
  echo ""
  echo "    --rsec_mols_per_cell"
  echo "        type: file, output, file must exist"
  echo "        example: RSEC_MolsPerCell_MEX.zip"
  echo "        Molecules per bioproduct per cell bassed on RSEC"
  echo ""
  echo "    --dbec_mols_per_cell"
  echo "        type: file, output, file must exist"
  echo "        example: DBEC_MolsPerCell_MEX.zip"
  echo "        Molecules per bioproduct per cell bassed on DBEC. DBEC data table is"
  echo "        only output if the experiment includes targeted mRNA or AbSeq"
  echo "        bioproducts."
  echo ""
  echo "    --rsec_mols_per_cell_unfiltered"
  echo "        type: file, output, file must exist"
  echo "        example: RSEC_MolsPerCell_Unfiltered_MEX.zip"
  echo "        Unfiltered tables containing all cell labels with 10 reads."
  echo ""
  echo "    --bam"
  echo "        type: file, output, file must exist"
  echo "        example: BioProduct.bam"
  echo "        Alignment file of R2 with associated R1 annotations for Bioproduct."
  echo ""
  echo "    --bam_index"
  echo "        type: file, output, file must exist"
  echo "        example: BioProduct.bam.bai"
  echo "        Index file for the alignment file."
  echo ""
  echo "    --bioproduct_stats"
  echo "        type: file, output, file must exist"
  echo "        example: Bioproduct_Stats.csv"
  echo "        Bioproduct Stats. Metrics from RSEC and DBEC Unique Molecular Identifier"
  echo "        adjustment algorithms on a per-bioproduct basis."
  echo ""
  echo "    --dimred_tsne"
  echo "        type: file, output, file must exist"
  echo "        example: tSNE_coordinates.csv"
  echo "        t-SNE dimensionality reduction coordinates per cell index"
  echo ""
  echo "    --dimred_umap"
  echo "        type: file, output, file must exist"
  echo "        example: UMAP_coordinates.csv"
  echo "        UMAP dimensionality reduction coordinates per cell index"
  echo ""
  echo "    --immune_cell_classification"
  echo "        type: file, output, file must exist"
  echo "        example: Immune_Cell_Classification.csv"
  echo "        Immune Cell Classification. Cell type classification based on the"
  echo "        expression of immune cell markers."
  echo ""
  echo "Multiplex outputs:"
  echo "    Outputs when multiplex option is selected"
  echo ""
  echo "    --sample_tag_metrics"
  echo "        type: file, output, file must exist"
  echo "        example: Sample_Tag_Metrics.csv"
  echo "        Sample Tag Metrics. Metrics from the sample determination algorithm."
  echo ""
  echo "    --sample_tag_calls"
  echo "        type: file, output, file must exist"
  echo "        example: Sample_Tag_Calls.csv"
  echo "        Sample Tag Calls. Assigned Sample Tag for each putative cell"
  echo ""
  echo "    --sample_tag_counts"
  echo "        type: file, multiple values allowed, output, file must exist"
  echo "        example: Sample_Tag1.zip"
  echo "        Sample Tag Counts. Separate data tables and metric summary for cells"
  echo "        assigned to each sample tag. Note: For putative cells that could not be"
  echo "        assigned a specific Sample Tag, a Multiplet_and_Undetermined.zip file is"
  echo "        also output."
  echo ""
  echo "    --sample_tag_counts_unassigned"
  echo "        type: file, output, file must exist"
  echo "        example: Multiplet_and_Undetermined.zip"
  echo "        Sample Tag Counts Unassigned. Data table and metric summary for cells"
  echo "        that could not be assigned a specific Sample Tag."
  echo ""
  echo "VDJ Outputs:"
  echo "    Outputs when VDJ option selected"
  echo ""
  echo "    --vdj_metrics"
  echo "        type: file, output, file must exist"
  echo "        example: VDJ_Metrics.csv"
  echo "        VDJ Metrics. Overall metrics from the VDJ analysis."
  echo ""
  echo "    --vdj_per_cell"
  echo "        type: file, output, file must exist"
  echo "        example: VDJ_perCell.csv"
  echo "        VDJ Per Cell. Cell specific read and molecule counts, VDJ gene segments,"
  echo "        CDR3 sequences, paired chains, and cell type."
  echo ""
  echo "    --vdj_per_cell_uncorrected"
  echo "        type: file, output, file must exist"
  echo "        example: VDJ_perCell_uncorrected.csv"
  echo "        VDJ Per Cell Uncorrected. Cell specific read and molecule counts, VDJ"
  echo "        gene segments, CDR3 sequences, paired chains, and cell type."
  echo ""
  echo "    --vdj_dominant_contigs"
  echo "        type: file, output, file must exist"
  echo "        example: VDJ_Dominant_Contigs_AIRR.csv"
  echo "        VDJ Dominant Contigs. Dominant contig for each cell label chain type"
  echo "        combination (putative cells only)."
  echo ""
  echo "    --vdj_unfiltered_contigs"
  echo "        type: file, output, file must exist"
  echo "        example: VDJ_Unfiltered_Contigs_AIRR.csv"
  echo "        VDJ Unfiltered Contigs. All contigs that were assembled and annotated"
  echo "        successfully (all cells)."
  echo ""
  echo "ATAC-Seq outputs:"
  echo "    Outputs when ATAC-Seq option selected"
  echo ""
  echo "    --atac_metrics"
  echo "        type: file, output, file must exist"
  echo "        example: ATAC_Metrics.csv"
  echo "        ATAC Metrics. Overall metrics from the ATAC-Seq analysis."
  echo ""
  echo "    --atac_metrics_json"
  echo "        type: file, output, file must exist"
  echo "        example: ATAC_Metrics.json"
  echo "        ATAC Metrics JSON. Overall metrics from the ATAC-Seq analysis in JSON"
  echo "        format."
  echo ""
  echo "    --atac_fragments"
  echo "        type: file, output, file must exist"
  echo "        example: ATAC_Fragments.bed.gz"
  echo "        ATAC Fragments. Chromosomal location, cell index, and read support for"
  echo "        each fragment detected"
  echo ""
  echo "    --atac_fragments_index"
  echo "        type: file, output, file must exist"
  echo "        example: ATAC_Fragments.bed.gz.tbi"
  echo "        Index of ATAC Fragments."
  echo ""
  echo "    --atac_transposase_sites"
  echo "        type: file, output, file must exist"
  echo "        example: ATAC_Transposase_Sites.bed.gz"
  echo "        ATAC Transposase Sites. Chromosomal location, cell index, and read"
  echo "        support for each transposase site detected"
  echo ""
  echo "    --atac_transposase_sites_index"
  echo "        type: file, output, file must exist"
  echo "        example: ATAC_Transposase_Sites.bed.gz.tbi"
  echo "        Index of ATAC Transposase Sites."
  echo ""
  echo "    --atac_peaks"
  echo "        type: file, output, file must exist"
  echo "        example: ATAC_Peaks.bed.gz"
  echo "        ATAC Peaks. Peak regions of transposase activity"
  echo ""
  echo "    --atac_peaks_index"
  echo "        type: file, output, file must exist"
  echo "        example: ATAC_Peaks.bed.gz.tbi"
  echo "        Index of ATAC Peaks."
  echo ""
  echo "    --atac_peak_annotation"
  echo "        type: file, output, file must exist"
  echo "        example: peak_annotation.tsv.gz"
  echo "        ATAC Peak Annotation. Estimated annotation of peak-to-gene connections"
  echo ""
  echo "    --atac_cell_by_peak"
  echo "        type: file, output, file must exist"
  echo "        example: ATAC_Cell_by_Peak_MEX.zip"
  echo "        ATAC Cell by Peak. Peak regions of transposase activity per cell"
  echo ""
  echo "    --atac_cell_by_peak_unfiltered"
  echo "        type: file, output, file must exist"
  echo "        example: ATAC_Cell_by_Peak_Unfiltered_MEX.zip"
  echo "        ATAC Cell by Peak Unfiltered. Unfiltered file containing all cell labels"
  echo "        with >=1 transposase sites in peaks."
  echo ""
  echo "    --atac_bam"
  echo "        type: file, output, file must exist"
  echo "        example: ATAC.bam"
  echo "        ATAC BAM. Alignment file for R1 and R2 with associated I2 annotations"
  echo "        for ATAC-Seq. Only output if the BAM generation flag is set to true."
  echo ""
  echo "    --atac_bam_index"
  echo "        type: file, output, file must exist"
  echo "        example: ATAC.bam.bai"
  echo "        Index of ATAC BAM."
  echo ""
  echo "AbSeq Cell Calling outputs:"
  echo "    Outputs when Cell Calling Abseq is selected"
  echo ""
  echo "    --protein_aggregates_experimental"
  echo "        type: file, output, file must exist"
  echo "        example: Protein_Aggregates_Experimental.csv"
  echo "        Protein Aggregates Experimental"
  echo ""
  echo "Putative Cell Calling Settings:"
  echo "    --cell_calling_data"
  echo "        type: string"
  echo "        example: mRNA"
  echo "        choices: [ mRNA, AbSeq, ATAC, mRNA_and_ATAC ]"
  echo "        Specify the dataset to be used for putative cell calling: mRNA, AbSeq,"
  echo "        ATAC, mRNA_and_ATAC"
  echo "        For putative cell calling using an AbSeq dataset, please provide an"
  echo "        AbSeq_Reference fasta file above."
  echo "        For putative cell calling using an ATAC dataset, please provide a"
  echo "        WTA+ATAC-Seq Reference_Archive file above."
  echo "        The default data for putative cell calling, will be determined the"
  echo "        following way:"
  echo "        - If mRNA Reads and ATAC Reads exist: mRNA_and_ATAC"
  echo "        - If only ATAC Reads exist: ATAC"
  echo "        - Otherwise: mRNA"
  echo ""
  echo "    --cell_calling_bioproduct_algorithm"
  echo "        type: string"
  echo "        example: Basic"
  echo "        choices: [ Basic, Refined ]"
  echo "        Specify the bioproduct algorithm to be used for putative cell calling:"
  echo "        Basic or Refined"
  echo "        By default, the Basic algorithm will be used for putative cell calling."
  echo ""
  echo "    --cell_calling_atac_algorithm"
  echo "        type: string"
  echo "        example: Basic"
  echo "        choices: [ Basic, Refined ]"
  echo "        Specify the ATAC-seq algorithm to be used for putative cell calling:"
  echo "        Basic or Refined"
  echo "        By default, the Basic algorithm will be used for putative cell calling."
  echo ""
  echo "    --exact_cell_count"
  echo "        type: integer"
  echo "        example: 10000"
  echo "        min: 1"
  echo "        Set a specific number of cells as putative, based on those with the"
  echo "        highest error-corrected read count"
  echo ""
  echo "    --expected_cell_count"
  echo "        type: integer"
  echo "        example: 20000"
  echo "        min: 1"
  echo "        Guide the basic putative cell calling algorithm by providing an estimate"
  echo "        of the number of cells expected.  Usually this can be the number of"
  echo "        cells loaded into the Rhapsody cartridge.  If there are multiple"
  echo "        inflection points on the second derivative cumulative curve, this will"
  echo "        ensure the one selected is near the expected."
  echo ""
  echo "Intronic Reads Settings:"
  echo "    --exclude_intronic_reads"
  echo "        type: boolean"
  echo "        example: false"
  echo "        By default, the flag is false, and reads aligned to exons and introns"
  echo "        are considered and represented in molecule counts. When the flag is set"
  echo "        to true, intronic reads will be excluded."
  echo "        The value can be true or false."
  echo ""
  echo "Multiplex Settings:"
  echo "    --sample_tags_version"
  echo "        type: string"
  echo "        example: human"
  echo "        choices: [ human, mouse, flex, nuclei_includes_mrna, nuclei_atac_only ]"
  echo "        Specify the version of the Sample Tags used in the run:"
  echo "        * If Sample Tag Multiplexing was done, specify the appropriate version:"
  echo "        human, mouse, flex, nuclei_includes_mrna, nuclei_atac_only"
  echo "        * If this is an SMK + Nuclei mRNA run or an SMK + Multiomic ATAC-Seq"
  echo "        (WTA+ATAC-Seq) run (and not an SMK + ATAC-Seq only run), choose the"
  echo "        \"nuclei_includes_mrna\" option."
  echo "        * If this is an SMK + ATAC-Seq only run (and not SMK + Multiomic"
  echo "        ATAC-Seq (WTA+ATAC-Seq)), choose the \"nuclei_atac_only\" option."
  echo ""
  echo "    --tag_names"
  echo "        type: string, multiple values allowed"
  echo "        example: 4-mySample;9-myOtherSample;6-alsoThisSample"
  echo "        Specify the tag number followed by '-' and the desired sample name to"
  echo "        appear in Sample_Tag_Metrics.csv"
  echo "        Do not use the special characters."
  echo ""
  echo "VDJ arguments:"
  echo "    --vdj_version"
  echo "        type: string"
  echo "        example: human"
  echo "        choices: [ human, mouse, humanBCR, humanTCR, mouseBCR, mouseTCR ]"
  echo "        If VDJ was done, specify the appropriate option: human, mouse, humanBCR,"
  echo "        humanTCR, mouseBCR, mouseTCR"
  echo ""
  echo "ATAC options:"
  echo "    --predefined_atac_peaks"
  echo "        type: file, file must exist"
  echo "        example: predefined_peaks.bed"
  echo "        An optional BED file containing pre-established chromatin accessibility"
  echo "        peak regions for generating the ATAC cell-by-peak matrix."
  echo ""
  echo "Additional options:"
  echo "    --run_name"
  echo "        type: string"
  echo "        default: sample"
  echo "        Specify a run name to use as the output file base name. Use only"
  echo "        letters, numbers, or hyphens. Do not use special characters or spaces."
  echo ""
  echo "    --generate_bam"
  echo "        type: boolean"
  echo "        default: false"
  echo "        Specify whether to create the BAM file output"
  echo ""
  echo "    --long_reads"
  echo "        type: boolean"
  echo "        Use STARlong (default: undefined - i.e. autodetects based on read"
  echo "        lengths) - Specify if the STARlong aligner should be used instead of"
  echo "        STAR. Set to true if the reads are longer than 650bp."
  echo ""
  echo "Advanced options:"
  echo "    NOTE: Only change these if you are really sure about what you are doing"
  echo ""
  echo "    --custom_star_params"
  echo "        type: string"
  echo "        example: --alignIntronMax 6000 --outFilterScoreMinOverLread 0.1"
  echo "--limitOutSJcollapsed 2000000"
  echo "        Modify STAR alignment parameters - Set this parameter to fully override"
  echo "        default STAR mapping parameters used in the pipeline."
  echo "        For reference this is the default that is used:"
  echo "          Short Reads: \`--outFilterScoreMinOverLread 0"
  echo "        --outFilterMatchNminOverLread 0 --outFilterMultimapScoreRange 0"
  echo "        --clip3pAdapterSeq AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  echo "        --seedSearchStartLmax 50 --outFilterMatchNmin 25 --limitOutSJcollapsed"
  echo "        2000000\`"
  echo "          Long Reads: Same as Short Reads + \`--seedPerReadNmax 10000\`"
  echo "        This applies to fastqs provided in the Reads user input"
  echo "        Do NOT set any non-mapping related params like \`--genomeDir\`,"
  echo "        \`--outSAMtype\`, \`--outSAMunmapped\`, \`--readFilesIn\`, \`--runThreadN\`,"
  echo "        etc."
  echo "        We use STAR version 2.7.10b"
  echo ""
  echo "    --custom_bwa_mem2_params"
  echo "        type: string"
  echo "        example: -k 16 -w 200 -r"
  echo "        Modify bwa-mem2 alignment parameters - Set this parameter to fully"
  echo "        override bwa-mem2 mapping parameters used in the pipeline"
  echo "        The pipeline does not specify any custom mapping params to bwa-mem2 so"
  echo "        program default values are used"
  echo "        This applies to fastqs provided in the Reads_ATAC user input"
  echo "        Do NOT set any non-mapping related params like \`-C\`, \`-t\`, etc."
  echo "        We use bwa-mem2 version 2.2.1"
  echo ""
  echo "CWL-runner arguments:"
  echo "    --parallel"
  echo "        type: boolean"
  echo "        default: true"
  echo "        Run jobs in parallel."
  echo ""
  echo "    --timestamps"
  echo "        type: boolean_true"
  echo "        Add timestamps to the errors, warnings, and notifications."
  echo ""
  echo "Undocumented arguments:"
  echo "    --abseq_umi"
  echo "        type: integer"
  echo ""
  echo "    --target_analysis"
  echo "        type: boolean"
  echo ""
  echo "    --vdj_jgene_evalue"
  echo "        type: double"
  echo "        e-value threshold for J gene. The e-value threshold for J gene call by"
  echo "        IgBlast/PyIR, default is set as 0.001"
  echo ""
  echo "    --vdj_vgene_evalue"
  echo "        type: double"
  echo "        e-value threshold for V gene. The e-value threshold for V gene call by"
  echo "        IgBlast/PyIR, default is set as 0.001"
  echo ""
  echo "    --write_filtered_reads"
  echo "        type: boolean"
  echo "        Output processed FASTQ reads."
  echo ""
  echo "Viash built in Computational Requirements:"
  echo "    ---cpus=INT"
  echo "        Number of CPUs to use"
  echo "    ---memory=STRING"
  echo "        Amount of memory to use. Examples: 4GB, 3MiB."
  echo ""
  echo "Viash built in Docker:"
  echo "    ---setup=STRATEGY"
  echo "        Setup the docker container. Options are: alwaysbuild, alwayscachedbuild, ifneedbebuild, ifneedbecachedbuild, alwayspull, alwayspullelsebuild, alwayspullelsecachedbuild, ifneedbepull, ifneedbepullelsebuild, ifneedbepullelsecachedbuild, push, pushifnotpresent, donothing."
  echo "        Default: ifneedbepullelsecachedbuild"
  echo "    ---dockerfile"
  echo "        Print the dockerfile to stdout."
  echo "    ---docker_run_args=ARG"
  echo "        Provide runtime arguments to Docker. See the documentation on \`docker run\` for more information."
  echo "    ---docker_image_id"
  echo "        Print the docker image id to stdout."
  echo "    ---debug"
  echo "        Enter the docker container for debugging purposes."
  echo ""
  echo "Viash built in Engines:"
  echo "    ---engine=ENGINE_ID"
  echo "        Specify the engine to use. Options are: docker, native."
  echo "        Default: docker"
}

# initialise array
VIASH_POSITIONAL_ARGS=''

while [[ $# -gt 0 ]]; do
    case "$1" in
        -h|--help)
            ViashHelp
            exit
            ;;
        ---v|---verbose)
            let "VIASH_VERBOSITY=VIASH_VERBOSITY+1"
            shift 1
            ;;
        ---verbosity)
            VIASH_VERBOSITY="$2"
            shift 2
            ;;
        ---verbosity=*)
            VIASH_VERBOSITY="$(ViashRemoveFlags "$1")"
            shift 1
            ;;
        --version)
            echo "bd_rhapsody processing-workflows-quantile-filtering"
            exit
            ;;
        --reads)
            if [ -z "$VIASH_PAR_READS" ]; then
              VIASH_PAR_READS="$2"
            else
              VIASH_PAR_READS="$VIASH_PAR_READS;""$2"
            fi
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --reads. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --reads=*)
            if [ -z "$VIASH_PAR_READS" ]; then
              VIASH_PAR_READS=$(ViashRemoveFlags "$1")
            else
              VIASH_PAR_READS="$VIASH_PAR_READS;"$(ViashRemoveFlags "$1")
            fi
            shift 1
            ;;
        --reads_atac)
            if [ -z "$VIASH_PAR_READS_ATAC" ]; then
              VIASH_PAR_READS_ATAC="$2"
            else
              VIASH_PAR_READS_ATAC="$VIASH_PAR_READS_ATAC;""$2"
            fi
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --reads_atac. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --reads_atac=*)
            if [ -z "$VIASH_PAR_READS_ATAC" ]; then
              VIASH_PAR_READS_ATAC=$(ViashRemoveFlags "$1")
            else
              VIASH_PAR_READS_ATAC="$VIASH_PAR_READS_ATAC;"$(ViashRemoveFlags "$1")
            fi
            shift 1
            ;;
        --reference_archive)
            [ -n "$VIASH_PAR_REFERENCE_ARCHIVE" ] && ViashError Bad arguments for option \'--reference_archive\': \'$VIASH_PAR_REFERENCE_ARCHIVE\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_REFERENCE_ARCHIVE="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --reference_archive. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --reference_archive=*)
            [ -n "$VIASH_PAR_REFERENCE_ARCHIVE" ] && ViashError Bad arguments for option \'--reference_archive=*\': \'$VIASH_PAR_REFERENCE_ARCHIVE\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_REFERENCE_ARCHIVE=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --targeted_reference)
            if [ -z "$VIASH_PAR_TARGETED_REFERENCE" ]; then
              VIASH_PAR_TARGETED_REFERENCE="$2"
            else
              VIASH_PAR_TARGETED_REFERENCE="$VIASH_PAR_TARGETED_REFERENCE;""$2"
            fi
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --targeted_reference. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --targeted_reference=*)
            if [ -z "$VIASH_PAR_TARGETED_REFERENCE" ]; then
              VIASH_PAR_TARGETED_REFERENCE=$(ViashRemoveFlags "$1")
            else
              VIASH_PAR_TARGETED_REFERENCE="$VIASH_PAR_TARGETED_REFERENCE;"$(ViashRemoveFlags "$1")
            fi
            shift 1
            ;;
        --abseq_reference)
            if [ -z "$VIASH_PAR_ABSEQ_REFERENCE" ]; then
              VIASH_PAR_ABSEQ_REFERENCE="$2"
            else
              VIASH_PAR_ABSEQ_REFERENCE="$VIASH_PAR_ABSEQ_REFERENCE;""$2"
            fi
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --abseq_reference. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --abseq_reference=*)
            if [ -z "$VIASH_PAR_ABSEQ_REFERENCE" ]; then
              VIASH_PAR_ABSEQ_REFERENCE=$(ViashRemoveFlags "$1")
            else
              VIASH_PAR_ABSEQ_REFERENCE="$VIASH_PAR_ABSEQ_REFERENCE;"$(ViashRemoveFlags "$1")
            fi
            shift 1
            ;;
        --supplemental_reference)
            if [ -z "$VIASH_PAR_SUPPLEMENTAL_REFERENCE" ]; then
              VIASH_PAR_SUPPLEMENTAL_REFERENCE="$2"
            else
              VIASH_PAR_SUPPLEMENTAL_REFERENCE="$VIASH_PAR_SUPPLEMENTAL_REFERENCE;""$2"
            fi
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --supplemental_reference. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --supplemental_reference=*)
            if [ -z "$VIASH_PAR_SUPPLEMENTAL_REFERENCE" ]; then
              VIASH_PAR_SUPPLEMENTAL_REFERENCE=$(ViashRemoveFlags "$1")
            else
              VIASH_PAR_SUPPLEMENTAL_REFERENCE="$VIASH_PAR_SUPPLEMENTAL_REFERENCE;"$(ViashRemoveFlags "$1")
            fi
            shift 1
            ;;
        -s)
            if [ -z "$VIASH_PAR_SUPPLEMENTAL_REFERENCE" ]; then
              VIASH_PAR_SUPPLEMENTAL_REFERENCE="$2"
            else
              VIASH_PAR_SUPPLEMENTAL_REFERENCE="$VIASH_PAR_SUPPLEMENTAL_REFERENCE;""$2"
            fi
            [ $# -lt 2 ] && ViashError Not enough arguments passed to -s. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --output_dir)
            [ -n "$VIASH_PAR_OUTPUT_DIR" ] && ViashError Bad arguments for option \'--output_dir\': \'$VIASH_PAR_OUTPUT_DIR\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_OUTPUT_DIR="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --output_dir. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --output_dir=*)
            [ -n "$VIASH_PAR_OUTPUT_DIR" ] && ViashError Bad arguments for option \'--output_dir=*\': \'$VIASH_PAR_OUTPUT_DIR\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_OUTPUT_DIR=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        -o)
            [ -n "$VIASH_PAR_OUTPUT_DIR" ] && ViashError Bad arguments for option \'-o\': \'$VIASH_PAR_OUTPUT_DIR\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_OUTPUT_DIR="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to -o. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --output_seurat)
            [ -n "$VIASH_PAR_OUTPUT_SEURAT" ] && ViashError Bad arguments for option \'--output_seurat\': \'$VIASH_PAR_OUTPUT_SEURAT\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_OUTPUT_SEURAT="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --output_seurat. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --output_seurat=*)
            [ -n "$VIASH_PAR_OUTPUT_SEURAT" ] && ViashError Bad arguments for option \'--output_seurat=*\': \'$VIASH_PAR_OUTPUT_SEURAT\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_OUTPUT_SEURAT=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --output_mudata)
            [ -n "$VIASH_PAR_OUTPUT_MUDATA" ] && ViashError Bad arguments for option \'--output_mudata\': \'$VIASH_PAR_OUTPUT_MUDATA\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_OUTPUT_MUDATA="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --output_mudata. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --output_mudata=*)
            [ -n "$VIASH_PAR_OUTPUT_MUDATA" ] && ViashError Bad arguments for option \'--output_mudata=*\': \'$VIASH_PAR_OUTPUT_MUDATA\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_OUTPUT_MUDATA=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --metrics_summary)
            [ -n "$VIASH_PAR_METRICS_SUMMARY" ] && ViashError Bad arguments for option \'--metrics_summary\': \'$VIASH_PAR_METRICS_SUMMARY\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_METRICS_SUMMARY="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --metrics_summary. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --metrics_summary=*)
            [ -n "$VIASH_PAR_METRICS_SUMMARY" ] && ViashError Bad arguments for option \'--metrics_summary=*\': \'$VIASH_PAR_METRICS_SUMMARY\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_METRICS_SUMMARY=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --pipeline_report)
            [ -n "$VIASH_PAR_PIPELINE_REPORT" ] && ViashError Bad arguments for option \'--pipeline_report\': \'$VIASH_PAR_PIPELINE_REPORT\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_PIPELINE_REPORT="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --pipeline_report. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --pipeline_report=*)
            [ -n "$VIASH_PAR_PIPELINE_REPORT" ] && ViashError Bad arguments for option \'--pipeline_report=*\': \'$VIASH_PAR_PIPELINE_REPORT\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_PIPELINE_REPORT=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --rsec_mols_per_cell)
            [ -n "$VIASH_PAR_RSEC_MOLS_PER_CELL" ] && ViashError Bad arguments for option \'--rsec_mols_per_cell\': \'$VIASH_PAR_RSEC_MOLS_PER_CELL\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_RSEC_MOLS_PER_CELL="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --rsec_mols_per_cell. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --rsec_mols_per_cell=*)
            [ -n "$VIASH_PAR_RSEC_MOLS_PER_CELL" ] && ViashError Bad arguments for option \'--rsec_mols_per_cell=*\': \'$VIASH_PAR_RSEC_MOLS_PER_CELL\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_RSEC_MOLS_PER_CELL=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --dbec_mols_per_cell)
            [ -n "$VIASH_PAR_DBEC_MOLS_PER_CELL" ] && ViashError Bad arguments for option \'--dbec_mols_per_cell\': \'$VIASH_PAR_DBEC_MOLS_PER_CELL\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_DBEC_MOLS_PER_CELL="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --dbec_mols_per_cell. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --dbec_mols_per_cell=*)
            [ -n "$VIASH_PAR_DBEC_MOLS_PER_CELL" ] && ViashError Bad arguments for option \'--dbec_mols_per_cell=*\': \'$VIASH_PAR_DBEC_MOLS_PER_CELL\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_DBEC_MOLS_PER_CELL=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --rsec_mols_per_cell_unfiltered)
            [ -n "$VIASH_PAR_RSEC_MOLS_PER_CELL_UNFILTERED" ] && ViashError Bad arguments for option \'--rsec_mols_per_cell_unfiltered\': \'$VIASH_PAR_RSEC_MOLS_PER_CELL_UNFILTERED\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_RSEC_MOLS_PER_CELL_UNFILTERED="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --rsec_mols_per_cell_unfiltered. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --rsec_mols_per_cell_unfiltered=*)
            [ -n "$VIASH_PAR_RSEC_MOLS_PER_CELL_UNFILTERED" ] && ViashError Bad arguments for option \'--rsec_mols_per_cell_unfiltered=*\': \'$VIASH_PAR_RSEC_MOLS_PER_CELL_UNFILTERED\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_RSEC_MOLS_PER_CELL_UNFILTERED=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --bam)
            [ -n "$VIASH_PAR_BAM" ] && ViashError Bad arguments for option \'--bam\': \'$VIASH_PAR_BAM\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_BAM="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --bam. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --bam=*)
            [ -n "$VIASH_PAR_BAM" ] && ViashError Bad arguments for option \'--bam=*\': \'$VIASH_PAR_BAM\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_BAM=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --bam_index)
            [ -n "$VIASH_PAR_BAM_INDEX" ] && ViashError Bad arguments for option \'--bam_index\': \'$VIASH_PAR_BAM_INDEX\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_BAM_INDEX="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --bam_index. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --bam_index=*)
            [ -n "$VIASH_PAR_BAM_INDEX" ] && ViashError Bad arguments for option \'--bam_index=*\': \'$VIASH_PAR_BAM_INDEX\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_BAM_INDEX=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --bioproduct_stats)
            [ -n "$VIASH_PAR_BIOPRODUCT_STATS" ] && ViashError Bad arguments for option \'--bioproduct_stats\': \'$VIASH_PAR_BIOPRODUCT_STATS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_BIOPRODUCT_STATS="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --bioproduct_stats. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --bioproduct_stats=*)
            [ -n "$VIASH_PAR_BIOPRODUCT_STATS" ] && ViashError Bad arguments for option \'--bioproduct_stats=*\': \'$VIASH_PAR_BIOPRODUCT_STATS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_BIOPRODUCT_STATS=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --dimred_tsne)
            [ -n "$VIASH_PAR_DIMRED_TSNE" ] && ViashError Bad arguments for option \'--dimred_tsne\': \'$VIASH_PAR_DIMRED_TSNE\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_DIMRED_TSNE="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --dimred_tsne. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --dimred_tsne=*)
            [ -n "$VIASH_PAR_DIMRED_TSNE" ] && ViashError Bad arguments for option \'--dimred_tsne=*\': \'$VIASH_PAR_DIMRED_TSNE\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_DIMRED_TSNE=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --dimred_umap)
            [ -n "$VIASH_PAR_DIMRED_UMAP" ] && ViashError Bad arguments for option \'--dimred_umap\': \'$VIASH_PAR_DIMRED_UMAP\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_DIMRED_UMAP="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --dimred_umap. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --dimred_umap=*)
            [ -n "$VIASH_PAR_DIMRED_UMAP" ] && ViashError Bad arguments for option \'--dimred_umap=*\': \'$VIASH_PAR_DIMRED_UMAP\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_DIMRED_UMAP=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --immune_cell_classification)
            [ -n "$VIASH_PAR_IMMUNE_CELL_CLASSIFICATION" ] && ViashError Bad arguments for option \'--immune_cell_classification\': \'$VIASH_PAR_IMMUNE_CELL_CLASSIFICATION\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_IMMUNE_CELL_CLASSIFICATION="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --immune_cell_classification. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --immune_cell_classification=*)
            [ -n "$VIASH_PAR_IMMUNE_CELL_CLASSIFICATION" ] && ViashError Bad arguments for option \'--immune_cell_classification=*\': \'$VIASH_PAR_IMMUNE_CELL_CLASSIFICATION\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_IMMUNE_CELL_CLASSIFICATION=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --sample_tag_metrics)
            [ -n "$VIASH_PAR_SAMPLE_TAG_METRICS" ] && ViashError Bad arguments for option \'--sample_tag_metrics\': \'$VIASH_PAR_SAMPLE_TAG_METRICS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_SAMPLE_TAG_METRICS="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --sample_tag_metrics. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --sample_tag_metrics=*)
            [ -n "$VIASH_PAR_SAMPLE_TAG_METRICS" ] && ViashError Bad arguments for option \'--sample_tag_metrics=*\': \'$VIASH_PAR_SAMPLE_TAG_METRICS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_SAMPLE_TAG_METRICS=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --sample_tag_calls)
            [ -n "$VIASH_PAR_SAMPLE_TAG_CALLS" ] && ViashError Bad arguments for option \'--sample_tag_calls\': \'$VIASH_PAR_SAMPLE_TAG_CALLS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_SAMPLE_TAG_CALLS="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --sample_tag_calls. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --sample_tag_calls=*)
            [ -n "$VIASH_PAR_SAMPLE_TAG_CALLS" ] && ViashError Bad arguments for option \'--sample_tag_calls=*\': \'$VIASH_PAR_SAMPLE_TAG_CALLS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_SAMPLE_TAG_CALLS=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --sample_tag_counts)
            [ -n "$VIASH_PAR_SAMPLE_TAG_COUNTS" ] && ViashError Bad arguments for option \'--sample_tag_counts\': \'$VIASH_PAR_SAMPLE_TAG_COUNTS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_SAMPLE_TAG_COUNTS="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --sample_tag_counts. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --sample_tag_counts=*)
            [ -n "$VIASH_PAR_SAMPLE_TAG_COUNTS" ] && ViashError Bad arguments for option \'--sample_tag_counts=*\': \'$VIASH_PAR_SAMPLE_TAG_COUNTS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_SAMPLE_TAG_COUNTS=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --sample_tag_counts_unassigned)
            [ -n "$VIASH_PAR_SAMPLE_TAG_COUNTS_UNASSIGNED" ] && ViashError Bad arguments for option \'--sample_tag_counts_unassigned\': \'$VIASH_PAR_SAMPLE_TAG_COUNTS_UNASSIGNED\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_SAMPLE_TAG_COUNTS_UNASSIGNED="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --sample_tag_counts_unassigned. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --sample_tag_counts_unassigned=*)
            [ -n "$VIASH_PAR_SAMPLE_TAG_COUNTS_UNASSIGNED" ] && ViashError Bad arguments for option \'--sample_tag_counts_unassigned=*\': \'$VIASH_PAR_SAMPLE_TAG_COUNTS_UNASSIGNED\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_SAMPLE_TAG_COUNTS_UNASSIGNED=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --vdj_metrics)
            [ -n "$VIASH_PAR_VDJ_METRICS" ] && ViashError Bad arguments for option \'--vdj_metrics\': \'$VIASH_PAR_VDJ_METRICS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_VDJ_METRICS="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --vdj_metrics. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --vdj_metrics=*)
            [ -n "$VIASH_PAR_VDJ_METRICS" ] && ViashError Bad arguments for option \'--vdj_metrics=*\': \'$VIASH_PAR_VDJ_METRICS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_VDJ_METRICS=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --vdj_per_cell)
            [ -n "$VIASH_PAR_VDJ_PER_CELL" ] && ViashError Bad arguments for option \'--vdj_per_cell\': \'$VIASH_PAR_VDJ_PER_CELL\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_VDJ_PER_CELL="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --vdj_per_cell. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --vdj_per_cell=*)
            [ -n "$VIASH_PAR_VDJ_PER_CELL" ] && ViashError Bad arguments for option \'--vdj_per_cell=*\': \'$VIASH_PAR_VDJ_PER_CELL\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_VDJ_PER_CELL=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --vdj_per_cell_uncorrected)
            [ -n "$VIASH_PAR_VDJ_PER_CELL_UNCORRECTED" ] && ViashError Bad arguments for option \'--vdj_per_cell_uncorrected\': \'$VIASH_PAR_VDJ_PER_CELL_UNCORRECTED\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_VDJ_PER_CELL_UNCORRECTED="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --vdj_per_cell_uncorrected. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --vdj_per_cell_uncorrected=*)
            [ -n "$VIASH_PAR_VDJ_PER_CELL_UNCORRECTED" ] && ViashError Bad arguments for option \'--vdj_per_cell_uncorrected=*\': \'$VIASH_PAR_VDJ_PER_CELL_UNCORRECTED\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_VDJ_PER_CELL_UNCORRECTED=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --vdj_dominant_contigs)
            [ -n "$VIASH_PAR_VDJ_DOMINANT_CONTIGS" ] && ViashError Bad arguments for option \'--vdj_dominant_contigs\': \'$VIASH_PAR_VDJ_DOMINANT_CONTIGS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_VDJ_DOMINANT_CONTIGS="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --vdj_dominant_contigs. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --vdj_dominant_contigs=*)
            [ -n "$VIASH_PAR_VDJ_DOMINANT_CONTIGS" ] && ViashError Bad arguments for option \'--vdj_dominant_contigs=*\': \'$VIASH_PAR_VDJ_DOMINANT_CONTIGS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_VDJ_DOMINANT_CONTIGS=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --vdj_unfiltered_contigs)
            [ -n "$VIASH_PAR_VDJ_UNFILTERED_CONTIGS" ] && ViashError Bad arguments for option \'--vdj_unfiltered_contigs\': \'$VIASH_PAR_VDJ_UNFILTERED_CONTIGS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_VDJ_UNFILTERED_CONTIGS="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --vdj_unfiltered_contigs. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --vdj_unfiltered_contigs=*)
            [ -n "$VIASH_PAR_VDJ_UNFILTERED_CONTIGS" ] && ViashError Bad arguments for option \'--vdj_unfiltered_contigs=*\': \'$VIASH_PAR_VDJ_UNFILTERED_CONTIGS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_VDJ_UNFILTERED_CONTIGS=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --atac_metrics)
            [ -n "$VIASH_PAR_ATAC_METRICS" ] && ViashError Bad arguments for option \'--atac_metrics\': \'$VIASH_PAR_ATAC_METRICS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_ATAC_METRICS="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --atac_metrics. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --atac_metrics=*)
            [ -n "$VIASH_PAR_ATAC_METRICS" ] && ViashError Bad arguments for option \'--atac_metrics=*\': \'$VIASH_PAR_ATAC_METRICS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_ATAC_METRICS=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --atac_metrics_json)
            [ -n "$VIASH_PAR_ATAC_METRICS_JSON" ] && ViashError Bad arguments for option \'--atac_metrics_json\': \'$VIASH_PAR_ATAC_METRICS_JSON\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_ATAC_METRICS_JSON="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --atac_metrics_json. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --atac_metrics_json=*)
            [ -n "$VIASH_PAR_ATAC_METRICS_JSON" ] && ViashError Bad arguments for option \'--atac_metrics_json=*\': \'$VIASH_PAR_ATAC_METRICS_JSON\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_ATAC_METRICS_JSON=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --atac_fragments)
            [ -n "$VIASH_PAR_ATAC_FRAGMENTS" ] && ViashError Bad arguments for option \'--atac_fragments\': \'$VIASH_PAR_ATAC_FRAGMENTS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_ATAC_FRAGMENTS="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --atac_fragments. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --atac_fragments=*)
            [ -n "$VIASH_PAR_ATAC_FRAGMENTS" ] && ViashError Bad arguments for option \'--atac_fragments=*\': \'$VIASH_PAR_ATAC_FRAGMENTS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_ATAC_FRAGMENTS=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --atac_fragments_index)
            [ -n "$VIASH_PAR_ATAC_FRAGMENTS_INDEX" ] && ViashError Bad arguments for option \'--atac_fragments_index\': \'$VIASH_PAR_ATAC_FRAGMENTS_INDEX\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_ATAC_FRAGMENTS_INDEX="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --atac_fragments_index. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --atac_fragments_index=*)
            [ -n "$VIASH_PAR_ATAC_FRAGMENTS_INDEX" ] && ViashError Bad arguments for option \'--atac_fragments_index=*\': \'$VIASH_PAR_ATAC_FRAGMENTS_INDEX\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_ATAC_FRAGMENTS_INDEX=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --atac_transposase_sites)
            [ -n "$VIASH_PAR_ATAC_TRANSPOSASE_SITES" ] && ViashError Bad arguments for option \'--atac_transposase_sites\': \'$VIASH_PAR_ATAC_TRANSPOSASE_SITES\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_ATAC_TRANSPOSASE_SITES="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --atac_transposase_sites. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --atac_transposase_sites=*)
            [ -n "$VIASH_PAR_ATAC_TRANSPOSASE_SITES" ] && ViashError Bad arguments for option \'--atac_transposase_sites=*\': \'$VIASH_PAR_ATAC_TRANSPOSASE_SITES\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_ATAC_TRANSPOSASE_SITES=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --atac_transposase_sites_index)
            [ -n "$VIASH_PAR_ATAC_TRANSPOSASE_SITES_INDEX" ] && ViashError Bad arguments for option \'--atac_transposase_sites_index\': \'$VIASH_PAR_ATAC_TRANSPOSASE_SITES_INDEX\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_ATAC_TRANSPOSASE_SITES_INDEX="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --atac_transposase_sites_index. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --atac_transposase_sites_index=*)
            [ -n "$VIASH_PAR_ATAC_TRANSPOSASE_SITES_INDEX" ] && ViashError Bad arguments for option \'--atac_transposase_sites_index=*\': \'$VIASH_PAR_ATAC_TRANSPOSASE_SITES_INDEX\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_ATAC_TRANSPOSASE_SITES_INDEX=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --atac_peaks)
            [ -n "$VIASH_PAR_ATAC_PEAKS" ] && ViashError Bad arguments for option \'--atac_peaks\': \'$VIASH_PAR_ATAC_PEAKS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_ATAC_PEAKS="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --atac_peaks. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --atac_peaks=*)
            [ -n "$VIASH_PAR_ATAC_PEAKS" ] && ViashError Bad arguments for option \'--atac_peaks=*\': \'$VIASH_PAR_ATAC_PEAKS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_ATAC_PEAKS=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --atac_peaks_index)
            [ -n "$VIASH_PAR_ATAC_PEAKS_INDEX" ] && ViashError Bad arguments for option \'--atac_peaks_index\': \'$VIASH_PAR_ATAC_PEAKS_INDEX\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_ATAC_PEAKS_INDEX="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --atac_peaks_index. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --atac_peaks_index=*)
            [ -n "$VIASH_PAR_ATAC_PEAKS_INDEX" ] && ViashError Bad arguments for option \'--atac_peaks_index=*\': \'$VIASH_PAR_ATAC_PEAKS_INDEX\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_ATAC_PEAKS_INDEX=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --atac_peak_annotation)
            [ -n "$VIASH_PAR_ATAC_PEAK_ANNOTATION" ] && ViashError Bad arguments for option \'--atac_peak_annotation\': \'$VIASH_PAR_ATAC_PEAK_ANNOTATION\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_ATAC_PEAK_ANNOTATION="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --atac_peak_annotation. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --atac_peak_annotation=*)
            [ -n "$VIASH_PAR_ATAC_PEAK_ANNOTATION" ] && ViashError Bad arguments for option \'--atac_peak_annotation=*\': \'$VIASH_PAR_ATAC_PEAK_ANNOTATION\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_ATAC_PEAK_ANNOTATION=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --atac_cell_by_peak)
            [ -n "$VIASH_PAR_ATAC_CELL_BY_PEAK" ] && ViashError Bad arguments for option \'--atac_cell_by_peak\': \'$VIASH_PAR_ATAC_CELL_BY_PEAK\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_ATAC_CELL_BY_PEAK="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --atac_cell_by_peak. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --atac_cell_by_peak=*)
            [ -n "$VIASH_PAR_ATAC_CELL_BY_PEAK" ] && ViashError Bad arguments for option \'--atac_cell_by_peak=*\': \'$VIASH_PAR_ATAC_CELL_BY_PEAK\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_ATAC_CELL_BY_PEAK=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --atac_cell_by_peak_unfiltered)
            [ -n "$VIASH_PAR_ATAC_CELL_BY_PEAK_UNFILTERED" ] && ViashError Bad arguments for option \'--atac_cell_by_peak_unfiltered\': \'$VIASH_PAR_ATAC_CELL_BY_PEAK_UNFILTERED\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_ATAC_CELL_BY_PEAK_UNFILTERED="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --atac_cell_by_peak_unfiltered. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --atac_cell_by_peak_unfiltered=*)
            [ -n "$VIASH_PAR_ATAC_CELL_BY_PEAK_UNFILTERED" ] && ViashError Bad arguments for option \'--atac_cell_by_peak_unfiltered=*\': \'$VIASH_PAR_ATAC_CELL_BY_PEAK_UNFILTERED\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_ATAC_CELL_BY_PEAK_UNFILTERED=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --atac_bam)
            [ -n "$VIASH_PAR_ATAC_BAM" ] && ViashError Bad arguments for option \'--atac_bam\': \'$VIASH_PAR_ATAC_BAM\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_ATAC_BAM="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --atac_bam. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --atac_bam=*)
            [ -n "$VIASH_PAR_ATAC_BAM" ] && ViashError Bad arguments for option \'--atac_bam=*\': \'$VIASH_PAR_ATAC_BAM\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_ATAC_BAM=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --atac_bam_index)
            [ -n "$VIASH_PAR_ATAC_BAM_INDEX" ] && ViashError Bad arguments for option \'--atac_bam_index\': \'$VIASH_PAR_ATAC_BAM_INDEX\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_ATAC_BAM_INDEX="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --atac_bam_index. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --atac_bam_index=*)
            [ -n "$VIASH_PAR_ATAC_BAM_INDEX" ] && ViashError Bad arguments for option \'--atac_bam_index=*\': \'$VIASH_PAR_ATAC_BAM_INDEX\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_ATAC_BAM_INDEX=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --protein_aggregates_experimental)
            [ -n "$VIASH_PAR_PROTEIN_AGGREGATES_EXPERIMENTAL" ] && ViashError Bad arguments for option \'--protein_aggregates_experimental\': \'$VIASH_PAR_PROTEIN_AGGREGATES_EXPERIMENTAL\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_PROTEIN_AGGREGATES_EXPERIMENTAL="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --protein_aggregates_experimental. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --protein_aggregates_experimental=*)
            [ -n "$VIASH_PAR_PROTEIN_AGGREGATES_EXPERIMENTAL" ] && ViashError Bad arguments for option \'--protein_aggregates_experimental=*\': \'$VIASH_PAR_PROTEIN_AGGREGATES_EXPERIMENTAL\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_PROTEIN_AGGREGATES_EXPERIMENTAL=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --cell_calling_data)
            [ -n "$VIASH_PAR_CELL_CALLING_DATA" ] && ViashError Bad arguments for option \'--cell_calling_data\': \'$VIASH_PAR_CELL_CALLING_DATA\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_CELL_CALLING_DATA="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --cell_calling_data. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --cell_calling_data=*)
            [ -n "$VIASH_PAR_CELL_CALLING_DATA" ] && ViashError Bad arguments for option \'--cell_calling_data=*\': \'$VIASH_PAR_CELL_CALLING_DATA\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_CELL_CALLING_DATA=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --cell_calling_bioproduct_algorithm)
            [ -n "$VIASH_PAR_CELL_CALLING_BIOPRODUCT_ALGORITHM" ] && ViashError Bad arguments for option \'--cell_calling_bioproduct_algorithm\': \'$VIASH_PAR_CELL_CALLING_BIOPRODUCT_ALGORITHM\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_CELL_CALLING_BIOPRODUCT_ALGORITHM="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --cell_calling_bioproduct_algorithm. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --cell_calling_bioproduct_algorithm=*)
            [ -n "$VIASH_PAR_CELL_CALLING_BIOPRODUCT_ALGORITHM" ] && ViashError Bad arguments for option \'--cell_calling_bioproduct_algorithm=*\': \'$VIASH_PAR_CELL_CALLING_BIOPRODUCT_ALGORITHM\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_CELL_CALLING_BIOPRODUCT_ALGORITHM=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --cell_calling_atac_algorithm)
            [ -n "$VIASH_PAR_CELL_CALLING_ATAC_ALGORITHM" ] && ViashError Bad arguments for option \'--cell_calling_atac_algorithm\': \'$VIASH_PAR_CELL_CALLING_ATAC_ALGORITHM\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_CELL_CALLING_ATAC_ALGORITHM="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --cell_calling_atac_algorithm. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --cell_calling_atac_algorithm=*)
            [ -n "$VIASH_PAR_CELL_CALLING_ATAC_ALGORITHM" ] && ViashError Bad arguments for option \'--cell_calling_atac_algorithm=*\': \'$VIASH_PAR_CELL_CALLING_ATAC_ALGORITHM\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_CELL_CALLING_ATAC_ALGORITHM=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --exact_cell_count)
            [ -n "$VIASH_PAR_EXACT_CELL_COUNT" ] && ViashError Bad arguments for option \'--exact_cell_count\': \'$VIASH_PAR_EXACT_CELL_COUNT\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_EXACT_CELL_COUNT="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --exact_cell_count. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --exact_cell_count=*)
            [ -n "$VIASH_PAR_EXACT_CELL_COUNT" ] && ViashError Bad arguments for option \'--exact_cell_count=*\': \'$VIASH_PAR_EXACT_CELL_COUNT\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_EXACT_CELL_COUNT=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --expected_cell_count)
            [ -n "$VIASH_PAR_EXPECTED_CELL_COUNT" ] && ViashError Bad arguments for option \'--expected_cell_count\': \'$VIASH_PAR_EXPECTED_CELL_COUNT\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_EXPECTED_CELL_COUNT="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --expected_cell_count. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --expected_cell_count=*)
            [ -n "$VIASH_PAR_EXPECTED_CELL_COUNT" ] && ViashError Bad arguments for option \'--expected_cell_count=*\': \'$VIASH_PAR_EXPECTED_CELL_COUNT\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_EXPECTED_CELL_COUNT=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --exclude_intronic_reads)
            [ -n "$VIASH_PAR_EXCLUDE_INTRONIC_READS" ] && ViashError Bad arguments for option \'--exclude_intronic_reads\': \'$VIASH_PAR_EXCLUDE_INTRONIC_READS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_EXCLUDE_INTRONIC_READS="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --exclude_intronic_reads. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --exclude_intronic_reads=*)
            [ -n "$VIASH_PAR_EXCLUDE_INTRONIC_READS" ] && ViashError Bad arguments for option \'--exclude_intronic_reads=*\': \'$VIASH_PAR_EXCLUDE_INTRONIC_READS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_EXCLUDE_INTRONIC_READS=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --sample_tags_version)
            [ -n "$VIASH_PAR_SAMPLE_TAGS_VERSION" ] && ViashError Bad arguments for option \'--sample_tags_version\': \'$VIASH_PAR_SAMPLE_TAGS_VERSION\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_SAMPLE_TAGS_VERSION="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --sample_tags_version. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --sample_tags_version=*)
            [ -n "$VIASH_PAR_SAMPLE_TAGS_VERSION" ] && ViashError Bad arguments for option \'--sample_tags_version=*\': \'$VIASH_PAR_SAMPLE_TAGS_VERSION\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_SAMPLE_TAGS_VERSION=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --tag_names)
            if [ -z "$VIASH_PAR_TAG_NAMES" ]; then
              VIASH_PAR_TAG_NAMES="$2"
            else
              VIASH_PAR_TAG_NAMES="$VIASH_PAR_TAG_NAMES;""$2"
            fi
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --tag_names. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --tag_names=*)
            if [ -z "$VIASH_PAR_TAG_NAMES" ]; then
              VIASH_PAR_TAG_NAMES=$(ViashRemoveFlags "$1")
            else
              VIASH_PAR_TAG_NAMES="$VIASH_PAR_TAG_NAMES;"$(ViashRemoveFlags "$1")
            fi
            shift 1
            ;;
        --vdj_version)
            [ -n "$VIASH_PAR_VDJ_VERSION" ] && ViashError Bad arguments for option \'--vdj_version\': \'$VIASH_PAR_VDJ_VERSION\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_VDJ_VERSION="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --vdj_version. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --vdj_version=*)
            [ -n "$VIASH_PAR_VDJ_VERSION" ] && ViashError Bad arguments for option \'--vdj_version=*\': \'$VIASH_PAR_VDJ_VERSION\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_VDJ_VERSION=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --predefined_atac_peaks)
            [ -n "$VIASH_PAR_PREDEFINED_ATAC_PEAKS" ] && ViashError Bad arguments for option \'--predefined_atac_peaks\': \'$VIASH_PAR_PREDEFINED_ATAC_PEAKS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_PREDEFINED_ATAC_PEAKS="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --predefined_atac_peaks. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --predefined_atac_peaks=*)
            [ -n "$VIASH_PAR_PREDEFINED_ATAC_PEAKS" ] && ViashError Bad arguments for option \'--predefined_atac_peaks=*\': \'$VIASH_PAR_PREDEFINED_ATAC_PEAKS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_PREDEFINED_ATAC_PEAKS=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --run_name)
            [ -n "$VIASH_PAR_RUN_NAME" ] && ViashError Bad arguments for option \'--run_name\': \'$VIASH_PAR_RUN_NAME\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_RUN_NAME="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --run_name. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --run_name=*)
            [ -n "$VIASH_PAR_RUN_NAME" ] && ViashError Bad arguments for option \'--run_name=*\': \'$VIASH_PAR_RUN_NAME\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_RUN_NAME=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --generate_bam)
            [ -n "$VIASH_PAR_GENERATE_BAM" ] && ViashError Bad arguments for option \'--generate_bam\': \'$VIASH_PAR_GENERATE_BAM\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_GENERATE_BAM="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --generate_bam. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --generate_bam=*)
            [ -n "$VIASH_PAR_GENERATE_BAM" ] && ViashError Bad arguments for option \'--generate_bam=*\': \'$VIASH_PAR_GENERATE_BAM\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_GENERATE_BAM=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --long_reads)
            [ -n "$VIASH_PAR_LONG_READS" ] && ViashError Bad arguments for option \'--long_reads\': \'$VIASH_PAR_LONG_READS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_LONG_READS="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --long_reads. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --long_reads=*)
            [ -n "$VIASH_PAR_LONG_READS" ] && ViashError Bad arguments for option \'--long_reads=*\': \'$VIASH_PAR_LONG_READS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_LONG_READS=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --custom_star_params)
            [ -n "$VIASH_PAR_CUSTOM_STAR_PARAMS" ] && ViashError Bad arguments for option \'--custom_star_params\': \'$VIASH_PAR_CUSTOM_STAR_PARAMS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_CUSTOM_STAR_PARAMS="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --custom_star_params. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --custom_star_params=*)
            [ -n "$VIASH_PAR_CUSTOM_STAR_PARAMS" ] && ViashError Bad arguments for option \'--custom_star_params=*\': \'$VIASH_PAR_CUSTOM_STAR_PARAMS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_CUSTOM_STAR_PARAMS=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --custom_bwa_mem2_params)
            [ -n "$VIASH_PAR_CUSTOM_BWA_MEM2_PARAMS" ] && ViashError Bad arguments for option \'--custom_bwa_mem2_params\': \'$VIASH_PAR_CUSTOM_BWA_MEM2_PARAMS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_CUSTOM_BWA_MEM2_PARAMS="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --custom_bwa_mem2_params. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --custom_bwa_mem2_params=*)
            [ -n "$VIASH_PAR_CUSTOM_BWA_MEM2_PARAMS" ] && ViashError Bad arguments for option \'--custom_bwa_mem2_params=*\': \'$VIASH_PAR_CUSTOM_BWA_MEM2_PARAMS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_CUSTOM_BWA_MEM2_PARAMS=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --parallel)
            [ -n "$VIASH_PAR_PARALLEL" ] && ViashError Bad arguments for option \'--parallel\': \'$VIASH_PAR_PARALLEL\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_PARALLEL="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --parallel. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --parallel=*)
            [ -n "$VIASH_PAR_PARALLEL" ] && ViashError Bad arguments for option \'--parallel=*\': \'$VIASH_PAR_PARALLEL\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_PARALLEL=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --timestamps)
            [ -n "$VIASH_PAR_TIMESTAMPS" ] && ViashError Bad arguments for option \'--timestamps\': \'$VIASH_PAR_TIMESTAMPS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_TIMESTAMPS=true
            shift 1
            ;;
        --abseq_umi)
            [ -n "$VIASH_PAR_ABSEQ_UMI" ] && ViashError Bad arguments for option \'--abseq_umi\': \'$VIASH_PAR_ABSEQ_UMI\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_ABSEQ_UMI="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --abseq_umi. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --abseq_umi=*)
            [ -n "$VIASH_PAR_ABSEQ_UMI" ] && ViashError Bad arguments for option \'--abseq_umi=*\': \'$VIASH_PAR_ABSEQ_UMI\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_ABSEQ_UMI=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --target_analysis)
            [ -n "$VIASH_PAR_TARGET_ANALYSIS" ] && ViashError Bad arguments for option \'--target_analysis\': \'$VIASH_PAR_TARGET_ANALYSIS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_TARGET_ANALYSIS="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --target_analysis. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --target_analysis=*)
            [ -n "$VIASH_PAR_TARGET_ANALYSIS" ] && ViashError Bad arguments for option \'--target_analysis=*\': \'$VIASH_PAR_TARGET_ANALYSIS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_TARGET_ANALYSIS=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --vdj_jgene_evalue)
            [ -n "$VIASH_PAR_VDJ_JGENE_EVALUE" ] && ViashError Bad arguments for option \'--vdj_jgene_evalue\': \'$VIASH_PAR_VDJ_JGENE_EVALUE\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_VDJ_JGENE_EVALUE="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --vdj_jgene_evalue. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --vdj_jgene_evalue=*)
            [ -n "$VIASH_PAR_VDJ_JGENE_EVALUE" ] && ViashError Bad arguments for option \'--vdj_jgene_evalue=*\': \'$VIASH_PAR_VDJ_JGENE_EVALUE\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_VDJ_JGENE_EVALUE=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --vdj_vgene_evalue)
            [ -n "$VIASH_PAR_VDJ_VGENE_EVALUE" ] && ViashError Bad arguments for option \'--vdj_vgene_evalue\': \'$VIASH_PAR_VDJ_VGENE_EVALUE\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_VDJ_VGENE_EVALUE="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --vdj_vgene_evalue. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --vdj_vgene_evalue=*)
            [ -n "$VIASH_PAR_VDJ_VGENE_EVALUE" ] && ViashError Bad arguments for option \'--vdj_vgene_evalue=*\': \'$VIASH_PAR_VDJ_VGENE_EVALUE\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_VDJ_VGENE_EVALUE=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        --write_filtered_reads)
            [ -n "$VIASH_PAR_WRITE_FILTERED_READS" ] && ViashError Bad arguments for option \'--write_filtered_reads\': \'$VIASH_PAR_WRITE_FILTERED_READS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_WRITE_FILTERED_READS="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to --write_filtered_reads. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        --write_filtered_reads=*)
            [ -n "$VIASH_PAR_WRITE_FILTERED_READS" ] && ViashError Bad arguments for option \'--write_filtered_reads=*\': \'$VIASH_PAR_WRITE_FILTERED_READS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_PAR_WRITE_FILTERED_READS=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        ---engine)
            VIASH_ENGINE_ID="$2"
            shift 2
            ;;
        ---engine=*)
            VIASH_ENGINE_ID="$(ViashRemoveFlags "$1")"
            shift 1
            ;;
        ---setup)
            VIASH_MODE='setup'
            VIASH_SETUP_STRATEGY="$2"
            shift 2
            ;;
        ---setup=*)
            VIASH_MODE='setup'
            VIASH_SETUP_STRATEGY="$(ViashRemoveFlags "$1")"
            shift 1
            ;;
        ---dockerfile)
            VIASH_MODE='dockerfile'
            shift 1
            ;;
        ---docker_run_args)
            VIASH_DOCKER_RUN_ARGS+=("$2")
            shift 2
            ;;
        ---docker_run_args=*)
            VIASH_DOCKER_RUN_ARGS+=("$(ViashRemoveFlags "$1")")
            shift 1
            ;;
        ---docker_image_id)
            VIASH_MODE='docker_image_id'
            shift 1
            ;;
        ---debug)
            VIASH_MODE='debug'
            shift 1
            ;;
        ---cpus)
            [ -n "$VIASH_META_CPUS" ] && ViashError Bad arguments for option \'---cpus\': \'$VIASH_META_CPUS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_META_CPUS="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to ---cpus. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        ---cpus=*)
            [ -n "$VIASH_META_CPUS" ] && ViashError Bad arguments for option \'---cpus=*\': \'$VIASH_META_CPUS\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_META_CPUS=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        ---memory)
            [ -n "$VIASH_META_MEMORY" ] && ViashError Bad arguments for option \'---memory\': \'$VIASH_META_MEMORY\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_META_MEMORY="$2"
            [ $# -lt 2 ] && ViashError Not enough arguments passed to ---memory. Use "--help" to get more information on the parameters. && exit 1
            shift 2
            ;;
        ---memory=*)
            [ -n "$VIASH_META_MEMORY" ] && ViashError Bad arguments for option \'---memory=*\': \'$VIASH_META_MEMORY\' \& \'$2\' - you should provide exactly one argument for this option. && exit 1
            VIASH_META_MEMORY=$(ViashRemoveFlags "$1")
            shift 1
            ;;
        *)  # positional arg or unknown option
            # since the positional args will be eval'd, can we always quote, instead of using ViashQuote
            VIASH_POSITIONAL_ARGS="$VIASH_POSITIONAL_ARGS '$1'"
            [[ $1 == -* ]] && ViashWarning $1 looks like a parameter but is not a defined parameter and will instead be treated as a positional argument. Use "--help" to get more information on the parameters.
            shift # past argument
            ;;
    esac
done

# parse positional parameters
eval set -- $VIASH_POSITIONAL_ARGS


if   [ "$VIASH_ENGINE_ID" == "native" ]  ; then
  VIASH_ENGINE_TYPE='native'
elif   [ "$VIASH_ENGINE_ID" == "docker" ]  ; then
  VIASH_ENGINE_TYPE='docker'
else
  ViashError "Engine '$VIASH_ENGINE_ID' is not recognized. Options are: docker, native."
  exit 1
fi

if [[ "$VIASH_ENGINE_TYPE" == "docker" ]]; then
  # check if docker is installed properly
  ViashDockerInstallationCheck

  # determine docker image id
  if [[ "$VIASH_ENGINE_ID" == 'docker' ]]; then
    VIASH_DOCKER_IMAGE_ID='images.viash-hub.com/vsh/openpipeline/mapping/bd_rhapsody:processing-workflows-quantile-filtering'
  fi

  # print dockerfile
  if [ "$VIASH_MODE" == "dockerfile" ]; then
    ViashDockerfile "$VIASH_ENGINE_ID"
    exit 0

  elif [ "$VIASH_MODE" == "docker_image_id" ]; then
    echo "$VIASH_DOCKER_IMAGE_ID"
    exit 0
  
  # enter docker container
  elif [[ "$VIASH_MODE" == "debug" ]]; then
    VIASH_CMD="docker run --entrypoint=bash ${VIASH_DOCKER_RUN_ARGS[@]} -v '$(pwd)':/pwd --workdir /pwd -t $VIASH_DOCKER_IMAGE_ID"
    ViashNotice "+ $VIASH_CMD"
    eval $VIASH_CMD
    exit 

  # build docker image
  elif [ "$VIASH_MODE" == "setup" ]; then
    ViashDockerSetup "$VIASH_DOCKER_IMAGE_ID" "$VIASH_SETUP_STRATEGY"
    ViashDockerCheckCommands "$VIASH_DOCKER_IMAGE_ID" 'bash'
    exit 0
  fi

  # check if docker image exists
  ViashDockerSetup "$VIASH_DOCKER_IMAGE_ID" ifneedbepullelsecachedbuild
  ViashDockerCheckCommands "$VIASH_DOCKER_IMAGE_ID" 'bash'
fi

# setting computational defaults

# helper function for parsing memory strings
function ViashMemoryAsBytes {
  local memory=`echo "$1" | tr '[:upper:]' '[:lower:]' | tr -d '[:space:]'`
  local memory_regex='^([0-9]+)([kmgtp]i?b?|b)$'
  if [[ $memory =~ $memory_regex ]]; then
    local number=${memory/[^0-9]*/}
    local symbol=${memory/*[0-9]/}
    
    case $symbol in
      b)      memory_b=$number ;;
      kb|k)   memory_b=$(( $number * 1000 )) ;;
      mb|m)   memory_b=$(( $number * 1000 * 1000 )) ;;
      gb|g)   memory_b=$(( $number * 1000 * 1000 * 1000 )) ;;
      tb|t)   memory_b=$(( $number * 1000 * 1000 * 1000 * 1000 )) ;;
      pb|p)   memory_b=$(( $number * 1000 * 1000 * 1000 * 1000 * 1000 )) ;;
      kib|ki)   memory_b=$(( $number * 1024 )) ;;
      mib|mi)   memory_b=$(( $number * 1024 * 1024 )) ;;
      gib|gi)   memory_b=$(( $number * 1024 * 1024 * 1024 )) ;;
      tib|ti)   memory_b=$(( $number * 1024 * 1024 * 1024 * 1024 )) ;;
      pib|pi)   memory_b=$(( $number * 1024 * 1024 * 1024 * 1024 * 1024 )) ;;
    esac
    echo "$memory_b"
  fi
}
# compute memory in different units
if [ ! -z ${VIASH_META_MEMORY+x} ]; then
  VIASH_META_MEMORY_B=`ViashMemoryAsBytes $VIASH_META_MEMORY`
  # do not define other variables if memory_b is an empty string
  if [ ! -z "$VIASH_META_MEMORY_B" ]; then
    VIASH_META_MEMORY_KB=$(( ($VIASH_META_MEMORY_B+999) / 1000 ))
    VIASH_META_MEMORY_MB=$(( ($VIASH_META_MEMORY_KB+999) / 1000 ))
    VIASH_META_MEMORY_GB=$(( ($VIASH_META_MEMORY_MB+999) / 1000 ))
    VIASH_META_MEMORY_TB=$(( ($VIASH_META_MEMORY_GB+999) / 1000 ))
    VIASH_META_MEMORY_PB=$(( ($VIASH_META_MEMORY_TB+999) / 1000 ))
    VIASH_META_MEMORY_KIB=$(( ($VIASH_META_MEMORY_B+1023) / 1024 ))
    VIASH_META_MEMORY_MIB=$(( ($VIASH_META_MEMORY_KIB+1023) / 1024 ))
    VIASH_META_MEMORY_GIB=$(( ($VIASH_META_MEMORY_MIB+1023) / 1024 ))
    VIASH_META_MEMORY_TIB=$(( ($VIASH_META_MEMORY_GIB+1023) / 1024 ))
    VIASH_META_MEMORY_PIB=$(( ($VIASH_META_MEMORY_TIB+1023) / 1024 ))
  else
    # unset memory if string is empty
    unset $VIASH_META_MEMORY_B
  fi
fi
# unset nproc if string is empty
if [ -z "$VIASH_META_CPUS" ]; then
  unset $VIASH_META_CPUS
fi


# check whether required parameters exist
if [ -z ${VIASH_PAR_OUTPUT_DIR+x} ]; then
  ViashError '--output_dir' is a required argument. Use "--help" to get more information on the parameters.
  exit 1
fi
if [ -z ${VIASH_META_NAME+x} ]; then
  ViashError 'name' is a required argument. Use "--help" to get more information on the parameters.
  exit 1
fi
if [ -z ${VIASH_META_FUNCTIONALITY_NAME+x} ]; then
  ViashError 'functionality_name' is a required argument. Use "--help" to get more information on the parameters.
  exit 1
fi
if [ -z ${VIASH_META_RESOURCES_DIR+x} ]; then
  ViashError 'resources_dir' is a required argument. Use "--help" to get more information on the parameters.
  exit 1
fi
if [ -z ${VIASH_META_EXECUTABLE+x} ]; then
  ViashError 'executable' is a required argument. Use "--help" to get more information on the parameters.
  exit 1
fi
if [ -z ${VIASH_META_CONFIG+x} ]; then
  ViashError 'config' is a required argument. Use "--help" to get more information on the parameters.
  exit 1
fi
if [ -z ${VIASH_META_TEMP_DIR+x} ]; then
  ViashError 'temp_dir' is a required argument. Use "--help" to get more information on the parameters.
  exit 1
fi

# filling in defaults
if [ -z ${VIASH_PAR_RUN_NAME+x} ]; then
  VIASH_PAR_RUN_NAME="sample"
fi
if [ -z ${VIASH_PAR_GENERATE_BAM+x} ]; then
  VIASH_PAR_GENERATE_BAM="false"
fi
if [ -z ${VIASH_PAR_PARALLEL+x} ]; then
  VIASH_PAR_PARALLEL="true"
fi
if [ -z ${VIASH_PAR_TIMESTAMPS+x} ]; then
  VIASH_PAR_TIMESTAMPS="false"
fi

# check whether required files exist
if [ ! -z "$VIASH_PAR_READS" ]; then
  IFS=';'
  set -f
  for file in $VIASH_PAR_READS; do
    unset IFS
    if [ ! -e "$file" ]; then
      ViashError "Input file '$file' does not exist."
      exit 1
    fi
  done
  set +f
fi
if [ ! -z "$VIASH_PAR_READS_ATAC" ]; then
  IFS=';'
  set -f
  for file in $VIASH_PAR_READS_ATAC; do
    unset IFS
    if [ ! -e "$file" ]; then
      ViashError "Input file '$file' does not exist."
      exit 1
    fi
  done
  set +f
fi
if [ ! -z "$VIASH_PAR_REFERENCE_ARCHIVE" ] && [ ! -e "$VIASH_PAR_REFERENCE_ARCHIVE" ]; then
  ViashError "Input file '$VIASH_PAR_REFERENCE_ARCHIVE' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_TARGETED_REFERENCE" ]; then
  IFS=';'
  set -f
  for file in $VIASH_PAR_TARGETED_REFERENCE; do
    unset IFS
    if [ ! -e "$file" ]; then
      ViashError "Input file '$file' does not exist."
      exit 1
    fi
  done
  set +f
fi
if [ ! -z "$VIASH_PAR_ABSEQ_REFERENCE" ]; then
  IFS=';'
  set -f
  for file in $VIASH_PAR_ABSEQ_REFERENCE; do
    unset IFS
    if [ ! -e "$file" ]; then
      ViashError "Input file '$file' does not exist."
      exit 1
    fi
  done
  set +f
fi
if [ ! -z "$VIASH_PAR_SUPPLEMENTAL_REFERENCE" ]; then
  IFS=';'
  set -f
  for file in $VIASH_PAR_SUPPLEMENTAL_REFERENCE; do
    unset IFS
    if [ ! -e "$file" ]; then
      ViashError "Input file '$file' does not exist."
      exit 1
    fi
  done
  set +f
fi
if [ ! -z "$VIASH_PAR_PREDEFINED_ATAC_PEAKS" ] && [ ! -e "$VIASH_PAR_PREDEFINED_ATAC_PEAKS" ]; then
  ViashError "Input file '$VIASH_PAR_PREDEFINED_ATAC_PEAKS' does not exist."
  exit 1
fi

# check whether parameters values are of the right type
if [[ -n "$VIASH_PAR_SAMPLE_TAG_COUNTS" ]]; then
  if ! [[ "$VIASH_PAR_SAMPLE_TAG_COUNTS" =~ \* ]]; then
    ViashError '--sample_tag_counts' has to be a path containing a wildcard, e.g. 'output_*.txt'. Use "--help" to get more information on the parameters.
    exit 1
  fi
fi
if [[ -n "$VIASH_PAR_EXACT_CELL_COUNT" ]]; then
  if ! [[ "$VIASH_PAR_EXACT_CELL_COUNT" =~ ^[-+]?[0-9]+$ ]]; then
    ViashError '--exact_cell_count' has to be an integer. Use "--help" to get more information on the parameters.
    exit 1
  fi
  if [[ $VIASH_PAR_EXACT_CELL_COUNT -lt 1 ]]; then
    ViashError '--exact_cell_count' has be more than or equal to 1. Use "--help" to get more information on the parameters.
    exit 1
  fi
fi
if [[ -n "$VIASH_PAR_EXPECTED_CELL_COUNT" ]]; then
  if ! [[ "$VIASH_PAR_EXPECTED_CELL_COUNT" =~ ^[-+]?[0-9]+$ ]]; then
    ViashError '--expected_cell_count' has to be an integer. Use "--help" to get more information on the parameters.
    exit 1
  fi
  if [[ $VIASH_PAR_EXPECTED_CELL_COUNT -lt 1 ]]; then
    ViashError '--expected_cell_count' has be more than or equal to 1. Use "--help" to get more information on the parameters.
    exit 1
  fi
fi
if [[ -n "$VIASH_PAR_EXCLUDE_INTRONIC_READS" ]]; then
  if ! [[ "$VIASH_PAR_EXCLUDE_INTRONIC_READS" =~ ^(true|True|TRUE|false|False|FALSE|yes|Yes|YES|no|No|NO)$ ]]; then
    ViashError '--exclude_intronic_reads' has to be a boolean. Use "--help" to get more information on the parameters.
    exit 1
  fi
fi
if [[ -n "$VIASH_PAR_GENERATE_BAM" ]]; then
  if ! [[ "$VIASH_PAR_GENERATE_BAM" =~ ^(true|True|TRUE|false|False|FALSE|yes|Yes|YES|no|No|NO)$ ]]; then
    ViashError '--generate_bam' has to be a boolean. Use "--help" to get more information on the parameters.
    exit 1
  fi
fi
if [[ -n "$VIASH_PAR_LONG_READS" ]]; then
  if ! [[ "$VIASH_PAR_LONG_READS" =~ ^(true|True|TRUE|false|False|FALSE|yes|Yes|YES|no|No|NO)$ ]]; then
    ViashError '--long_reads' has to be a boolean. Use "--help" to get more information on the parameters.
    exit 1
  fi
fi
if [[ -n "$VIASH_PAR_PARALLEL" ]]; then
  if ! [[ "$VIASH_PAR_PARALLEL" =~ ^(true|True|TRUE|false|False|FALSE|yes|Yes|YES|no|No|NO)$ ]]; then
    ViashError '--parallel' has to be a boolean. Use "--help" to get more information on the parameters.
    exit 1
  fi
fi
if [[ -n "$VIASH_PAR_TIMESTAMPS" ]]; then
  if ! [[ "$VIASH_PAR_TIMESTAMPS" =~ ^(true|True|TRUE|false|False|FALSE|yes|Yes|YES|no|No|NO)$ ]]; then
    ViashError '--timestamps' has to be a boolean_true. Use "--help" to get more information on the parameters.
    exit 1
  fi
fi
if [[ -n "$VIASH_PAR_ABSEQ_UMI" ]]; then
  if ! [[ "$VIASH_PAR_ABSEQ_UMI" =~ ^[-+]?[0-9]+$ ]]; then
    ViashError '--abseq_umi' has to be an integer. Use "--help" to get more information on the parameters.
    exit 1
  fi
fi
if [[ -n "$VIASH_PAR_TARGET_ANALYSIS" ]]; then
  if ! [[ "$VIASH_PAR_TARGET_ANALYSIS" =~ ^(true|True|TRUE|false|False|FALSE|yes|Yes|YES|no|No|NO)$ ]]; then
    ViashError '--target_analysis' has to be a boolean. Use "--help" to get more information on the parameters.
    exit 1
  fi
fi
if [[ -n "$VIASH_PAR_VDJ_JGENE_EVALUE" ]]; then
  if ! [[ "$VIASH_PAR_VDJ_JGENE_EVALUE" =~ ^[-+]?(\.[0-9]+|[0-9]+(\.[0-9]*)?)([eE][-+]?[0-9]+)?$ ]]; then
    ViashError '--vdj_jgene_evalue' has to be a double. Use "--help" to get more information on the parameters.
    exit 1
  fi
fi
if [[ -n "$VIASH_PAR_VDJ_VGENE_EVALUE" ]]; then
  if ! [[ "$VIASH_PAR_VDJ_VGENE_EVALUE" =~ ^[-+]?(\.[0-9]+|[0-9]+(\.[0-9]*)?)([eE][-+]?[0-9]+)?$ ]]; then
    ViashError '--vdj_vgene_evalue' has to be a double. Use "--help" to get more information on the parameters.
    exit 1
  fi
fi
if [[ -n "$VIASH_PAR_WRITE_FILTERED_READS" ]]; then
  if ! [[ "$VIASH_PAR_WRITE_FILTERED_READS" =~ ^(true|True|TRUE|false|False|FALSE|yes|Yes|YES|no|No|NO)$ ]]; then
    ViashError '--write_filtered_reads' has to be a boolean. Use "--help" to get more information on the parameters.
    exit 1
  fi
fi
if [[ -n "$VIASH_META_CPUS" ]]; then
  if ! [[ "$VIASH_META_CPUS" =~ ^[-+]?[0-9]+$ ]]; then
    ViashError 'cpus' has to be an integer. Use "--help" to get more information on the parameters.
    exit 1
  fi
fi
if [[ -n "$VIASH_META_MEMORY_B" ]]; then
  if ! [[ "$VIASH_META_MEMORY_B" =~ ^[-+]?[0-9]+$ ]]; then
    ViashError 'memory_b' has to be a long. Use "--help" to get more information on the parameters.
    exit 1
  fi
fi
if [[ -n "$VIASH_META_MEMORY_KB" ]]; then
  if ! [[ "$VIASH_META_MEMORY_KB" =~ ^[-+]?[0-9]+$ ]]; then
    ViashError 'memory_kb' has to be a long. Use "--help" to get more information on the parameters.
    exit 1
  fi
fi
if [[ -n "$VIASH_META_MEMORY_MB" ]]; then
  if ! [[ "$VIASH_META_MEMORY_MB" =~ ^[-+]?[0-9]+$ ]]; then
    ViashError 'memory_mb' has to be a long. Use "--help" to get more information on the parameters.
    exit 1
  fi
fi
if [[ -n "$VIASH_META_MEMORY_GB" ]]; then
  if ! [[ "$VIASH_META_MEMORY_GB" =~ ^[-+]?[0-9]+$ ]]; then
    ViashError 'memory_gb' has to be a long. Use "--help" to get more information on the parameters.
    exit 1
  fi
fi
if [[ -n "$VIASH_META_MEMORY_TB" ]]; then
  if ! [[ "$VIASH_META_MEMORY_TB" =~ ^[-+]?[0-9]+$ ]]; then
    ViashError 'memory_tb' has to be a long. Use "--help" to get more information on the parameters.
    exit 1
  fi
fi
if [[ -n "$VIASH_META_MEMORY_PB" ]]; then
  if ! [[ "$VIASH_META_MEMORY_PB" =~ ^[-+]?[0-9]+$ ]]; then
    ViashError 'memory_pb' has to be a long. Use "--help" to get more information on the parameters.
    exit 1
  fi
fi
if [[ -n "$VIASH_META_MEMORY_KIB" ]]; then
  if ! [[ "$VIASH_META_MEMORY_KIB" =~ ^[-+]?[0-9]+$ ]]; then
    ViashError 'memory_kib' has to be a long. Use "--help" to get more information on the parameters.
    exit 1
  fi
fi
if [[ -n "$VIASH_META_MEMORY_MIB" ]]; then
  if ! [[ "$VIASH_META_MEMORY_MIB" =~ ^[-+]?[0-9]+$ ]]; then
    ViashError 'memory_mib' has to be a long. Use "--help" to get more information on the parameters.
    exit 1
  fi
fi
if [[ -n "$VIASH_META_MEMORY_GIB" ]]; then
  if ! [[ "$VIASH_META_MEMORY_GIB" =~ ^[-+]?[0-9]+$ ]]; then
    ViashError 'memory_gib' has to be a long. Use "--help" to get more information on the parameters.
    exit 1
  fi
fi
if [[ -n "$VIASH_META_MEMORY_TIB" ]]; then
  if ! [[ "$VIASH_META_MEMORY_TIB" =~ ^[-+]?[0-9]+$ ]]; then
    ViashError 'memory_tib' has to be a long. Use "--help" to get more information on the parameters.
    exit 1
  fi
fi
if [[ -n "$VIASH_META_MEMORY_PIB" ]]; then
  if ! [[ "$VIASH_META_MEMORY_PIB" =~ ^[-+]?[0-9]+$ ]]; then
    ViashError 'memory_pib' has to be a long. Use "--help" to get more information on the parameters.
    exit 1
  fi
fi

# check whether value is belongs to a set of choices
if [ ! -z "$VIASH_PAR_CELL_CALLING_DATA" ]; then
  VIASH_PAR_CELL_CALLING_DATA_CHOICES=("mRNA;AbSeq;ATAC;mRNA_and_ATAC")
  IFS=';'
  set -f
  if ! [[ ";${VIASH_PAR_CELL_CALLING_DATA_CHOICES[*]};" =~ ";$VIASH_PAR_CELL_CALLING_DATA;" ]]; then
    ViashError '--cell_calling_data' specified value of \'$VIASH_PAR_CELL_CALLING_DATA\' is not in the list of allowed values. Use "--help" to get more information on the parameters.
    exit 1
  fi
  set +f
  unset IFS
fi

if [ ! -z "$VIASH_PAR_CELL_CALLING_BIOPRODUCT_ALGORITHM" ]; then
  VIASH_PAR_CELL_CALLING_BIOPRODUCT_ALGORITHM_CHOICES=("Basic;Refined")
  IFS=';'
  set -f
  if ! [[ ";${VIASH_PAR_CELL_CALLING_BIOPRODUCT_ALGORITHM_CHOICES[*]};" =~ ";$VIASH_PAR_CELL_CALLING_BIOPRODUCT_ALGORITHM;" ]]; then
    ViashError '--cell_calling_bioproduct_algorithm' specified value of \'$VIASH_PAR_CELL_CALLING_BIOPRODUCT_ALGORITHM\' is not in the list of allowed values. Use "--help" to get more information on the parameters.
    exit 1
  fi
  set +f
  unset IFS
fi

if [ ! -z "$VIASH_PAR_CELL_CALLING_ATAC_ALGORITHM" ]; then
  VIASH_PAR_CELL_CALLING_ATAC_ALGORITHM_CHOICES=("Basic;Refined")
  IFS=';'
  set -f
  if ! [[ ";${VIASH_PAR_CELL_CALLING_ATAC_ALGORITHM_CHOICES[*]};" =~ ";$VIASH_PAR_CELL_CALLING_ATAC_ALGORITHM;" ]]; then
    ViashError '--cell_calling_atac_algorithm' specified value of \'$VIASH_PAR_CELL_CALLING_ATAC_ALGORITHM\' is not in the list of allowed values. Use "--help" to get more information on the parameters.
    exit 1
  fi
  set +f
  unset IFS
fi

if [ ! -z "$VIASH_PAR_SAMPLE_TAGS_VERSION" ]; then
  VIASH_PAR_SAMPLE_TAGS_VERSION_CHOICES=("human;mouse;flex;nuclei_includes_mrna;nuclei_atac_only")
  IFS=';'
  set -f
  if ! [[ ";${VIASH_PAR_SAMPLE_TAGS_VERSION_CHOICES[*]};" =~ ";$VIASH_PAR_SAMPLE_TAGS_VERSION;" ]]; then
    ViashError '--sample_tags_version' specified value of \'$VIASH_PAR_SAMPLE_TAGS_VERSION\' is not in the list of allowed values. Use "--help" to get more information on the parameters.
    exit 1
  fi
  set +f
  unset IFS
fi

if [ ! -z "$VIASH_PAR_VDJ_VERSION" ]; then
  VIASH_PAR_VDJ_VERSION_CHOICES=("human;mouse;humanBCR;humanTCR;mouseBCR;mouseTCR")
  IFS=';'
  set -f
  if ! [[ ";${VIASH_PAR_VDJ_VERSION_CHOICES[*]};" =~ ";$VIASH_PAR_VDJ_VERSION;" ]]; then
    ViashError '--vdj_version' specified value of \'$VIASH_PAR_VDJ_VERSION\' is not in the list of allowed values. Use "--help" to get more information on the parameters.
    exit 1
  fi
  set +f
  unset IFS
fi

# create parent directories of output files, if so desired
if [ ! -z "$VIASH_PAR_OUTPUT_DIR" ] && [ ! -d "$(dirname "$VIASH_PAR_OUTPUT_DIR")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_OUTPUT_DIR")"
fi
if [ ! -z "$VIASH_PAR_OUTPUT_SEURAT" ] && [ ! -d "$(dirname "$VIASH_PAR_OUTPUT_SEURAT")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_OUTPUT_SEURAT")"
fi
if [ ! -z "$VIASH_PAR_OUTPUT_MUDATA" ] && [ ! -d "$(dirname "$VIASH_PAR_OUTPUT_MUDATA")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_OUTPUT_MUDATA")"
fi
if [ ! -z "$VIASH_PAR_METRICS_SUMMARY" ] && [ ! -d "$(dirname "$VIASH_PAR_METRICS_SUMMARY")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_METRICS_SUMMARY")"
fi
if [ ! -z "$VIASH_PAR_PIPELINE_REPORT" ] && [ ! -d "$(dirname "$VIASH_PAR_PIPELINE_REPORT")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_PIPELINE_REPORT")"
fi
if [ ! -z "$VIASH_PAR_RSEC_MOLS_PER_CELL" ] && [ ! -d "$(dirname "$VIASH_PAR_RSEC_MOLS_PER_CELL")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_RSEC_MOLS_PER_CELL")"
fi
if [ ! -z "$VIASH_PAR_DBEC_MOLS_PER_CELL" ] && [ ! -d "$(dirname "$VIASH_PAR_DBEC_MOLS_PER_CELL")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_DBEC_MOLS_PER_CELL")"
fi
if [ ! -z "$VIASH_PAR_RSEC_MOLS_PER_CELL_UNFILTERED" ] && [ ! -d "$(dirname "$VIASH_PAR_RSEC_MOLS_PER_CELL_UNFILTERED")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_RSEC_MOLS_PER_CELL_UNFILTERED")"
fi
if [ ! -z "$VIASH_PAR_BAM" ] && [ ! -d "$(dirname "$VIASH_PAR_BAM")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_BAM")"
fi
if [ ! -z "$VIASH_PAR_BAM_INDEX" ] && [ ! -d "$(dirname "$VIASH_PAR_BAM_INDEX")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_BAM_INDEX")"
fi
if [ ! -z "$VIASH_PAR_BIOPRODUCT_STATS" ] && [ ! -d "$(dirname "$VIASH_PAR_BIOPRODUCT_STATS")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_BIOPRODUCT_STATS")"
fi
if [ ! -z "$VIASH_PAR_DIMRED_TSNE" ] && [ ! -d "$(dirname "$VIASH_PAR_DIMRED_TSNE")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_DIMRED_TSNE")"
fi
if [ ! -z "$VIASH_PAR_DIMRED_UMAP" ] && [ ! -d "$(dirname "$VIASH_PAR_DIMRED_UMAP")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_DIMRED_UMAP")"
fi
if [ ! -z "$VIASH_PAR_IMMUNE_CELL_CLASSIFICATION" ] && [ ! -d "$(dirname "$VIASH_PAR_IMMUNE_CELL_CLASSIFICATION")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_IMMUNE_CELL_CLASSIFICATION")"
fi
if [ ! -z "$VIASH_PAR_SAMPLE_TAG_METRICS" ] && [ ! -d "$(dirname "$VIASH_PAR_SAMPLE_TAG_METRICS")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_SAMPLE_TAG_METRICS")"
fi
if [ ! -z "$VIASH_PAR_SAMPLE_TAG_CALLS" ] && [ ! -d "$(dirname "$VIASH_PAR_SAMPLE_TAG_CALLS")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_SAMPLE_TAG_CALLS")"
fi
if [ ! -z "$VIASH_PAR_SAMPLE_TAG_COUNTS" ] && [ ! -d "$(dirname "$VIASH_PAR_SAMPLE_TAG_COUNTS")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_SAMPLE_TAG_COUNTS")"
fi
if [ ! -z "$VIASH_PAR_SAMPLE_TAG_COUNTS_UNASSIGNED" ] && [ ! -d "$(dirname "$VIASH_PAR_SAMPLE_TAG_COUNTS_UNASSIGNED")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_SAMPLE_TAG_COUNTS_UNASSIGNED")"
fi
if [ ! -z "$VIASH_PAR_VDJ_METRICS" ] && [ ! -d "$(dirname "$VIASH_PAR_VDJ_METRICS")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_VDJ_METRICS")"
fi
if [ ! -z "$VIASH_PAR_VDJ_PER_CELL" ] && [ ! -d "$(dirname "$VIASH_PAR_VDJ_PER_CELL")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_VDJ_PER_CELL")"
fi
if [ ! -z "$VIASH_PAR_VDJ_PER_CELL_UNCORRECTED" ] && [ ! -d "$(dirname "$VIASH_PAR_VDJ_PER_CELL_UNCORRECTED")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_VDJ_PER_CELL_UNCORRECTED")"
fi
if [ ! -z "$VIASH_PAR_VDJ_DOMINANT_CONTIGS" ] && [ ! -d "$(dirname "$VIASH_PAR_VDJ_DOMINANT_CONTIGS")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_VDJ_DOMINANT_CONTIGS")"
fi
if [ ! -z "$VIASH_PAR_VDJ_UNFILTERED_CONTIGS" ] && [ ! -d "$(dirname "$VIASH_PAR_VDJ_UNFILTERED_CONTIGS")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_VDJ_UNFILTERED_CONTIGS")"
fi
if [ ! -z "$VIASH_PAR_ATAC_METRICS" ] && [ ! -d "$(dirname "$VIASH_PAR_ATAC_METRICS")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_ATAC_METRICS")"
fi
if [ ! -z "$VIASH_PAR_ATAC_METRICS_JSON" ] && [ ! -d "$(dirname "$VIASH_PAR_ATAC_METRICS_JSON")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_ATAC_METRICS_JSON")"
fi
if [ ! -z "$VIASH_PAR_ATAC_FRAGMENTS" ] && [ ! -d "$(dirname "$VIASH_PAR_ATAC_FRAGMENTS")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_ATAC_FRAGMENTS")"
fi
if [ ! -z "$VIASH_PAR_ATAC_FRAGMENTS_INDEX" ] && [ ! -d "$(dirname "$VIASH_PAR_ATAC_FRAGMENTS_INDEX")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_ATAC_FRAGMENTS_INDEX")"
fi
if [ ! -z "$VIASH_PAR_ATAC_TRANSPOSASE_SITES" ] && [ ! -d "$(dirname "$VIASH_PAR_ATAC_TRANSPOSASE_SITES")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_ATAC_TRANSPOSASE_SITES")"
fi
if [ ! -z "$VIASH_PAR_ATAC_TRANSPOSASE_SITES_INDEX" ] && [ ! -d "$(dirname "$VIASH_PAR_ATAC_TRANSPOSASE_SITES_INDEX")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_ATAC_TRANSPOSASE_SITES_INDEX")"
fi
if [ ! -z "$VIASH_PAR_ATAC_PEAKS" ] && [ ! -d "$(dirname "$VIASH_PAR_ATAC_PEAKS")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_ATAC_PEAKS")"
fi
if [ ! -z "$VIASH_PAR_ATAC_PEAKS_INDEX" ] && [ ! -d "$(dirname "$VIASH_PAR_ATAC_PEAKS_INDEX")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_ATAC_PEAKS_INDEX")"
fi
if [ ! -z "$VIASH_PAR_ATAC_PEAK_ANNOTATION" ] && [ ! -d "$(dirname "$VIASH_PAR_ATAC_PEAK_ANNOTATION")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_ATAC_PEAK_ANNOTATION")"
fi
if [ ! -z "$VIASH_PAR_ATAC_CELL_BY_PEAK" ] && [ ! -d "$(dirname "$VIASH_PAR_ATAC_CELL_BY_PEAK")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_ATAC_CELL_BY_PEAK")"
fi
if [ ! -z "$VIASH_PAR_ATAC_CELL_BY_PEAK_UNFILTERED" ] && [ ! -d "$(dirname "$VIASH_PAR_ATAC_CELL_BY_PEAK_UNFILTERED")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_ATAC_CELL_BY_PEAK_UNFILTERED")"
fi
if [ ! -z "$VIASH_PAR_ATAC_BAM" ] && [ ! -d "$(dirname "$VIASH_PAR_ATAC_BAM")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_ATAC_BAM")"
fi
if [ ! -z "$VIASH_PAR_ATAC_BAM_INDEX" ] && [ ! -d "$(dirname "$VIASH_PAR_ATAC_BAM_INDEX")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_ATAC_BAM_INDEX")"
fi
if [ ! -z "$VIASH_PAR_PROTEIN_AGGREGATES_EXPERIMENTAL" ] && [ ! -d "$(dirname "$VIASH_PAR_PROTEIN_AGGREGATES_EXPERIMENTAL")" ]; then
  mkdir -p "$(dirname "$VIASH_PAR_PROTEIN_AGGREGATES_EXPERIMENTAL")"
fi

if  [ "$VIASH_ENGINE_ID" == "native" ]  ; then
  if [ "$VIASH_MODE" == "run" ]; then
    VIASH_CMD="bash"
  else
    ViashError "Engine '$VIASH_ENGINE_ID' does not support mode '$VIASH_MODE'."
    exit 1
  fi
fi

if [[ "$VIASH_ENGINE_TYPE" == "docker" ]]; then
  # detect volumes from file arguments
  VIASH_CHOWN_VARS=()
if [ ! -z "$VIASH_PAR_READS" ]; then
  VIASH_TEST_READS=()
  IFS=';'
  for var in $VIASH_PAR_READS; do
    unset IFS
    VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$var")" )
    var=$(ViashDockerAutodetectMount "$var")
    VIASH_TEST_READS+=( "$var" )
  done
  VIASH_PAR_READS=$(IFS=';' ; echo "${VIASH_TEST_READS[*]}")
fi
if [ ! -z "$VIASH_PAR_READS_ATAC" ]; then
  VIASH_TEST_READS_ATAC=()
  IFS=';'
  for var in $VIASH_PAR_READS_ATAC; do
    unset IFS
    VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$var")" )
    var=$(ViashDockerAutodetectMount "$var")
    VIASH_TEST_READS_ATAC+=( "$var" )
  done
  VIASH_PAR_READS_ATAC=$(IFS=';' ; echo "${VIASH_TEST_READS_ATAC[*]}")
fi
if [ ! -z "$VIASH_PAR_REFERENCE_ARCHIVE" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_REFERENCE_ARCHIVE")" )
  VIASH_PAR_REFERENCE_ARCHIVE=$(ViashDockerAutodetectMount "$VIASH_PAR_REFERENCE_ARCHIVE")
fi
if [ ! -z "$VIASH_PAR_TARGETED_REFERENCE" ]; then
  VIASH_TEST_TARGETED_REFERENCE=()
  IFS=';'
  for var in $VIASH_PAR_TARGETED_REFERENCE; do
    unset IFS
    VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$var")" )
    var=$(ViashDockerAutodetectMount "$var")
    VIASH_TEST_TARGETED_REFERENCE+=( "$var" )
  done
  VIASH_PAR_TARGETED_REFERENCE=$(IFS=';' ; echo "${VIASH_TEST_TARGETED_REFERENCE[*]}")
fi
if [ ! -z "$VIASH_PAR_ABSEQ_REFERENCE" ]; then
  VIASH_TEST_ABSEQ_REFERENCE=()
  IFS=';'
  for var in $VIASH_PAR_ABSEQ_REFERENCE; do
    unset IFS
    VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$var")" )
    var=$(ViashDockerAutodetectMount "$var")
    VIASH_TEST_ABSEQ_REFERENCE+=( "$var" )
  done
  VIASH_PAR_ABSEQ_REFERENCE=$(IFS=';' ; echo "${VIASH_TEST_ABSEQ_REFERENCE[*]}")
fi
if [ ! -z "$VIASH_PAR_SUPPLEMENTAL_REFERENCE" ]; then
  VIASH_TEST_SUPPLEMENTAL_REFERENCE=()
  IFS=';'
  for var in $VIASH_PAR_SUPPLEMENTAL_REFERENCE; do
    unset IFS
    VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$var")" )
    var=$(ViashDockerAutodetectMount "$var")
    VIASH_TEST_SUPPLEMENTAL_REFERENCE+=( "$var" )
  done
  VIASH_PAR_SUPPLEMENTAL_REFERENCE=$(IFS=';' ; echo "${VIASH_TEST_SUPPLEMENTAL_REFERENCE[*]}")
fi
if [ ! -z "$VIASH_PAR_OUTPUT_DIR" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_OUTPUT_DIR")" )
  VIASH_PAR_OUTPUT_DIR=$(ViashDockerAutodetectMount "$VIASH_PAR_OUTPUT_DIR")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_OUTPUT_DIR" )
fi
if [ ! -z "$VIASH_PAR_OUTPUT_SEURAT" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_OUTPUT_SEURAT")" )
  VIASH_PAR_OUTPUT_SEURAT=$(ViashDockerAutodetectMount "$VIASH_PAR_OUTPUT_SEURAT")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_OUTPUT_SEURAT" )
fi
if [ ! -z "$VIASH_PAR_OUTPUT_MUDATA" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_OUTPUT_MUDATA")" )
  VIASH_PAR_OUTPUT_MUDATA=$(ViashDockerAutodetectMount "$VIASH_PAR_OUTPUT_MUDATA")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_OUTPUT_MUDATA" )
fi
if [ ! -z "$VIASH_PAR_METRICS_SUMMARY" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_METRICS_SUMMARY")" )
  VIASH_PAR_METRICS_SUMMARY=$(ViashDockerAutodetectMount "$VIASH_PAR_METRICS_SUMMARY")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_METRICS_SUMMARY" )
fi
if [ ! -z "$VIASH_PAR_PIPELINE_REPORT" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_PIPELINE_REPORT")" )
  VIASH_PAR_PIPELINE_REPORT=$(ViashDockerAutodetectMount "$VIASH_PAR_PIPELINE_REPORT")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_PIPELINE_REPORT" )
fi
if [ ! -z "$VIASH_PAR_RSEC_MOLS_PER_CELL" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_RSEC_MOLS_PER_CELL")" )
  VIASH_PAR_RSEC_MOLS_PER_CELL=$(ViashDockerAutodetectMount "$VIASH_PAR_RSEC_MOLS_PER_CELL")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_RSEC_MOLS_PER_CELL" )
fi
if [ ! -z "$VIASH_PAR_DBEC_MOLS_PER_CELL" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_DBEC_MOLS_PER_CELL")" )
  VIASH_PAR_DBEC_MOLS_PER_CELL=$(ViashDockerAutodetectMount "$VIASH_PAR_DBEC_MOLS_PER_CELL")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_DBEC_MOLS_PER_CELL" )
fi
if [ ! -z "$VIASH_PAR_RSEC_MOLS_PER_CELL_UNFILTERED" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_RSEC_MOLS_PER_CELL_UNFILTERED")" )
  VIASH_PAR_RSEC_MOLS_PER_CELL_UNFILTERED=$(ViashDockerAutodetectMount "$VIASH_PAR_RSEC_MOLS_PER_CELL_UNFILTERED")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_RSEC_MOLS_PER_CELL_UNFILTERED" )
fi
if [ ! -z "$VIASH_PAR_BAM" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_BAM")" )
  VIASH_PAR_BAM=$(ViashDockerAutodetectMount "$VIASH_PAR_BAM")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_BAM" )
fi
if [ ! -z "$VIASH_PAR_BAM_INDEX" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_BAM_INDEX")" )
  VIASH_PAR_BAM_INDEX=$(ViashDockerAutodetectMount "$VIASH_PAR_BAM_INDEX")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_BAM_INDEX" )
fi
if [ ! -z "$VIASH_PAR_BIOPRODUCT_STATS" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_BIOPRODUCT_STATS")" )
  VIASH_PAR_BIOPRODUCT_STATS=$(ViashDockerAutodetectMount "$VIASH_PAR_BIOPRODUCT_STATS")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_BIOPRODUCT_STATS" )
fi
if [ ! -z "$VIASH_PAR_DIMRED_TSNE" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_DIMRED_TSNE")" )
  VIASH_PAR_DIMRED_TSNE=$(ViashDockerAutodetectMount "$VIASH_PAR_DIMRED_TSNE")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_DIMRED_TSNE" )
fi
if [ ! -z "$VIASH_PAR_DIMRED_UMAP" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_DIMRED_UMAP")" )
  VIASH_PAR_DIMRED_UMAP=$(ViashDockerAutodetectMount "$VIASH_PAR_DIMRED_UMAP")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_DIMRED_UMAP" )
fi
if [ ! -z "$VIASH_PAR_IMMUNE_CELL_CLASSIFICATION" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_IMMUNE_CELL_CLASSIFICATION")" )
  VIASH_PAR_IMMUNE_CELL_CLASSIFICATION=$(ViashDockerAutodetectMount "$VIASH_PAR_IMMUNE_CELL_CLASSIFICATION")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_IMMUNE_CELL_CLASSIFICATION" )
fi
if [ ! -z "$VIASH_PAR_SAMPLE_TAG_METRICS" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_SAMPLE_TAG_METRICS")" )
  VIASH_PAR_SAMPLE_TAG_METRICS=$(ViashDockerAutodetectMount "$VIASH_PAR_SAMPLE_TAG_METRICS")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_SAMPLE_TAG_METRICS" )
fi
if [ ! -z "$VIASH_PAR_SAMPLE_TAG_CALLS" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_SAMPLE_TAG_CALLS")" )
  VIASH_PAR_SAMPLE_TAG_CALLS=$(ViashDockerAutodetectMount "$VIASH_PAR_SAMPLE_TAG_CALLS")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_SAMPLE_TAG_CALLS" )
fi
if [ ! -z "$VIASH_PAR_SAMPLE_TAG_COUNTS" ]; then
  VIASH_TEST_SAMPLE_TAG_COUNTS=()
  IFS=';'
  for var in $VIASH_PAR_SAMPLE_TAG_COUNTS; do
    unset IFS
    VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$var")" )
    var=$(ViashDockerAutodetectMount "$var")
    VIASH_TEST_SAMPLE_TAG_COUNTS+=( "$var" )
    VIASH_CHOWN_VARS+=( "$var" )
  done
  VIASH_PAR_SAMPLE_TAG_COUNTS=$(IFS=';' ; echo "${VIASH_TEST_SAMPLE_TAG_COUNTS[*]}")
fi
if [ ! -z "$VIASH_PAR_SAMPLE_TAG_COUNTS_UNASSIGNED" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_SAMPLE_TAG_COUNTS_UNASSIGNED")" )
  VIASH_PAR_SAMPLE_TAG_COUNTS_UNASSIGNED=$(ViashDockerAutodetectMount "$VIASH_PAR_SAMPLE_TAG_COUNTS_UNASSIGNED")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_SAMPLE_TAG_COUNTS_UNASSIGNED" )
fi
if [ ! -z "$VIASH_PAR_VDJ_METRICS" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_VDJ_METRICS")" )
  VIASH_PAR_VDJ_METRICS=$(ViashDockerAutodetectMount "$VIASH_PAR_VDJ_METRICS")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_VDJ_METRICS" )
fi
if [ ! -z "$VIASH_PAR_VDJ_PER_CELL" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_VDJ_PER_CELL")" )
  VIASH_PAR_VDJ_PER_CELL=$(ViashDockerAutodetectMount "$VIASH_PAR_VDJ_PER_CELL")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_VDJ_PER_CELL" )
fi
if [ ! -z "$VIASH_PAR_VDJ_PER_CELL_UNCORRECTED" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_VDJ_PER_CELL_UNCORRECTED")" )
  VIASH_PAR_VDJ_PER_CELL_UNCORRECTED=$(ViashDockerAutodetectMount "$VIASH_PAR_VDJ_PER_CELL_UNCORRECTED")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_VDJ_PER_CELL_UNCORRECTED" )
fi
if [ ! -z "$VIASH_PAR_VDJ_DOMINANT_CONTIGS" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_VDJ_DOMINANT_CONTIGS")" )
  VIASH_PAR_VDJ_DOMINANT_CONTIGS=$(ViashDockerAutodetectMount "$VIASH_PAR_VDJ_DOMINANT_CONTIGS")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_VDJ_DOMINANT_CONTIGS" )
fi
if [ ! -z "$VIASH_PAR_VDJ_UNFILTERED_CONTIGS" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_VDJ_UNFILTERED_CONTIGS")" )
  VIASH_PAR_VDJ_UNFILTERED_CONTIGS=$(ViashDockerAutodetectMount "$VIASH_PAR_VDJ_UNFILTERED_CONTIGS")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_VDJ_UNFILTERED_CONTIGS" )
fi
if [ ! -z "$VIASH_PAR_ATAC_METRICS" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_ATAC_METRICS")" )
  VIASH_PAR_ATAC_METRICS=$(ViashDockerAutodetectMount "$VIASH_PAR_ATAC_METRICS")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_ATAC_METRICS" )
fi
if [ ! -z "$VIASH_PAR_ATAC_METRICS_JSON" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_ATAC_METRICS_JSON")" )
  VIASH_PAR_ATAC_METRICS_JSON=$(ViashDockerAutodetectMount "$VIASH_PAR_ATAC_METRICS_JSON")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_ATAC_METRICS_JSON" )
fi
if [ ! -z "$VIASH_PAR_ATAC_FRAGMENTS" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_ATAC_FRAGMENTS")" )
  VIASH_PAR_ATAC_FRAGMENTS=$(ViashDockerAutodetectMount "$VIASH_PAR_ATAC_FRAGMENTS")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_ATAC_FRAGMENTS" )
fi
if [ ! -z "$VIASH_PAR_ATAC_FRAGMENTS_INDEX" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_ATAC_FRAGMENTS_INDEX")" )
  VIASH_PAR_ATAC_FRAGMENTS_INDEX=$(ViashDockerAutodetectMount "$VIASH_PAR_ATAC_FRAGMENTS_INDEX")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_ATAC_FRAGMENTS_INDEX" )
fi
if [ ! -z "$VIASH_PAR_ATAC_TRANSPOSASE_SITES" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_ATAC_TRANSPOSASE_SITES")" )
  VIASH_PAR_ATAC_TRANSPOSASE_SITES=$(ViashDockerAutodetectMount "$VIASH_PAR_ATAC_TRANSPOSASE_SITES")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_ATAC_TRANSPOSASE_SITES" )
fi
if [ ! -z "$VIASH_PAR_ATAC_TRANSPOSASE_SITES_INDEX" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_ATAC_TRANSPOSASE_SITES_INDEX")" )
  VIASH_PAR_ATAC_TRANSPOSASE_SITES_INDEX=$(ViashDockerAutodetectMount "$VIASH_PAR_ATAC_TRANSPOSASE_SITES_INDEX")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_ATAC_TRANSPOSASE_SITES_INDEX" )
fi
if [ ! -z "$VIASH_PAR_ATAC_PEAKS" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_ATAC_PEAKS")" )
  VIASH_PAR_ATAC_PEAKS=$(ViashDockerAutodetectMount "$VIASH_PAR_ATAC_PEAKS")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_ATAC_PEAKS" )
fi
if [ ! -z "$VIASH_PAR_ATAC_PEAKS_INDEX" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_ATAC_PEAKS_INDEX")" )
  VIASH_PAR_ATAC_PEAKS_INDEX=$(ViashDockerAutodetectMount "$VIASH_PAR_ATAC_PEAKS_INDEX")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_ATAC_PEAKS_INDEX" )
fi
if [ ! -z "$VIASH_PAR_ATAC_PEAK_ANNOTATION" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_ATAC_PEAK_ANNOTATION")" )
  VIASH_PAR_ATAC_PEAK_ANNOTATION=$(ViashDockerAutodetectMount "$VIASH_PAR_ATAC_PEAK_ANNOTATION")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_ATAC_PEAK_ANNOTATION" )
fi
if [ ! -z "$VIASH_PAR_ATAC_CELL_BY_PEAK" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_ATAC_CELL_BY_PEAK")" )
  VIASH_PAR_ATAC_CELL_BY_PEAK=$(ViashDockerAutodetectMount "$VIASH_PAR_ATAC_CELL_BY_PEAK")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_ATAC_CELL_BY_PEAK" )
fi
if [ ! -z "$VIASH_PAR_ATAC_CELL_BY_PEAK_UNFILTERED" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_ATAC_CELL_BY_PEAK_UNFILTERED")" )
  VIASH_PAR_ATAC_CELL_BY_PEAK_UNFILTERED=$(ViashDockerAutodetectMount "$VIASH_PAR_ATAC_CELL_BY_PEAK_UNFILTERED")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_ATAC_CELL_BY_PEAK_UNFILTERED" )
fi
if [ ! -z "$VIASH_PAR_ATAC_BAM" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_ATAC_BAM")" )
  VIASH_PAR_ATAC_BAM=$(ViashDockerAutodetectMount "$VIASH_PAR_ATAC_BAM")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_ATAC_BAM" )
fi
if [ ! -z "$VIASH_PAR_ATAC_BAM_INDEX" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_ATAC_BAM_INDEX")" )
  VIASH_PAR_ATAC_BAM_INDEX=$(ViashDockerAutodetectMount "$VIASH_PAR_ATAC_BAM_INDEX")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_ATAC_BAM_INDEX" )
fi
if [ ! -z "$VIASH_PAR_PROTEIN_AGGREGATES_EXPERIMENTAL" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_PROTEIN_AGGREGATES_EXPERIMENTAL")" )
  VIASH_PAR_PROTEIN_AGGREGATES_EXPERIMENTAL=$(ViashDockerAutodetectMount "$VIASH_PAR_PROTEIN_AGGREGATES_EXPERIMENTAL")
  VIASH_CHOWN_VARS+=( "$VIASH_PAR_PROTEIN_AGGREGATES_EXPERIMENTAL" )
fi
if [ ! -z "$VIASH_PAR_PREDEFINED_ATAC_PEAKS" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_PAR_PREDEFINED_ATAC_PEAKS")" )
  VIASH_PAR_PREDEFINED_ATAC_PEAKS=$(ViashDockerAutodetectMount "$VIASH_PAR_PREDEFINED_ATAC_PEAKS")
fi
if [ ! -z "$VIASH_META_RESOURCES_DIR" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_META_RESOURCES_DIR")" )
  VIASH_META_RESOURCES_DIR=$(ViashDockerAutodetectMount "$VIASH_META_RESOURCES_DIR")
fi
if [ ! -z "$VIASH_META_EXECUTABLE" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_META_EXECUTABLE")" )
  VIASH_META_EXECUTABLE=$(ViashDockerAutodetectMount "$VIASH_META_EXECUTABLE")
fi
if [ ! -z "$VIASH_META_CONFIG" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_META_CONFIG")" )
  VIASH_META_CONFIG=$(ViashDockerAutodetectMount "$VIASH_META_CONFIG")
fi
if [ ! -z "$VIASH_META_TEMP_DIR" ]; then
  VIASH_DIRECTORY_MOUNTS+=( "$(ViashDockerAutodetectMountArg "$VIASH_META_TEMP_DIR")" )
  VIASH_META_TEMP_DIR=$(ViashDockerAutodetectMount "$VIASH_META_TEMP_DIR")
fi
  
  # get unique mounts
  VIASH_UNIQUE_MOUNTS=($(for val in "${VIASH_DIRECTORY_MOUNTS[@]}"; do echo "$val"; done | sort -u))
fi

if [[ "$VIASH_ENGINE_TYPE" == "docker" ]]; then
  # change file ownership
  function ViashPerformChown {
    if (( ${#VIASH_CHOWN_VARS[@]} )); then
      set +e
      VIASH_CMD="docker run --entrypoint=bash --rm ${VIASH_UNIQUE_MOUNTS[@]} $VIASH_DOCKER_IMAGE_ID -c 'chown $(id -u):$(id -g) --silent --recursive ${VIASH_CHOWN_VARS[@]}'"
      ViashDebug "+ $VIASH_CMD"
      eval $VIASH_CMD
      set -e
    fi
  }
  trap ViashPerformChown EXIT
fi

if [[ "$VIASH_ENGINE_TYPE" == "docker" ]]; then
  # helper function for filling in extra docker args
  if [ ! -z "$VIASH_META_MEMORY_B" ]; then
    VIASH_DOCKER_RUN_ARGS+=("--memory=${VIASH_META_MEMORY_B}")
  fi
  if [ ! -z "$VIASH_META_CPUS" ]; then
    VIASH_DOCKER_RUN_ARGS+=("--cpus=${VIASH_META_CPUS}")
  fi
fi

if [[ "$VIASH_ENGINE_TYPE" == "docker" ]]; then
  VIASH_CMD="docker run --entrypoint=bash ${VIASH_DOCKER_RUN_ARGS[@]} ${VIASH_UNIQUE_MOUNTS[@]} $VIASH_DOCKER_IMAGE_ID"
fi


# set dependency paths


ViashDebug "Running command: $(echo $VIASH_CMD)"
cat << VIASHEOF | eval $VIASH_CMD
set -e
tempscript=\$(mktemp "$VIASH_META_TEMP_DIR/viash-run-bd_rhapsody-XXXXXX").py
function clean_up {
  rm "\$tempscript"
}
function interrupt {
  echo -e "\nCTRL-C Pressed..."
  exit 1
}
trap clean_up EXIT
trap interrupt INT SIGINT
cat > "\$tempscript" << 'VIASHMAIN'
import os
import re
import subprocess
import tempfile
from typing import Any
import yaml
import shutil
import glob

## VIASH START
# The following code has been auto-generated by Viash.
par = {
  'reads': $( if [ ! -z ${VIASH_PAR_READS+x} ]; then echo "r'${VIASH_PAR_READS//\'/\'\"\'\"r\'}'.split(';')"; else echo None; fi ),
  'reads_atac': $( if [ ! -z ${VIASH_PAR_READS_ATAC+x} ]; then echo "r'${VIASH_PAR_READS_ATAC//\'/\'\"\'\"r\'}'.split(';')"; else echo None; fi ),
  'reference_archive': $( if [ ! -z ${VIASH_PAR_REFERENCE_ARCHIVE+x} ]; then echo "r'${VIASH_PAR_REFERENCE_ARCHIVE//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'targeted_reference': $( if [ ! -z ${VIASH_PAR_TARGETED_REFERENCE+x} ]; then echo "r'${VIASH_PAR_TARGETED_REFERENCE//\'/\'\"\'\"r\'}'.split(';')"; else echo None; fi ),
  'abseq_reference': $( if [ ! -z ${VIASH_PAR_ABSEQ_REFERENCE+x} ]; then echo "r'${VIASH_PAR_ABSEQ_REFERENCE//\'/\'\"\'\"r\'}'.split(';')"; else echo None; fi ),
  'supplemental_reference': $( if [ ! -z ${VIASH_PAR_SUPPLEMENTAL_REFERENCE+x} ]; then echo "r'${VIASH_PAR_SUPPLEMENTAL_REFERENCE//\'/\'\"\'\"r\'}'.split(';')"; else echo None; fi ),
  'output_dir': $( if [ ! -z ${VIASH_PAR_OUTPUT_DIR+x} ]; then echo "r'${VIASH_PAR_OUTPUT_DIR//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'output_seurat': $( if [ ! -z ${VIASH_PAR_OUTPUT_SEURAT+x} ]; then echo "r'${VIASH_PAR_OUTPUT_SEURAT//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'output_mudata': $( if [ ! -z ${VIASH_PAR_OUTPUT_MUDATA+x} ]; then echo "r'${VIASH_PAR_OUTPUT_MUDATA//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'metrics_summary': $( if [ ! -z ${VIASH_PAR_METRICS_SUMMARY+x} ]; then echo "r'${VIASH_PAR_METRICS_SUMMARY//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'pipeline_report': $( if [ ! -z ${VIASH_PAR_PIPELINE_REPORT+x} ]; then echo "r'${VIASH_PAR_PIPELINE_REPORT//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'rsec_mols_per_cell': $( if [ ! -z ${VIASH_PAR_RSEC_MOLS_PER_CELL+x} ]; then echo "r'${VIASH_PAR_RSEC_MOLS_PER_CELL//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'dbec_mols_per_cell': $( if [ ! -z ${VIASH_PAR_DBEC_MOLS_PER_CELL+x} ]; then echo "r'${VIASH_PAR_DBEC_MOLS_PER_CELL//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'rsec_mols_per_cell_unfiltered': $( if [ ! -z ${VIASH_PAR_RSEC_MOLS_PER_CELL_UNFILTERED+x} ]; then echo "r'${VIASH_PAR_RSEC_MOLS_PER_CELL_UNFILTERED//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'bam': $( if [ ! -z ${VIASH_PAR_BAM+x} ]; then echo "r'${VIASH_PAR_BAM//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'bam_index': $( if [ ! -z ${VIASH_PAR_BAM_INDEX+x} ]; then echo "r'${VIASH_PAR_BAM_INDEX//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'bioproduct_stats': $( if [ ! -z ${VIASH_PAR_BIOPRODUCT_STATS+x} ]; then echo "r'${VIASH_PAR_BIOPRODUCT_STATS//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'dimred_tsne': $( if [ ! -z ${VIASH_PAR_DIMRED_TSNE+x} ]; then echo "r'${VIASH_PAR_DIMRED_TSNE//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'dimred_umap': $( if [ ! -z ${VIASH_PAR_DIMRED_UMAP+x} ]; then echo "r'${VIASH_PAR_DIMRED_UMAP//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'immune_cell_classification': $( if [ ! -z ${VIASH_PAR_IMMUNE_CELL_CLASSIFICATION+x} ]; then echo "r'${VIASH_PAR_IMMUNE_CELL_CLASSIFICATION//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'sample_tag_metrics': $( if [ ! -z ${VIASH_PAR_SAMPLE_TAG_METRICS+x} ]; then echo "r'${VIASH_PAR_SAMPLE_TAG_METRICS//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'sample_tag_calls': $( if [ ! -z ${VIASH_PAR_SAMPLE_TAG_CALLS+x} ]; then echo "r'${VIASH_PAR_SAMPLE_TAG_CALLS//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'sample_tag_counts': $( if [ ! -z ${VIASH_PAR_SAMPLE_TAG_COUNTS+x} ]; then echo "r'${VIASH_PAR_SAMPLE_TAG_COUNTS//\'/\'\"\'\"r\'}'.split(';')"; else echo None; fi ),
  'sample_tag_counts_unassigned': $( if [ ! -z ${VIASH_PAR_SAMPLE_TAG_COUNTS_UNASSIGNED+x} ]; then echo "r'${VIASH_PAR_SAMPLE_TAG_COUNTS_UNASSIGNED//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'vdj_metrics': $( if [ ! -z ${VIASH_PAR_VDJ_METRICS+x} ]; then echo "r'${VIASH_PAR_VDJ_METRICS//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'vdj_per_cell': $( if [ ! -z ${VIASH_PAR_VDJ_PER_CELL+x} ]; then echo "r'${VIASH_PAR_VDJ_PER_CELL//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'vdj_per_cell_uncorrected': $( if [ ! -z ${VIASH_PAR_VDJ_PER_CELL_UNCORRECTED+x} ]; then echo "r'${VIASH_PAR_VDJ_PER_CELL_UNCORRECTED//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'vdj_dominant_contigs': $( if [ ! -z ${VIASH_PAR_VDJ_DOMINANT_CONTIGS+x} ]; then echo "r'${VIASH_PAR_VDJ_DOMINANT_CONTIGS//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'vdj_unfiltered_contigs': $( if [ ! -z ${VIASH_PAR_VDJ_UNFILTERED_CONTIGS+x} ]; then echo "r'${VIASH_PAR_VDJ_UNFILTERED_CONTIGS//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'atac_metrics': $( if [ ! -z ${VIASH_PAR_ATAC_METRICS+x} ]; then echo "r'${VIASH_PAR_ATAC_METRICS//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'atac_metrics_json': $( if [ ! -z ${VIASH_PAR_ATAC_METRICS_JSON+x} ]; then echo "r'${VIASH_PAR_ATAC_METRICS_JSON//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'atac_fragments': $( if [ ! -z ${VIASH_PAR_ATAC_FRAGMENTS+x} ]; then echo "r'${VIASH_PAR_ATAC_FRAGMENTS//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'atac_fragments_index': $( if [ ! -z ${VIASH_PAR_ATAC_FRAGMENTS_INDEX+x} ]; then echo "r'${VIASH_PAR_ATAC_FRAGMENTS_INDEX//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'atac_transposase_sites': $( if [ ! -z ${VIASH_PAR_ATAC_TRANSPOSASE_SITES+x} ]; then echo "r'${VIASH_PAR_ATAC_TRANSPOSASE_SITES//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'atac_transposase_sites_index': $( if [ ! -z ${VIASH_PAR_ATAC_TRANSPOSASE_SITES_INDEX+x} ]; then echo "r'${VIASH_PAR_ATAC_TRANSPOSASE_SITES_INDEX//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'atac_peaks': $( if [ ! -z ${VIASH_PAR_ATAC_PEAKS+x} ]; then echo "r'${VIASH_PAR_ATAC_PEAKS//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'atac_peaks_index': $( if [ ! -z ${VIASH_PAR_ATAC_PEAKS_INDEX+x} ]; then echo "r'${VIASH_PAR_ATAC_PEAKS_INDEX//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'atac_peak_annotation': $( if [ ! -z ${VIASH_PAR_ATAC_PEAK_ANNOTATION+x} ]; then echo "r'${VIASH_PAR_ATAC_PEAK_ANNOTATION//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'atac_cell_by_peak': $( if [ ! -z ${VIASH_PAR_ATAC_CELL_BY_PEAK+x} ]; then echo "r'${VIASH_PAR_ATAC_CELL_BY_PEAK//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'atac_cell_by_peak_unfiltered': $( if [ ! -z ${VIASH_PAR_ATAC_CELL_BY_PEAK_UNFILTERED+x} ]; then echo "r'${VIASH_PAR_ATAC_CELL_BY_PEAK_UNFILTERED//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'atac_bam': $( if [ ! -z ${VIASH_PAR_ATAC_BAM+x} ]; then echo "r'${VIASH_PAR_ATAC_BAM//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'atac_bam_index': $( if [ ! -z ${VIASH_PAR_ATAC_BAM_INDEX+x} ]; then echo "r'${VIASH_PAR_ATAC_BAM_INDEX//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'protein_aggregates_experimental': $( if [ ! -z ${VIASH_PAR_PROTEIN_AGGREGATES_EXPERIMENTAL+x} ]; then echo "r'${VIASH_PAR_PROTEIN_AGGREGATES_EXPERIMENTAL//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'cell_calling_data': $( if [ ! -z ${VIASH_PAR_CELL_CALLING_DATA+x} ]; then echo "r'${VIASH_PAR_CELL_CALLING_DATA//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'cell_calling_bioproduct_algorithm': $( if [ ! -z ${VIASH_PAR_CELL_CALLING_BIOPRODUCT_ALGORITHM+x} ]; then echo "r'${VIASH_PAR_CELL_CALLING_BIOPRODUCT_ALGORITHM//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'cell_calling_atac_algorithm': $( if [ ! -z ${VIASH_PAR_CELL_CALLING_ATAC_ALGORITHM+x} ]; then echo "r'${VIASH_PAR_CELL_CALLING_ATAC_ALGORITHM//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'exact_cell_count': $( if [ ! -z ${VIASH_PAR_EXACT_CELL_COUNT+x} ]; then echo "int(r'${VIASH_PAR_EXACT_CELL_COUNT//\'/\'\"\'\"r\'}')"; else echo None; fi ),
  'expected_cell_count': $( if [ ! -z ${VIASH_PAR_EXPECTED_CELL_COUNT+x} ]; then echo "int(r'${VIASH_PAR_EXPECTED_CELL_COUNT//\'/\'\"\'\"r\'}')"; else echo None; fi ),
  'exclude_intronic_reads': $( if [ ! -z ${VIASH_PAR_EXCLUDE_INTRONIC_READS+x} ]; then echo "r'${VIASH_PAR_EXCLUDE_INTRONIC_READS//\'/\'\"\'\"r\'}'.lower() == 'true'"; else echo None; fi ),
  'sample_tags_version': $( if [ ! -z ${VIASH_PAR_SAMPLE_TAGS_VERSION+x} ]; then echo "r'${VIASH_PAR_SAMPLE_TAGS_VERSION//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'tag_names': $( if [ ! -z ${VIASH_PAR_TAG_NAMES+x} ]; then echo "r'${VIASH_PAR_TAG_NAMES//\'/\'\"\'\"r\'}'.split(';')"; else echo None; fi ),
  'vdj_version': $( if [ ! -z ${VIASH_PAR_VDJ_VERSION+x} ]; then echo "r'${VIASH_PAR_VDJ_VERSION//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'predefined_atac_peaks': $( if [ ! -z ${VIASH_PAR_PREDEFINED_ATAC_PEAKS+x} ]; then echo "r'${VIASH_PAR_PREDEFINED_ATAC_PEAKS//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'run_name': $( if [ ! -z ${VIASH_PAR_RUN_NAME+x} ]; then echo "r'${VIASH_PAR_RUN_NAME//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'generate_bam': $( if [ ! -z ${VIASH_PAR_GENERATE_BAM+x} ]; then echo "r'${VIASH_PAR_GENERATE_BAM//\'/\'\"\'\"r\'}'.lower() == 'true'"; else echo None; fi ),
  'long_reads': $( if [ ! -z ${VIASH_PAR_LONG_READS+x} ]; then echo "r'${VIASH_PAR_LONG_READS//\'/\'\"\'\"r\'}'.lower() == 'true'"; else echo None; fi ),
  'custom_star_params': $( if [ ! -z ${VIASH_PAR_CUSTOM_STAR_PARAMS+x} ]; then echo "r'${VIASH_PAR_CUSTOM_STAR_PARAMS//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'custom_bwa_mem2_params': $( if [ ! -z ${VIASH_PAR_CUSTOM_BWA_MEM2_PARAMS+x} ]; then echo "r'${VIASH_PAR_CUSTOM_BWA_MEM2_PARAMS//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'parallel': $( if [ ! -z ${VIASH_PAR_PARALLEL+x} ]; then echo "r'${VIASH_PAR_PARALLEL//\'/\'\"\'\"r\'}'.lower() == 'true'"; else echo None; fi ),
  'timestamps': $( if [ ! -z ${VIASH_PAR_TIMESTAMPS+x} ]; then echo "r'${VIASH_PAR_TIMESTAMPS//\'/\'\"\'\"r\'}'.lower() == 'true'"; else echo None; fi ),
  'abseq_umi': $( if [ ! -z ${VIASH_PAR_ABSEQ_UMI+x} ]; then echo "int(r'${VIASH_PAR_ABSEQ_UMI//\'/\'\"\'\"r\'}')"; else echo None; fi ),
  'target_analysis': $( if [ ! -z ${VIASH_PAR_TARGET_ANALYSIS+x} ]; then echo "r'${VIASH_PAR_TARGET_ANALYSIS//\'/\'\"\'\"r\'}'.lower() == 'true'"; else echo None; fi ),
  'vdj_jgene_evalue': $( if [ ! -z ${VIASH_PAR_VDJ_JGENE_EVALUE+x} ]; then echo "float(r'${VIASH_PAR_VDJ_JGENE_EVALUE//\'/\'\"\'\"r\'}')"; else echo None; fi ),
  'vdj_vgene_evalue': $( if [ ! -z ${VIASH_PAR_VDJ_VGENE_EVALUE+x} ]; then echo "float(r'${VIASH_PAR_VDJ_VGENE_EVALUE//\'/\'\"\'\"r\'}')"; else echo None; fi ),
  'write_filtered_reads': $( if [ ! -z ${VIASH_PAR_WRITE_FILTERED_READS+x} ]; then echo "r'${VIASH_PAR_WRITE_FILTERED_READS//\'/\'\"\'\"r\'}'.lower() == 'true'"; else echo None; fi )
}
meta = {
  'name': $( if [ ! -z ${VIASH_META_NAME+x} ]; then echo "r'${VIASH_META_NAME//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'functionality_name': $( if [ ! -z ${VIASH_META_FUNCTIONALITY_NAME+x} ]; then echo "r'${VIASH_META_FUNCTIONALITY_NAME//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'resources_dir': $( if [ ! -z ${VIASH_META_RESOURCES_DIR+x} ]; then echo "r'${VIASH_META_RESOURCES_DIR//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'executable': $( if [ ! -z ${VIASH_META_EXECUTABLE+x} ]; then echo "r'${VIASH_META_EXECUTABLE//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'config': $( if [ ! -z ${VIASH_META_CONFIG+x} ]; then echo "r'${VIASH_META_CONFIG//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'temp_dir': $( if [ ! -z ${VIASH_META_TEMP_DIR+x} ]; then echo "r'${VIASH_META_TEMP_DIR//\'/\'\"\'\"r\'}'"; else echo None; fi ),
  'cpus': $( if [ ! -z ${VIASH_META_CPUS+x} ]; then echo "int(r'${VIASH_META_CPUS//\'/\'\"\'\"r\'}')"; else echo None; fi ),
  'memory_b': $( if [ ! -z ${VIASH_META_MEMORY_B+x} ]; then echo "int(r'${VIASH_META_MEMORY_B//\'/\'\"\'\"r\'}')"; else echo None; fi ),
  'memory_kb': $( if [ ! -z ${VIASH_META_MEMORY_KB+x} ]; then echo "int(r'${VIASH_META_MEMORY_KB//\'/\'\"\'\"r\'}')"; else echo None; fi ),
  'memory_mb': $( if [ ! -z ${VIASH_META_MEMORY_MB+x} ]; then echo "int(r'${VIASH_META_MEMORY_MB//\'/\'\"\'\"r\'}')"; else echo None; fi ),
  'memory_gb': $( if [ ! -z ${VIASH_META_MEMORY_GB+x} ]; then echo "int(r'${VIASH_META_MEMORY_GB//\'/\'\"\'\"r\'}')"; else echo None; fi ),
  'memory_tb': $( if [ ! -z ${VIASH_META_MEMORY_TB+x} ]; then echo "int(r'${VIASH_META_MEMORY_TB//\'/\'\"\'\"r\'}')"; else echo None; fi ),
  'memory_pb': $( if [ ! -z ${VIASH_META_MEMORY_PB+x} ]; then echo "int(r'${VIASH_META_MEMORY_PB//\'/\'\"\'\"r\'}')"; else echo None; fi ),
  'memory_kib': $( if [ ! -z ${VIASH_META_MEMORY_KIB+x} ]; then echo "int(r'${VIASH_META_MEMORY_KIB//\'/\'\"\'\"r\'}')"; else echo None; fi ),
  'memory_mib': $( if [ ! -z ${VIASH_META_MEMORY_MIB+x} ]; then echo "int(r'${VIASH_META_MEMORY_MIB//\'/\'\"\'\"r\'}')"; else echo None; fi ),
  'memory_gib': $( if [ ! -z ${VIASH_META_MEMORY_GIB+x} ]; then echo "int(r'${VIASH_META_MEMORY_GIB//\'/\'\"\'\"r\'}')"; else echo None; fi ),
  'memory_tib': $( if [ ! -z ${VIASH_META_MEMORY_TIB+x} ]; then echo "int(r'${VIASH_META_MEMORY_TIB//\'/\'\"\'\"r\'}')"; else echo None; fi ),
  'memory_pib': $( if [ ! -z ${VIASH_META_MEMORY_PIB+x} ]; then echo "int(r'${VIASH_META_MEMORY_PIB//\'/\'\"\'\"r\'}')"; else echo None; fi )
}
dep = {
  
}

## VIASH END


def clean_arg(argument):
    argument["clean_name"] = re.sub("^-*", "", argument["name"])
    return argument


def read_config(path: str) -> dict[str, Any]:
    with open(path, "r") as f:
        config = yaml.safe_load(f)

    config["arguments"] = [
        clean_arg(arg) for grp in config["argument_groups"] for arg in grp["arguments"]
    ]

    return config


def strip_margin(text: str) -> str:
    return re.sub("(\\n?)[ \\t]*\\|", "\\\\1", text)


def process_params(par: dict[str, Any], config, temp_dir: str) -> str:
    # check input parameters
    assert par["reads"] or par["reads_atac"], (
        "Pass at least one set of inputs to --reads or --reads_atac."
    )

    # output to temp dir if output_dir was not passed
    if not par["output_dir"]:
        par["output_dir"] = os.path.join(temp_dir, "output")

    # checking sample prefix
    if par["run_name"] and re.match("[^A-Za-z0-9]", par["run_name"]):
        print(
            "--run_name should only consist of letters, numbers or hyphens. Replacing all '[^A-Za-z0-9]' with '-'.",
            flush=True,
        )
        par["run_name"] = re.sub("[^A-Za-z0-9\\\\-]", "-", par["run_name"])

    # make paths absolute
    for argument in config["arguments"]:
        if par[argument["clean_name"]] and argument["type"] == "file":
            if isinstance(par[argument["clean_name"]], list):
                par[argument["clean_name"]] = [
                    os.path.abspath(f) for f in par[argument["clean_name"]]
                ]
            else:
                par[argument["clean_name"]] = os.path.abspath(
                    par[argument["clean_name"]]
                )

    return par


def generate_config(par: dict[str, Any], config) -> str:
    content_list = [
        strip_margin("""\\
        |#!/usr/bin/env cwl-runner
        |
        |cwl:tool: rhapsody
        |""")
    ]

    for argument in config["arguments"]:
        arg_info = argument.get("info") or {}
        config_key = arg_info.get("config_key")
        if par[argument["clean_name"]] and config_key:
            if argument["type"] == "file":
                str = strip_margin(f"""\\
                    |{config_key}:
                    |""")
                if isinstance(par[argument["clean_name"]], list):
                    for file in par[argument["clean_name"]]:
                        str += strip_margin(f"""\\
                            | - class: File
                            |   location: "{file}"
                            |""")
                else:
                    str += strip_margin(f"""\\
                        |   class: File
                        |   location: "{par[argument["clean_name"]]}"
                        |""")
                content_list.append(str)
            else:
                content_list.append(
                    strip_margin(f"""\\
                    |{config_key}: {par[argument["clean_name"]]}
                    |""")
                )

    ## Write config to file
    return "".join(content_list)


def generate_config_file(
    par: dict[str, Any], config: dict[str, Any], temp_dir: str
) -> str:
    config_file = os.path.join(temp_dir, "config.yml")
    config_content = generate_config(par, config)
    with open(config_file, "w") as f:
        f.write(config_content)
    return config_file


def generate_cwl_file(meta: dict[str, Any], dir: str) -> str:
    # create cwl file (if need be)
    orig_cwl_file = os.path.join(
        meta["resources_dir"], "rhapsody_pipeline_2.2.1_nodocker.cwl"
    )

    # Inject computational requirements into pipeline
    if meta["memory_mb"] or meta["cpus"]:
        cwl_file = os.path.join(dir, "pipeline.cwl")

        # Read in the file
        with open(orig_cwl_file, "r") as file:
            cwl_data = file.read()

        # Inject computational requirements into pipeline
        if meta["memory_mb"]:
            memory = int(meta["memory_mb"]) - 2000  # keep 2gb for OS
            cwl_data = re.sub(
                '"ramMin": [^\\n]*[^,](,?)\\n', f'"ramMin": {memory}\\\\1\\n', cwl_data
            )
        if meta["cpus"]:
            cwl_data = re.sub(
                '"coresMin": [^\\n]*[^,](,?)\\n',
                f'"coresMin": {meta["cpus"]}\\\\1\\n',
                cwl_data,
            )

        # Write the file out again
        with open(cwl_file, "w") as file:
            file.write(cwl_data)
    else:
        cwl_file = orig_cwl_file

    return cwl_file


def copy_outputs(par: dict[str, Any], config: dict[str, Any]):
    for arg in config["arguments"]:
        par_value = par[arg["clean_name"]]
        if par_value and arg["type"] == "file" and arg["direction"] == "output":
            # example template: '[sample_name]_(assay)_cell_type_experimental.csv'
            template = (arg.get("info") or {}).get("template")
            if template:
                template_glob = (
                    template.replace("sample", par["run_name"])
                    .replace("assay", "*")
                    .replace("number", "*")
                )
                files = glob.glob(os.path.join(par["output_dir"], template_glob))
                if len(files) == 0 and arg["required"]:
                    raise ValueError(
                        f"Expected output file '{template_glob}' not found."
                    )
                elif len(files) > 1 and not arg["multiple"]:
                    raise ValueError(
                        f"Expected single output file '{template_glob}', but found multiple."
                    )

                if not arg["multiple"]:
                    try:
                        shutil.copy(files[0], par_value)
                        print(f"Copied {files[0]} to {par_value}")
                    except IndexError:
                        print(f"Unable to copy {template_glob} to {par_value}")
                else:
                    # replace '*' in par_value with index
                    for i, file in enumerate(files):
                        shutil.copy(file, par_value.replace("*", str(i)))


def main(par: dict[str, Any], meta: dict[str, Any], temp_dir: str):
    config = read_config(meta["config"])

    # Preprocess params
    par = process_params(par, config, temp_dir)

    ## Process parameters
    cmd = [
        "cwl-runner",
        "--no-container",
        "--preserve-entire-environment",
        "--outdir",
        par["output_dir"],
    ]

    if par["parallel"]:
        cmd.append("--parallel")

    if par["timestamps"]:
        cmd.append("--timestamps")

    # Create cwl file (if need be)
    cwl_file = generate_cwl_file(meta, temp_dir)
    cmd.append(cwl_file)

    # Create params file
    config_file = generate_config_file(par, config, temp_dir)
    cmd.append(config_file)

    # keep environment variables but set TMPDIR to temp_dir
    env = dict(os.environ)
    env["TMPDIR"] = temp_dir

    # Create output dir if not exists
    if not os.path.exists(par["output_dir"]):
        os.makedirs(par["output_dir"])

    # Run command
    print("> " + " ".join(cmd), flush=True)
    _ = subprocess.check_call(cmd, cwd=os.path.dirname(config_file), env=env)

    # Copy outputs
    copy_outputs(par, config)


if __name__ == "__main__":
    with tempfile.TemporaryDirectory(
        prefix="cwl-bd_rhapsody-", dir=meta["temp_dir"]
    ) as temp_dir:
        main(par, meta, temp_dir)
VIASHMAIN
python -B "\$tempscript" &
wait "\$!"

VIASHEOF


if [[ "$VIASH_ENGINE_TYPE" == "docker" ]]; then
  # strip viash automount from file paths
  
  if [ ! -z "$VIASH_PAR_READS" ]; then
    unset VIASH_TEST_READS
    IFS=';'
    for var in $VIASH_PAR_READS; do
      unset IFS
      if [ -z "$VIASH_TEST_READS" ]; then
      VIASH_TEST_READS="$(ViashDockerStripAutomount "$var")"
    else
      VIASH_TEST_READS="$VIASH_TEST_READS;""$(ViashDockerStripAutomount "$var")"
    fi
    done
    VIASH_PAR_READS="$VIASH_TEST_READS"
  fi
  if [ ! -z "$VIASH_PAR_READS_ATAC" ]; then
    unset VIASH_TEST_READS_ATAC
    IFS=';'
    for var in $VIASH_PAR_READS_ATAC; do
      unset IFS
      if [ -z "$VIASH_TEST_READS_ATAC" ]; then
      VIASH_TEST_READS_ATAC="$(ViashDockerStripAutomount "$var")"
    else
      VIASH_TEST_READS_ATAC="$VIASH_TEST_READS_ATAC;""$(ViashDockerStripAutomount "$var")"
    fi
    done
    VIASH_PAR_READS_ATAC="$VIASH_TEST_READS_ATAC"
  fi
  if [ ! -z "$VIASH_PAR_REFERENCE_ARCHIVE" ]; then
    VIASH_PAR_REFERENCE_ARCHIVE=$(ViashDockerStripAutomount "$VIASH_PAR_REFERENCE_ARCHIVE")
  fi
  if [ ! -z "$VIASH_PAR_TARGETED_REFERENCE" ]; then
    unset VIASH_TEST_TARGETED_REFERENCE
    IFS=';'
    for var in $VIASH_PAR_TARGETED_REFERENCE; do
      unset IFS
      if [ -z "$VIASH_TEST_TARGETED_REFERENCE" ]; then
      VIASH_TEST_TARGETED_REFERENCE="$(ViashDockerStripAutomount "$var")"
    else
      VIASH_TEST_TARGETED_REFERENCE="$VIASH_TEST_TARGETED_REFERENCE;""$(ViashDockerStripAutomount "$var")"
    fi
    done
    VIASH_PAR_TARGETED_REFERENCE="$VIASH_TEST_TARGETED_REFERENCE"
  fi
  if [ ! -z "$VIASH_PAR_ABSEQ_REFERENCE" ]; then
    unset VIASH_TEST_ABSEQ_REFERENCE
    IFS=';'
    for var in $VIASH_PAR_ABSEQ_REFERENCE; do
      unset IFS
      if [ -z "$VIASH_TEST_ABSEQ_REFERENCE" ]; then
      VIASH_TEST_ABSEQ_REFERENCE="$(ViashDockerStripAutomount "$var")"
    else
      VIASH_TEST_ABSEQ_REFERENCE="$VIASH_TEST_ABSEQ_REFERENCE;""$(ViashDockerStripAutomount "$var")"
    fi
    done
    VIASH_PAR_ABSEQ_REFERENCE="$VIASH_TEST_ABSEQ_REFERENCE"
  fi
  if [ ! -z "$VIASH_PAR_SUPPLEMENTAL_REFERENCE" ]; then
    unset VIASH_TEST_SUPPLEMENTAL_REFERENCE
    IFS=';'
    for var in $VIASH_PAR_SUPPLEMENTAL_REFERENCE; do
      unset IFS
      if [ -z "$VIASH_TEST_SUPPLEMENTAL_REFERENCE" ]; then
      VIASH_TEST_SUPPLEMENTAL_REFERENCE="$(ViashDockerStripAutomount "$var")"
    else
      VIASH_TEST_SUPPLEMENTAL_REFERENCE="$VIASH_TEST_SUPPLEMENTAL_REFERENCE;""$(ViashDockerStripAutomount "$var")"
    fi
    done
    VIASH_PAR_SUPPLEMENTAL_REFERENCE="$VIASH_TEST_SUPPLEMENTAL_REFERENCE"
  fi
  if [ ! -z "$VIASH_PAR_OUTPUT_DIR" ]; then
    VIASH_PAR_OUTPUT_DIR=$(ViashDockerStripAutomount "$VIASH_PAR_OUTPUT_DIR")
  fi
  if [ ! -z "$VIASH_PAR_OUTPUT_SEURAT" ]; then
    VIASH_PAR_OUTPUT_SEURAT=$(ViashDockerStripAutomount "$VIASH_PAR_OUTPUT_SEURAT")
  fi
  if [ ! -z "$VIASH_PAR_OUTPUT_MUDATA" ]; then
    VIASH_PAR_OUTPUT_MUDATA=$(ViashDockerStripAutomount "$VIASH_PAR_OUTPUT_MUDATA")
  fi
  if [ ! -z "$VIASH_PAR_METRICS_SUMMARY" ]; then
    VIASH_PAR_METRICS_SUMMARY=$(ViashDockerStripAutomount "$VIASH_PAR_METRICS_SUMMARY")
  fi
  if [ ! -z "$VIASH_PAR_PIPELINE_REPORT" ]; then
    VIASH_PAR_PIPELINE_REPORT=$(ViashDockerStripAutomount "$VIASH_PAR_PIPELINE_REPORT")
  fi
  if [ ! -z "$VIASH_PAR_RSEC_MOLS_PER_CELL" ]; then
    VIASH_PAR_RSEC_MOLS_PER_CELL=$(ViashDockerStripAutomount "$VIASH_PAR_RSEC_MOLS_PER_CELL")
  fi
  if [ ! -z "$VIASH_PAR_DBEC_MOLS_PER_CELL" ]; then
    VIASH_PAR_DBEC_MOLS_PER_CELL=$(ViashDockerStripAutomount "$VIASH_PAR_DBEC_MOLS_PER_CELL")
  fi
  if [ ! -z "$VIASH_PAR_RSEC_MOLS_PER_CELL_UNFILTERED" ]; then
    VIASH_PAR_RSEC_MOLS_PER_CELL_UNFILTERED=$(ViashDockerStripAutomount "$VIASH_PAR_RSEC_MOLS_PER_CELL_UNFILTERED")
  fi
  if [ ! -z "$VIASH_PAR_BAM" ]; then
    VIASH_PAR_BAM=$(ViashDockerStripAutomount "$VIASH_PAR_BAM")
  fi
  if [ ! -z "$VIASH_PAR_BAM_INDEX" ]; then
    VIASH_PAR_BAM_INDEX=$(ViashDockerStripAutomount "$VIASH_PAR_BAM_INDEX")
  fi
  if [ ! -z "$VIASH_PAR_BIOPRODUCT_STATS" ]; then
    VIASH_PAR_BIOPRODUCT_STATS=$(ViashDockerStripAutomount "$VIASH_PAR_BIOPRODUCT_STATS")
  fi
  if [ ! -z "$VIASH_PAR_DIMRED_TSNE" ]; then
    VIASH_PAR_DIMRED_TSNE=$(ViashDockerStripAutomount "$VIASH_PAR_DIMRED_TSNE")
  fi
  if [ ! -z "$VIASH_PAR_DIMRED_UMAP" ]; then
    VIASH_PAR_DIMRED_UMAP=$(ViashDockerStripAutomount "$VIASH_PAR_DIMRED_UMAP")
  fi
  if [ ! -z "$VIASH_PAR_IMMUNE_CELL_CLASSIFICATION" ]; then
    VIASH_PAR_IMMUNE_CELL_CLASSIFICATION=$(ViashDockerStripAutomount "$VIASH_PAR_IMMUNE_CELL_CLASSIFICATION")
  fi
  if [ ! -z "$VIASH_PAR_SAMPLE_TAG_METRICS" ]; then
    VIASH_PAR_SAMPLE_TAG_METRICS=$(ViashDockerStripAutomount "$VIASH_PAR_SAMPLE_TAG_METRICS")
  fi
  if [ ! -z "$VIASH_PAR_SAMPLE_TAG_CALLS" ]; then
    VIASH_PAR_SAMPLE_TAG_CALLS=$(ViashDockerStripAutomount "$VIASH_PAR_SAMPLE_TAG_CALLS")
  fi
  if [ ! -z "$VIASH_PAR_SAMPLE_TAG_COUNTS" ]; then
    VIASH_PAR_SAMPLE_TAG_COUNTS=$(ViashDockerStripAutomount "$VIASH_PAR_SAMPLE_TAG_COUNTS")
  fi
  if [ ! -z "$VIASH_PAR_SAMPLE_TAG_COUNTS_UNASSIGNED" ]; then
    VIASH_PAR_SAMPLE_TAG_COUNTS_UNASSIGNED=$(ViashDockerStripAutomount "$VIASH_PAR_SAMPLE_TAG_COUNTS_UNASSIGNED")
  fi
  if [ ! -z "$VIASH_PAR_VDJ_METRICS" ]; then
    VIASH_PAR_VDJ_METRICS=$(ViashDockerStripAutomount "$VIASH_PAR_VDJ_METRICS")
  fi
  if [ ! -z "$VIASH_PAR_VDJ_PER_CELL" ]; then
    VIASH_PAR_VDJ_PER_CELL=$(ViashDockerStripAutomount "$VIASH_PAR_VDJ_PER_CELL")
  fi
  if [ ! -z "$VIASH_PAR_VDJ_PER_CELL_UNCORRECTED" ]; then
    VIASH_PAR_VDJ_PER_CELL_UNCORRECTED=$(ViashDockerStripAutomount "$VIASH_PAR_VDJ_PER_CELL_UNCORRECTED")
  fi
  if [ ! -z "$VIASH_PAR_VDJ_DOMINANT_CONTIGS" ]; then
    VIASH_PAR_VDJ_DOMINANT_CONTIGS=$(ViashDockerStripAutomount "$VIASH_PAR_VDJ_DOMINANT_CONTIGS")
  fi
  if [ ! -z "$VIASH_PAR_VDJ_UNFILTERED_CONTIGS" ]; then
    VIASH_PAR_VDJ_UNFILTERED_CONTIGS=$(ViashDockerStripAutomount "$VIASH_PAR_VDJ_UNFILTERED_CONTIGS")
  fi
  if [ ! -z "$VIASH_PAR_ATAC_METRICS" ]; then
    VIASH_PAR_ATAC_METRICS=$(ViashDockerStripAutomount "$VIASH_PAR_ATAC_METRICS")
  fi
  if [ ! -z "$VIASH_PAR_ATAC_METRICS_JSON" ]; then
    VIASH_PAR_ATAC_METRICS_JSON=$(ViashDockerStripAutomount "$VIASH_PAR_ATAC_METRICS_JSON")
  fi
  if [ ! -z "$VIASH_PAR_ATAC_FRAGMENTS" ]; then
    VIASH_PAR_ATAC_FRAGMENTS=$(ViashDockerStripAutomount "$VIASH_PAR_ATAC_FRAGMENTS")
  fi
  if [ ! -z "$VIASH_PAR_ATAC_FRAGMENTS_INDEX" ]; then
    VIASH_PAR_ATAC_FRAGMENTS_INDEX=$(ViashDockerStripAutomount "$VIASH_PAR_ATAC_FRAGMENTS_INDEX")
  fi
  if [ ! -z "$VIASH_PAR_ATAC_TRANSPOSASE_SITES" ]; then
    VIASH_PAR_ATAC_TRANSPOSASE_SITES=$(ViashDockerStripAutomount "$VIASH_PAR_ATAC_TRANSPOSASE_SITES")
  fi
  if [ ! -z "$VIASH_PAR_ATAC_TRANSPOSASE_SITES_INDEX" ]; then
    VIASH_PAR_ATAC_TRANSPOSASE_SITES_INDEX=$(ViashDockerStripAutomount "$VIASH_PAR_ATAC_TRANSPOSASE_SITES_INDEX")
  fi
  if [ ! -z "$VIASH_PAR_ATAC_PEAKS" ]; then
    VIASH_PAR_ATAC_PEAKS=$(ViashDockerStripAutomount "$VIASH_PAR_ATAC_PEAKS")
  fi
  if [ ! -z "$VIASH_PAR_ATAC_PEAKS_INDEX" ]; then
    VIASH_PAR_ATAC_PEAKS_INDEX=$(ViashDockerStripAutomount "$VIASH_PAR_ATAC_PEAKS_INDEX")
  fi
  if [ ! -z "$VIASH_PAR_ATAC_PEAK_ANNOTATION" ]; then
    VIASH_PAR_ATAC_PEAK_ANNOTATION=$(ViashDockerStripAutomount "$VIASH_PAR_ATAC_PEAK_ANNOTATION")
  fi
  if [ ! -z "$VIASH_PAR_ATAC_CELL_BY_PEAK" ]; then
    VIASH_PAR_ATAC_CELL_BY_PEAK=$(ViashDockerStripAutomount "$VIASH_PAR_ATAC_CELL_BY_PEAK")
  fi
  if [ ! -z "$VIASH_PAR_ATAC_CELL_BY_PEAK_UNFILTERED" ]; then
    VIASH_PAR_ATAC_CELL_BY_PEAK_UNFILTERED=$(ViashDockerStripAutomount "$VIASH_PAR_ATAC_CELL_BY_PEAK_UNFILTERED")
  fi
  if [ ! -z "$VIASH_PAR_ATAC_BAM" ]; then
    VIASH_PAR_ATAC_BAM=$(ViashDockerStripAutomount "$VIASH_PAR_ATAC_BAM")
  fi
  if [ ! -z "$VIASH_PAR_ATAC_BAM_INDEX" ]; then
    VIASH_PAR_ATAC_BAM_INDEX=$(ViashDockerStripAutomount "$VIASH_PAR_ATAC_BAM_INDEX")
  fi
  if [ ! -z "$VIASH_PAR_PROTEIN_AGGREGATES_EXPERIMENTAL" ]; then
    VIASH_PAR_PROTEIN_AGGREGATES_EXPERIMENTAL=$(ViashDockerStripAutomount "$VIASH_PAR_PROTEIN_AGGREGATES_EXPERIMENTAL")
  fi
  if [ ! -z "$VIASH_PAR_PREDEFINED_ATAC_PEAKS" ]; then
    VIASH_PAR_PREDEFINED_ATAC_PEAKS=$(ViashDockerStripAutomount "$VIASH_PAR_PREDEFINED_ATAC_PEAKS")
  fi
  if [ ! -z "$VIASH_META_RESOURCES_DIR" ]; then
    VIASH_META_RESOURCES_DIR=$(ViashDockerStripAutomount "$VIASH_META_RESOURCES_DIR")
  fi
  if [ ! -z "$VIASH_META_EXECUTABLE" ]; then
    VIASH_META_EXECUTABLE=$(ViashDockerStripAutomount "$VIASH_META_EXECUTABLE")
  fi
  if [ ! -z "$VIASH_META_CONFIG" ]; then
    VIASH_META_CONFIG=$(ViashDockerStripAutomount "$VIASH_META_CONFIG")
  fi
  if [ ! -z "$VIASH_META_TEMP_DIR" ]; then
    VIASH_META_TEMP_DIR=$(ViashDockerStripAutomount "$VIASH_META_TEMP_DIR")
  fi
fi


# check whether required files exist
if [ ! -z "$VIASH_PAR_OUTPUT_DIR" ] && [ ! -e "$VIASH_PAR_OUTPUT_DIR" ]; then
  ViashError "Output file '$VIASH_PAR_OUTPUT_DIR' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_OUTPUT_SEURAT" ] && [ ! -e "$VIASH_PAR_OUTPUT_SEURAT" ]; then
  ViashError "Output file '$VIASH_PAR_OUTPUT_SEURAT' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_OUTPUT_MUDATA" ] && [ ! -e "$VIASH_PAR_OUTPUT_MUDATA" ]; then
  ViashError "Output file '$VIASH_PAR_OUTPUT_MUDATA' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_METRICS_SUMMARY" ] && [ ! -e "$VIASH_PAR_METRICS_SUMMARY" ]; then
  ViashError "Output file '$VIASH_PAR_METRICS_SUMMARY' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_PIPELINE_REPORT" ] && [ ! -e "$VIASH_PAR_PIPELINE_REPORT" ]; then
  ViashError "Output file '$VIASH_PAR_PIPELINE_REPORT' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_RSEC_MOLS_PER_CELL" ] && [ ! -e "$VIASH_PAR_RSEC_MOLS_PER_CELL" ]; then
  ViashError "Output file '$VIASH_PAR_RSEC_MOLS_PER_CELL' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_DBEC_MOLS_PER_CELL" ] && [ ! -e "$VIASH_PAR_DBEC_MOLS_PER_CELL" ]; then
  ViashError "Output file '$VIASH_PAR_DBEC_MOLS_PER_CELL' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_RSEC_MOLS_PER_CELL_UNFILTERED" ] && [ ! -e "$VIASH_PAR_RSEC_MOLS_PER_CELL_UNFILTERED" ]; then
  ViashError "Output file '$VIASH_PAR_RSEC_MOLS_PER_CELL_UNFILTERED' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_BAM" ] && [ ! -e "$VIASH_PAR_BAM" ]; then
  ViashError "Output file '$VIASH_PAR_BAM' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_BAM_INDEX" ] && [ ! -e "$VIASH_PAR_BAM_INDEX" ]; then
  ViashError "Output file '$VIASH_PAR_BAM_INDEX' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_BIOPRODUCT_STATS" ] && [ ! -e "$VIASH_PAR_BIOPRODUCT_STATS" ]; then
  ViashError "Output file '$VIASH_PAR_BIOPRODUCT_STATS' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_DIMRED_TSNE" ] && [ ! -e "$VIASH_PAR_DIMRED_TSNE" ]; then
  ViashError "Output file '$VIASH_PAR_DIMRED_TSNE' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_DIMRED_UMAP" ] && [ ! -e "$VIASH_PAR_DIMRED_UMAP" ]; then
  ViashError "Output file '$VIASH_PAR_DIMRED_UMAP' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_IMMUNE_CELL_CLASSIFICATION" ] && [ ! -e "$VIASH_PAR_IMMUNE_CELL_CLASSIFICATION" ]; then
  ViashError "Output file '$VIASH_PAR_IMMUNE_CELL_CLASSIFICATION' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_SAMPLE_TAG_METRICS" ] && [ ! -e "$VIASH_PAR_SAMPLE_TAG_METRICS" ]; then
  ViashError "Output file '$VIASH_PAR_SAMPLE_TAG_METRICS' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_SAMPLE_TAG_CALLS" ] && [ ! -e "$VIASH_PAR_SAMPLE_TAG_CALLS" ]; then
  ViashError "Output file '$VIASH_PAR_SAMPLE_TAG_CALLS' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_SAMPLE_TAG_COUNTS" ] && ! compgen -G "$VIASH_PAR_SAMPLE_TAG_COUNTS" > /dev/null; then
  ViashError "Output file '$VIASH_PAR_SAMPLE_TAG_COUNTS' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_SAMPLE_TAG_COUNTS_UNASSIGNED" ] && [ ! -e "$VIASH_PAR_SAMPLE_TAG_COUNTS_UNASSIGNED" ]; then
  ViashError "Output file '$VIASH_PAR_SAMPLE_TAG_COUNTS_UNASSIGNED' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_VDJ_METRICS" ] && [ ! -e "$VIASH_PAR_VDJ_METRICS" ]; then
  ViashError "Output file '$VIASH_PAR_VDJ_METRICS' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_VDJ_PER_CELL" ] && [ ! -e "$VIASH_PAR_VDJ_PER_CELL" ]; then
  ViashError "Output file '$VIASH_PAR_VDJ_PER_CELL' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_VDJ_PER_CELL_UNCORRECTED" ] && [ ! -e "$VIASH_PAR_VDJ_PER_CELL_UNCORRECTED" ]; then
  ViashError "Output file '$VIASH_PAR_VDJ_PER_CELL_UNCORRECTED' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_VDJ_DOMINANT_CONTIGS" ] && [ ! -e "$VIASH_PAR_VDJ_DOMINANT_CONTIGS" ]; then
  ViashError "Output file '$VIASH_PAR_VDJ_DOMINANT_CONTIGS' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_VDJ_UNFILTERED_CONTIGS" ] && [ ! -e "$VIASH_PAR_VDJ_UNFILTERED_CONTIGS" ]; then
  ViashError "Output file '$VIASH_PAR_VDJ_UNFILTERED_CONTIGS' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_ATAC_METRICS" ] && [ ! -e "$VIASH_PAR_ATAC_METRICS" ]; then
  ViashError "Output file '$VIASH_PAR_ATAC_METRICS' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_ATAC_METRICS_JSON" ] && [ ! -e "$VIASH_PAR_ATAC_METRICS_JSON" ]; then
  ViashError "Output file '$VIASH_PAR_ATAC_METRICS_JSON' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_ATAC_FRAGMENTS" ] && [ ! -e "$VIASH_PAR_ATAC_FRAGMENTS" ]; then
  ViashError "Output file '$VIASH_PAR_ATAC_FRAGMENTS' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_ATAC_FRAGMENTS_INDEX" ] && [ ! -e "$VIASH_PAR_ATAC_FRAGMENTS_INDEX" ]; then
  ViashError "Output file '$VIASH_PAR_ATAC_FRAGMENTS_INDEX' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_ATAC_TRANSPOSASE_SITES" ] && [ ! -e "$VIASH_PAR_ATAC_TRANSPOSASE_SITES" ]; then
  ViashError "Output file '$VIASH_PAR_ATAC_TRANSPOSASE_SITES' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_ATAC_TRANSPOSASE_SITES_INDEX" ] && [ ! -e "$VIASH_PAR_ATAC_TRANSPOSASE_SITES_INDEX" ]; then
  ViashError "Output file '$VIASH_PAR_ATAC_TRANSPOSASE_SITES_INDEX' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_ATAC_PEAKS" ] && [ ! -e "$VIASH_PAR_ATAC_PEAKS" ]; then
  ViashError "Output file '$VIASH_PAR_ATAC_PEAKS' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_ATAC_PEAKS_INDEX" ] && [ ! -e "$VIASH_PAR_ATAC_PEAKS_INDEX" ]; then
  ViashError "Output file '$VIASH_PAR_ATAC_PEAKS_INDEX' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_ATAC_PEAK_ANNOTATION" ] && [ ! -e "$VIASH_PAR_ATAC_PEAK_ANNOTATION" ]; then
  ViashError "Output file '$VIASH_PAR_ATAC_PEAK_ANNOTATION' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_ATAC_CELL_BY_PEAK" ] && [ ! -e "$VIASH_PAR_ATAC_CELL_BY_PEAK" ]; then
  ViashError "Output file '$VIASH_PAR_ATAC_CELL_BY_PEAK' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_ATAC_CELL_BY_PEAK_UNFILTERED" ] && [ ! -e "$VIASH_PAR_ATAC_CELL_BY_PEAK_UNFILTERED" ]; then
  ViashError "Output file '$VIASH_PAR_ATAC_CELL_BY_PEAK_UNFILTERED' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_ATAC_BAM" ] && [ ! -e "$VIASH_PAR_ATAC_BAM" ]; then
  ViashError "Output file '$VIASH_PAR_ATAC_BAM' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_ATAC_BAM_INDEX" ] && [ ! -e "$VIASH_PAR_ATAC_BAM_INDEX" ]; then
  ViashError "Output file '$VIASH_PAR_ATAC_BAM_INDEX' does not exist."
  exit 1
fi
if [ ! -z "$VIASH_PAR_PROTEIN_AGGREGATES_EXPERIMENTAL" ] && [ ! -e "$VIASH_PAR_PROTEIN_AGGREGATES_EXPERIMENTAL" ]; then
  ViashError "Output file '$VIASH_PAR_PROTEIN_AGGREGATES_EXPERIMENTAL' does not exist."
  exit 1
fi


exit 0
