{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "bedtools_closest",
  "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",
  "type": "object",
  "$defs": {
    "inputs": {
      "title": "Inputs",
      "type": "object",
      "description": "No description",
      "properties": {
        "input_a": {
          "type": "string",
          "format": "path",
          "exists": true,
          "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",
          "help_text": "Type: `file`, multiple: `False`, required, direction: `input`, example: `\"queries.bed\"`. "
        },
        "input_b": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "format": "path",
          "exists": true,
          "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",
          "help_text": "Type: `file`, multiple: `True`, required, direction: `input`, example: `[\"database1.bed\";\"database2.bed\"]`. "
        }
      }
    },
    "outputs": {
      "title": "Outputs",
      "type": "object",
      "description": "No description",
      "properties": {
        "output": {
          "type": "string",
          "format": "path",
          "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",
          "help_text": "Type: `file`, multiple: `False`, required, default: `\"$id.$key.output.bed\"`, direction: `output`, example: `\"closest_features.bed\"`. ",
          "default": "$id.$key.output.bed"
        }
      }
    },
    "distance options": {
      "title": "Distance Options",
      "type": "object",
      "description": "No description",
      "properties": {
        "distance": {
          "type": "boolean",
          "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",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "distance_mode": {
          "type": "string",
          "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",
          "help_text": "Type: `string`, multiple: `False`, example: `\"ref\"`, choices: ``ref`, `a`, `b``. ",
          "enum": [
            "ref",
            "a",
            "b"
          ]
        }
      }
    },
    "filtering options": {
      "title": "Filtering Options",
      "type": "object",
      "description": "No description",
      "properties": {
        "ignore_overlaps": {
          "type": "boolean",
          "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",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "ignore_upstream": {
          "type": "boolean",
          "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",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "ignore_downstream": {
          "type": "boolean",
          "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",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "force_upstream": {
          "type": "boolean",
          "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",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "force_downstream": {
          "type": "boolean",
          "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",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "strand": {
          "type": "boolean",
          "description": "Require same strandedness.\n\nOnly consider features in B that are on the same strand as\nthe corresponding feature in A.\n",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "different_strand": {
          "type": "boolean",
          "description": "Require different strandedness.\n\nOnly consider features in B that are on the opposite strand\nfrom the corresponding feature in A.\n",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        }
      }
    },
    "advanced options": {
      "title": "Advanced Options",
      "type": "object",
      "description": "No description",
      "properties": {
        "k_closest": {
          "type": "integer",
          "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",
          "help_text": "Type: `integer`, multiple: `False`, default: `1`, example: `3`. ",
          "default": 1
        },
        "tie_mode": {
          "type": "string",
          "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",
          "help_text": "Type: `string`, multiple: `False`, default: `\"all\"`, example: `\"first\"`, choices: ``all`, `first`, `last``. ",
          "enum": [
            "all",
            "first",
            "last"
          ],
          "default": "all"
        },
        "different_names": {
          "type": "boolean",
          "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",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        }
      }
    },
    "nextflow input-output arguments": {
      "title": "Nextflow input-output arguments",
      "type": "object",
      "description": "Input/output parameters for Nextflow itself. Please note that both publishDir and publish_dir are supported but at least one has to be configured.",
      "properties": {
        "publish_dir": {
          "type": "string",
          "description": "Path to an output directory.",
          "help_text": "Type: `string`, multiple: `False`, required, example: `\"output/\"`. "
        }
      }
    }
  },
  "allOf": [
    {
      "$ref": "#/$defs/inputs"
    },
    {
      "$ref": "#/$defs/outputs"
    },
    {
      "$ref": "#/$defs/distance options"
    },
    {
      "$ref": "#/$defs/filtering options"
    },
    {
      "$ref": "#/$defs/advanced options"
    },
    {
      "$ref": "#/$defs/nextflow input-output arguments"
    }
  ]
}
