{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "required": ["name"],
    "SimpleComment":
    {"type": "object",
    "SimpleComment": ["This is a standard configuration file for Daijin. Fields:",
    "- short_reads: this section deals with RNA-Seq short read input data.",
    "- name: name of the species under analysis.",
    "- reference: reference data to use. A reference genome is required."],
    "properties": {}},
    "load":{
      "SimpleComment": ["Commands to use to load/select the versions of the programs to use. Leave an empty string if no loading is necessary."],
      "type": "object",
      "required": ["tophat", "gmap", "star", "hisat", "samtools", "cufflinks", "trinity", "scallop",
        "stringtie", "class", "transdecoder", "portcullis", "mikado", "blast"],
      "properties": {
       "tophat": {"type": "string", "default": ""},
        "gmap": {"type": "string", "default": ""},
        "star": {"type": "string", "default": ""},
        "hisat": {"type": "string", "default": ""},
        "samtools": {"type": "string", "default": ""},
        "cufflinks": {"type": "string", "default": ""},
        "scallop": {"type": "string", "default": ""},
        "trinity": {"type": "string", "default": ""},
        "stringtie": {"type": "string", "default": ""},
        "class": {"type": "string", "default": ""},
        "transdecoder": {"type": "string", "default": ""},
        "prodigal": {"type": "string", "default": ""},
        "portcullis": {"type": "string", "default": ""},
        "mikado": {"type": "string", "default": ""},
        "diamond": {"type": "string", "default": ""},
        "blast": {"type": "string", "default": ""}
      }
    },
    "portcullis": {
      "SimpleComment": ["Options related to portcullis"],
      "type": "object",
      "properties": {
       "do": {"type": "boolean", "default": true, "required": true},
        "canonical_juncs": {"type": "string", "default": "C,S", "required": true}
      }
    },
    "extra": {
      "SimpleComment": ["Options related to indexing."],
      "type": "object",
      "properties": {
        "star_index": {"type": "string", "default": "", "required": true}
      }
    },
    "long_reads": {
      "type": "object",
      "SimpleComment": ["Parameters related to long reads to use for the assemblies."],
      "properties": {
        "files": {"type": "array", "default": []},
        "samples": {"type": "array", "default": []},
        "strandedness": {"type": "array", "default": [], "items": {"type": "string",
            "enum": ["fr-firststrand",
              "fr-secondstrand",
              "fr-unstranded",
            "f", "r"]}},
        "skip_split": {"type": "boolean", "default": true}
      }
    },
    "short_reads": {
      "SimpleComment": ["Parameters related to the reads to use for the assemblies. Voices:",
          "- r1: array of left read files.",
          "- r2: array of right read files. It must be of the same length of r1; if one",
          "  one or more of the samples are single-end reads, add an empty string.",
          "- samples: array of the sample names. It must be of the same length of r1.",
          "- strandedness: array of strand-specificity of the samples. It must be of the",
          "  same length of r1. Valid values: fr-firststrand, fr-secondstrand, fr-unstranded."
        ],
      "type": "object",
      "required": ["r1", "r2", "samples", "strandedness"],
      "properties": {
        "r1": {
          "type": "array",
          "required": true,
          "default": [],
          "uniqueItems": true,
          "items": {"type": "string"}
        },
        "r2": {
          "type": "array",
          "required": true,
          "items": {"type": ["string", "null"]},
          "default": []
        },
        "samples": {
          "type": "array",
          "items": {"type": "string"},
          "default": []
        },
        "strandedness": {
          "type": "array",
          "required": true,
          "default": [],
          "items": {"type": "string",
            "enum": ["fr-firststrand",
              "fr-secondstrand",
              "fr-unstranded",
            "f", "r"]}
        }
      }
    },
    "name": {
      "type": "string",
      "default": "Daijin",
      "SimpleComment": ["Name to be used for the project."],
      "required": true
    },
    "out_dir": {
      "type": "string",
      "default": "daijin",
      "Comment": "Output directory for the project",
      "required": true
    },
    "threads": {
      "type": "integer",
      "default": 4,
      "Comment": "Threads to be used per process.",
      "required": true,
      "minimum": 1
    },
    "scheduler": {
      "type": ["string"],
      "default": "",
      "enum": ["LSF", "SLURM", "PBS", ""],
      "Comment": "Scheduler to be used for the project. Set to null if you plan to use DRMAA or are using a local machine.",
      "required": true
    },
    "align_methods": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "tophat": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "minItems": 1
        },
        "hisat": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "minItems": 1
        },
        "star": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "minItems": 1
        },
        "gsnap": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "minItems": 1
        }
      }
    },
    "long_read_align_methods": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "star": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "minItems": 1
        },
        "gmap": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "minItems": 1
        }
      }
    },
    "asm_methods": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "stringtie": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "minItems": 1
        },
        "cufflinks": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "minItems": 1
        },
        "class": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "minItems": 1
        },
        "scallop": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "minItems": 1
        },
        "trinity": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "minItems": 1
        },
        "trinitydn": {
          "type": "boolean",
          "default": false
        }
      }
    },
    "reference": {
        "$ref": "configuration_blueprint.json#properties/reference"
      },
    "transdecoder": {
      "type": "object",
      "properties": {
        "min_protein_len": {"type": "integer", "minimum": 1, "default": 30, "required": true},
        "execute": {"type": "boolean", "default": true, "required": true}
      },
      "required": ["min_protein_len"]
    },
    "blastx": {
      "type":"object",
      "properties":{
        "prot_db": {"type": "array", "required": true, "default": []},
        "evalue": {"type": "number", "minimum": 0, "default": 0.0000001},
        "max_target_seqs": {"type": "integer", "minimum": 1, "default": 10},
        "chunks": {"type": "integer", "minimum": 1, "default": 10}
      },
      "required": ["prot_db", "evalue", "chunks"]
    },
    "mikado": {
      "type": "object",
      "properties": {
        "modes": {"type": "array", "minItems": 1,
          "items": {"type": "string",
            "enum": ["nosplit", "split", "lenient", "permissive", "stringent"]},
          "default": ["permissive"],
        "required": true},
        "db_settings": {"$ref": "configuration_blueprint.json#properties/db_settings"},
        "use_diamond": {"type": "boolean", "default": true},
        "use_prodigal": {"type": "boolean", "default": false},
        "pick": {
          "type": "object",
          "properties": {
            "scoring_file": {"$ref": "configuration_blueprint.json#properties/pick/properties/scoring_file"},
            "alternative_splicing": {
              "$ref": "configuration_blueprint.json#properties/pick/properties/alternative_splicing"},
            "clustering": {
                  "$ref": "configuration_blueprint.json#properties/pick/properties/clustering"},
            "fragments": {
                   "$ref": "configuration_blueprint.json#properties/pick/properties/fragments"
            },
            "run_options": {
              "type": "object",
              "properties": {
                "intron_range": {
                  "$ref": "configuration_blueprint.json#properties/pick/properties/run_options/properties/intron_range"
                }
              }
            }
          }
        },
        "serialise": {
          "type": "object",
          "properties": {
            "force": {
              "type": "boolean",
              "default": true
            }
          },
          "required": ["force"]
        },
        "prepare": {
          "type": "object",
          "SimpleComment": ["Options related to Mikado prepare. Possibilities:",
          "- lenient: whether to activate the lenient mode of Mikado.",
          "- canonical: which combinations of donor and acceptor sites are considered as valid."],
          "properties": {
          "canonical": {
            "$ref": "configuration_blueprint.json#properties/prepare/properties/canonical"},
          "lenient":  {
            "$ref": "configuration_blueprint.json#properties/prepare/properties/lenient"}
          }
        }
      }
    },
    "tgg": {
      "type": "object",
      "SimpleComment": ["Options related to genome-guided Trinity."],
      "Comment": ["Options related to genome-guided Trinity.",
      "- max_mem: Maximum memory to be used for the assembly. Default: 6000Mb",
      "- npaths: number of alignments per sequence, using GMAP. Default: 0 (one alignment per sequence, exclude chimeric).",
      "- identity: minimum identity for any alignment. Default: 95%",
      "- coverage: minimum coverage for any alignment. Default: 70%"],
      "properties": {
        "max_mem": {"type": "integer", "default": 6000, "minimum": 1000, "required": true},
        "npaths": {"type": "integer", "default": 0},
        "identity": {"type": "number", "default": 0.95, "minimum": 0, "maximum": 1},
        "coverage": {"type": "number", "default": 0.70, "minimum": 0, "maximum": 1}
      }
    }
  }
}
