} } //var_dump($resultarray); //echo json_encode($resultarray); $jsonstring = ""; $jsonstring = $jsonstring . "[\n"; foreach ($resultarray as $key => $value) { $jsonstring = $jsonstring . "{\n"; $jsonstring = $jsonstring . "\"name\" : \"{$key}\", \n"; $jsonstring = $jsonstring . "\"borderWidth\": 1,\n"; $jsonstring = $jsonstring . "\"data\": ["; for ($i = 1; $i <= 512; $i++) { if (array_key_exists($i, $resultarray[$key])) { $jsonstring = $jsonstring . "[" . getx($i) . "," . gety($i) . "," . $resultarray[$key][$i] . "],\n"; } else { $jsonstring = $jsonstring . "[" . getx($i) . "," . gety($i) . ",0],\n"; } } $jsonstring = $jsonstring . "],\n\"dataLabels\": {\n \"enabled\": true,\n \"color\":\"black\",\n \"style\": {\n \"textShadow\": \"none\"\n }\n }\t"; $jsonstring = $jsonstring . "},\n"; } $jsonstring = $jsonstring . "]\n"; if ($_GET["prev"] == 1) { include 'savejson.php'; } } $sqlcheck = "insert into jsonstore (name,json) VALUES ('do_not_delete','1');"; //echo $sqlcheck; $sqlchecksecurity = $mindb_connection->query($sqlcheck); $drop1 = "drop table last_align_basecalled_template;"; $drop2 = "drop table last_align_basecalled_complement;";
function readsperpore($jobname, $currun) { $checkvar = $currun . $jobname; $checkrunning = $currun . $jobname . "status"; global $memcache; global $mindb_connection; global $reflength; //$jsonstring = $memcache->get("$checkvar"); $checkingrunning = $memcache->get("{$checkrunning}"); if ($checkingrunning === "No" || $checkingrunning === FALSE) { $memcache->set("{$checkrunning}", "YES", 0, 0); $checkrow = "select name,json from jsonstore where name = '" . $jobname . "' ;"; $checking = $mindb_connection->query($checkrow); if ($checking->num_rows == 1) { //echo "We have already run this!"; foreach ($checking as $row) { $jsonstring = $row['json']; } } else { $sql_template = "select count(*) as count, channel from basecalled_template inner join config_general using (basename_id) group by channel order by channel;"; $resultarray; $template = $mindb_connection->query($sql_template); if ($template->num_rows >= 1) { foreach ($template as $row) { $resultarray['template'][$row['channel']] = $row['count']; } } //var_dump($resultarray); //echo json_encode($resultarray); $jsonstring; $jsonstring = $jsonstring . "[\n"; foreach ($resultarray as $key => $value) { $jsonstring = $jsonstring . "{\n"; $jsonstring = $jsonstring . "\"name\" : \"{$key}\", \n"; $jsonstring = $jsonstring . "\"borderWidth\": 1,\n"; $jsonstring = $jsonstring . "\"data\": ["; for ($i = 1; $i <= 512; $i++) { if (array_key_exists($i, $resultarray[$key])) { $jsonstring = $jsonstring . "[" . getx($i) . "," . gety($i) . "," . $resultarray[$key][$i] . "],\n"; } else { $jsonstring = $jsonstring . "[" . getx($i) . "," . gety($i) . ",0],\n"; } } $jsonstring = $jsonstring . "],\n\"dataLabels\": {\n \"enabled\": true,\n \"color\":\"black\",\n \"style\": {\n \"textShadow\": \"none\"\n }\n }\t"; $jsonstring = $jsonstring . "},\n"; } $jsonstring = $jsonstring . "]\n"; if ($_GET["prev"] == 1) { include 'savejson.php'; } } $memcache->set("{$checkvar}", $jsonstring); } else { $jsonstring = $memcache->get("{$checkvar}"); } // cache for 2 minute as we want yield to update semi-regularly... $memcache->delete("{$checkrunning}"); return $jsonstring; }