<?xml version="1.0" encoding="UTF-8"?>
<!--
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    #
    # Copyright (C) 2003-2007 Open Microscopy Environment
    #       Massachusetts Institute of Technology,
    #       National Institutes of Health,
    #       University of Dundee,
    #       University of Wisconsin at Madison
    #
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
<!--
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # Written by:  Andrew Patterson <ajpatterson@lifesci.dundee.ac.uk>
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
<xsd:schema xmlns="http://www.openmicroscopy.org/Schemas/SPW/2007-06" 
    targetNamespace="http://www.openmicroscopy.org/Schemas/SPW/2007-06" 
    xmlns:OME="http://www.openmicroscopy.org/Schemas/OME/2007-06" 
    xmlns:AML="http://www.openmicroscopy.org/Schemas/AnalysisModule/2007-06" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    version="2" 
    elementFormDefault="qualified">
    <xsd:import namespace="http://www.openmicroscopy.org/Schemas/OME/2007-06" schemaLocation="http://www.openmicroscopy.org/Schemas/OME/2007-06/ome.xsd"/>
    <xsd:import namespace="http://www.openmicroscopy.org/Schemas/AnalysisModule/2007-06" schemaLocation="http://www.openmicroscopy.org/Schemas/AnalysisModule/2007-06/AnalysisModule.xsd"/>

    <xsd:annotation>
        <xsd:documentation>
            Open Microscopy Environment
            Screen, Plate, and Well XML Schema
            Author:  Andrew J Patterson
        </xsd:documentation>
    </xsd:annotation>

    <xsd:element name="Plate">
        <xsd:annotation>
            <xsd:documentation>
                This element identifies microtiter plates within a screen.
                A plate can belong to more than one screen.
                The Screen(s) that a plate belongs to are specified by the ScreenRef element.
                The Plate ID and Name attributes are required.
				The Wells in a plate are numbers from the top-left corner in a grid starting at zero.
				i.e The top-left well of a plate is index (0,0)
            </xsd:documentation>
        </xsd:annotation>
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="ScreenRef" minOccurs="0" maxOccurs="unbounded"/>
                <xsd:element ref="Well" minOccurs="0" maxOccurs="unbounded"/>
            </xsd:sequence>
            <xsd:attribute name="ID" use="required" type="PlateID"/>
            <xsd:attribute name="Name" use="required" type="xsd:string">
	            <xsd:annotation>
	                <xsd:documentation>
			            The Name identifies the plate to the user.  It is used much like the 
					 	ID, and so must be unique within the document.
	                </xsd:documentation>
	            </xsd:annotation>     	
			</xsd:attribute>
            <xsd:attribute name="Description" type="xsd:string"/>
            <xsd:attribute name="Status" type="xsd:string">
	            <xsd:annotation>
	                <xsd:documentation>
		            	A textual annotation of the current state of the plate with respect to the 
						experiment work-flow; e.g.
						1. Seed cell: done; 2. Transfection: done;	3. Gel doc: todo.
	                </xsd:documentation>
	            </xsd:annotation>
			</xsd:attribute>
            <xsd:attribute name="ExternalIdentifier" type="xsd:string">
                <xsd:annotation>
                    <xsd:documentation>
                        The ExternalIdentifier attribute may contain a reference to an external database.
                    </xsd:documentation>
                </xsd:annotation>     	
			</xsd:attribute>
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="PlateRef">
        <xsd:annotation>
            <xsd:documentation>
                The PlateRef element is a reference to a Plate element.
                Screen elements may have one or more PlateRef elements to define the plates that are part of the screen.
                Plates may belong to more than one screen.
            </xsd:documentation>
        </xsd:annotation>
        <xsd:complexType>
            <xsd:complexContent>
                <xsd:extension base="OME:Reference">
                    <xsd:attribute name="ID" use="required" type="PlateID"/>
                </xsd:extension>
            </xsd:complexContent>
        </xsd:complexType>
    </xsd:element>

    <xsd:simpleType name="PlateID">
        <xsd:restriction base="OME:LSID">
            <xsd:pattern value="(urn:lsid:([\w\-\.]+\.[\w\-\.]+)+:Plate:\S+)|(Plate:\S+)"/>
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:element name="Reagent">
        <xsd:annotation>
            <xsd:documentation>
                Reagent is used to describe a chemical or some other physical experimental parameter.
            </xsd:documentation>
        </xsd:annotation>      
        <xsd:complexType>
            <xsd:attribute name="ID" use="required" type="ReagentID"/>
            <xsd:attribute name="Description" type="xsd:string">
                <xsd:annotation>
                    <xsd:documentation>
						A long description for the reagent
                    </xsd:documentation>
                </xsd:annotation>                   
            </xsd:attribute>
            <xsd:attribute name="Name" type="xsd:string">
                <xsd:annotation>
                    <xsd:documentation>
						A short name for the reagent
                    </xsd:documentation>
                </xsd:annotation>                
            </xsd:attribute>
            <xsd:attribute name="ReagentIdentifier" type="xsd:string">
                <xsd:annotation>
                    <xsd:documentation>
                        This is a reference to an external (to OME) representation of the Reagent.
                        It serves as a foreign key into an external database. - It is sometimes refereed to as ExternalIdentifier.
                    </xsd:documentation>
                </xsd:annotation>      
            </xsd:attribute>
       </xsd:complexType>
    </xsd:element>

    <xsd:element name="ReagentRef">
        <xsd:complexType>
            <xsd:complexContent>
                <xsd:extension base="OME:Reference">
                    <xsd:attribute name="ID" use="required" type="ReagentID"/>
                </xsd:extension>
            </xsd:complexContent>
        </xsd:complexType>
    </xsd:element>
    
    <xsd:simpleType name="ReagentID">
        <xsd:restriction base="OME:LSID">
            <xsd:pattern value="(urn:lsid:([\w\-\.]+\.[\w\-\.]+)+:Reagent:\S+)|(Reagent:\S+)"/>
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:element name="Screen">
        <xsd:annotation>
            <xsd:documentation>
                The Screen element is a grouping for Plates.
                The required attribute is the Screen's Name and ID - both must be unique within the document.
                The Screen element may contain an ExternalRef attribute that refers to an external database.
                A description of the screen may be specified in the Description element.
                Screens may contain overlapping sets of Plates i.e.  Screens and Plates have a many-to-many relationship.
                Plates contain one or more ScreenRef elements to specify what screens they belong to.
            </xsd:documentation>
        </xsd:annotation>
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="OME:Description" minOccurs="0"/>
                <xsd:element ref="Reagent" minOccurs="0" maxOccurs="unbounded"/>
                <xsd:element ref="PlateRef" minOccurs="0" maxOccurs="unbounded"/>
                <xsd:element ref="ScreenAcquisition" minOccurs="0" maxOccurs="unbounded"/>
            </xsd:sequence>
            <xsd:attribute name="ID" use="required" type="ScreenID"/>
            <xsd:attribute name="Name" use="required" type="xsd:string"/>
            <xsd:attribute name="ProtocolIdentifier" type="xsd:string">
			        <xsd:annotation>
			            <xsd:documentation>
							A pointer to an externally defined protocol, usually in a screening database.
			            </xsd:documentation>
			        </xsd:annotation>
				</xsd:attribute>	
            <xsd:attribute name="ProtocolDescription" type="xsd:string">
			        <xsd:annotation>
			            <xsd:documentation>
							A description of the screen protocol; may contain very detailed information to 
							reproduce some of that found in a screening database.
			            </xsd:documentation>
			        </xsd:annotation>
				</xsd:attribute>	
            <xsd:attribute name="ReagentSetDescription" type="xsd:string">
			        <xsd:annotation>
			            <xsd:documentation>
							A description of the set of reagents; may contain very detailed information to
							reproduce some of that information found in a screening database.
			            </xsd:documentation>
			        </xsd:annotation>
				</xsd:attribute>	
            <xsd:attribute name="ReagentSetIdentifier" type="xsd:string">
			        <xsd:annotation>
			            <xsd:documentation>
							A pointer to an externally defined set of reagents, usually in a screening 
							database/automation database.
			            </xsd:documentation>
			        </xsd:annotation>
				</xsd:attribute>	
            <xsd:attribute name="Type" type="xsd:string">
		        <xsd:annotation>
		            <xsd:documentation>
						A human readable identifier for the screen type; e.g. RNAi, cDNA, SiRNA, etc.
						This string is likely to become an enumeration in future releases.
		            </xsd:documentation>
		        </xsd:annotation>
			</xsd:attribute>	
        </xsd:complexType>
    </xsd:element>

    <xsd:simpleType name="ScreenID">
        <xsd:restriction base="OME:LSID">
            <xsd:pattern value="(urn:lsid:([\w\-\.]+\.[\w\-\.]+)+:Screen:\S+)|(Screen:\S+)"/>
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:element name="ScreenRef">
        <xsd:annotation>
            <xsd:documentation>
                The ScreenRef element is a reference to a Screen element.
                Plate elements may have one or more ScreenRef elements to define the screen that a plate belongs to.
                Plates may belong to more than one screen.
            </xsd:documentation>
        </xsd:annotation>
        <xsd:complexType>
            <xsd:complexContent>
                <xsd:extension base="OME:Reference">
                    <xsd:attribute name="ID" use="required" type="ScreenID"/>
                </xsd:extension>
            </xsd:complexContent>
        </xsd:complexType>
    </xsd:element>
    
    <xsd:element name="ScreenAcquisition">
        <xsd:annotation>
            <xsd:documentation>
                ScreenAcquisition is used to describe a single acquisition run for a screen.
                Since Screens are abstract, this object is used to record the set of images
                acquired in a single acquisition run.  The Images for this run are linked
                to ScreenAcquisition through WellSample.
            </xsd:documentation>
        </xsd:annotation>     
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="WellSampleRef" minOccurs="0" maxOccurs="unbounded"/>
            </xsd:sequence>
            <xsd:attribute name="ID" use="required" type="ScreenAcquisitionID"/>
            <xsd:attribute name="EndTime" type="xsd:dateTime">
                <xsd:annotation>
                    <xsd:documentation>
						Time when the last image of this acquisition was collected
                    </xsd:documentation>
                </xsd:annotation>     
            </xsd:attribute>
            <xsd:attribute name="StartTime" type="xsd:dateTime">
                <xsd:annotation>
                    <xsd:documentation>
						Time when the first image of this acquisition was collected
                    </xsd:documentation>
                </xsd:annotation>     
            </xsd:attribute>
        </xsd:complexType>
    </xsd:element>

    <xsd:simpleType name="ScreenAcquisitionID">
        <xsd:restriction base="OME:LSID">
            <xsd:pattern value="(urn:lsid:([\w\-\.]+\.[\w\-\.]+)+:ScreenAcquisition:\S+)|(ScreenAcquisition:\S+)"/>
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:element name="Well">
        <xsd:annotation>
            <xsd:documentation>
                A Well is a component of the Well/Plate/Screen construct to describe screening applications.
                A Well has a number of WellSample elements that link to the Images collected in this well.
 				The ReagentRef links any Reagents that were used in this Well. A well is part of one or more Plates.
				The origin for the row and column identifiers is the top left corner of the plate starting at zero.
				i.e The top left well of a plate is index (0,0)
            </xsd:documentation>
        </xsd:annotation> 
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="WellSample" minOccurs="0" maxOccurs="unbounded"/>
                <xsd:element ref="ReagentRef" minOccurs="0"/>
            </xsd:sequence>
            <xsd:attribute name="ID" use="required" type="WellID"/>
            <xsd:attribute name="Column" type="xsd:integer">
                <xsd:annotation>
                    <xsd:documentation>
						This is the column index of the well, the origin is the top left corner of the plate
						with the first column of cells being column zero. i.e top left is (0,0)
                    </xsd:documentation>
                </xsd:annotation>     
            </xsd:attribute>
            <xsd:attribute name="ExternalDescription" type="xsd:string">
                <xsd:annotation>
                    <xsd:documentation>
 						A description of the externally defined identifier for this plate.
                   </xsd:documentation>
                </xsd:annotation>                 
            </xsd:attribute>
            <xsd:attribute name="ExternalIdentifier" type="xsd:string">
                <xsd:annotation>
                    <xsd:documentation>
                        The ExternalIdentifier attribute may contain a reference to an external database.
                    </xsd:documentation>
                </xsd:annotation>           
            </xsd:attribute>
            <xsd:attribute name="Row" type="xsd:integer">
                <xsd:annotation>
                    <xsd:documentation>
						This is the row index of the well, the origin is the top left corner of the plate
						with the first row of wells being row zero. i.e top left is (0,0)
                    </xsd:documentation>
                </xsd:annotation>         
            </xsd:attribute>
            <xsd:attribute name="Type" type="xsd:string">
                <xsd:annotation>
                    <xsd:documentation>
						A human readable identifier for the screening status. 
						e.g. empty, positive control, negative control, control, experimental, etc.
						This string is likely to become an enumeration in future releases.
                    </xsd:documentation>
                </xsd:annotation>     
            </xsd:attribute>
        </xsd:complexType>
    </xsd:element>

    <xsd:simpleType name="WellID">
        <xsd:restriction base="OME:LSID">
            <xsd:pattern value="(urn:lsid:([\w\-\.]+\.[\w\-\.]+)+:Well:\S+)|(Well:\S+)"/>
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:element name="WellSample">
        <xsd:annotation>
            <xsd:documentation>
				WellSample is an individual image that has been captured within a Well.
            </xsd:documentation>
        </xsd:annotation> 
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="ImageRef" minOccurs="0"/>
            </xsd:sequence>
            <xsd:attribute name="ID" use="required" type="WellSampleID"/>
            <xsd:attribute name="Index" type="xsd:integer">
                <xsd:annotation>
                    <xsd:documentation>
						This is the main link to the core Image element
                    </xsd:documentation>
                </xsd:annotation>     
            </xsd:attribute>
            <xsd:attribute name="PosX" type="xsd:float">
                <xsd:annotation>
                    <xsd:documentation>
						The X position of the image within the well
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:attribute>
            <xsd:attribute name="PosY" type="xsd:float">
                <xsd:annotation>
                    <xsd:documentation>
						The Y position of the image within the well
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:attribute>
            <xsd:attribute name="Timepoint" type="xsd:integer">
                <xsd:annotation>
                    <xsd:documentation>
						The time-point at which the image started to be collected
                    </xsd:documentation>
                </xsd:annotation>     
            </xsd:attribute>
        </xsd:complexType>
    </xsd:element>

    <xsd:simpleType name="WellSampleID">
        <xsd:restriction base="OME:LSID">
            <xsd:pattern value="(urn:lsid:([\w\-\.]+\.[\w\-\.]+)+:WellSample:\S+)|(WellSample:\S+)"/>
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:element name="ImageRef">
        <xsd:annotation>
            <xsd:documentation>
                The ImageRef element is a reference to a OME:Image element.
            </xsd:documentation>
        </xsd:annotation>
        <xsd:complexType>
            <xsd:complexContent>
                <xsd:extension base="OME:Reference">
                    <xsd:attribute name="ID" use="required" type="OME:ImageID"/>
                </xsd:extension>
            </xsd:complexContent>
        </xsd:complexType>
    </xsd:element>
    
    <xsd:element name="WellSampleRef">
        <xsd:annotation>
            <xsd:documentation>
                The WellSampleRef element is a reference to a WellSample element.
            </xsd:documentation>
        </xsd:annotation>
        <xsd:complexType>
            <xsd:complexContent>
                <xsd:extension base="OME:Reference">
                    <xsd:attribute name="ID" use="required" type="WellSampleID"/>
                </xsd:extension>
            </xsd:complexContent>
        </xsd:complexType>
    </xsd:element>
    
</xsd:schema>
