<?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/types.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" minOccurs="0" type="xs:string" />
        <xs:element name="comment" minOccurs="0" type="xs:string" />
        <xs:element ref="go_terms" minOccurs="0" />
        <xs:element ref="clan_membership" minOccurs="0" />
        <xs:element ref="curation_details" minOccurs="0" />
        <xs:element ref="hmm_details" minOccurs="0" />
      </xs:all>
      <xs:attribute name="entry_type">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:enumeration value="Pfam-A" />
            <xs:enumeration value="Pfam-B" />
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
      <xs:attribute name="accession" type="pfamAccession" use="required" />
      <xs:attribute name="id" type="pfamId" use="required" />
    </xs:complexType>
  </xs:element>

  <xs:element name="clan_membership">
    <xs:annotation>
      <xs:documentation>Details of the Pfam clan to which the entity belongs</xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:attribute name="clan_acc" type="clanAccession" />
      <xs:attribute name="clan_id" type="xs:string" />
    </xs:complexType>
  </xs:element>
  
  <xs:element name="go_terms">
    <xs:annotation>
      <xs:documentation>Details of the Gene Ontology (GO) terms for this family</xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="category" maxOccurs="unbounded" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="category">
    <xs:annotation>
      <xs:documentation>Details of the Gene Ontology (GO) categories for this family</xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="term" maxOccurs="unbounded" />
      </xs:sequence>
      <xs:attribute name="name">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:enumeration value="component" />
            <xs:enumeration value="function" />
            <xs:enumeration value="process" />
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="term">
    <xs:annotation>
      <xs:documentation>A Gene Ontology (GO) term</xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base="xs:string">
		      <xs:attribute name="go_id" type="goId" />      
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="curation_details">
    <xs:annotation>
      <xs:documentation>Detailed curation information</xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:all>
        <xs:element name="status" type="xs:string" />
        <xs:element name="seed_source" type="xs:string" />
        <xs:element name="previous_id" type="xs:string" minOccurs="0" />
        <xs:element name="num_archs" type="xs:positiveInteger" />
        <xs:element ref="num_seqs" />
        <xs:element name="num_species" type="xs:positiveInteger" />
        <xs:element name="num_structures" type="xs:positiveInteger" />
        <xs:element name="percentage_identity" type="xs:float" />
        <xs:element name="av_length" type="xs:float" />
        <xs:element name="av_coverage" type="xs:float" />
        <xs:element name="type" type="pfamAType" />
      </xs:all>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="hmm_details">
    <xs:annotation>
      <xs:documentation>Detailed information about a model</xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:all>
        <xs:element name="build_commands" type="xs:string" />
        <xs:element name="search_commands" type="xs:string" />
        <xs:element name="cutoffs">
          <xs:complexType>
            <xs:all>
              <xs:element name="gathering" type="cutoff" />
              <xs:element name="trusted" type="cutoff" />
              <xs:element name="noise" type="cutoff" />
            </xs:all>
          </xs:complexType>
        </xs:element>
      </xs:all>
      <xs:attribute name="hmmer_version" type="xs:string" />
      <xs:attribute name="model_version" type="xs:positiveInteger" />
      <xs:attribute name="model_length" type="xs:positiveInteger" />
    </xs:complexType>
  </xs:element>
  
  <xs:complexType name="cutoff">
    <xs:annotation>
      <xs:documentation>Values for a specific type of cutoff</xs:documentation>
    </xs:annotation>
    <xs:all>
      <xs:element name="sequence" type="xs:float" />
      <xs:element name="domain" type="xs:float" />
    </xs:all>
  </xs:complexType>

  <xs:element name="num_seqs">
    <xs:annotation>
      <xs:documentation>The number of sequences in the alignment(s)</xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:all>
        <xs:element name="seed" type="xs:integer" />
        <xs:element name="full" type="xs:integer" />
      </xs:all>
    </xs:complexType>
  </xs:element>
  
</xs:schema>
