#
# Schema definitions for AIRR standards objects
#
Info:
    title: AIRR Schema
    description: Schema definitions for AIRR standards objects
    version: 2.0
    contact:
        name: AIRR Community
        url: https://github.com/airr-community
    license:
        name: Creative Commons Attribution 4.0 International
        url: https://creativecommons.org/licenses/by/4.0/


# Properties that are based upon an ontology use this
# standard schema definition
Ontology:
    type: object
    properties:
        id:
            type: string
            description: CURIE of the concept, encoding the ontology and the local ID
        label:
            type: string
            description: Label of the concept in the respective ontology

# Map to expand CURIE prefixes to full IRIs
CURIEMap:
    ABREG:
        type: identifier
        default:
            map: ABREG
        map:
            ABREG:
                iri_prefix: "http://antibodyregistry.org/AB_"
    CHEBI:
        type: ontology
        default:
            map: OBO
            provider: OLS
        map:
            OBO:
                iri_prefix: "http://purl.obolibrary.org/obo/CHEBI_"
    CL:
        type: ontology
        default:
            map: OBO
            provider: OLS
        map:
            OBO:
                iri_prefix: "http://purl.obolibrary.org/obo/CL_"
    DOI:
        type: identifier
        default:
            map: DOI
        map:
            DOI:
                iri_prefix: "https://doi.org/"
    DOID:
        type: ontology
        default:
            map: OBO
            provider: OLS
        map:
            OBO:
                iri_prefix: "http://purl.obolibrary.org/obo/DOID_"
    ENA:
        type: identifier
        default:
            map: ENA
        map:
            ENA:
                iri_prefix: "https://www.ebi.ac.uk/ena/browser/view/"
    ENSG:
        type: identifier
        default:
            map: ENSG
        map:
            ENSG:
                iri_prefix: "https://www.ensembl.org/Multi/Search/Results?q="
    GAZ:
        type: ontology
        default:
            map: OBO
            provider: OLS
        map:
            OBO:
                iri_prefix: "http://purl.obolibrary.org/obo/GAZ_"
    IEDB_RECEPTOR:
        type: identifier
        default:
            map: IEDB_RECEPTOR
            provider: IEDB_RECEPTOR
        map:
            IEDB_RECEPTOR:
                iri_prefix: "https://www.iedb.org/receptor/"
    IEDB_EPITOPE:
        type: identifier
        default:
            map: IEDB_EPITOPE
            provider: IEDB_EPITOPE
        map:
            IEDB_EPITOPE:
                iri_prefix: "https://www.iedb.org/epitope/"
    IMGT_GERMLINESET:
        type: identifier
        default:
            map: IMGT_GERMLINESET
        map:
            IMGT_GERMLINESET:
                iri_prefix: "https://www.imgt.org/download/V-QUEST/archives/"
    MRO:
        type: ontology
        default:
            map: OBO
            provider: OLS
        map:
            OBO:
                iri_prefix: "http://purl.obolibrary.org/obo/MRO_"
    NCBITAXON:
        type: taxonomy
        default:
            map: OBO
            provider: OLS
        map:
            OBO:
                iri_prefix: "http://purl.obolibrary.org/obo/NCBITaxon_"
            BioPortal:
                iri_prefix: "http://purl.bioontology.org/ontology/NCBITAXON/"
    NCIT:
        type: ontology
        default:
            map: OBO
            provider: OLS
        map:
            OBO:
                iri_prefix: "http://purl.obolibrary.org/obo/NCIT_"
    OGRDB_GERMLINESET:
        type: identifier
        default:
            map: OGRDB_GERMLINESET
        map:
            OGRDB_GERMLINESET:
                iri_prefix: "https://ogrdb.airr-community.org/api_v2/"
    ORCID:
        type: catalog
        default:
            map: ORCID
            provider: ORCID
        map:
            ORCID:
                iri_prefix: "https://orcid.org/"
    ROR:
        type: catalog
        default:
            map: ROR
            provider: ROR
        map:
            ROR:
                iri_prefix: "https://ror.org/"
    SRA:
        type: identifier
        default:
            map: SRA
        map:
            SRA:
                iri_prefix: "https://trace.ncbi.nlm.nih.gov/Traces/sra/?run="
    UBERON:
        type: ontology
        default:
            map: OBO
            provider: OLS
        map:
            OBO:
                iri_prefix: "http://purl.obolibrary.org/obo/UBERON_"
    UNIPROT:
        type: identifier
        default:
            map: UNIPROT
        map:
            UniProt:
                iri_prefix: "http://purl.uniprot.org/uniprot/"
    UO:
        type: ontology
        default:
            map: OBO
            provider: OLS
        map:
            OBO:
                iri_prefix: "http://purl.obolibrary.org/obo/UO_"

InformationProvider:
    provider:
        ENA:
            request:
                url:
                    - "{iri}"
                response: text/html
        IEDB_RECEPTOR:
            request:
                url: 
                    - 'https://query-api.iedb.org/tcr_search?receptor_group_id=eq.{local_id}'
                    - 'https://query-api.iedb.org/bcr_search?receptor_group_id=eq.{local_id}'
                response: application/json
        IEDB_EPITOPE:
            request:
                url:
                    - "https://query-api.iedb.org/epitope_search?structure_id=eq.{local_id}"
                response: application/json
        IMGT_GERMLINESET:
            request:
                url:
                    - "{iri}"
                response: application/zip
        OLS:
            request:
                url:
                    - "https://www.ebi.ac.uk/ols/api/ontologies/{ontology_id}/terms?iri={iri}"
                response: application/json
        Ontobee:
            request:
                url:
                    - "http://www.ontobee.org/ontology/rdf/{ontology_id}?iri={iri}"
                response: application/rdf+xml
        OGRDB_GERMLINESET:
            request:
                url:
                    - "{iri}"
                response: application/json
        ORCID:
            request:
                url:
                    - "https://pub.orcid.org/v2.1/{local_id}"
                header:
                    Accept: application/json
                response: application/json
        ROR:
            request:
                url:
                    - "https://api.ror.org/organizations/{iri}"
                response: application/json
        SRA:
            request:
                url:
                    - "{iri}"
                response: text/html
    parameter:
        CHEBI:
            Ontobee:
                ontology_id: CHEBI
            OLS:
                ontology_id: chebi
        CL:
            Ontobee:
                ontology_id: CL
            OLS:
                ontology_id: cl
        DOID:
            Ontobee:
                ontology_id: DOID
            OLS:
                ontology_id: doid
        GAZ:
            Ontobee:
                ontology_id: GAZ
            OLS:
                ontology_id: gaz
        MRO:
            Ontobee:
                ontology_id: MRO
            OLS:
                ontology_id: mro
        NCBITAXON:
            Ontobee:
                ontology_id: NCBITaxon
            OLS:
                ontology_id: ncbitaxon
            BioPortal:
                ontology_id: NCBITAXON
        NCIT:
            Ontobee:
                ontology_id: NCIT
            OLS:
                ontology_id: ncit
        UBERON:
            Ontobee:
                ontology_id: UBERON
            OLS:
                ontology_id: uberon
        UO:
            Ontobee:
                ontology_id: UO
            OLS:
                ontology_id: uo

# AIRR specification extensions
#
# The schema definitions for AIRR standards objects is extended to
# provide a number of AIRR specific attributes. This schema definition
# specifies the structure, property names and data types. These
# attributes are attached to an AIRR field with the x-airr property.

Attributes:
    type: object
    properties:
        miairr:
            type: string
            description: MiAIRR requirement level.
            enum:
                - essential
                - important
                - defined
            default: defined
        identifier:
            type: boolean
            description: >
                True if the field is an identifier required to link metadata and/or individual
                sequence records across objects in the complete AIRR Data Model and ADC API.
            default: false
        adc-query-support:
            type: boolean
            description: >
                True if an ADC API implementation must support queries on the field.
                If false, query support for the field in ADC API implementations is optional.
            default: false
        adc-api-optional:
            type: boolean
            description: >
                If false, repositories must implement these fields both for queries and query repsonse.
                Only applies to fields in the ADC API spec that are extensions to the AIRR Standard,
                targeted at "convenience query fields" that make queries against repositories more
                efficient than if queries were limited to AIRR fields only.
                If true, repositories can choose to support the field or not.
            default: false
        nullable:
            type: boolean
            description: True if the field may have a null value.
            default: true
        deprecated:
            type: boolean
            description: True if the field has been deprecated from the schema.
            default: false
        deprecated-description:
            type: string
            description: Information regarding the deprecation of the field.
        deprecated-replaced-by:
            type: array
            items:
                type: string
            description: The deprecated field is replaced by this list of fields.
        set:
            type: integer
            description: MiAIRR set
        subset:
            type: string
            description: MiAIRR subset
        name:
            type: string
            description: MiAIRR name
        format:
            type: string
            description: Field format. If null then assume the full range of the field data type
            enum:
                - ontology
                - controlled_vocabulary
                - physical_quantity
                - time_point
                - time_interval
                - CURIE
        ontology:
            type: object
            description: Ontology definition for field
            properties:
                draft:
                    type: boolean
                    description: Indicates if ontology definition is a draft
                top_node:
                    type: object
                    description: >
                        Concept to use as top node for ontology. Note that this must have the same CURIE namespace
                        as the actually annotated concept.
                    properties:
                        id:
                            type: string
                            description: CURIE for the top node term
                        label:
                            type: string
                            description: Ontology name for the top node term
# FileObject
FileObject:
    type: object
    properties:
        format:
            type: string
            description: The file format for the file (e.g. json, tsv).
        compression:
            type: string
            description: The type of compression (if any) used for the file (e.g. zip, gz, bz2).
        filename:
            type: string
            description: The name of the file
        checksum:
            type: string
            description: MD5 checksum of the file.
        version:
            type: string
            description: Version stamp for the file (if any).

# AIRR DataSet specification
#     An AIRR DataSet consists of tags for types of AIRR Schema Objects and a set of files that hold data in the AIRR format
#     appropriate for that AIRR schema object.

DataSet:
    type: object
    properties:
        name:
            type: string
            description: A human readable name for the data set.
        description:
            type: string
            description: A description of the data set.
        repository_url:
            type: string
            description: The URL of the repository from which the data set came from (if the data came from a repository)
        files:
            type: object
            description: A set of files based on data type, where the key for each object denotes the type of data and the accompanying array of files (and related file metadata) contain the data of that type. All top level AIRR objects (e.g. Repertoire, Rearrangement, Clone, Cell, Expression, Reactivity, Receptor, RepertoireGroup) are allowed. Custom data types are also permitted, so the manifest can include data that is outside of the AIRR specification.
            properties:
                Repertoire:
                    type: array
                    items:
                        $ref: '#/FileObject'
                Rearrangement:
                    type: array
                    items:
                        $ref: '#/FileObject'
                Clone:
                    type: array
                    items:
                        $ref: '#/FileObject'
                Cell:
                    type: array
                    items:
                        $ref: '#/FileObject'
                Expression:
                    type: array
                    items:
                        $ref: '#/FileObject'
                Reactivity:
                    type: array
                    items:
                        $ref: '#/FileObject'
                Receptor:
                    type: array
                    items:
                        $ref: '#/FileObject'
                GermlineSet:
                    type: array
                    items:
                        $ref: '#/FileObject'
                GenotypeSet:
                    type: array
                    items:
                        $ref: '#/FileObject'
                RepertoireGroup:
                    type: array
                    items:
                        $ref: '#/FileObject'
                ADCQuery:
                    type: array
                    items:
                        $ref: '#/FileObject'

                        
# AIRR Manifest specification.
#     An AIRR Manifest contains metadata for a group of accompanying files that are part of a set or coherent unit. 

Manifest:
    type: object
    properties:
        name:
            type: string
            description: A human readable name for the data manifest.
            x-airr:
                nullable: false
        description:
            type: string
            description: A description of the purpose for this data manifest
        created_at:
            type: string
            description: Time/data stamp when the dat manifest was created.
        data_sets:
            type: array
            items:
                $ref: '#/DataSet'



# AIRR Data File
#
# A JSON data file that holds Repertoire metadata, data processing
# analysis objects, or any object in the AIRR Data Model.
#
# It is presumed that the objects gathered together in an AIRR Data File are related
# or relevant to each other, e.g. part of the same study; thus, the ID fields can be
# internally resolved unless the ID contains an external PID. This implies that AIRR
# Data Files cannot be merged simply by concatenating arrays; any merge program
# would need to manage duplicate or conflicting ID values.
#
# While the properties in an AIRR Data File are not required, if one is provided then
# the value should not be null.
        
DataFile:
    type: object
    properties:
        Info:
            $ref: '#/InfoObject'
            x-airr:
                nullable: false
        Repertoire:
            type: array
            description: List of repertoires
            items:
                $ref: '#/Repertoire'
            x-airr:
                nullable: false
        RepertoireGroup:
            type: array
            description: List of repertoire groups
            items:
                $ref: '#/RepertoireGroup'
            x-airr:
                nullable: false
        Rearrangement:
            type: array
            description: List of rearrangement records
            items:
                $ref: '#/Rearrangement'
            x-airr:
                nullable: false
        Cell:
            type: array
            description: List of cells
            items:
                $ref: '#/Cell'
            x-airr:
                nullable: false
        Clone:
            type: array
            description: List of clones
            items:
                $ref: '#/Clone'
            x-airr:
                nullable: false
        Node:
            type: array
            description: List of nodes
            items:
                $ref: '#/Node'
            x-airr:
                nullable: false
        GermlineSet:
            type: array
            description: List of germline sets
            items:
                $ref: '#/GermlineSet'
            x-airr:
                nullable: false
        GenotypeSet:
            type: array
            description: List of genotype sets
            items:
                $ref: '#/GenotypeSet'
            x-airr:
                nullable: false
        Manifest:
            type: array
            description: List of data set manifests
            items:
              $ref: '#/Manifest'
            x-airr:
                nullable: false

# AIRR Info object, should be similar to openapi
# should we point to an openapi schema?
InfoObject:
    type: object
    description: Provides information about data and API responses.
    required:
        - title
        - version
    properties:
        title:
            type: string
            x-airr:
                nullable: false
        version:
            type: string
            x-airr:
                nullable: false
        description:
            type: string
        contact:
            type: object
            properties:
                name:
                    type: string
                url:
                    type: string
                email:
                    type: string
        license:
            type: object
            required:
                - name
            properties:
                name:
                    type: string
                    x-airr:
                        nullable: false
                url:
                    type: string

#
# General objects
#

# A time point
TimePoint:
    description: Time point at which an observation or other action was performed.
    type: object
    properties:
        time_label:
            type: string
            description: Informative label for the time point
            example: Pre-operative sampling of cancer tissue
            x-airr:
                adc-query-support: true
        time_value:
            type: number
            description: Value of the time point
            example: -5.0
            x-airr:
                nullable: false
                adc-query-support: true
        time_unit:
            $ref: '#/Ontology'
            description: Unit of the time point
            title: Unit of immunization schedule
            example:
                id: UO:0000033
                label: day
            x-airr:
                nullable: false
                adc-query-support: true
                format: ontology
                ontology:
                    draft: false
                    top_node:
                        id: UO:0000003
                        label: time unit

# A time range or interval
TimeInterval:
    description: Time range or interval for a measurement, observation or action.
    type: object
    properties:
        time_min:
            type: number
            description: Lower/minimum value of the time interval
            example: 5.0
            x-airr:
                adc-query-support: true
                nullable: false
        time_max:
            type: number
            description: Upper/maximum value of the time interval
            example: 10.0
            x-airr:
                adc-query-support: true
                nullable: false
        time_unit:
            $ref: '#/Ontology'
            description: Unit of the time interval
            example:
                id: UO:0000033
                label: day
            x-airr:
                nullable: false
                adc-query-support: true
                format: ontology
                ontology:
                    draft: false
                    top_node:
                        id: UO:0000003
                        label: time unit

