#!/usr/bin/env bash
#
# mixcr Bash Completion
# =======================
#
# Bash completion support for the `mixcr` command,
# generated by [picocli](http://picocli.info/) version 3.6.1.
#
# Installation
# ------------
#
# 1. Source all completion scripts in your .bash_profile
#
#   cd $YOUR_APP_HOME/bin
#   for f in $(find . -name "*_completion"); do line=". $(pwd)/$f"; grep "$line" ~/.bash_profile || echo "$line" >> ~/.bash_profile; done
#
# 2. Open a new bash console, and type `mixcr [TAB][TAB]`
#
# 1a. Alternatively, if you have [bash-completion](https://github.com/scop/bash-completion) installed:
#     Place this file in a `bash-completion.d` folder:
#
#   * /etc/bash-completion.d
#   * /usr/local/etc/bash-completion.d
#   * ~/bash-completion.d
#
# Documentation
# -------------
# The script is called by bash whenever [TAB] or [TAB][TAB] is pressed after
# 'mixcr (..)'. By reading entered command line parameters,
# it determines possible bash completions and writes them to the COMPREPLY variable.
# Bash then completes the user input if only one entry is listed in the variable or
# shows the options if more than one is listed in COMPREPLY.
#
# References
# ----------
# [1] http://stackoverflow.com/a/12495480/1440785
# [2] http://tiswww.case.edu/php/chet/bash/FAQ
# [3] https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html
# [4] http://zsh.sourceforge.net/Doc/Release/Options.html#index-COMPLETE_005fALIASES
# [5] https://stackoverflow.com/questions/17042057/bash-check-element-in-array-for-elements-in-another-array/17042655#17042655
# [6] https://www.gnu.org/software/bash/manual/html_node/Programmable-Completion.html#Programmable-Completion
#

if [ -n "$BASH_VERSION" ]; then
  # Enable programmable completion facilities when using bash (see [3])
  shopt -s progcomp
elif [ -n "$ZSH_VERSION" ]; then
  # Make alias a distinct command for completion purposes when using zsh (see [4])
  setopt COMPLETE_ALIASES
  alias compopt=complete
fi

# ArrContains takes two arguments, both of which are the name of arrays.
# It creates a temporary hash from lArr1 and then checks if all elements of lArr2
# are in the hashtable.
#
# Returns zero (no error) if all elements of the 2nd array are in the 1st array,
# otherwise returns 1 (error).
#
# Modified from [5]
function ArrContains() {
  local lArr1 lArr2
  declare -A tmp
  eval lArr1=("\"\${$1[@]}\"")
  eval lArr2=("\"\${$2[@]}\"")
  for i in "${lArr1[@]}";{ [ -n "$i" ] && ((++tmp[$i]));}
  for i in "${lArr2[@]}";{ [ -n "$i" ] && [ -z "${tmp[$i]}" ] && return 1;}
  return 0
}

