<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
 
<!-- Root Node -->
<xsl:template name="root" match="/DrugResistance_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://hivdb.stanford.edu/pages/algs/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="//result"/>
				<xsl:call-template name="footer"/>
			</body>
		</html>
	</xsl:template>

	<xsl:template name="result" match="result">
		<xsl:if test="count(inputSequence) &gt; 0">
			<div class="subHeader1">
				Seq ID:
				<xsl:value-of select="inputSequence/name"/>
			</div>
		</xsl:if>
	
		<xsl:choose>
			<xsl:when test="count(geneData[present='true']) &gt; 0">
				<xsl:choose>
					<!-- the followinig is used when a sequence is submitted -->
					<xsl:when test="count(inputSequence) &gt; 0">
						<xsl:call-template name="geneSummaryData"/>
						<xsl:if test="count(../reportQualityAnalysis)='0' or ../reportQualityAnalysis='true'">
							<xsl:call-template name="SequenceQA"/>
						</xsl:if>
					</xsl:when>
					<xsl:otherwise>
						<xsl:call-template name="geneSummaryData2"/>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:call-template name="drugResistanceInterpretation"/>
				<xsl:if test="count(../reportScoring)='0' or ../reportScoring='true'">
					<xsl:call-template name="printScoringSection"/>
				</xsl:if>
			</xsl:when>
			<xsl:when test="count(geneData[quality]) &gt; 0">
				<!-- there is gene data but all genes have problems -->
				<xsl:call-template name="allGenesProblem"/>
			</xsl:when>
			<xsl:when test="success='false'">
				<table class="textDesc" cellpadding="1" cellspacing="0" width="670">
					<tbody><tr><td><font face="ARIAL" size="2">
					<xsl:choose>
						<xsl:when test="errorMessage">
							<xsl:value-of select="errorMessage"/>
							<BR/><BR/>
						</xsl:when>
						<xsl:otherwise>
							Could not process sequence - unknown reason<BR/><BR/>
						</xsl:otherwise>
					</xsl:choose>
					</font></td></tr></tbody>
				</table>	
			</xsl:when>
			<xsl:otherwise>
				<table class="textDesc" cellpadding="1" cellspacing="0" width="670">
					<tbody><tr><td><font face="ARIAL" size="2">
						Unknown error encountered<BR/><BR/>
					</font></td></tr></tbody>
				</table>
			</xsl:otherwise>
		</xsl:choose>
	</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://hivdb.stanford.edu/pages/algs/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://hivdb.stanford.edu/pages/algs/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://hivdb.stanford.edu/pages/algs/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://hivdb.stanford.edu/pages/algs/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://hivdb.stanford.edu/pages/algs/images/btn_genotype-cl.gif" border="0" height="19" width="146"/>
			</a>
			<a href="http://hivdb.stanford.edu/pages/algs/HIVdb.html">
				<img alt="HIVdb Program" src="http://hivdb.stanford.edu/pages/algs/images/hivdb_nav_button.gif" border="0" height="19" width="116"/>
			</a>
		</div>
		<h2 class="submain2">HIVdb: Genotypic Resistance Interpretation Algorithm</h2>
		<font face="ARIAL" size="2">
			<B><xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;</xsl:text>Report: 
			<xsl:value-of select="submissionName"/>
			Date: <xsl:value-of select="dateTime"/>											
			</B>
		</font>
		<br/><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">(c) 1998-2005. All Rights Reserved.</div>
	</xsl:template>

	<!-- ============================================= -->
	<xsl:template name="printScoringSection">
		<table class="textDescBordered" cellpadding="1" cellspacing="0" width="670"><tbody>
			<tr>
				<td>
					<font face="ARIAL" size="3">
						<b>Mutation Scoring</b>
					</font>
				</td>
			</tr>

			<xsl:for-each select="scoreTable">
				<tr>
					<td>
						<table class="data" border="0" cellpadding="1" cellspacing="0">
						<xsl:attribute name="width">240</xsl:attribute>
						<tbody>
							<xsl:for-each select="scoreRow">
							<tr>
								<xsl:for-each select="score">
									<xsl:choose>
										<xsl:when test="./@pos">
											<td><P CLASS='cellright'><font face="ARIAL" size="2">
											<a>
											<xsl:attribute name="href">
												<xsl:text>http://hivdb.stanford.edu/cgi-bin/Marvel.cgi?pos=</xsl:text>
												<xsl:value-of select="./@pos"/>
												<xsl:text>&amp;drug=</xsl:text>
												<xsl:value-of select="./@drug"/>
												<xsl:text>&amp;class=</xsl:text>
												<xsl:value-of select="./@class"/>
											</xsl:attribute>
											<xsl:attribute name="target">window2</xsl:attribute>
											<xsl:value-of select="./@value"/>
											</a>
											</font></P></td>
										</xsl:when>
										<xsl:when test="./@drug">
											<td><P CLASS='cellright'><font face="ARIAL" size="2">
											<xsl:value-of select="./@value"/>
											</font></P></td>
										</xsl:when>
										<xsl:otherwise>
											<td><font face="ARIAL" size="2"><b>
											<xsl:value-of select="./@value"/>
											<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
											</b></font></td>
										</xsl:otherwise>
									</xsl:choose>
								</xsl:for-each>
							</tr>
							</xsl:for-each>
						</tbody>
						</table>
					</td>
				</tr>
				<!-- blank line -->
				<tr><td><xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text></td></tr>
			</xsl:for-each>
		</tbody>
	</table>
	</xsl:template>
	
	<!-- ============================================= -->
	<!-- Sequence Quality Assessment info. -->
	<xsl:template name="SequenceQA">
		<xsl:if test="count(./geneData/quality/criteriaFailed) &gt; 0">
		<xsl:for-each select="geneData">
			<xsl:if test="count(./quality/criteriaFailed) &gt; 0">
				<table class="textDesc" cellpadding="1" cellspacing="0" width="670">
					<tbody>
					<tr><td>
						<font face="ARIAL" size="2">
						<B><xsl:value-of select="gene"/> Unusual/Bad Quality (interpretation not done)</B></font><br/>
					</td></tr>
					<xsl:for-each select="./quality/criteriaFailed">
						<tr><td>
							<font face="ARIAL" size="2">
							<xsl:value-of select="."/></font><br/>
						</td></tr>
					</xsl:for-each>
					</tbody>
				</table>
				<br/>
			</xsl:if>
		</xsl:for-each>
		</xsl:if>

		<div class="subHeader1">Sequence Quality Assessment</div>
		<xsl:for-each select="geneData">
		<xsl:if test="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"><xsl:value-of select="gene"/></font>
										</td>
										<td>
											<font face="ARIAL" size="2"> Stop Codons, Frame Shifts:</font>
										</td>
										<td align="center">
											<font face="ARIAL" size="2">
												<xsl:choose>
													<xsl:when test="quality/stopAndFrameshiftPositions">
														<xsl:value-of select="quality/stopAndFrameshiftPositions"/>											
													</xsl:when>
													<xsl:otherwise>
														<I>None</I>
													</xsl:otherwise>
												</xsl:choose>
												<!--
												<xsl:call-template name="genList">
													<xsl:with-param name="nodeName" select="quality/stop | quality/frameshift/position"/>
												</xsl:call-template>
												-->
											</font>
										</td>
									</tr>
									<tr>
										<td>
											<font face="ARIAL" size="2"><xsl:value-of select="gene"/></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="quality/ambiguous"/>
												</xsl:call-template>
											</font>
										</td>
									</tr>
									<tr>
										<td>
											<font face="ARIAL" size="2"><xsl:value-of select="gene"/></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="mutation[atypical='true']/position"/>
												</xsl:call-template>
											</font>
										</td>
									</tr>
									<xsl:if test="count(quality/GAHypermutatedPositions) &gt; 0">
									<tr>
										<td>
											<font face="ARIAL" size="2"><xsl:value-of select="gene"/></font>
										</td>
										<td>
											<font face="ARIAL" size="2"> G-A Hypermutated:</font>
										</td>
										<td align="center">
											<font face="ARIAL" size="2">
												<xsl:call-template name="genList">
													<xsl:with-param name="nodeName" select="quality/GAHypermutatedPositions"/>
												</xsl:call-template>
											</font>
										</td>
									</tr>
									</xsl:if>

								</tbody>
							</table>
						</td>
						<td width="2%"/>
						<td valign="bottom">
						<xsl:if test="quality/href">
							<img alt=""> <xsl:attribute name="src"><xsl:value-of select="quality/href"/></xsl:attribute></img>
						</xsl:if>
						</td>
					</tr>
				</tbody>
			</table>
		</xsl:if>
		</xsl:for-each>
		<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>

	<!-- ============================================= -->
	<xsl:template name="allGenesProblem">
		<table class="textDesc" cellpadding="1" cellspacing="0" width="670">
		<tbody>
			<xsl:for-each select="geneData">
				<xsl:if test="count(./quality) &gt; 0">
					<tr>
						<td><font face="ARIAL" size="2"><B>
							<xsl:value-of select="gene"/>
							Unusual/Bad Quality (interpretation not done)</B><br/>
							<xsl:for-each select="./quality/criteriaFailed">
								<xsl:value-of select="."/><br/>
							</xsl:for-each>
							</font>
							<br/>
						</td>
					</tr>
				</xsl:if>
			</xsl:for-each>
		</tbody></table>
	</xsl:template>


	<!-- ============================================= -->
	<!-- Summary info. -->
	<xsl:template name="geneSummaryData">
		<div class="subHeader1">Summary Data</div>
		<table class="textDesc" cellpadding="1" cellspacing="0">
			<tbody>
				<xsl:for-each select="geneData">
				<tr>
					<td>
						<xsl:if test="gene='PR' and present='true'">
							<font face="ARIAL" size="2">
								<b>Sequence includes PR: codons: <xsl:value-of select="firstAA"/>  - <xsl:value-of select="lastAA"/></b>
							</font>
							<br/>
						</xsl:if>
						<xsl:if test="gene='RT' and present='true'">
							<font face="ARIAL" size="2">
								<b>Sequence includes RT: codons: <xsl:value-of select="firstAA"/> - <xsl:value-of select="lastAA"/></b>
							</font>
							<br/>
						</xsl:if>
						<xsl:if test="gene='IN' and present='true'">
							<font face="ARIAL" size="2">
								<b>Sequence includes IN: codons: <xsl:value-of select="firstAA"/> - <xsl:value-of select="lastAA"/></b>
							</font>
							<br/>
						</xsl:if>
					</td>
				</tr>
				</xsl:for-each>
			</tbody>
		</table>
		<table class="textDesc" cellpadding="1" cellspacing="0" width="670">
			<tbody>
				<tr>
					<td>
						<font face="ARIAL" size="2">
							<xsl:if test="count(GAHypermutated) &gt; 0">
								<em>This sequence is G-A Hypermutated</em><br/>
							</xsl:if>
							<xsl:choose>
								<xsl:when test="sequenceQualityCounts and sequenceQualityCounts/insertions = '0' and sequenceQualityCounts/deletions = '0'">
									<em>There are no insertions or deletions</em>
								</xsl:when>
								<xsl:otherwise>
									<xsl:for-each select="geneData">
										<xsl:if test="count(mutation[type='insertion']) &gt; 0">
											<xsl:call-template name="printInsertions">
												<xsl:with-param name="insertions" select="mutation[type='insertion']"/>
											</xsl:call-template>
										</xsl:if>
										<xsl:if test="count(mutation[type='insertion']) &gt; 0 and count(mutation[type='deletion']) &gt; 0">
											<br/>
										</xsl:if>
										<xsl:if test="count(mutation[type='deletion']) &gt; 0">
											<xsl:call-template name="printDeletions">
												<xsl:with-param name="deletions" select="mutation[type='deletion']"/>
											</xsl:call-template>
										</xsl:if>
									</xsl:for-each>
								</xsl:otherwise>
							</xsl:choose>
						</font>
					</td>
				</tr>
			</tbody>
		</table>
		
		<!-- Reading Frameshift Info.-->
		<xsl:if test="sequenceQualityCounts and sequenceQualityCounts/frameshifts &gt; '0'">
			<table class="textDesc" cellpadding="1" cellspacing="0" width="670"><tr><td>
			<font color="RED" face="ARIAL"><ol>
			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/><br/>
		
			<xsl:for-each select="geneData">
				<xsl:for-each select="quality/frameshift">
					<li>Shift of length <xsl:value-of select="length"/> nucleic acids at codon <xsl:value-of select="position"/> in <xsl:value-of select="../../gene"/>
					</li>
					<pre><xsl:value-of select="rawAlignBlock"/></pre>
				</xsl:for-each>
			</xsl:for-each>
			</ol></font></td></tr></table>
		</xsl:if>

		<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:for-each select="geneData">
								<xsl:if test="present='true'">
									<li>
										<em>
											<font face="arial" size="2"><xsl:value-of select="gene"/>: <xsl:value-of select="subtype/type"/> (<xsl:value-of select="subtype/percentSimilarity"/>%)</font>
										</em>
									</li>
								</xsl:if>
							</xsl:for-each>
						</ol>
					</td>
				</tr>
			</tbody>
		</table>
	</xsl:template>

	<!-- ============================================= -->
	<!-- Summary info. for mutation input -->
	<xsl:template name="geneSummaryData2">
		<xsl:if test="count(GAHypermutated) &gt; 0">
			<table class="textDesc" cellpadding="1" cellspacing="0" width="670">
				<tbody>
					<tr>
						<td>
							<font face="ARIAL" size="2">
								<em>This sequence is G-A Hypermutated</em><br/>
							</font>
						</td>
					</tr>
				</tbody>
			</table>
		</xsl:if>
	</xsl:template>
		
	<!-- ======================================== -->
	<!-- Insertion info. -->
	<xsl:template name="printInsertions">
		<xsl:param name="insertions"/>
		<xsl:for-each select="$insertions">