# A physical quantity
PhysicalQuantity:
    description: A physical quantity from a measurement or observation.
    type: object
    properties:
        physical_quantity:
            type: number
            description: Physical quantity
            example: -5.0
            x-airr:
                adc-query-support: true
                nullable: false
        physical_unit:
            $ref: '#/Ontology'
            description: Unit of physical quantity
            example:
                id: UO:0000024
                label: nanogram
            x-airr:
                nullable: false
                adc-query-support: true
                format: ontology
                ontology:
                    draft: false
                    top_node:
                        id: UO:0000002
                        label: physical quantity

# A time quantity
TimeQuantity:
    description: A time quantity 
    type: object
    properties:
        time_quantity:
            type: number
            description: Time quantity
            example: 30.0
            x-airr:
                adc-query-support: true
                nullable: false
        time_unit:
            $ref: '#/Ontology'
            description: Unit of time
            example:
                id: UO:0000033
                label: day
            x-airr:
                nullable: false
                adc-query-support: true
                format: ontology
                ontology:
                    draft: false
                    top_node:
                        id: UO:0000003
                        label: time unit



# Contributor record to describe invididuals and their contribution to a data set
#
Contributor:
    description: Individual whose contribution to this work should be acknowledged
    type: object
    required:
        - contributor_id
        - name
    properties:
        contributor_id:
            type: string
            description: Unique identifier of this contributor within the file
            x-airr:
                nullable: true
                identifier: true
                miairr: important
        name:
            type: string
            description: Full name of contributor
            x-airr:
                 nullable: false
        orcid_id:
            type: string
            description: >
                ORCID identifier of the contributor. Note that if present, the label of the ORCID record should take
                precedence over the name reported in the `name` property.
            title: ORCID iD
            example:
                id: ORCID:0000-0002-1825-0097
                label: Josiah Carberry
            x-airr:
                nullable: true
                adc-query-support: true
                format: CURIE
        affiliation:
            type: string
            description: >
                ROR of the contributor's primary affiliation. Note that ROR are only minted for institutions, not
                from individuals institutes, divisions or departments.
            title: ROR
            example:
                id: ROR:05h7xva58
                label: Wesleyan University
            x-airr:
                nullable: true
                adc-query-support: true
                format: CURIE
        affiliation_department:
            type: string
            description: >
                Additional information regarding the contributor's primary affiliation. Can be used to specify
                individual institutes, divisions or departments.
            example: Department for Psychoceramics
            x-airr:
                nullable: true
        contributions:
            type: array
            description: List of all roles the contributor had in a project
            items:
                $ref: '#/ContributorContribution'
            x-airr:
                nullable: true

ContributorContribution:
    type: object
    required:
        - role
    properties:
        role:
            type: string
            description: Role according to CRediT taxonomy
            enum:
                - conceptualization
                - data curation
                - formal analysis
                - funding acquisition
                - investigation
                - methodology
                - project administration
                - resources
                - software
                - supervision
                - validation
                - visualization
                - writing - original draft
                - writing - review & editing
            x-airr:
                nullable: false
        degree:
            type: string
            description: >
                Optional specification of the degree of contribution, should be used if multiple individuals serve
                the same role.
            enum:
                - lead
                - equal
                - supporting
            x-airr:
                nullable: true

#
# Germline gene schema
#

# Rearranged and genomic germline sequences
RearrangedSequence:
    type: object
    description: >
        Details of a directly observed rearranged sequence or an inference from rearranged sequences 
        contributing support for a gene or allele.
    required:
        - sequence_id
        - sequence
        - derivation
        - observation_type
        - repository_name
        - repository_ref
        - deposited_version
        - seq_start
        - seq_end
    properties:
        sequence_id:
            type: string
            description: >
                Unique identifier of this RearrangedSequence within the file, typically generated by the repository 
                hosting the schema, for example from the underlying ID of the database record.
            x-airr:
                identifier: true
                miairr: important
        sequence:
            type: string
            description: nucleotide sequence
            x-airr:
                miairr: essential
                nullable: false
        derivation:
            type: string
            enum:
                - DNA
                - RNA
                - null
            description: The class of nucleic acid that was used as primary starting material
            x-airr:
                miairr: important
                nullable: true
        observation_type:
            type: string
            enum:
                - direct_sequencing
                - inference_from_repertoire
            description: >
                The type of observation from which this sequence was drawn, such as direct sequencing or 
                inference from repertoire sequencing data.
            x-airr:
                miairr: essential
                nullable: false
        curation:
            type: string
            description: Curational notes on the sequence
        repository_name:
            type: string
            description: Name of the repository in which the sequence has been deposited
            x-airr:
                miairr: important
        repository_ref:
            type: string
            description: Queryable id or accession number of the sequence published by the repository
            x-airr:
                miairr: important
        deposited_version:
            type: string
            description: Version number of the sequence within the repository
            x-airr:
                miairr: important
        sequence_start:
            type: integer
            description: Start co-ordinate of the sequence detailed in this record, within the sequence deposited
            x-airr:
                miairr: essential
                nullable: false
        sequence_end:
            type: integer
            description: End co-ordinate of the sequence detailed in this record, within the sequence deposited
            x-airr:
                miairr: essential
                nullable: false

UnrearrangedSequence:
    description: Details of an unrearranged sequence contributing support for a gene or allele
    type: object
    required:
        - sequence_id
        - sequence
        - repository_name
        - repository_ref
        - gff_seqid
        - gff_start
        - gff_end
        - strand
    properties:
        sequence_id:
            type: string
            description: unique identifier of this UnrearrangedSequence within the file
            x-airr:
                identifier: true
                miairr: important
        sequence:
            type: string
            description: >
                Sequence of interest described in this record. Typically, this will include gene and promoter region.
            x-airr:
                miairr: essential
                nullable: false
        curation:
            type: string
            description: Curational notes on the sequence
        repository_name:
            type: string
            description: Name of the repository in which the assembly or contig is deposited
            x-airr:
                miairr: important
        repository_ref:
            type: string
            description: Queryable id or accession number of the sequence published by the repository
            x-airr:
                miairr: important
        patch_no:
            type: string
            description: Genome assembly patch number in which this gene was determined
        gff_seqid:
            type: string
            description: >
                Sequence (from the assembly) of a window including the gene and preferably also the promoter region.
        gff_start:
            type: integer
            description: >
                Genomic co-ordinates of the start of the sequence of interest described in this record in 
                Ensemble GFF version 3.
        gff_end:
            type: integer
            description: >
                Genomic co-ordinates of the end of the sequence of interest described in this record in 
                Ensemble GFF version 3.
        strand:
            type: string
            enum:
                - "+"
                - "-"
                - null
            description: sense (+ or -)
            x-airr:
                nullable: true

# V gene delineation
SequenceDelineationV:
    description: Delineation of a V-gene in a particular system
    type: object
    required:
        - sequence_delineation_id
        - delineation_scheme
        - fwr1_start
        - fwr1_end
        - cdr1_start
        - cdr1_end
        - fwr2_start
        - fwr2_end
        - cdr2_start
        - cdr2_end
        - fwr3_start
        - fwr3_end
        - cdr3_start
    properties:
        sequence_delineation_id:
            type: string
            description: >
                Unique identifier of this SequenceDelineationV within the file. Typically, generated by the 
                repository hosting the record.
            x-airr:
                identifier: true
                miairr: important
        delineation_scheme:
            type: string
            description: Name of the delineation scheme
            example: Chothia
            x-airr:
                miairr: important
        unaligned_sequence:
            type: string
            x-airr:
                miairr: important
            description: entire V-sequence covered by this delineation
        aligned_sequence:
            type: string
            description: >
                Aligned sequence if this delineation provides an alignment. An aligned sequence should always be 
                provided for IMGT delineations.
        fwr1_start:
            type: integer
            description: FWR1 start co-ordinate in the 'unaligned sequence' field
            x-airr:
                miairr: important
        fwr1_end:
            type: integer
            description: FWR1 end co-ordinate in the 'unaligned sequence' field
            x-airr:
                miairr: important
        cdr1_start:
            type: integer
            description: CDR1 start co-ordinate in the 'unaligned sequence' field
            x-airr:
                miairr: important
        cdr1_end:
            type: integer
            description: CDR1 end co-ordinate in the 'unaligned sequence' field
            x-airr:
                miairr: important
        fwr2_start:
            type: integer
            description: FWR2 start co-ordinate in the 'unaligned sequence' field
            x-airr:
                miairr: important
        fwr2_end:
            type: integer
            description: FWR2 end co-ordinate in the 'unaligned sequence' field
            x-airr:
                miairr: important
        cdr2_start:
            type: integer
            description: CDR2 start co-ordinate in the 'unaligned sequence' field
            x-airr:
                miairr: important
        cdr2_end:
            type: integer
            description: CDR2 end co-ordinate in the 'unaligned sequence' field
            x-airr:
                miairr: important
        fwr3_start:
            type: integer
            description: FWR3 start co-ordinate in the 'unaligned sequence' field
            x-airr:
                miairr: important
        fwr3_end:
            type: integer
            description: FWR3 end co-ordinate in the 'unaligned sequence' field
            x-airr:
                miairr: important
        cdr3_start:
            type: integer
            description: CDR3 start co-ordinate in the 'unaligned sequence' field
            x-airr:
                miairr: important
        alignment_labels:
            type: array
            items:
                type: string
            description: >
                One string for each codon in the aligned_sequence indicating the label of that codon according to 
                the numbering of the delineation scheme if it provides one.

# Description of a putative or confirmed Ig receptor gene/allele
AlleleDescription:
    description: Details of a putative or confirmed Ig receptor gene/allele inferred from one or more observations
    type: object
    required:
        - allele_description_id
        - acknowledgements
        - release_version
        - release_date
        - release_description
        - sequence
        - coding_sequence
        - locus
        - sequence_type
        - functional
        - inference_type
        - species
    properties:
        allele_description_id:
            type: string
            description: >
                Unique identifier of this AlleleDescription within the file. Typically, generated by the 
                repository hosting the record.
            x-airr:
                identifier: true
                miairr: important
        allele_description_ref:
            type: string
            description: Unique reference to the allele description, in standardized form (Repo:Label:Version)
            example: OGRDB:Human_IGH:IGHV1-69*01.001
            x-airr:
                miairr: important
        acknowledgements:
            type: array
            description: >
                List of individuals whose contribution to the gene description should be acknowledged. Note that these
                are not necessarily identical with the authors on an associated manuscript or other scholarly
                communication. Further note that typically at least the three CRediT contributor roles "supervision",
                "investigation" and "data curation" should be assigned. The current maintainer should be listed first.
            items:
                $ref: '#/Contributor'
        release_version:
            type: integer
            description: Version number of this record, updated whenever a revised version is published or released
            x-airr:
                miairr: important
        release_date:
            type: string
            format: date-time
            description: Date of this release
            title: Release Date
            example: "2021-02-02"
            x-airr:
                miairr: important
        release_description:
            type: string
            description: Brief descriptive notes of the reason for this release and the changes embodied
            x-airr:
                miairr: important
        label:
            type: string
            description: >
                The accepted name for this gene or allele following the relevant nomenclature.
                The value in this field should correspond to values in acceptable name fields of other schemas, 
                such as v_call, d_call, and j_call fields.
            example: IGHV1-69*01
            x-airr:
                miairr: important
        sequence:
            type: string
            description: >
                Nucleotide sequence of the gene. This should cover the full length that is available, 
                including where possible RSS, and 5' UTR and lead-in for V-gene sequences.
            x-airr:
                miairr: essential
                nullable: false
        coding_sequence:
            type: string
            description: >
                Nucleotide sequence of the core coding region, such as the coding region of a D-, J- or C- gene 
                or the coding region of a V-gene excluding the leader.
            x-airr:
                miairr: important
        aliases:
            type: array
            items:
                type: string
            description: Alternative names for this sequence
        locus:
            type: string
            enum:
                - IGH
                - IGI
                - IGK
                - IGL
                - TRA
                - TRB
                - TRG
                - TRD
            description: Gene locus
            x-airr:
                miairr: essential
                nullable: false
        chromosome:
            type: integer
            description: chromosome on which the gene is located
        sequence_type:
            type: string
            enum:
                - V
                - D
                - J
                - C
            description: Sequence type (V, D, J, C)
            x-airr:
                miairr: essential
                nullable: false
        functional:
            type: boolean
            description: True if the gene is functional, false if it is a pseudogene
            x-airr:
                miairr: important
        inference_type:
            type: string
            enum:
                - genomic_and_rearranged
                - genomic_only
                - rearranged_only
                - null
            description: Type of inference(s) from which this gene sequence was inferred
            x-airr:
                miairr: important
                nullable: true
        species:
            $ref: '#/Ontology'
            description: Binomial designation of subject's species
            title: Organism
            example:
                id: NCBITAXON:9606
                label: Homo sapiens
            x-airr:
                miairr: essential
                nullable: false
                format: ontology
                ontology:
                    draft: false
                    top_node:
                        id: NCBITAXON:7776
                        label: Gnathostomata
        species_subgroup:
            type: string
            description: Race, strain or other species subgroup to which this subject belongs
            example: BALB/c
        species_subgroup_type:
            type: string
            enum:
                - breed
                - strain
                - inbred
                - outbred
                - locational
                - null
            x-airr:
                nullable: true
        status:
            type: string
            enum:
                - active
                - draft
                - retired
                - withdrawn
                - null
            description: Status of record, assumed active if the field is not present
            x-airr:
                nullable: true
        subgroup_designation:
            type: string
            description: Identifier of the gene subgroup or clade, as (and if) defined
        gene_designation:
            type: string
            description: Gene number or other identifier, as (and if) defined
        allele_designation:
            type: string
            description: Allele number or other identifier, as (and if) defined
        allele_similarity_cluster_designation:
            type: string
            description: ID of the similarity cluster used in this germline set, if designated
        allele_similarity_cluster_member_id:
            type: string
            description: Membership ID of the allele within the similarity cluster, if a cluster is designated
        j_codon_frame:
            type: integer
            enum:
                - 1
                - 2
                - 3
                - null
            description: >
                Codon position of the first nucleotide in the 'coding_sequence' field. Mandatory for J genes. 
                Not used for V or D genes. '1' means the sequence is in-frame, '2' means that the first bp is 
                missing from the first codon, and '3' means that the first 2 bp are missing.
            x-airr:
                nullable: true
        gene_start:
            type: integer
            description: >
                Co-ordinate in the sequence field of the first nucleotide in the coding_sequence field.
            x-airr:
                miairr: important
        gene_end:
            type: integer
            description: >
                Co-ordinate in the sequence field of the last gene-coding nucleotide in the coding_sequence field.
            x-airr:
                miairr: important
        utr_5_prime_start:
            type: integer
            description: Start co-ordinate in the sequence field of the 5 prime UTR (V-genes only).
        utr_5_prime_end:
            type: integer
            description: End co-ordinate in the sequence field of the 5 prime UTR (V-genes only).
        leader_1_start:
            type: integer
            description: Start co-ordinate in the sequence field of L-PART1 (V-genes only).
        leader_1_end:
            type: integer
            description: End co-ordinate in the sequence field of L-PART1 (V-genes only).
        leader_2_start:
            type: integer
            description: Start co-ordinate in the sequence field of L-PART2 (V-genes only).
        leader_2_end:
            type: integer
            description: End co-ordinate in the sequence field of L-PART2 (V-genes only).
        v_rs_start:
            type: integer
            description: Start co-ordinate in the sequence field of the V recombination site (V-genes only).
        v_rs_end:
            type: integer
            description: End co-ordinate in the sequence field of the V recombination site (V-genes only).
        d_rs_3_prime_start:
            type: integer
            description: Start co-ordinate in the sequence field of the 3 prime D recombination site (D-genes only).
        d_rs_3_prime_end:
            type: integer
            description: End co-ordinate in the sequence field of the 3 prime D recombination site (D-genes only).
        d_rs_5_prime_start:
            type: integer
            description: Start co-ordinate in the sequence field of the 5 prime D recombination site (D-genes only).
        d_rs_5_prime_end:
            type: integer
            description: End co-ordinate in the sequence field of 5 the prime D recombination site (D-genes only).
        j_cdr3_end:
            type: integer
            description: >
                In the case of a J-gene, the co-ordinate in the sequence field of the first nucelotide of the 
                conserved PHE or TRP (IMGT codon position 118).
        j_rs_start:
            type: integer
            description: Start co-ordinate in the sequence field of J recombination site (J-genes only).
        j_rs_end:
            type: integer
            description: End co-ordinate in the sequence field of J recombination site (J-genes only).
        j_donor_splice:
            type: integer
            description: Co-ordinate in the sequence field of the final 3' nucleotide of the J-REGION (J-genes only).
        v_gene_delineations:
            type: array
            items:
                $ref: '#/SequenceDelineationV'
        unrearranged_support:
            type: array
            items:
                $ref: '#/UnrearrangedSequence'
        rearranged_support:
            type: array
            items:
                $ref: '#/RearrangedSequence'
        paralogs:
            type: array
            items:
                type: string
            description: Gene symbols of any paralogs
        curation:
            type: string
            description: >
                Curational notes on the AlleleDescription. This can be used to give more extensive notes on the 
                decisions taken than are provided in the release_description.
        curational_tags:
            type: array
            items:
                type: string
                enum:
                    - likely_truncated
                    - likely_full_length
            description: Controlled-vocabulary tags applied to this description
            x-airr:
                nullable: true

