Esempio n. 1
0
function evidence_render_history($variant_id)
{
    $html = "<UL>\n";
    $thisyear = strftime("%Y", time());
    $today = strftime("%b %e %Y", time());
    $q = theDb()->query("\nSELECT\n UNIX_TIMESTAMP(edit_timestamp) AS edit_timestamp,\n edit_oid,\n u.fullname AS edit_fullname,\n article_pmid,\n s.genome_id AS genome_id,\n s.disease_id AS disease_id,\n d.disease_name AS disease_name,\n IF(g.name IS NULL OR g.name='',concat('[',global_human_id,']'),g.name) AS genome_name,\n is_delete,\n previous_edit_id,\n edit_id,\n v.*\nFROM edits s\nLEFT JOIN variants v ON v.variant_id=s.variant_id\nLEFT JOIN eb_users u ON u.oid=s.edit_oid\nLEFT JOIN genomes g ON g.genome_id=s.genome_id\nLEFT JOIN diseases d ON d.disease_id=s.disease_id\nWHERE s.variant_id=? AND is_draft=0\nORDER BY edit_timestamp DESC, edit_id DESC, previous_edit_id DESC\n", array($variant_id));
    if (theDb()->isError($q)) {
        die($q->getMessage());
    }
    $lastli = "";
    while ($row =& $q->fetchRow()) {
        $li = "<LI>";
        $nicetime = strftime("%b %e %Y %l:%M%P", $row["edit_timestamp"]);
        $nicetime = str_replace("  ", " ", $nicetime);
        $nicetime = str_replace("{$today} ", "", $nicetime);
        $nicetime = str_replace("{$thisyear} ", "", $nicetime);
        $nicetime = ereg_replace(" [^ ]+\$", "", $nicetime);
        $li .= $nicetime;
        $li .= " <A href=\"edits?oid=" . urlencode($row["edit_oid"]) . "\">" . htmlspecialchars($row["edit_fullname"]) . "</A> ";
        $summary = "";
        if ($row["is_delete"]) {
            $li .= "removed ";
        } else {
            if ($row["previous_edit_id"]) {
                $li .= "edited ";
                $summary = " summary";
            } else {
                $li .= "added ";
            }
        }
        if ($row["disease_id"]) {
            $li .= "OR figures for " . htmlspecialchars($row["disease_name"]) . " from " . ($row["article_pmid"] ? "article " . $row["article_pmid"] : "unpublished research section");
        } else {
            if ($row["article_pmid"]) {
                $li .= "article " . htmlspecialchars($row["article_pmid"]) . $summary;
            } else {
                if ($row["genome_id"]) {
                    $li .= htmlspecialchars($row["genome_name"]) . $summary;
                } else {
                    $li .= "variant{$summary}";
                }
            }
        }
        $variant_name = evidence_get_variant_name(&$row, "-");
        $li .= " <A href=\"" . $variant_name . ";" . $row["edit_id"] . "\">view</A>";
        $li .= "</LI>\n";
        // Compress sequences of same type of edit (same person, date, etc.)
        if ($li != $lastli) {
            $html .= $li;
        } else {
            // TODO: offer to expand these in case the person wants to
            // recover an intermediate edit
        }
        $lastli = $li;
    }
    $html .= "</UL>\n";
    return $html;
}
Esempio n. 2
0
function print_content($x)
{
    global $report_title, $where_sql, $where_param, $orderby_sql;
    if (!$_GET["bareli"]) {
        print "<h1>{$report_title}</h1>\n\n";
    }
    $sql_limit = $_GET["all"] ? "" : "LIMIT 300";
    $q = theDb()->query("SELECT *, diseases.disease_name disease_name, edits.genome_id genome_id, UNIX_TIMESTAMP(edit_timestamp) t FROM edits\n\tLEFT JOIN eb_users ON edit_oid=oid\n\tLEFT JOIN variants ON variants.variant_id=edits.variant_id\n\tLEFT JOIN genomes ON edits.genome_id>0 AND edits.genome_id=genomes.genome_id\n\tLEFT JOIN diseases ON diseases.disease_id=edits.disease_id\n\tWHERE {$where_sql} AND is_draft=0\n\tORDER BY {$orderby_sql}\n\t{$sql_limit}", $where_param);
    if (theDb()->isError($q)) {
        die($q->getMessage());
    }
    $relevant_fields = array("is_delete", "variant_id", "article_pmid", "genome_id", "disease_id", "edit_oid");
    $lastrow = FALSE;
    $output_count = 0;
    if (!$_GET["bareli"]) {
        print "<UL>";
    }
    while ($row =& $q->fetchRow()) {
        if ($lastrow && arrays_partially_equal($lastrow, $row, $relevant_fields) && $lastrow["previous_edit_id"] > 0 == $row["previous_edit_id"] > 0) {
            continue;
        }
        $variant_link = evidence_get_variant_name($row, " ", true);
        $version_link = "<A href=\"" . evidence_get_variant_name(&$row, "-") . ";{$row['edit_id']}\">view</A>";
        if (!$lastrow || $lastrow[variant_id] != $row[variant_id]) {
            $variant_link = "<A href=\"" . evidence_get_variant_name(&$row, "-") . "\">{$variant_link}</A>";
        }
        $lastrow = $row;
        print "<LI>";
        print strftime("%b %e ", $row["t"]);
        print $variant_link;
        if ($row["is_delete"] && !$row["article_pmid"] && !$row["genome_id"] && !$row["disease_id"]) {
            print " deleted by ";
        } else {
            if (!$row["previous_edit_id"] && !$row["article_pmid"] && !$row["genome_id"]) {
                print " added by ";
            } else {
                print " edited by ";
            }
        }
        print "<A href=\"edits?oid=" . urlencode($row["edit_oid"]) . "\">" . htmlspecialchars($row["fullname"] ? $row["fullname"] : $row["nickname"]) . "</A>";
        if ($row["genome_id"]) {
            if (!($genome_name = $row["name"])) {
                if (!($genome_name = $row["global_human_id"])) {
                    $genome_name = "#" . $row["genome_id"];
                }
            }
        }
        $genome_name = htmlspecialchars($genome_name);
        if ($row["article_pmid"] && $row["is_delete"]) {
            print " (PMID {$row['article_pmid']} removed)";
        } else {
            if ($row["genome_id"] && $row["is_delete"]) {
                print " ({$genome_name} removed)";
            } else {
                if ($row["article_pmid"] && !$row["previous_edit_id"]) {
                    print " (PMID {$row['article_pmid']} added)";
                } else {
                    if ($row["genome_id"] && !$row["previous_edit_id"]) {
                        print " ({$genome_name} added)";
                    } else {
                        if ($row["disease_id"]) {
                            print " (" . htmlspecialchars($row["disease_name"]) . ")";
                        }
                    }
                }
            }
        }
        print " -- {$version_link}";
        print "</LI>\n";
        if (!$_GET["all"] && ++$output_count >= 30) {
            print "<SPAN>&nbsp;<BR />\n";
            foreach (array("", "&all=1") as $all) {
                print "<BUTTON onclick=\"\$('busysignal').removeClassName('csshide'); this.disabled = true; new Ajax.Updater (this.parentNode, 'edits?" . htmlentities(ereg_replace('&?(before_edit_id|bareli)=[0-9]+', '', $_SERVER[QUERY_STRING])) . "&before_edit_id={$row[edit_id]}&bareli=1{$all}', { onFailure: function() { this.disabled = false; \$('busysignal').addClassName('csshide'); } }); return false;\">" . ($all == "" ? "Next page" : "Show all") . "</BUTTON> &nbsp; \n";
            }
            print " <IMG style=\"vertical-align: middle;\" id=\"busysignal\" class=\"csshide\" src=\"/img/busy.gif\" width=\"16\" height=\"16\" alt=\"\" /></SPAN>\n";
            break;
        }
    }
    if (!$_GET["bareli"]) {
        print "</UL>\n";
    }
}
Esempio n. 3
0
        $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;
    }
    $renderer->render_row($row);
}
$gOut["content"] .= $renderer->html();
Esempio n. 4
0
function print_content()
{
    global $config;
    global $sql_where;
    global $sql_having;
    global $sql_occur_filter;
    global $sql_orderby;
    global $sql_right_join;
    global $sql_params;
    global $min_certainty;
    global $max_certainty;
    global $snap;
    global $gTheTextile;
    global $want_column;
    $q = theDb()->query($sql = "\nSELECT s.*, v.*, g.*, fs.*,\n-- gs.summary_short AS g_summary_short,\n MAX(o.zygosity) AS max_zygosity,\n d.dataset_id AS d_dataset_id,\n g.genome_id AS g_genome_id,\n y.hitcount AS hitcount,\n vf.f AS variant_frequency\nFROM snap_{$snap} s\n{$sql_right_join}\nLEFT JOIN flat_summary fs ON s.variant_id=fs.variant_id\nLEFT JOIN variants v ON s.variant_id=v.variant_id\nLEFT JOIN variant_frequency vf ON vf.variant_id=v.variant_id\nLEFT JOIN variant_occurs o ON v.variant_id=o.variant_id AND {$sql_occur_filter}\nLEFT JOIN datasets d ON o.dataset_id=d.dataset_id\nLEFT JOIN genomes g ON d.genome_id=g.genome_id\nLEFT JOIN yahoo_boss_cache y ON s.variant_id=y.variant_id\nLEFT JOIN variant_external omim ON omim.variant_id=s.variant_id AND omim.tag='OMIM'\n-- LEFT JOIN snap_{$snap} gs ON gs.variant_id=s.variant_id AND gs.article_pmid=0 AND gs.genome_id=g.genome_id\nWHERE s.article_pmid=0 AND s.genome_id=0 AND s.disease_id=0 AND {$sql_where}\nGROUP BY v.variant_id,g.genome_id\nHAVING {$sql_having}\n{$sql_orderby}\n", $sql_params);
    $colcount = 5 + count($want_column);
    if (theDb()->isError($q)) {
        die("DB Error: " . $q->getMessage() . "<br>" . $sql);
    }
    print "<TABLE class=\"report_table\" style=\"width: 100%\">\n";
    print "<TR><TD colspan=\"{$colcount}\" id=\"reportpage_turner_copy\" style=\"text-align: right;\">&nbsp;</TD></TR>\n";
    print "<TR><TH>" . join("</TH><TH>", array("Variant", "Impact", "Inheritance pattern", "Summary", "Genomes"));
    foreach ($want_column as $k => $v) {
        print "</TH><TH>{$v}";
    }
    print "</TH></TR>\n";
    $output_row = 0;
    $output_page = 0;
    $output_cut_off_after = 0;
    $tr_attrs = "";
    $genome_rows = array();
    for ($row =& $q->fetchRow(); $row; $row =& $nextrow) {
        $row["name"] = $row["name"] ? $row["name"] : "[" . $row["global_human_id"] . "]";
        $genome_rows[$row["genome_id"]] = $row;
        $nextrow =& $q->fetchRow();
        if ($nextrow && $row["variant_id"] == $nextrow["variant_id"]) {
            continue;
        }
        $certainty = evidence_compute_certainty($row["variant_quality"], $row["variant_impact"]);
        $certainty = substr($certainty, 0, 1);
        if ($certainty == 0 && ($min_certainty == 0 || $max_certainty == -1)) {
            // need to distinguish between "insufficiently evaluated" and "uncertain"
            $have_2or3 = 0;
            $have_4or5 = 0;
            $nonempty_scores = 0;
            $category_index = -1;
            $scores = str_split(str_pad($row["variant_quality"], 6, "-"));
            foreach ($scores as $score) {
                if ($score != "-") {
                    ++$nonempty_scores;
                }
            }
            if ($nonempty_scores < 4 || $scores[2] == "-" && $scores[3] == "-" || $scores[4] == "-" && $scores[5] == "-") {
                $certainty = -1;
            }
        }
        if ($min_certainty > $certainty || $max_certainty < $certainty) {
            $genome_rows = array();
            continue;
        }
        ++$output_row;
        if ($output_row % $config["ROWSPERPAGE"] == 1) {
            ++$output_page;
            $tr_attrs = " class=\"reportpage reportpage_{$output_page}\"";
            if ($output_page > 1) {
                $tr_attrs = " class=\"reportpage reportpage_{$output_page} csshide\"";
            }
        }
        if ($output_page > $config["MAXPAGES"]) {
            if (!$output_cut_off_after) {
                $output_cut_off_after = $output_row - 1;
            }
            $genome_rows = array();
            continue;
        }
        $variant_name_display = evidence_get_variant_name($row, "&nbsp;", true);
        $variant_name_link = evidence_get_variant_name($row, "-", true);
        $rowspan = count($genome_rows);
        if ($rowspan < 1) {
            $rowspan = 1;
        }
        $rowspan = "rowspan=\"{$rowspan}\"";
        $impact = ereg_replace("^likely ", "l.", $row["variant_impact"]);
        if ($certainty == -1) {
            $impact = "insufficiently evaluated / uncertain {$impact}";
        } else {
            if ($certainty == 1) {
                $impact = "likely {$impact}";
            } else {
                if ($certainty <= 0) {
                    $impact = "uncertain {$impact}";
                }
            }
        }
        if (strlen($row["variant_frequency"])) {
            $impact .= sprintf(", f=%.3f", $row["variant_frequency"]);
        }
        $summary_short = $gTheTextile->textileRestricted($row["summary_short"]);
        if ($row["hitcount"] > 0) {
            $s = $row["hitcount"] == 1 ? "" : "s";
            $summary_short .= "<P>({$row['hitcount']} web hit{$s})</P>";
        }
        printf("<TR{$tr_attrs}><TD {$rowspan}>%s</TD><TD {$rowspan}>%s</TD><TD {$rowspan}>%s</TD><TD {$rowspan}>%s</TD>", "<A href=\"{$variant_name_link}\">{$variant_name_display}</A>", $impact, $row["variant_dominance"], $summary_short);
        $rownum = 0;
        foreach ($genome_rows as $id => $row) {
            if (++$rownum > 1) {
                print "</TR>\n<TR{$tr_attrs}>";
            }
            if (!$row["g_genome_id"]) {
                print "<TD></TD>";
            } else {
                print "<TD width=\"15%\"><A href=\"{$variant_name_link}#g{$id}\">" . htmlspecialchars($row["name"]) . "</A>";
                if ($row["max_zygosity"] == 'homozygous') {
                    print " (hom)";
                }
                print "</TD>";
            }
            if ($rownum == 1) {
                foreach ($want_column as $k => $v) {
                    printf("<TD {$rowspan}>%s</TD>", $row[$k]);
                }
            }
        }
        print "</TR>\n";
        $genome_rows = array();
    }
    if ($output_page > 1) {
        print "<TR><TD colspan=\"{$colcount}\" id=\"reportpage_turner\" style=\"text-align: right;\">Page: ";
        for ($p = 1; $p <= $output_page && $p <= $config["MAXPAGES"]; $p++) {
            print "<A class=\"reportpage_turnbutton\" href=\"#\" onclick=\"reportpage_goto({$p});\">{$p}</A> ";
        }
        print "<BR /><STRONG>Total results: {$output_row}</STRONG>";
        if ($output_cut_off_after) {
            print "<BR />(Only displaying first {$output_cut_off_after} results)";
        }
        print "</TD></TR>\n";
        print "<SCRIPT type=\"text/javascript\"><!--\n";
        print "reportpage_init();\n";
        print "\n// -->\n</SCRIPT>";
    } else {
        print "<TR><TD colspan=\"{$colcount}\" style=\"text-align: right;\"><STRONG>Total results: {$output_row}</STRONG></TD></TR>";
    }
    print "</TABLE>\n";
}