name: "bedtools_closest"
namespace: "bedtools"
version: "main"
authors:
- name: "Robrecht Cannoodt"
  roles:
  - "author"
  - "maintainer"
  info:
    links:
      email: "robrecht@data-intuitive.com"
      github: "rcannood"
      orcid: "0000-0003-3641-729X"
      linkedin: "robrechtcannoodt"
    organizations:
    - name: "Data Intuitive"
      href: "https://www.data-intuitive.com"
      role: "Data Science Engineer"
    - name: "Open Problems"
      href: "https://openproblems.bio"
      role: "Core Member"
argument_groups:
- name: "Inputs"
  arguments:
  - type: "file"
    name: "--input_a"
    alternatives:
    - "-a"
    description: "Query file in BED, GFF, or VCF format.\n\nFor each feature in this\
      \ file, the closest feature in file B\nwill be identified and reported.\n"
    info: null
    example:
    - "queries.bed"
    must_exist: true
    create_parent: true
    required: true
    direction: "input"
    multiple: false
    multiple_sep: ";"
  - type: "file"
    name: "--input_b"
    alternatives:
    - "-b"
    description: "Database file(s) in BED, GFF, or VCF format.\n\n**Single file:**\
      \ Find closest features in one database\n**Multiple files:** Find closest features\
      \ across multiple databases\n**Format:** Same or different format as input A\n"
    info: null
    example:
    - "database1.bed"
    - "database2.bed"
    must_exist: true
    create_parent: true
    required: true
    direction: "input"
    multiple: true
    multiple_sep: ";"
- name: "Outputs"
  arguments:
  - type: "file"
    name: "--output"
    description: "Output file with closest feature results.\n\nContains input A features\
      \ with additional columns showing\nthe closest features from file(s) B, and\
      \ optionally distance\nand other metadata.\n"
    info: null
    example:
    - "closest_features.bed"
    must_exist: true
    create_parent: true
    required: true
    direction: "output"
    multiple: false
    multiple_sep: ";"
- name: "Distance Options"
  arguments:
  - type: "boolean_true"
    name: "--distance"
    alternatives:
    - "-d"
    description: "Report distance to closest feature as extra column.\n\n**Distance\
      \ calculation:** Always positive, 0 for overlapping features\n**Use case:**\
      \ When you need quantitative proximity measurements\n"
    info: null
    direction: "input"
  - type: "string"
    name: "--distance_mode"
    alternatives:
    - "-D"
    description: "Report signed distance with orientation awareness.\n\n**\"ref\"\
      :** Distance relative to reference genome coordinates\n**\"a\":** Distance relative\
      \ to strand of feature A  \n**\"b\":** Distance relative to strand of feature\
      \ B\n\n**Negative values:** Upstream features\n**Positive values:** Downstream\
      \ features\n"
    info: null
    example:
    - "ref"
    required: false
    choices:
    - "ref"
    - "a"
    - "b"
    direction: "input"
    multiple: false
    multiple_sep: ";"
- name: "Filtering Options"
  arguments:
  - type: "boolean_true"
    name: "--ignore_overlaps"
    alternatives:
    - "-io"
    description: "Ignore overlapping features in B.\n\nOnly consider features in B\
      \ that do not overlap with A.\nUseful for finding nearby but non-overlapping\
      \ features.\n"
    info: null
    direction: "input"
  - type: "boolean_true"
    name: "--ignore_upstream"
    alternatives:
    - "-iu"
    description: "Ignore upstream features in B.\n\n**Requires:** --distance_mode\
      \ parameter\n**Effect:** Only consider downstream features\n**Orientation:**\
      \ Follows --distance_mode orientation rules\n"
    info: null
    direction: "input"
  - type: "boolean_true"
    name: "--ignore_downstream"
    alternatives:
    - "-id"
    description: "Ignore downstream features in B.\n\n**Requires:** --distance_mode\
      \ parameter  \n**Effect:** Only consider upstream features\n**Orientation:**\
      \ Follows --distance_mode orientation rules\n"
    info: null
    direction: "input"
  - type: "boolean_true"
    name: "--force_upstream"
    alternatives:
    - "-fu"
    description: "Choose first upstream feature when ties exist.\n\n**Requires:**\
      \ --distance_mode parameter\n**Tie handling:** Among equally close features,\
      \ prefer upstream\n**Orientation:** Follows --distance_mode orientation rules\n"
    info: null
    direction: "input"
  - type: "boolean_true"
    name: "--force_downstream"
    alternatives:
    - "-fd"
    description: "Choose first downstream feature when ties exist.\n\n**Requires:**\
      \ --distance_mode parameter\n**Tie handling:** Among equally close features,\
      \ prefer downstream  \n**Orientation:** Follows --distance_mode orientation\
      \ rules\n"
    info: null
    direction: "input"
  - type: "boolean_true"
    name: "--strand"
    alternatives:
    - "-s"
    description: "Require same strandedness.\n\nOnly consider features in B that are\
      \ on the same strand as\nthe corresponding feature in A.\n"
    info: null
    direction: "input"
  - type: "boolean_true"
    name: "--different_strand"
    alternatives:
    - "-S"
    description: "Require different strandedness.\n\nOnly consider features in B that\
      \ are on the opposite strand\nfrom the corresponding feature in A.\n"
    info: null
    direction: "input"
