{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "bedtools_subtract",
  "description": "Remove the portion(s) of genomic intervals that are overlapped by other features.\n\nbedtools subtract removes portions of intervals in file A that overlap with intervals \nin file B. By default, only the overlapping portions are removed, leaving the \nnon-overlapping parts of A intervals. This is essential for genomic analysis tasks \nlike removing repetitive elements, excluding known variants, or filtering out \nunwanted regions from interval datasets.\n\nThis tool is commonly used for:\n- Removing repetitive elements or low-complexity regions from analysis\n- Excluding known polymorphic sites from variant calling regions\n- Filtering out blacklisted genomic regions from ChIP-seq peaks\n- Creating clean interval sets by removing overlapping annotations\n- Generating non-overlapping genomic windows for analysis\n- Quality control by removing problematic genomic regions\n",
  "type": "object",
  "$defs": {
    "inputs": {
      "title": "Inputs",
      "type": "object",
      "description": "No description",
      "properties": {
        "input_a": {
          "type": "string",
          "format": "path",
          "exists": true,
          "description": "Input file A containing genomic intervals to subtract from.\n\n**Format:** BED, GFF, or VCF file with genomic coordinates\n**Content:** Intervals from which overlapping portions will be removed\n**Usage:** This is the primary input file that will be modified\n**Requirements:** Standard genomic interval format\n**Output:** Modified intervals with overlapping regions removed\n",
          "help_text": "Type: `file`, multiple: `False`, required, direction: `input`, example: `\"target_regions.bed\"`. "
        },
        "input_b": {
          "type": "string",
          "format": "path",
          "exists": true,
          "description": "Input file B containing genomic intervals to subtract.\n\n**Format:** BED, GFF, or VCF file with genomic coordinates  \n**Content:** Intervals that will be removed from file A\n**Usage:** Regions in this file will be subtracted from input_a intervals\n**Requirements:** Standard genomic interval format\n**Effect:** Any overlap with these intervals will be removed from A\n",
          "help_text": "Type: `file`, multiple: `False`, required, direction: `input`, example: `\"repetitive_elements.bed\"`. "
        }
      }
    },
    "outputs": {
      "title": "Outputs",
      "type": "object",
      "description": "No description",
      "properties": {
        "output": {
          "type": "string",
          "format": "path",
          "description": "Output file with subtracted intervals.\n\n**Format:** Same format as input file A\n**Content:** Modified intervals from A with B regions removed\n**Behavior:** Only non-overlapping portions of A intervals are retained\n**Special cases:** Intervals completely overlapped by B are omitted entirely\n",
          "help_text": "Type: `file`, multiple: `False`, required, default: `\"$id.$key.output.bed\"`, direction: `output`, example: `\"filtered_regions.bed\"`. ",
          "default": "$id.$key.output.bed"
        }
      }
    },
    "overlap options": {
      "title": "Overlap Options",
      "type": "object",
      "description": "No description",
      "properties": {
        "min_overlap_a": {
          "type": "number",
          "description": "Minimum overlap required as a fraction of A interval.\n\n**Default:** 1E-9 (essentially 1 base pair)\n**Range:** 0.0 to 1.0\n**Usage:** B must overlap at least this fraction of A for subtraction\n**Example:** 0.5 requires B to overlap at least 50% of A interval\n",
          "help_text": "Type: `double`, multiple: `False`, example: `0.1`. "
        },
        "min_overlap_b": {
          "type": "number",
          "description": "Minimum overlap required as a fraction of B interval.\n\n**Default:** 1E-9 (essentially 1 base pair)\n**Range:** 0.0 to 1.0\n**Usage:** A must overlap at least this fraction of B for subtraction\n**Example:** 0.3 requires A to overlap at least 30% of B interval\n",
          "help_text": "Type: `double`, multiple: `False`, example: `0.1`. "
        },
        "reciprocal": {
          "type": "boolean",
          "description": "Require that the fraction overlap be reciprocal for A AND B.\n\n**Usage:** Both A and B must overlap each other by the specified fractions\n**Example:** With -f 0.9, B must overlap 90% of A AND A must overlap 90% of B\n**Effect:** More stringent overlap requirement than -f or -F alone\n**Default:** false (only one-way overlap required)\n",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "either_overlap": {
          "type": "boolean",
          "description": "Require that the minimum fraction be satisfied for A OR B.\n\n**Usage:** Either the -f fraction OR the -F fraction must be satisfied\n**Example:** With -f 0.9 and -F 0.1, either 90% of A OR 10% of B must be covered\n**Default:** false (both fractions must be satisfied if both specified)\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 overlap detection.\n\n**Usage:** Only subtract B intervals that overlap A on the same strand\n**Applications:** Strand-specific analysis, gene annotation filtering\n**Default:** false (overlaps reported without respect to strand)\n",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "opposite_strand": {
          "type": "boolean",
          "description": "Require different strandedness for overlap detection.\n\n**Usage:** Only subtract B intervals that overlap A on the opposite strand\n**Applications:** Antisense filtering, strand-specific exclusions\n**Default:** false (overlaps reported without respect to strand)\n",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        }
      }
    },
    "subtraction behavior": {
      "title": "Subtraction Behavior",
      "type": "object",
      "description": "No description",
      "properties": {
        "remove_entire": {
          "type": "boolean",
          "description": "Remove entire feature if any overlap is found.\n\n**Behavior:** Instead of partial subtraction, remove entire A interval if any overlap with B\n**Usage:** Binary filtering - intervals are either kept completely or removed completely\n**Applications:** Quality filtering, blacklist exclusion\n**Default:** false (only overlapping portions are subtracted)\n",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "remove_if_all_overlap": {
          "type": "boolean",
          "description": "Remove entire feature based on sum of all B feature overlaps.\n\n**Usage:** Same as -A but considers cumulative overlap from multiple B features\n**Behavior:** Remove A if total overlap from all B features meets threshold\n**Applications:** Complex filtering based on multiple overlapping annotations\n**Requires:** Used with -f option for fraction threshold\n",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        }
      }
    },
    "output format options": {
      "title": "Output Format Options",
      "type": "object",
      "description": "No description",
      "properties": {
        "write_original_b": {
          "type": "boolean",
          "description": "Write the original entry in B for each overlap.\n\n**Output:** Each A interval followed by overlapping B intervals\n**Usage:** Track which B features caused the subtraction\n**Restrictions:** Overlap filtering by -f and -r still applies\n**Applications:** Detailed overlap reporting, annotation tracking\n",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "write_overlap_counts": {
          "type": "boolean",
          "description": "Write original A and B entries plus the number of base pairs of overlap.\n\n**Output:** A interval, B interval, and overlap count in base pairs\n**Usage:** Quantify the extent of overlap between features\n**Filtering:** Only A features with overlap are reported\n**Applications:** Overlap statistics, coverage analysis\n",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "output_bed": {
          "type": "boolean",
          "description": "Convert BAM input to BED format output.\n\n**Usage:** Only applicable when input is BAM format\n**Effect:** Output genomic coordinates in BED format\n**Applications:** Converting alignment data to interval format\n",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "include_header": {
          "type": "boolean",
          "description": "Print the header from the A file prior to results.\n\n**Usage:** Preserves metadata and format information from input\n**Applications:** Maintaining file structure and annotations\n**Formats:** Particularly relevant for VCF and GFF files\n",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        }
      }
    },
    "performance options": {
      "title": "Performance Options",
      "type": "object",
      "description": "No description",
      "properties": {
        "use_split": {
          "type": "boolean",
          "description": "Treat \"split\" BAM or BED12 entries as distinct BED intervals.\n\n**Usage:** Split complex entries into individual intervals\n**Applications:** Detailed analysis of spliced alignments or multi-part features\n**Formats:** Applies to BAM alignments and BED12 format\n",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "sorted_input": {
          "type": "boolean",
          "description": "Use the \"chromsweep\" algorithm for sorted input.\n\n**Requirements:** Input must be sorted by chromosome then start coordinate\n**Performance:** Much faster for large sorted files\n**Usage:** Optimize processing for pre-sorted genomic data\n**Sort command:** sort -k1,1 -k2,2n input.bed\n",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "genome_file": {
          "type": "string",
          "format": "path",
          "description": "Genome file to enforce consistent chromosome sort order.\n\n**Format:** Tab-delimited file with chromosome names and lengths\n**Usage:** Only applies when used with -sorted option\n**Purpose:** Ensure consistent chromosome ordering across input files\n**Example:** chr1\\t249250621\n",
          "help_text": "Type: `file`, multiple: `False`, direction: `input`, example: `\"genome.txt\"`. "
        },
        "no_name_check": {
          "type": "boolean",
          "description": "Don't throw error for different chromosome naming conventions.\n\n**Usage:** For sorted data with mixed naming (e.g., \"chr1\" vs \"chr01\")\n**Applications:** Working with data from different sources\n**Safety:** Allows processing despite naming inconsistencies\n",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "no_buffer": {
          "type": "boolean",
          "description": "Disable output buffering for real-time processing.\n\n**Effect:** Each line printed immediately instead of buffered\n**Trade-off:** Slower output but enables real-time processing\n**Applications:** Pipeline integration, streaming analysis\n",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "input_buffer": {
          "type": "string",
          "description": "Amount of memory to allocate for input buffer.\n\n**Format:** Integer with optional K/M/G suffix\n**Examples:** \"1G\", \"512M\", \"2048K\"\n**Usage:** Larger buffers can improve I/O performance for large files\n**Note:** Currently has no effect with compressed files\n",
          "help_text": "Type: `string`, multiple: `False`, example: `\"1G\"`. "
        }
      }
    },
    "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/overlap options"
    },
    {
      "$ref": "#/$defs/strand options"
    },
    {
      "$ref": "#/$defs/subtraction behavior"
    },
    {
      "$ref": "#/$defs/output format options"
    },
    {
      "$ref": "#/$defs/performance options"
    },
    {
      "$ref": "#/$defs/nextflow input-output arguments"
    }
  ]
}