# Bash completion entry point function.
# _complete_mixcr finds which commands and subcommands have been specified
# on the command line and delegates to the appropriate function
# to generate possible options and subcommands for the last specified subcommand.
function _complete_mixcr() {
  CMDS0=(help)
  CMDS1=(analyze)
  CMDS2=(align)
  CMDS3=(assemble)
  CMDS4=(assembleContigs)
  CMDS5=(assemblePartial)
  CMDS6=(extend)
  CMDS7=(exportAlignments)
  CMDS8=(exportAlignmentsPretty)
  CMDS9=(exportClones)
  CMDS10=(exportClonesPretty)
  CMDS11=(exportReadsForClones)
  CMDS12=(exportReads)
  CMDS13=(mergeAlignments)
  CMDS14=(filterAlignments)
  CMDS15=(sortAlignments)
  CMDS16=(alignmentsDiff)
  CMDS17=(clonesDiff)
  CMDS18=(alignmentsStat)
  CMDS19=(listLibraries)
  CMDS20=(versionInfo)
  CMDS21=(pipelineInfo)
  CMDS22=(slice)
  CMDS23=(info)
  CMDS24=(analyze help)
  CMDS25=(analyze amplicon)
  CMDS26=(analyze shotgun)

  ArrContains COMP_WORDS CMDS26 && { _picocli_mixcr_analyze_shotgun; return $?; }
  ArrContains COMP_WORDS CMDS25 && { _picocli_mixcr_analyze_amplicon; return $?; }
  ArrContains COMP_WORDS CMDS24 && { _picocli_mixcr_analyze_help; return $?; }
  ArrContains COMP_WORDS CMDS23 && { _picocli_mixcr_info; return $?; }
  ArrContains COMP_WORDS CMDS22 && { _picocli_mixcr_slice; return $?; }
  ArrContains COMP_WORDS CMDS21 && { _picocli_mixcr_pipelineInfo; return $?; }
  ArrContains COMP_WORDS CMDS20 && { _picocli_mixcr_versionInfo; return $?; }
  ArrContains COMP_WORDS CMDS19 && { _picocli_mixcr_listLibraries; return $?; }
  ArrContains COMP_WORDS CMDS18 && { _picocli_mixcr_alignmentsStat; return $?; }
  ArrContains COMP_WORDS CMDS17 && { _picocli_mixcr_clonesDiff; return $?; }
  ArrContains COMP_WORDS CMDS16 && { _picocli_mixcr_alignmentsDiff; return $?; }
  ArrContains COMP_WORDS CMDS15 && { _picocli_mixcr_sortAlignments; return $?; }
  ArrContains COMP_WORDS CMDS14 && { _picocli_mixcr_filterAlignments; return $?; }
  ArrContains COMP_WORDS CMDS13 && { _picocli_mixcr_mergeAlignments; return $?; }
  ArrContains COMP_WORDS CMDS12 && { _picocli_mixcr_exportReads; return $?; }
  ArrContains COMP_WORDS CMDS11 && { _picocli_mixcr_exportReadsForClones; return $?; }
  ArrContains COMP_WORDS CMDS10 && { _picocli_mixcr_exportClonesPretty; return $?; }
  ArrContains COMP_WORDS CMDS9 && { _picocli_mixcr_exportClones; return $?; }
  ArrContains COMP_WORDS CMDS8 && { _picocli_mixcr_exportAlignmentsPretty; return $?; }
  ArrContains COMP_WORDS CMDS7 && { _picocli_mixcr_exportAlignments; return $?; }
  ArrContains COMP_WORDS CMDS6 && { _picocli_mixcr_extend; return $?; }
  ArrContains COMP_WORDS CMDS5 && { _picocli_mixcr_assemblePartial; return $?; }
  ArrContains COMP_WORDS CMDS4 && { _picocli_mixcr_assembleContigs; return $?; }
  ArrContains COMP_WORDS CMDS3 && { _picocli_mixcr_assemble; return $?; }
  ArrContains COMP_WORDS CMDS2 && { _picocli_mixcr_align; return $?; }
  ArrContains COMP_WORDS CMDS1 && { _picocli_mixcr_analyze; return $?; }
  ArrContains COMP_WORDS CMDS0 && { _picocli_mixcr_help; return $?; }

  # No subcommands were specified; generate completions for the top-level command.
  _picocli_mixcr; return $?;
}

# Generates completions for the options and subcommands of the `mixcr` command.
function _picocli_mixcr() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS="help analyze align assemble assembleContigs assemblePartial extend exportAlignments exportAlignmentsPretty exportClones exportClonesPretty exportReadsForClones exportReads mergeAlignments filterAlignments sortAlignments alignmentsDiff clonesDiff alignmentsStat listLibraries versionInfo pipelineInfo slice info"
  FLAG_OPTS="-h --help -v --version -h --help"
  ARG_OPTS=""

  if [[ "${CURR_WORD}" == -* ]]; then
    COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS}" -- ${CURR_WORD}) )
  else
    COMPREPLY=( $(compgen -W "${COMMANDS}" -- ${CURR_WORD}) )
  fi
}

# Generates completions for the options and subcommands of the `help` subcommand.
function _picocli_mixcr_help() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-h --help"
  ARG_OPTS=""

  if [[ "${CURR_WORD}" == -* ]]; then
    COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS}" -- ${CURR_WORD}) )
  else
    COMPREPLY=( $(compgen -W "${COMMANDS}" -- ${CURR_WORD}) )
  fi
}

