<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
 
<!-- Root Node -->
<xsl:template name="root" match="/Stanford_Algorithm_Interpretation">
<xsl:text disable-output-escaping="yes">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;</xsl:text>
		<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
			<head>
				<title>HIVdb: Genotypic Resistance Interpretation Algorithm</title>
				<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
				<meta content="MSHTML 6.00.2900.2604" name="GENERATOR"/>
				<link href="http://hivdb6.stanford.edu/asi/deployed/css/hivdb.css" type="text/css" rel="stylesheet"/>
				<style type="">TD {font-size:10pt} </style>
			</head>
			<body>
				<xsl:call-template name="header"/>
				<xsl:apply-templates select="//success"/>
				<xsl:call-template name="footer"/>
			</body>
		</html>
	</xsl:template>

	<xsl:template name="success" match="success">
				<xsl:apply-templates select="summary"/>
				<xsl:apply-templates select="SequenceQA"/>
				<!-- <xsl:value-of select="name(.)"/> -->
				<xsl:call-template name="drugResistanceInterpretation"/>
				<xsl:call-template name="printScoringSection"/>
	</xsl:template>

	<!-- Document header -->
	<xsl:template name="header">
		<a id="top"/>
		<div id="masthead">
			<a href="http://hivdb.stanford.edu/index.html">
				<img alt="Stanford University HIV Drug Resistance Database - A curated public database designed to represent, store, and analyze the divergent forms of data underlying HIV drug resistance." src="http://hivdb6.stanford.edu/asi/deployed/images/header.gif" border="0" height="53" width="680"/>
			</a>
		</div>
		<div id="topnav">
			<a href="http://hivdb.stanford.edu/index.html">
				<img alt="Home" src="http://hivdb6.stanford.edu/asi/deployed/images/home.gif" border="0" height="19" width="42"/>
			</a>
			<a href="http://hivdb.stanford.edu/pages/genotype-rx.html">
				<img alt="Genotype-RX" src="http://hivdb6.stanford.edu/asi/deployed/images/btn_genotype-rx.gif" border="0" height="19" width="100"/>
			</a>
			<a href="http://hivdb.stanford.edu/pages/genotype-phenotype.html">
				<img alt="Genotype-Pheno" src="http://hivdb6.stanford.edu/asi/deployed/images/btn_genotype-ph.gif" border="0" height="19" width="128"/>
			</a>
			<a href="http://hivdb.stanford.edu/pages/genotype-clinical.html">
				<img alt="Genotype-Clinical" src="http://hivdb6.stanford.edu/asi/deployed/images/btn_genotype-cl.gif" border="0" height="19" width="146"/>
			</a>
			<a href="http://hivdb6.stanford.edu/asi/deployed/HIVdb.html">
				<img alt="HIVdb Program" src="http://hivdb6.stanford.edu/asi/deployed/images/hivdb_nav_button.gif" border="0" height="19" width="116"/>
			</a>
		</div>
		<h2 class="submain2">HIVdb: Genotypic Resistance Interpretation Algorithm</h2>
		<br/>
		<div class="subHeader1">SeqID:    Date: 12-May-2006</div>
		<br/>
	</xsl:template>
	
	<!-- Document footer -->
	<xsl:template name="footer">
		<div class="dotted"/>
		<table id="botnav">
			<tbody>
				<tr>
					<td>
						<h4>The Team</h4>
						<ul>
							<li>
								<a href="http://hivdb.stanford.edu/pages/contactUs.html">Who We Are &amp; How to Contact Us</a>
							</li>
							<li>
								<a href="http://hivdb.stanford.edu/pages/publications.html">Publications</a>
							</li>
							<li>
								<a href="#">Collaborators</a>
							</li>
							<li>
								<a href="http://hivdb.stanford.edu/pages/acknowledgements.html">Acknowledgements</a>
							</li>
						</ul>
					</td>
					<td class="spacer"> </td>
					<td>
						<h4>The Data</h4>
						<ul>
							<li>
								<a href="http://hivdb.stanford.edu/pages/documents.html">User Guide &amp; Database Documents</a>
							</li>
							<li>
								<a href="http://hivdb.stanford.edu/cgi-bin/Summary.cgi">Database Statistics</a>
							</li>
							<li>
								<a href="http://hivdb.stanford.edu/pages/links.html">HIV Related Links</a>
							</li>
							<li>
								<a href="http://hivdb.stanford.edu/pages/resources.html">Additional Resources</a>
							</li>
						</ul>
					</td>
				</tr>
			</tbody>
		</table>
		<div id="footer">© 1998-2005. All Rights Reserved.</div>
	</xsl:template>
	
	<xsl:template name="printScoringSection">
		<table class="textDescBordered" cellpadding="1" cellspacing="0" width="670">
			<tbody>
				<tr>
					<td>
						<table>
							<tbody>
								<tr>
									<td>
										<font face="ARIAL" size="3">
											<b>Mutation Scoring</b>
										</font>
									</td>
								</tr>
								<tr>
									<td>
										<table width="600">
											<tbody>
												<tr>
													<xsl:if test="drugScores//drug[@type='PI']">
														<td valign="top">
															<!-- Insert PR Scoring table width=240-->
															<xsl:call-template name="printScoreTable">
																<xsl:with-param name="drugList" select="drugScores//drug[@type='PI']"/>
																<xsl:with-param name="mutationList" select="PR_mutations//mutation[@classification='PI_MAJOR'] | PR_mutations//mutation[@classification='PI_MINOR']"/>
																<xsl:with-param name="tableWidth">240</xsl:with-param>
															</xsl:call-template>
														</td>
													</xsl:if>
													<xsl:if test="drugScores//drug[@type='NRTI'] | drugScores//drug[@type='NNRTI']">
														<td valign="top">
															<!-- Insert RT Scoring table width=240-->
															<xsl:call-template name="printScoreTable">
																<xsl:with-param name="drugList" select="drugScores//drug[@type='NRTI'] | drugScores//drug[@type='NNRTI']"/>
																<xsl:with-param name="mutationList" select="RT_mutations//mutation[@classification='NRTI'] | RT_mutations//mutation[@classification='NNRTI']"/>
																<xsl:with-param name="tableWidth">380</xsl:with-param>
															</xsl:call-template>
														</td>
													</xsl:if>
												</tr>
											</tbody>
										</table>
									</td>
								</tr>
							</tbody>
						</table>
					</td>
				</tr>
			</tbody>
		</table>
	</xsl:template>
	<!-- Sequence Quality Assessment info. -->
	<xsl:template match="SequenceQA">
		<div class="subHeader1">Sequence Quality Assessment</div>
		<xsl:if test="../summary/PR/present='true'">
			<table border="0" cellpadding="0" cellspacing="0">
				<tbody>
					<tr>
						<td align="left">
							<font face="ARIAL" size="2"/>
							<table class="data" cellpadding="1" cellspacing="0" width="300">
								<tbody>
									<tr>
										<td align="center" width="50">
											<font face="ARIAL" size="3">
												<b>Gene</b>
											</font>
										</td>
										<td align="center" width="120">
											<font face="ARIAL" size="3">
												<b>QA Problem</b>
											</font>
										</td>
										<td align="center" width="50">
											<font face="ARIAL" size="3">
												<b>Codons</b>
											</font>
										</td>
									</tr>
									<tr>
										<td>
											<font face="ARIAL" size="2">PR</font>
										</td>
										<td>
											<font face="ARIAL" size="2"> Stop Codons, Frame Shifts:</font>
										</td>
										<td align="center">
											<font face="ARIAL" size="2">
												<xsl:call-template name="genList">
													<xsl:with-param name="nodeName" select="PR//stop | PR//frameshift/AAPosition"/>
												</xsl:call-template>
											</font>
										</td>
									</tr>
									<tr>
										<td>
											<font face="ARIAL" size="2">PR</font>
										</td>
										<td>
											<font face="ARIAL" size="2"> B,D,H,V,N:</font>
										</td>
										<td align="center">
											<font face="ARIAL" size="2">
												<xsl:call-template name="genList">
													<xsl:with-param name="nodeName" select="PR//ambiguous"/>
												</xsl:call-template>
											</font>
										</td>
									</tr>
									<tr>
										<td>
											<font face="ARIAL" size="2">PR</font>
										</td>
										<td>
											<font face="ARIAL" size="2"> Unusual Residues:</font>
										</td>
										<td align="center">
											<font face="ARIAL" size="2">
												<xsl:call-template name="genList">
													<xsl:with-param name="nodeName" select="PR//atypical"/>
												</xsl:call-template>
											</font>
										</td>
									</tr>
								</tbody>
							</table>
						</td>
						<td width="2%"/>
						<td valign="bottom">
						<xsl:if test="PR/image/@href">
							<img alt=""> <xsl:attribute name="src"><xsl:value-of select="PR/image/@href"/></xsl:attribute></img>
						</xsl:if>
						</td>
					</tr>
				</tbody>
			</table>
		</xsl:if>
		<xsl:if test="../summary/RT/present='true'">
			<table border="0" cellpadding="0" cellspacing="0">
				<tbody>
					<tr>
						<td align="left">
							<font face="ARIAL" size="2">		</font>
							<table class="data" cellpadding="1" cellspacing="0" width="300">
								<tbody>
									<tr>
										<td align="center" width="50">
											<font face="ARIAL" size="3">
												<b>Gene</b>
											</font>
										</td>
										<td align="center" width="120">
											<font face="ARIAL" size="3">
												<b>QA Problem</b>
											</font>
										</td>
										<td align="center" width="50">
											<font face="ARIAL" size="3">
												<b>Codons</b>
											</font>
										</td>
									</tr>
									<tr>
										<td>
											<font face="ARIAL" size="2">RT</font>
										</td>
										<td>
											<font face="ARIAL" size="2"> Stop Codons, Frame Shifts:</font>
										</td>
										<td align="center">
											<font face="ARIAL" size="2">
												<xsl:call-template name="genList">
													<xsl:with-param name="nodeName" select="RT//stop | RT//frameshift/AAPosition"/>
												</xsl:call-template>
											</font>
										</td>
									</tr>
									<tr>
										<td>
											<font face="ARIAL" size="2">RT</font>
										</td>
										<td>
											<font face="ARIAL" size="2"> B,D,H,V,N:</font>
										</td>
										<td align="center">
											<font face="ARIAL" size="2">
												<xsl:call-template name="genList">
													<xsl:with-param name="nodeName" select="RT//ambiguous"/>
												</xsl:call-template>
											</font>
										</td>
									</tr>
									<tr>
										<td>
											<font face="ARIAL" size="2">RT</font>
										</td>
										<td>
											<font face="ARIAL" size="2"> Unusual Residues:</font>
										</td>
										<td align="center">
											<font face="ARIAL" size="2">
												<xsl:call-template name="genList">
													<xsl:with-param name="nodeName" select="RT//atypical"/>
												</xsl:call-template>
											</font>
										</td>
									</tr>
								</tbody>
							</table>
						</td>
						<td width="2%"/>
						<td valign="bottom">
							<xsl:if test="RT/image/@href">
								<img alt=""><xsl:attribute name="src"><xsl:value-of select="RT/image/@href"/></xsl:attribute></img>
							</xsl:if>
						</td>
					</tr>
				</tbody>
			</table>
		</xsl:if>
		<table class="textDesc" cellpadding="0" cellspacing="0" width="670">
			<tbody>
				<tr>
					<td>
						<font face="ARIAL" size="1">    <em>Blue lines indicate differences from 
