name: bedtools_bedtobam
namespace: bedtools
description: |
  Converts feature records to BAM format.
  
  Converts genomic intervals from BED, GFF, or VCF formats into BAM format,
  creating aligned sequence records that can be used with standard BAM tools.
keywords: [Converts, BED, GFF, VCF, BAM]
links:
  documentation: https://bedtools.readthedocs.io/en/latest/content/tools/bedtobam.html
  repository: https://github.com/arq5x/bedtools2
  homepage: https://bedtools.readthedocs.io/en/latest/
references:
  doi: 10.1093/bioinformatics/btq033
license: MIT
requirements:
  commands: [bedtools]
authors:
  - __merge__: /src/_authors/theodoro_gasperin.yaml
    roles: [author]
  - __merge__: /src/_authors/robrecht_cannoodt.yaml
    roles: [author, maintainer]

argument_groups:
  - name: Inputs
    arguments:
      - name: --input
        alternatives: [-i]
        type: file
        description: |
          Input genomic intervals file in BED, GFF, or VCF format.
          
          **Requirements:**
          - BED files must be at least BED4 format (requires name field)
          - File must contain valid genomic coordinates
        required: true
        example: input.bed
      
      - name: --genome
        alternatives: [-g]
        type: file
        description: | 
          Genome file defining chromosome names and sizes.
          
          **Format:** Two-column tab-delimited file:
          ```
          chr1    249250621
          chr2    243199373
          ```
          
          **Note:** This is NOT a FASTA file. Use `samtools faidx` to create from FASTA if needed.
        required: true
        example: hg19.genome
    
  - name: Outputs
    arguments:
      - name: --output
        alternatives: [-o]
        type: file
        direction: output
        description: |
          Output BAM file containing converted genomic intervals.
          
          **Format:** Standard BAM format (compressed by default)
        required: true
        example: output.bam

  - name: Options
    arguments:
      - name: --map_quality
        alternatives: [-mapq]
        type: integer
        description: | 
          Set the mapping quality for the BAM records.
          
          **Range:** 0-255 (higher values indicate better quality)
          
          **Default:** 255 (maximum quality)
        min: 0
        max: 255
        default: 255
      
      - name: --bed12
        type: boolean_true
        description: | 
          Process BED file as BED12 format with blocked intervals.
          
          **Features:**
          - BAM CIGAR string reflects BED blocks (exons/introns)
          - Useful for representing spliced alignments
          - Requires BED12 format input

      - name: --uncompress_bam
        alternatives: [-ubam]
        type: boolean_true
        description: | 
          Write uncompressed BAM output.
          
          **Default behavior:** Writes compressed BAM
          **Use case:** When downstream tools require uncompressed format
      
resources:
  - type: bash_script
    path: script.sh

test_resources:
  - type: bash_script
    path: test.sh
  - type: file
    path: /src/_utils/test_helpers.sh

engines:
  - type: docker
    image: quay.io/biocontainers/bedtools:2.31.1--h13024bc_3
    setup:
      - type: docker
        run:
          - "bedtools --version 2>&1 | head -1 | sed 's/.*bedtools v/bedtools: /' > /var/software_versions.txt"

runners:
  - type: executable
  - type: nextflow