# Generates completions for the options and subcommands of the `analyze` subcommand.
function _picocli_mixcr_analyze() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS="help amplicon shotgun"
  FLAG_OPTS=""
  ARG_OPTS=""

  if [[ "${CURR_WORD}" == -* ]]; then
    COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS}" -- ${CURR_WORD}) )
  else
    COMPREPLY=( $(compgen -W "${COMMANDS}" -- ${CURR_WORD}) )
  fi
}

# Generates completions for the options and subcommands of the `align` subcommand.
function _picocli_mixcr_align() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-h --help -nw --no-warnings --verbose -f --force-overwrite --force --overwrite-if-required -d --no-merge --write-all --buffers -a --save-description -g --save-reads"
  ARG_OPTS="-s --species -r --report --json-report -b --library -p --parameters -O --not-aligned-R1 --not-aligned-R2 -n --limit -t --threads -c --chains"

  compopt +o default

  case ${PREV_WORD} in
    -s|--species)
      return
      ;;
    -r|--report)
      return
      ;;
    --json-report)
      return
      ;;
    -b|--library)
      return
      ;;
    -p|--parameters)
      return
      ;;
    -O)
      return
      ;;
    --not-aligned-R1)
      return
      ;;
    --not-aligned-R2)
      return
      ;;
    -n|--limit)
      return
      ;;
    -t|--threads)
      return
      ;;
    -c|--chains)
      return
      ;;
  esac

  if [[ "${CURR_WORD}" == -* ]]; then
    COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS}" -- ${CURR_WORD}) )
  else
    COMPREPLY=( $(compgen -W "${COMMANDS}" -- ${CURR_WORD}) )
  fi
}

# Generates completions for the options and subcommands of the `assemble` subcommand.
function _picocli_mixcr_assemble() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-h --help -nw --no-warnings --verbose -f --force-overwrite --force --overwrite-if-required --buffers -a --write-alignments"
  ARG_OPTS="-p --parameters -r --report --json-report -O -t --threads"

  compopt +o default

  case ${PREV_WORD} in
    -p|--parameters)
      return
      ;;
    -r|--report)
      return
      ;;
    --json-report)
      return
      ;;
    -O)
      return
      ;;
    -t|--threads)
      return
      ;;
  esac

  if [[ "${CURR_WORD}" == -* ]]; then
    COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS}" -- ${CURR_WORD}) )
  else
    COMPREPLY=( $(compgen -W "${COMMANDS}" -- ${CURR_WORD}) )
  fi
}

# Generates completions for the options and subcommands of the `assembleContigs` subcommand.
function _picocli_mixcr_assembleContigs() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-h --help -nw --no-warnings --verbose -f --force-overwrite --force --overwrite-if-required"
  ARG_OPTS="-O -r --report --debug-report --json-report -t --threads"

  compopt +o default

  case ${PREV_WORD} in
    -O)
      return
      ;;
    -r|--report)
      return
      ;;
    --debug-report)
      return
      ;;
    --json-report)
      return
      ;;
    -t|--threads)
      return
      ;;
  esac

  if [[ "${CURR_WORD}" == -* ]]; then
    COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS}" -- ${CURR_WORD}) )
  else
    COMPREPLY=( $(compgen -W "${COMMANDS}" -- ${CURR_WORD}) )
  fi
}

# Generates completions for the options and subcommands of the `assemblePartial` subcommand.
function _picocli_mixcr_assemblePartial() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-h --help -nw --no-warnings --verbose -f --force-overwrite --force --overwrite-if-required -o --overlapped-only -d --drop-partial"
  ARG_OPTS="-O -r --report --json-report"

  compopt +o default

  case ${PREV_WORD} in
    -O)
      return
      ;;
    -r|--report)
      return
      ;;
    --json-report)
      return
      ;;
  esac

  if [[ "${CURR_WORD}" == -* ]]; then
    COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS}" -- ${CURR_WORD}) )
  else
    COMPREPLY=( $(compgen -W "${COMMANDS}" -- ${CURR_WORD}) )
  fi
}

