$history_box .= "<LI>View the <A href=\"{$variant_name};{$next_version}\">next version</A>"; } if ($next_version) { $history_box .= "<LI>View the <A href=\"{$variant_name}\">latest version"; } else { $history_box .= "<LI>View <A href=\"{$variant_name}\">this version without highlighted changes"; } $history_box .= "</A>"; if (getCurrentUser()) { $history_box .= " and enable editing features"; } $history_box .= "</LI>\n"; $history_box .= "</UL></DIV>"; $gDisableEditing = TRUE; } $report =& evidence_get_report($history_box && $max_edit_id ? 0 + $max_edit_id : "latest", $variant_id); $row0 =& $report[0]; $variant_name_long = evidence_get_variant_name($row0, " ", false); $variant_name_short = evidence_get_variant_name($row0, " ", true); $gOut["title"] = "{$variant_name_short} - GET-Evidence"; $gOut["content"] = "<h1>{$variant_name_short}</h1>\n<!-- {$variant_id} -->\n"; if ($variant_name_long != $variant_name_short) { $gOut["content"] .= "<p>({$variant_name_long})</p>\n"; } $gOut["content"] .= seealso_related($row0["variant_gene"], $row0["variant_aa_pos"], $variant_id); $gOut["content"] .= $history_box; $renderer = new evidence_row_renderer(); foreach ($report as $row) { if ($row["article_pmid"] > 0 || $row["genome_id"] > 0) { break; }
function evidence_get_assoc($snap, $variant_id) { $rows =& evidence_get_report($snap, $variant_id); global $gWantKeysForAssoc; if (!is_array($gWantKeysForAssoc["variant"])) { foreach ($gWantKeysForAssoc as $k => &$v) { if ($k == "all") { continue; } $v = explode(" ", $gWantKeysForAssoc["all"] . " " . $v); } } $variant = array("genomes" => array(), "articles" => array(), "diseases" => array()); for ($i = 0; $i < sizeof($rows); $i++) { $row =& $rows[$i]; $editor = user::lookup($row["edit_oid"]); $row["editor_name"] = $editor->get("fullname"); if (strlen($row["summary_long"]) == 0) { $row["summary_long"] = $row["summary_short"]; } if ($row["article_pmid"] > 0) { $section =& $variant["articles"]["" . $row["article_pmid"]]; $want_keys =& $gWantKeysForAssoc["article"]; } else { if ($row["genome_id"] > 0) { $section =& $variant["genomes"]["" . $row["genome_id"]]; $want_keys =& $gWantKeysForAssoc["genome"]; } else { $section =& $variant; $want_keys =& $gWantKeysForAssoc["variant"]; $row["aa_change"] = $row["variant_aa_from"] . $row["variant_aa_pos"] . $row["variant_aa_to"]; $row["aa_change_short"] = aa_short_form($row["aa_change"]); // TODO: combine these into one array and add labels $row["quality_scores"] = str_split(str_pad($row["variant_quality"], 6, "-")); $row["quality_comments"] = $row["variant_quality_text"] ? json_decode($row["variant_quality_text"], true) : array(); $diseases = evidence_get_all_oddsratios($rows); unset($max_or_id); foreach ($diseases as $id => &$d) { if (!isset($max_or_id) || $diseases[$max_or_id]["figs"]["or"] < $d["figs"]["or"]) { $max_or_id = $id; } } if (isset($max_or_id)) { $row["disease_max_or"] = $diseases[$max_or_id]; } } } if ($row["disease_id"] > 0) { $section =& $section["diseases"]["" . $row["disease_id"]]; if (ereg('^\\[', $row["summary_short"])) { $row = array_merge(json_decode($row["summary_short"], true), $row); } $want_keys =& $gWantKeysForAssoc["disease"]; } foreach ($want_keys as $k) { list($inkey, $outkey) = explode(":", $k); if (!$outkey) { $outkey = $inkey; } $section[$outkey] = $row[$inkey]; } unset($section); } foreach (array("articles", "genomes") as $section) { $variant[$section] = array_values($variant[$section]); foreach ($variant[$section] as &$x) { if (is_array($x["diseases"])) { $x["diseases"] = array_values($x["diseases"]); } } } return $variant; }
include "lib/openid.php"; evidence_create_tables(); openid_create_tables(); if ($_REQUEST["test-insert"]) { if (!getCurrentUser("is_admin")) { die("yours is not an admin account."); } header("Content-type: text/plain"); $variant_id = evidence_get_variant_id("NPHP4", 848, "Arg", "Trp", true); $e = evidence_edit_id_generate(null, $variant_id); evidence_save_draft($e, array("variant_impact" => "unknown", "variant_dominance" => "unknown", "summary_short" => "This variant has been found together with R682X as a compound heterozygote in three nephronophthisis and retinitis pigmentosa, (Senior-Loken syndrome) patients from one family.")); print "after evidence_save_draft\n"; print_r(theDb()->getRow("SELECT * FROM edits WHERE edit_id=?", array($e))); evidence_submit($e); print "after evidence_submit\n"; print_r(evidence_get_report("latest", $variant_id)); evidence_signoff($e); $a = evidence_edit_id_generate(null, $variant_id); evidence_save_draft($a, array("article_pmid" => 12205563, "summary_short" => "Otto, E. et al. A gene mutated in nephronophthisis and retinitis pigmentosa encodes a novel protein, nephroretinin, conserved in evolution. Am J Hum Genet 71, 1161-1167, doi:S0002-9297(07)60408-X [pii]")); evidence_submit($a); evidence_signoff($a); $a = evidence_edit_id_generate(null, $variant_id); evidence_save_draft($a, array("article_pmid" => 9734597, "summary_short" => "Lemmink, H. H. et al. Novel mutations in the thiazide-sensitive NaCl cotransporter gene in patients with Gitelman syndrome with predominant localization to the C-terminal domain. Kidney Int 54, 720-730, doi:10.1046/j.1523-1755.1998.00070.x (1998).")); evidence_submit($a); print "release:\n"; print_r(evidence_get_report("release", $variant_id)); print "latest:\n"; print_r(evidence_get_report("latest", $variant_id)); } else { header("Location: /"); }