# Collection of gene descriptions into a germline set
GermlineSet:
    type: object
    description: >
        A germline object set bringing together multiple AlleleDescriptions from the same strain or species. 
        All genes in a GermlineSet should be from a single locus.
    required:
        - germline_set_id
        - acknowledgements
        - release_version
        - release_description
        - release_date
        - germline_set_name
        - germline_set_ref
        - species
        - locus
        - allele_descriptions
    properties:
        germline_set_id:
            type: string
            description: >
                Unique identifier of the GermlineSet within this file. Typically, generated by the 
                repository hosting the record.
            x-airr:
                identifier: true
                miairr: important
        acknowledgements:
            type: array
            description: >
                List of individuals whose contribution to the germline set should be acknowledged. Note that these are
                not necessarily identical with the authors on an associated manuscript or other scholarly communication.
                Further note that typically at least the three CRediT contributor roles "supervision", "investigation"
                and "data curation" should be assigned. The coresponding author should be listed last.
            items:
                $ref: '#/Contributor'
        release_version:
            type: integer
            description: Version number of this record, allocated automatically
            x-airr:
                miairr: important
        release_description:
            type: string
            description: Brief descriptive notes of the reason for this release and the changes embodied
            x-airr:
                miairr: important
        release_date:
            type: string
            format: date-time
            description: Date of this release
            title: Release Date
            example: "2021-02-02"
            x-airr:
                miairr: important
        germline_set_name:
            type: string
            description: descriptive name of this germline set
            x-airr:
                miairr: important
        germline_set_ref:
            type: string
            description: Unique identifier of the germline set and version, in CURIE format
            example: OGRDB_GERMLINESET:germline/set/9606.IGH_VDJ/9
            x-airr:
                miairr: important
                format: CURIE
        pub_ids:
            type: array
            items:
                type: string
            description: Publications describing the germline set
            example: ["PMID:35720344"]
        species:
            $ref: '#/Ontology'
            description: Binomial designation of subject's species
            title: Organism
            example:
                id: NCBITAXON:9606
                label: Homo sapiens
            x-airr:
                miairr: essential
                nullable: false
                format: ontology
                ontology:
                    draft: false
                    top_node:
                        id: NCBITAXON:7776
                        label: Gnathostomata
        species_subgroup:
            type: string
            description: Race, strain or other species subgroup to which this subject belongs
            example: BALB/c
        species_subgroup_type:
            type: string
            enum:
                - breed
                - strain
                - inbred
                - outbred
                - locational
                - null
            x-airr:
                nullable: true
        locus:
            type: string
            enum:
                - IGH
                - IGI
                - IGK
                - IGL
                - TRA
                - TRB
                - TRG
                - TRD
            description: Gene locus
            x-airr:
                miairr: essential
                nullable: false
        allele_descriptions:
            type: array
            items:
                $ref: '#/AlleleDescription'
            description: list of allele_descriptions in the germline set
            x-airr:
                miairr: important
        curation:
            type: string
            description: >
                Curational notes on the GermlineSet. This can be used to give more extensive notes on the 
                decisions taken than are provided in the release_description.

#
# Genotype schema
#

# GenotypeSet lists the  Genotypes (describing different loci) inferred for this subject

GenotypeSet:
    type: object
    required:
        - receptor_genotype_set_id
    properties:
        receptor_genotype_set_id:
            type: string
            description: >
                A unique identifier for this Receptor Genotype Set, typically generated by the repository 
                hosting the schema, for example from the underlying ID of the database record.
            x-airr:
                identifier: true
                miairr: important
        genotype_class_list:
            description: List of Genotypes included in this Receptor Genotype Set.
            type: array
            items:
                $ref: '#/Genotype'

# This enumerates the alleles and gene deletions inferred in a single subject. Included alleles may either be listed by reference to a GermlineSet, or
# listed as 'undocumented', in which case the inferred sequence is provided

# Genotype of adaptive immune receptors
Genotype:
    type: object
    required:
        - receptor_genotype_id
        - locus
    properties:
        receptor_genotype_id:
            type: string
            description: >
                A unique identifier within the file for this Receptor Genotype, typically generated by the 
                repository hosting the schema, for example from the underlying ID of the database record.
            x-airr:
                identifier: true
                miairr: important
        locus:
            type: string
            enum:
                - IGH
                - IGI
                - IGK
                - IGL
                - TRA
                - TRB
                - TRD
                - TRG
            description: Gene locus
            example: IGH
            x-airr:
                miairr: essential
                nullable: false
                adc-query-support: true
                format: controlled_vocabulary
        documented_alleles:
            type: array
            description: List of alleles documented in reference set(s)
            items:
                $ref: '#/DocumentedAllele'
            x-airr:
                miairr: important
        undocumented_alleles:
            type: array
            description: List of alleles inferred to be present and not documented in an identified GermlineSet
            items:
                $ref: '#/UndocumentedAllele'
            x-airr:
                adc-query-support: true
        deleted_genes:
            type: array
            description: Array of genes identified as being deleted in this genotype
            items:
                $ref: '#/DeletedGene'
            x-airr:
                adc-query-support: true
        inference_process:
            type: string
            enum:
                - genomic_sequencing
                - repertoire_sequencing
                - null
            description: Information on how the genotype was acquired. Controlled vocabulary.
            title: Genotype acquisition process
            example: repertoire_sequencing
            x-airr:
                adc-query-support: true
                format: controlled_vocabulary
                nullable: true

# Documented Allele
# This describes a 'known' allele found in a genotype
# It 'known' in the sense that it is documented in a reference set

DocumentedAllele:
    type: object
    required:
        - label
        - germline_set_ref
    properties:
        label:
            type: string
            x-airr:
                miairr: important
            description: The accepted name for this allele, taken from the GermlineSet
        germline_set_ref:
            type: string
            description: GermlineSet from which it was taken, referenced in CURIE format 
            example: OGRDB_GERMLINESET:germline/set/9606.IGH_VDJ/9
            x-airr:
                miairr: important
                format: CURIE
        phasing:
            type: integer
            nullable: true
            description: >
                Chromosomal phasing indicator. Alleles with the same value are inferred to be located on the 
                same chromosome.

# Undocumented Allele
# This describes a 'undocumented' allele found in a genotype
# It is 'undocumented' in the sense that it was not found in reference sets consulted for the analysis

UndocumentedAllele:
    required:
        - allele_name
        - sequence
    type: object
    properties:
        allele_name:
            type: string
            x-airr:
                miairr: important
            description: Allele name as allocated by the inference pipeline
        sequence:
            type: string
            x-airr:
                miairr: essential
                nullable: false
            description: nt sequence of the allele, as provided by the inference pipeline
        phasing:
            type: integer
            nullable: true
            description: >
                Chromosomal phasing indicator. Alleles with the same value are inferred to be located on the 
                same chromosome.

# Deleted Gene
# It is regarded as 'deleted' in the sense that it was not identified during inference of the genotype

DeletedGene:
    required:
        - label
        - germline_set_ref
    type: object
    properties:
        label:
            type: string
            x-airr:
                miairr: essential
                nullable: false
            description: The accepted name for this gene, taken from the GermlineSet
        germline_set_ref:
            type: string
            description: GermlineSet from which it was taken, referenced in CURIE format 
            example: OGRDB_GERMLINESET:germline/set/9606.IGH_VDJ/9
            x-airr:
                miairr: important
                format: CURIE
        phasing:
            type: integer
            nullable: true
            description: >
                Chromosomal phasing indicator. Alleles with the same value are inferred to be located on the 
                same chromosome.

# List of MHCGenotypes describing a subject's genotype
MHCGenotypeSet:
    type: object
    required:
        - mhc_genotype_set_id
        - mhc_genotype_list
    properties:
        mhc_genotype_set_id:
            type: string
            description: A unique identifier for this MHCGenotypeSet
            x-airr:
                identifier: true
                miairr: important
        mhc_genotype_list:
            description: List of MHCGenotypes included in this set
            type: array
            items:
                $ref: '#/MHCGenotype'
            x-airr:
                miairr: important

# Genotype of major histocompatibility complex (MHC) class I, class II and non-classical loci
MHCGenotype:
    type: object
    required:
        - mhc_genotype_id
        - mhc_class
        - mhc_alleles
    properties:
        mhc_genotype_id:
            type: string
            description: A unique identifier for this MHCGenotype, assumed to be unique in the context of the study
            x-airr:
                identifier: true
                miairr: important
        mhc_class:
            type: string
            enum:
                - MHC-I
                - MHC-II
                - MHC-nonclassical
            description: Class of MHC alleles described by the MHCGenotype
            example: MHC-I
            x-airr:
                miairr: essential
                nullable: false
                adc-query-support: true
                format: controlled_vocabulary
        mhc_alleles:
            type: array
            description: List of MHC alleles of the indicated mhc_class identified in an individual
            items:
                $ref: '#/MHCAllele'
            x-airr:
                miairr: important
                adc-query-support: true
        mhc_genotyping_method:
            type: string
            description: >
                Information on how the genotype was determined. The content of this field should come from a list of
                recommended terms provided in the AIRR Schema documentation.
            title: MHC genotyping method
            example: pcr_low_resolution
            x-airr:
                miairr: important
                adc-query-support: true


# Allele of an MHC gene
MHCAllele:
    type: object
    properties:
        allele_designation:
            type: string
            description: >
                The accepted designation of an allele, usually its gene symbol plus allele/sub-allele/etc
                identifiers, if provided by the mhc_typing method
            x-airr:
                miairr: important
        gene:
            $ref: '#/Ontology'
            description: The MHC gene to which the described allele belongs
            title: MHC gene
            example:
                id: MRO:0000046
                label: HLA-A
            x-airr:
                miairr: important
                adc-query-support: false
                format: ontology
                ontology:
                    draft: true
                    top_node:
                        id: MRO:0000004
                        label: MHC gene
        reference_set_ref:
            type: string
            description: Repository and list from which it was taken (issuer/name/version)
            x-airr:
                miairr: important

#
# Repertoire metadata schema
#

# The overall study with a globally unique study_id
Study:
    type: object
    required:
        - study_id
        - study_title
        - study_type
        - inclusion_exclusion_criteria
        - grants
        - contributors
        - pub_ids
        - keywords_study
    properties:
        study_id:
            type: string
            description: >
                Unique ID assigned by study registry such as one of the International Nucleotide Sequence Database
                Collaboration (INSDC) repositories.
            title: Study ID
            example: PRJNA001
            x-airr:
                identifier: true
                miairr: important
                nullable: true
                adc-query-support: true
                set: 1
                subset: study
                name: Study ID
        study_title:
            type: string
            description: Descriptive study title
            title: Study title
            example: Effects of sun light exposure of the Treg repertoire
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 1
                subset: study
                name: Study title
        study_type:
            $ref: '#/Ontology'
            description: Type of study design
            title: Study type
            example:
                id: NCIT:C15197
                label: Case-Control Study
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 1
                subset: study
                name: Study type
                format: ontology
                ontology:
                    draft: false
                    top_node:
                        id: NCIT:C63536
                        label: Study
        study_description:
            type: string
            description: Generic study description
            title: Study description
            example: Longer description
            x-airr:
                nullable: true
                name: Study description
                adc-query-support: true
        inclusion_exclusion_criteria:
            type: string
            description: List of criteria for inclusion/exclusion for the study
            title: Study inclusion/exclusion criteria
            example: "Include: Clinical P. falciparum infection; Exclude: Seropositive for HIV"
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 1
                subset: study
                name: Study inclusion/exclusion criteria
        grants:
            type: string
            description: Funding agencies and grant numbers
            title: Grant funding agency
            example: NIH, award number R01GM987654
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 1
                subset: study
                name: Grant funding agency
        contributors:
            type: array
            description: >
                List of individuals who contributed to the study. Note that these are not necessarily identical with
                the authors on an associated manuscript or other scholarly communication. Further note that typically
                at least the three CRediT contributor roles "supervision", "investigation" and "data curation" should
                be assigned. The coresponding author should be listed last.
            title: Contributors
            items:
                $ref: '#/Contributor'
            x-airr:
                nullable: false
                miairr: essential
                adc-query-support: true
                set: 1
                subset: study
                name: Contributors
        study_contact:
            type: string
            description: >
                Full contact information of the contact persons for this study This should include an e-mail address
                and a persistent identifier such as an ORCID ID.
            x-airr:
                deprecated: true
                deprecated-description: >
                    Acknowledgements and contact information was re-organized into the contributors property, which
                    is an array of Contributor objects.
                deprecated-replaced-by:
                    - contributors
        collected_by:
            type: string
            description: >
                Full contact information of the data collector, i.e. the person who is legally responsible for data
                collection and release. This should include an e-mail address and a persistent identifier such as an
                ORCID ID.
            x-airr:
                deprecated: true
                deprecated-description: >
                    Acknowledgements and contact information was re-organized into the contributors property, which
                    is an array of Contributor objects.
                deprecated-replaced-by:
                    - contributors
        lab_name:
            type: string
            description: Department of data collector
            x-airr:
                deprecated: true
                deprecated-description: >
                    Acknowledgements and contact information was re-organized into the contributors property, which
                    is an array of Contributor objects.
                deprecated-replaced-by:
                    - contributors
        lab_address:
            type: string
            description: Institution and institutional address of data collector
            x-airr:
                deprecated: true
                deprecated-description: >
                    Acknowledgements and contact information was re-organized into the contributors property, which
                    is an array of Contributor objects.
                deprecated-replaced-by:
                    - contributors
        submitted_by:
            type: string
            description: >
                Full contact information of the data depositor, i.e., the person submitting the data to a repository.
                This should include an e-mail address and a persistent identifier such as an ORCID ID. This is
                supposed to be a short-lived and technical role until the submission is relased.
            x-airr:
                deprecated: true
                deprecated-description: >
                    Acknowledgements and contact information was re-organized into the contributors property, which
                    is an array of Contributor objects.
                deprecated-replaced-by:
                    - contributors
        pub_ids:
            type: array
            items:
                type: string
            description: >
                Array of publications describing the rationale and/or outcome of the study as an array of CURIE objects such as 
                a DOI or Pubmed ID. Where more than one publication is given, if there is a primary publication for the study it
                should come first.
            title: Relevant publications
            example: ["PMID:29144493", "DOI:10.1038/ni.3873"]
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 1
                subset: study
                name: Relevant publications
        keywords_study:
            type: array
            items:
                type: string
                enum:
                    - contains_ig
                    - contains_tr
                    - contains_paired_chain
                    - contains_schema_rearrangement
                    - contains_schema_clone
                    - contains_schema_cell
                    - contains_schema_receptor
                    - contains_schema_cellexpression
                    - contains_schema_receptorreactivity
            description: >
                Keywords describing properties of one or more data sets in a study. "contains_schema" keywords indicate that
                the study contains data objects from the AIRR Schema of that type (Rearrangement, Clone, Cell, Receptor) while
                the other keywords indicate that the study design considers the type of data indicated (e.g. it is possible to have
                a study that "contains_paired_chain" but does not "contains_schema_cell").
            title: Keywords for study
            example:
                - contains_ig
                - contains_schema_rearrangement
                - contains_schema_clone
                - contains_schema_cell
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 1
                subset: study
                name: Keywords for study
                format: controlled_vocabulary
        adc_publish_date:
            type: string
            format: date-time
            description: >
                Date the study was first published in the AIRR Data Commons.
            title: ADC Publish Date
            example: "2021-02-02"
            x-airr:
                nullable: true
                adc-query-support: true
                name: ADC Publish Date
        adc_update_date:
            type: string
            format: date-time
            description: >
                Date the study data was updated in the AIRR Data Commons.
            title: ADC Update Date
            example: "2021-02-02"
            x-airr:
                nullable: true
                adc-query-support: true
                name: ADC Update Date

