<?xml version="1.0"?>
<!--
***** BEGIN LICENSE BLOCK *****
Version: MPL 1.1/GPL 2.0/LGPL 2.1

The contents of this file are subject to the Mozilla Public License Version
1.1 (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.mozilla.org/MPL/

Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
the specific language governing rights and limitations under the License.

The Original Code is PharmGen.

The Initial Developer of the Original Code is
PharmGKB (The Pharmacogenetics and Pharmacogenetics Knowledge Base,
supported by NIH U01GM61374).
Portions created by the Initial Developer are Copyright (C) 2005
the Initial Developer. All Rights Reserved.

Contributor(s):

Alternatively, the contents of this file may be used under the terms of
either the GNU General Public License Version 2 or later (the "GPL"), or the
GNU Lesser General Public License Version 2.1 or later (the "LGPL"), in
which case the provisions of the GPL or the LGPL are applicable instead of
those above. If you wish to allow use of your version of this file only
under the terms of either the GPL or the LGPL, and not to allow others to
use your version of this file under the terms of the MPL, indicate your
decision by deleting the provisions above and replace them with the notice
and other provisions required by the GPL or the LGPL. If you do not delete
the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL.

***** END LICENSE BLOCK *****
-->

<xsd:schema version="4.0"
  targetNamespace="http://www.pharmgkb.org/schema/"
  xmlns="http://www.pharmgkb.org/schema/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:sch="http://www.ascc.net/xml/schematron"
  elementFormDefault="qualified">

  <xsd:annotation>
    <xsd:documentation>
      This XML schema defines basic, reusable sequence related entities.
      For complete documentation, see http://www.pharmgkb.org/schema/.
    </xsd:documentation>
  </xsd:annotation>


  <!-- Included XML Schema Files -->
  <xsd:include schemaLocation="http://www.pharmgkb.org/schema/types.xsd" />


  <!-- ChromosomeType -->
  <xsd:simpleType name="ChromosomeType">
    <xsd:restriction base="xsd:token">
      <xsd:minLength value="1" />
      <xsd:maxLength value="3" />
      <xsd:pattern value="([0-9]+)|([XY])" />
    </xsd:restriction>
  </xsd:simpleType>


  <!-- DnaSequenceType -->
  <xsd:simpleType name="DnaSequenceType">
    <xsd:annotation>
      <xsd:documentation>
        A DNA sequence.  The valid sequence alphabet is A, T, C, and G.
      </xsd:documentation>
    </xsd:annotation>
    <!-- restrictions -->
    <xsd:restriction base="xsd:token">
      <xsd:minLength value="1" />
      <xsd:pattern value="[AaCcGgTt]+" />
    </xsd:restriction>
  </xsd:simpleType>


  <!-- IupacDnaSequenceType -->
  <xsd:simpleType name="IupacDnaSequenceType">
    <xsd:annotation>
      <xsd:documentation>
        An IUPAC DNA sequence.  The valid sequence alphabet is A, T, C, G and
        the IUPAC ambiguity codes.  See
        http://www.ncbi.nlm.nih.gov/SNP/iupac.html for a list of the
        IUPAC ambiguity codes and their definitions.
      </xsd:documentation>
    </xsd:annotation>
    <!-- restrictions -->
    <xsd:restriction base="xsd:token">
      <xsd:minLength value="1" />
      <xsd:pattern value="[AaBbCcDdGgHhKkMmNnTtUuRrSsVvWwYy]+" />
    </xsd:restriction>
  </xsd:simpleType>


  <!-- VariantDnaSequenceType -->
  <xsd:simpleType name="VariantDnaSequenceType">
    <xsd:annotation>
      <xsd:documentation>
        A variant DNA sequence.  The valid sequence alphabet is A, T, C,
        G, and - (to denote a deletion).
      </xsd:documentation>
    </xsd:annotation>
    <!-- restrictions -->
    <xsd:restriction base="xsd:token">
      <xsd:minLength value="1" />
      <xsd:pattern value="([AaCcGgTt]+)|(\-)|(\([AaBbCcDdGgHhKkMmNnTtUuRrSsVvWwYy]+\)\d+)|(\[[AaCcGgTt]+\])|(\[\-+\])" />
    </xsd:restriction>
  </xsd:simpleType>


  <!-- RnaSequenceType -->
  <xsd:simpleType name="RnaSequenceType">
    <xsd:annotation>
      <xsd:documentation>
        An RNA sequence.  The valid sequence alphabet is A, U, C, and G.
      </xsd:documentation>
    </xsd:annotation>
    <!-- restrictions -->
    <xsd:restriction base="xsd:token">
      <xsd:minLength value="1" />
      <xsd:pattern value="[AaCcGgUu]+" />
    </xsd:restriction>
  </xsd:simpleType>


  <!-- ProteinSequenceType -->
  <xsd:simpleType name="ProteinSequenceType">
    <xsd:annotation>
      <xsd:documentation>
        A protein sequence.  The valid sequence alphabet is the IUB-IUPAC amino
        acid symbols.  See http://www.chem.qmul.ac.uk/iupac/AminoAcid/A2021.html
        for the recommendation.
      </xsd:documentation>
    </xsd:annotation>
    <!-- restrictions -->
    <xsd:restriction base="xsd:token">
      <xsd:minLength value="1" />
      <xsd:pattern value="[AaBbCcDdEeFfGgHhIiKkLlMmNnPpQqRrSsTtUuVvWwXxYyZz]+" />
    </xsd:restriction>
  </xsd:simpleType>


  <!-- AminoAcidType -->
  <xsd:simpleType name="AminoAcidType">
    <xsd:annotation>
      <xsd:documentation>
        An amino acid.
      </xsd:documentation>
    </xsd:annotation>
    <!-- restrictions -->
    <xsd:restriction base="xsd:token">
      <xsd:enumeration value="Ala" />
      <xsd:enumeration value="Arg" />
      <xsd:enumeration value="Asn" />
      <xsd:enumeration value="Asp" />
      <xsd:enumeration value="Cys" />
      <xsd:enumeration value="Gln" />
      <xsd:enumeration value="Glu" />
      <xsd:enumeration value="Gly" />
      <xsd:enumeration value="His" />
      <xsd:enumeration value="Ile" />
      <xsd:enumeration value="Leu" />
      <xsd:enumeration value="Lys" />
      <xsd:enumeration value="Met" />
      <xsd:enumeration value="Phe" />
      <xsd:enumeration value="Pro" />
      <xsd:enumeration value="Ser" />
      <xsd:enumeration value="Sec" />
      <xsd:enumeration value="Thr" />
      <xsd:enumeration value="Trp" />
      <xsd:enumeration value="Tyr" />
      <xsd:enumeration value="Val" />
      <xsd:enumeration value="del" />
    </xsd:restriction>
  </xsd:simpleType>


  <!-- ProteinChangeClass -->
  <xsd:complexType name="ProteinChangeClass">
    <xsd:sequence>
      <!-- XXX: disable temporarily, should require proteinXref -->
      <xsd:element name="proteinXref" type="XrefClass" minOccurs="0" maxOccurs="1" />
      <xsd:element name="aminoAcidPosition" type="xsd:integer" minOccurs="1" maxOccurs="1" />
      <xsd:element name="referenceAminoAcid" type="ProteinSequenceType" minOccurs="1" maxOccurs="1" />
      <xsd:element name="variantAminoAcid" type="ProteinSequenceType" minOccurs="1" maxOccurs="1" />
      <xsd:element name="causesFrameShift" type="xsd:boolean" default="false" minOccurs="0" maxOccurs="1" />
    </xsd:sequence>
  </xsd:complexType>


  <!-- RegionClass -->
  <xsd:complexType name="RegionClass">
    <xsd:annotation>
      <xsd:documentation>
        This class defines a region of a sequence.
        See http://www.pharmgkb.org/schema/docs/region.html for details.
      </xsd:documentation>
      <xsd:appinfo>
        <sch:pattern name="Rules for RegionClass">
          <sch:rule context="pgkb:region">
            <sch:report test="number(pgkb:startPosition)&gt;number(pgkb:stopPosition)">The startPosition must be less than the stopPosition</sch:report>
          </sch:rule>
          <sch:rule context="pgkb:analyzedRegion">
            <sch:report test="number(pgkb:startPosition)&gt;number(pgkb:stopPosition)">The startPosition must be less than the stopPosition</sch:report>
          </sch:rule>
          <sch:rule context="pgkb:amplicon">
            <sch:report test="number(pgkb:startPosition)&gt;number(pgkb:stopPosition)">The startPosition must be less than the stopPosition</sch:report>
          </sch:rule>
          <sch:rule context="pgkb:forwardRead">
            <sch:report test="number(pgkb:startPosition)&gt;number(pgkb:stopPosition)">The startPosition must be less than the stopPosition</sch:report>
          </sch:rule>
          <sch:rule context="pgkb:reverseRead">
            <sch:report test="number(pgkb:startPosition)&gt;number(pgkb:stopPosition)">The startPosition must be less than the stopPosition</sch:report>
          </sch:rule>
          <sch:rule context="pgkb:annealingRegionInPrimer">
            <sch:report test="number(pgkb:startPosition)&gt;number(pgkb:stopPosition)">The startPosition must be less than the stopPosition</sch:report>
          </sch:rule>
          <sch:rule context="pgkb:annealingRegionInReferenceSequence">
            <sch:report test="number(pgkb:startPosition)&gt;number(pgkb:stopPosition)">The startPosition must be less than the stopPosition</sch:report>
          </sch:rule>
        </sch:pattern>
      </xsd:appinfo>
    </xsd:annotation>
    <!-- subelements -->
    <xsd:sequence>
      <xsd:element name="startPosition" type="xsd:integer" minOccurs="1" maxOccurs="1" />
      <xsd:element name="stopPosition" type="xsd:integer" minOccurs="1" maxOccurs="1" />
    </xsd:sequence>
  </xsd:complexType>


  <!-- CoordinateSystemClass -->
  <xsd:complexType name="CoordinateSystemClass">
    <xsd:annotation>
      <xsd:documentation>
        This class defines the coordinate system.
        See http://www.pharmgkb.org/schema/docs/coordinateSystem.html for details.
      </xsd:documentation>
    </xsd:annotation>
    <!-- subelements -->
    <xsd:sequence>
      <xsd:element name="startPosition" type="xsd:integer" minOccurs="1" maxOccurs="1" default="1" />
      <xsd:element name="hasZero" type="xsd:boolean" minOccurs="1" maxOccurs="1" default="false" />
      <xsd:element name="orientation" minOccurs="0" maxOccurs="1" default="forward">
        <xsd:simpleType>
          <xsd:restriction base="xsd:token">
            <xsd:enumeration value="forward" />
            <xsd:enumeration value="reverse" />
          </xsd:restriction>
        </xsd:simpleType>
      </xsd:element>
      <xsd:element name="strand" minOccurs="0" maxOccurs="1" default="plus">
        <xsd:simpleType>
          <xsd:restriction base="xsd:token">
            <xsd:enumeration value="plus" />
            <xsd:enumeration value="minus" />
          </xsd:restriction>
        </xsd:simpleType>
      </xsd:element>
    </xsd:sequence>
  </xsd:complexType>


</xsd:schema>