<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright 2018 EMBL - European Bioinformatics Institute
  ~ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
  ~ file except in compliance with the License. You may obtain a copy of the License at
  ~ http://www.apache.org/licenses/LICENSE-2.0
  ~ Unless required by applicable law or agreed to in writing, software distributed under the
  ~ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  ~ CONDITIONS OF ANY KIND, either express or implied. See the License for the
  ~ specific language governing permissions and limitations under the License.
  -->

<!-- version:1.5.61 -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:com="SRA.common">
    <xs:import schemaLocation="SRA.common.xsd" namespace="SRA.common"/>

    <xs:complexType name="RunType">
        <xs:annotation>
            <xs:documentation>
                A run contains a group of reads generated for a particular experiment.
            </xs:documentation>
        </xs:annotation>
        <xs:complexContent>
            <xs:extension base="com:ObjectType">
                <xs:sequence>
                    <xs:element name="TITLE" type="xs:string" minOccurs="0" maxOccurs="1">
                        <xs:annotation>
                            <xs:documentation>
                        Short text that can be used to define submissions in searches or in displays.
                   </xs:documentation>
                        </xs:annotation>
                    </xs:element>
                    <xs:element name="EXPERIMENT_REF" nillable="false" maxOccurs="1" minOccurs="1">
                        <xs:annotation>
                            <xs:documentation>Identifies the parent experiment.
                   </xs:documentation>
                        </xs:annotation>
                        <xs:complexType>
                            <xs:complexContent>
                                <xs:extension base="com:RefObjectType">
                                </xs:extension>
                            </xs:complexContent>
                        </xs:complexType>
                    </xs:element>
                    <xs:element name="SPOT_DESCRIPTOR" type="com:SpotDescriptorType" maxOccurs="1"
                        minOccurs="0"/>

                    <xs:element name="PLATFORM" type="com:PlatformType" maxOccurs="1" minOccurs="0"/>

                    <xs:element name="PROCESSING" maxOccurs="1" minOccurs="0"
                        type="com:ProcessingType"/>

                    <xs:element maxOccurs="1" minOccurs="0" name="RUN_TYPE">
                        <xs:annotation>
                            <xs:documentation>The type of the run. </xs:documentation>
                        </xs:annotation>
                        <xs:complexType>
                            <xs:choice>
                                <xs:element name="REFERENCE_ALIGNMENT"
                                    type="com:ReferenceSequenceType"> </xs:element>
                            </xs:choice>
                        </xs:complexType>
                    </xs:element>

                    <xs:sequence>
                        <xs:element name="DATA_BLOCK" maxOccurs="1" minOccurs="0">
                            <xs:complexType>

                                <xs:sequence>
                                    <xs:element name="FILES">
                                        <xs:annotation>
                                            <xs:documentation> Data files associated with the run.</xs:documentation>
                                        </xs:annotation>
                                        <xs:complexType>
                                            <xs:sequence maxOccurs="1" minOccurs="1">
                                                <xs:element name="FILE" maxOccurs="unbounded">
                                                  <xs:complexType>
                                                  <xs:sequence>
                                                  <xs:element name="READ_LABEL" type="xs:string"
                                                  minOccurs="0" maxOccurs="unbounded">
                                                  <xs:annotation>
                                                  <xs:documentation>
                                                        The READ_LABEL can associate a certain file to a certain read_label defined in the SPOT_DESCRIPTOR.
                                                    </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:element>
                                                  </xs:sequence>
                                                  <xs:attribute name="filename" type="xs:string"
                                                  use="required">
                                                  <xs:annotation>
                                                  <xs:documentation>The name or relative pathname of a run data file.</xs:documentation>
                                                  </xs:annotation>
                                                  </xs:attribute>
                                                  <xs:attribute name="filetype" use="required">
                                                  <xs:annotation>
                                                  <xs:documentation> The run data file model.</xs:documentation>
                                                  </xs:annotation>
                                                  <xs:simpleType>
                                                  <xs:restriction base="xs:string">
                                                  <xs:enumeration value="sra">
                                                  <xs:annotation>
                                                  <xs:documentation>Sequence Read Archives native format in serialized (single file) form.</xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>
                                                  <xs:enumeration value="srf">
                                                  <xs:annotation>
                                                  <xs:documentation>Standard Short Read Format file (.srf), all platforms</xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>
                                                  <xs:enumeration value="sff">
                                                  <xs:annotation>
                                                  <xs:documentation>454 Standard Flowgram Format file (.sff)</xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>
                                                  <xs:enumeration value="fastq">
                                                  <xs:annotation>
                                                  <xs:documentation>
                                                              Combined nucleotide/qualities sequence file in .fastq form.
                                                              Please see SRA File Formats Guide for definitions of the definition and restrictions on this form.
                                                          </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>
                                                  <xs:enumeration value="fasta">
                                                  <xs:annotation>
                                                  <xs:documentation> 
                                                                Please see SRA File Formats Guide for definitions of these file formats, 
                                                                and the SRA Submission Guidelines document for data series that are appropriate for your study.
                                                                Sequence and qualities are minimally required.
                                                            </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>
                                                  <xs:enumeration value="tab">
                                                  <xs:annotation>
                                                  <xs:documentation>
                                                                Tab delimited text file used to deliver certain auxiliary data along with sequencing submissions (only needed for certain
                                                                use cases).   The first line is devoted to column headers.  Each column is dedicated to an INDSC
                                                                data series type.
                                                                Please see SRA File Formats Guide for definitions of the definition and restrictions on this form.
                                                            </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>
                                                  <xs:enumeration value="454_native">
                                                  <xs:annotation>
                                                  <xs:documentation>
                                                                A combination of 454 primary analysis output files, including 
                                                                seq
                                                                qual
                                                                Please see SRA File Formats Guide for definitions of these file formats, 
                                                                and the SRA Submission Guidelines document for data series that are appropriate for your study.
                                                                Sequence and qualities are minimally required.
                                                            </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>
                                                  <xs:enumeration value="454_native_seq">
                                                  <xs:annotation>
                                                  <xs:documentation>
                                                                454 base calls (for example  .seq or .fna).
                                                                Please see SRA File Formats Guide for definitions of these file formats, 
                                                                and the SRA Submission Guidelines document for data series that are appropriate for your study.
                                                                Sequence and qualities are minimally required.
                                                            </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>
                                                  <xs:enumeration value="454_native_qual">
                                                  <xs:annotation>
                                                  <xs:documentation>
                                                                454 quality scores  (for example  .qual).
                                                                Please see SRA File Formats Guide for definitions of these file formats, 
                                                                and the SRA Submission Guidelines document for data series that are appropriate for your study.
                                                                Sequence and qualities are minimally required.
                                                            </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>
                                                  <xs:enumeration value="Helicos_native">
                                                  <xs:annotation>
                                                  <xs:documentation>
                                                                A kind of fastq format specific to the Helicos platform.
                                                                Please see SRA File Formats Guide for definitions of these file formats, 
                                                                and the SRA Submission Guidelines document for data series that are appropriate for your study.
                                                                Sequence and qualities are minimally required.
                                                            </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>
                                                  <xs:enumeration value="Illumina_native">
                                                  <xs:annotation>
                                                  <xs:documentation> 
                                                               Please see SRA File Formats Guide for definitions of these file formats, 
                                                               and the SRA Submission Guidelines document for data series that are appropriate for your study.
                                                               Sequence and qualities are minimally required.
                                                            </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>
                                                  <xs:enumeration value="Illumina_native_seq">
                                                  <xs:annotation>
                                                  <xs:documentation> 
                                                                Please see SRA File Formats Guide for definitions of these file formats, 
                                                                and the SRA Submission Guidelines document for data series that are appropriate for your study.
                                                                Sequence and qualities are minimally required.
                                                            </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>
                                                  <xs:enumeration value="Illumina_native_prb">
                                                  <xs:annotation>
                                                  <xs:documentation> 
                                                                Please see SRA File Formats Guide for definitions of these file formats, 
                                                                and the SRA Submission Guidelines document for data series that are appropriate for your study.
                                                                Sequence and qualities are minimally required.
                                                            </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>
                                                  <xs:enumeration value="Illumina_native_int">
                                                  <xs:annotation>
                                                  <xs:documentation> 
                                                                Please see SRA File Formats Guide for definitions of these file formats, 
                                                                and the SRA Submission Guidelines document for data series that are appropriate for your study.
                                                                Sequence and qualities are minimally required.
                                                            </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>
                                                  <xs:enumeration value="Illumina_native_qseq">
                                                  <xs:annotation>
                                                  <xs:documentation> 
                                                                Please see SRA File Formats Guide for definitions of these file formats, 
                                                                and the SRA Submission Guidelines document for data series that are appropriate for your study.
                                                                Sequence and qualities are minimally required.
                                                            </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>
                                                  <xs:enumeration value="Illumina_native_scarf">
                                                  <xs:annotation>
                                                  <xs:documentation> 
                                                                Please see SRA File Formats Guide for definitions of these file formats, 
                                                                and the SRA Submission Guidelines document for data series that are appropriate for your study.
                                                                Sequence and qualities are minimally required.
                                                            </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>
                                                  <xs:enumeration value="SOLiD_native">
                                                  <xs:annotation>
                                                  <xs:documentation>
                                                                A combination of SOLiD  primary analysis output files, including:
                                                                csfasta
                                                                _QV.qual
                                                                _intensity.ScaledCY3.fasta
                                                                _intensity.ScaledCY5.fasta
                                                                _intensity.ScaledFTC.fasta
                                                                _intensity.ScaledTXR.fasta
                                                                Please see SRA File Formats Guide for definitions of these file formats, 
                                                                and the SRA Submission Guidelines document for data series that are appropriate for your study.
                                                                Sequence and qualities are minimally required.
                                                            </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>
                                                  <xs:enumeration value="SOLiD_native_csfasta">
                                                  <xs:annotation>
                                                  <xs:documentation>
                                                                Colorspace calls (for example .csfasta)
                                                                Please see SRA File Formats Guide for definitions of these file formats, 
                                                                and the SRA Submission Guidelines document for data series that are appropriate for your study.
                                                                Sequence and qualities are minimally required.
                                                            </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>
                                                  <xs:enumeration value="SOLiD_native_qual">
                                                  <xs:annotation>
                                                  <xs:documentation>
                                                                Colorspace quality scores (for example .qual)
                                                                Please see SRA File Formats Guide for definitions of these file formats, 
                                                                and the SRA Submission Guidelines document for data series that are appropriate for your study.
                                                                Sequence and qualities are minimally required.
                                                            </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>
                                                  <xs:enumeration value="PacBio_HDF5">
                                                  <xs:annotation>
                                                  <xs:documentation>                                                              
                                                                 Pacific Biosciences Hierarchical Data Format. Please see
                                                                 SRA File Formats Guide for definitions of these file formats.
                                                  </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>
                                                  <xs:enumeration value="bam">
                                                  <xs:annotation>
                                                  <xs:documentation>
                                                                Binary SAM format that combines alignment and sequencing data.
                                                                Please see SRA File Formats Guide for definitions of these file formats, 
                                                                and the SRA Submission Guidelines document for data series that are appropriate for your study.
                                                                Sequence and qualities are minimally required.
                                                  </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>
                                                  <xs:enumeration value="cram">
                                                  <xs:annotation>
                                                  <xs:documentation>
                                                                Binary CRAM format that combines alignment and sequencing data.
                                                                Please see SRA File Formats Guide for definitions of these file formats, 
                                                                and the SRA Submission Guidelines document for data series that are appropriate for your study.
                                                                Sequence and qualities are minimally required.
                                                  </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>
                                                  <xs:enumeration value="CompleteGenomics_native">
                                                  <xs:annotation>
                                                  <xs:documentation>
                                                              Please see SRA File Formats Guide for definitions of these file formats, 
                                                              and the SRA Submission Guidelines document for data series that are appropriate for your study.
                                                              Sequence and qualities are minimally required.
                                                          </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>
                                                  <xs:enumeration value="OxfordNanopore_native">
                                                  <xs:annotation>
                                                  <xs:documentation>
                                                                Oxford Nanopore data format. 
                                                  </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>
                                                  </xs:restriction>
                                                  </xs:simpleType>
                                                  </xs:attribute>
                                                  <xs:attribute name="quality_scoring_system"
                                                  use="optional">
                                                  <xs:annotation>
                                                  <xs:documentation>
                                                    How the input data are scored for quality.  
                                                </xs:documentation>
                                                  </xs:annotation>
                                                  <xs:simpleType>
                                                  <xs:restriction base="xs:string">
                                                  <xs:enumeration value="phred">
                                                  <xs:annotation>
                                                  <xs:documentation>
                                                                The quality score is expressed as a probability of error in log form:
                                                                -10 log(1/p) where p is the probability of error, with value range 0..63,
                                                                0 meaning no base call.
                                                            </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>
                                                  <xs:enumeration value="log-odds">
                                                  <xs:annotation>
                                                  <xs:documentation>
                                                                The quality score is expressed as the ratio of error to non-error in log form:
                                                                -10 log(p/(1-p)) where p is the probability of error, with value range -40..40.
                                                                The SRA will convert these into phred scale during loadtime.
                                                            </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>
                                                  </xs:restriction>
                                                  </xs:simpleType>
                                                  </xs:attribute>
                                                  <xs:attribute name="quality_encoding"
                                                  use="optional">
                                                  <xs:annotation>
                                                  <xs:documentation>
                                                    Character used in representing the minimum quality value. 
                                                    Helps specify how to decode text rendering of quality data.
                                                </xs:documentation>
                                                  </xs:annotation>
                                                  <xs:simpleType>
                                                  <xs:restriction base="xs:string">
                                                  <xs:enumeration value="ascii">
                                                  <xs:annotation>
                                                  <xs:documentation>
                                                                ASCII character based encoding.
                                                            </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>
                                                  <xs:enumeration value="decimal">
                                                  <xs:annotation>
                                                  <xs:documentation>
                                                               Single decimal value per quality score.
                                                            </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>
                                                  <xs:enumeration value="hexadecimal">
                                                  <xs:annotation>
                                                  <xs:documentation>
                                                                Single hexadecimal value per quality score.
                                                            </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>
                                                  </xs:restriction>
                                                  </xs:simpleType>
                                                  </xs:attribute>
                                                  <xs:attribute name="ascii_offset" use="optional">
                                                  <xs:annotation>
                                                  <xs:documentation>
                                                    Character used in representing the minimum quality value.  Helps specify how to decode text rendering of quality data.
                                                </xs:documentation>
                                                  </xs:annotation>
                                                  <xs:simpleType>
                                                  <xs:restriction base="xs:string">
                                                  <xs:enumeration value="!">
                                                  <xs:annotation>
                                                  <xs:documentation>
                                                                ASCII value 33.  Typically used for range 0..63.
                                                            </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>
                                                  <xs:enumeration value="@">
                                                  <xs:annotation>
                                                  <xs:documentation>
                                                                ASCII value 64.  Typically used for range 0..60.
                                                            </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>

                                                  </xs:restriction>
                                                  </xs:simpleType>
                                                  </xs:attribute>
                                                  <xs:attribute name="checksum_method"
                                                  use="required">
                                                  <xs:annotation>
                                                  <xs:documentation>
                                                    Checksum method used.
                                                </xs:documentation>
                                                  </xs:annotation>
                                                  <xs:simpleType>
                                                  <xs:restriction base="xs:string">
                                                  <xs:enumeration value="MD5">
                                                  <xs:annotation>
                                                  <xs:documentation>
                                                                Checksum generated by the MD5 method (md5sum in unix). 
                                                            </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>
                                                  <xs:enumeration value="SHA-256">
                                                  <xs:annotation>
                                                  <xs:documentation>
                                                                Checksum generated by the SHA-256 method . 
                                                            </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:enumeration>
                                                  </xs:restriction>
                                                  </xs:simpleType>
                                                  </xs:attribute>
                                                  <xs:attribute name="checksum" type="xs:string"
                                                  use="required">
                                                  <xs:annotation>
                                                  <xs:documentation>
                                                    Checksum of uncompressed file.
                                                </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:attribute>
                                                  <xs:attribute name="unencrypted_checksum"
                                                  type="xs:string" use="optional">
                                                  <xs:annotation>
                                                  <xs:documentation>
                                                            Checksum of unenrypted file(used in conjunction with checksum of encrypted file).
                                                        </xs:documentation>
                                                  </xs:annotation>
                                                  </xs:attribute>
                                                  </xs:complexType>
                                                </xs:element>
                                            </xs:sequence>
                                        </xs:complexType>
                                    </xs:element>
                                </xs:sequence>
                                <xs:attribute name="member_name" type="xs:string" use="optional">
                                    <xs:annotation>
                                        <xs:documentation>
                                        Allow for an individual DATA_BLOCK to be associated with a member of a sample pool.
                                    </xs:documentation>
                                    </xs:annotation>
                                </xs:attribute>
                            </xs:complexType>
                        </xs:element>
                    </xs:sequence>
                    <xs:element name="RUN_LINKS" minOccurs="0" maxOccurs="1">
                        <xs:annotation>
                            <xs:documentation>
                            Links to resources related to this RUN or RUN set (publication, datasets, online databases).
                        </xs:documentation>
                        </xs:annotation>
                        <xs:complexType>
                            <xs:sequence minOccurs="1" maxOccurs="1">
                                <xs:element name="RUN_LINK" type="com:LinkType"
                                    maxOccurs="unbounded"/>
                            </xs:sequence>
                        </xs:complexType>
                    </xs:element>

                    <xs:element name="RUN_ATTRIBUTES" minOccurs="0" maxOccurs="1">
                        <xs:annotation>
                            <xs:documentation>
                            Properties and attributes of a RUN.  These can be entered as free-form 
                            tag-value pairs. For certain studies, submitters may be asked to follow a
                            community established ontology when describing the work.
                        </xs:documentation>
                        </xs:annotation>
                        <xs:complexType>
                            <xs:sequence maxOccurs="1" minOccurs="1">
                                <xs:element name="RUN_ATTRIBUTE" type="com:AttributeType"
                                    maxOccurs="unbounded"/>
                            </xs:sequence>
                        </xs:complexType>
                    </xs:element>
                </xs:sequence>
                <xs:attribute name="run_date" use="optional" type="xs:dateTime">
                    <xs:annotation>
                        <xs:documentation>
                        ISO date when the run took place.  
                    </xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attribute name="run_center" use="optional" type="xs:string">
                    <xs:annotation>
                        <xs:documentation>
                        If applicable, the name of the contract sequencing center that executed the run.
                        Example: 454MSC.
                    </xs:documentation>
                    </xs:annotation>
                </xs:attribute>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="RunSetType">
        <xs:sequence minOccurs="1" maxOccurs="1">
            <xs:element name="RUN" type="RunType" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>

    <xs:element name="RUN_SET" type="RunSetType">
        <xs:annotation>
            <xs:documentation>
                RUN_SET serves as a container for a set of runs and a name space
                for establishing referential integrity between them. 
            </xs:documentation>
        </xs:annotation>

    </xs:element>

    <xs:element name="RUN" type="RunType"/>
</xs:schema>
