{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://prc-trypcell-atlas.com/schema/submission.schema.json",
  "title": "TrypCell Atlas public submission manifest",
  "description": "Metadata manifest for proposing a Trypanosoma single-cell study or a correction. It contains source descriptors, not expression matrices or raw sequencing data.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "submission_type",
    "title",
    "species"
  ],
  "properties": {
    "submission_type": {
      "type": "string",
      "enum": ["new_study", "correction"]
    },
    "title": {
      "type": "string",
      "minLength": 1,
      "maxLength": 320
    },
    "existing_record_id": {
      "type": "string",
      "maxLength": 320,
      "description": "TrypCell record ID, page URL or earlier submission receipt ID. Required when submission_type is correction."
    },
    "paper_identifier": {
      "type": "string",
      "minLength": 1,
      "maxLength": 180,
      "description": "DOI, PMID or stable identifier for a clearly labelled citable preprint."
    },
    "paper_url": {
      "type": "string",
      "format": "uri",
      "maxLength": 500
    },
    "species": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120
    },
    "strain": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "sequencing_method": {
      "type": "string",
      "minLength": 1,
      "maxLength": 240
    },
    "reference_genome": {
      "type": "string",
      "minLength": 1,
      "maxLength": 240
    },
    "repository_accessions": {
      "type": "string",
      "minLength": 1,
      "maxLength": 500
    },
    "repository_url": {
      "type": "string",
      "format": "uri",
      "maxLength": 500
    },
    "processed_expression_layer": {
      "type": "string",
      "minLength": 1,
      "maxLength": 320,
      "description": "Describe whether the source contains counts, normalized values, scaled values or another clearly defined layer."
    },
    "processed_data_url": {
      "type": "string",
      "format": "uri",
      "maxLength": 500
    },
    "analysis_code_url": {
      "type": "string",
      "format": "uri",
      "maxLength": 500
    },
    "data_licence": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "reviewer_notes": {
      "type": "string",
      "maxLength": 2400
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "submission_type": { "const": "correction" }
        }
      },
      "then": {
        "required": ["existing_record_id", "reviewer_notes"],
        "anyOf": [
          { "required": ["paper_url"] },
          { "required": ["repository_url"] },
          { "required": ["processed_data_url"] },
          { "required": ["analysis_code_url"] }
        ]
      },
      "else": {
        "required": [
          "paper_identifier",
          "paper_url",
          "strain",
          "sequencing_method",
          "reference_genome",
          "repository_accessions",
          "repository_url",
          "processed_expression_layer",
          "data_licence"
        ]
      }
    }
  ]
}