SubjectGenotype:
    type: object
    properties:
        receptor_genotype_set:
            $ref: '#/GenotypeSet'
            description: Immune receptor genotype set for this subject.
        mhc_genotype_set:
            $ref: '#/MHCGenotypeSet'
            description: MHC genotype set for this subject.

# 1-to-n relationship between a study and its subjects
# subject_id is unique within a study
Subject:
    type: object
    required:
        - subject_id
        - synthetic
        - species
        - sex
        - age
        - age_event
        - ancestry_population
        - ethnicity
        - race
        - strain_name
        - linked_subjects
        - link_type
    properties:
        subject_id:
            type: string
            description: >
                Subject ID assigned by submitter, unique within study. If possible, a persistent subject ID linked to
                an INSDC or similar repository study should be used.
            title: Subject ID
            example: SUB856413
            x-airr:
                identifier: true
                miairr: important
                nullable: true
                adc-query-support: true
                set: 1
                subset: subject
                name: Subject ID
        synthetic:
            type: boolean
            description: TRUE for libraries in which the diversity has been synthetically generated (e.g. phage display)
            title: Synthetic library
            x-airr:
                miairr: essential
                nullable: false
                adc-query-support: true
                set: 1
                subset: subject
                name: Synthetic library
        species:
            $ref: '#/Ontology'
            description: Binomial designation of subject's species
            title: Organism
            example:
                id: NCBITAXON:9606
                label: Homo sapiens
            x-airr:
                miairr: essential
                nullable: false
                adc-query-support: true
                set: 1
                subset: subject
                name: Species
                format: ontology
                ontology:
                    draft: false
                    top_node:
                        id: NCBITAXON:7776
                        label: Gnathostomata
        organism:
            $ref: '#/Ontology'
            description: Binomial designation of subject's species
            x-airr:
                deprecated: true
                deprecated-description: Field was renamed to species for clarity.
                deprecated-replaced-by:
                    - species
        sex:
            type: string
            enum:
                - male
                - female
                - pooled
                - hermaphrodite
                - intersex
                - null
            description: Biological sex of subject
            title: Sex
            example: female
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 1
                subset: subject
                name: Sex
                format: controlled_vocabulary
        age:
            $ref: '#/TimeInterval'
            description: >
                Age of subject expressed as a time interval. If singular time point then
                min == max in the time interval.
            examples:
                - min: 50
                  max: 50
                  unit:
                      id: UO:0000036
                      label: year
                - min: 5
                  max: 10
                  unit:
                      id: UO:0000034
                      label: week
            x-airr:
                nullable: true
                miairr: important
                adc-query-support: true
                set: 1
                subset: subject
                name: Age
                format: time_interval
        age_event:
            type: string
            description: >
                Event in the study schedule to which `Age` refers. For NCBI BioSample this MUST be `sampling`. For other
                implementations submitters need to be aware that there is currently no mechanism to encode to potential
                delta between `Age event` and `Sample collection time`, hence the chosen events should be in temporal proximity.
            title: Age event
            example: enrollment
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 1
                subset: subject
                name: Age event

        
        
        age_min:
            type: number
            x-airr:
                nullable: true
                deprecated: true
                deprecated-description: Combined into single age field.
                deprecated-replaced-by:
                    - age
        age_max:
            type: number
            x-airr:
                nullable: true
                deprecated: true
                deprecated-description: Combined into single age field.
                deprecated-replaced-by:
                    - age
        age_unit:
            $ref: '#/Ontology'
            x-airr:
                nullable: true
                deprecated: true
                deprecated-description: Combined into single age field.
                deprecated-replaced-by:
                    - age
        ancestry_population:
            $ref: '#/Ontology'
            description: Broad geographic origin of ancestry (continent)
            title: Ancestry population
            example:
                id: GAZ:00000459
                label: South America
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 1
                subset: subject
                name: Ancestry population
                format: ontology
                ontology:
                    draft: true
                    top_node:
                        id: GAZ:00000448
                        label: geographic location
        location_birth:
            $ref: '#/Ontology'
            description: Self-reported location of birth of the subject, preferred granularity is country-level
            example:
                id: GAZ:00002939
                label: Poland
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 1
                subset: subject
                name: Location of birth
                format: ontology
                ontology:
                    draft: true
                    top_node:
                        id: GAZ:00000448
                        label: geographic location
        ethnicity:
            type: string
            description: Ethnic group of subject (defined as cultural/language-based membership)
            title: Ethnicity
            example: English, Kurds, Manchu, Yakuts (and other fields from Wikipedia)
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 1
                subset: subject
                name: Ethnicity
        race:
            type: string
            description: Racial group of subject (as defined by NIH)
            title: Race
            example: White, American Indian or Alaska Native, Black, Asian, Native Hawaiian or Other Pacific Islander, Other
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 1
                subset: subject
                name: Race
        strain_name:
            type: string
            description: Non-human designation of the strain or breed of animal used
            title: Strain name
            example: C57BL/6J
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 1
                subset: subject
                name: Strain name
        linked_subjects:
            type: string
            description: Subject ID to which `Relation type` refers
            title: Relation to other subjects
            example: SUB1355648
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 1
                subset: subject
                name: Relation to other subjects
        link_type:
            type: string
            description: Relation between subject and `linked_subjects`, can be genetic or environmental (e.g.exposure)
            title: Relation type
            example: father, daughter, household
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 1
                subset: subject
                name: Relation type
        diagnosis:
            type: array
            description: Diagnosis information for subject
            items:
                $ref: '#/Diagnosis'
            x-airr:
                nullable: false
                adc-query-support: true
        genotype:
            $ref: '#/SubjectGenotype'
            title: SubjectGenotype

# 1-to-n relationship between a subject and its diagnoses
Diagnosis:
    type: object
    required:
        - study_group_description
        - disease_diagnosis
        - disease_length
        - disease_stage
        - prior_therapies
        - immunogen
        - intervention
        - medical_history
    properties:
        study_group_description:
            type: string
            description: Designation of study arm to which the subject is assigned to
            title: Study group description
            example: control
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 1
                subset: diagnosis and intervention
                name: Study group description
        diagnosis_timepoint:
            $ref: '#/TimePoint'
            description: Time point for the diagnosis
            title: Diagnosis timepoint
            example: 
                label: Study enrollment
                value: 60
                unit:
                    id: UO:0000033
                    label: day
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 1
                subset: diagnosis and intervention
                name: Diagnosis timepoint
                format: time_point
        disease_diagnosis:
            $ref: '#/Ontology'
            description: Diagnosis of subject
            title: Diagnosis
            example:
                id: DOID:9538
                label: multiple myeloma
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 1
                subset: diagnosis and intervention
                name: Diagnosis
                format: ontology
                ontology:
                    draft: false
                    top_node:
                        id: DOID:4
                        label: disease
        disease_length:
            $ref: '#/TimeQuantity'
            description: Time duration between initial diagnosis and current intervention
            title: Length of disease
            example:
                quantity: 23
                unit:
                    id: UO:0000035
                    label: month
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 1
                subset: diagnosis and intervention
                name: Length of disease
                format: physical_quantity
        disease_stage:
            type: string
            description: Stage of disease at current intervention
            title: Disease stage
            example: Stage II
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 1
                subset: diagnosis and intervention
                name: Disease stage
        prior_therapies:
            type: string
            description: List of all relevant previous therapies applied to subject for treatment of `Diagnosis`
            title: Prior therapies for primary disease under study
            example: melphalan/prednisone
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 1
                subset: diagnosis and intervention
                name: Prior therapies for primary disease under study
        immunogen:
            type: string
            description: Antigen, vaccine or drug applied to subject at this intervention
            title: Immunogen/agent
            example: bortezomib
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 1
                subset: diagnosis and intervention
                name: Immunogen/agent
        intervention:
            type: string
            description: Description of intervention
            title: Intervention definition
            example: systemic chemotherapy, 6 cycles, 1.25 mg/m2
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 1
                subset: diagnosis and intervention
                name: Intervention definition
        medical_history:
            type: string
            description: Medical history of subject that is relevant to assess the course of disease and/or treatment
            title: Other relevant medical history
            example: MGUS, first diagnosed 5 years prior
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 1
                subset: diagnosis and intervention
                name: Other relevant medical history

# 1-to-n relationship between a subject and its samples
# sample_id is unique within a study
Sample:
    type: object
    required:
        - sample_id
        - sample_type
        - tissue
        - anatomic_site
        - disease_state_sample
        - collection_time_point_relative
        - biomaterial_provider
    properties:
        sample_id:
            type: string
            description: >
                Sample ID assigned by submitter, unique within study. If possible, a persistent sample ID linked to
                INSDC or similar repository study should be used.
            title: Biological sample ID
            example: SUP52415
            x-airr:
                identifier: true
                miairr: important
                nullable: true
                adc-query-support: true
                set: 2
                subset: sample
                name: Biological sample ID
        sample_type:
            type: string
            description: The way the sample was obtained, e.g. fine-needle aspirate, organ harvest, peripheral venous puncture
            title: Sample type
            example: Biopsy
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 2
                subset: sample
                name: Sample type
        tissue:
            $ref: '#/Ontology'
            description: The actual tissue sampled, e.g. lymph node, liver, peripheral blood
            title: Tissue
            example:
                id: UBERON:0002371
                label: bone marrow
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 2
                subset: sample
                name: Tissue
                format: ontology
                ontology:
                    draft: false
                    top_node:
                        id: UBERON:0010000
                        label: multicellular anatomical structure
        anatomic_site:
            type: string
            description: The anatomic location of the tissue, e.g. Inguinal, femur
            title: Anatomic site
            example: Iliac crest
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 2
                subset: sample
                name: Anatomic site
        disease_state_sample:
            type: string
            description: Histopathologic evaluation of the sample
            title: Disease state of sample
            example: Tumor infiltration
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 2
                subset: sample
                name: Disease state of sample
        collection_time_point_relative:
            $ref: '#/TimePoint'
            description: Time point at which sample was taken, relative to `label` event
            title: Sample collection time
            example:
                label: Primary vaccination
                value: 14
                unit:
                    id: UO:0000033
                    label: day
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 2
                subset: sample
                name: Sample collection time
                format: time_point
        collection_time_point_relative_unit:
            $ref: '#/Ontology'
            x-airr:
                nullable: true
                deprecated: true
                deprecated-description: Field has been merged with collection_time_point_relative.
                deprecated-replaced-by:
                    - collection_time_point_relative
        collection_time_point_reference:
            type: string
            description: Event in the study schedule to which `Sample collection time` relates to
            x-airr:
                nullable: true
                deprecated: true
                deprecated-description: Field has been merged with collection_time_point_relative.
                deprecated-replaced-by:
                    - collection_time_point_relative
        collection_location:
            $ref: '#/Ontology'
            description: Location where the sample was taken, preferred granularity is country-level
            title: Sample collection location
            example:
                id: GAZ:00002939
                label: Poland
            x-airr:
                miairr: important
                nullable: true
                set: 2
                subset: sample
                name: Sample collection location
                format: ontology
                ontology:
                    draft: true
                    top_node:
                        id: GAZ:00000448
                        label: geographic location
        biomaterial_provider:
            type: string
            description: Name and address of the entity providing the sample
            title: Biomaterial provider
            example: Tissues-R-Us, Tampa, FL, USA
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 2
                subset: sample
                name: Biomaterial provider

# 1-to-n relationship between a sample and processing of its cells
CellProcessing:
    type: object
    required:
        - tissue_processing
        - cell_subset
        - cell_phenotype
        - single_cell
        - cell_number
        - cells_per_reaction
        - cell_storage
        - cell_quality
        - cell_isolation
        - cell_processing_protocol
    properties:
        tissue_processing:
            type: string
            description: Enzymatic digestion and/or physical methods used to isolate cells from sample
            title: Tissue processing
            example: Collagenase A/Dnase I digested, followed by Percoll gradient
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 3
                subset: process (cell)
                name: Tissue processing
        cell_subset:
            $ref: '#/Ontology'
            description: Commonly-used designation of isolated cell population
            title: Cell subset
            example:
                id: CL:0000972
                label: class switched memory B cell
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 3
                subset: process (cell)
                name: Cell subset
                format: ontology
                ontology:
                    draft: false
                    top_node:
                        id: CL:0000542
                        label: lymphocyte
        cell_phenotype:
            type: string
            description: >
                List of cellular markers and their expression levels used to isolate the cell population.
            title: Cell subset phenotype
            example: CD19+ CD38+ CD27+ IgM- IgD-
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 3
                subset: process (cell)
                name: Cell subset phenotype
        cell_label:
            type: string
            description: >
                Free text cell type annotation. Primarily used for annotating cell types that are not 
                provided in the Cell Ontology.
            title: Cell annotation
            example: age-associated B cell
            x-airr:
                miairr: defined
                nullable: true
                adc-query-support: true
                set: 3
                subset: process (cell)
                name: Cell annotation
        cell_species:
            $ref: '#/Ontology'
            description: >
                Binomial designation of the species from which the analyzed cells originate. Typically, this value
                should be identical to `species`, in which case it SHOULD NOT be set explicitly. However, there are
                valid experimental setups in which the two might differ, e.g., chimeric animal models. If set, this
                key will overwrite the `species` information for all lower layers of the schema.
            title: Cell species
            example:
                id: NCBITAXON:9606
                label: Homo sapiens
            x-airr:
                miairr: defined
                nullable: true
                adc-query-support: true
                set: 3
                subset: process (cell)
                name: Cell species
                format: ontology
                ontology:
                    draft: false
                    top_node:
                        id: NCBITAXON:7776
                        label: Gnathostomata
        single_cell:
            type: boolean
            description: TRUE if single cells were isolated into separate compartments
            title: Single-cell sort
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 3
                subset: process (cell)
                name: Single-cell sort
        cell_number:
            type: integer
            description: Total number of cells that went into the experiment
            title: Number of cells in experiment
            example: 1000000
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 3
                subset: process (cell)
                name: Number of cells in experiment
        cells_per_reaction:
            type: integer
            description: Number of cells for each biological replicate
            title: Number of cells per sequencing reaction
            example: 50000
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 3
                subset: process (cell)
                name: Number of cells per sequencing reaction
        cell_storage:
            type: boolean
            description: TRUE if cells were cryo-preserved between isolation and further processing
            title: Cell storage
            example: TRUE
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 3
                subset: process (cell)
                name: Cell storage
        cell_quality:
            type: string
            description: Relative amount of viable cells after preparation and (if applicable) thawing
            title: Cell quality
            example: 90% viability as determined by 7-AAD
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 3
                subset: process (cell)
                name: Cell quality
        cell_isolation:
            type: string
            description: Description of the procedure used for marker-based isolation or enrich cells
            title: Cell isolation / enrichment procedure
            example: >
                Cells were stained with fluorochrome labeled antibodies and then sorted on a FlowMerlin (CE) cytometer.
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 3
                subset: process (cell)
                name: Cell isolation / enrichment procedure
        cell_processing_protocol:
            type: string
            description: >
                Description of the methods applied to the sample including cell preparation/ isolation/enrichment and
                nucleic acid extraction. This should closely mirror the Materials and methods section in the manuscript.
            title: Processing protocol
            example: Stimulated wih anti-CD3/anti-CD28
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 3
                subset: process (cell)
                name: Processing protocol