# Generates completions for the options and subcommands of the `extend` subcommand.
function _picocli_mixcr_extend() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-h --help -nw --no-warnings --verbose -f --force-overwrite --force --overwrite-if-required"
  ARG_OPTS="-c --chains -r --report --json-report -q --quality --v-anchor --j-anchor --min-v-score --min-j-score -t --threads"

  compopt +o default

  case ${PREV_WORD} in
    -c|--chains)
      return
      ;;
    -r|--report)
      return
      ;;
    --json-report)
      return
      ;;
    -q|--quality)
      return
      ;;
    --v-anchor)
      return
      ;;
    --j-anchor)
      return
      ;;
    --min-v-score)
      return
      ;;
    --min-j-score)
      return
      ;;
    -t|--threads)
      return
      ;;
  esac

  if [[ "${CURR_WORD}" == -* ]]; then
    COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS}" -- ${CURR_WORD}) )
  else
    COMPREPLY=( $(compgen -W "${COMMANDS}" -- ${CURR_WORD}) )
  fi
}

# Generates completions for the options and subcommands of the `exportAlignments` subcommand.
function _picocli_mixcr_exportAlignments() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-h --help -nw --no-warnings --verbose -f --force-overwrite --force -v --with-spaces -lf --list-fields -s --no-spaces -targets -vHit -dHit -jHit -cHit -vGene -dGene -jGene -cGene -vFamily -dFamily -jFamily -cFamily -vHitScore -dHitScore -jHitScore -cHitScore -vHitsWithScore -dHitsWithScore -jHitsWithScore -cHitsWithScore -vHits -dHits -jHits -cHits -vGenes -dGenes -jGenes -cGenes -vFamilies -dFamilies -jFamilies -cFamilies -vAlignment -dAlignment -jAlignment -cAlignment -vAlignments -dAlignments -jAlignments -cAlignments -defaultAnchorPoints -readId -readIds -sequence -quality -descrR1 -descrR2 -descrsR1 -descrsR2 -readHistory -cloneId -cloneIdWithMappingType -vIdentityPercents -dIdentityPercents -jIdentityPercents -cIdentityPercents -vBestIdentityPercent -dBestIdentityPercent -jBestIdentityPercent -cBestIdentityPercent -chains -topChains"
  ARG_OPTS="-c --chains -p --preset -pf --preset-file -n --limit -nFeature -qFeature -aaFeature -nFeatureImputed -aaFeatureImputed -minFeatureQuality -avrgFeatureQuality -lengthOf -nMutations -nMutationsRelative -aaMutations -aaMutationsRelative -mutationsDetailed -mutationsDetailedRelative -positionInReferenceOf -positionOf"

  compopt +o default

  case ${PREV_WORD} in
    -c|--chains)
      return
      ;;
    -p|--preset)
      return
      ;;
    -pf|--preset-file)
      return
      ;;
    -n|--limit)
      return
      ;;
    -nFeature)
      return
      ;;
    -qFeature)
      return
      ;;
    -aaFeature)
      return
      ;;
    -nFeatureImputed)
      return
      ;;
    -aaFeatureImputed)
      return
      ;;
    -minFeatureQuality)
      return
      ;;
    -avrgFeatureQuality)
      return
      ;;
    -lengthOf)
      return
      ;;
    -nMutations)
      return
      ;;
    -nMutationsRelative)
      return
      ;;
    -aaMutations)
      return
      ;;
    -aaMutationsRelative)
      return
      ;;
    -mutationsDetailed)
      return
      ;;
    -mutationsDetailedRelative)
      return
      ;;
    -positionInReferenceOf)
      return
      ;;
    -positionOf)
      return
      ;;
  esac

  if [[ "${CURR_WORD}" == -* ]]; then
    COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS}" -- ${CURR_WORD}) )
  else
    COMPREPLY=( $(compgen -W "${COMMANDS}" -- ${CURR_WORD}) )
  fi
}

# Generates completions for the options and subcommands of the `exportAlignmentsPretty` subcommand.
function _picocli_mixcr_exportAlignmentsPretty() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-h --help -nw --no-warnings --verbose -f --force-overwrite --force -t --top -a --gene -d --descriptions"
  ARG_OPTS="-b --limit-before -n --limit -c --chains -s --skip -e --cdr3-equals -g --feature -r --read-contains --filter -i --read-ids"

  compopt +o default

  case ${PREV_WORD} in
    -b|--limit-before)
      return
      ;;
    -n|--limit)
      return
      ;;
    -c|--chains)
      return
      ;;
    -s|--skip)
      return
      ;;
    -e|--cdr3-equals)
      return
      ;;
    -g|--feature)
      return
      ;;
    -r|--read-contains)
      return
      ;;
    --filter)
      return
      ;;
    -i|--read-ids)
      return
      ;;
  esac

  if [[ "${CURR_WORD}" == -* ]]; then
    COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS}" -- ${CURR_WORD}) )
  else
    COMPREPLY=( $(compgen -W "${COMMANDS}" -- ${CURR_WORD}) )
  fi
}

