function tripal_cv_cvterm_info
1.x trees.inc | tripal_cv_cvterm_info($cvterm_id) |
Describe a cvterm (Rendered)
Related topics
1 string reference to 'tripal_cv_cvterm_info'
- tripal_cv_menu in tripal_cv/
tripal_cv.module - Implements hook_menu(). Registers all menu items associated with this module
File
- tripal_cv/
includes/ trees.inc, line 361 - @todo Stephen describe this file
Code
function tripal_cv_cvterm_info($cvterm_id) {
// get the id of the term to look up
$cv = check_plain($_REQUEST['cv']);
$tree_id = check_plain($_REQUEST['tree_id']);
// first get any additional information to add to the cvterm
if (strcmp($tree_id, 'undefined') != 0) {
$tripal_mod = preg_replace("/^(tripal_.+?)_cv_tree_(.+)$/", "$1", $tree_id);
if ($tripal_mod) {
$callback = $tripal_mod . "_cvterm_add";
$opt = call_user_func_array($callback, array($cvterm_id, $tree_id));
}
}
$sql = "
SELECT CVT.name as cvtermname, CVT.definition, CV.name as cvname,
DBX.accession,DB.urlprefix,DB.db_id,DB.name as dbname
FROM {CVTerm} CVT
INNER JOIN {CV} on CVT.cv_id = CV.cv_id
INNER JOIN {dbxref} DBX on CVT.dbxref_id = DBX.dbxref_id
INNER JOIN {DB} on DBX.db_id = DB.db_id
WHERE CVT.cvterm_id = %d
";
$cvterm = db_fetch_object(chado_query($sql, $cvterm_id));
$sql = "
SELECT CVTS.synonym, CVT.name as cvname
FROM {cvtermsynonym} CVTS
INNER JOIN {cvterm} CVT on CVTS.type_id = CVT.cvterm_id
WHERE CVTS.cvterm_id = %d
";
$results = chado_query($sql, $cvterm_id);
while ($synonym = db_fetch_object($results)) {
$synonym_rows .= "<b>$synonym->cvname:</b> $synonym->synonym<br />";
}
$accession = $cvterm->accession;
if ($cvterm->urlprefix) {
$accession = "<a href=\"$cvterm->urlprefix$cvterm->accession\">$cvterm->accession</a>";
}
$content = "
<div id=\"cvterm\">
<table>
<tr><th>Term</th><td>$cvterm->cvtermname</td></tr>
<tr><th>Accession</th><td>$accession</td></tr>
<tr><th>Ontology</th><td>$cvterm->cvname</td></tr>
<tr><th>Definition</th><td>$cvterm->definition</td></tr>
<tr><th>Synonyms</th><td>$synonym_rows</td></tr>
<tr><th>Internal ID</th><td>$cvterm_id</td></tr>
";
// now add in any additional options from a hook
if ($opt) {
foreach ($opt as $key => $value) {
$content .= "<tr><th>$key</th><td>$value</td>";
}
}
// close out the information table
$content .= "
</table>
</div>
";
drupal_json(array('update' => $content));
}