{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "Metadata Model",
    "description": "Models how JSON data should be stored for use in the Dashboard",
    "type": "object",
    "required": [
        "program",
        "project",
        "submitter_donor_id"
    ],
    "properties": {
        "program": {
            "type": "string"
        },
        "project": {
            "type": "string"
        },
        "submitter_donor_id": {
            "type": "string"
        },
        "center_name": {
            "type": "string"
        },
        "donor_analysis_attributes": {
            "donor_example_attribute:": {
                "type": "array",
                "items": {
                    "type": "string"
                }
            }
        },
        "donor_uuid": {
            "type": "string"
        },
        "specimen": {
            "type": "array",
            "items": {
                "submitter_specimen_id": {
                    "type": "string"
                },
                "submitter_specimen_uuid": {
                    "type": "string"
                },
                "submitter_specimen_type": {
                    "enum": [
                        "Normal - solid tissue",
                        "Normal - blood derived",
                        "Normal - bone marrow",
                        "Normal - tissue adjacent to primary",
                        "Normal - buccal cell",
                        "Normal - EBV immortalized",
                        "Normal - lymph node",
                        "Normal - other",
                        "Primary tumour - solid tissue",
                        "Primary tumour - blood derived (peripheral blood)",
                        "Primary tumour - blood derived (bone marrow)",
                        "Primary tumour - additional new primary",
                        "Primary tumour - other",
                        "Recurrent tumour - solid tissue",
                        "Recurrent tumour - blood derived (peripheral blood)",
                        "Recurrent tumour - blood derived (bone marrow)",
                        "Recurrent tumour - other",
                        "Metastatic tumour - NOS",
                        "Metastatic tumour - lymph node",
                        "Metastatic tumour - metastatsis local to lymph node",
                        "Metastatic tumour - metastatsis to distant location",
                        "Metastatic tumour - additional metastatic",
                        "Xenograft - derived from primary tumour",
                        "Xenograft - derived from tumour cell line",
                        "Cell line - derived from tumour",
                        "Primary tumour - lymph node",
                        "Metastatic tumour - other",
                        "Cell line - derived from xenograft tumour"
                    ]
                },
                "specimen_analysis_attributes": {
                    "specimen_example_attribute:": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    }
                },
                "samples": {
                    "type": "array",
                    "items": {
                        "normal_sample_attributes": {
                            "type": "array",
                            "items": {
                                "sample_attributes": {
                                    "sample_example_attribute": {
                                        "type": "array",
                                        "items": {
                                            "type": "string"
                                        }
                                    }
                                },
                                "submitter_sample_id": {
                                    "type": "string"
                                },
                                "sequence_upload": {
                                    "workflows": {
                                        "type": "array",
                                        "items": {
                                            "workflow_name": {
                                                "type": "string"
                                            },
                                            "workflow_info": {
                                                "workflow_version": {
                                                    "type": "string"
                                                },
                                                "workflow_source_url": {
                                                    "type": "string"
                                                },
                                                "workflow_bundle_url": {
                                                    "type": "string"
                                                },
                                                "workflow_description": {
                                                    "type": "string"
                                                },
                                                "workflow_inputs": {
                                                    "type": "array",
                                                    "_uniqueItems": true,
                                                    "items": {
                                                        "file_storage_bundle_uri": {
                                                            "type": "string"
                                                        },
                                                        "file_storage_metadata_json_uri": {
                                                            "type": "string"
                                                        },
                                                        "file_storage_bundle_files": {
                                                            "type": "array",
                                                            "items": {
                                                                "foo.filetype": {
                                                                    "file_type_label": {
                                                                        "type": "string"
                                                                    },
                                                                    "file_type_cv_terms": {
                                                                        "type": "array",
                                                                        "items": {
                                                                            "type": "string"
                                                                        }
                                                                    },
                                                                    "file_storage_uri": {
                                                                        "type": "string"
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                },
                                                "workflow_outputs": {
                                                    "type": "array",
                                                    "_uniqueItems": true,
                                                    "items": {
                                                        "foo.filetype": {
                                                            "file_type_label": {
                                                                "type": "string"
                                                            },
                                                            "file_type_cv_terms": {
                                                                "type": "array",
                                                                "items": {
                                                                    "type": "string"
                                                                }
                                                            }
                                                        }
                                                    }
                                                },
                                                "workflow_params": {
                                                    "param1": {
                                                        "type": "number"
                                                    },
                                                    "param2": {
                                                        "type": "number"
                                                    }
                                                }
                                            },
                                            "qc_metrics": {
                                                "coverage_average": {
                                                    "type": "number"
                                                },
                                                "insert_size_average": {
                                                    "type": "number"
                                                },
                                                "insert_size_sd": {
                                                    "type": "number"
                                                }
                                            },
                                            "timing_metrics": {
                                                "overall_walltime_seconds": {
                                                    "type": "number"
                                                },
                                                "overall_start_time_utc": {
                                                    "type": "string",
                                                    "format": "date-time"
                                                },
                                                "overall_stop_time_utc": {
                                                    "type": "string",
                                                    "format": "date-time"
                                                },
                                                "step_timing": {
                                                    "alignment": {
                                                        "walltime_seconds": {
                                                            "type": "number"
                                                        },
                                                        "start_time_utc": {
                                                            "type": "string",
                                                            "format": "date-time"
                                                        },
                                                        "stop_time_utc": {
                                                            "type": "string",
                                                            "format": "date-time"
                                                        }
                                                    }
                                                }
                                            },
                                            "host_metrics": {
                                                "vm_instance_type": {
                                                    "type": "string"
                                                },
                                                "vm_instance_cores": {
                                                    "type": "number"
                                                },
                                                "vm_instance_mem_gb": {
                                                    "type": "number"
                                                },
                                                "vm_location": {
                                                    "type": "string"
                                                },
                                                "vm_region": {
                                                    "type": "string"
                                                }
                                            }
                                        }
                                    }
                                },
                                "alignment": {
                                    "sequencing_strategy": {
                                        "type": "string"
                                    },
                                    "workflows": {
                                        "type": "array",
                                        "items": {
                                            "workflow_name": {
                                                "type": "string"
                                            },
                                            "workflow_info": {
                                                "workflow_version": {
                                                    "type": "string"
                                                },
                                                "workflow_source_url": {
                                                    "type": "string"
                                                },
                                                "workflow_bundle_url": {
                                                    "type": "string"
                                                },
                                                "workflow_description": {
                                                    "type": "string"
                                                },
                                                "workflow_inputs": {
                                                    "type": "array",
                                                    "_uniqueItems": true,
                                                    "items": {
                                                        "file_storage_bundle_uri": {
                                                            "type": "string"
                                                        },
                                                        "file_storage_metadata_json_uri": {
                                                            "type": "string"
                                                        },
                                                        "file_storage_bundle_files": {
                                                            "type": "array",
                                                            "items": {
                                                                "foo.filetype": {
                                                                    "file_type_label": {
                                                                        "type": "string"
                                                                    },
                                                                    "file_type_cv_terms": {
                                                                        "type": "array",
                                                                        "items": {
                                                                            "type": "string"
                                                                        }
                                                                    },
                                                                    "file_storage_uri": {
                                                                        "type": "string"
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                },
                                                "workflow_outputs": {
                                                    "type": "array",
                                                    "_uniqueItems": true,
                                                    "items": {
                                                        "foo.filetype": {
                                                            "file_type_label": {
                                                                "type": "string"
                                                            },
                                                            "file_type_cv_terms": {
                                                                "type": "array",
                                                                "items": {
                                                                    "type": "string"
                                                                }
                                                            }
                                                        }
                                                    }
                                                },
                                                "workflow_params": {
                                                    "param1": {
                                                        "type": "number"
                                                    },
                                                    "param2": {
                                                        "type": "number"
                                                    }
                                                }
                                            },
                                            "qc_metrics": {
                                                "coverage_average": {
                                                    "type": "number"
                                                },
                                                "insert_size_average": {
                                                    "type": "number"
                                                },
                                                "insert_size_sd": {
                                                    "type": "number"
                                                }
                                            },
                                            "timing_metrics": {
                                                "overall_walltime_seconds": {
                                                    "type": "number"
                                                },
                                                "overall_start_time_utc": {
                                                    "type": "string",
                                                    "format": "date-time"
                                                },
                                                "overall_stop_time_utc": {
                                                    "type": "string",
                                                    "format": "date-time"
                                                },
                                                "step_timing": {
                                                    "alignment": {
                                                        "walltime_seconds": {
                                                            "type": "number"
                                                        },
                                                        "start_time_utc": {
                                                            "type": "string",
                                                            "format": "date-time"
                                                        },
                                                        "stop_time_utc": {
                                                            "type": "string",
                                                            "format": "date-time"
                                                        }
                                                    }
                                                }
                                            },
                                            "host_metrics": {
                                                "vm_instance_type": {
                                                    "type": "string"
                                                },
                                                "vm_instance_cores": {
                                                    "type": "number"
                                                },
                                                "vm_instance_mem_gb": {
                                                    "type": "number"
                                                },
                                                "vm_location": {
                                                    "type": "string"
                                                },
                                                "vm_region": {
                                                    "type": "string"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "germline_variant_calling": {
            "workflows": {
                "type": "array",
                "items": {
                    "workflow_name": {
                        "type": "string"
                    },
                    "workflow_info": {
                        "workflow_version": {
                            "type": "string"
                        },
                        "workflow_source_url": {
                            "type": "string"
                        },
                        "workflow_bundle_url": {
                            "type": "string"
                        },
                        "workflow_description": {
                            "type": "string"
                        },
                        "workflow_inputs": {
                            "type": "array",
                            "_uniqueItems": true,
                            "items": {
                                "file_storage_bundle_uri": {
                                    "type": "string"
                                },
                                "file_storage_metadata_json_uri": {
                                    "type": "string"
                                },
                                "file_storage_bundle_files": {
                                    "type": "array",
                                    "items": {
                                        "foo.filetype": {
                                            "file_type_label": {
                                                "type": "string"
                                            },
                                            "file_type_cv_terms": {
                                                "type": "array",
                                                "items": {
                                                    "type": "string"
                                                }
                                            },
                                            "file_storage_uri": {
                                                "type": "string"
                                            }
                                        }
                                    }
                                }
                            }
                        },
                        "workflow_outputs": {
                            "type": "array",
                            "_uniqueItems": true,
                            "items": {
                                "foo.filetype": {
                                    "file_type_label": {
                                        "type": "string"
                                    },
                                    "file_type_cv_terms": {
                                        "type": "array",
                                        "items": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        },
                        "workflow_params": {
                            "param1": {
                                "type": "number"
                            },
                            "param2": {
                                "type": "number"
                            }
                        }
                    },
                    "qc_metrics": {
                        "coverage_average": {
                            "type": "number"
                        },
                        "insert_size_average": {
                            "type": "number"
                        },
                        "insert_size_sd": {
                            "type": "number"
                        }
                    },
                    "timing_metrics": {
                        "overall_walltime_seconds": {
                            "type": "number"
                        },
                        "overall_start_time_utc": {
                            "type": "string",
                            "format": "date-time"
                        },
                        "overall_stop_time_utc": {
                            "type": "string",
                            "format": "date-time"
                        },
                        "step_timing": {
                            "alignment": {
                                "walltime_seconds": {
                                    "type": "number"
                                },
                                "start_time_utc": {
                                    "type": "string",
                                    "format": "date-time"
                                },
                                "stop_time_utc": {
                                    "type": "string",
                                    "format": "date-time"
                                }
                            }
                        }
                    },
                    "host_metrics": {
                        "vm_instance_type": {
                            "type": "string"
                        },
                        "vm_instance_cores": {
                            "type": "number"
                        },
                        "vm_instance_mem_gb": {
                            "type": "number"
                        },
                        "vm_location": {
                            "type": "string"
                        },
                        "vm_region": {
                            "type": "string"
                        }
                    }
                }
            }
        }
    }
}