# Generates completions for the options and subcommands of the `exportClones` subcommand.
function _picocli_mixcr_exportClones() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-h --help -nw --no-warnings --verbose -f --force-overwrite --force -v --with-spaces -lf --list-fields -s --no-spaces -o --filter-out-of-frames -t --filter-stops -targets -vHit -dHit -jHit -cHit -vGene -dGene -jGene -cGene -vFamily -dFamily -jFamily -cFamily -vHitScore -dHitScore -jHitScore -cHitScore -vHitsWithScore -dHitsWithScore -jHitsWithScore -cHitsWithScore -vHits -dHits -jHits -cHits -vGenes -dGenes -jGenes -cGenes -vFamilies -dFamilies -jFamilies -cFamilies -vAlignment -dAlignment -jAlignment -cAlignment -vAlignments -dAlignments -jAlignments -cAlignments -defaultAnchorPoints -cloneId -count -fraction -sequence -quality -vIdentityPercents -dIdentityPercents -jIdentityPercents -cIdentityPercents -vBestIdentityPercent -dBestIdentityPercent -jBestIdentityPercent -cBestIdentityPercent -chains -topChains"
  ARG_OPTS="-c --chains -p --preset -pf --preset-file -n --limit -q --minimal-clone-fraction -m --minimal-clone-count -nFeature -qFeature -aaFeature -nFeatureImputed -aaFeatureImputed -minFeatureQuality -avrgFeatureQuality -lengthOf -nMutations -nMutationsRelative -aaMutations -aaMutationsRelative -mutationsDetailed -mutationsDetailedRelative -positionInReferenceOf -positionOf"

  compopt +o default

  case ${PREV_WORD} in
    -c|--chains)
      return
      ;;
    -p|--preset)
      return
      ;;
    -pf|--preset-file)
      return
      ;;
    -n|--limit)
      return
      ;;
    -q|--minimal-clone-fraction)
      return
      ;;
    -m|--minimal-clone-count)
      return
      ;;
    -nFeature)
      return
      ;;
    -qFeature)
      return
      ;;
    -aaFeature)
      return
      ;;
    -nFeatureImputed)
      return
      ;;
    -aaFeatureImputed)
      return
      ;;
    -minFeatureQuality)
      return
      ;;
    -avrgFeatureQuality)
      return
      ;;
    -lengthOf)
      return
      ;;
    -nMutations)
      return
      ;;
    -nMutationsRelative)
      return
      ;;
    -aaMutations)
      return
      ;;
    -aaMutationsRelative)
      return
      ;;
    -mutationsDetailed)
      return
      ;;
    -mutationsDetailedRelative)
      return
      ;;
    -positionInReferenceOf)
      return
      ;;
    -positionOf)
      return
      ;;
  esac

  if [[ "${CURR_WORD}" == -* ]]; then
    COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS}" -- ${CURR_WORD}) )
  else
    COMPREPLY=( $(compgen -W "${COMMANDS}" -- ${CURR_WORD}) )
  fi
}

# Generates completions for the options and subcommands of the `exportClonesPretty` subcommand.
function _picocli_mixcr_exportClonesPretty() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-h --help -nw --no-warnings --verbose -f --force-overwrite --force"
  ARG_OPTS="-b --limitBefore -n --limit -i --clone-ids -s --skip -c --chains -e --cdr3-equals -r --clonal-sequence-contains"

  compopt +o default

  case ${PREV_WORD} in
    -b|--limitBefore)
      return
      ;;
    -n|--limit)
      return
      ;;
    -i|--clone-ids)
      return
      ;;
    -s|--skip)
      return
      ;;
    -c|--chains)
      return
      ;;
    -e|--cdr3-equals)
      return
      ;;
    -r|--clonal-sequence-contains)
      return
      ;;
  esac

  if [[ "${CURR_WORD}" == -* ]]; then
    COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS}" -- ${CURR_WORD}) )
  else
    COMPREPLY=( $(compgen -W "${COMMANDS}" -- ${CURR_WORD}) )
  fi
}

