{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://raw.githubusercontent.com/nf-core/proteinfamilies/main/nextflow_schema.json",
    "title": "nf-core/proteinfamilies pipeline parameters",
    "description": "Generate protein family level models (Multiple Sequence Alignments (MSAs), Hidden Markov Models (HMMs)) starting from a FASTA amino acid sequence file.",
    "type": "object",
    "$defs": {
        "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", "outdir"],
            "properties": {
                "input": {
                    "type": "string",
                    "format": "file-path",
                    "exists": true,
                    "schema": "assets/schema_input.json",
                    "mimetype": "text/csv",
                    "pattern": "^\\S+\\.csv$",
                    "description": "Path to comma-separated file '.csv' containing information about the samples in the experiment.",
                    "help_text": "You will need to create a design file with information about the samples in your experiment before running the pipeline. Use this parameter to specify its location. It has to be a comma-separated file '.csv' with 3 columns, and a header row. See [usage docs](https://nf-co.re/proteinfamilies/usage#samplesheet-input).",
                    "fa_icon": "fas fa-file-csv"
                },
                "outdir": {
                    "type": "string",
                    "format": "directory-path",
                    "description": "The output directory where the results will be saved. You have to use absolute paths to storage on Cloud infrastructure.",
                    "help_text": "You will need to define where your results will be saved. Use this parameter to specify the location.",
                    "fa_icon": "fas fa-folder-open"
                },
                "email": {
                    "type": "string",
                    "description": "Email address for completion summary. Example: name.surname@example.com",
                    "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"
                }
            }
        },
        "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"
                },
                "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": "Institutional config URL link.",
                    "hidden": true,
                    "fa_icon": "fas fa-users-cog"
                },
                "modules_testdata_base_path": {
                    "type": "string",
                    "description": "Base path / URL for data used in the modules",
                    "hidden": true
                }
            }
        },
        "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": {
                "version": {
                    "type": "boolean",
                    "description": "Display version and exit.",
                    "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. Example: name.surname@example.com",
                    "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. Example: name.surname@example.com",
                    "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
                },
                "hook_url": {
                    "type": "string",
                    "description": "Incoming hook URL for messaging service",
                    "fa_icon": "fas fa-people-group",
                    "help_text": "Incoming hook URL for messaging service. Currently, MS Teams and Slack are supported.",
                    "hidden": true
                },
                "multiqc_config": {
                    "type": "string",
                    "format": "file-path",
                    "description": "Custom config file to supply to MultiQC.",
                    "fa_icon": "fas fa-cog",
                    "hidden": true
                },
                "multiqc_logo": {
                    "type": "string",
                    "description": "Custom logo file to supply to MultiQC. File name must also be set in the MultiQC config file",
                    "fa_icon": "fas fa-image",
                    "hidden": true
                },
                "multiqc_methods_description": {
                    "type": "string",
                    "description": "Custom MultiQC yaml file containing HTML including a methods description.",
                    "fa_icon": "fas fa-cog"
                },
                "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
                },
                "pipelines_testdata_base_path": {
                    "type": "string",
                    "fa_icon": "far fa-check-circle",
                    "description": "Base URL or local path to location of pipeline test dataset files",
                    "default": "https://raw.githubusercontent.com/nf-core/test-datasets/proteinfamilies/",
                    "hidden": true
                },
                "trace_report_suffix": {
                    "type": "string",
                    "fa_icon": "far calendar",
                    "description": "Suffix to add to the trace report filename. Default is the date and time in the format yyyy-MM-dd_HH-mm-ss.",
                    "hidden": true
                },
                "help": {
                    "type": ["boolean", "string"],
                    "description": "Display the help message."
                },
                "help_full": {
                    "type": "boolean",
                    "description": "Display the full detailed help message."
                },
                "show_hidden": {
                    "type": "boolean",
                    "description": "Display hidden parameters in the help message (only works when --help or --help_full are provided)."
                }
            }
        },
        "quality_check_params": {
            "title": "Quality check parameters",
            "type": "object",
            "description": "Use these parameters to control the flow of the quality check subworkflow execution.",
            "properties": {
                "skip_preprocessing": {
                    "type": "boolean",
                    "fa_icon": "fas fa-ban",
                    "description": "Skip all default QC steps for sequences (gap trimming, length filtering, validation, duplicate removal).",
                    "help": "Skips input amino acid sequence preprocessing transformations, length filtering, duplicate removal and validation checks."
                },
                "min_seq_length": {
                    "type": "integer",
                    "default": 30,
                    "fa_icon": "fas fa-ruler-horizontal",
                    "description": "The minimum allowed sequence length",
                    "help_text": "Specify the minimum length of amino acid sequences that go into clustering."
                },
                "max_seq_length": {
                    "type": "integer",
                    "default": 5000,
                    "fa_icon": "fas fa-ruler-horizontal",
                    "description": "The maximum allowed sequence length",
                    "help_text": "Specify the maximum length of amino acid sequences that go into clustering."
                },
                "remove_duplicates_on_sequence": {
                    "type": "boolean",
                    "description": "Remove duplicate input amino acid sequences, based on the sequence.",
                    "help": "Instead of just removing by similar identifier, the tool also removes duplicate sequences."
                }
            }
        },
        "clustering_params": {
            "title": "Clustering parameters",
            "type": "object",
            "description": "Use these parameters to control the flow of the clustering subworkflow execution.",
            "properties": {
                "save_mmseqs_db": {
                    "type": "boolean",
                    "description": "Save the db output folder of mmseqs createdb",
                    "help_text": "Specify to save the mmseqs formatted database of input fasta sequences."
                },
                "clustering_tool": {
                    "type": "string",
                    "default": "cluster",
                    "description": "Choose clustering algorithm. Either simple 'cluster' for medium size inputs, or 'linclust' for less sensitive clustering of larger datasets.",
                    "help_text": "mmseqs algorithms available: 'cluster' or 'linclust'.",
                    "enum": ["linclust", "cluster"]
                },
                "cluster_seq_identity": {
                    "type": "number",
                    "default": 0.3,
                    "minimum": 0.0,
                    "maximum": 1.0,
                    "description": "mmseqs parameter for minimum sequence identity",
                    "help_text": "Minimum sequence identity required for clustering. Metagenomics protein families include diverse sequences, so using the mmseqs default identity (0.9) would oversplit them. A default value of 0.3 allows grouping more distant homologs while still maintaining meaningful functional relationships (https://doi.org/10.1093/protein/12.2.85)."
                },
                "cluster_coverage": {
                    "type": "number",
                    "default": 0.5,
                    "minimum": 0.0,
                    "maximum": 1.0,
                    "description": "mmseqs parameter for minimum sequence coverage ratio",
                    "help_text": "Minimum sequence length coverage required for clustering. Similarly to the cluster_seq_identity parameter, a lower value (i.e., 0.5) than the mmseqs default (i.e., 0.8) enables the generation of protein families that are composed of more distant homologs."
                },
                "cluster_cov_mode": {
                    "type": "integer",
                    "default": 0,
                    "description": "mmseqs parameter for coverage mode: 0 for both, 1 for target and 2 for query sequence",
                    "help_text": "Defined by the number of aligned residue pairs divided by 0: the maximum of the length of query/centre and target/non-centre sequences, 1: the length of the target/non-centre sequence, 2: the length of the query/centre"
                },
                "save_mmseqs_clustering": {
                    "type": "boolean",
                    "description": "Save the clustering output folder of mmseqs cluster or linclust",
                    "help_text": "Specify to save the mmseqs formatted result clustering."
                },
                "cluster_size_threshold": {
                    "type": "integer",
                    "default": 25,
                    "description": "Minimum clustering chunk size threshold to create seed Multiple Sequence Alignments upon.",
                    "help_text": "This is an initial filter for the mmseqs clustering results. The lower the threshold, the more families will be generated. Additional sequences may be later recruited in the families."
                },
                "save_mmseqs_chunked_fasta": {
                    "type": "boolean",
                    "description": "Save membership-filtered initial mmseqs clusters in fasta format",
                    "help_text": "Specify to save the mmseqs clusters in fasta format."
                }
            }
        },
        "alignment_params": {
            "title": "Alignment parameters",
            "type": "object",
            "description": "Use these parameters to control the Multiple Sequence Alignment subworkflow execution.",
            "properties": {
                "alignment_tool": {
                    "type": "string",
                    "description": "Choose alignment tool. FAMSA is recommended as best time-memory-accuracy combination option.",
                    "help_text": "Available tools: 'famsa' or 'mafft'.",
                    "enum": ["famsa", "mafft"]
                },
                "skip_msa_trimming": {
                    "type": "boolean",
                    "description": "Boolean whether to skip the trimming process of gappy positions from Multiple Sequence Alignments (MSAs)",
                    "default": false,
                    "fa_icon": "fas fa-check-square",
                    "hidden": true
                },
                "clipkit_out_format": {
                    "type": "string",
                    "default": "clipkit",
                    "description": "Choose the output format of the clipped alignment.",
                    "help_text": "Make sure this is different than the input extension format, otherwise the tool won't run (i.e., != aln for famsa and != fas for mafft)."
                },
                "trim_ends_only": {
                    "type": "boolean",
                    "default": true,
                    "description": "Choose if ClipKIT should only clip gaps at the ends of the MSAs.",
                    "help_text": "By default, ClipKIT clips gaps over the specified threshold, both at the ends and throughout the length of the MSA. This flag restricts clipping to the ends"
                },
                "gap_threshold": {
                    "type": "number",
                    "default": 0.5,
                    "minimum": 0.0,
                    "maximum": 1.0,
                    "description": "Multiple Sequence Alignment (MSA) positions with gappiness greater than this threshold will be trimmed"
                },
                "skip_additional_sequence_recruiting": {
                    "type": "boolean",
                    "description": "Skip recruitment of additional sequences from the input FASTA file using the family Hidden Markov Models (HMMs) into the full alignment",
                    "default": false,
                    "fa_icon": "fas fa-check-square",
                    "hidden": true,
                    "help_text": "If this is set to false, the hmmer/hmmsearch module will be used to recruit additional sequences from the input fasta file into the family (above the hmmsearch_query_length_threshold), resulting in bigger but better described families"
                },
                "hmmsearch_write_target": {
                    "type": "boolean",
                    "description": "Boolean whether to generate target results file of hmmsearch",
                    "default": false,
                    "fa_icon": "fas fa-check-square",
                    "hidden": true,
                    "help_text": "Specify to calculate the hmmsearch tabular (space-delimited) summary of per-target output (*.tbl.gz)."
                },
                "hmmsearch_write_domain": {
                    "type": "boolean",
                    "description": "Boolean whether to generate domain results file of hmmsearch",
                    "default": true,
                    "fa_icon": "fas fa-check-square",
                    "hidden": true,
                    "help_text": "Specify to calculate the hmmsearch tabular (space-delimited) summary of per-domain output (*.domtbl.gz)."
                },
                "hmmsearch_evalue_cutoff": {
                    "type": "number",
                    "default": 0.001,
                    "description": "hmmsearch e-value cutoff threshold for reported results"
                },
                "save_hmmsearch_results": {
                    "type": "boolean",
                    "description": "Save the output of hmmsearch (.domtbl.gz and .tbl.gz)",
                    "help_text": "Specify to save the .domtbl.gz and .tbl.gz files generated by running hmmsearch on the family model against the input set of sequences."
                },
                "hmmsearch_query_length_threshold": {
                    "type": "number",
                    "default": 0.9,
                    "minimum": 0.0,
                    "maximum": 1.0,
                    "description": "hmmsearch minimum length percentage filter of hit env vs query length",
                    "help_text": "This length threshold should be quite high to make sure that small, fragmented sequences are not recruited in the family models"
                },
                "save_hmmsearch_filtered_fasta": {
                    "type": "boolean",
                    "description": "Save family fasta files after recruiting sequences with hmmsearch",
                    "help_text": "Specify to save the extended family fasta files with all hmmsearch recruited sequences."
                }
            }
        },
        "redundancy_params": {
            "title": "Redundancy removal parameters",
            "type": "object",
            "description": "Use these parameters to control the redundancy removal subworkflow execution.",
            "properties": {
                "skip_family_redundancy_removal": {
                    "type": "boolean",
                    "description": "Skip removal of between-family redundancy via hmmsearch sequence to family model matching.",
                    "default": false,
                    "fa_icon": "fas fa-question-circle",
                    "hidden": true,
                    "help_text": "Suggested to keep false, so that redundant families are not further processed, for better resource management and to avoid duplication."
                },
                "skip_family_merging": {
                    "type": "boolean",
                    "description": "Flag to skip merging of similar families.",
                    "default": false,
                    "fa_icon": "fas fa-question-circle",
                    "hidden": true,
                    "help_text": "If false, similar families (but not redundant!) will be merged, depending on the hmmsearch_family_similarity_length_threshold parameter."
                },
                "hmmsearch_family_redundancy_length_threshold": {
                    "type": "number",
                    "default": 1.0,
                    "minimum": 0.0,
                    "maximum": 1.0,
                    "description": "hmmsearch minimum length percentage filter of hit env vs query length, for redundant family removal"
                },
                "hmmsearch_family_similarity_length_threshold": {
                    "type": "number",
                    "default": 0.9,
                    "minimum": 0.0,
                    "maximum": 1.0,
                    "description": "hmmsearch minimum length percentage of hit env vs query length, to flag and report similar families (and to optionally merge)",
                    "help_text": "Must be below the hmmsearch_family_redundancy_length_threshold to be valid."
                },
                "save_non_redundant_fams_fasta": {
                    "type": "boolean",
                    "description": "Save only the fasta files of non-redundant families (might still contain redundant sequences)",
                    "help_text": "Specify to save the fasta files of non-redundant families."
                },
                "skip_sequence_redundancy_removal": {
                    "type": "boolean",
                    "description": "Skip removal of inside-family redundancy of sequences via mmseqs clustering.",
                    "default": false,
                    "fa_icon": "fas fa-question-circle",
                    "hidden": true,
                    "help_text": "Highly similar sequences within the same family should be removed, while making sure that the protein family diversity is still well captured."
                },
                "cluster_seq_identity_for_redundancy": {
                    "type": "number",
                    "default": 0.9,
                    "minimum": 0.0,
                    "maximum": 1.0,
                    "description": "mmseqs parameter for minimum sequence identity",
                    "help_text": "Need to be quite high, to make sure that the diversity is still well captured, while highly similar sequences are removed"
                },
                "cluster_coverage_for_redundancy": {
                    "type": "number",
                    "default": 0.9,
                    "minimum": 0.0,
                    "maximum": 1.0,
                    "description": "mmseqs parameter for minimum sequence coverage ratio",
                    "help_text": "Need to be quite high, to make sure that the diversity is still well captured, well highly similar sequences are removed"
                },
                "cluster_cov_mode_for_redundancy": {
                    "type": "integer",
                    "default": 0,
                    "description": "mmseqs parameter for coverage mode: 0 for both, 1 for target and 2 for query sequence",
                    "help_text": "Defined by the number of aligned residue pairs divided by 0: the maximum of the length of query/centre and target/non-centre sequences, 1: the length of the target/non-centre sequence, 2: the length of the query/centre"
                },
                "save_non_redundant_seqs_fasta": {
                    "type": "boolean",
                    "description": "Save the final family fasta files with sequence redundancy removed",
                    "help_text": "Specify to save the family fasta files with non-redundant sequence sets."
                }
            }
        },
        "downstream_params": {
            "title": "Downstream samplsheet creation parameters",
            "type": "object",
            "description": "Use these parameters to produce samplsheets for downstream pipelines execution.",
            "properties": {
                "skip_proteinfold_samplesheet": {
                    "type": "boolean",
                    "description": "Skip the generation of the proteinfold samplesheet.",
                    "default": true,
                    "fa_icon": "fas fa-question-circle",
                    "hidden": true
                }
            }
        }
    },
    "allOf": [
        {
            "$ref": "#/$defs/input_output_options"
        },
        {
            "$ref": "#/$defs/institutional_config_options"
        },
        {
            "$ref": "#/$defs/generic_options"
        },
        {
            "$ref": "#/$defs/quality_check_params"
        },
        {
            "$ref": "#/$defs/clustering_params"
        },
        {
            "$ref": "#/$defs/alignment_params"
        },
        {
            "$ref": "#/$defs/redundancy_params"
        },
        {
            "$ref": "#/$defs/downstream_params"
        }
    ]
}
