<?xml version="1.0"?>

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:cis="http://zlab.bu.edu/schema/cisml"
>

<xsl:output method="html" />

<!-- A stylesheet to generate a text report of pvalues for patterns scanned over a group of sequences-->

<xsl:template match="/">
	<html>
		<head>
			<title>Sequence Analysis by <xsl:value-of select="/cis:cis-element-search/cis:program-name"/></title>
			<link href="cisml.css" rel="stylesheet" type="text/css"></link>
		</head> 
		<body>
			<h2 align="center">Sequence Analysis with <xsl:value-of select="/cis:cis-element-search/cis:program-name"/></h2>
				<xsl:choose>
					<xsl:when test="//cis:multi-pattern-scan">
						<xsl:for-each select="//cis:multi-pattern-scan">
							<!-- Loop through each pattern group -->
							<xsl:sort select="@pvalue"/>
							<h2>Pattern Group #<xsl:value-of select="position()"/></h2>
							<h2>Group P-value: <xsl:value-of select="@pvalue"/></h2>
							<table>
								<tr><th>Pattern ID</th><th>P-value</th><th>Pattern Name</th></tr>
								<xsl:for-each select="./cis:pattern">
									<!-- Loop through each pattern in this pattern group -->
									<xsl:sort select="@pvalue" data-type="number" order="ascending" />
									<tr>
									<td><xsl:value-of select="@accession" /></td>
									<td><xsl:value-of select="@pvalue"/></td>
									<td><xsl:value-of select="@name"/></td>
									</tr>
								</xsl:for-each>
							</table>
						</xsl:for-each>
					</xsl:when>
					<xsl:otherwise>
						<table>
						<tr><th>Pattern ID</th><th>P-value</th><th>Pattern Name</th></tr>
						<xsl:for-each select="//cis:pattern">
							<!-- Loop through each pattern -->
							<xsl:sort select="@pvalue" data-type="number" order="ascending" />
							<tr>
								<td><xsl:value-of select="@accession" /></td>
								<td><xsl:value-of select="@pvalue"/></td>
								<td><xsl:value-of select="@name"/></td>
							</tr>
						</xsl:for-each>
						</table>
					</xsl:otherwise>
				</xsl:choose>
		</body>
	</html>
</xsl:template>

</xsl:stylesheet>







