<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Quality Report for "<%=basename(x@filename)%>"</title>
    <meta http-equiv="content-type" 
	  content="text/html;charset=utf-8" />
    <style type="text/css" media="screen">
      body {
      font-family: arial, sans-serif;
      }
      .section {
      width: 920px;
      border-style: solid;
      border-width: 0 0 1px 0;
      border-color: grey;
      padding: 1.4em;
      }
      .section h2 {
      color: #444444;
      }
      .fixed-font {
      font-family: monospace;
      }

      table, td, th {
      font-family: monospace;
      border: 0;
      padding-right: 1.2em;
      }
    </style>
  </head>
  <body>
    <div class="section">
      <h2>General Information</h2>
      File: <span class="fixed-font"><%=x@filename%></span><br/>
      Type: <span class="fixed-font">FASTQ</span><br/>
      Sequence Length Range: <span class="fixed-font"><%=sl.range[1]%> to <%=sl.range[2]%></span><br/>
      Total Sequences: <span class="fixed-font"><%=sum(x@seq.lengths)%></span><br/>
      Unique Sequences: <span class="fixed-font"><%=length(x@hash)%></span><br/>
    </div>
    
    <div class="section">
      <h2>Quality by Position</h2>
      <%
         qualPlot(x)
         ggsave(file.path(dir, 'images', 'qualplot.png'), width=WIDTH, height=HEIGHT, dpi=DPI)
         %>
      <img src='images/qualplot.png'/><br/>
      <em><font color="grey">Grey lines</font>: 10% and 90% quantiles</em></br>
      <em><font color="orange">Orange lines</font>: 25% and 75% quartiles</em><br/>
      <em><font color="blue">Blue point</font>: median</em><br/>    
      <em><font color="green">Green dash</font>: mean</em><br/>
      <em><font color="purple">Purple line</font>: lowess curve</em><br/>
    </div>

    <div class="section">
      <h2>Nucleotide Frequency by Position</h2>
      <%
         basePlot(x)
         ggsave(file.path(dir, 'images', 'basefreqs.png'), width=WIDTH, height=HEIGHT, dpi=DPI)
         %>
      <img src='images/basefreqs.png' />
    </div>

    <div class="section">
      <h2>Nucleotide Proportion by Position</h2>
      <%
         basePlot(x, type="proportion")
         ggsave(file.path(dir, 'images', 'baseprops.png'), width=WIDTH, height=HEIGHT, dpi=DPI)
         %>
      <img src='images/baseprops.png' />
    </div>


    <div class="section">
      <h2>N Frequency by Position</h2>
      <%
         basePlot(x, bases='N')
         ggsave(file.path(dir, 'images', 'nfreq.png'), width=WIDTH, height=HEIGHT, dpi=DPI)
         %>
      <img src='images/nfreq.png' />
    </div>

    <div class="section">
      <h2>GC Content by Position</h2>
      <%
         gcPlot(x)
         ggsave(file.path(dir, 'images', 'gc.png'), width=WIDTH, height=HEIGHT, dpi=DPI)
         %>
      <img src='images/gc.png' />
    </div>

    <div class="section">
      <h2>Sequence Length Distribution</h2>
      <%
         seqlenPlot(x)
         ggsave(file.path(dir, 'images', 'seqlengths.png'), width=WIDTH, height=HEIGHT, dpi=DPI)
         %>
      <img src='images/seqlengths.png' />
    </div>


    <div class="section">
      <h2>Most Frequent Sequences</h2>
      <%
         if (x@hashed) {
           x <- makeHashTable(x)
           print(x, type="html")         
         } else {
           cat("No sequence frequency information available - readSeqFile() run with hash=FALSE")
         }
         %>
    </div>

    <div style="font-size: 0.8em; margin-left: 280px;">Report produced by the R package <span class="fixed-font">qrqc</span></div>
    <div style="font-size: 0.8em; margin-left: 280px;">(c) Vince Buffalo 2011-2012, License: GPL 2.0</div>
  </body>
</html>
