name: bedtools_getfasta
namespace: bedtools
description: |
  Extract DNA sequences from a FASTA file based on feature coordinates.
  
  Given intervals specified in BED/GFF/VCF format and a FASTA file, this tool
  extracts the corresponding sequences from the FASTA file. Various output formats
  are supported including FASTA (default), tab-delimited, and BED format with sequences.
  
keywords: [sequencing, fasta, BED, GFF, VCF, sequence extraction]
links:
  documentation: https://bedtools.readthedocs.io/en/latest/content/tools/getfasta.html
  repository: https://github.com/arq5x/bedtools2
references:
  doi: 10.1093/bioinformatics/btq033
license: GPL-2.0
requirements:
  commands: [bedtools]
authors:
  - __merge__: /src/_authors/dries_schaumont.yaml
    roles: [author, maintainer]
  - __merge__: /src/_authors/robrecht_cannoodt.yaml
    roles: [author]

argument_groups:
  - name: Input arguments
    arguments:
      - name: --input_fasta
        alternatives: [-fi]
        type: file
        required: true
        description: |
          Input FASTA file containing sequences for extraction.
          The headers in the input FASTA file must exactly match the chromosome
          column in the BED file.
      - name: "--input_bed"
        alternatives: [-bed]
        type: file
        required: true
        description: |
          BED/GFF/VCF file containing intervals to extract from the FASTA file.
          BED files containing a single region require a newline character
          at the end of the line, otherwise a blank output file is produced.
      - name: --rna
        type: boolean_true
        description: |
          The FASTA is RNA not DNA. Reverse complementation handled accordingly.
    
  - name: Processing options
    arguments:
        - name: "--strandedness"
          type: boolean_true
          alternatives: ["-s"]
          description: |
            Force strandedness. If the feature occupies the antisense strand, the output sequence will
            be reverse complemented. By default strandedness is not taken into account.
        - name: "--split"
          type: boolean_true
          description: |
            When input is in BED12 format, create a separate FASTA entry for each block in a BED12 record.
            Blocks are described in the 11th and 12th columns of the BED format.
        - name: "--full_header"
          type: boolean_true
          alternatives: [-fullHeader]
          description: |
            Use full FASTA header. By default, only the word before the first space or tab is used.

  - name: Output arguments
    arguments:
      - name: --output
        alternatives: [-o, -fo]
        required: true
        type: file
        direction: output
        description: |
          Output file where the extracted sequences will be written.
          By default, output is in FASTA format unless --tab or --bed_out is specified.
      - name: --name
        type: boolean_true
        description: |
          Set the FASTA header for each extracted sequence to be the "name" and coordinate 
          columns from the BED feature (format: name::chr:start-end).
      - name: "--name_only"
        type: boolean_true
        alternatives: [-nameOnly]
        description: |
          Set the FASTA header for each extracted sequence to be only the "name" 
          column from the BED feature.
      - name: --tab
        type: boolean_true
        description: |
          Report extracted sequences in a tab-delimited format instead of FASTA format.
          Output format: name<tab>sequence.
      - name: --bed_out
        type: boolean_true
        alternatives: [-bedOut]
        description: |
          Report extracted sequences in a tab-delimited BED format instead of FASTA format.
          Output format: chr<tab>start<tab>end<tab>name<tab>sequence.                     

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
