{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "bedtools_map",
  "description": "Apply statistical functions to columns from overlapping genomic intervals.\n\nThis tool maps values from intervals in file B onto overlapping intervals in file A\nby applying statistical operations (sum, mean, median, etc.). For each interval in A,\nit finds all overlapping intervals in B and applies the specified function to the \nspecified column(s). Useful for aggregating scores, computing statistics over \ngenomic regions, or annotating intervals with quantitative data.\n",
  "type": "object",
  "$defs": {
    "inputs": {
      "title": "Inputs",
      "type": "object",
      "description": "No description",
      "properties": {
        "input_a": {
          "type": "string",
          "format": "path",
          "exists": true,
          "description": "First input file (intervals to annotate).\n\n**Format:** BED, GFF, VCF file with genomic intervals\n**Requirement:** Must be sorted by chromosome, then start position\n**Usage:** Each interval will be annotated with mapped values from file B\n",
          "help_text": "Type: `file`, multiple: `False`, required, direction: `input`, example: `\"target_regions.bed\"`. "
        },
        "input_b": {
          "type": "string",
          "format": "path",
          "exists": true,
          "description": "Second input file (source of values to map).\n\n**Format:** BED, GFF, VCF file with genomic intervals and data columns\n**Requirement:** Must be sorted by chromosome, then start position\n**Usage:** Overlapping intervals provide values for mapping operations\n",
          "help_text": "Type: `file`, multiple: `False`, required, direction: `input`, example: `\"data_intervals.bed\"`. "
        }
      }
    },
    "outputs": {
      "title": "Outputs",
      "type": "object",
      "description": "No description",
      "properties": {
        "output": {
          "type": "string",
          "format": "path",
          "description": "Output file with mapped values appended to input A intervals.\n\n**Format:** Same as input A with additional columns for mapped values\n**Content:** Original columns from A plus computed statistical values\n**Order:** Follows the order specified in column and operation parameters\n",
          "help_text": "Type: `file`, multiple: `False`, required, default: `\"$id.$key.output.bed\"`, direction: `output`, example: `\"annotated_regions.bed\"`. ",
          "default": "$id.$key.output.bed"
        }
      }
    },
    "mapping options": {
      "title": "Mapping Options",
      "type": "object",
      "description": "No description",
      "properties": {
        "columns": {
          "type": "string",
          "description": "Columns from file B to use for mapping operations.\n\n**Default:** 5 (fifth column, typically score column in BED)\n**Format:** Comma-delimited list for multiple columns\n**Example:** \"5\" for score column, \"4,5\" for name and score columns\n**Indexing:** 1-based column numbering\n",
          "help_text": "Type: `string`, multiple: `False`, example: `\"5\"`. "
        },
        "operations": {
          "type": "string",
          "description": "Statistical operations to apply to specified columns.\n\n**Numeric operations:** sum, min, max, absmin, absmax, mean, median, mode, antimode, stdev, sstdev, count, count_distinct\n**List operations:** collapse, distinct, distinct_sort_num, distinct_sort_num_desc, distinct_only\n**Position operations:** first, last\n\n**Default:** sum\n**Format:** Comma-delimited list for multiple operations\n**Pairing:** Operations applied to columns in respective order\n",
          "help_text": "Type: `string`, multiple: `False`, example: `\"mean\"`. "
        },
        "delimiter": {
          "type": "string",
          "description": "Custom delimiter for collapse operations.\n\n**Default:** \",\" (comma)\n**Usage:** Only affects collapse, distinct, and related operations\n**Example:** \"|\" for pipe-separated values, \";\" for semicolon-separated\n",
          "help_text": "Type: `string`, multiple: `False`, example: `\"|\"`. "
        },
        "precision": {
          "type": "integer",
          "description": "Decimal precision for numerical output.\n\n**Default:** 5 decimal places\n**Range:** 0-15 (reasonable range for floating point precision)\n**Usage:** Controls rounding of computed statistical values\n",
          "help_text": "Type: `integer`, multiple: `False`, example: `3`. "
        }
      }
    },
    "overlap options": {
      "title": "Overlap Options",
      "type": "object",
      "description": "No description",
      "properties": {
        "min_overlap_a": {
          "type": "number",
          "description": "Minimum overlap required as fraction of A.\n\n**Range:** 0.0 to 1.0\n**Default:** 1E-9 (effectively 1bp)\n**Example:** 0.50 requires 50% of A to be overlapped by B\n",
          "help_text": "Type: `double`, multiple: `False`, example: `0.5`. "
        },
        "min_overlap_b": {
          "type": "number",
          "description": "Minimum overlap required as fraction of B.\n\n**Range:** 0.0 to 1.0\n**Default:** 1E-9 (effectively 1bp)\n**Example:** 0.50 requires 50% of B to overlap A\n",
          "help_text": "Type: `double`, multiple: `False`, example: `0.5`. "
        },
        "reciprocal": {
          "type": "boolean",
          "description": "Require reciprocal overlap for both A and B.\n\n**Effect:** Both -f and -F thresholds must be satisfied\n**Example:** With -f 0.90 -r, requires B overlaps 90% of A AND A overlaps 90% of B\n**Default:** false\n",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "either": {
          "type": "boolean",
          "description": "Require minimum fraction satisfied for A OR B.\n\n**Effect:** Only one of -f or -F thresholds needs to be satisfied\n**Alternative:** Without -e, both fractions must be satisfied\n**Default:** false (both required)\n",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        }
      }
    },
    "strand options": {
      "title": "Strand Options",
      "type": "object",
      "description": "No description",
      "properties": {
        "same_strand": {
          "type": "boolean",
          "description": "Require same strandedness for overlaps.\n\n**Effect:** Only consider overlaps on the same strand\n**Default:** false (strand-independent)\n",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "opposite_strand": {
          "type": "boolean",
          "description": "Require different strandedness for overlaps.\n\n**Effect:** Only consider overlaps on opposite strands\n**Default:** false (strand-independent)\n**Note:** May have issues in some bedtools versions\n",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        }
      }
    },
    "format options": {
      "title": "Format Options",
      "type": "object",
      "description": "No description",
      "properties": {
        "split": {
          "type": "boolean",
          "description": "Treat split BAM or BED12 entries as distinct intervals.\n\n**Effect:** Split multi-block entries into individual intervals\n**Usage:** For BAM alignments with gaps or BED12 entries\n**Default:** false\n",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "bed_output": {
          "type": "boolean",
          "description": "Write output in BED format when using BAM input.\n\n**Effect:** Forces BED output format for BAM inputs\n**Default:** false\n",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "header": {
          "type": "boolean",
          "description": "Print header from file A prior to results.\n\n**Effect:** Includes original header from input file A\n**Default:** false\n",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        }
      }
    },
    "advanced options": {
      "title": "Advanced Options",
      "type": "object",
      "description": "No description",
      "properties": {
        "genome": {
          "type": "string",
          "format": "path",
          "description": "Genome file for consistent chromosome sorting.\n\n**Format:** Tab-delimited file with chromosome name and size\n**Usage:** Only applies when used with sorted data\n**Purpose:** Enforces consistent chromosome sort order\n",
          "help_text": "Type: `file`, multiple: `False`, direction: `input`, example: `\"genome.txt\"`. "
        },
        "no_name_check": {
          "type": "boolean",
          "description": "Skip chromosome naming convention checks for sorted data.\n\n**Effect:** Allows different naming (e.g., \"chr1\" vs \"chr01\")\n**Usage:** For files with inconsistent chromosome naming\n**Default:** false (strict checking)\n",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "no_buffer": {
          "type": "boolean",
          "description": "Disable buffered output.\n\n**Effect:** Print each line immediately instead of buffering\n**Usage:** For real-time processing or piping\n**Trade-off:** Slower performance but immediate output\n**Default:** false (buffered output)\n",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "io_buffer": {
          "type": "string",
          "description": "Specify input buffer memory size.\n\n**Format:** Integer with optional K/M/G suffix\n**Example:** \"128M\" for 128 megabytes\n**Note:** No effect with compressed files\n",
          "help_text": "Type: `string`, multiple: `False`, example: `\"128M\"`. "
        }
      }
    },
    "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/mapping options"
    },
    {
      "$ref": "#/$defs/overlap options"
    },
    {
      "$ref": "#/$defs/strand options"
    },
    {
      "$ref": "#/$defs/format options"
    },
    {
      "$ref": "#/$defs/advanced options"
    },
    {
      "$ref": "#/$defs/nextflow input-output arguments"
    }
  ]
}