# object for PCR primer targets
PCRTarget:
    type: object
    required:
        - pcr_target_locus
        - forward_pcr_primer_target_location
        - reverse_pcr_primer_target_location
    properties:
        pcr_target_locus:
            type: string
            enum:
                - IGH
                - IGI
                - IGK
                - IGL
                - TRA
                - TRB
                - TRD
                - TRG
                - null
            description: >
                Designation of the target locus. Note that this field uses a controlled vocubulary that is meant to
                provide a generic classification of the locus, not necessarily the correct designation according to
                a specific nomenclature.
            title: Target locus for PCR
            example: IGK
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 3
                subset: process (nucleic acid [pcr])
                name: Target locus for PCR
                format: controlled_vocabulary
        forward_pcr_primer_target_location:
            type: string
            description: Position of the most distal nucleotide templated by the forward primer or primer mix
            title: Forward PCR primer target location
            example: IGHV, +23
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 3
                subset: process (nucleic acid [pcr])
                name: Forward PCR primer target location
        reverse_pcr_primer_target_location:
            type: string
            description: Position of the most proximal nucleotide templated by the reverse primer or primer mix
            title: Reverse PCR primer target location
            example: IGHG, +57
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 3
                subset: process (nucleic acid [pcr])
                name: Reverse PCR primer target location

# generally, a 1-to-1 relationship between a CellProcessing and processing of its nucleic acid
# but may be 1-to-n for technical replicates.
NucleicAcidProcessing:
    type: object
    required:
        - template_class
        - template_quality
        - template_amount
        - library_generation_method
        - library_generation_protocol
        - library_generation_kit_version
        - complete_sequences
        - physical_linkage
    properties:
        template_class:
            type: string
            enum:
                - DNA
                - RNA
            description: >
                The class of nucleic acid that was used as primary starting material for the following procedures
            title: Target substrate
            example: RNA
            x-airr:
                miairr: essential
                nullable: false
                adc-query-support: true
                set: 3
                subset: process (nucleic acid)
                name: Target substrate
                format: controlled_vocabulary
        template_quality:
            type: string
            description: Description and results of the quality control performed on the template material
            title: Target substrate quality
            example: RIN 9.2
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 3
                subset: process (nucleic acid)
                name: Target substrate quality
        template_amount:
            $ref: '#/PhysicalQuantity'
            description: Amount of template that went into the process
            title: Template amount
            example:
                quantity: 1000
                unit:
                    id: UO:0000024
                    label: nanogram
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 3
                subset: process (nucleic acid)
                name: Template amount
                format: physical_quantity
        template_amount_unit:
            $ref: '#/Ontology'
            x-airr:
                nullable: true
                deprecated: true
                deprecated-description: Field has been merged with template_amount.
                deprecated-replaced-by:
                    - template_amount
        library_generation_method:
            type: string
            enum:
                - "PCR"
                - "RT(RHP)+PCR"
                - "RT(oligo-dT)+PCR"
                - "RT(oligo-dT)+TS+PCR"
                - "RT(oligo-dT)+TS(UMI)+PCR"
                - "RT(specific)+PCR"
                - "RT(specific)+TS+PCR"
                - "RT(specific)+TS(UMI)+PCR"
                - "RT(specific+UMI)+PCR"
                - "RT(specific+UMI)+TS+PCR"
                - "RT(specific)+TS"
                - "other"
            description: Generic type of library generation
            title: Library generation method
            example: RT(oligo-dT)+TS(UMI)+PCR
            x-airr:
                miairr: essential
                nullable: false
                adc-query-support: true
                set: 3
                subset: process (nucleic acid)
                name: Library generation method
                format: controlled_vocabulary
        library_generation_protocol:
            type: string
            description: Description of processes applied to substrate to obtain a library that is ready for sequencing
            title: Library generation protocol
            example: cDNA was generated using
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 3
                subset: process (nucleic acid)
                name: Library generation protocol
        library_generation_kit_version:
            type: string
            description: When using a library generation protocol from a commercial provider, provide the protocol version number
            title: Protocol IDs
            example: v2.1 (2016-09-15)
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 3
                subset: process (nucleic acid)
                name: Protocol IDs
        pcr_target:
            type: array
            description: >
                If a PCR step was performed that specifically targets the IG/TR loci, the target and primer locations
                need to be provided here. This field holds an array of PCRTarget objects, so that multiplex PCR setups
                amplifying multiple loci at the same time can be annotated using one record per locus. PCR setups not
                targeting any specific locus must not annotate this field but select the appropriate
                library_generation_method instead.
            items:
                $ref: '#/PCRTarget'
            x-airr:
                nullable: false
                adc-query-support: true
        complete_sequences:
            type: string
            enum:
                - partial
                - complete
                - "complete+untemplated"
                - mixed
            description: >
                To be considered `complete`, the procedure used for library construction MUST generate sequences that
                1) include the first V gene codon that encodes the mature polypeptide chain (i.e. after the
                leader sequence) and 2) include the last complete codon of the J gene (i.e. 1 bp 5' of the J->C
                splice site) and 3) provide sequence information for all positions between 1) and 2). To be considered
                `complete & untemplated`, the sections of the sequences defined in points 1) to 3) of the previous
                sentence MUST be untemplated, i.e. MUST NOT overlap with the primers used in library preparation.
                `mixed` should only be used if the procedure used for library construction will likely produce multiple
                categories of sequences in the given experiment. It SHOULD NOT be used as a replacement of a NULL value.
            title: Complete sequences
            example: partial
            x-airr:
                miairr: essential
                nullable: false
                adc-query-support: true
                set: 3
                subset: process (nucleic acid)
                name: Complete sequences
                format: controlled_vocabulary
        physical_linkage:
            type: string
            enum:
                - none
                - hetero_head-head
                - hetero_tail-head
                - hetero_prelinked
            description: >
                In case an experimental setup is used that physically links nucleic acids derived from distinct
                `Rearrangements` before library preparation, this field describes the mode of that linkage. All
                `hetero_*` terms indicate that in case of paired-read sequencing, the two reads should be expected
                to map to distinct IG/TR loci. `*_head-head` refers to techniques that link the 5' ends of transcripts
                in a single-cell context. `*_tail-head` refers to techniques that link the 3' end of one transcript to
                the 5' end of another one in a single-cell context. This term does not provide any information whether
                a continuous reading-frame between the two is generated. `*_prelinked` refers to constructs in which
                the linkage was already present on the DNA level (e.g. scFv).
            title: Physical linkage of different rearrangements
            example: hetero_head-head
            x-airr:
                miairr: essential
                nullable: false
                adc-query-support: true
                set: 3
                subset: process (nucleic acid)
                name: Physical linkage of different rearrangements
                format: controlled_vocabulary

# 1-to-n relationship between a NucleicAcidProcessing and SequencingRun with resultant raw sequence file(s)
SequencingRun:
    type: object
    required:
        - sequencing_run_id
        - total_reads_passing_qc_filter
        - sequencing_platform
        - sequencing_facility
        - sequencing_run_date
        - sequencing_kit
    properties:
        sequencing_run_id:
            type: string
            description: ID of sequencing run assigned by the sequencing facility
            title: Batch number
            example: 160101_M01234
            x-airr:
                identifier: true
                miairr: important
                nullable: true
                adc-query-support: true
                set: 3
                subset: process (sequencing)
                name: Batch number
        total_reads_passing_qc_filter:
            type: integer
            description: Number of usable reads for analysis
            title: Total reads passing QC filter
            example: 10365118
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 3
                subset: process (sequencing)
                name: Total reads passing QC filter
        sequencing_platform:
            type: string
            description: Designation of sequencing instrument used
            title: Sequencing platform
            example: Alumina LoSeq 1000
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 3
                subset: process (sequencing)
                name: Sequencing platform
        sequencing_facility:
            type: string
            description: Name and address of sequencing facility
            title: Sequencing facility
            example: Seqs-R-Us, Vancouver, BC, Canada
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 3
                subset: process (sequencing)
                name: Sequencing facility
        sequencing_run_date:
            type: string
            description: Date of sequencing run
            title: Date of sequencing run
            format: date
            example: 2016-12-16
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 3
                subset: process (sequencing)
                name: Date of sequencing run
        sequencing_kit:
            type: string
            description: Name, manufacturer, order and lot numbers of sequencing kit
            title: Sequencing kit
            example: "FullSeq 600, Alumina, #M123456C0, 789G1HK"
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 3
                subset: process (sequencing)
                name: Sequencing kit
        sequencing_files:
            $ref: '#/SequencingData'
            description: Set of sequencing files produced by the sequencing run
            x-airr:
                nullable: false
                adc-query-support: true

# Resultant raw sequencing files from a SequencingRun
SequencingData:
    type: object
    required:
        - sequencing_data_id
        - file_type
        - filename
        - read_direction
        - read_length
        - paired_filename
        - paired_read_direction
        - paired_read_length
    properties:
        sequencing_data_id:
            type: string
            description: >
                Persistent identifier of raw data stored in an archive (e.g. INSDC run ID). Data archive should 
                be identified in the CURIE prefix.
            title: Raw sequencing data persistent identifier
            example: "SRA:SRR11610494"
            x-airr:
                identifier: true
                miairr: important
                nullable: true
                adc-query-support: true
                set: 4
                subset: data (raw reads)
                format: CURIE
        file_type:
            type: string
            description: File format for the raw reads or sequences
            title: Raw sequencing data file type
            enum:
                - fasta
                - fastq
                - null
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 4
                subset: data (raw reads)
                name: Raw sequencing data file type
                format: controlled_vocabulary
        filename:
            type: string
            description: File name for the raw reads or sequences. The first file in paired-read sequencing.
            title: Raw sequencing data file name
            example: MS10R-NMonson-C7JR9_S1_R1_001.fastq
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 4
                subset: data (raw reads)
                name: Raw sequencing data file name
        read_direction:
            type: string
            description: Read direction for the raw reads or sequences. The first file in paired-read sequencing.
            title: Read direction
            example: forward
            enum:
                - forward
                - reverse
                - mixed
                - null
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 4
                subset: data (raw reads)
                name: Read direction
                format: controlled_vocabulary
        read_length:
            type: integer
            description: Read length in bases for the first file in paired-read sequencing
            title: Forward read length
            example: 300
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 4
                subset: data (raw reads)
                name: Forward read length
        paired_filename:
            type: string
            description: File name for the second file in paired-read sequencing
            title: Paired raw sequencing data file name
            example: MS10R-NMonson-C7JR9_S1_R2_001.fastq
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 4
                subset: data (raw reads)
                name: Paired raw sequencing data file name
        paired_read_direction:
            type: string
            description: Read direction for the second file in paired-read sequencing
            title: Paired read direction
            example: reverse
            enum:
                - forward
                - reverse
                - mixed
                - null
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 4
                subset: data (raw reads)
                name: Paired read direction
                format: controlled_vocabulary
        paired_read_length:
            type: integer
            description: Read length in bases for the second file in paired-read sequencing
            title: Paired read length
            example: 300
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 4
                subset: data (raw reads)
                name: Paired read length
        index_filename:
            type: string
            description: File name for the index file
            title: Sequencing index file name
            example: MS10R-NMonson-C7JR9_S1_R3_001.fastq
            x-airr:
                nullable: true
                adc-query-support: true
        index_length:
            type: integer
            description: Read length in bases for the index file
            title: Index read length
            example: 8
            x-airr:
                nullable: true
                adc-query-support: true

# 1-to-n relationship between a repertoire and data processing
#
# Set of annotated rearrangement sequences produced by
# data processing upon the raw sequence data for a repertoire.
DataProcessing:
    type: object
    required:
        - software_versions
        - paired_reads_assembly
        - quality_thresholds
        - primer_match_cutoffs
        - collapsing_method
        - data_processing_protocols
        - germline_database
    properties:
        data_processing_id:
            type: string
            description: Identifier for the data processing object.
            title: Data processing ID
            x-airr:
                identifier: true
                nullable: true
                name: Data processing ID
                adc-query-support: true
        primary_annotation:
            type: boolean
            default: false
            description: >
                If true, indicates this is the primary or default data processing for
                the repertoire and its rearrangements. If false, indicates this is a secondary
                or additional data processing.
            title: Primary annotation
            x-airr:
                nullable: false
                adc-query-support: true
                identifier: true
        software_versions:
            type: string
            description: Version number and / or date, include company pipelines
            title: Software tools and version numbers
            example: IgBLAST 1.6
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 5
                subset: process (computational)
                name: Software tools and version numbers
        paired_reads_assembly:
            type: string
            description: How paired end reads were assembled into a single receptor sequence
            title: Paired read assembly
            example: PandaSeq (minimal overlap 50, threshold 0.8)
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 5
                subset: process (computational)
                name: Paired read assembly
        quality_thresholds:
            type: string
            description: How/if sequences were removed from (4) based on base quality scores
            title: Quality thresholds
            example: Average Phred score >=20
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 5
                subset: process (computational)
                name: Quality thresholds
        primer_match_cutoffs:
            type: string
            description: How primers were identified in the sequences, were they removed/masked/etc?
            title: Primer match cutoffs
            example: Hamming distance <= 2
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 5
                subset: process (computational)
                name: Primer match cutoffs
        collapsing_method:
            type: string
            description: The method used for combining multiple sequences from (4) into a single sequence in (5)
            title: Collapsing method
            example: MUSCLE 3.8.31
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 5
                subset: process (computational)
                name: Collapsing method
        data_processing_protocols:
            type: string
            description: General description of how QC is performed
            title: Data processing protocols
            example: Data was processed using [...]
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 5
                subset: process (computational)
                name: Data processing protocols
        data_processing_files:
            type: array
            items:
                type: string
            description: Array of file names for data produced by this data processing.
            title: Processed data file names
            example:
                - 'ERR1278153_aa.txz'
                - 'ERR1278153_ab.txz'
                - 'ERR1278153_ac.txz'
            x-airr:
                nullable: true
                adc-query-support: true
                name: Processed data file names
        germline_database:
            type: string
            description: Source of germline V(D)J genes with version number or date accessed.
            title: V(D)J germline reference database
            example: ENSEMBL, Homo sapiens build 90, 2017-10-01
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 5
                subset: process (computational)
                name: V(D)J germline reference database
        germline_set_ref:
            type: string
            description: Unique identifier of the germline set and version, in CURIE format
            example: OGRDB_GERMLINESET:germline/set/9606.IGH_VDJ/9
            x-airr:
                nullable: true
                adc-query-support: true
                format: CURIE
        analysis_provenance_id:
            type: string
            description: Identifier for machine-readable PROV model of analysis provenance
            title: Analysis provenance ID
            x-airr:
                nullable: true
                adc-query-support: true

SampleProcessing:
    allOf:
        - type: object
          properties:
              sample_processing_id:
                  type: string
                  description: >
                      Identifier for the sample processing object. This field should be unique within the repertoire.
                      This field can be used to uniquely identify the combination of sample, cell processing,
                      nucleic acid processing and sequencing run information for the repertoire.
                  title: Sample processing ID
                  x-airr:
                      identifier: true
                      nullable: true
                      name: Sample processing ID
                      adc-query-support: true
        - $ref: '#/Sample'
        - $ref: '#/CellProcessing'
        - $ref: '#/NucleicAcidProcessing'
        - $ref: '#/SequencingRun'