consensus B; tall blue lines indicate sites associated with drug resistance.<br/>    Red lines indicate QA problems.</em>
						</font>
						<br/>
					</td>
				</tr>
			</tbody>
		</table>
		<br/>
	</xsl:template>
	<!-- Summary info. -->
	<xsl:template match="summary">
		<div class="subHeader1">Summary Data</div>
		<!-- Reading Frameshift Info.-->
		<table class="textDesc" cellpadding="1" cellspacing="0">
			<tbody>
				<tr>
					<td>
						<xsl:if test="PR/present= 'true'">
							<font face="ARIAL" size="2">
								<b>Sequence includes PR: codons: <xsl:value-of select="PR/firstAA"/>  - <xsl:value-of select="PR/lastAA"/>
								</b>
							</font>
							<br/>
						</xsl:if>
						<xsl:if test="RT/present= 'true'">
							<font face="ARIAL" size="2">
								<b>Sequence includes RT: codons: <xsl:value-of select="RT/firstAA"/> - <xsl:value-of select="RT/lastAA"/>
								</b>
							</font>
							<br/>
						</xsl:if>
					</td>
				</tr>
			</tbody>
		</table>
		<table class="textDesc" cellpadding="1" cellspacing="0" width="670">
			<tbody>
				<tr>
					<td>
						<font face="ARIAL" size="2">
							<xsl:choose>
								<xsl:when test="RT//insertion | PR//insertion | ../SequenceQA//frameshift">
									<xsl:if test="PR//insertion">
										<xsl:call-template name="printInsertions">
											<xsl:with-param name="insertions" select="PR//insertion"/>
										</xsl:call-template>
									</xsl:if>
									<xsl:if test="RT//insertion">
										<xsl:call-template name="printInsertions">
											<xsl:with-param name="insertions" select="RT//insertion"/>
										</xsl:call-template>
									</xsl:if>
								</xsl:when>
								<xsl:otherwise>
									<em>There are no insertions or deletions</em>
								</xsl:otherwise>
							</xsl:choose>
						</font>
					</td>
				</tr>
			</tbody>
		</table>
		<table class="textDesc" cellpadding="1" cellspacing="0" width="670">
				<tr>
					<td>
						<xsl:if test=" (../SequenceQA//frameshift)">
							<xsl:call-template name="frameshift"/>
						</xsl:if>
					</td>
				</tr>
		</table>
					

		<table class="textDesc" cellpadding="1" cellspacing="0" width="670">
			<tbody>
				<tr>
					<td>
						<em>
							<font face="arial" size="2">
