name: parallel_map
description: |
  Map wells in batch, using STAR
  Spliced Transcripts Alignment to a Reference (C) Alexander Dobin
  https://github.com/alexdobin/STAR
requirements:
  commands:
    - STAR
    - file
    - parallel
argument_groups:
  - name: Input arguments
    arguments:
    - name: "--input_r1"
      type: file
      required: true
      multiple: true
    - name: "--input_r2"
      type: file
      required: true
      multiple: true
    - name: "--genomeDir"
      type: file
      required: true
      description: STAR reference directory
    - name: "--barcodes"
      type: string 
      multiple: true
      required: true
      description: The barcodes/wells to process
  - name: Barcode arguments
    arguments:
    - name: "--wellBarcodesLength"
      type: integer
      required: true
      description: The length of the well barcodes
    - name: "--umiLength"
      type: integer
      required: true
      description: The length of the UMIs
    - name: "--limitBAMsortRAM"
      type: string
      default: "10000000000"
  - name: Runtime arguments
    arguments:
    - name: "--runThreadN"
      description: "Number of threads to use for a single STAR execution."
      type: integer
      default: 1
  - name: Output arguments
    arguments:
    - name: "--output"
      type: file
      description: |
        Location of the output folders, 1 folder per barcode. The value used
        for this argument must contain a '*', which will be replaced with the
        barcode to form the final output location for that barcode.
      required: true
      multiple: true
      direction: output
      default: './*'
    - name: "--joblog"
      type: file
      description: Where to store the log file listing all the jobs.
      required: false
      direction: output
      default: "execution_log.txt"

resources:
- type: bash_script
  path: script.sh
- path: STAR

test_resources:
  - type: bash_script
    path: test.sh

engines:
  - type: docker
    image: debian:stable-slim
    setup:
      - type: apt
        packages:
          - procps
          - wget
          - automake
          - make
          - gcc
          - g++
          - zlib1g-dev
          - parallel
          - file
      - type: docker
        build_args:
          - STAR_V=2.7.6a
        env:
          - STAR_SOURCE="https://github.com/alexdobin/STAR/archive/refs/tags/$STAR_V.tar.gz"
          - STAR_TARGET="/app/star-$STAR_V.tar.gz"
          - STAR_INSTALL_DIR="/app/STAR-$STAR_V"
          - STAR_BINARY=STAR
        copy:
          - STAR /usr/local/bin/$STAR_BINARY
runners:
  - type: executable
  - type: nextflow