# The composite schema for the repertoire object
#
# This represents a sample repertoire as defined by the study
# and experimentally observed by raw sequence data. A repertoire
# can only be for one subject but may include multiple samples.
Repertoire:
    type: object
    required:
        - study
        - subject
        - sample
        - data_processing
    properties:
        repertoire_id:
            type: string
            description: >
                Identifier for the repertoire object. This identifier should be globally unique so that repertoires
                from multiple studies can be combined together without conflict. The repertoire_id is used to link
                other AIRR data to a Repertoire. Specifically, the Rearrangements Schema includes repertoire_id for
                referencing the specific Repertoire for that Rearrangement.
            title: Repertoire ID
            x-airr:
                nullable: true
                adc-query-support: true
                identifier: true
        repertoire_name:
            type: string
            description: Short generic display name for the repertoire
            title: Repertoire name
            x-airr:
                nullable: true
                name: Repertoire name
                adc-query-support: true
        repertoire_description:
            type: string
            description: Generic repertoire description
            title: Repertoire description
            x-airr:
                nullable: true
                name: Repertoire description
                adc-query-support: true
        repertoire_type:
            type: string
            enum:
                - observed
                - simulated
                - inferred
                - null
            description: >
                Repertoire type (source). Most often the type should be "observed," meaning it corresponds to
                an actual physical sample that was sequenced. Other allowed values are "simulated," i.e. the
                Rearrangements were generated in silico and there is no linked Subject/Sample metadata, and
                "inferred" for Rearrangements that are phylogenetically reconstructed from observed sequences.
                Inferred Repertoires should point to the same Subject/Sample metadata as the corresponding
                physical Repertoires.
            title: Repertoire type
            example: physical
            x-airr:
                nullable: true
                name: Repertoire type
                format: controlled_vocabulary
                adc-query-support: true
        study:
            $ref: '#/Study'
            description: Study object
            x-airr:
                nullable: false
                adc-query-support: true
        subject:
            $ref: '#/Subject'
            description: Subject object
            x-airr:
                nullable: false
                adc-query-support: true
        sample:
            type: array
            description: List of Sample Processing objects
            items:
                $ref: '#/SampleProcessing'
            x-airr:
                nullable: false
                adc-query-support: true
        data_processing:
            type: array
            description: List of Data Processing objects
            items:
                $ref: '#/DataProcessing'
            x-airr:
                nullable: false
                adc-query-support: true

# A RepertoireFilter references the underlying Repertoires to be included in a RepertoireGroup
# and describes if/how the Rearrangements/Cells within the original Repertoire have been filtered 
RepertoireFilter:
    type: object
    properties:
        repertoire_id:
            type: string
            description: Identifier to the repertoire
            x-airr:
                nullable: false
                adc-query-support: true
        repertoire_description:
            type: string
            description: Description of this repertoire within the group
            x-airr:
                nullable: true
                adc-query-support: true
        time_point:
            $ref: '#/TimePoint'
            description: Time point designation for this repertoire within the group
            x-airr:
                nullable: true
                adc-query-support: true
        filter:
            type: object
            x-airr:
                nullable: true
            description: >
                A JSON object describing how this Repertoire was filtered
                using the same structure as an ADC API query

# A RepertoireGroup combines multiple Repertoires for analysis purposes
# without needing to duplicate the underlying (meta)data
RepertoireGroup:
    type: object
    required:
        - repertoire_group_id
        - repertoires
    properties:
        repertoire_group_id:
            type: string
            description: Identifier for this repertoire group
            x-airr:
                identifier: true
        repertoire_group_name:
            type: string
            description: Short display name for this repertoire group
        repertoire_group_description:
            type: string
            description: Repertoire group description
        repertoires:
            type: array
            description: >
                List of repertoires in this group with an associated description and time point designation
            items:
                $ref: '#/RepertoireFilter'


