{
    "$schema": "http://json-schema.org/draft-07/schema",
    "$id": "https://raw.githubusercontent.com/nf-core/bcellmagic/master/nextflow_schema.json",
    "title": "nf-core/bcellmagic pipeline parameters",
    "description": "B and T cell repertoire analysis pipeline with the Immcantation framework.",
    "type": "object",
    "definitions": {
        "input_output_options": {
            "title": "Input/output options",
            "type": "object",
            "fa_icon": "fas fa-terminal",
            "description": "Define where the pipeline should find input data and save output data.",
            "required": [
                "input"
            ],
            "properties": {
                "input": {
                    "type": "string",
                    "fa_icon": "fas fa-dna",
                    "description": "Path to a tsv file providing paths to the fastq files for each sample and the necessary metadata for the analysis.",
                    "help_text": "The input file includes important sample metadata and the path to the R1 and R2 fastq files, and index read file (I), if available. The file should include the following columns, separated with tabs, with exactly these header names:\n\n```bash\nID Source Treatment Extraction_time Population R1 R2 I1\nQMKMK072AD Patient_2 Drug_treatment baseline p sample_S8_L001_R1_001.fastq.gz sample_S8_L001_R2_001.fastq.gz sample_S8_L001_I1_001.fastq.gz\n```\n\nThis metadata will then be automatically annotated in a column with the same header in the tables outputed by the pipeline. Where:\n\n* ID: sample ID.\n* Source: patient or organism code.\n* Treatment: treatment condition applied to the sample.\n* Extraction_time: time of cell extraction for the sample.\n* Population: B-cell population (e.g. naive, double-negative, memory, plasmablast).\n* R1: path to fastq file with first mates of paired-end sequencing.\n* R2: path to fastq file with second mates of paired-end sequencing.\n* I1: path to fastq with illumina index and UMI (unique molecular identifier) barcode (optional column)\n\nSpecify the path for your input file like this:\n\n```bash\n--input 'path/to/metadata/metadata_sheet.tsv'\n```"
                },
                "cprimers": {
                    "type": "string",
                    "fa_icon": "fas fa-dna",
                    "description": "Path to a fasta file containing the C-region primer sequences."
                },
                "vprimers": {
                    "type": "string",
                    "fa_icon": "fas fa-dna",
                    "description": "Path to a fasta file containinc the V-region primer sequences."
                },
                "outdir": {
                    "type": "string",
                    "description": "Path to the output directory where the results will be saved.",
                    "default": "./results",
                    "fa_icon": "fas fa-folder-open"
                },
                "email": {
                    "type": "string",
                    "description": "Email address for completion summary.",
                    "fa_icon": "fas fa-envelope",
                    "help_text": "Set this parameter to your e-mail address to get a summary e-mail with details of the run sent to you when the workflow exits. If set in your user config file (`~/.nextflow/config`) then you don't need to specify this on the command line for every run.",
                    "pattern": "^([a-zA-Z0-9_\\-\\.]+)@([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,5})$"
                },
                "multiqc_title": {
                    "type": "string",
                    "description": "MultiQC report title. Printed as page header, used for filename if not otherwise specified.",
                    "fa_icon": "fas fa-file-signature"
                }
            }
        },
        "databases_cache": {
            "title": "Databases cache",
            "type": "object",
            "description": "Define the paths to the igblast and IMGT databases if you have them cached.",
            "default": "",
            "properties": {
                "igblast_base": {
                    "type": "string",
                    "description": "Path to the cached igblast database.",
                    "help_text": "If it is not provided, the database will be newly downloaded.",
                    "fa_icon": "fas fa-database"
                },
                "imgtdb_base": {
                    "type": "string",
                    "description": "Path to the cached igblast database.",
                    "help_text": "If it is not provided, the database will be newly downloaded.",
                    "fa_icon": "fas fa-database"
                },
                "save_databases": {
                    "type": "boolean",
                    "description": "Save databases so you can use the cache in future runs.",
                    "fa_icon": "fas fa-file-download"
                },
                "species": {
                    "type": "string",
                    "default": "human",
                    "description": "Species to perform Igblast. Choose from: human, mouse.",
                    "enum": [
                        "human",
                        "mouse"
                    ]
                },
                "loci": {
                    "type": "string",
                    "default": "ig",
                    "enum": [
                        "ig",
                        "tr"
                    ],
                    "description": "Loci to perform Igblast. Choose from: ig (BCR / Immunoglobulins), tr (TCR)."
                }
            },
            "help_text": "",
            "fa_icon": "fas fa-database"
        },
        "primer_handling": {
            "title": "Primer handling",
            "type": "object",
            "description": "Define the primer region start and how to deal with the primer alignment.",
            "default": "",
            "properties": {
                "protocol": {
                    "type": "string",
                    "default": "pcr_umi",
                    "fa_icon": "fas fa-flask",
                    "description": "Protocol used for the V(D)J amplicon sequencing.",
                    "enum": [
                        "pcr_umi",
                        "race_5p_umi"
                    ],
                    "help_text": "Available protocols are:\n- `pcr_umi`: (default). PCR amplification with UMI barcodes. Please also provide the C-primer (`--cprimers`) and V-primer (`--vprimers`) sequences, specify the UMI barcode length (`--umi_length`) and position (`--umi_position`), the V-primer start (`--vprimer_start`), and C-primer start (`--cprimer_start`) and position (`--cprimer_position`).\n- `race_5p_umi`: 5'-RACE amplification with UMI barcodes. Please also provide the C-primer (`--cprimers`) and linker or template switch oligo sequences (`--race_linker`), specify the UMI barcode length (`--umi_length`) and position (`--umi_position`), the C-primer start (`--cprimer_start`) and position (`--cprimer_position`)."
                },
                "vprimer_start": {
                    "type": "integer",
                    "description": "Start position of V region primers (without counting the UMI barcode).",
                    "fa_icon": "fas fa-dna"
                },
                "cprimer_start": {
                    "type": "integer",
                    "description": "Start position of C region primers (without counting the UMI barcode).",
                    "fa_icon": "fas fa-dna"
                },
                "race_linker": {
                    "type": "string",
                    "description": "Path to fasta file containing the linker sequence, if no V-region primers were used but a linker sequence is present (e.g. 5' RACE SMARTer TAKARA protocol).",
                    "fa_icon": "fas fa-dna"
                },
                "cprimer_position": {
                    "type": "string",
                    "default": "R1",
                    "fa_icon": "fas fa-dna",
                    "description": "Indicate if C region primers are in the R1 or R2 reads.",
                    "enum": [
                        "R1",
                        "R2"
                    ]
                }
            },
            "fa_icon": "fas fa-dna"
        },
        "umi_barcode_handling": {
            "title": "UMI barcode handling",
            "type": "object",
            "description": "Define how UMI barcodes should be treated.",
            "default": "",
            "properties": {
                "index_file": {
                    "type": "boolean",
                    "description": "Indicate if UMI indices are recorded in a separate index file.",
                    "help_text": "Set to `true` if UMI barcodes are to be read from a separate illumina index fastq file. If Illumina indices and UMI barcodes are already integrated into the R1 reads, leave the default `--index_file false`.\n\nThe pipeline requires UMI barcodes for identifying unique transcripts. These barcodes are typically read from an index file but sometimes can be provided merged with the start of the R1 or R2 reads. If provided in an additional index file, set the `--index_file` parameter, if provided merged with the R1 or R2 reads, set the `--umi_position` parameter.",
                    "fa_icon": "fas fa-barcode"
                },
                "umi_position": {
                    "type": "string",
                    "default": "R1",
                    "description": "Indicate if UMI indices are recorded in the R1 (default) or R1 fastq file.",
                    "help_text": "The pipeline requires UMI barcodes for identifying unique transcripts. These barcodes are typically read from an index file but sometimes can be provided merged with the start of the R1 or R2 reads. If provided in an additional index file, set the `--index_file` parameter, if provided merged with the R1 or R2 reads, set the `--umi_position` parameter to R1 or R2, respectively.",
                    "enum": [
                        "R1",
                        "R2"
                    ],
                    "fa_icon": "fas fa-barcode"
                },
                "umi_length": {
                    "type": "integer",
                    "description": "UMI barcode length in nucleotides.",
                    "fa_icon": "fas fa-barcode",
                    "default": 8
                },
                "umi_start": {
                    "type": "integer",
                    "description": "UMI barcode start position.",
                    "fa_icon": "fas fa-barcode"
                }
            },
            "help_text": "The pipeline requires UMI barcodes for identifying unique\ntranscripts. These barcodes are typically read from an index file but sometimes can be provided merged with the start of the R1 or R2 reads. If provided in an additional index file, set the `--index_file` parameter, if provided merged with the R1 or R2 reads, set the `--umi_position` parameter. Specify the UMI barcode length with the `--umi_length` parameter.",
            "required": [
                "umi_length"
            ],
            "fa_icon": "fas fa-barcode"
        },
        "presto_options": {
            "title": "Presto options",
            "type": "object",
            "description": "Options for the presto tools",
            "default": "",
            "properties": {
                "filterseq_q": {
                    "type": "integer",
                    "default": 20,
                    "description": "Quality threshold for Presto FilterSeq sequence filtering.",
                    "fa_icon": "fas fa-filter"
                },
                "primer_mask_mode": {
                    "type": "string",
                    "default": "cut",
                    "description": "Masking mode for the Presto MaskPrimer process. Available: cut, mask, trim, tag.",
                    "enum": [
                        "cut",
                        "mask",
                        "trim",
                        "tag"
                    ],
                    "help_text": "The primer masking modes will perform the following actions:\n\n* `cut`: remove both the primer region and the preceding sequence.\n* `mask`: replace the primer region with Ns and remove the preceding sequence.\n* `trim`: remove the region preceding the primer, but leave the primer region intact.\n* `tag`: leave the input sequence unmodified.",
                    "fa_icon": "fas fa-cut"
                },
                "primer_maxerror": {
                    "type": "number",
                    "default": 0.2,
                    "description": "Maximum scoring error for the Presto MaxPrimer process for the C and/or V region primers identification.",
                    "fa_icon": "fas fa-exclamation-triangle"
                },
                "primer_consensus": {
                    "type": "number",
                    "default": 0.6,
                    "description": "Maximum error for building the primer consensus.",
                    "fa_icon": "fas fa-align-center"
                }
            },
            "fa_icon": "fas fa-align-center"
        },
        "clustering_threshold_definition": {
            "title": "Clustering threshold definition",
            "type": "object",
            "description": "Define how the B-cell clonal trees should be calculated.",
            "default": "",
            "properties": {
                "set_cluster_threshold": {
                    "type": "boolean",
                    "description": "Set to true if to manually adjust the clustering threshold for cell clones.",
                    "help_text": "Set the `--set_cluster_threshold` parameter to allow manual cluster hamming distance threshold definition. Then specify the value in the `--cluster_threshold` parameter.\n\nBy default, the pipeline will define clones for each of the samples, as two sequences having the same V gene assignment, C gene assignment, J-gene assignment, and junction length. Additionally, the similarity of the junction region sequences will be assessed by hamming distances. A distance threshold for determining if two sequences come from the same clone is automatically determined by the process shazam. Alternatively, a hamming distance threshold can be manually set by setting the `--set_cluster_threshold` and `--cluster_threshold` parameters.",
                    "fa_icon": "fab fa-pagelines"
                },
                "cluster_threshold": {
                    "type": "number",
                    "default": 0.14,
                    "description": "Set the clustering threshold Hamming distance value.",
                    "help_text": "To have any effect, the  `--set_cluster_threshold` parameter needs to be set to `true`.\n\nBy default, the pipeline will define clones for each of the samples, as two sequences having the same V gene assignment, C gene assignment, J-gene assignment, and junction length. Additionally, the similarity of the junction region sequences will be assessed by hamming distances. A distance threshold for determining if two sequences come from the same clone is automatically determined by the process shazam. Alternatively, a hamming distance threshold can be manually set by setting the `--set_cluster_threshold` and `--cluster_threshold` parameters.",
                    "fa_icon": "fab fa-pagelines"
                },
                "threshold_method": {
                    "type": "string",
                    "default": "density",
                    "description": "Set the method for finding the clustering threshold.",
                    "help_text": "This method will be used to find the Hamming nearest neighbor distances threshold for determining if a sequence belongs to the same B/T-cell clone or not. Available methods are \"gmm\" for a maximum-likelihood Gamma or Gaussian mixture fitting, and \"density\" for fitting a binned approximation to the ordinary kernel density estimate to the nearest neighbor distances.",
                    "fa_icon": "fab fa-pagelines"
                }
            },
            "help_text": "By default, the pipeline will define clones for each of the samples, as two sequences having the same V gene assignment, C gene assignment, J-gene assignment, and junction length. Additionally, the similarity of the CDR3 sequences will be assessed by Hamming distances. \n\nA distance threshold for determining if two sequences come from the same clone or not is automatically determined by the process shazam. Alternatively, a hamming distance threshold can be  manually set   by setting the `--set_cluster_threshold` and `--cluster_threshold` parameters.",
            "fa_icon": "fab fa-pagelines"
        },
        "downstream_options": {
            "title": "Downstream options",
            "type": "object",
            "description": "Define downstream analysis options.",
            "default": "",
            "properties": {
                "skip_report": {
                    "type": "boolean",
                    "description": "Skip repertoire analysis and report generation."
                },
                "skip_lineage": {
                    "type": "boolean",
                    "description": "Skip clonal lineage analysis and lineage tree plotting."
                },
                "skip_multiqc": {
                    "type": "boolean",
                    "description": "Skip multiqc report generation."
                }
            },
            "help_text": "Downstream analyses include a series of R scripts based on the Immcantation Alakazam, ChangeO and Shazam packages to calculate:\n- Clonal abundance and diversity\n- Clonal lineage tree export in graphML\n- Clonal overlap and statistics\n- Mutational load\n- Isotype and V-family distribution",
            "fa_icon": "fas fa-angle-double-right"
        },
        "reference_genome_options": {
            "title": "Reference genome options",
            "type": "object",
            "fa_icon": "fas fa-dna",
            "description": "Options for the reference genome indices used to align reads.",
            "properties": {
                "igenomes_base": {
                    "type": "string",
                    "format": "directory-path",
                    "description": "Directory / URL base for iGenomes references.",
                    "default": "s3://ngi-igenomes/igenomes",
                    "fa_icon": "fas fa-cloud-download-alt",
                    "hidden": true
                },
                "igenomes_ignore": {
                    "type": "boolean",
                    "description": "Do not load the iGenomes reference config.",
                    "fa_icon": "fas fa-ban",
                    "hidden": true,
                    "help_text": "Do not load `igenomes.config` when running the pipeline. You may choose this option if you observe clashes between custom parameters and those supplied in `igenomes.config`.",
                    "default": true
                }
            }
        },
        "institutional_config_options": {
            "title": "Institutional config options",
            "type": "object",
            "fa_icon": "fas fa-university",
            "description": "Parameters used to describe centralised config profiles. These should not be edited.",
            "help_text": "The centralised nf-core configuration profiles use a handful of pipeline parameters to describe themselves. This information is then printed to the Nextflow log when you run a pipeline. You should not need to change these values when you run a pipeline.",
            "properties": {
                "custom_config_version": {
                    "type": "string",
                    "description": "Git commit id for Institutional configs.",
                    "default": "master",
                    "hidden": true,
                    "fa_icon": "fas fa-users-cog"
                },
                "custom_config_base": {
                    "type": "string",
                    "description": "Base directory for Institutional configs.",
                    "default": "https://raw.githubusercontent.com/nf-core/configs/master",
                    "hidden": true,
                    "help_text": "If you're running offline, Nextflow will not be able to fetch the institutional config files from the internet. If you don't need them, then this is not a problem. If you do need them, you should download the files from the repo and tell Nextflow where to find them with this parameter.",
                    "fa_icon": "fas fa-users-cog"
                },
                "hostnames": {
                    "type": "string",
                    "description": "Institutional configs hostname.",
                    "hidden": true,
                    "fa_icon": "fas fa-users-cog"
                },
                "config_profile_name": {
                    "type": "string",
                    "description": "Institutional config name.",
                    "hidden": true,
                    "fa_icon": "fas fa-users-cog"
                },
                "config_profile_description": {
                    "type": "string",
                    "description": "Institutional config description.",
                    "hidden": true,
                    "fa_icon": "fas fa-users-cog"
                },
                "config_profile_contact": {
                    "type": "string",
                    "description": "Institutional config contact information.",
                    "hidden": true,
                    "fa_icon": "fas fa-users-cog"
                },
                "config_profile_url": {
                    "type": "string",
                    "description": "Directory to keep pipeline Nextflow logs and reports.",
                    "default": "${params.outdir}/pipeline_info",
                    "fa_icon": "fas fa-cogs",
                    "hidden": true
                }
            }
        },
        "max_job_request_options": {
            "title": "Max job request options",
            "type": "object",
            "fa_icon": "fab fa-acquisitions-incorporated",
            "description": "Set the top limit for requested resources for any single job.",
            "help_text": "If you are running on a smaller system, a pipeline step requesting more resources than are available may cause the Nextflow to stop the run with an error. These options allow you to cap the maximum resources requested by any single job so that the pipeline will run on your system.\n\nNote that you can not _increase_ the resources requested by any job using these options. For that you will need your own configuration file. See [the nf-core website](https://nf-co.re/usage/configuration) for details.",
            "properties": {
                "max_cpus": {
                    "type": "integer",
                    "description": "Maximum number of CPUs that can be requested for any single job.",
                    "default": 16,
                    "fa_icon": "fas fa-microchip",
                    "hidden": true,
                    "help_text": "Use to set an upper-limit for the CPU requirement for each process. Should be an integer e.g. `--max_cpus 1`"
                },
                "max_memory": {
                    "type": "string",
                    "description": "Maximum amount of memory that can be requested for any single job.",
                    "default": "128.GB",
                    "fa_icon": "fas fa-memory",
                    "pattern": "^\\d+(\\.\\d+)?\\.?\\s*(K|M|G|T)?B$",
                    "hidden": true,
                    "help_text": "Use to set an upper-limit for the memory requirement for each process. Should be a string in the format integer-unit e.g. `--max_memory '8.GB'`"
                },
                "max_time": {
                    "type": "string",
                    "description": "Maximum amount of time that can be requested for any single job.",
                    "default": "240.h",
                    "fa_icon": "far fa-clock",
                    "pattern": "^(\\d+\\.?\\s*(s|m|h|day)\\s*)+$",
                    "hidden": true,
                    "help_text": "Use to set an upper-limit for the time requirement for each process. Should be a string in the format integer-unit e.g. `--max_time '2.h'`"
                }
            }
        },
        "generic_options": {
            "title": "Generic options",
            "type": "object",
            "fa_icon": "fas fa-file-import",
            "description": "Less common options for the pipeline, typically set in a config file.",
            "help_text": "These options are common to all nf-core pipelines and allow you to customise some of the core preferences for how the pipeline runs.\n\nTypically these options would be set in a Nextflow config file loaded for all pipeline runs, such as `~/.nextflow/config`.",
            "properties": {
                "help": {
                    "type": "boolean",
                    "description": "Display help text.",
                    "fa_icon": "fas fa-question-circle",
                    "hidden": true
                },
                "publish_dir_mode": {
                    "type": "string",
                    "default": "copy",
                    "description": "Method used to save pipeline results to output directory.",
                    "help_text": "The Nextflow `publishDir` option specifies which intermediate files should be saved to the output directory. This option tells the pipeline what method should be used to move these files. See [Nextflow docs](https://www.nextflow.io/docs/latest/process.html#publishdir) for details.",
                    "fa_icon": "fas fa-copy",
                    "enum": [
                        "symlink",
                        "rellink",
                        "link",
                        "copy",
                        "copyNoFollow",
                        "move"
                    ],
                    "hidden": true
                },
                "email_on_fail": {
                    "type": "string",
                    "description": "Email address for completion summary, only when pipeline fails.",
                    "fa_icon": "fas fa-exclamation-triangle",
                    "pattern": "^([a-zA-Z0-9_\\-\\.]+)@([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,5})$",
                    "help_text": "An email address to send a summary email to when the pipeline is completed - ONLY sent if the pipeline does not exit successfully.",
                    "hidden": true
                },
                "plaintext_email": {
                    "type": "boolean",
                    "description": "Send plain-text email instead of HTML.",
                    "fa_icon": "fas fa-remove-format",
                    "hidden": true
                },
                "max_multiqc_email_size": {
                    "type": "string",
                    "description": "File size limit when attaching MultiQC reports to summary emails.",
                    "pattern": "^\\d+(\\.\\d+)?\\.?\\s*(K|M|G|T)?B$",
                    "default": "25.MB",
                    "fa_icon": "fas fa-file-upload",
                    "hidden": true
                },
                "monochrome_logs": {
                    "type": "boolean",
                    "description": "Do not use coloured log outputs.",
                    "fa_icon": "fas fa-palette",
                    "hidden": true
                },
                "multiqc_config": {
                    "type": "string",
                    "description": "Custom config file to supply to MultiQC.",
                    "fa_icon": "fas fa-cog",
                    "hidden": true
                },
                "tracedir": {
                    "type": "string",
                    "description": "Directory to keep pipeline Nextflow logs and reports.",
                    "default": "${params.outdir}/pipeline_info",
                    "fa_icon": "fas fa-cogs",
                    "hidden": true
                },
                "validate_params": {
                    "type": "boolean",
                    "description": "Boolean whether to validate parameters against the schema at runtime",
                    "default": true,
                    "fa_icon": "fas fa-check-square",
                    "hidden": true
                },
                "show_hidden_params": {
                    "type": "boolean",
                    "fa_icon": "far fa-eye-slash",
                    "description": "Show all params when using `--help`",
                    "hidden": true,
                    "help_text": "By default, parameters set as _hidden_ in the schema are not shown on the command line when a user runs with `--help`. Specifying this option will tell the pipeline to show all parameters."
                },
                "enable_conda": {
                    "type": "boolean",
                    "description": "Run this workflow with Conda. You can also use '-profile conda' instead of providing this parameter.",
                    "hidden": true,
                    "fa_icon": "fas fa-bacon"
                },
                "singularity_pull_docker_container": {
                    "type": "boolean",
                    "description": "Instead of directly downloading Singularity images for use with Singularity, force the workflow to pull and convert Docker containers instead.",
                    "hidden": true,
                    "fa_icon": "fas fa-toolbox",
                    "help_text": "This may be useful for example if you are unable to directly pull Singularity containers to run the pipeline due to http/https proxy issues."
                }
            }
        }
    },
    "allOf": [
        {
            "$ref": "#/definitions/input_output_options"
        },
        {
            "$ref": "#/definitions/databases_cache"
        },
        {
            "$ref": "#/definitions/primer_handling"
        },
        {
            "$ref": "#/definitions/umi_barcode_handling"
        },
        {
            "$ref": "#/definitions/presto_options"
        },
        {
            "$ref": "#/definitions/clustering_threshold_definition"
        },
        {
            "$ref": "#/definitions/downstream_options"
        },
        {
            "$ref": "#/definitions/reference_genome_options"
        },
        {
            "$ref": "#/definitions/institutional_config_options"
        },
        {
            "$ref": "#/definitions/max_job_request_options"
        },
        {
            "$ref": "#/definitions/generic_options"
        }
    ]
}
