Пример #1
0
function evidence_qualify_impact($scores, $impact)
{
    $c = str_split(evidence_compute_certainty($scores, $impact));
    if ($c[0] === "-") {
        return ucfirst($impact);
    }
    if ($c[0] === '0') {
        $impact = "uncertain {$impact}";
    } else {
        if ($c[0] === '1') {
            $impact = "likely {$impact}";
        }
    }
    if ($c[1] === '0') {
        $impact = "low clinical importance, {$impact}";
    } else {
        if ($c[1] === '1') {
            $impact = "moderate clinical importance, {$impact}";
        } else {
            if ($c[1] === '2') {
                $impact = "high clinical importance, {$impact}";
            }
        }
    }
    return ucfirst($impact);
}
Пример #2
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";
}