<b><xsl:value-of select="../gene"/> AA Insertion:  </b>codon <xsl:value-of select="position"/>      AA: <xsl:value-of select="insertionTranslatedNA"/>      NA: <xsl:value-of select="insertionNucleicAcid"/>
		<xsl:if test="not(position()=last())"><br/></xsl:if>  
 		</xsl:for-each>
	</xsl:template>
	
	<xsl:template name="printDeletions">
		<xsl:param name="deletions"/>
		<xsl:for-each select="$deletions">
<b><xsl:value-of select="../gene"/> AA Deletion:  </b>codon <xsl:value-of select="position"/>
		<xsl:if test="not(position()=last())"><br/></xsl:if>  
 		</xsl:for-each>
	</xsl:template>

	<!-- Drug Resistance Interpretation section -->
	<xsl:template name="drugResistanceInterpretation">
		<xsl:for-each select="geneData">
		<xsl:if test="present='true'">

			<div class="subHeader1">Drug Resistance Interpretation: <xsl:value-of select="gene"/></div>
<!-- table 1 -->			
			<table class="textDescBordered" border="0" cellpadding="1" cellspacing="0" width="670"><tbody>
				<tr>
					<td>
						<!-- PIMAJOR, PIMINOR, OTHER mutations -->
<!-- table 2 -->						
						<table width="600"><tbody> 
							<tr>
								<td valign="top" width="35%">
									<font face="ARIAL" size="2">
									<b> 
									<xsl:choose>
										<xsl:when test="gene='PR'"> PI Major Resistance Mutations:</xsl:when>
										<xsl:when test="gene='RT'"> NRTI Resistance Mutations:</xsl:when>
										<xsl:when test="gene='IN'"> IN Major Resistance Mutations:</xsl:when>
									</xsl:choose>
									</b>
									</font>
								</td>
								<td width="75%">
									<font face="ARIAL" size="2">
									<xsl:choose>
										<xsl:when test="gene='PR'">
											<xsl:choose>
												<xsl:when test="count(mutation[classification='PI_MAJOR']) > 0">
													<b>
													<xsl:call-template name="genList2">
														<xsl:with-param name="nodeName" select="mutation[classification='PI_MAJOR']"/>
													</xsl:call-template>
													</b>
												</xsl:when>
												<xsl:when test="count(mutation[classification='PI_MAJOR']) = 0">
													None
												</xsl:when>
											</xsl:choose>
										</xsl:when>
										<xsl:when test="gene='RT'">
											<xsl:choose>
												<xsl:when test="count(mutation[classification='NRTI']) > 0">
													<b>
													<xsl:call-template name="genList2">
														<xsl:with-param name="nodeName" select="mutation[classification='NRTI']"/>
													</xsl:call-template>
													</b>
												</xsl:when>
												<xsl:when test="count(mutation[classification='NRTI']) = 0">
													None
												</xsl:when>
											</xsl:choose>												
										</xsl:when>
										<xsl:when test="gene='IN'">
											<xsl:choose>
												<xsl:when test="count(mutation[classification='INI_MAJOR']) > 0">
													<b>
													<xsl:call-template name="genList2">
														<xsl:with-param name="nodeName" select="mutation[classification='INI_MAJOR']"/>
													</xsl:call-template>
													</b>
												</xsl:when>
												<xsl:when test="count(mutation[classification='INI_MAJOR']) = 0">
													None
												</xsl:when>
											</xsl:choose>
										</xsl:when>
									</xsl:choose>
									</font>
								</td>
							</tr>
							<tr>
								<td valign="top">
									<font face="ARIAL" size="2">
									<b>
									<xsl:choose>
										<xsl:when test="gene='PR'"> PI Minor Resistance Mutations:</xsl:when>
										<xsl:when test="gene='RT'"> NNRTI Resistance Mutations:</xsl:when>
										<xsl:when test="gene='IN'"> IN Minor Resistance Mutations:</xsl:when>
									</xsl:choose>
									</b>
									</font>
								</td>
								<td>
									<font face="ARIAL" size="2">
									<xsl:choose>
										<xsl:when test="gene='PR'">
											<xsl:choose>
												<xsl:when test="count(mutation[classification='PI_MINOR']) > 0">
													<b>
													<xsl:call-template name="genList2">
														<xsl:with-param name="nodeName" select="mutation[classification='PI_MINOR']"/>
													</xsl:call-template>
													</b>
												</xsl:when>
												<xsl:when test="count(mutation[classification='PI_MINOR']) = 0">
													None
												</xsl:when>
											</xsl:choose>
										</xsl:when>
										<xsl:when test="gene='RT'">
											<xsl:choose>
												<xsl:when test="count(mutation[classification='NNRTI']) > 0">
													<b>
													<xsl:call-template name="genList2">
														<xsl:with-param name="nodeName" select="mutation[classification='NNRTI']"/>
													</xsl:call-template>
													</b>
												</xsl:when>
												<xsl:when test="count(mutation[classification='NNRTI']) = 0">
													None
												</xsl:when>
											</xsl:choose>
										</xsl:when>
										<xsl:when test="gene='IN'">
											<xsl:choose>
												<xsl:when test="count(mutation[classification='INI_MINOR']) > 0">
													<b>
													<xsl:call-template name="genList2">
														<xsl:with-param name="nodeName" select="mutation[classification='INI_MINOR']"/>
													</xsl:call-template>
													</b>
												</xsl:when>
												<xsl:when test="count(mutation[classification='INI_MINOR']) = 0">
													None
												</xsl:when>
											</xsl:choose>
										</xsl:when>
									</xsl:choose>
									</font>
								</td>
							</tr>
							<tr>
								<td valign="top">
									<font face="ARIAL" size="2">
									<b>Other Mutations:</b>
									</font>
								</td>
								<td>
									<font face="ARIAL" size="2">
										<xsl:choose>
											<xsl:when test="count(mutation[classification='OTHER']) > 0">
												<xsl:call-template name="genList2">
													<xsl:with-param name="nodeName" select="mutation[classification='OTHER']"/>
												</xsl:call-template>
											</xsl:when>
											<xsl:when test="count(mutation[classification='OTHER']) = 0">
													None
											</xsl:when>
										</xsl:choose>
									</font>
								</td>
							</tr>
						</tbody></table>
