public function doGET()
    {
        $db_options = Portal_DB::availableDatabases('formatdb');
        ?>
<style type="text/css">
table#table_options {
  border-collapse: collapse;
}
table#table_options td {
  border: 1px solid lightgrey;
  vertical-align: top;
}
table#table_C td {
  border-style: none;
  font-size: small;
}
pre {
  border: 1px solid grey;
  background-color: #ff9;
  font-weight: bold;
  padding: 2pt;
}
  </style>
<table style="text-align: left;" id="table_options" border="0" cellpadding="2" cellspacing="0">
  <tbody>
    <tr>
      <th>Option</th>
      <th>Value</th>
      <th>Explanation</th>
    </tr>
    <tr>
      <td>-p</td>
      <td>
      <select name="p">
      <option value="blastn">blastn</option>
      <option selected="selected" value="blastp">blastp</option>
      <option value="blastx">blastx</option>
      <option value="tblastn">tblastn</option>
      <option value="tblastx">tblastx</option>
      </select>
      </td>
      <td>Program Name
      </td>
    </tr>
    <tr>
      <td valign="top">-d</td>
      <td valign="top">
      <select name="d"><?php 
        echo $db_options;
        ?>
</select>
      </td>
      <td valign="top">Database</td>
    </tr>
    <tr id="alternative_1">
      <td>-i</td>
      <td><input name="i" type="file" /></td>
      <td>Query File [File In]</td>
    </tr>
    <tr>
      <td>-e</td>
      <td><input style="text-align: right;" name="e" value="10.0" /></td>
      <td>Expectation value (E) [Real]</td>
    </tr>
    <tr>
      <td>-m</td>
      <td>
      <select name="m">
      <option selected="selected" value="0">pairwise</option>
      <optgroup label="query-anchored">
      <option value="1">showing identities</option>
      <option value="2">no identities</option>
      <option value="5">no identities and blunt ends</option>
      </optgroup><optgroup label="flat query-anchored">
      <option value="3">show identities</option>
      <option value="4">no identities</option>
      <option value="6">no identities and blunt ends</option>
      </optgroup>
      <option value="7">XML
Blast output</option>
      <optgroup label="tabular">
      <option value="8">without comment lines</option>
      <option value="9">tabular
