{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "bedtools_merge",
  "description": "Merges overlapping BED/GFF/VCF entries into single intervals.\n\nThis tool combines overlapping or book-ended features in BED, GFF, or VCF\nfiles into single merged intervals. It provides extensive options for\ncontrolling merge behavior, including strand-specific merging, distance\nthresholds, and aggregation operations on additional columns.\n\n**Default behavior:** Merges overlapping and adjacent features regardless of strand\n**Input requirements:** Input file must be sorted by chromosome and start position\n",
  "type": "object",
  "$defs": {
    "inputs": {
      "title": "Inputs",
      "type": "object",
      "description": "No description",
      "properties": {
        "input": {
          "type": "string",
          "format": "path",
          "exists": true,
          "description": "Input file in BED, GFF, or VCF format to be merged.\n\n**Requirements:**\n- File must be sorted by chromosome and start position\n- Use `bedtools sort` if input is not sorted\n\n**Supported formats:** BED, GFF, VCF, or BAM (with --bed flag)\n",
          "help_text": "Type: `file`, multiple: `False`, required, direction: `input`, example: `\"intervals.bed\"`. "
        }
      }
    },
    "outputs": {
      "title": "Outputs",
      "type": "object",
      "description": "No description",
      "properties": {
        "output": {
          "type": "string",
          "format": "path",
          "description": "Output file containing merged intervals.\n\nThe output will contain merged intervals in BED format, with\nadditional columns included if aggregation operations are specified\nvia --columns and --operation parameters.\n",
          "help_text": "Type: `file`, multiple: `False`, required, default: `\"$id.$key.output.bed\"`, direction: `output`, example: `\"merged_intervals.bed\"`. ",
          "default": "$id.$key.output.bed"
        }
      }
    },
    "options": {
      "title": "Options",
      "type": "object",
      "description": "No description",
      "properties": {
        "strand": {
          "type": "boolean",
          "description": "Force strandedness for merging operations.\n\nOnly merge features that are on the same strand",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "specific_strand": {
          "type": "string",
          "description": "Merge features from one specific strand only.\n\n**Options:**\n- \"+\" : Merge only forward strand features\n- \"-\" : Merge only reverse strand features\n\nFeatures from the opposite strand will be ignored entirely.\n",
          "help_text": "Type: `string`, multiple: `False`, example: `\"+\"`, choices: ``+`, `-``. ",
          "enum": [
            "+",
            "-"
          ]
        },
        "distance": {
          "type": "integer",
          "description": "Maximum distance between features for merging.\n\n**Positive values:** Features within this distance will be merged\n**Negative values:** Minimum overlap required (in base pairs)\n**Zero (default):** Only overlapping and book-ended features merge\n\n**Examples:**\n- `-d 100` : Merge features within 100bp of each other\n- `-d -50` : Require at least 50bp overlap to merge\n",
          "help_text": "Type: `integer`, multiple: `False`, default: `0`, example: `100`. ",
          "default": 0
        },
        "columns": {
          "type": "string",
          "description": "Columns to aggregate during merging operations.\n\nSpecify which columns from the input file should be included\nin the merged output with aggregation operations applied.\n\n**Format:** Single column (e.g., \"5\") or comma-separated list (e.g., \"4,5,6\")\n**Column numbering:** 1-indexed (column 1 = chromosome, etc.)\n",
          "help_text": "Type: `string`, multiple: `False`, example: `\"4,5,6\"`. "
        },
        "operation": {
          "type": "string",
          "description": "Aggregation operations to apply to specified columns.\n\n**Numerical operations:**\n- sum, min, max, mean, median, mode\n- absmin, absmax, stdev, sstdev\n\n**List operations:**\n- collapse (comma-separated list with duplicates)\n- distinct (comma-separated unique values)\n- distinct_sort_num (unique values, numerically sorted)\n\n**Count operations:**\n- count (number of values)\n- count_distinct (number of unique values)\n\n**Positional operations:**\n- first (first value), last (last value)\n\n**Multiple operations:** Use comma-separated list (e.g., \"sum,mean,count\")\n",
          "help_text": "Type: `string`, multiple: `False`, example: `\"mean,count\"`. "
        },
        "delimiter": {
          "type": "string",
          "description": "Custom delimiter for collapse/distinct operations.\n\nCharacter or string used to separate values in list-type\noperations like collapse, distinct, etc.\n",
          "help_text": "Type: `string`, multiple: `False`, default: `\",\"`, example: `\"|\"`. ",
          "default": ","
        },
        "precision": {
          "type": "integer",
          "description": "Decimal precision for numerical output values.\n\nControls the number of decimal places displayed for\nfloating-point results from numerical operations.\n",
          "help_text": "Type: `integer`, multiple: `False`, default: `5`, example: `3`. ",
          "default": 5
        },
        "bed": {
          "type": "boolean",
          "description": "Output in BED format when using BAM input.\n\nWhen the input file is in BAM format, this flag ensures\nthe output is written in standard BED format instead of\nthe default BAM-specific output format.\n",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "header": {
          "type": "boolean",
          "description": "Include header from input file in output.\n\nPreserves and prints any header lines from the input file\n(e.g., GFF version lines, VCF headers) before the merged results.\n",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "no_buffer": {
          "type": "boolean",
          "description": "Disable buffered output for real-time processing.\n\n**Default behavior:** Output is buffered for efficiency\n**With --no_buffer:** Each line printed immediately as generated\n\n**Use cases:** Real-time processing, piping to other tools\n**Performance:** Slower for large files but enables streaming\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/options"
    },
    {
      "$ref": "#/$defs/nextflow input-output arguments"
    }
  ]
}