<!-- end table 2 -->

<!-- table 3 -->
						<br/>
						<table width="600"><tbody>
							<tr>
								<td valign="top">
<!-- table 4 -->
									<table width="325"><tbody>
										<tr>
											<td colspan='2' align='center'>
												<font face="ARIAL" size="2">
													<b>
													<xsl:choose>
														<xsl:when test="gene='PR'"> Protease Inhibitors</xsl:when>
														<xsl:when test="gene='RT'"> Nucleoside RTI</xsl:when>
														<xsl:when test="gene='IN'"> Integrase Inhibitors</xsl:when>
													</xsl:choose>
													</b>
												</font>
											</td>
										</tr>

										<xsl:choose>
											<xsl:when test="gene='PR'">
												<xsl:call-template name="printResistanceLevel">
													<xsl:with-param name="nodeList" select="../drugScore[type='PI']"/>
													<xsl:with-param name="width">60</xsl:with-param>
												</xsl:call-template>
											</xsl:when>
											<xsl:when test="gene='RT'">
												<xsl:call-template name="printResistanceLevel">
													<xsl:with-param name="nodeList" select="../drugScore[type='NRTI']"/>
													<xsl:with-param name="width">40</xsl:with-param>
												</xsl:call-template>
											</xsl:when>
											<xsl:when test="gene='IN'">
												<xsl:call-template name="printResistanceLevel">
													<xsl:with-param name="nodeList" select="../drugScore[type='INI']"/>
													<xsl:with-param name="width">60</xsl:with-param>
												</xsl:call-template>
											</xsl:when>
										</xsl:choose>
									</tbody></table>
								</td>