with comment lines</option>
      </optgroup><optgroup label="ASN">
      <option value="10">text</option>
      <option value="11">binary [Integer]</option>
      </optgroup>
      </select>
      </td>
      <td>alignment view options<br />
      </td>
    </tr>
    <!--<tr>
  <td>-o</td>
  <td><input name="o" />
  <br />
  </td>
  <td>BLAST report Output File [File Out]</td>
    </tr>-->
    <tr>
      <td>-F</td>
      <td><select name="F"><option value="T" selected="selected">TRUE</option><option value="F">FALSE</option></select></td>
      <td>Filter query sequence (DUST with blastn, SEGwith others)</td>
    </tr>
    <tr>
      <td>-G</td>
      <td><input style="text-align: right;" name="G" value="-1" /></td>
      <td> Cost to open a gap (-1 invokes defaultbehavior) [Integer]</td>
    </tr>
    <tr>
      <td>-E</td>
      <td><input style="text-align: right;" name="E" value="-1" /></td>
      <td>Cost to extend a gap (-1 invokes defaultbehavior) [Integer]</td>
    </tr>
    <tr>
      <td>-X</td>
      <td><input style="text-align: right;" name="X" value="0" /></td>
      <td>X dropoff value for gapped alignment (in bits) (zero invokes default behavior)<br />blastn 30, megablast 20, tblastx 0, all others 15 [Integer]</td>
    </tr>
    <tr>
      <td>-I</td>
      <td><select name="I"><option value="T">TRUE</option><option value="F" selected="selected">FALSE</option></select></td>
      <td>Show GI's in deflines</td>
    </tr>
    <tr>
      <td>-q</td>
      <td><input style="text-align: right;" name="q" value="-3" /></td>
      <td>Penalty for a nucleotide mismatch (blastn only) [Integer]</td>
    </tr>
    <tr>
      <td>-r</td>
      <td><input style="text-align: right;" name="r" value="1" /></td>
      <td>Reward for a nucleotide match (blastn only) [Integer]</td>
    </tr>
    <tr>
      <td>-v</td>
      <td><input style="text-align: right;" name="v" value="500" /></td>
      <td>Number of database sequences to show one-line descriptions for (V) [Integer]</td>
    </tr>
    <tr>
      <td>-b</td>
      <td><input style="text-align: right;" name="b" value="250" /></td>
      <td>Number of database sequences to show alignments for (B) [Integer]</td>
    </tr>
    <tr>
      <td>-f</td>
      <td><input style="text-align: right;" name="f" value="0" /></td>
      <td>Threshold for extending hits, default if zero<br /> blastp 11, blastn 0, blastx 12, tblastn 13, tblastx 13, megablast 0 [Real]</td>
    </tr>
    <tr>
      <td>-g</td>
      <td><select name="g"><option value="T" selected="selected">TRUE</option><option value="F">FALSE</option></select></td>
      <td>Perform gapped alignment (not available with tblastx)</td>
    </tr>
    <tr>
      <td>-Q</td>
      <td><input style="text-align: right;" name="Q" value="1" /></td>
      <td>Query Genetic code to use [Integer]</td>
    </tr>
    <tr>
      <td>-D</td>
      <td><input style="text-align: right;" name="D" value="1" /></td>
      <td>DB Genetic code (for tblast[nx] only) [Integer]</td>
    </tr>
    <tr>
      <td>-O</td>
      <td><select name="O"><option value="T">TRUE</option><option value="F" selected="selected">FALSE</option></select></td>
      <td>SeqAlign file [File Out]&nbsp; Optional</td>
    </tr>
    <tr>
      <td>-J</td>
      <td><select name="J"><option value="T">TRUE</option><option value="F" selected="selected">FALSE</option></select></td>
      <td>Believe the query defline</td>
    </tr>
    <tr>
      <td>-M</td>
      <td>
      <select name="M">
      <option selected="selected" value="BLOSUM62">BLOSUM62</option>
      </select>
      </td>
      <td>Matrix [String]</td>
    </tr>
    <tr>
      <td>-W</td>
      <td><input style="text-align: right;" name="W" value="0" /></td>
      <td>Word size, default if zero (blastn 11, megablast 28, all others 3) [Integer]</td>
    </tr>
    <tr>
      <td>-z</td>
      <td><input style="text-align: right;" name="z" value="0" /></td>
      <td>Effective length of the database (use zero for the real size) [Real]</td>
    </tr>
    <tr>
      <td>-K</td>
      <td><input style="text-align: right;" name="K" value="0" /></td>
      <td>Number of best hits from a region to keep. Off by default. If used a value of 100 is recommended.<br/>Very high values of -v or -b is also suggested [Integer]</td>
    </tr>
    <tr>
      <td>-P</td>
      <td><input style="text-align: right;" name="P" value="0" /></td>
      <td>0 for multiple hit, 1 for single hit (does not apply to blastn) [Integer]</td>
    </tr>
    <tr>
      <td>-Y</td>
      <td><input style="text-align: right;" name="Y" value="0" /></td>
      <td>Effective length of the search space (use zero for the real size) [Real]</td>
    </tr>
    <tr>
      <td>-S</td>
      <td>
      <select name="S">
      <option value="1">top</option>
      <option value="2">bottom</option>
      <option selected="selected" value="3">both</option>
      </select>
      </td>
      <td>Query strands to search against database (for blast[nx], and tblastx)</td>
    </tr>
    <tr>
      <td>-T</td>
      <td><select name="T"><option value="T">TRUE</option><option value="F" selected="selected">FALSE</option></select></td>
      <td>Produce HTML output</td>
    </tr>
    <tr>
      <td>-l</td>
      <td><input name="l" type="file" /></td>
      <td>Restrict search of database to list of GI's [File In]&nbsp; Optional</td>
    </tr>
    <tr>
      <td>-U</td>
      <td><select name="U"><option value="T">TRUE</option><option value="F" selected="selected">FALSE</option></select></td>
      <td>Use lower case filtering of FASTA sequence&nbsp; Optional</td>
    </tr>
    <tr>
      <td>-y</td>
      <td><input style="text-align: right;" name="y" value="0.0" /></td>
      <td>X dropoff value for ungapped extensions in bits (0.0 invokes default behavior)<br />blastn 20, megablast 10, all others 7 [Real]</td>
    </tr>
    <tr>
      <td>-Z</td>
      <td><input style="text-align: right;" name="Z" value="0" /></td>
      <td>X dropoff value for final gapped alignment in bits (0.0 invokes default behavior)<br/>blastn/megablast 100, tblastx 0, all others 25 [Integer]</td>
    </tr>
    <tr>
      <td>-R</td>
      <td><input name="R" type="file" /></td>
      <td>PSI-TBLASTN checkpoint file [File In]&nbsp; Optional</td>
    </tr>
    <tr>
      <td>-n</td>
      <td><select name="n"><option value="T">TRUE</option><option value="F" selected="selected">FALSE</option></select></td>
      <td>MegaBlast search</td>
    </tr>
    <tr>
      <td>-L</td>
      <td><input name="L" /></td>
      <td>Location on query sequence [String]&nbsp; Optional</td>
    </tr>
    <tr>
      <td>-A</td>
      <td><input style="text-align: right;" name="A" value="0" /></td>
      <td>Multiple Hits window size, default if zero (blastn/megablast 0, all others 40 [Integer]</td>
    </tr>
    <tr>
      <td>-w</td>
      <td><input style="text-align: right;" name="w" value="0" /></td>
      <td>Frame shift penalty (OOF algorithm for blastx) [Integer]</td>
    </tr>
    <tr>
      <td>-t</td>
      <td><input style="text-align: right;" name="t" value="0" /></td>
      <td>Length of the largest intron allowed in a translated nucleotide sequence when linking multiple distinct alignments. (0 invokes default behavior; a negative value disables linking.) [Integer]</td>
    </tr>
    <tr>
      <td>-B</td>
      <td><input style="text-align: right;" name="B" value="0" /></td>
      <td>Number of concatenated queries, for blastn and tblastn [Integer]&nbsp; Optional</td>
    </tr>
    <tr>
      <td>-V</td>
      <td><select name="V"><option value="T">TRUE</option><option value="F" selected="selected">FALSE</option></select></td>
      <td>Force use of the legacy BLAST engine&nbsp; Optional</td>
    </tr>
    <tr>
      <td>-C</td>
      <td>
      <table id="table_C" border="0" cellpadding="0" cellspacing="0">
        <tbody>
          <tr>
            <td><input name="C" value="0" type="radio" /></td>
            <td style="white-space: nowrap;">No composition-based statistics</td>
          </tr>
          <tr>
            <td><input name="C" value="1" type="radio" /></td>
            <td style="white-space: nowrap;">Composition-based statistics<br />as in NAR 29:2994-3005, 2001</td>
          </tr>
          <tr>
            <td><input name="C" value="2" type="radio" checked="checked" /></td>
            <td style="white-space: nowrap;">Composition-based score adjustment<br />as in Bioinformatics 21:902-911, 2005,<br />conditioned on sequence properties</td>
          </tr>
          <tr>
            <td><input name="C" value="3" type="radio" /></td>
            <td style="white-space: nowrap;">Composition-based score adjustment<br />as in Bioinformatics 21:902-911, 2005,<br />unconditionally</td>
          </tr>
          <tr>
            <td><select name="Cu"><option value="T">TRUE</option><option value="F" selected="selected">FALSE</option></select></td>
            <td style="white-space: nowrap;">Unified p-value combining alignment<br />p-value and compositional p-value<br />in round 1 only</td>
          </tr>
        </tbody>
      </table>
      </td>
      <td>Use composition-based score adjustments for blastp or tblastn</td>
    </tr>
    <tr>
      <td>-s</td>
      <td><select name="s"><option value="T">TRUE</option><option value="F" selected="selected">FALSE</option></select></td>
      <td>Compute locally optimal Smith-Waterman alignments (This option is only available for gapped tblastn.)</td>
    </tr>
    <tr>
      <td></td>
      <td colspan="2"><input type="submit" /><input type="reset" onclick="return confirm('Are you sure you want to reset the form?');"/></td>
    </tr>
  </tbody>
</table><?php 
    }
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * $Id: database_types.php 2459 2009-08-10 21:20:41Z pieterb $
 **************************************************************************/
