$schema: "http://json-schema.org/draft-07/schema#"

description: snakemake config file for a prophane job

type: object

# forbid usage of parameters beyond the ones defined in this schema
additionalProperties: false

required:
  - general
  - input
  - output_dir
  - tasks
  - decoy_regex

properties:
  use_test_general_config:
    type: string
    description: optional path to general config that overrides default general config
  db_base_dir:
    type: string
    description: path to directory that contains prophane databases
  general:
    type: object
    description: general job information
    additionalProperties: false
    properties:
      job_name:
        type: string
      job_comment:
        type: string
  input:
    type: object
    description: user provided input files and format of proteomic search result
    required:
      - report_style
      - fastas
      - taxmaps
    additionalProperties: { type: string }
    minItems: 4
    maxItems: 4
    properties:
      report_style:
        type: string
      fastas:
        type: array
        minItems: 1
        items:
          type: string
      taxmaps:
        type: array
        items:
          type: string
    oneOf:
      - required: [search_result]
        properties:
          search_result: {type: string}
      - required: [report]
        properties:
          report: {type: string}
      - required: [generic_table]
        properties:
          generic_table: {type: string}
      - required: [mpa_report]
        properties:
          mpa_report: {type: string}
      - required: [mpa_multisample]
        properties:
          mpa_report: {type: string}

  output_dir:
    type: string
  seqdb:
    type: array
    minItems: 1
    items:
      type: string
  taxmaps:
    type: array
    minItems: 1
    items:
      type: string
  taxlevel:
    type: array
    minItems: 1
    uniqueItems: true
    items:
      type: string
    default:
      - "superkingdom"
      - "phylum"
      - "class"
      - "order"
      - "family"
      - "genus"
      - "species"

  tasks:
    type: array
    description: "list of unique annotation tasks"
    minItems: 1
    uniqueItems: true
    items:
      type: object
      description: "definition of a single annotation task"
      additionalProperties: false
      properties:
        prog:
          type: string
          enum: ["diamond blastp", "hmmscan", "hmmsearch", "emapper", "acc2annot_mapper"]
        shortname:
          type: string
        db_type:
          type: string
        db_version:
          type: string
        type:
          type: string
          enum:
            - functional
            - taxonomic
        params:
          type: object
      required:
        - prog
        - shortname
        - db_type
        - type
      allOf:
        - if:
            properties:
              prog: {const: "acc2annot_mapper"}
          then:
            properties:
              db_type: {const: "custom_map"}
              params:
                type: object
                additionalProperties: false
                properties:
                  path:
                    type: string
                required: [path]
        - if:
            properties:
              prog: {const: "diamond blastp"}
          then:
            properties:
              params:
                type: object
                additionalProperties: false
                properties:
                  header:
                    enum: ['']
                  strand:
                    enum: ['both', 'minus', 'plus']
                  top:
                    type: number
                  range-culling:
                    enum: ['']
                  min-score:
                    type: number
                  id:
                    type: number
                  sensitive:
                    enum: ['']
                  more-sensitive:
                    enum: ['']
                  block-size:
                    type: number
                  index-chunks:
                    type: integer
                  gapopen:
                    type: number
                  gapextend:
                    type: number
                  frameshift:
                    type: number
                  matrix:
                    type: string
                  custom-matrix:
                    type: string
                  lambda:
                    type: number
                  K:
                    type: number
                  comp-based-stats:
                    enum: [0, 1]
                  masking:
                    enum: [0, 1]
                  taxonmap:
                    type: string
                  taxonlist:
                    type: string
                  algo:
                    enum: [0, 1]
                  bin:
                    type: integer
                  min-orf:
                    enum: ['']
                  freq-sd:
                    type: number
                  id2:
                    type: number
                  window:
                    type: number
                  xdrop:
                    type: number
                  ungapped-score:
                    type: number
                  hit-band:
                    type: string
                  hit-score:
                    type: number
                  gapped-xdrop:
                    type: number
                  band:
                    type: string
                  shapes:
                    type: integer
                  shape-mask:
                    type: integer
                  index-mode:
                    enum: [0, 1]
                  rank-ratio:
                    enum: ['']
                  rank-ratio2:
                    enum: ['']
                  max-hsps:
                    type: integer
                  range-cover:
                    type: number
                  dbsize:
                    type: integer
                  evalue:
                    type: number
                  query-cover:
                    type: number
                  max-target-seqs:
                    type: integer

        - if:
            properties:
              prog: {enum: ["hmmscan", "hmmsearch"]}
          then:
            properties:
              params:
                type: object
                additionalProperties: false
                properties:
                  E:
                    type: number
                  T:
                    type: number
                  domE:
                    type: number
                  domT:
                    type: number
                  incE:
                    type: number
                  incT:
                    type: number
                  incdomE:
                    type: number
                  incdomT:
                    type: number
                  max:
                    enum: ['']
                  F1:
                    type: number
                  F2:
                    type: number
                  F3:
                    type: number
                  nobias:
                    enum: ['']
                  nonull2:
                    enum: ['']
                  Z:
                    type: integer
                  domZ:
                    type: integer
                  seed:
                    type: integer
                  evalue:
                    type: number
                  cut_ga:
                    enum: ['']
                  cut_nc:
                    enum: ['']
                  cut_tc:
                    enum: ['']

        - if:
            properties:
              prog: {const: "emapper"}
          then:
            properties:
              params:
                type: object
                additionalProperties: false
                properties:
                  guessdb:
                    enum: ['']
                  tax_scope:
                    enum: ['']
                  target_orthologs:
                    enum: ['one2one', 'many2one', 'one2many', 'many2many', 'all']
                  go_evidence:
                    enum: ['experimental', 'non-electronic']
                  hmm_maxhits:
                    type: integer
                  hmm_evalue:
                    type: number
                  hmm_score:
                    type: number
                  hmm_maxseqlen:
                    type: integer
                  hmm_qcov:
                    type: number
                  Z:
                    type: integer
                  matrix:
                    enum: ['BLOSUM62', 'BLOSUM90', 'BLOSUM80', 'BLOSUM50', 'BLOSUM45', 'PAM250', 'PAM70', 'PAM30']
                  gapopen:
                    type: number
                  gapextend:
                    type: number
                  seed_ortholog_evalue:
                    type: number
                  seed_ortholog_score:
                    type: number
                  m:
                    enum: ["diamond", "hmmer"]

  decoy_regex:
    type: string
  quant_method:
    type: string
    enum: ["max_nsaf", "min_nsaf", "mean_nsaf", "raw"]
    default: "max_nsaf"
  sample_groups:
    description: one object per sample group, object key being the sample type (e.g. sample, control), can be arbitrary string. Value of each object is an array of strings, matching the name of each run.
    type: object
    additionalProperties: {type: array, items: {type: string}}
  lca:
    type: object
    description: choose prefered lca (lowest common ancestor) method and threshold
    additionalProperties: false
    default: {}
    properties:
      method:
        type: string
        enum: ["lca", "democratic_lca"]
        default: "lca"
      threshold:
        type: number
        default: 1
      minimum_number_of_annotations:
        type: integer
        default: 0
      ignore_unclassified:
        type: boolean
        default: false
