示例#1
0
<?php

include '../../phpdb/dbExpertConnector.php';
$connector = new dbConnector();
$buffer = $connector->query("SELECT block_id,tree,treestring,sequences,base_score,game_par,game_highscore FROM bioblocks");
while ($myrow = $connector->fetchArray($buffer)) {
    /* misc variables */
    $blockid = $myrow['block_id'];
    $tree_string = $myrow['treestring'];
    /* build species list */
    $tree_struct = $myrow['tree'];
    $speclist = array();
    $newid = "";
    for ($i = 0; $i <= strlen($tree_struct); $i++) {
        $carac = substr($tree_struct, $i, 1);
        if ($carac == '(' or $carac == ')' or $carac == ',') {
            if ($newid != "") {
                array_push($speclist, $newid);
                $newid = "";
            }
        } else {
            $newid .= $carac;
        }
    }
    /* build sequence array */
    $fulldataseqs = json_decode($myrow['sequences'], true);
    $sequences = $fulldataseqs['sequence'];
    /* combine */
    $fullsequences = array_combine($speclist, $sequences);
    /* compute real score */
    $treefilename = $blockid . ".tree";
示例#2
0
    }
}
/* define arguments to submit */
$id = $_POST['stage'];
$user = $_POST['user'];
$score = $_POST['score'];
$fulltree = $_POST['tree'];
/* retrieve missing data */
$connector = new dbConnector();
/* id syntax: s<num> from bioblocks & x<num> from expertblocks                           */
/* if it starts with x, one must look into the expertblock data to know the bioblocks id */
$prefix = $id[0];
$suffix = substr($id, 1);
if ($prefix == 's') {
    $buffer = $connector->query("SELECT tree,treestring FROM bioblocks WHERE block_id = {$suffix}");
    $xarray = $connector->fetchArray($buffer);
    $tree_string = $xarray['treestring'];
    $tree_struct = $xarray['tree'];
    $bio_id = $suffix;
} elseif ($prefix == 'x') {
    $buffer = $connector->query("SELECT bioblock_id,tree,treestring FROM expertblocks WHERE block_id = {$suffix}");
    $xarray = $connector->fetchArray($buffer);
    $tree_string = $xarray['treestring'];
    $tree_struct = $xarray['tree'];
    $bio_id = $xarray['bioblock_id'];
}
/* build species list */
$speclist = array();
$newid = "";
for ($i = 0; $i <= strlen($tree_struct); $i++) {
    $carac = substr($tree_struct, $i, 1);