name: bismark_bt2_index
version: 0.0.3
output_asset_class: bismark_bt2_index
description: |
  Genome index for Bisulfite-Seq applications, produced by
  bismark_genome_preparation using bowtie2. Used for bisulfite
  sequencing alignment with Bismark.
input_files: {}
input_params:
  parallel:
    default: "4"
    description: Number of threads to use for parallel computing
input_assets:
  fasta:
    asset_class: fasta
    default: fasta
    description: fasta asset for genome
    colocate:
      - source_key: fasta
docker_image: quay.io/biocontainers/bismark:3.1.0--hfa8f182_0
command_templates:
  # `--bowtie2` became the DEFAULT in bismark 3.x, but the flag is still
  # accepted and still means bowtie2. Kept explicit on purpose: this recipe
  # publishes a bowtie2 asset, so the aligner must be stated, not inherited
  # from whatever the current default happens to be. Verified in
  # bismark:3.1.0--hfa8f182_0: `--bowtie2 <folder> --parallel 2` parses and
  # produces Bisulfite_Genome/{CT,GA}_conversion/BS_*.bt2, same layout as 0.x.
  - bismark_genome_preparation --bowtie2 {{values.output_folder}} --parallel {{values.params["parallel"]}}
custom_seek_keys:
  # Content-anchored on the version token, never on a line/field number.
  # bismark 3.x is a Rust rewrite whose banner collapsed to ONE line, so the
  # old `awk 'NR==4{print $5}'` returned empty (-> asset named ""). Both banner
  # shapes are matched so the expression describes "bismark's version" rather
  # than one release's formatting:
  #   3.x    bismark_genome_preparation (Bismark Rust suite) v3.1.0 (... built ...)
  #   0.x    Bismark Genome Preparation Version: v0.22.1
  # Written with sed -E, not grep -P: the biocontainers image's /usr/bin/grep
  # is BusyBox (no -P support), and the whole pipeline now runs inside that
  # one image, not on a host/crate with GNU grep. sed -E has no \K, so each
  # banner shape gets its own capture-and-print alternative.
  version: 'bismark_genome_preparation --version 2>/dev/null | sed -nE ''s/.*\(Bismark Rust suite\) v([0-9]+\.[0-9]+(\.[0-9]+)?).*/\1/p;s/.*Bismark Genome Preparation Version: v([0-9]+\.[0-9]+(\.[0-9]+)?).*/\1/p'' | head -1'
default_asset: "{{values.custom_seek_keys.version}}"

tags:
- alignment
- bisulfite-seq
- methylation
- epigenetics
outputs:
- pattern: Bisulfite_Genome/**
  description: Bismark bowtie2 bisulfite genome index directory
test:
  commands:
  - test -d {output_dir}/Bisulfite_Genome
resources:
  memory: 8GB
  disk: 10GB
  time: 3h
metadata:
  author: nsheff
  created: '2026-05-20'
  license: BSD-2-Clause
