<?xml version="1.0" encoding="UTF-8"?>

<OmixedDatabaseSchema name="newGeneric" verson="1.1" comment="a general purpose model of biological experiments">
  
    <!--

      change history:

       v1.1   02/01/2008

         - added link from 'AssayDataSet' to 'Assay'
	 - moved link from 'AssayDataSet' to 'AssayDataSet' into the 'Data Origins' group
	 - added 'ValidationRuleSet' to 'AssayDataSet'
	 - added a bunch of attrbiutes from the maxdLoad2 transcriptomics model
	 - added the AssayType pseudo-ontology
	 - added the AssayDataSetType pseudo-ontology
         - restructured all items which use protocols to have a "details" group
	 - removed 'Person' and 'Location' links to all protocols
	 - added 'Title' and 'Type' attributes to all protocols


	 v1.2 25/05/2008
	 - created 'Annotation' ityem type and added links to all protcols and materials
	 - removed 'Title' and 'Type' attributes from all protocols

	 v1.3 06/06/2008

	 - revised 'AssayDataSet' to make the raw/derived choice more consistent
	 - renamed 'AssayDataSet.File' to 'AssayDataSet.Data File'
	 - removed 'AssayDataSet'Data Format'  (format should be stored in the File link 'Data File')

      -->

  <ItemTypeList>
    

    <!-- ====================================================================== -->

    <ItemType name="Annotation">

      <Group name="Name">
	<Attribute name="Text" type="string" />
	
	<Group name="OntologyReference">
	  <Attribute name="Name" type="string" />     <!-- ::TODO::  could be a link to an ontology, or a list of standard ontologies or something -->
	  <Attribute name="Version" type="string" />   
	  <Attribute name="Accession" type="string" />   
	</Group>
      </Group>


      <Group name="Value">
	<Attribute name="Text" type="string" />
	
	<Group name="OntologyReference">
	  <Attribute name="Name" type="string" />       <!-- ::TODO::  could be a link to an ontology, or a list of standard ontologies or something --> 
	  <Attribute name="Version" type="string" />   
	  <Attribute name="Accession" type="string" />   
	</Group>
      </Group>
       
    </ItemType>

    

    <ItemType name="Location">
      <Attribute name="Name" type="string" />   
      <Attribute name="Address" type="text" />   
      <Attribute name="Country" type="string" />   
      <Attribute name="Region" type="string" />   
      <Attribute name="Latitude" type="string" />
      <Attribute name="Longitude" type="string" />
      <Attribute name="Altitude" type="string" />
    </ItemType>


    <ItemType name="Person">
       <Attribute name="Name" type="string" />   
       <Attribute name="Contact Telephone" type="string" />   
       <Attribute name="Contact E-mail" type="string" />   
       <Attribute name="Contact Address" type="text" />   
    </ItemType>
      

    <!-- ====================================================================== -->
    
    
    <ItemType name="Source">
	
      <Comment>
	A Source can be any population, organism or part of
	an organism which is used as part of an experiment.
      </Comment>
      
      <Attribute name="Description" type="string" />
      
      <DisplayColour hex="#FFCC00"/>
      
      <!-- ::todo:: link to ontology -->
      <!-- ::todo:: what about multiple species? -->
      <Attribute name="Species" type="string">
	<Comment>The name(s) of the species known to be in this Source</Comment>
      </Attribute>

      <Attribute name="Material Type" type="string">
	<Comment>For example "wild population", "laboratory animal", "cell culture", "soil sample" etc.</Comment>
      </Attribute>

      <Link name="Location" to="Location"> 
	<Comment>Where is this Source to be found?</Comment>
      </Link>

      <Link name="Annotation" to="Annotation" arity="many"> 
	<Comment>Additional metadata</Comment>
      </Link>


    </ItemType>
    

    <!-- ====================================================================== -->


    <ItemType name="SamplingProtocol">

      <Comment>
	A SamplingProtocol describes the method used
	for obtaining a Sample from Source
      </Comment>
      
      <Attribute name="Description" type="text" hint.lines="4" />
      
      <Link name="Annotation" to="Annotation" arity="many" />

      <!--
      <Attribute name="Title" type="string"/>

      <Attribute name="Type" type="string"/>

      <DisplayColour hex="#009900"/>
      -->
      
    </ItemType>
    
    
    <!-- ====================================================================== -->
    
    
    <ItemType name="Sample">
      
      <Comment>
	A Sample is some portion of a Source
	which has been isolated for investigation
      </Comment>

      <DisplayColour hex="#009900"/>

      <Attribute name="Description" type="text" hint.lines="4" />
      
      <Group name="Sampling Details">
	
	<Link to="Source" arity="one">
	  <Comment>
	    Where did this Sample come from?
	  </Comment>
	</Link>
	
	<Link to="SamplingProtocol" arity="one">
	  <Comment>
	    How was this Sample obtained?
	  </Comment>
	</Link>
	
	<Attribute name="Sampled on" type="date" >
	  <Comment>
	    When was this Sample acquired ?
	  </Comment>
	</Attribute>
	
	<Link name="Sampled by" to="Person">
	  <Comment>
	    Who carried out the SamplingProtocol ?
	  </Comment>
	</Link>
	
      </Group>

      <Attribute name="Material Type" type="string"/>
	<Comment>
	  What sort of material is this sample? For example 'blood', 'frozen tissue', 'whole organism' etc.
	</Comment>

      <!-- ::TODO:: use a units ontology -->
      <Group name="Quantity">
	<Attribute name="Value" type="number"/>
	<Attribute name="Unit" type="string"/>
	<Comment>
	  How much material is in this Sample ?
	</Comment>
      </Group>

      <Link name="Annotation" to="Annotation" arity="many"> 
	<Comment>Additional metadata</Comment>
      </Link>

      <!-- as it is not nested inside anything else this ValidationRuleSet applies to the whole ItemItem -->
      <ValidationRuleSet>
	<ValidationRule failure_message="A Sample must be linked to a Source">
	  <Condition has_value="Sampling Details.Source"/>
	</ValidationRule>
	<ValidationRule failure_message="A Sample must be linked to a SamplingProtocol">
	  <Condition has_value="Sampling Details.SamplingProtocol"/>
	</ValidationRule>
      </ValidationRuleSet>
      
    </ItemType>
 
   
    <!-- ====================================================================== -->


    <ItemType name="TreatmentProtocol">

      <Comment>
	A TreatmentProtocol describes a process used 
	to differentiate biological materials during an experiment,
	for example incubation, drug doses, stavation and so on.
      </Comment>
      
      <Attribute name="Description" type="text" hint.lines="4" />
      
      <Link name="Annotation" to="Annotation" arity="many"/>

      <!--
      <Attribute name="Title" type="string"/>

      <Attribute name="Type" type="string"/>

 
      <DisplayColour hex="#669966"/>
      -->
  

    </ItemType>
    
 
    <!-- ====================================================================== -->
 
    
    <ItemType name="TreatedSample">

      <Comment>
	A TreatedSample is a Sample or TreatedSample that has had
	something done to it, for example being exposed to a stress or
	environmental change, or being combined with other Samples or
	TreatedSamples.
	 
	The treatment that was applied is described by the
	TreatmentProtocol to which it is linked.
      </Comment>
      
      <DisplayColour hex="#669966"/>

      <Link to="Sample" arity="many">
	<Comment>
	  Which Sample(s) does this TreatedSample come from?

	  A TreatedSample can be linked to one
	  or more Sampless to construct
	  a chain of treatments
        </Comment>
      </Link>
      
      <Link to="TreatedSample" arity="many">
	<Comment>
	  Which other TreatedSample(s) does this TreatedSample come from?
	  
	  A TreatedSample can be linked to one
	  or more other TreatedSamples to construct
	  a chain of treatments
	</Comment>
      </Link>
      
      <Group name="Treatment Details">
	
	<Comment type="pre">this is the pre-comment for the 'Treatment Details' group</Comment>

	<Comment type="post">this is the post-comment for the 'Treatment Details' group</Comment>

	<Link to="TreatmentProtocol" arity="one">
	  <Purpose>
	    What treatment was applied to produce this TreatedSample?
	  </Purpose>
	</Link>
	
	<Attribute name="Performed on" type="date" >
	  <Comment>
	    When was this action done?
	  </Comment>
	</Attribute>
	
	<Link name="Performed by" to="Person">
	  <Comment>
	    Who did this action?
	  </Comment>
	</Link>
	
      </Group>


      <Attribute name="Material Type" type="string"/>

      <!-- ::TODO:: use a units ontology -->
      <Group name="Quantity">
	<Attribute name="Value" type="number"/>
	<Attribute name="Unit" type="string"/>
      </Group>

      <Attribute name="Description" type="text" hint.lines="4" />
      
      <Link name="Annotation" to="Annotation" arity="many"> 
	<Comment>Additional metadata</Comment>
      </Link>

      <ValidationRuleSet>
	<ValidationRule failure_message="A TreatedSample must be linked to either one or more Samples, or one or more other TreatedSamples">
	  <Either>
	    <Condition has_value="Sample"/>
	    <Condition has_value="TreatedSample"/>
	  </Either>
	</ValidationRule>
	<ValidationRule failure_message="A TreatedSample must be linked to a TreatmentProtocol">
	  <Condition has_value="Treatment Details.TreatmentProtocol"/>
	</ValidationRule>
      </ValidationRuleSet>
 
    </ItemType>
 
   
     <!-- ====================================================================== -->

   
    <ItemType name="PreparationProtocol">

      <Comment>
	A PreparationProtocol describes a process used
	to prepare a Sample or TreatedSample
	for use in an Assay, for example dye-labelling,
	cell separation, and so on.
      </Comment>

      <Attribute name="Description" type="text" hint.lines="4" />
      
      <Link name="Annotation" to="Annotation" arity="many" />
      
       <!--
       <Attribute name="Title" type="string"/>
       
       <Attribute name="Type" type="string"/>
       
       <Attribute name="Description" type="text" hint.lines="4" />
       
       <DisplayColour hex="#00FF99"/>
       -->
       
    </ItemType>
    
    
    <!-- ====================================================================== -->


    <ItemType name="PreparedSample">
      
      <Comment>
	A PreparedSample is a Sample or TreatedSample
	which has been prepared for use in one or more Assays.
      </Comment>

      <DisplayColour hex="#00FF99"/>

      <Link to="Sample" arity="many">
	<Comment>
	  Which Sample(s) does this PreparedSample come from?

	  A PreparedSample can be linked to one or
          more Samples (unless it has already
          been linked to some TreatedSamples)
        </Comment>
      </Link>

      <Link to="TreatedSample" arity="many">
	<Comment>
	  Which TreatedSample(s) does this PreparedSample come from?
        </Comment>
      </Link>

      <Group name="Preparation Details">
	
	<Link to="PreparationProtocol" arity="one">
	  <Comment>
	    How was this PreparationProtocol prepared for for assaying?
	  </Comment>
	</Link>
	
	<Attribute name="Performed on" type="date" >
	  <Comment>
	    When was this action done?
	  </Comment>
	</Attribute>
	
	<Link name="Performed by" to="Person">
	  <Comment>
	    Who did this action?
	  </Comment>
	</Link>


      </Group>

     
      <Attribute name="Material Type" type="string"/>
      
      <!-- ::TODO:: use a units ontology -->
      <Group name="Quantity">
	<Attribute name="Value" type="number"/>
	<Attribute name="Unit" type="string"/>
      </Group>

      <Attribute name="Description" type="text" hint.lines="4" />
      
      <Link name="Annotation" to="Annotation" arity="many"> 
	<Comment>Additional metadata</Comment>
      </Link>
      

      <ValidationRuleSet>

	<ValidationRule failure_message="A PreparedSample must be linked to either one or more Samples, or one or more other TreatedSamples">
	  <Either>
	    <Condition has_value="Sample"/>
	    <Condition has_value="TreatedSample"/>
	  </Either>
	</ValidationRule>

	<ValidationRule failure_message="A PreparedSample must be linked to a PreparationProtocol">
	  <Condition has_value="Preparation Details.PreparationProtocol"/>
	</ValidationRule>

      </ValidationRuleSet>
 
    </ItemType>
    

    <!-- ====================================================================== -->

    
    <ItemType name="AssayEquipment">

      <Comment>
	AssayEquipment represents the collection of hardware
	and/or software that was used to perform an Assay
      </Comment>
      
      <Attribute name="Description" type="text" hint.lines="4" />
            
      <Link name="Hardware Details" to="Annotation" arity="many"/> 
      
      <Link name="Software Details" to="Annotation" arity="many"/> 
      
      <Link name="Annotation" to="Annotation" arity="many"> 
	<Comment>Additional metadata</Comment>
      </Link>
     
    </ItemType>
    
    
    <!-- ====================================================================== -->
    
    
    <ItemType name="AnalysisProtocol">

      <Comment type="pre">
	An AnalysisProtocol describes the process by which the
	results in an AssayDataSet were obtained from
	an Assay or from another AssayDataSet
      </Comment>

      <Attribute name="Description" type="text" hint.lines="4" />
      
      <Link name="Annotation" to="Annotation" arity="many">
	<Comment>Additional metadata</Comment>
      </Link>
      
      <Attribute name="Software Used" type="text" hint.lines="4" />
      
      <Attribute name="Algorithms Used" type="text" hint.lines="4" />

      <!--
      <Attribute name="Title" type="string"/>

      <Attribute name="Type" type="string"/>

      <Attribute name="Description" type="text" hint.lines="4" />

      <DisplayColour hex="#6600CC"/>
      -->

    </ItemType>
    
       
    <!-- ====================================================================== -->


    <ItemType name="AssayDataSet">

      <Comment type="pre">
	An AssayDataSet is a collection of results obtained by
	performing an Assay on one more	PreparedSamples, or by
	performing an analysis on one or more other AssayDataSets.
      </Comment>

      <Link to="AssayDataSetType" arity="one" />

      <!--
      <Attribute name="Data Format" type="string" /> 
      -->

      <Attribute name="Description" type="text" hint.lines="4" />

      <Link name="Annotation" to="Annotation" arity="many"> 
	<Comment>Additional metadata</Comment>
      </Link>
      
      <File name="Data File" />

      <DisplayColour hex="#6600CC"/>

      <Group name="Raw Data" >
       
	<Comment type="pre">
	  If this AssayDataSet represents data that were
          generated by analysis of an Assay, then these fields should
          be used.
        </Comment>

       <Link to="Assay" arity="many">
	 <Comment>
	   From which Assay(s) was this data acquired?
         </Comment>
       </Link>

 	<Link to="AnalysisProtocol" arity="one">
	  <Comment>
	    How was the data generated?
          </Comment>
	</Link>

	<Attribute name="Performed on" type="date" >
	  <Comment>
	    When was this data acquired?
	  </Comment>
	</Attribute>
	
	<Link name="Performed by" to="Person">
	  <Comment>
	    Who performed this action?
	  </Comment>
	</Link>

      </Group>

      <Group name="Derived Data" >

	<Comment type="pre">
	  If this AssayDataSet represents data that were
          derived from some AssayDataSet, then these fields should be used.
        </Comment>

	<Link to="AssayDataSet" arity="many">
	  <Comment>
	    Which other AssayDataSet(s) were used to derive this one?
          </Comment>
	</Link>

	<Link to="AnalysisProtocol" arity="one">
	  <Comment>
	    How was this data derived?
          </Comment>
	</Link>

	<Attribute name="Performed on" type="date" >
	  <Comment>
	    When was this data generated?
	  </Comment>
	</Attribute>
	
	<Link name="Performed by" to="Person">
	  <Comment>
	    Who performed this action?
	  </Comment>
	</Link>

      </Group>
	
      <ValidationRuleSet>
	<ValidationRule failure_message="An AssayDataSet must be linked to either one or more Assay, or one or more other AssayDataSets">
	  <Either>
	    <Condition has_value="Raw Data.Assay"/>
	    <Condition has_value="Derived Data.AssayDataSet"/>
	  </Either>
	</ValidationRule>
	<!-- ::TODO:: if has 'Raw Data.Assay then needs 'Raw Data.AnalysisProtocol' -->
	<!-- ::TODO:: if has 'Derived Data.AssayDataSet' then needs'Derived Data.AnalysisProtocol' -->
	<!-- ::TODO:: can only be either Raw or Dervied -->
      </ValidationRuleSet>
 

    </ItemType>
    
       
    <!-- ====================================================================== -->

    
    <ItemType name="AssayProtocol">

      <Comment>
	A AssayProtocol describes a process used
	to perform an Assay.
      </Comment>

      <Attribute name="Description" type="text" hint.lines="4" />
      
      <Link name="Annotation" to="Annotation" arity="many" />

      <!--
      <Attribute name="Title" type="string"/>
      
      <Attribute name="Type" type="string"/>

      <DisplayColour hex="#3333FF"/>
      -->
 
 
    </ItemType>
    
    
    <!-- ====================================================================== -->
    
    <!-- this can be used to build a simple ontology of assay types to
         classify the types of examinations available in a multi-omics study 
      -->
    
    <ItemType name="AssayType"> 

      <Link name="is_a" to="AssayType" arity="many"/>     

      <Attribute name="Description" type="text" hint.lines="4" />

    </ItemType>

    
    <!-- ====================================================================== -->
    
    <!-- this can be used to build a simple ontology of assay data set
         types to classify the types of data available in a multi-omics study 
      -->
    
    <ItemType name="AssayDataSetType"> 

      <Link name="is_a" to="AssayDataSetType" arity="many"/>     

      <Attribute name="Description" type="text" hint.lines="4" />

    </ItemType>


    <!-- ====================================================================== -->
    

    <ItemType name="Assay"> 
      <Comment>
	An Assay is any process by which one or more
	observations are made to determine the biomolecular properties
	of one or more PreparedSamples either by a
	simple test, such as measuring pH or taking a photgraph though
	a microscope, or by the application of a high-throughput
	mechanism such a microarray analysis or mass
	spectrometry.
      </Comment>

      <DisplayColour hex="#3333FF"/>

      <Link to="AssayType" arity="one" />
      
      <Attribute name="Description" type="text" hint.lines="4" />
      
      <Link to="AssayEquipment" arity="many">
	<Purpose>
	  What AssayEquipment was used for this Assay?
	</Purpose>
	<Comment>
	  An Assay must be linked to an
          AssayEquipment which describes the hardware and
          software used in that Assay
        </Comment>
      </Link>

      <Link to="PreparedSample" arity="many">
	<Purpose>
	  Which PreparedSample(s) were examined in this Assay?
	</Purpose>
 	<Comment>
	  An Assay must be linked to at least one
          PreparedSample
        </Comment>
      </Link>

      <Group name="Assay Details">
	
	<Link to="AssayProtocol" arity="one">
	  <Purpose>
	    Which AssayProtocol was followed for this Assay?
	  </Purpose>
	  <Comment>
	    An Assay must be linked to the
            AssayProtocol which describes how it
            was performed
          </Comment>
	</Link>

  	<Attribute name="Performed on" type="date" >
	  <Comment>
	    When was this assay carried out?
	  </Comment>
	</Attribute>
	
	<Link name="Performed by" to="Person">
	  <Comment>
	    Who did the action?
	  </Comment>
	</Link>

      </Group>

      <Link name="Annotation" to="Annotation" arity="many"> 
	<Comment>Additional metadata</Comment>
      </Link>

      <!--
      <Link to="AssayDataSet" arity="many">
	<Purpose>
	  What AssayDataSet(s) were produced by this Assay?
	</Purpose>
 	<Comment>
	  An Assay can be linked one or
          more AssayDataSets which store the results of
          that Assay
        </Comment>
      </Link>
      -->

      <ValidationRuleSet>

	<ValidationRule failure_message="An Assay must be linked to one or more AssayEquipments">
	  <Condition has_value="AssayEquipment"/>
	</ValidationRule>

	<ValidationRule failure_message="An Assay must be linked to one or more PreparedSamples">
	  <Condition has_value="PreparedSample"/>
	</ValidationRule>

	<ValidationRule failure_message="An Assay must be linked to an AssayProtocol">
	  <Condition has_value="Assay Details.AssayProtocol"/>
	</ValidationRule>

      </ValidationRuleSet>


    </ItemType>
    
       
    <!-- ====================================================================== -->

    
    <ItemType name="Study">
      <Comment>
	A Study is a set of related Assays
      </Comment>
      
      <Attribute name="Description" type="text" hint.lines="4" />
      
      <Attribute name="Purpose" type="text" hint.lines="4" />
      
      <Attribute name="Start Date" type="string" />
      
      <Attribute name="End Date" type="string" />
      
      <DisplayColour hex="#CC00CC"/>
      
      <Link to="Assay" arity="many">
	<Comment>
	  A Study can be linked any number of Assays
	</Comment>
      </Link>
      
      <Link name="Annotation" to="Annotation" arity="many"> 
	<Comment>Additional metadata</Comment>
      </Link>

    </ItemType>
    
       
    <!-- ====================================================================== -->


    <ItemType name="Investigation">

      <Comment>
	An Investigation is a collection of related Studies
	which share some common goal
      </Comment>

      <Attribute name="Title" type="text" hint.lines="4" />

      <Attribute name="Description" type="text" hint.lines="4" />
      
      <Attribute name="Hypothesis" type="text" hint.lines="4" />
      
      <Attribute name="Start Date" type="string" />
      
      <Attribute name="End Date" type="string" />
      
      <DisplayColour hex="#990033"/>

      <Link to="Study" arity="many">
 	<Comment>
	  An Investigation can be linked any number of Studies
	</Comment>
      </Link>

      <Link name="Annotation" to="Annotation" arity="many"> 
	<Comment>Additional metadata</Comment>
      </Link>

    </ItemType>
    
    
    <!-- ====================================================================== -->
    
    
  </ItemTypeList>
  
  
  <RootItemTypeList>
    <ItemType name="Investigation"/>
  </RootItemTypeList>
   

</OmixedDatabaseSchema>