# Generates completions for the options and subcommands of the `exportReadsForClones` subcommand.
function _picocli_mixcr_exportReadsForClones() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-h --help -nw --no-warnings --verbose -f --force-overwrite --force -s --separate"
  ARG_OPTS="--id"

  compopt +o default

  case ${PREV_WORD} in
    --id)
      return
      ;;
  esac

  if [[ "${CURR_WORD}" == -* ]]; then
    COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS}" -- ${CURR_WORD}) )
  else
    COMPREPLY=( $(compgen -W "${COMMANDS}" -- ${CURR_WORD}) )
  fi
}

# Generates completions for the options and subcommands of the `exportReads` subcommand.
function _picocli_mixcr_exportReads() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-h --help -nw --no-warnings --verbose -f --force-overwrite --force"
  ARG_OPTS=""

  if [[ "${CURR_WORD}" == -* ]]; then
    COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS}" -- ${CURR_WORD}) )
  else
    COMPREPLY=( $(compgen -W "${COMMANDS}" -- ${CURR_WORD}) )
  fi
}

# Generates completions for the options and subcommands of the `mergeAlignments` subcommand.
function _picocli_mixcr_mergeAlignments() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-h --help -nw --no-warnings --verbose -f --force-overwrite --force --overwrite-if-required"
  ARG_OPTS=""

  if [[ "${CURR_WORD}" == -* ]]; then
    COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS}" -- ${CURR_WORD}) )
  else
    COMPREPLY=( $(compgen -W "${COMMANDS}" -- ${CURR_WORD}) )
  fi
}

# Generates completions for the options and subcommands of the `filterAlignments` subcommand.
function _picocli_mixcr_filterAlignments() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-h --help -nw --no-warnings --verbose -f --force-overwrite --force --overwrite-if-required -x --chimeras-only"
  ARG_OPTS="-c --chains -g --contains-feature -e --cdr3-equals -i --read-ids -n --limit"

  compopt +o default

  case ${PREV_WORD} in
    -c|--chains)
      return
      ;;
    -g|--contains-feature)
      return
      ;;
    -e|--cdr3-equals)
      return
      ;;
    -i|--read-ids)
      return
      ;;
    -n|--limit)
      return
      ;;
  esac

  if [[ "${CURR_WORD}" == -* ]]; then
    COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS}" -- ${CURR_WORD}) )
  else
    COMPREPLY=( $(compgen -W "${COMMANDS}" -- ${CURR_WORD}) )
  fi
}

# Generates completions for the options and subcommands of the `sortAlignments` subcommand.
function _picocli_mixcr_sortAlignments() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-h --help -nw --no-warnings --verbose -f --force-overwrite --force --overwrite-if-required"
  ARG_OPTS=""

  if [[ "${CURR_WORD}" == -* ]]; then
    COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS}" -- ${CURR_WORD}) )
  else
    COMPREPLY=( $(compgen -W "${COMMANDS}" -- ${CURR_WORD}) )
  fi
}

# Generates completions for the options and subcommands of the `alignmentsDiff` subcommand.
function _picocli_mixcr_alignmentsDiff() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-h --help -nw --no-warnings --verbose -f --force-overwrite --force"
  ARG_OPTS="-o1 --only-in-first -o2 --only-in-second -d1 --diff-from-first -d2 --diff-from-second -g --gene-feature -l --top-hits-level"

  compopt +o default

  case ${PREV_WORD} in
    -o1|--only-in-first)
      return
      ;;
    -o2|--only-in-second)
      return
      ;;
    -d1|--diff-from-first)
      return
      ;;
    -d2|--diff-from-second)
      return
      ;;
    -g|--gene-feature)
      return
      ;;
    -l|--top-hits-level)
      return
      ;;
  esac

  if [[ "${CURR_WORD}" == -* ]]; then
    COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS}" -- ${CURR_WORD}) )
  else
    COMPREPLY=( $(compgen -W "${COMMANDS}" -- ${CURR_WORD}) )
  fi
}