# The extended rearrangement object
Rearrangement:
    type: object
    required:
        - sequence_id
        - sequence
        - rev_comp
        - productive
        - v_call
        - d_call
        - j_call
        - sequence_alignment
        - germline_alignment
        - junction
        - junction_aa
        - v_cigar
        - d_cigar
        - j_cigar
    properties:
        sequence_id:
            type: string
            description: >
                Unique query sequence identifier for the Rearrangement. Most often this will be the input sequence
                header or a substring thereof, but may also be a custom identifier defined by the tool in
                cases where query sequences have been combined in some fashion prior to alignment. When
                downloaded from an AIRR Data Commons repository, this will usually be a universally unique
                record locator for linking with other objects in the AIRR Data Model.
            x-airr:
                adc-query-support: true
                identifier: true
        sequence:
            type: string
            description: >
                The query nucleotide sequence. Usually, this is the unmodified input sequence, which may be
                reverse complemented if necessary. In some cases, this field may contain consensus sequences or
                other types of collapsed input sequences if these steps are performed prior to alignment.
        quality:
            type: string
            description: >
                The Sanger/Phred quality scores for assessment of sequence quality.
                Phred quality scores from 0 to 93 are encoded using ASCII 33 to 126 (Used by Illumina from v1.8.)
        sequence_aa:
            type: string
            description: >
                Amino acid translation of the query nucleotide sequence.
        rev_comp:
            type: boolean
            description: >
                True if the alignment is on the opposite strand (reverse complemented) with respect to the
                query sequence. If True then all output data, such as alignment coordinates and sequences,
                are based on the reverse complement of 'sequence'.
        productive:
            type: boolean
            description: >
                True if the V(D)J sequence is predicted to be productive.
            x-airr:
                adc-query-support: true
        vj_in_frame:
            type: boolean
            description: True if the V and J gene alignments are in-frame.
        stop_codon:
            type: boolean
            description: True if the aligned sequence contains a stop codon.
        complete_vdj:
            type: boolean
            description: >
                True if the sequence alignment spans the entire V(D)J region. Meaning,
                sequence_alignment includes both the first V gene codon that encodes the
                mature polypeptide chain (i.e., after the leader sequence) and the last
                complete codon of the J gene (i.e., before the J-C splice site).
                This does not require an absence of deletions within the internal
                FWR and CDR regions of the alignment.
        locus:
            type: string
            enum:
                - IGH
                - IGI
                - IGK
                - IGL
                - TRA
                - TRB
                - TRD
                - TRG
                - null
            description: >
                Gene locus (chain type). Note that this field uses a controlled vocabulary that is meant to provide a
                generic classification of the locus, not necessarily the correct designation according to a specific
                nomenclature.
            title: Gene locus
            example: IGH
            x-airr:
                nullable: true
                adc-query-support: true
                name: Gene locus
                format: controlled_vocabulary
        locus_species:
            $ref: '#/Ontology'
            description: >
                Binomial designation of the species from which the locus originates. Typically, this value should be
                identical to `organism`, if which case it SHOULD NOT be set explicitly. However, there are valid
                experimental setups in which the two might differ, e.g. transgenic animal models. If set, this key
                will overwrite the `organism` information for all lower layers of the schema.
            title: Locus species
            example:
                id: NCBITAXON:9606
                label: Homo sapiens
            x-airr:
                nullable: true
                adc-query-support: true
                name: Locus species
                format: ontology
                ontology:
                    draft: false
                    top_node:
                        id: NCBITAXON:7776
                        label: Gnathostomata
        v_call:
            type: string
            description: >
                V gene with allele. If referring to a known reference sequence in a database
                the relevant gene/allele nomenclature should be followed (e.g., IGHV4-59*01 if using IMGT/GENE-DB).
            title: V gene with allele
            example: IGHV4-59*01
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 6
                subset: data (processed sequence)
                name: V gene with allele
        d_call:
            type: string
            description: >
                First or only D gene with allele. If referring to a known reference sequence in a database
                the relevant gene/allele nomenclature should be followed (e.g., IGHD3-10*01 if using IMGT/GENE-DB).
            title: D gene with allele
            example: IGHD3-10*01
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 6
                subset: data (processed sequence)
                name: D gene with allele
        d2_call:
            type: string
            description: >
                Second D gene with allele. If referring to a known reference sequence in a database the relevant
                gene/allele nomenclature should be followed (e.g., IGHD3-10*01 if using IMGT/GENE-DB).
            example: IGHD3-10*01
        j_call:
            type: string
            description: >
                J gene with allele. If referring to a known reference sequence in a database the relevant
                gene/allele nomenclature should be followed (e.g., IGHJ4*02 if using IMGT/GENE-DB).
            title: J gene with allele
            example: IGHJ4*02
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 6
                subset: data (processed sequence)
                name: J gene with allele
        c_call:
            type: string
            description: >
                Constant region gene with allele. If referring to a known reference sequence in a database the
                relevant gene/allele nomenclature should be followed (e.g., IGHG1*01 if using IMGT/GENE-DB).
            title: C region
            example: IGHG1*01
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 6
                subset: data (processed sequence)
                name: C region
        sequence_alignment:
            type: string
            description: >
                Aligned portion of query sequence, including any indel corrections or numbering spacers,
                such as IMGT-gaps. Typically, this will include only the V(D)J region, but that is not
                a requirement.
        quality_alignment:
            type: string
            description: >
                Sanger/Phred quality scores for assessment of sequence_alignment quality.
                Phred quality scores from 0 to 93 are encoded using ASCII 33 to 126 (Used by Illumina from v1.8.)
        sequence_alignment_aa:
            type: string
            description: >
                Amino acid translation of the aligned query sequence.
        germline_alignment:
            type: string
            description: >
                Assembled, aligned, full-length inferred germline sequence spanning the same region
                as the sequence_alignment field (typically the V(D)J region) and including the same set
                of corrections and spacers (if any).
        germline_alignment_aa:
            type: string
            description: >
                Amino acid translation of the assembled germline sequence.
        junction:
            type: string
            description: >
                Junction region nucleotide sequence, where the junction is defined as
                the CDR3 plus the two flanking conserved codons.
            title: IMGT-JUNCTION nucleotide sequence
            example: TGTGCAAGAGCGGGAGTTTACGACGGATATACTATGGACTACTGG
            x-airr:
                miairr: important
                nullable: true
                set: 6
                subset: data (processed sequence)
                name: IMGT-JUNCTION nucleotide sequence
        junction_aa:
            type: string
            description: >
                Amino acid translation of the junction.
            title: IMGT-JUNCTION amino acid sequence
            example: CARAGVYDGYTMDYW
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                set: 6
                subset: data (processed sequence)
                name: IMGT-JUNCTION amino acid sequence
        np1:
            type: string
            description: >
                Nucleotide sequence of the combined N/P region between the V gene and
                first D gene alignment or between the V gene and J gene alignments.
        np1_aa:
            type: string
            description: >
                Amino acid translation of the np1 field.
        np2:
            type: string
            description: >
                Nucleotide sequence of the combined N/P region between either the first D gene and J gene
                alignments or the first D gene and second D gene alignments.
        np2_aa:
            type: string
            description: >
                Amino acid translation of the np2 field.
        np3:
            type: string
            description: >
                Nucleotide sequence of the combined N/P region between the second D gene
                and J gene alignments.
        np3_aa:
            type: string
            description: >
                Amino acid translation of the np3 field.
        cdr1:
            type: string
            description: >
                Nucleotide sequence of the aligned CDR1 region.
        cdr1_aa:
            type: string
            description: >
                Amino acid translation of the cdr1 field.
        cdr2:
            type: string
            description: >
                Nucleotide sequence of the aligned CDR2 region.
        cdr2_aa:
            type: string
            description: >
                Amino acid translation of the cdr2 field.
        cdr3:
            type: string
            description: >
                Nucleotide sequence of the aligned CDR3 region.
        cdr3_aa:
            type: string
            description: >
                Amino acid translation of the cdr3 field.
        fwr1:
            type: string
            description: >
                Nucleotide sequence of the aligned FWR1 region.
        fwr1_aa:
            type: string
            description: >
                Amino acid translation of the fwr1 field.
        fwr2:
            type: string
            description: >
                Nucleotide sequence of the aligned FWR2 region.
        fwr2_aa:
            type: string
            description: >
                Amino acid translation of the fwr2 field.
        fwr3:
            type: string
            description: >
                Nucleotide sequence of the aligned FWR3 region.
        fwr3_aa:
            type: string
            description: >
                Amino acid translation of the fwr3 field.
        fwr4:
            type: string
            description: >
                Nucleotide sequence of the aligned FWR4 region.
        fwr4_aa:
            type: string
            description: >
                Amino acid translation of the fwr4 field.
        v_score:
            type: number
            description: Alignment score for the V gene.
        v_identity:
            type: number
            description: Fractional identity for the V gene alignment.
        v_support:
            type: number
            description: >
                V gene alignment E-value, p-value, likelihood, probability or other similar measure of
                support for the V gene assignment as defined by the alignment tool.
        v_cigar:
            type: string
            description: CIGAR string for the V gene alignment.
        d_score:
            type: number
            description: Alignment score for the first or only D gene alignment.
        d_identity:
            type: number
            description: Fractional identity for the first or only D gene alignment.
        d_support:
            type: number
            description: >
                D gene alignment E-value, p-value, likelihood, probability or other similar measure of
                support for the first or only D gene as defined by the alignment tool.
        d_cigar:
            type: string
            description: CIGAR string for the first or only D gene alignment.
        d2_score:
            type: number
            description: Alignment score for the second D gene alignment.
        d2_identity:
            type: number
            description: Fractional identity for the second D gene alignment.
        d2_support:
            type: number
            description: >
                D gene alignment E-value, p-value, likelihood, probability or other similar measure of
                support for the second D gene as defined by the alignment tool.
        d2_cigar:
            type: string
            description: CIGAR string for the second D gene alignment.
        j_score:
            type: number
            description: Alignment score for the J gene alignment.
        j_identity:
            type: number
            description: Fractional identity for the J gene alignment.
        j_support:
            type: number
            description: >
                J gene alignment E-value, p-value, likelihood, probability or other similar measure of
                support for the J gene assignment as defined by the alignment tool.
        j_cigar:
            type: string
            description: CIGAR string for the J gene alignment.
        c_score:
            type: number
            description: Alignment score for the C gene alignment.
        c_identity:
            type: number
            description: Fractional identity for the C gene alignment.
        c_support:
            type: number
            description: >
                C gene alignment E-value, p-value, likelihood, probability or other similar measure of
                support for the C gene assignment as defined by the alignment tool.
        c_cigar:
            type: string
            description: CIGAR string for the C gene alignment.
        v_sequence_start:
            type: integer
            description: >
                Start position of the V gene in the query sequence (1-based closed interval).
        v_sequence_end:
            type: integer
            description: >
                End position of the V gene in the query sequence (1-based closed interval).
        v_germline_start:
            type: integer
            description: >
                Alignment start position in the V gene reference sequence (1-based closed interval).
        v_germline_end:
            type: integer
            description: >
                Alignment end position in the V gene reference sequence (1-based closed interval).
        v_alignment_start:
            type: integer
            description: >
                Start position of the V gene alignment in both the sequence_alignment and germline_alignment
                fields (1-based closed interval).
        v_alignment_end:
            type: integer
            description: >
                End position of the V gene alignment in both the sequence_alignment and germline_alignment
                fields (1-based closed interval).
        d_sequence_start:
            type: integer
            description: >
                Start position of the first or only D gene in the query sequence.
                (1-based closed interval).
        d_sequence_end:
            type: integer
            description: >
                End position of the first or only D gene in the query sequence.
                (1-based closed interval).
        d_germline_start:
            type: integer
            description: >
                Alignment start position in the D gene reference sequence for the first or only
                D gene (1-based closed interval).
        d_germline_end:
            type: integer
            description: >
                Alignment end position in the D gene reference sequence for the first or only
                D gene (1-based closed interval).
        d_alignment_start:
            type: integer
            description: >
                Start position of the first or only D gene in both the sequence_alignment
                and germline_alignment fields (1-based closed interval).
        d_alignment_end:
            type: integer
            description: >
                End position of the first or only D gene in both the sequence_alignment
                and germline_alignment fields (1-based closed interval).
        d2_sequence_start:
            type: integer
            description: >
                Start position of the second D gene in the query sequence (1-based closed interval).
        d2_sequence_end:
            type: integer
            description: >
                End position of the second D gene in the query sequence (1-based closed interval).
        d2_germline_start:
            type: integer
            description: >
                Alignment start position in the second D gene reference sequence (1-based closed interval).
        d2_germline_end:
            type: integer
            description: >
                Alignment end position in the second D gene reference sequence (1-based closed interval).
        d2_alignment_start:
            type: integer
            description: >
                Start position of the second D gene alignment in both the sequence_alignment and
                germline_alignment fields (1-based closed interval).
        d2_alignment_end:
            type: integer
            description: >
                End position of the second D gene alignment in both the sequence_alignment and
                germline_alignment fields (1-based closed interval).
        j_sequence_start:
            type: integer
            description: >
                Start position of the J gene in the query sequence (1-based closed interval).
        j_sequence_end:
            type: integer
            description: >
                End position of the J gene in the query sequence (1-based closed interval).
        j_germline_start:
            type: integer
            description: >
                Alignment start position in the J gene reference sequence (1-based closed interval).
        j_germline_end:
            type: integer
            description: >
                Alignment end position in the J gene reference sequence (1-based closed interval).
        j_alignment_start:
            type: integer
            description: >
                Start position of the J gene alignment in both the sequence_alignment and germline_alignment
                fields (1-based closed interval).
        j_alignment_end:
            type: integer
            description: >
                End position of the J gene alignment in both the sequence_alignment and germline_alignment
                fields (1-based closed interval).
        c_sequence_start:
            type: integer
            description: >
                Start position of the C gene in the query sequence (1-based closed interval).
        c_sequence_end:
            type: integer
            description: >
                End position of the C gene in the query sequence (1-based closed interval).
        c_germline_start:
            type: integer
            description: >
                Alignment start position in the C gene reference sequence (1-based closed interval).
        c_germline_end:
            type: integer
            description: >
                Alignment end position in the C gene reference sequence (1-based closed interval).
        c_alignment_start:
            type: integer
            description: >
                Start position of the C gene alignment in both the sequence_alignment and germline_alignment
                fields (1-based closed interval).
        c_alignment_end:
            type: integer
            description: >
                End position of the C gene alignment in both the sequence_alignment and germline_alignment
                fields (1-based closed interval).
        cdr1_start:
            type: integer
            description: CDR1 start position in the query sequence (1-based closed interval).
        cdr1_end:
            type: integer
            description: CDR1 end position in the query sequence (1-based closed interval).
        cdr2_start:
            type: integer
            description: CDR2 start position in the query sequence (1-based closed interval).
        cdr2_end:
            type: integer
            description: CDR2 end position in the query sequence (1-based closed interval).
        cdr3_start:
            type: integer
            description: CDR3 start position in the query sequence (1-based closed interval).
        cdr3_end:
            type: integer
            description: CDR3 end position in the query sequence (1-based closed interval).
        fwr1_start:
            type: integer
            description: FWR1 start position in the query sequence (1-based closed interval).
        fwr1_end:
            type: integer
            description: FWR1 end position in the query sequence (1-based closed interval).
        fwr2_start:
            type: integer
            description: FWR2 start position in the query sequence (1-based closed interval).
        fwr2_end:
            type: integer
            description: FWR2 end position in the query sequence (1-based closed interval).
        fwr3_start:
            type: integer
            description: FWR3 start position in the query sequence (1-based closed interval).
        fwr3_end:
            type: integer
            description: FWR3 end position in the query sequence (1-based closed interval).
        fwr4_start:
            type: integer
            description: FWR4 start position in the query sequence (1-based closed interval).
        fwr4_end:
            type: integer
            description: FWR4 end position in the query sequence (1-based closed interval).
        v_sequence_alignment:
            type: string
            description: >
                Aligned portion of query sequence assigned to the V gene, including any
                indel corrections or numbering spacers.
        v_sequence_alignment_aa:
            type: string
            description: >
                Amino acid translation of the v_sequence_alignment field.
        d_sequence_alignment:
            type: string
            description: >
                Aligned portion of query sequence assigned to the first or only D gene, including any
                indel corrections or numbering spacers.
        d_sequence_alignment_aa:
            type: string
            description: >
                Amino acid translation of the d_sequence_alignment field.
        d2_sequence_alignment:
            type: string
            description: >
                Aligned portion of query sequence assigned to the second D gene, including any
                indel corrections or numbering spacers.
        d2_sequence_alignment_aa:
            type: string
            description: >
                Amino acid translation of the d2_sequence_alignment field.
        j_sequence_alignment:
            type: string
            description: >
                Aligned portion of query sequence assigned to the J gene, including any
                indel corrections or numbering spacers.
        j_sequence_alignment_aa:
            type: string
            description: >
                Amino acid translation of the j_sequence_alignment field.
        c_sequence_alignment:
            type: string
            description: >
                Aligned portion of query sequence assigned to the constant region, including
                any indel corrections or numbering spacers.
        c_sequence_alignment_aa:
            type: string
            description: >
                Amino acid translation of the c_sequence_alignment field.
        v_germline_alignment:
            type: string
            description: >
                Aligned V gene germline sequence spanning the same region
                as the v_sequence_alignment field and including the same set
                of corrections and spacers (if any).
        v_germline_alignment_aa:
            type: string
            description: >
                Amino acid translation of the v_germline_alignment field.
        d_germline_alignment:
            type: string
            description: >
                Aligned D gene germline sequence spanning the same region
                as the d_sequence_alignment field and including the same set
                of corrections and spacers (if any).
        d_germline_alignment_aa:
            type: string
            description: >
                Amino acid translation of the d_germline_alignment field.
        d2_germline_alignment:
            type: string
            description: >
                Aligned D gene germline sequence spanning the same region
                as the d2_sequence_alignment field and including the same set
                of corrections and spacers (if any).
        d2_germline_alignment_aa:
            type: string
            description: >
                Amino acid translation of the d2_germline_alignment field.
        j_germline_alignment:
            type: string
            description: >
                Aligned J gene germline sequence spanning the same region
                as the j_sequence_alignment field and including the same set
                of corrections and spacers (if any).
        j_germline_alignment_aa:
            type: string
            description: >
                Amino acid translation of the j_germline_alignment field.
        c_germline_alignment:
            type: string
            description: >
                Aligned constant region germline sequence spanning the same region
                as the c_sequence_alignment field and including the same set
                of corrections and spacers (if any).
        c_germline_alignment_aa:
            type: string
            description: >
                Amino acid translation of the c_germline_aligment field.
        junction_length:
            type: integer
            description: Number of nucleotides in the junction sequence.
        junction_aa_length:
            type: integer
            description: Number of amino acids in the junction sequence.
            x-airr:
                adc-query-support: true
        np1_length:
            type: integer
            description: >
                Number of nucleotides between the V gene and first D gene alignments or
                between the V gene and J gene alignments.
        np2_length:
            type: integer
            description: >
                Number of nucleotides between either the first D gene and J gene alignments
                or the first D gene and second D gene alignments.
        np3_length:
            type: integer
            description: >
                Number of nucleotides between the second D gene and J gene alignments.
        n1_length:
            type: integer
            description: Number of untemplated nucleotides 5' of the first or only D gene alignment.
        n2_length:
            type: integer
            description: Number of untemplated nucleotides 3' of the first or only D gene alignment.
        n3_length:
            type: integer
            description: Number of untemplated nucleotides 3' of the second D gene alignment.
        p3v_length:
            type: integer
            description: Number of palindromic nucleotides 3' of the V gene alignment.
        p5d_length:
            type: integer
            description: Number of palindromic nucleotides 5' of the first or only D gene alignment.
        p3d_length:
            type: integer
            description: Number of palindromic nucleotides 3' of the first or only D gene alignment.
        p5d2_length:
            type: integer
            description: Number of palindromic nucleotides 5' of the second D gene alignment.
        p3d2_length:
            type: integer
            description: Number of palindromic nucleotides 3' of the second D gene alignment.
        p5j_length:
            type: integer
            description: Number of palindromic nucleotides 5' of the J gene alignment.
        v_frameshift:
            type: boolean
            description: >
                True if the V gene in the query nucleotide sequence contains a translational
                frameshift relative to the frame of the V gene reference sequence.
        j_frameshift:
            type: boolean
            description: >
                True if the J gene in the query nucleotide sequence contains a translational
                frameshift relative to the frame of the J gene reference sequence.
        d_frame:
            type: integer
            description: >
                Numerical reading frame (1, 2, 3) of the first or only D gene in the query nucleotide sequence,
                where frame 1 is relative to the first codon of D gene reference sequence.
        d2_frame:
            type: integer
            description: >
                Numerical reading frame (1, 2, 3) of the second D gene in the query nucleotide sequence,
                where frame 1 is relative to the first codon of D gene reference sequence.
        consensus_count:
            type: integer
            description: >
                Number of reads contributing to the UMI consensus or contig assembly for this sequence.
                For example, the sum of the number of reads for all UMIs that contribute to
                the query sequence.
        duplicate_count:
            type: integer
            description: >
                Copy number or number of duplicate observations for the query sequence.
                For example, the number of identical reads observed for this sequence.
            title: Read count
            example: 123
            x-airr:
                miairr: important
                nullable: true
                set: 6
                subset: data (processed sequence)
                name: Read count
        umi_count:
            type: integer
            description: >
                Number of distinct UMIs represented by this sequence.
                For example, the total number of UMIs that contribute to
                the contig assembly for the query sequence.
        cell_id:
            type: string
            description: >
                Identifier defining the cell of origin for the query sequence.
            title: Cell index
            example: W06_046_091
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                identifier: true
                set: 6
                subset: data (processed sequence)
                name: Cell index
        clone_id:
            type: string
            description: Clonal cluster assignment for the query sequence.
            x-airr:
                nullable: true
                adc-query-support: true
                identifier: true
        repertoire_id:
            type: string
            description: Identifier to the associated repertoire in study metadata.
            x-airr:
                nullable: true
                adc-query-support: true
                identifier: true
        reactivity_id:
            type: string
            description: >
                Comma separated list of unique identifiers for Reactivity objects associated with this Rearrangement.
                Order and length of reactivity_id and reactivity_ref are independent.
            x-airr:
                nullable: true
                identifier: true
        reactivity_ref:
            type: string
            description: >
                Comma separated list of CURIE identifiers of external reactivity records (e.g. IEDB_EPITOPE:1616345, https://https://www.iedb.org/epitope/1616345) 
                associated with this Rearrangement. Order and length of reactivity_id and reactivity_ref are independent.
            example: "IEDB_EPITOPE:1616345, IEDB_EPITOPE:100725"
            x-airr:
                nullable: true
        sample_processing_id:
            type: string
            description: >
                Identifier to the sample processing object in the repertoire metadata
                for this rearrangement. If the repertoire has a single sample then
                this field may be empty or missing. If the repertoire has multiple samples then
                this field may be empty or missing if the sample cannot be differentiated or
                the relationship is not maintained by the data processing.
            x-airr:
                nullable: true
                adc-query-support: true
                identifier: true
        data_processing_id:
            type: string
            description: >
                Identifier to the data processing object in the repertoire metadata
                for this rearrangement. If this field is empty than the primary data processing object is assumed.
            x-airr:
                nullable: true
                adc-query-support: true
                identifier: true
        rearrangement_type:
            type: string
            enum:
                - observed
                - simulated
                - inferred
                - null
            description: >
                Rearrangement type (source). Most often the type should be "observed," meaning it corresponds to
                an actual physical sample that was sequenced. Other allowed values are "simulated," i.e. the
                Rearrangements were generated in silico and there is no linked Subject/Sample metadata, and
                "inferred" for Rearrangements that are phylogenetically reconstructed from observed sequences.
                Inferred Rearrangements should be assigned to a Repertoire with repertoire_type=inferred.
            x-airr:
                nullable: true
                name: Rearrangement type
                format: controlled_vocabulary
                adc-query-support: true
        rearrangement_id:
            type: string
            description: >
                Identifier for the Rearrangement object. May be identical to sequence_id,
                but will usually be a universally unique record locator for database applications.
            x-airr:
                deprecated: true
                deprecated-description: Field has been merged with sequence_id to avoid confusion.
                deprecated-replaced-by:
                    - sequence_id
        rearrangement_set_id:
            type: string
            description: >
                Identifier for grouping Rearrangement objects.
            x-airr:
                deprecated: true
                deprecated-description: Field has been replaced by other specialized identifiers.
                deprecated-replaced-by:
                    - repertoire_id
                    - sample_processing_id
                    - data_processing_id
        germline_database:
            type: string
            description: Source of germline V(D)J genes with version number or date accessed.
            example: ENSEMBL, Homo sapiens build 90, 2017-10-01
            x-airr:
                deprecated: true
                deprecated-description: Field was moved up to the DataProcessing level to avoid data duplication.
                deprecated-replaced-by:
                    - "DataProcessing:germline_database"

# A unique inferred clone object that has been constructed within a single data processing
# for a single RepertoireGroup and a subset of its rearrangements and/or cells.
Clone:
    type: object
    required:
        - clone_id
        - repertoire_group_id
        - repertoire_id
        - nodes
    properties:
        clone_id:
            type: string
            description: Identifier for the clone.
            x-airr:
                nullable: false
                identifier: true
        repertoire_group_id:
            type: string
            description: >
                Identifier of the RepertoireGroup that this Clone is derived from.
                If the Clone is derived from a single Repertoire, repertoire_id
                may be used instead.
            x-airr:
                nullable: true
                adc-query-support: true
        repertoire_id:
            type: string
            description: >
                Identifier of the Repertoire that this Clone is derived from. Should
                only be used if Clones are calculated from a single Repertoire without
                defining a RepertoireGroup. Otherwise use repertoire_group_id instead.
            x-airr:
                nullable: true
                adc-query-support: true
        clone_class:
            type: string
            enum:
                - Rearrangement
                - Cell
                - mixed
                - null
            description: Is this a single-chain clone or a cell-based clone?
            x-airr:
                nullable: true
        data_processing_id:
            type: string
            description: Identifier of the data processing object in the repertoire metadata for this clone.
            x-airr:
                nullable: true
                adc-query-support: true
        nodes:
            type: array
            items:
                $ref: '#/Node'
            description: List of Nodes that are members of this clone. 
            x-airr:
                nullable: true
        inferred_ancestor:
            type: string
            description: >
                Node_id string that acts as a key to the Node record for the 
                inferred naive Rearrangement or Cell for this clone.
            x-airr:
                nullable: true
        clone_count:
            type: integer
            description: >
                Absolute count of the size (number of members) of this clone in the repertoire.
                This could simply be the number of sequences (Rearrangement records) observed in this clone,
                the number of distinct cell barcodes (unique cell_id values),
                or a more sophisticated calculation appropriate to the experimental protocol.
                Absolute count is provided versus a frequency so that downstream analysis tools can perform their own normalization.
            x-airr:
                nullable: true
        seed_id:
            type: string
            description: sequence_id or cell_id of the seed sequence/cell. Empty string (or null) if there is no seed sequence.
            x-airr:
                nullable: true
        tree:
            type: string
            description: Newick string describing the tree.
            x-airr:
                nullable: true

# A node acts as reference object to link members of a clone to their original repertoires.
Node:
    type: object
    required:
        - node_id
        - repertoire_id
    properties:
        node_id:
            type: string
            description: Identifier for the node.
            x-airr:
                nullable: false
                identifier: true
        repertoire_id:
            type: string
            description: Identifier of the repertoire that cell or rearrangement contained by this node.
            x-airr:
                nullable: true
                adc-query-support: true
        cell_id:
            type: string
            description: >
                Identifier of the cell contained by this node.
                NOTE: Mutually exclusive with Node.sequence_id
            x-airr:
                nullable: true
                adc-query-support: true
        sequence_id:
            type: string
            description: >
                Identifier of the rearrangement contained by this node.
                NOTE: Mutually exclusive with Node.cell_id
            x-airr:
                nullable: true
                adc-query-support: true
        node_type:
            type: string
            enum:
                - observed
                - inferred
                - simulated
                - null
            description: >
                Node type (source). "Observed" for rearrangements/cells that were observed in the source data,
                "inferred" for unobserved intermediates that were phylogenetically inferred, or "simulated" for
                simulated rearrangements/cells.
            x-airr:
                nullable: true
                format: controlled_vocabulary
        node_class:
            type: string
            enum:
                - Rearrangement
                - Cell
                - null
            description: Does this node contain a rearrangement of a cell?
            x-airr:
                nullable: true
                format: controlled_vocabulary

# The cell object acts as point of reference for all data that can be related
# to an individual cell, either by direct observation or inference.
Cell:
    type: object
    required:
        - cell_id
        - repertoire_id
        - virtual_pairing
    properties:
        cell_id:
            type: string
            description: >
                Identifier for the Cell object. This identifier must be unique within 
                a given study, but it is recommended that it be a universally unique record locator
                to enable database applications.
            title: Cell index
            x-airr:
                identifier: true
                miairr: defined
                nullable: false
                adc-query-support: true
                name: Cell index
        repertoire_id:
            type: string
            description: Identifier to the associated repertoire in study metadata.
            title: Parental repertoire of cell
            x-airr:
                miairr: defined
                nullable: true
                adc-query-support: true
                name: Parental repertoire of cell
        data_processing_id:
            type: string
            description: Identifier of the data processing object in the repertoire metadata for this cell.
            title: Data processing for cell
            x-airr:
                miairr: defined
                nullable: true
                adc-query-support: true
                name: Data processing for cell
        receptors:
            type: array
            description: >
                Array of receptor identifiers defined for the Receptor objects associated with this cell
            title: Cell-associated receptors
            items:
                type: string
            example: [id1, id2]
            x-airr:
                miairr: defined
                nullable: true
                adc-query-support: true
                name: Cell-associated receptors
        cell_subset:
            $ref: '#/Ontology'
            description: Commonly-used designation of isolated cell population.
            title: Cell subset
            example:
                id: CL:0000972
                label: class switched memory B cell
            x-airr:
                miairr: important
                nullable: true
                adc-query-support: true
                name: Cell subset
                format: ontology
                ontology:
                    draft: false
                    top_node:
                        id: CL:0000542
                        label: lymphocyte
        cell_phenotype:
            type: string
            description: >
                List of cellular markers and their expression levels used to isolate the cell population.
            title: Cell subset phenotype
            example: CD19+ CD38+ CD27+ IgM- IgD-
            x-airr:
                miairr: defined
                nullable: true
                adc-query-support: true
                name: Cell subset phenotype
        cell_label:
            type: string
            description: >
                Free text cell type annotation. Primarily used for annotating cell types that are not 
                provided in the Cell Ontology.
            title: Cell annotation
            example: age-associated B cell
            x-airr:
                miairr: defined
                nullable: true
                adc-query-support: true
                name: Cell annotation
        virtual_pairing:
            type: boolean
            description: >
                boolean to indicate if pairing was inferred.
            title: Virtual pairing
            x-airr:
                miairr: defined
                nullable: true
                adc-query-support: true
                name: Virtual pairing
        cell_type:
            type: string
            enum:
                - observed
                - simulated
                - inferred
                - null
            description: >
                Cell type (source). Most often the type should be "observed," meaning it corresponds to
                an actual physical sample that was sequenced. Other allowed values are "simulated," i.e. the
                Cells were generated in silico and there is no linked Subject/Sample metadata, and
                "inferred" for Cells that are phylogenetically reconstructed from observed sequences.
                Inferred Cells should be assigned to a Repertoire with repertoire_type=inferred.
            x-airr:
                nullable: true
                format: controlled_vocabulary
                adc-query-support: true

# The Expression object acts as a container to hold a single expression level measurement from
# an experiment. Expression data is associated with a cell_id and the related repertoire_id and
# data_processing_id
Expression:
    type: object
    required:
        - expression_id
        - repertoire_id
        - data_processing_id
        - cell_id
        - property
        - property_type
        - value
    properties:
        expression_id:
            type: string
            description: >
                Identifier for the Expression object. This identifier must be unique within 
                a given study, but it is recommended that it be a universally unique record locator
                to enable database applications.
            title: Expression property measurement identifier
            x-airr:
                identifier: true
                miairr: defined
                nullable: false
                adc-query-support: true
                name: Expression measurement identifier
        cell_id:
            type: string
            description: >
                Identifier of the cell to which this expression data is related.
            title: Cell identifier
            example: W06_046_091
            x-airr:
                miairr: defined
                nullable: false
                adc-query-support: true
                name: Cell identifier
        repertoire_id:
            type: string
            description: Identifier for the associated repertoire in study metadata.
            title: Parental repertoire of cell
            x-airr:
                miairr: defined
                nullable: true
                adc-query-support: true
                name: Parental repertoire of cell
        data_processing_id:
            type: string
            description: Identifier of the data processing object in the repertoire metadata for this cell.
            title: Data processing for cell
            x-airr:
                miairr: defined
                nullable: true
                adc-query-support: true
                name: Data processing for cell
        property_type:
            type: string
            description: >
                Keyword describing the property type and detection method used to measure the property value.
                The following keywords are recommended, but custom property types are also valid:
                "mrna_expression_by_read_count",
                "protein_expression_by_fluorescence_intensity", "antigen_bait_binding_by_fluorescence_intensity",
                "protein_expression_by_dna_barcode_count" and "antigen_bait_binding_by_dna_barcode_count".
            title: Property type and detection method
            x-airr:
                miairr: defined
                nullable: false
                adc-query-support: true
                name: Property type and detection method
        property:
            type: string
            title: Property information
            description: >
                Name of the property observed, typically a gene or antibody identifier (and label) from a 
                canonical resource such as Ensembl (e.g. ENSG00000275747, IGHV3-79) or 
                Antibody Registry (ABREG:1236456, Purified anti-mouse/rat/human CD27 antibody).
            example:
                id: ENSG:ENSG00000275747
                label: IGHV3-79
            x-airr:
                miairr: defined
                adc-query-support: true
                format: CURIE
                name: Property information
        value:
            type: number
            description: Level at which the property was observed in the experiment (non-normalized).
            title: Property value
            example: 3
            x-airr:
                miairr: defined
                nullable: true
                adc-query-support: true
                name: Property value


# The Receptor object holds information about a receptor (immunoglobulin or TCR)
#
Receptor:
    type: object
    required:
        - receptor_id
        - receptor_hash
        - receptor_type
        - receptor_variable_domain_1_aa
        - receptor_variable_domain_1_locus
        - receptor_variable_domain_2_aa
        - receptor_variable_domain_2_locus
    properties:
        receptor_id:
            type: string
            description: >
                Identifier for the Receptor object. This identifier must be unique within 
                a given study, but it is recommended that it be a universally unique record locator
                to enable database applications.
            title: Receptor ID
            example: TCR-MM-012345
            x-airr:
                identifier: true
                nullable: false
                adc-query-support: true
        receptor_hash:
            type: string
            description: >
                The SHA256 hash of the receptor amino acid sequence, calculated on the concatenated
                ``receptor_variable_domain_*_aa`` sequences and represented as base16-encoded string.
            title: Receptor hash ID
            example: aa1c4b77a6f4927611ab39f5267415beaa0ba07a952c233d803b07e52261f026
            x-airr:
                nullable: false
                adc-query-support: true
        receptor_type:
            type: string
            enum:
                - Ig
                - TCR
            description: The top-level receptor type, either Immunoglobulin (Ig) or T Cell Receptor (TCR).
            x-airr:
                format: controlled_vocabulary
                nullable: false
                adc-query-support: true
        receptor_variable_domain_1_aa:
            type: string
            description: >
                Complete amino acid sequence of the mature variable domain of the Ig heavy, TCR beta or TCR delta chain.
                The mature variable domain is defined as encompassing all AA from and including first AA after the the
                signal peptide to and including the last AA that is completely encoded by the J gene.
            example: >
                QVQLQQPGAELVKPGASVKLSCKASGYTFTSYWMHWVKQRPGRGLEWIGRIDPNSGGTKYNEKFKSKATLTVDKPSSTAYMQLSSLTSEDSAVYYCARYDYYGSSYFDYWGQGTTLTVSS
            x-airr:
                nullable: false
                adc-query-support: true
        receptor_variable_domain_1_locus:
            type: string
            enum:
                - IGH
                - TRB
                - TRD
            description: Locus from which the variable domain in receptor_variable_domain_1_aa originates
            example: IGH
            x-airr:
                format: controlled_vocabulary
                nullable: false
                adc-query-support: true
        receptor_variable_domain_2_aa:
            type: string
            description: >
                Complete amino acid sequence of the mature variable domain of the Ig light, TCR alpha or TCR gamma chain.
                The mature variable domain is defined as encompassing all AA from and including first AA after the the
                signal peptide to and including the last AA that is completely encoded by the J gene.
            example: >
                QAVVTQESALTTSPGETVTLTCRSSTGAVTTSNYANWVQEKPDHLFTGLIGGTNNRAPGVPARFSGSLIGDKAALTITGAQTEDEAIYFCALWYSNHWVFGGGTKLTVL
            x-airr:
                nullable: false
                adc-query-support: true
        receptor_variable_domain_2_locus:
            type: string
            enum:
                - IGI
                - IGK
                - IGL
                - TRA
                - TRG
            description: Locus from which the variable domain in receptor_variable_domain_2_aa originates
            example: IGL
            x-airr:
                format: controlled_vocabulary
                nullable: false
                adc-query-support: true
        receptor_ref:
            type: array
            description: Array of receptor identifiers defined for the Receptor object
            title: Receptor cross-references
            items:
                type: string
            example: ["IEDB_RECEPTOR:10"]
            x-airr:
                nullable: true
                adc-query-support: true

# The Reactivity object holds information about the reactivity exhibited by a given Cell
#
Reactivity:
    type: object
    required:
        - reactivity_id
        - cell_id
        - ligand_type
        - antigen_type
        - antigen
        - reactivity_method
        - reactivity_readout
        - reactivity_value
        - reactivity_unit
    properties:
        reactivity_id:
            type: string
            description: >
                Identifier for the Reactivity object. This identifier must be unique within 
                a given study, but it is recommended that it be a universally unique record locator
                to enable database applications.
            title: Reactivity ID
            x-airr:
                identifier: true
                nullable: false
                adc-query-support: true
        cell_id:
            type: string
            description: >
                Identifier of the Cell in the context of which the reactivity measurement was conducted.
            title: Cell ID
            x-airr:
                nullable: true
                adc-query-support: true
        repertoire_id:
            type: string
            description: Identifier for the associated repertoire in study metadata.
            title: Parental repertoire of cell
            x-airr:
                miairr: defined
                nullable: true
                adc-query-support: true
                name: Parental repertoire of cell
        data_processing_id:
            type: string
            description: Identifier of the data processing object in the repertoire metadata for this cell.
            title: Data processing for cell
            x-airr:
                miairr: defined
                nullable: true
                adc-query-support: true
                name: Data processing for cell
        ligand_type:
            type: string
            enum:
                - "MHC:peptide"
                - "MHC:non-peptide"
                - protein
                - peptide
                - non-peptidic
            description: Classification of ligand binding to the cell
            example: "MHC:peptide"
            x-airr:
                format: controlled_vocabulary
                nullable: false
                adc-query-support: true
        antigen_type:
            type: string
            enum:
                - protein
                - peptide
                - non-peptidic
            description: >
                The type of antigen before processing by the immune system.
            example: protein
            x-airr:
                format: controlled_vocabulary
                nullable: false
                adc-query-support: true
        antigen:
            type: string
            description: >
                The substance against which the receptor was tested. This can be any substance that
                stimulates an adaptive immune response in the host, either through antibody production
                or by T cell activation after presentation via an MHC molecule.
            title: Antigen
            example:
                id: UNIPROT:P01308
                label: Insulin
            x-airr:
                nullable: false
                adc-query-support: true
                format: CURIE
        antigen_source_species:
            $ref: '#/Ontology'
            description: The species from which the antigen was isolated
            title: Source species of antigen
            example:
                id: NCBITAXON:9606
                label: Homo sapiens
            x-airr:
                nullable: true
                adc-query-support: true
                format: ontology
                ontology:
                    draft: true
                    top_node:
                        id: NCBITAXON:1
                        label: root
        peptide_start:
            type: integer
            description: Start position of the peptide within the reference protein sequence
            example: 87
            x-airr:
                nullable: true
        peptide_end:
            type: integer
            description: End position of the peptide within the reference protein sequence
            example: 101
            x-airr:
                nullable: true
        peptide_sequence_aa:
            type: string
            description: >
                The actual peptide sequence against which the receptor reactivity was measured. This field should be
                used as a convenience for antigens of antigen_type `protein` or `peptide`.
            example: QKRGIVEQCCTSICS
            x-airr:
                nullable: true
                adc-query-support: true
        mhc_class:
            type: string
            enum:
                - MHC-I
                - MHC-II
                - MHC-nonclassical
                - null
            description: Class of MHC molecule, only present for MHC:x ligand types
            example: MHC-II
            x-airr:
                format: controlled_vocabulary
                nullable: true
                adc-query-support: true
        mhc_gene_1:
            $ref: '#/Ontology'
            description: The MHC gene to which the mhc_allele_1 belongs
            title: MHC gene 1
            example:
                id: MRO:0000055
                label: HLA-DRA
            x-airr:
                nullable: true
                adc-query-support: true
                format: ontology
                ontology:
                    draft: true
                    top_node:
                        id: MRO:0000004
                        label: MHC gene
        mhc_allele_1:
            type: string
            description: Allele designation of the MHC alpha chain
            example: HLA-DRA*01:01
            x-airr:
                nullable: true
                adc-query-support: true
        mhc_gene_2:
            $ref: '#/Ontology'
            description: The MHC gene to which the mhc_allele_2 belongs
            title: MHC gene 2
            example:
                id: MRO:0000057
                label: HLA-DRB1
            x-airr:
                nullable: true
                adc-query-support: true
                format: ontology
                ontology:
                    draft: true
                    top_node:
                        id: MRO:0000004
                        label: MHC gene
        mhc_allele_2:
            type: string
            description: >
                Allele designation of the MHC class II beta chain or the invariant beta2-microglobin chain
            example: HLA-DRB1*04:01
            x-airr:
                nullable: true
                adc-query-support: true
        reactivity_method:
            type: string
            description: >
                The methodology used to assess/classify reactivity. This should be either the assay utlizied in the experiment,
                delineated as "annotated" if annotated from an external source (e.g. IEDB), or inferred if imputed using
                a computational method. In future versions we anticipate this field being an enumerated type, and it is strongly
                recommended that users utilize one of the following keywords in this field if appropriate:
                native_protein, MHC_peptide_multimer, annotated, inferred.
            x-airr:
                nullable: false
                adc-query-support: true
        reactivity_readout:
            type: string
            description: >
                Reactivity measurement read-out. For physical assays, this should describe what was measured. For inferred
                and annotated methods this should indicate a confidence/quality level for the inference/annotation. In future
                versions we anticipate this field being an enumerated type, and it is strongly recommended that users utilize
                one of the following keywords in this field if appropriate: fluorescence_intensity, barcode_count, confidence.
            example: barcode_count
            x-airr:
                nullable: false
                adc-query-support: true
        reactivity_value:
            type: number
            description: The absolute (processed) value of the measurement
            example: 162
            x-airr:
                nullable: false
                adc-query-support: true
        reactivity_unit:
            type: string
            description: The unit of the measurement
            example: read count
            x-airr:
                nullable: false
                adc-query-support: true
        reactivity_refs:
            type: array
            description: Array of cross references to external epitope reactivity records 
            title: Epitope reactivity cross-references
            items:
                type: string
            example: ["IEDB_EPITOPE:1616345"]
            x-airr:
                nullable: true
                adc-query-support: true
