<?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 a publication.
      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" />



  <!-- publication -->
  <xsd:element name="publication">
    <xsd:annotation>
      <xsd:documentation>
        This class defines a publication.
        See http://www.pharmgkb.org/schema/docs/publication.html for details.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:complexContent>
        <xsd:extension base="AccessionObjectClass">
          <!-- subelements -->
          <xsd:sequence>
            <xsd:element name="title" type="NonEmptyTokenType" minOccurs="1" maxOccurs="1" />
            <xsd:element name="author" type="PersonClass" minOccurs="0" maxOccurs="unbounded" />
            <xsd:element name="citation" type="NonEmptyStringType" minOccurs="0" maxOccurs="1" />
            <xsd:element name="journal" type="NonEmptyTokenType" minOccurs="0" maxOccurs="1" />
            <xsd:element name="volume" type="NonEmptyTokenType" minOccurs="0" maxOccurs="1" />
            <xsd:element name="page" type="NonEmptyTokenType" minOccurs="0" maxOccurs="1" />
            <xsd:element name="year" type="xsd:nonNegativeInteger" minOccurs="0" maxOccurs="1" />
            <xsd:element name="month" type="xsd:nonNegativeInteger" minOccurs="0" maxOccurs="1" />
            <xsd:element name="abstract" type="xsd:token" minOccurs="0" maxOccurs="1" />
          </xsd:sequence>
        </xsd:extension>
      </xsd:complexContent>
    </xsd:complexType>
  </xsd:element>


  <!-- literature annotation -->
  <xsd:element name="literatureAnnotation">
    <xsd:annotation>
      <xsd:documentation>
        This class defines a literature annotation.
        See http://www.pharmgkb.org/schema/docs/literatureAnnotation.html for details.
      </xsd:documentation>
      <xsd:appinfo>
        <sch:pattern name="Required elements for literatureAnnotation">
          <sch:rule context="pgkb:literatureAnnotation">
            <sch:report test="pgkb:dataXref and not(pgkb:dataXref/@resource='PharmGKB')">dataXref resource must be 'PharmGKB'</sch:report>
            <sch:report test="pgkb:dataXref and not(starts-with(., 'PS'))">dataXref value must be a valid PharmGKB Submission ID (must start with 'PS')</sch:report>
          </sch:rule>
        </sch:pattern>
      </xsd:appinfo>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:complexContent>
        <xsd:extension base="AccessionObjectClass">
          <!-- subelements -->
          <xsd:sequence>
            <xsd:element name="name" type="NonEmptyStringType" minOccurs="0" maxOccurs="1" />
            <xsd:element name="literatureXref" type="XrefClass" minOccurs="1" maxOccurs="1" />
            <xsd:element name="publicationXref" type="XrefClass" minOccurs="0" maxOccurs="1" />
            <xsd:element name="publicationType" minOccurs="1" maxOccurs="unbounded">
              <xsd:simpleType>
                <xsd:restriction base="xsd:token">
                  <xsd:enumeration value="Review article" />
                  <xsd:enumeration value="Case report" />
                  <xsd:enumeration value="Primary experiment paper" />
                  <xsd:enumeration value="Methodology paper" />
                  <xsd:enumeration value="Ethical, legal and social issues" />
                  <xsd:enumeration value="Meeting abstract" />
                  <xsd:enumeration value="Human Study" />
                  <xsd:enumeration value="Clinical Trial" />
                  <xsd:enumeration value="Family Study" />
                  <xsd:enumeration value="Meta-Analysis" />
                  <xsd:enumeration value="Genome-Wide Association Study" />
                  <xsd:enumeration value="Commentary/Opinion" />
                </xsd:restriction>
              </xsd:simpleType>
            </xsd:element>
            <xsd:element name="category" type="PharmacogeneticKnowledgeCategoryEnum" minOccurs="0" maxOccurs="5" />
            <xsd:element name="evidenceLocation" minOccurs="0" maxOccurs="3">
              <xsd:simpleType>
                <xsd:restriction base="xsd:token">
                  <xsd:enumeration value="Unknown" />
                  <xsd:enumeration value="Title" />
                  <xsd:enumeration value="Abstract" />
                  <xsd:enumeration value="Body" />
                  <xsd:enumeration value="NA" />
                </xsd:restriction>
              </xsd:simpleType>
            </xsd:element>
            <xsd:element name="relationship" minOccurs="0" maxOccurs="unbounded">
              <xsd:complexType>
                <xsd:sequence>
                  <xsd:element name="type">
                    <xsd:simpleType>
                      <xsd:restriction base="xsd:token">
                        <xsd:enumeration value="related" />
                        <xsd:enumeration value="positively related" />
                        <xsd:enumeration value="negatively related" />
                        <xsd:enumeration value="not related" />
                        <xsd:enumeration value="discussed" />
                      </xsd:restriction>
                    </xsd:simpleType>
                  </xsd:element>
                  <xsd:element name="category" type="PharmacogeneticKnowledgeCategoryEnum" minOccurs="0" maxOccurs="5" />
                  <xsd:element name="geneXref" type="XrefClass" minOccurs="0" maxOccurs="unbounded" />
                  <xsd:element name="drugXref" type="XrefClass" minOccurs="0" maxOccurs="unbounded" />
                  <xsd:element name="diseaseXref" type="XrefClass" minOccurs="0" maxOccurs="unbounded" />
                  <xsd:element name="interactingGeneXref" type="XrefClass" minOccurs="0" maxOccurs="unbounded" />
                  <xsd:element name="interactingDrugXref" type="XrefClass" minOccurs="0" maxOccurs="unbounded" />
                  <xsd:element name="interactingDiseaseXref" type="XrefClass" minOccurs="0" maxOccurs="unbounded" />
                  <xsd:element name="rsId" type="NonEmptyTokenType" minOccurs="0" maxOccurs="unbounded" />
                </xsd:sequence>
              </xsd:complexType>
            </xsd:element>
            <xsd:element name="dataXref" type="XrefClass" minOccurs="0" maxOccurs="unbounded" />
            <xsd:element name="rsId" type="NonEmptyTokenType" minOccurs="0" maxOccurs="unbounded" />
            <xsd:element name="keyword" type="NonEmptyTokenType" minOccurs="0" maxOccurs="unbounded" />
            <xsd:element name="term" type="OntologyTermClass" minOccurs="0" maxOccurs="unbounded" />
          </xsd:sequence>
        </xsd:extension>
      </xsd:complexContent>
    </xsd:complexType>
  </xsd:element>


  <!-- published assay -->
  <xsd:element name="publishedAssay">
    <xsd:annotation>
      <xsd:documentation>
        This class defines a published assay.
        See http://www.pharmgkb.org/schema/docs/publishedAssay.html for details.
      </xsd:documentation>
      <xsd:appinfo>
        <sch:pattern name="Required elements for publishedAssay">
          <sch:rule context="pgkb:publishedAssay">
            <sch:report test="not(@pharmgkbId) and
            not(pgkb:name)">Missing element:  name</sch:report>
            <sch:report test="not(@pharmgkbId) and
            not(pgkb:description)">Missing element:  description</sch:report>
            <sch:report test="pgkb:geneXref and not(pgkb:geneXref/@resource='PharmGKB')">geneXref resource must be 'PharmGKB'</sch:report>
          </sch:rule>
        </sch:pattern>
      </xsd:appinfo>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:complexContent>
        <xsd:extension base="AccessionObjectClass">
          <!-- subelements -->
          <xsd:sequence>
            <xsd:element name="name" type="NonEmptyTokenType" minOccurs="0" maxOccurs="1" />
            <xsd:element name="type" minOccurs="0" maxOccurs="1">
              <xsd:simpleType>
                <xsd:restriction base="xsd:token">
                  <xsd:enumeration value="DHPLC Assay" />
                  <xsd:enumeration value="PCR Assay" />
                  <xsd:enumeration value="Pyrosequencing Assay" />
                  <xsd:enumeration value="RFLP Assay" />
                  <xsd:enumeration value="TaqMan Assay" />
                  <xsd:enumeration value="PCR Sizing Assay" />
                  <xsd:enumeration value="Genotyping Assay" />
                  <xsd:enumeration value="Sequencing Assay" />
                </xsd:restriction>
              </xsd:simpleType>
            </xsd:element>
            <xsd:element name="forwardPrimerName" type="NonEmptyStringType" minOccurs="0" maxOccurs="1" />
            <xsd:element name="forwardPrimer" type="DnaSequenceType" minOccurs="0" maxOccurs="1" />
            <xsd:element name="reversePrimerName" type="NonEmptyStringType" minOccurs="0" maxOccurs="1" />
            <xsd:element name="reversePrimer" type="DnaSequenceType" minOccurs="0" maxOccurs="1" />
            <xsd:element name="description" type="NonEmptyStringType" minOccurs="0" maxOccurs="1" />
            <xsd:element name="geneXref" type="XrefClass" minOccurs="0" maxOccurs="1" />
            <xsd:element name="xref" type="XrefClass" minOccurs="0" maxOccurs="unbounded" />
          </xsd:sequence>
        </xsd:extension>
      </xsd:complexContent>
    </xsd:complexType>
  </xsd:element>

</xsd:schema>