# Generates completions for the options and subcommands of the `clonesDiff` subcommand.
function _picocli_mixcr_clonesDiff() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-h --help -nw --no-warnings --verbose -f --force-overwrite --force -v -j -c"
  ARG_OPTS=""

  if [[ "${CURR_WORD}" == -* ]]; then
    COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS}" -- ${CURR_WORD}) )
  else
    COMPREPLY=( $(compgen -W "${COMMANDS}" -- ${CURR_WORD}) )
  fi
}

# Generates completions for the options and subcommands of the `alignmentsStat` subcommand.
function _picocli_mixcr_alignmentsStat() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-h --help -nw --no-warnings --verbose"
  ARG_OPTS=""

  if [[ "${CURR_WORD}" == -* ]]; then
    COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS}" -- ${CURR_WORD}) )
  else
    COMPREPLY=( $(compgen -W "${COMMANDS}" -- ${CURR_WORD}) )
  fi
}

# Generates completions for the options and subcommands of the `listLibraries` subcommand.
function _picocli_mixcr_listLibraries() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-h --help -nw --no-warnings --verbose"
  ARG_OPTS=""

  if [[ "${CURR_WORD}" == -* ]]; then
    COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS}" -- ${CURR_WORD}) )
  else
    COMPREPLY=( $(compgen -W "${COMMANDS}" -- ${CURR_WORD}) )
  fi
}

# Generates completions for the options and subcommands of the `versionInfo` subcommand.
function _picocli_mixcr_versionInfo() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-h --help -nw --no-warnings --verbose"
  ARG_OPTS=""

  if [[ "${CURR_WORD}" == -* ]]; then
    COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS}" -- ${CURR_WORD}) )
  else
    COMPREPLY=( $(compgen -W "${COMMANDS}" -- ${CURR_WORD}) )
  fi
}

# Generates completions for the options and subcommands of the `pipelineInfo` subcommand.
function _picocli_mixcr_pipelineInfo() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-h --help -nw --no-warnings --verbose --json"
  ARG_OPTS=""

  if [[ "${CURR_WORD}" == -* ]]; then
    COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS}" -- ${CURR_WORD}) )
  else
    COMPREPLY=( $(compgen -W "${COMMANDS}" -- ${CURR_WORD}) )
  fi
}

# Generates completions for the options and subcommands of the `slice` subcommand.
function _picocli_mixcr_slice() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-h --help -nw --no-warnings --verbose -f --force-overwrite --force --overwrite-if-required"
  ARG_OPTS="-i --id"

  compopt +o default

  case ${PREV_WORD} in
    -i|--id)
      return
      ;;
  esac

  if [[ "${CURR_WORD}" == -* ]]; then
    COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS}" -- ${CURR_WORD}) )
  else
    COMPREPLY=( $(compgen -W "${COMMANDS}" -- ${CURR_WORD}) )
  fi
}

# Generates completions for the options and subcommands of the `info` subcommand.
function _picocli_mixcr_info() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-h --help -nw --no-warnings --verbose -t --table"
  ARG_OPTS=""

  if [[ "${CURR_WORD}" == -* ]]; then
    COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS}" -- ${CURR_WORD}) )
  else
    COMPREPLY=( $(compgen -W "${COMMANDS}" -- ${CURR_WORD}) )
  fi
}

# Generates completions for the options and subcommands of the `help` subcommand.
function _picocli_mixcr_analyze_help() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-h --help"
  ARG_OPTS=""

  if [[ "${CURR_WORD}" == -* ]]; then
    COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS}" -- ${CURR_WORD}) )
  else
    COMPREPLY=( $(compgen -W "${COMMANDS}" -- ${CURR_WORD}) )
  fi
}