<!-- end table 4 -->

<!-- table 5 -->
								<td valign='top'>
									<table width="300"><tbody>
										<xsl:choose>
											<xsl:when test="gene='RT'">
												<tr>
													<td colspan='2' align='center'>
														<font face="ARIAL" size="2"><b>Non-Nucleoside RTI</b></font>
													</td>
												</tr>
												<xsl:call-template name="printResistanceLevel">
													<xsl:with-param name="nodeList" select="../drugScore[type='NNRTI']"/>
													<xsl:with-param name="width">40</xsl:with-param>
												</xsl:call-template>
											</xsl:when>
											<xsl:otherwise>
											</xsl:otherwise>
										</xsl:choose>
									</tbody></table>
<!-- end table 5 -->
								</td>
							</tr>
						</tbody></table>
<!-- end table 3 -->
					</td>
				</tr>
			</tbody></table>
<!-- end table 1 -->

			<xsl:if test="count(../comment) &gt; 0 or count(../drugComment) &gt; 0">
				<table class="textDescBordered" cellpadding="1" cellspacing="0" width="670">
					<tbody>
						<tr>
							<td>
								<font face="ARIAL" size="3">
									<b><xsl:value-of select="gene"/> Comments</b>
								</font>
								<br/>
								<xsl:choose>
									<xsl:when test="gene='PR'">
										<xsl:if test="count(../comment[gene='PR' and grouping='PIMajor']) &gt; 0">
											<ul><b>PIMajor</b>
											<xsl:apply-templates select="../comment[gene='PR' and grouping='PIMajor']">
												<xsl:sort select="position" data-type="number"/>
											</xsl:apply-templates>
											</ul>
										</xsl:if>
										
										<xsl:if test="count(../comment[gene='PR' and grouping='PIMinor']) &gt; 0">
											<ul><b>PIMinor</b>
											<xsl:apply-templates select="../comment[gene='PR' and grouping='PIMinor']">
												<xsl:sort select="position" data-type="number"/>
											</xsl:apply-templates>
											</ul>
										</xsl:if>
										<!--
										<xsl:if test="count(../comment[gene='PR' and grouping='Special']) &gt; 0">
											<ul><b>Special</b>
											<xsl:apply-templates select="../comment[gene='PR' and grouping='Special']">
												<xsl:sort select="position" data-type="number"/>
											</xsl:apply-templates>
											</ul>
										</xsl:if>
										-->
										
										<xsl:if test="count(../drugComment[gene='PR']) &gt; 0">
											<ul><b>Special</b>
											<xsl:apply-templates select="../drugComment[gene='PR']"/>
											</ul>
										</xsl:if>
										
										<xsl:if test="count(../comment[gene='PR' and grouping='Other']) &gt; 0">
											<ul><b>Other</b>
											<xsl:apply-templates select="../comment[gene='PR' and grouping='Other']">
												<xsl:sort select="position" data-type="number"/>
											</xsl:apply-templates>
											</ul>
										</xsl:if>
									</xsl:when>
									<xsl:when test="gene='RT'">
										<xsl:if test="count(../comment[gene='RT' and grouping='NRTI']) &gt; 0">
											<ul><b>NRTI</b>
											<xsl:apply-templates select="../comment[gene='RT' and grouping='NRTI']">
												<xsl:sort select="position" data-type="number"/>
											</xsl:apply-templates>
											</ul>
										</xsl:if>
										
										<xsl:if test="count(../comment[gene='RT' and grouping='NNRTI']) &gt; 0">
											<ul><b>NNRTI</b>
											<xsl:apply-templates select="../comment[gene='RT' and grouping='NNRTI']">
												<xsl:sort select="position" data-type="number"/>
											</xsl:apply-templates>
											</ul>
										</xsl:if>
										
										<!--
										<xsl:if test="count(../comment[gene='RT' and grouping='Special']) &gt; 0">
											<ul><b>Special</b>
											<xsl:apply-templates select="../comment[gene='RT' and grouping='Special']">
												<xsl:sort select="position" data-type="number"/>
											</xsl:apply-templates>
											</ul>
										</xsl:if>
										-->
										
										<xsl:if test="count(../drugComment[gene='RT']) &gt; 0">
											<ul><b>Special</b>
											<xsl:apply-templates select="../drugComment[gene='RT']"/>
											</ul>
										</xsl:if>
	
										<xsl:if test="count(../comment[gene='RT' and grouping='Other']) &gt; 0">
											<ul><b>Other</b>
											<xsl:apply-templates select="../comment[gene='RT' and grouping='Other']">
												<xsl:sort select="position" data-type="number"/>
											</xsl:apply-templates>
											</ul>
										</xsl:if>
									</xsl:when>
									<xsl:when test="gene='IN'">
										<xsl:if test="count(../comment[gene='IN' and grouping='INIMajor']) &gt; 0">
											<ul><b>INIMajor</b>
											<xsl:apply-templates select="../comment[gene='IN' and grouping='INIMajor']">
												<xsl:sort select="position" data-type="number"/>
											</xsl:apply-templates>
											</ul>
										</xsl:if>
										
										<xsl:if test="count(../comment[gene='IN' and grouping='INIMinor']) &gt; 0">
											<ul><b>INIMinor</b>
											<xsl:apply-templates select="../comment[gene='IN' and grouping='INIMinor']">
												<xsl:sort select="position" data-type="number"/>
											</xsl:apply-templates>
											</ul>
										</xsl:if>
										
										<!--
										<xsl:if test="count(../comment[gene='IN' and grouping='Special']) &gt; 0">
											<ul><b>Special</b>
											<xsl:apply-templates select="../comment[gene='IN' and grouping='Special']">
												<xsl:sort select="position" data-type="number"/>
											</xsl:apply-templates>
											</ul>
										</xsl:if>
										-->
										
										<xsl:if test="count(../drugComment[gene='IN']) &gt; 0">
											<ul><b>Special</b>
											<xsl:apply-templates select="../drugComment[gene='IN']"/>
											</ul>
										</xsl:if>
										
										<xsl:if test="count(../comment[gene='IN' and grouping='Other']) &gt; 0">
											<ul><b>Other</b>
											<xsl:apply-templates select="../comment[gene='IN' and grouping='Other']">
												<xsl:sort select="position" data-type="number"/>
											</xsl:apply-templates>
											</ul>
										</xsl:if>
									</xsl:when>
								</xsl:choose>
							</td>
						</tr>
					</tbody>
				</table>
			</xsl:if>
		</xsl:if>
		</xsl:for-each>
	</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:sort order="ascending" data-type="number" select="."/> -->
			<!-- <xsl:sort select="."/> -->
			
			<xsl:value-of select="."/>
			<xsl:if test="not(position()=last())">
				<xsl:text>, </xsl:text>
			</xsl:if>
		</xsl:for-each>
	</xsl:template>
	
	<!-- =================================================== -->
	<!-- Utility method to generate comma separated list(2). -->
	<xsl:template name="genList2">
		<xsl:param name="nodeName"/>
		<xsl:for-each select="$nodeName">
			<xsl:value-of select="mutationString"/>
			<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="genericName"/>
							(<xsl:value-of select="drugCode"/>)
						</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:value-of select="resistanceLevelText"/>
					</font>
				</xsl:element>
			</tr>
		</xsl:for-each>
	</xsl:template>
	
	<!-- ========================================================-->
	<!-- Utility method to print Comments in bulletted list -->
	<xsl:template match="comment">
		<li><font face="ARIAL" size="2">
			<xsl:value-of select="commentString"/>
			</font>
		</li>
	</xsl:template>
	
	<!-- ========================================================-->
	<!-- Utility method to print Drug Comments in bulletted list -->
	<xsl:template match="drugComment">
		<li><font face="ARIAL" size="2">
			<xsl:value-of select="commentString"/>
			</font>
		</li>
	</xsl:template>
</xsl:stylesheet>