/**
 * File documentation.
 * @todo Implement retrieval of info about individual database types.
 * @package Portal
 */
require_once 'include/global.php';
REST::require_method('GET', 'HEAD');
$path_info = Portal::path_info();
if (!empty($path_info[0])) {
    $id = Portal_DB::databaseTypeIDByName($path_info[0]);
    if (empty($id)) {
        REST::fatal(REST::HTTP_NOT_FOUND);
    }
    REST::header(REST::best_xhtml_type() . '; charset="UTF-8"');
    echo REST::html_start("Database type \"{$path_info[0]}\"") . Portal_DB::databaseTypeDescription($id) . REST::html_end();
    exit;
}
$directory = RESTDir::factory();
foreach (Portal_DB::databaseTypeIDs() as $id) {
    $directory->line(Portal_DB::databaseTypeName($id), array('Content-Type' => Portal_DB::databaseTypeContentType($id), 'Extension' => Portal_DB::databaseTypeExtension($id)));
}
$directory->end();
    public function doGET()
    {
        $options = Portal_DB::availableDatabases('formatdb');
        ?>
<script type="text/javascript">
  function addFileInput(sibling, name) {
    var fi = document.createElement('input'), br = document.createElement('br');
    fi.setAttribute('type', 'file');
    fi.setAttribute('name', name);
    sibling.parentNode.insertBefore(br, sibling);
    sibling.parentNode.insertBefore(fi, sibling)
  }
</script>
<table class="applicationparams" border="0" cellpadding="0"
  cellspacing="0">
  <tr>
    <th>Param</th>
    <th>Value</th>
    <th>Type</th>
    <th>Description</th>
  </tr>

  <tr>
    <td>-ch</td>
    <td><input type="text" name="ch" style="text-align: right"
      value="0.2" /></td>
    <td>[Real]</td>
    <td>high intensity cutoff as a fraction of max peak</td>
  </tr>
  <tr>
    <td>-ci</td>
    <td><input type="text" name="ci" style="text-align: right"
      value="0.0005" /></td>
    <td>[Real]</td>
    <td>intensity cutoff increment as a fraction of max peak</td>
  </tr>
  <tr>
    <td>-cl</td>
    <td><input type="text" name="cl" style="text-align: right"
      value="0.0" /></td>
    <td>[Real]</td>
    <td>low intensity cutoff as a fraction of max peak</td>
  </tr>
  <tr>
    <td>-conffile</td>
    <td><input type="file" name="conffile" /></td>
    <td>[File_In]</td>
    <td>Program's configuration (registry) data file</td>
  </tr>
  <tr>
    <td>-cp</td>
    <td><input type="text" name="cp" style="text-align: right" value="0" /></td>
    <td>[Integer]</td>
    <td>eliminate charge reduced precursors in spectra (0=no, 1=yes)</td>
  </tr>
  <tr>
    <td>-d</td>
    <td><select name="d">
    <?php 
        echo $options;
        ?>
    </select></td>
    <td>[String]</td>
    <td>Blast sequence library to search. Do not include .p* filename
    suffixes.</td>
  </tr>
  <tr>
    <td>-e</td>
    <td><input type="text" name="e" style="text-align: right" value="0" /></td>
    <td>[Integer]</td>
    <td>id number of enzyme to use</td>
  </tr>
  <tr>
    <td>-f</td>
    <td><input type="file" name="f" /></td>
    <td>[File_In]</td>
    <td>single dta file to search</td>
  </tr>
  <tr>
    <td>-fb</td>
    <td><input type="file" name="fb" /></td>
    <td>[File_In]</td>
    <td>multiple dta files separated by blank lines to search</td>
  </tr>
  <tr>
    <td>-fbz2</td>
    <td><input type="file" name="fbz2" /></td>
    <td>[File_In]</td>
    <td>omssa omx file compressed by bzip2</td>
  </tr>
  <tr>
    <td>-fm</td>
    <td><input type="file" name="fm" /></td>
    <td>[File_In]</td>
    <td>mgf formatted file</td>
  </tr>
  <tr>
    <td>-foms</td>
    <td><input type="file" name="foms" /></td>
    <td>[File_In]</td>
    <td>omssa oms file</td>
  </tr>
  <tr>
    <td>-fomx</td>
    <td><input type="file" name="fomx" /></td>
    <td>[File_In]</td>
    <td>omssa omx file</td>
  </tr>
  <tr>
    <td>-fp</td>
    <td><input type="file" name="fp" /></td>
    <td>[File_In]</td>
    <td>pkl formatted file</td>
  </tr>
  <tr>
    <td>-fx</td>
    <td><input type="file" name="fx" /></td>
    <td>[File_In]</td>
    <td>multiple xml-encapsulated dta files to search</td>
  </tr>
  <tr>
    <td>-fxml</td>
    <td><input type="file" name="fxml" /></td>
    <td>[File_In]</td>
    <td>omssa xml search request file</td>
  </tr>
  <tr>
    <td>-h1</td>
    <td><input type="text" name="h1" style="text-align: right" value="2" /></td>
    <td>[Integer]</td>
    <td>number of peaks allowed in single charge window</td>
  </tr>
  <tr>
    <td>-h2</td>
    <td><input type="text" name="h2" style="text-align: right" value="2" /></td>
    <td>[Integer]</td>
    <td>number of peaks allowed in double charge window</td>
  </tr>
  <tr>
    <td>-he</td>
    <td><input type="text" name="he" style="text-align: right" value="1" /></td>
    <td>[Real]</td>
    <td>the maximum evalue allowed in the hit list</td>
  </tr>
  <tr>
    <td>-hl</td>
    <td><input type="text" name="hl" style="text-align: right"
      value="30" /></td>
    <td>[Integer]</td>
    <td>maximum number of hits retained per precursor charge state per
    spectrum</td>
  </tr>
  <tr>
    <td>-hm</td>
    <td><input type="text" name="hm" style="text-align: right" value="2" /></td>
    <td>[Integer]</td>
    <td>the minimum number of m/z matches a sequence library peptide
    must have for the hit to the peptide to be recorded</td>
  </tr>
  <tr>
    <td>-hs</td>
    <td><input type="text" name="hs" style="text-align: right" value="4" /></td>
    <td>[Integer]</td>
    <td>the minimum number of m/z values a spectrum must have to be
    searched</td>
  </tr>
  <tr>
    <td>-ht</td>
    <td><input type="text" name="ht" style="text-align: right" value="6" /></td>
    <td>[Integer]</td>
    <td>number of m/z values corresponding to the most intense peaks
    that must include one match to the theoretical peptide</td>
  </tr>
  <tr>
    <td>-i</td>
    <td><input type="text" name="i" value="1,4" /></td>
    <td>[String]</td>
    <td>id numbers of ions to search (comma delimited, no spaces)</td>
  </tr>
  <tr>
    <td>-ii</td>
    <td><input type="text" name="ii" style="text-align: right"
      value="0.01" /></td>
    <td>[Real]</td>
    <td>evalue threshold to iteratively search a spectrum again, 0 =
    always</td>
  </tr>
  <tr>
    <td>-ir</td>
    <td><input type="text" name="ir" style="text-align: right"
      value="0.0" /></td>
    <td>[Real]</td>
    <td>evalue threshold to replace a hit, 0 = only if better</td>
  </tr>
  <tr>
    <td>-is</td>
    <td><input type="text" name="is" style="text-align: right"
      value="0.0" /></td>
    <td>[Real]</td>
    <td>evalue threshold to include a sequence in the iterative search,
    0 = all</td>
  </tr>
  <tr>
    <td>-logfile</td>
    <td><input type="text" name="logfile" value="" /></td>
    <td>[File_Out]</td>
    <td>File to which the program log should be redirected</td>
  </tr>
  <tr>
    <td>-mf</td>
    <td><input type="text" name="mf" value="" /></td>
    <td>[String]</td>
    <td>comma delimited (no spaces) list of id numbers for fixed
    modifications</td>
  </tr>
  <tr>
    <td>-mm</td>
    <td><input type="text" name="mm" style="text-align: right"
      value="128" /></td>
    <td>[Integer]</td>
    <td>the maximum number of mass ladders to generate per database
    peptide</td>
  </tr>
  <tr>
    <td>-mux</td>
    <td><input type="file" name="mux" /></td>
    <td>[File_In]</td>
    <td>file containing user modification data (defaults to usermods.xml
    as packaged with the application)</td>
  </tr>
  <tr>
    <td>-mv</td>
    <td><input type="text" name="mv" value="" /></td>
    <td>[String]</td>
    <td>comma delimited (no spaces) list of id numbers for variable
    modifications</td>
  </tr>
  <tr>
    <td>-mx</td>
    <td><input type="file" name="mx" /></td>
    <td>[String]</td>
    <td>file containing modification data (defaults to mods.xml as
    packaged with the application)</td>
  </tr>
  <tr>
    <td>-no</td>
    <td><input type="text" name="no" style="text-align: right" value="4" /></td>
    <td>[Integer]</td>
    <td>minimum size of peptides for no-enzyme and semi-tryptic searches</td>
  </tr>
  <tr>
    <td>-nox</td>
    <td><input type="text" name="nox" style="text-align: right"
      value="40" /></td>
    <td>[Integer]</td>
    <td>maximum size of peptides for no-enzyme and semi-tryptic searches
    (0=none)</td>
  </tr>
  <tr>
    <td>-nt</td>
    <td><input type="text" name="nt" style="text-align: right" value="0" /></td>
    <td>[Integer]</td>
    <td>number of search threads to use, 0=autodetect</td>
  </tr>
  <tr>
    <td>-o</td>
    <td><input type="text" name="o" value="" /></td>
    <td>[String]</td>
    <td>filename for text asn.1 formatted search results</td>
  </tr>
  <tr>
    <td>-ob</td>
    <td><input type="text" name="ob" value="" /></td>
    <td>[String]</td>
    <td>filename for binary asn.1 formatted search results</td>
  </tr>
  <tr>
    <td>-obz2</td>
    <td><input type="text" name="obz2" value="" /></td>
    <td>[String]</td>
    <td>filename for bzip2 compressed xml formatted search results</td>
  </tr>
  <tr>
    <td>-oc</td>
    <td><input type="text" name="oc" value="" /></td>
    <td>[String]</td>
    <td>filename for csv formatted search summary</td>
  </tr>
  <tr>
    <td>-op</td>
    <td><input type="text" name="op" value="" /></td>
    <td>[String]</td>
    <td>filename for pepXML formatted search results</td>
  </tr>
  <tr>
    <td>-ox</td>
    <td><input type="text" name="ox" value="" /></td>
    <td>[String]</td>
    <td>filename for xml formatted search results</td>
  </tr>
  <tr>
    <td>-p</td>
    <td><input type="text" name="p" value="" /></td>
    <td>[String]</td>
    <td>id numbers of ion series to apply no product ions at proline
    rule at (comma delimited, no spaces)</td>
  </tr>
  <tr>
    <td>-pc</td>
    <td><input type="text" name="pc" style="text-align: right" value="1" /></td>
    <td>[Integer]</td>
    <td>minimum number of precursors that match a spectrum</td>
  </tr>
  <tr>
    <td>-sb1</td>
    <td><input type="text" name="sb1" style="text-align: right"
      value="1" /></td>
    <td>[Integer]</td>
    <td>should first forward (b1) product ions be in search (1=no)</td>
  </tr>
  <tr>
    <td>-scorp</td>
    <td><input type="text" name="scorp" style="text-align: right"
      value="0.5" /></td>
    <td>[Real]</td>
    <td>probability of consecutive ion (used in correlation correction)</td>
  </tr>
  <tr>
    <td>-scorr</td>
    <td><input type="text" name="scorr" style="text-align: right"
      value="0" /></td>
    <td>[Integer]</td>
    <td>turn off correlation correction to score (1=off, 0=use
    correlation)</td>
  </tr>
  <tr>
    <td>-sct</td>
    <td><input type="text" name="sct" style="text-align: right"
      value="0" /></td>
    <td>[Integer]</td>
    <td>should c terminus ions be searched (1=no)</td>
  </tr>
  <tr>
    <td>-sp</td>
    <td><input type="text" name="sp" style="text-align: right"
      value="100" /></td>
    <td>[Integer]</td>
    <td>max number of ions in each series being searched (0=all)</td>
  </tr>
  <tr>
    <td>-ta</td>
    <td><input type="text" name="ta" style="text-align: right"
      value="1.0" /></td>
    <td>[Real]</td>
    <td>automatic mass tolerance adjustment fraction</td>
  </tr>
  <tr>
    <td>-te</td>
    <td><input type="text" name="te" style="text-align: right"
      value="2.0" /></td>
    <td>[Real]</td>
    <td>precursor ion m/z tolerance in Da</td>
  </tr>
  <tr>
    <td>-tem</td>
    <td><input type="text" name="tem" style="text-align: right"
      value="0" /></td>
    <td>[Integer]</td>
    <td>precursor ion search type (0 = mono, 1 = avg, 2 = N15, 3 =
    exact)</td>
  </tr>
  <tr>
    <td>-tex</td>
    <td><input type="text" name="tex" style="text-align: right"
      value="1446.94" /></td>
    <td>[Real]</td>
    <td>threshold in Da above which the mass of neutron should be added
    in exact mass search</td>
  </tr>
  <tr>
    <td>-tez</td>
    <td><input type="text" name="tez" style="text-align: right"
      value="0" /></td>
    <td>[Integer]</td>
    <td>charge dependency of precursor mass tolerance (0 = none, 1 =
    linear)</td>
  </tr>
  <tr>
    <td>-to</td>
    <td><input type="text" name="to" style="text-align: right"
      value="0.8" /></td>
    <td>[Real]</td>
    <td>product ion m/z tolerance in Da</td>
  </tr>
  <tr>
    <td>-tom</td>
    <td><input type="text" name="tom" style="text-align: right"
      value="0" /></td>
    <td>[Integer]</td>
    <td>product ion search type (0 = mono, 1 = avg, 2 = N15, 3 = exact)</td>
  </tr>
  <tr>
    <td>-v</td>
    <td><input type="text" name="v" style="text-align: right" value="1" /></td>
    <td>[Integer]</td>
    <td>number of missed cleavages allowed</td>
  </tr>
  <tr>
    <td>-w1</td>
    <td><input type="text" name="w1" style="text-align: right"
      value="20" /></td>
    <td>[Integer]</td>
    <td>single charge window in Da</td>
  </tr>
  <tr>
    <td>-w2</td>
    <td><input type="text" name="w2" style="text-align: right"
      value="14" /></td>
    <td>[Integer]</td>
    <td>double charge window in Da</td>
  </tr>
  <tr>
    <td>-x</td>
    <td><input type="text" name="x" value="0" /></td>
    <td>[String]</td>
    <td>comma delimited list of taxids to search (0 = all)</td>
  </tr>
  <tr>
    <td>-z1</td>
    <td><input type="text" name="z1" style="text-align: right"
      value="0.95" /></td>
    <td>[Real]</td>
    <td>fraction of peaks below precursor used to determine if spectrum
    is charge 1</td>
  </tr>
  <tr>
    <td>-zc</td>
    <td><input type="text" name="zc" style="text-align: right" value="1" /></td>
    <td>[Integer]</td>
    <td>should charge plus one be determined algorithmically? (1=yes)</td>
  </tr>
  <tr>
    <td>-zcc</td>
    <td><input type="text" name="zcc" style="text-align: right"
      value="2" /></td>
    <td>[Integer]</td>
    <td>how should precursor charges be determined? (1=believe the input
    file, 2=use a range)</td>
  </tr>
  <tr>
    <td>-zh</td>
    <td><input type="text" name="zh" style="text-align: right" value="3" /></td>
    <td>[Integer]</td>
    <td>maximum precursor charge to search when not 1+</td>
  </tr>
  <tr>
    <td>-zl</td>
    <td><input type="text" name="zl" style="text-align: right" value="1" /></td>
    <td>[Integer]</td>
    <td>minimum precursor charge to search when not 1+</td>
  </tr>
  <tr>
    <td>-zoh</td>
    <td><input type="text" name="zoh" style="text-align: right"
      value="2" /></td>
    <td>[Integer]</td>
    <td>maximum product charge to search</td>
  </tr>
  <tr>
    <td>-zt</td>
    <td><input type="text" name="zt" style="text-align: right" value="3" /></td>
    <td>[Integer]</td>
    <td>minimum precursor charge to start considering multiply charged
    products</td>
  </tr>
  <tr>
    <td>-dryrun</td>
    <td><input type="checkbox" name="dryrun" /></td>
    <td>[FLAG]</td>
    <td>Dry run the application: do nothing, only test all preconditions</td>
  </tr>
  <tr>
    <td>-el</td>
    <td><input type="checkbox" name="el" /></td>
    <td>[FLAG]</td>
    <td>print a list of enzymes and their corresponding id number</td>
  </tr>
  <tr>
    <td>-il</td>
    <td><input type="checkbox" name="il" /></td>
    <td>[FLAG]</td>
    <td>print a list of ions and their corresponding id number</td>
  </tr>
  <tr>
    <td>-ml</td>
    <td><input type="checkbox" name="ml" /></td>
    <td>[FLAG]</td>
    <td>print a list of modifications and their corresponding id number</td>
  </tr>
  <tr>
    <td>-mnm</td>
    <td><input type="checkbox" name="mnm" /></td>
    <td>[FLAG]</td>
    <td>n-term methionine should not be cleaved</td>
  </tr>
  <tr>
    <td>-ni</td>
    <td><input type="checkbox" name="ni" /></td>
    <td>[FLAG]</td>
    <td>don't print informational messages</td>
  </tr>
  <tr>
    <td>-ns</td>
    <td><input type="checkbox" name="ns" /></td>
    <td>[FLAG]</td>
    <td>depreciated flag</td>
  </tr>
  <tr>
    <td>-os</td>
    <td><input type="checkbox" name="os" /></td>
    <td>[FLAG]</td>
    <td>use omssa 1.0 scoring</td>
  </tr>
  <tr>
    <td>-umm</td>
    <td><input type="checkbox" name="umm" /></td>
    <td>[FLAG]</td>
    <td>use memory mapped sequence libraries</td>
  </tr>
  <tr>
    <td>-w</td>
    <td><input type="checkbox" name="w" /></td>
    <td>[FLAG]</td>
    <td>include spectra and search params in search results</td>
  </tr>

  <tr>
    <td colspan="4"><input type="submit" value="Run Application" /></td>
  </tr>
</table>
<?php 
    }
}
REST::require_method('GET', 'HEAD');
$path_info = Portal::path_info();
if (count($path_info) != 3) {
    REST::fatal(REST::HTTP_NOT_FOUND);
}
$file = explode('.', $path_info[2], 2);
if (!($database_id = (int) $file[0])) {
    REST::fatal(REST::HTTP_NOT_FOUND);
}
$user_id = Portal_User::current()->user_id();
$result = Portal_MySQL::query(<<<EOS
SELECT `d`.`name`,
       `d`.`version`,
       `d`.`type`,
       `d`.`checksum`,
       `u`.`user_name`
  FROM `Database` AS d LEFT JOIN `User` AS u USING(`user_id`)
 WHERE `d`.`database_id` = {$database_id}
   AND (`d`.`user_id` = {$user_id} OR `d`.`is_shared` = 1);
EOS
);
if (!($row = $result->fetch_row())) {
    REST::fatal(REST::HTTP_NOT_FOUND);
}
$fileinfo = @stat($realfilepath);
$filename = "{$row[0]}-{$row[1]}." . Portal_DB::databaseTypeExtension($row[2]);
REST::header(array('Content-Type' => Portal_DB::databaseTypeContentType($row[2]), 'Content-Encoding' => 'identity', 'Content-Disposition' => "attachment; filename=\"{$filename}\"", 'Last-Modified' => REST::http_date($fileinfo['mtime']), 'ETag' => "\"{$row[3]}\"", 'X-Creator-Name' => $row[4], 'Content-Length' => $fileinfo['size']));
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    readfile($realfilepath);
}
$options = '';
foreach (Portal_DB::databaseTypeIDs() as $databaseTypeID) {
    $databaseTypeName = Portal_DB::databaseTypeName($databaseTypeID);
    $options .= "\n<option value=\"{$databaseTypeName}\">{$databaseTypeName}</option>";
}
$directory = RESTDir::factory("{$path_info[0]}, version {$path_info[1]}")->setForm(<<<EOS
<h1>Database upload</h1>
<form method="post" action="./" enctype="multipart/form-data">
<input type="file" name="dbfile" /><br />
<input type="checkbox" name="shared" value="1" /> Share this database with others<br />
Database type: <select name="type">
{$options}
</select><br />
<input type="submit" value="Upload" />
</form>
EOS
);
$user_id = Portal_User::current()->user_id();
$result = Portal_MySQL::query(<<<EOS
SELECT `user_name`, `database_id`, `type` FROM `Database` LEFT JOIN `User` USING(`user_id`)
WHERE `name` = {$dbname}
  AND `version` = {$dbversion}
  AND ( `is_shared` > 0 OR `Database`.`user_id` = {$user_id})
ORDER BY 3, 1;
EOS
);
while ($row = $result->fetch_array()) {
    $filesize = filesize(Portal_DB::DATABASE_DIR . $row[1]);
    $directory->line($row[1] . '.' . Portal_DB::databaseTypeExtension($row[2]), array('Size' => filesize(Portal_DB::DATABASE_DIR . $row[1]) . ' B', 'DBType' => Portal_DB::databaseTypeName($row[2]), 'Creator' => $row[0], 'Content-Type' => Portal_DB::databaseTypeContentType($row[2])));
}
$directory->end();
    public function doGET()
    {
        $db_options = Portal_DB::availableDatabases('csbfa');
        ?>
<style type="text/css">
table#table_options {
  border-collapse: collapse;
}
table#table_options td {
  border: 1px solid lightgrey;
  vertical-align: top;
}
  </style>