# Generates completions for the options and subcommands of the `amplicon` subcommand.
function _picocli_mixcr_analyze_amplicon() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-h --help -nw --no-warnings --verbose -f --force-overwrite --force --impute-germline-on-export --only-productive --contig-assembly --do-not-extend-alignments"
  ARG_OPTS="-s --species --starting-material -r --report --align --assemblePartial --extend --assemble --assembleContigs --export --assemble-partial-rounds --receptor-type --5-end --3-end --adapters --region-of-interest"
  startingMaterial_OPTION_ARGS="rna dna" # _StartingMaterial values
  chains_OPTION_ARGS="tcr bcr xcr tra trb trd trg igh igk igl" # --receptor-type values
  5End_OPTION_ARGS="no-v-primers v-primers" # --5-end values
  3End_OPTION_ARGS="j-primers j-c-intron-primers c-primers" # --3-end values
  adapters_OPTION_ARGS="adapters-present no-adapters" # --adapters values

  compopt +o default

  case ${PREV_WORD} in
    -s|--species)
      return
      ;;
    --starting-material)
      COMPREPLY=( $( compgen -W "${startingMaterial_OPTION_ARGS}" -- ${CURR_WORD} ) )
      return $?
      ;;
    -r|--report)
      return
      ;;
    --align)
      return
      ;;
    --assemblePartial)
      return
      ;;
    --extend)
      return
      ;;
    --assemble)
      return
      ;;
    --assembleContigs)
      return
      ;;
    --export)
      return
      ;;
    --assemble-partial-rounds)
      return
      ;;
    --receptor-type)
      COMPREPLY=( $( compgen -W "${chains_OPTION_ARGS}" -- ${CURR_WORD} ) )
      return $?
      ;;
    --5-end)
      COMPREPLY=( $( compgen -W "${5End_OPTION_ARGS}" -- ${CURR_WORD} ) )
      return $?
      ;;
    --3-end)
      COMPREPLY=( $( compgen -W "${3End_OPTION_ARGS}" -- ${CURR_WORD} ) )
      return $?
      ;;
    --adapters)
      COMPREPLY=( $( compgen -W "${adapters_OPTION_ARGS}" -- ${CURR_WORD} ) )
      return $?
      ;;
    --region-of-interest)
      return
      ;;
  esac

  if [[ "${CURR_WORD}" == -* ]]; then
    COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS}" -- ${CURR_WORD}) )
  else
    COMPREPLY=( $(compgen -W "${COMMANDS}" -- ${CURR_WORD}) )
  fi
}

# Generates completions for the options and subcommands of the `shotgun` subcommand.
function _picocli_mixcr_analyze_shotgun() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-h --help -nw --no-warnings --verbose -f --force-overwrite --force --impute-germline-on-export --only-productive --contig-assembly --do-not-extend-alignments"
  ARG_OPTS="-s --species --starting-material -r --report --align --assemblePartial --extend --assemble --assembleContigs --export --assemble-partial-rounds --receptor-type"
  startingMaterial_OPTION_ARGS="rna dna" # _StartingMaterial values
  chains_OPTION_ARGS="tcr bcr xcr tra trb trd trg igh igk igl" # --receptor-type values

  compopt +o default

  case ${PREV_WORD} in
    -s|--species)
      return
      ;;
    --starting-material)
      COMPREPLY=( $( compgen -W "${startingMaterial_OPTION_ARGS}" -- ${CURR_WORD} ) )
      return $?
      ;;
    -r|--report)
      return
      ;;
    --align)
      return
      ;;
    --assemblePartial)
      return
      ;;
    --extend)
      return
      ;;
    --assemble)
      return
      ;;
    --assembleContigs)
      return
      ;;
    --export)
      return
      ;;
    --assemble-partial-rounds)
      return
      ;;
    --receptor-type)
      COMPREPLY=( $( compgen -W "${chains_OPTION_ARGS}" -- ${CURR_WORD} ) )
      return $?
      ;;
  esac

  if [[ "${CURR_WORD}" == -* ]]; then
    COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS}" -- ${CURR_WORD}) )
  else
    COMPREPLY=( $(compgen -W "${COMMANDS}" -- ${CURR_WORD}) )
  fi
}

# Define a completion specification (a compspec) for the
# `mixcr`, `mixcr.sh`, and `mixcr.bash` commands.
# Uses the bash `complete` builtin (see [6]) to specify that shell function
# `_complete_mixcr` is responsible for generating possible completions for the
# current word on the command line.
# The `-o default` option means that if the function generated no matches, the
# default Bash completions and the Readline default filename completions are performed.
complete -F _complete_mixcr -o default mixcr mixcr.sh mixcr.bash


Process finished with exit code 0