- name: "Advanced Options"
  arguments:
  - type: "integer"
    name: "--k_closest"
    alternatives:
    - "-k"
    description: "Report k closest hits for each query.\n\n**Default:** 1 (single\
      \ closest feature)\n**Multiple hits:** Reports multiple closest features per\
      \ query\n**Tie handling:** All ties still reported based on --tie_mode\n"
    info: null
    example:
    - 3
    default:
    - 1
    required: false
    direction: "input"
    multiple: false
    multiple_sep: ";"
  - type: "string"
    name: "--tie_mode"
    alternatives:
    - "-t"
    description: "How to handle ties for closest features.\n\n**\"all\":** Report\
      \ all equally close features (default)\n**\"first\":** Report first tie found\
      \ in file B\n**\"last\":** Report last tie found in file B\n"
    info: null
    example:
    - "first"
    default:
    - "all"
    required: false
    choices:
    - "all"
    - "first"
    - "last"
    direction: "input"
    multiple: false
    multiple_sep: ";"
  - type: "boolean_true"
    name: "--different_names"
    alternatives:
    - "-N"
    description: "Require different names between query and hit.\n\nFor BED files,\
      \ compares the 4th column (name field).\nUseful to avoid self-hits in self-comparisons.\n"
    info: null
    direction: "input"
resources:
- type: "bash_script"
  path: "script.sh"
  is_executable: true
description: "Find the closest feature in file B for each feature in file A.\n\nFor\
  \ each interval in file A, this tool identifies the nearest feature in\nfile B,\
  \ regardless of whether they overlap. Useful for associating genomic\nfeatures with\
  \ their nearest neighbors, such as finding the closest gene\nto each SNP or the\
  \ nearest regulatory element to each promoter.\n\n**Default behavior:** Reports\
  \ closest feature regardless of strand or overlap\n**Distance reporting:** Optional\
  \ distance calculation with various orientations\n**Multiple hits:** Configurable\
  \ handling of ties and k-nearest neighbors\n"
test_resources:
- type: "bash_script"
  path: "test.sh"
  is_executable: true
- type: "file"
  path: "test_helpers.sh"
info: null
status: "enabled"
scope:
  image: "public"
  target: "public"
requirements:
  commands:
  - "bedtools"
  - "ps"
keywords:
- "Closest"
- "Nearest"
- "Distance"
- "BED"
- "GFF"
- "VCF"
- "Association"
license: "MIT"
references:
  doi:
  - "10.1093/bioinformatics/btq033"
links:
  repository: "https://github.com/arq5x/bedtools2"
  homepage: "https://bedtools.readthedtools.io/en/latest/"
  documentation: "https://bedtools.readthedocs.io/en/latest/content/tools/closest.html"
runners:
- type: "executable"
  id: "executable"
  docker_setup_strategy: "ifneedbepullelsecachedbuild"