<table style="text-align: left;" id="table_options" border="0" cellpadding="2" cellspacing="0">
  <tbody>
    <tr>
      <th>Option</th>
      <th>Type</th>
      <th>Value</th>
      <th>Explanation</th>
    </tr>
    <tr>
      <td valign="top">&lt;chr&gt;</td>
      <td>INFILE</td>
      <td valign="top">
        <select name="chr"><?php 
        echo $db_options;
        ?>
</select>
      </td>
      <td valign="top">Chromosome reference (FASTA) (required)</td>
    </tr>
    <tr>
      <td valign="top">&lt;reads_1.bfq&gt;</td>
      <td>INFILE</td>
      <td valign="top"><input name="reads_1" type="file" /></td>
      <td valign="top">First read (BFQ) (required)</td>
    </tr>
    <tr>
      <td valign="top">&lt;reads_2.bfq&gt;</td>
      <td>INFILE</td>
      <td valign="top"><input name="reads_2" type="file" /></td>
      <td valign="top">Second read (BFQ) (optional)</td>
    </tr>
    <tr>
      <td>-1</td>
      <td>INT</td>
      <td><input type="text" style="text-align: right;" name="1" value="0" /></td>
      <td>length of the first read (&lt;=127)</td>
    </tr>
    <tr>
      <td>-2</td>
      <td>INT</td>
      <td><input type="text" style="text-align: right;" name="2" value="0" /></td>
      <td>length of the second read (&lt;=127)</td>
    </tr>
    <tr>
      <td>-m</td>
      <td>FLOAT</td>
      <td><input type="text" style="text-align: right;" name="m" value="0.001" /></td>
      <td>rate of difference between reads and references</td>
    </tr>
    <tr>
      <td>-e</td>
      <td>INT</td>
      <td><input type="text" style="text-align: right;" name="e" value="70" /></td>
      <td>maximum allowed sum of qualities of mismatches</td>
    </tr>
    <tr>
      <td>-d</td>
      <td>OUTFILE</td>
      <td><input type="checkbox" name="d" value="1" /></td>
      <td>adapter sequence file</td>
    </tr>
    <tr>
      <td>-a</td>
      <td>INT</td>
      <td><input type="text" style="text-align: right;" name="a" value="250" /></td>
      <td>max distance between two paired reads</td>
    </tr>
    <tr>
      <td>-A</td>
      <td>INT</td>
      <td><input type="text" style="text-align: right;" name="A" value="0" /></td>
      <td>max distance between two RF paired reads</td>
    </tr>
    <tr>
      <td>-n</td>
      <td>INT</td>
      <td><input type="text" style="text-align: right;" name="n" value="2" /></td>
      <td>number of mismatches in the first 24bp</td>
    </tr>
    <tr>
      <td>-M</td>
      <td>SELECT</td>
      <td><select name="M">
        <option value="" selected="selected"></option>
        <option value="c">c</option>
        <option value="g">g</option>
      </select></td>
      <td>methylation alignment mode</td>
    </tr>
    <tr>
      <td>-u</td>
      <td>OUTFILE</td>
      <td><input type="checkbox" name="u" value="1" /></td>
      <td>dump unmapped and poorly aligned reads to FILE</td>
    </tr>
    <tr>
      <td>-H</td>
      <td>OUTFILE</td>
      <td><input type="checkbox" name="H" value="1" /></td>
      <td>dump multiple/all 01-mismatch hits to FILE</td>
    </tr>
    <tr>
      <td>-C</td>
      <td>INT</td>
      <td><input type="text" style="text-align: right;" name="C" value="250" /></td>
      <td>max number of hits to output. &gt;512 for all 01 hits.</td>
    </tr>
    <tr>
      <td>-s</td>
      <td>INT</td>
      <td><input type="text" style="text-align: right;" name="s" value="" /></td>
      <td>seed for random number generator (Default: random)</td>
    </tr>
    <tr>
      <td>-W</td>
      <td>FLAG</td>
      <td><input type="checkbox" name="W" value="1" /></td>
      <td>disable Smith-Waterman alignment</td>
    </tr>
    <tr>
      <td>-t</td>
      <td>FLAG</td>
      <td><input type="checkbox" name="t" value="1" /></td>
      <td>trim all reads (usually not recommended)</td>
    </tr>
    <tr>
      <td>-c</td>
      <td>FLAG</td>
      <td><input type="checkbox" name="c" value="1" /></td>
      <td>match in the colorspace</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td colspan="2"><input type="submit" /><input type="reset" onclick="return confirm('Are you sure you want to reset the form?');"/></td>
    </tr>
  </tbody>
</table><?php 
    }