{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "bedtools_bamtobed",
  "description": "Converts BAM alignments to BED6 or BEDPE format.\n\nThis tool converts alignments in BAM format to either BED6 or BEDPE format,\nallowing for flexible downstream analysis of genomic intervals.\n",
  "type": "object",
  "$defs": {
    "inputs": {
      "title": "Inputs",
      "type": "object",
      "description": "No description",
      "properties": {
        "input": {
          "type": "string",
          "format": "path",
          "exists": true,
          "description": "Input BAM file containing aligned sequences.\n\n**Requirements:**\n- Must be in SAM/BAM format\n- For paired-end BEDPE output (`--bedpe`), must be grouped or sorted by query name\n",
          "help_text": "Type: `file`, multiple: `False`, required, direction: `input`, example: `\"input.bam\"`. "
        }
      }
    },
    "outputs": {
      "title": "Outputs",
      "type": "object",
      "description": "No description",
      "properties": {
        "output": {
          "type": "string",
          "format": "path",
          "description": "Output file in BED or BEDPE format.\n\n**Output formats:**\n- Default: BED6 format (6 columns)\n- With `--bedpe`: BEDPE format for paired-end data\n- With `--bed12`: BED12 format with blocked intervals\n",
          "help_text": "Type: `file`, multiple: `False`, required, default: `\"$id.$key.output.bed\"`, direction: `output`, example: `\"output.bed\"`. ",
          "default": "$id.$key.output.bed"
        }
      }
    },
    "options": {
      "title": "Options",
      "type": "object",
      "description": "No description",
      "properties": {
        "bedpe": {
          "type": "boolean",
          "description": "Write BEDPE format for paired-end data.\n\n**Requirements:**\n- BAM must be grouped or sorted by query name\n- Produces paired-end BED format with mate information\n",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "mate1": {
          "type": "boolean",
          "description": "When writing BEDPE format (`--bedpe`), always report mate one as the first BEDPE block.\n\nEnsures consistent ordering of paired-end reads in output.\n",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "bed12": {
          "type": "boolean",
          "description": "Write blocked BED format (BED12 format).\n\n**Features:**\n- Creates 12-column BED format with block information\n- Automatically forces `--split` option\n- Useful for representing spliced alignments\n\nSee [BED12 format specification](http://genome-test.cse.ucsc.edu/FAQ/FAQformat#format1) for details.\n",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "split": {
          "type": "boolean",
          "description": "Report split BAM alignments as separate BED entries.\n\n**Behavior:**\n- Splits only on **N** CIGAR operations (introns/gaps)\n- Each split becomes a separate BED interval\n- Useful for RNA-seq data with spliced alignments\n",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "splitD": {
          "type": "boolean",
          "description": "Split alignments based on both **N** and **D** CIGAR operators.\n\n**Features:**\n- Splits on N (gaps/introns) and D (deletions) operations\n- Automatically forces `--split` option\n- More aggressive splitting than `--split` alone\n",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "edit_distance": {
          "type": "boolean",
          "description": "Use BAM edit distance (NM tag) for BED score instead of mapping quality.\n\n**Scoring behavior:**\n- **Default BED**: Uses mapping quality as score\n- **Default BEDPE**: Uses minimum of two mapping qualities\n- **With --ed + --bedpe**: Reports total edit distance from both mates\n",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "tag": {
          "type": "string",
          "description": "Use other numeric BAM alignment tag for BED score.\n\n**Usage:**\n- Specify any numeric BAM tag (e.g., `SM`, `AS`, `XS`)\n- Replaces default mapping quality scoring\n- **Not allowed** with BEDPE output format\n",
          "help_text": "Type: `string`, multiple: `False`, example: `\"SM\"`. "
        },
        "color": {
          "type": "string",
          "description": "RGB color string for BED12 format visualization.\n\n**Format:** R,G,B values (0-255 each)\n\n**Default:** `255,0,0` (red)\n",
          "help_text": "Type: `string`, multiple: `False`, example: `\"255,0,0\"`. "
        },
        "cigar": {
          "type": "boolean",
          "description": "Add the CIGAR string as a 7th column in BED output.\n\nUseful for preserving alignment information in BED format.\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"
    }
  ]
}
