Example #1
0
function seealso_related($gene, $aa_pos, $skip_variant_id)
{
    $related_variants = theDb()->getAll("SELECT v.variant_gene gene, CONCAT(v.variant_aa_from,v.variant_aa_pos,v.variant_aa_to) aa_long FROM variants v WHERE v.variant_gene=? AND v.variant_aa_pos=? AND v.variant_id <> ?", array($gene, $aa_pos, $skip_variant_id));
    $seealso = "";
    foreach ($related_variants as $x) {
        $x["aa_short"] = aa_short_form($x["aa_long"]);
        $seealso .= "<LI>See also: <A href=\"" . $x["gene"] . "-" . $x["aa_short"] . "\">" . $x["gene"] . " " . $x["aa_short"] . "</A></LI>\n";
    }
    if ($seealso) {
        $seealso = "<DIV id=\"seealso\"><UL>{$seealso}</UL></DIV>\n";
    }
    return $seealso;
}
Example #2
0
function blosum62($aa1, $aa2)
{
    $aa1 = aa_short_form($aa1);
    $aa2 = aa_short_form($aa2);
    if ($aa1 == "X" || $aa2 == "X") {
        return -10;
    }
    global $gBLOSUM62;
    if (!is_array($gBLOSUM62["A"])) {
        $keys = array_keys($gBLOSUM62);
        foreach ($gBLOSUM62 as $a => &$b) {
            $b = array_combine($keys, preg_split('/  ?/', $b));
            array_shift($keys);
        }
    }
    if ($aa1 <= $aa2) {
        return $gBLOSUM62[$aa1][$aa2];
    } else {
        return $gBLOSUM62[$aa2][$aa1];
    }
}
Example #3
0
function evidence_get_variant_name(&$variant, $separator = " ", $shortp = false)
{
    if (is_array($variant)) {
        $row =& $variant;
    } else {
        if (ereg("^[0-9]+\$", $variant)) {
            $row =& theDb()->getRow("SELECT * from variants WHERE variant_id=?", array($variant));
        }
    }
    if ($row["variant_rsid"]) {
        return "rs" . $row["variant_rsid"];
    } else {
        if ($shortp) {
            return $row["variant_gene"] . $separator . aa_short_form($row["variant_aa_from"] . $row["variant_aa_pos"] . $row["variant_aa_to"]);
        } else {
            return $row["variant_gene"] . $separator . $row["variant_aa_from"] . $row["variant_aa_pos"] . $row["variant_aa_to"];
        }
    }
}
Example #4
0
function yahoo_boss_update_external($variant_id)
{
    $cache = yahoo_boss_lookup($variant_id);
    if (!$cache) {
        print "No search results\n";
        return;
    }
    $variant = theDb()->getRow("SELECT v.*, vo.rsid rsid FROM variants v\n\t\t\t\t LEFT JOIN variant_occurs vo\n\t\t\t\t  ON v.variant_id=vo.variant_id\n\t\t\t\t  AND vo.rsid IS NOT NULL\n\t\t\t\t WHERE v.variant_id=?\n\t\t\t\t GROUP BY v.variant_id", array($variant_id));
    if (!$variant || theDb()->isError($variant)) {
        print "No such variant\n";
        return FALSE;
    }
    if ($variant["variant_gene"]) {
        $gene_aa_long = $variant["variant_gene"] . " " . $variant["variant_aa_from"] . $variant["variant_aa_pos"] . $variant["variant_aa_to"];
        $gene_aa_short = $variant["variant_gene"] . " " . aa_short_form($variant["variant_aa_from"]) . $variant["variant_aa_pos"] . aa_short_form($variant["variant_aa_to"]);
        $search_string = "{$gene_aa_long} OR {$gene_aa_short}";
        if (($rsid = $variant["variant_rsid"]) || ($rsid = $variant["rsid"])) {
            $search_string .= " OR rs{$rsid}";
        }
    } else {
        $search_string = "rs" . $variant["variant_rsid"];
    }
    $user_url = "http://search.yahoo.com/search?p=" . urlencode($search_string);
    $content = "";
    $skipped_hits = 0;
    if ($cache["hitcount"] > 0) {
        preg_match_all('{<result>.*?</result>}is', $cache["xml"], $matches, PREG_PATTERN_ORDER);
        foreach ($matches[0] as $result) {
            $resulttag = array();
            foreach (array("url", "dispurl", "abstract", "title") as $t) {
                if (preg_match("{<{$t}>(.*?)</{$t}>}i", $result, $regs)) {
                    $resulttag[$t] = preg_replace('{<\\!\\[CDATA\\[(.*?)\\]\\]>}s', '$1', $regs[1]);
                } else {
                    $resulttag = FALSE;
                    continue;
                }
            }
            if (ereg("snp\\.med\\.harvard\\.edu|evidence\\.personalgenomes\\.org", $resulttag["url"])) {
                $skipped_hits++;
                continue;
            }
            if ($resulttag) {
                $content .= "<LI><A href=\"" . $resulttag["url"] . "\">" . $resulttag["title"] . "</A><BR />" . $resulttag["abstract"] . "<BR /><DIV class=\"searchurl\">" . $resulttag["dispurl"] . "</DIV></LI>\n";
            }
        }
    }
    // If we skipped some hits (because they point to this page or
    // Trait-o-matic), subtract them from the cached hitcount so "no
    // web results except this page" gets counted as 0 for
    // statistics/display.
    if ($skipped_hits > 0 && preg_match('/<resultset_web\\b[^<]*\\sdeephits="?(\\d+)"?/s', $cache["xml"], $regs) && $regs[1] >= $skipped_hits) {
        $hitcount = $regs[1] - $skipped_hits;
        if ($hitcount != $cache["hitcount"]) {
            $cache["hitcount"] = $hitcount;
            theDb()->query("UPDATE yahoo_boss_cache SET hitcount=? WHERE variant_id=?", array($hitcount, $variant_id));
        }
    }
    // Build html display for variant page
    $content = "<UL><STRONG>Web search results (" . $cache["hitcount"] . " hit" . ($cache["hitcount"] == 1 ? "" : "s") . " -- <A href=\"" . $user_url . "\">see all</A>)</STRONG>" . $content . "</UL>";
    theDb()->query("DELETE FROM variant_external WHERE variant_id=? AND tag=?", array($variant_id, "Yahoo!"));
    $q = theDb()->query("INSERT INTO variant_external SET variant_id=?, tag=?, content=?, url=NULL, updated=NOW()", array($variant_id, "Yahoo!", $content));
}
Example #5
0
     $variant_id = $regs[0];
 } else {
     if (aa_sane($_POST["variant_aa_change"])) {
         if (ereg("^([^0-9]+)([0-9]+)([^0-9]+)\$", aa_long_form($_POST["variant_aa_change"]), $regs)) {
             $aa_from = $regs[1];
             $aa_pos = $regs[2];
             $aa_to = $regs[3];
         }
         $gene = strtoupper($_POST["variant_gene"]);
         $variant_id = evidence_get_variant_id($gene, $aa_pos, $aa_from, $aa_to, true);
         $edit_id = evidence_get_latest_edit($variant_id, 0, 0, 0, true);
         $response["latest_edit_v{$variant_id}a0g0"] = $edit_id;
         $response["latest_edit_id"] = $edit_id;
         $response["variant_id"] = $variant_id;
         $response["please_reload"] = true;
         $response["variant_key"] = "{$gene} " . aa_short_form("{$aa_from}{$aa_pos}{$aa_to}");
     } else {
         die("Invalid variant specified");
     }
 }
 if ($article_pmid || $genome_id || $disease_id) {
     $latest_edit_id = evidence_get_latest_edit($variant_id, $article_pmid, $genome_id, $disease_id, true);
     $response["latest_edit_v{$variant_id}a{$article_pmid}g{$genome_id}"] = $latest_edit_id;
     $response["latest_edit_id"] = $latest_edit_id;
     $renderer = new evidence_row_renderer();
     $renderer->render_row(theDb()->getRow("SELECT * FROM edits WHERE edit_id=?", array($latest_edit_id)));
     $response["html"] = $renderer->html();
     ereg("id=\"([^\"]+)", $response["html"], $regs);
     $response["e_id"] = $regs[1];
 }
 header("Content-type: application/json");