- type: "nextflow"
  id: "nextflow"
  directives:
    tag: "$id"
  auto:
    simplifyInput: true
    simplifyOutput: false
    transcript: false
    publish: false
  config:
    labels:
      mem1gb: "memory = 1000000000.B"
      mem2gb: "memory = 2000000000.B"
      mem5gb: "memory = 5000000000.B"
      mem10gb: "memory = 10000000000.B"
      mem20gb: "memory = 20000000000.B"
      mem50gb: "memory = 50000000000.B"
      mem100gb: "memory = 100000000000.B"
      mem200gb: "memory = 200000000000.B"
      mem500gb: "memory = 500000000000.B"
      mem1tb: "memory = 1000000000000.B"
      mem2tb: "memory = 2000000000000.B"
      mem5tb: "memory = 5000000000000.B"
      mem10tb: "memory = 10000000000000.B"
      mem20tb: "memory = 20000000000000.B"
      mem50tb: "memory = 50000000000000.B"
      mem100tb: "memory = 100000000000000.B"
      mem200tb: "memory = 200000000000000.B"
      mem500tb: "memory = 500000000000000.B"
      mem1gib: "memory = 1073741824.B"
      mem2gib: "memory = 2147483648.B"
      mem4gib: "memory = 4294967296.B"
      mem8gib: "memory = 8589934592.B"
      mem16gib: "memory = 17179869184.B"
      mem32gib: "memory = 34359738368.B"
      mem64gib: "memory = 68719476736.B"
      mem128gib: "memory = 137438953472.B"
      mem256gib: "memory = 274877906944.B"
      mem512gib: "memory = 549755813888.B"
      mem1tib: "memory = 1099511627776.B"
      mem2tib: "memory = 2199023255552.B"
      mem4tib: "memory = 4398046511104.B"
      mem8tib: "memory = 8796093022208.B"
      mem16tib: "memory = 17592186044416.B"
      mem32tib: "memory = 35184372088832.B"
      mem64tib: "memory = 70368744177664.B"
      mem128tib: "memory = 140737488355328.B"
      mem256tib: "memory = 281474976710656.B"
      mem512tib: "memory = 562949953421312.B"
      cpu1: "cpus = 1"
      cpu2: "cpus = 2"
      cpu5: "cpus = 5"
      cpu10: "cpus = 10"
      cpu20: "cpus = 20"
      cpu50: "cpus = 50"
      cpu100: "cpus = 100"
      cpu200: "cpus = 200"
      cpu500: "cpus = 500"
      cpu1000: "cpus = 1000"
  debug: false
  container: "docker"
engines:
- type: "docker"
  id: "docker"
  image: "quay.io/biocontainers/bedtools:2.31.1--h13024bc_3"
  target_registry: "images.viash-hub.com"
  target_tag: "main"
  namespace_separator: "/"
  setup:
  - type: "docker"
    run:
    - "bedtools --version 2>&1 | head -1 | sed 's/.*bedtools v/bedtools: /' > /var/software_versions.txt"
  entrypoint: []
  cmd: null
- type: "native"
  id: "native"
build_info:
  config: "src/bedtools/bedtools_closest/config.vsh.yaml"
  runner: "executable"
  engine: "docker|native"
  output: "target/executable/bedtools/bedtools_closest"
  executable: "target/executable/bedtools/bedtools_closest/bedtools_closest"
  viash_version: "0.9.4"
  git_commit: "9991e9a4f5ddd5085a4e2becf962950b1daf594b"
  git_remote: "https://github.com/viash-hub/biobox"
package_config:
  name: "biobox"
  version: "main"
  summary: "A curated collection of high-quality, standalone bioinformatics components\
    \ built with [Viash](https://viash.io).\n"
  description: "`biobox` offers a suite of reliable bioinformatics components, similar\
    \ to [nf-core/modules](https://github.com/nf-core/modules) and [snakemake-wrappers/bio](https://github.com/snakemake/snakemake-wrappers/tree/master/bio),\
    \ but built using the [Viash](https://viash.io) framework.\n\nThis approach emphasizes\
    \ **reusability**, **reproducibility**, and adherence to **best practices**. Key\
    \ features of `biobox` components include:\n\n* **Standalone & Nextflow Ready:**\
    \ Run components directly via the command line or seamlessly integrate them into\
    \ Nextflow workflows.\n* **High Quality Standards:**\n    * Comprehensive documentation\
    \ for components and parameters.\n    * Full exposure of underlying tool arguments.\n\
    \    * Containerized (Docker) for dependency management and reproducibility.\n\
    \    * Unit tested for verified functionality.\n"
  info: null
  viash_version: "0.9.4"
  source: "src"
  target: "target"
  config_mods:
  - ".requirements.commands += ['ps']\n"
  - ".engines += { type: \"native\" }"
  - ".engines[.type == 'docker'].target_registry := 'images.viash-hub.com'"
  - ".engines[.type == 'docker'].target_tag := 'main'"
  keywords:
  - "bioinformatics"
  - "modules"
  - "sequencing"
  license: "MIT"
  organization: "vsh"
  links:
    repository: "https://github.com/viash-hub/biobox"
    issue_tracker: "https://github.com/viash-hub/biobox/issues"