Subtype and % similarity to closest reference isolate:
</font>
						</em>
						<ol>
							<xsl:if test="PR/subtype">
								<li>
									<em>
										<font face="arial" size="2">PR: <xsl:value-of select="PR/subtype/@type"/> (<xsl:value-of select="PR/subtype/@percentSimilarity"/>%)</font>
									</em>
								</li>
							</xsl:if>
							<xsl:if test="RT/subtype">
								<li>
									<em>
										<font face="arial" size="2">RT: <xsl:value-of select="RT/subtype/@type"/> (<xsl:value-of select="RT/subtype/@percentSimilarity"/>%)</font>
									</em>
								</li>
							</xsl:if>
						</ol>
					</td>
				</tr>
			</tbody>
		</table>
	</xsl:template>
	
	<!-- Insertion info. -->
	<xsl:template name="printInsertions">
		<xsl:param name="insertions"/>
		<xsl:for-each select="$insertions">
  <b><xsl:value-of select="name(parent::*)"/> AA Insertion:  </b>codon <xsl:value-of select="./@position"/>      AA: <xsl:value-of select="./@translatedNA"/>      NA: <xsl:value-of select="./@nucleicAcid"/>
		 <xsl:if test="not(position()=last())"><br/></xsl:if>  
 		</xsl:for-each>
		
		<ol>
			<xsl:for-each select="SequenceQA//frameshift">
				<li>Shift of length <xsl:value-of select="length"/> nucleic acids at codon <xsl:value-of select="AAPosition"/> in <xsl:value-of select="name(..)"/>
				</li>
				<br/>
				<pre>
					<xsl:value-of select="rawAlignBlock"/>
				</pre>
			</xsl:for-each>
		</ol>
	</xsl:template>
	
	<!-- Drug Resistance Interpretation section -->
	<xsl:template name="drugResistanceInterpretation">
		<!-- PR -->
		<xsl:if test="PR_mutations">
			<div class="subHeader1">Drug Resistance Interpretation</div>
			<table class="textDescBordered" border="0" cellpadding="1" cellspacing="0" width="670">
				<tbody>
					<tr>
						<td>
							<!-- PIMAJOR, PIMINOR, OTHER mutations -->
							<table width="600">
								<tbody>
									<tr>
										<td valign="top" width="35%">
											<font face="ARIAL" size="2">
												<b>PI Major Resistance Mutations:</b>
											</font>
										</td>
										<td width="75%">
											<font face="ARIAL" size="2">
												<b>
													<xsl:call-template name="genList">
														<xsl:with-param name="nodeName" select="PR_mutations//mutation[@classification='PI_MAJOR']"/>
													</xsl:call-template>
												</b>
											</font>
										</td>
									</tr>
									<tr>
										<td valign="top">
											<font face="ARIAL" size="2">
												<b>PI Minor Resistance Mutations:</b>
											</font>
										</td>
										<td>
											<font face="ARIAL" size="2">
												<b>
													<xsl:call-template name="genList">
														<xsl:with-param name="nodeName" select="PR_mutations//mutation[@classification='PI_MINOR']"/>
													</xsl:call-template>
												</b>
											</font>
										</td>
									</tr>
									<tr>
										<td valign="top">
											<font face="ARIAL" size="2">
												<b>PR Other Mutations:</b>
											</font>
										</td>
										<td>
											<font face="ARIAL" size="2">
												<xsl:call-template name="genList">
													<xsl:with-param name="nodeName" select="PR_mutations//mutation[@classification='OTHER']"/>
												</xsl:call-template>
											</font>
										</td>
									</tr>
								</tbody>
							</table>
							<br/>
							<table width="400">
								<tbody>
									<tr>
										<td/>
										<td>
											<font face="ARIAL" size="2">
												<b>Protease Inhibitors</b>
											</font>
										</td>
									</tr>
									<xsl:call-template name="printResistanceLevel">
										<xsl:with-param name="nodeList" select="drugScores//drug[@type='PI']"/>
										<xsl:with-param name="width">10</xsl:with-param>
									</xsl:call-template>
								</tbody>
							</table>
						</td>
					</tr>
				</tbody>
			</table>
			<xsl:if test="comments//comment[substring(@id,1, 2)='PR']">
				<table class="textDescBordered" cellpadding="1" cellspacing="0" width="670">
					<tbody>
						<tr>
							<td>
								<font face="ARIAL" size="3">
									<b>PR Comments</b>
								</font>
								<br/>
								<xsl:call-template name="printBulletList">
									<xsl:with-param name="nodeList" select="comments//comment[substring(@id,1, 2)='PR']"/>
								</xsl:call-template>
							</td>
						</tr>
					</tbody>
				</table>
			</xsl:if>
		</xsl:if>
		<!-- RT -->
		<xsl:if test="RT_mutations">
			<br/>
			<div class="subHeader1">Drug Resistance Interpretation</div>
			<table class="textDescBordered" border="0" cellpadding="1" cellspacing="0" width="670">
				<tbody>
					<tr>
						<td>
							<table width="600">
								<tbody>
									<tr>
										<td valign="top" width="35%">
											<font face="ARIAL" size="2">
												<b>NRTI Resistance Mutations:</b>
											</font>
										</td>
										<td width="75%">
											<font face="ARIAL" size="2">
												<b>
													<xsl:call-template name="genList">
														<xsl:with-param name="nodeName" select="RT_mutations//mutation[@classification='NRTI']"/>
													</xsl:call-template>
												</b>
											</font>
										</td>
									</tr>
									<tr>
										<td valign="top">
											<font face="ARIAL" size="2">
												<b>NNRTI Resistance Mutations:</b>
											</font>
										</td>
										<td>
											<font face="ARIAL" size="2">
												<xsl:call-template name="genList">
													<xsl:with-param name="nodeName" select="RT_mutations//mutation[@classification='NNRTI']"/>
												</xsl:call-template>
												<br/>
											</font>
										</td>
									</tr>
									<tr>
										<td valign="top">
											<font face="ARIAL" size="2">
												<b>RT Other Mutations:</b>
											</font>
										</td>
										<td>
											<font face="ARIAL" size="2">
												<xsl:call-template name="genList">
													<xsl:with-param name="nodeName" select="RT_mutations//mutation[@classification='OTHER']"/>
												</xsl:call-template>
											</font>
										</td>
									</tr>
								</tbody>
							</table>
							<br/>
							<table width="600">
								<tbody>
									<tr>
										<td>
											<table width="300">
												<caption>
													<font face="ARIAL" size="2">
														<b>Nucleoside RTI</b>
													</font>
												</caption>
												<tbody>
													<xsl:call-template name="printResistanceLevel">
														<xsl:with-param name="nodeList" select="drugScores//drug[@type='NRTI']"/>
														<xsl:with-param name="width">20</xsl:with-param>
													</xsl:call-template>
												</tbody>
											</table>
										</td>
										<td valign="top">
											<table width="300">
												<caption>
													<font face="ARIAL" size="2">
														<b>Non-Nucleoside RTI</b>
													</font>
												</caption>
												<tbody>
													<xsl:call-template name="printResistanceLevel">
														<xsl:with-param name="nodeList" select="drugScores//drug[@type='NNRTI']"/>
														<xsl:with-param name="width">10</xsl:with-param>
													</xsl:call-template>
												</tbody>
											</table>
										</td>
									</tr>
								</tbody>
							</table>
						</td>
					</tr>
				</tbody>
			</table>
			<table class="textDescBordered" cellpadding="1" cellspacing="0" width="670">
				<tbody>
					<tr>
						<td>
							<font face="ARIAL" size="3">
								<b>RT Comments</b>
							</font>
							<br/>
							<xsl:call-template name="printBulletList">
								<xsl:with-param name="nodeList" select="comments//comment[substring(@id,1, 2)='RT']"/>
							</xsl:call-template>
							<ul type="square">
								</ul>
						</td>
					</tr>
				</tbody>
			</table>
		</xsl:if>
	</xsl:template>
	
	<!-- Frameshift info. -->
	<xsl:template name="frameshift">
		<font color="RED" face="ARIAL">
		There is a reading frame shift! Please examine the sequence 
		carefully.  The presence of a reading frame shift 
		(insertions or deletions that are not multiples of 3 NA) suggests the 
		possibility of a sequencing error.
		Reading frame shifts 
		in this sequence are shown below.  A region of the underlying raw
		alignment text on either side of the reading frame shift is also shown.
		<br/>	
		<ol>
			<xsl:for-each select="../SequenceQA//frameshift">
				<li>Shift of length <xsl:value-of select="length"/> nucleic acids at codon <xsl:value-of select="AAPosition"/> in <xsl:value-of select="name(..)"/>
				</li>
				<br/>
				<pre>
					<xsl:value-of select="rawAlignBlock"/>
				</pre>
			</xsl:for-each>
		</ol>
		</font>
	</xsl:template>
	<!-- Utility method to generate comma separated list. -->
	<xsl:template name="genList">
		<xsl:param name="nodeName"/>
		<xsl:if test="count($nodeName) = 0">
			<em>None</em>
		</xsl:if>
		<xsl:for-each select="$nodeName">
			<xsl:value-of select="."/>
			<xsl:if test="not(position()=last())">
				<xsl:text>, </xsl:text>
			</xsl:if>
		</xsl:for-each>
	</xsl:template>
	<!-- Utility method to print drug resistance levels -->
	<xsl:template name="printResistanceLevel">
		<xsl:param name="nodeList"/>
		<xsl:param name="width"/>
		<xsl:for-each select="$nodeList">
			<tr>
				<xsl:element name="td">
					<xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
					<font face="ARIAL">
						<b>
							<xsl:value-of select="./@code"/>
						</b>
					</font>
				</xsl:element>
				<xsl:element name="td">
					<xsl:attribute name="width"><xsl:value-of select="100 - $width"/>%</xsl:attribute>
					<font face="ARIAL" size="2">
						<xsl:call-template name="translateResistanceLevel">
							<xsl:with-param name="numLevel">
								<xsl:value-of select="./@levelStanford"/>
							</xsl:with-param>
						</xsl:call-template>
					</font>
				</xsl:element>
			</tr>
		</xsl:for-each>
	</xsl:template>
	<!-- Utility method to print node values as a bulletted list -->
	<xsl:template name="printBulletList">
		<xsl:param name="nodeList"/>
		<ul>
			<xsl:for-each select="$nodeList">
				<li><font face="ARIAL" size="2">
					<xsl:value-of select="."/>
					</font>
				</li>
			</xsl:for-each>
		</ul>
	</xsl:template>
	<!-- Utility method to translate numeric resistance level to string -->
	<xsl:template name="translateResistanceLevel">
		<xsl:param name="numLevel"/>
		<xsl:choose>
			<xsl:when test="$numLevel=1">Susceptible</xsl:when>
			<xsl:when test="$numLevel=2">Potential low-level resistance</xsl:when>
			<xsl:when test="$numLevel=3">Low-level resistance</xsl:when>
			<xsl:when test="$numLevel=4">Intermediate resistance</xsl:when>
			<xsl:when test="$numLevel=5">High-level resistance</xsl:when>
		</xsl:choose>
	</xsl:template>
	<!-- Utility method to print mutation scoring -->
	<xsl:template name="printScoreTable">
		<xsl:param name="drugList"/>
		<xsl:param name="mutationList"/>
		<xsl:param name="tableWidth"/>
		<table class="data" border="0" cellpadding="1" cellspacing="0">
			<xsl:attribute name="width"><xsl:value-of select="$tableWidth"/></xsl:attribute>
			<tbody>
				<tr>
					<!-- Add header with Drug Names-->
					<td> </td>
					<xsl:for-each select="$drugList">
						<xsl:sort select="@type" order="descending"/>
						<xsl:sort select="@code" order="ascending"/>
						<td>
							<font face="ARIAL" size="2">
								<b>
									<xsl:value-of select="./@code"/>
								</b>
							</font>
						</td>
					</xsl:for-each>
				</tr>
				<!-- Add partial scores for each mutation-->
				<xsl:for-each select="$mutationList">
					<tr>
						<td>
							<font face="ARIAL" size="2">
								<b>
									<xsl:value-of select="."/>
								</b>
							</font>
						</td>
						<xsl:variable name="mutation" select="."/>
						<xsl:for-each select="$drugList">
							<xsl:sort select="@type" order="descending"/>
							<xsl:sort select="@code" order="ascending"/>
							<td align="center">
								<font face="ARIAL" size="2">
									<xsl:choose>
										<xsl:when test="./partialScore[@mutation=$mutation]">
											<a target="window2">
												<xsl:attribute name="href">
													<xsl:call-template name="scoreHyperlink">
														<xsl:with-param name="drug" select="."/>
														<xsl:with-param name="mutation" select="$mutation"/>
													</xsl:call-template>
												</xsl:attribute>
												<xsl:value-of select="./partialScore[@mutation=$mutation]/@score"/>
											</a>
										</xsl:when>
										<xsl:otherwise>
											<a target="window2">
												<xsl:attribute name="href">
													<xsl:call-template name="scoreHyperlink">
														<xsl:with-param name="drug" select="."/>
														<xsl:with-param name="mutation" select="$mutation"/>
													</xsl:call-template>
												</xsl:attribute>
												<xsl:text> </xsl:text>
											</a>
										</xsl:otherwise>
									</xsl:choose>
								</font>
							</td>
						</xsl:for-each>
					</tr>
				</xsl:for-each>
				<!-- Add Total Scores row-->
				<tr>
					<td>
						<font face="ARIAL" size="2"> Total: </font>
					</td>
					<xsl:for-each select="$drugList">
						<xsl:sort select="@type" order="descending"/>
						<xsl:sort select="@code" order="ascending"/>
						<td align="center">
							<font face="ARIAL" size="2">
								<xsl:value-of select="./@score"/>
							</font>
						</td>
					</xsl:for-each>
				</tr>
			</tbody>
		</table>
	</xsl:template>
	
	<!-- Utility template to create score hyperlink (for use in the scoring table) -->
	<xsl:template name="scoreHyperlink">
		<xsl:param name="drug"/>
		<xsl:param name="mutation"/>
		<xsl:text>http://hivdb.stanford.edu/cgi-bin/GetResiData.cgi?pos=</xsl:text>
		<!-- need to use hack to extract position, XPath 2.0 has regexp but 2.0 isn't that popular yet-->
		<xsl:value-of select="translate($mutation, translate($mutation, '0123456789',''), '')"/> 
		<xsl:text>&amp;drug=</xsl:text><xsl:value-of select="$drug/@code"/>	
		<xsl:text>&amp;class=</xsl:text><xsl:value-of select="$drug/@type"/>
		<xsl:text>&amp;drug1=any</xsl:text>	
	</xsl:template>
</xsl:stylesheet>
