<?xml version="1.0"?>
<!--
Authors: John Tate, C<jt6@sanger.ac.uk>, Rob Finn, C<rdf@sanger.ac.uk>

Copyright (c) 2007: Genome Research Ltd.

This is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.

You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns="http://pfam.sanger.ac.uk/"
           targetNamespace="http://pfam.sanger.ac.uk/"
           elementFormDefault="qualified" 
           attributeFormDefault="unqualified">

  <xs:include schemaLocation="http://pfam.sanger.ac.uk/static/documents/schemas/elements.xsd" />
  
  <xs:element name="pfam">
    <xs:annotation>
      <xs:documentation>Information from the Pfam database</xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="entry" maxOccurs="unbounded" />
      </xs:sequence>
      <xs:attribute name="release" type="xs:float" use="required" />
      <xs:attribute name="release_date" type="pfamDate" use="required" />
    </xs:complexType>
    <xs:key name="entry">
      <xs:selector xpath="entry" />
      <xs:field xpath="@accession" />
    </xs:key>
  </xs:element>

  <xs:element name="entry">
    <xs:annotation>
      <xs:documentation>Information about a Pfam database entity</xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:all>
        <xs:element name="description" type="xs:string" />
        <xs:element name="comment"     type="xs:string" minOccurs="0" />
        <xs:element ref="taxonomy" />
        <xs:element ref="sequence" />
        <xs:element ref="matches" minOccurs="0" />
      </xs:all>
      <xs:attribute name="entry_type" fixed="sequence" />
      <xs:attribute name="db"         type="xs:string"        use="required" />
      <xs:attribute name="db_release" type="xs:string"        use="required" />
      <xs:attribute name="accession"  type="uniprotAccession" use="required" />
      <xs:attribute name="id"         type="xs:string"        use="required" />
    </xs:complexType>
  </xs:element>

  <xs:element name="taxonomy">
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base="xs:string">
          <xs:attribute name="tax_id"       type="xs:positiveInteger" />
          <xs:attribute name="species_name" type="xs:string" />
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="sequence">
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base="proteinSequence">
          <xs:attribute name="length"  type="xs:positiveInteger" use="required" />
          <xs:attribute name="md5"     type="md5"                use="required" />
          <xs:attribute name="crc64"   type="crc64"              use="required" />
          <xs:attribute name="version" type="xs:positiveInteger" use="required" />
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="matches">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="match" minOccurs="0" maxOccurs="unbounded" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
    
</xs:schema>
