Hello!

To see the file structure, click on "tree".

Note that updates take place every 10 minutes, commits may not be seen immediately.
Added GO web services in TermSearch_JSON. More XML doc output revisions
authorpreecej <preecej@localhost>
Fri, 26 Aug 2011 00:32:15 +0000 (00:32 +0000)
committerpreecej <preecej@localhost>
Fri, 26 Aug 2011 00:32:15 +0000 (00:32 +0000)
on paw_TranformForImport.

svn path=/; revision=171

preecej/semantic_wiki/paw_TransformForImport.pl
preecej/semantic_wiki/services/TermSearch_JSON.php

index 40c24959a0e7105ca52bec6bd65172ab9ee2c14b..370ec024e230d61bee3a6b5eb3a6416ba4ce3e79 100644 (file)
@@ -819,6 +819,8 @@ sub transform_gaf
     
                     foreach my $ont_term (keys %{$annotations{$annotation}{"Ontological References"}})
                     {
+                        # TODO: gather PMID's for separate REf Publication page creation (avoid dupes)
+                        
                         $writer->startTag("Template",Name=>"Ontological_Reference_Repeater");
                             $writer->dataElement("Field", $ontology_info{$curr_ontology_type}{"name"}, Name=>"Ontology");
                             $writer->dataElement("Field", $ont_term, Name=>"Term ID");
index 8be6a577da9d48e3a8f651849d8e2736dccf77c9..93f3b8ab0ca79655a50320278356d91c2305373a 100644 (file)
@@ -5,7 +5,8 @@
 if(isset($_GET['user']) && ($_GET['user']) == 'paw') {
 
         $arr_field_names = array('name','acc');
-    
+        $arr_ontologies = array('go','po');
+        
         /* read the params and/or set our own */
         $type = isset($_GET['type']) ? $_GET['type'] : autocomplete; // autocomplete is the default
         
@@ -17,6 +18,10 @@ if(isset($_GET['user']) && ($_GET['user']) == 'paw') {
         $number_of_terms = isset($_GET['max']) ? intval($_GET['max']) : 10; //10 is the default
         if ($number_of_terms > 50) { $number_of_terms = 50; } 
 
+        $ont = isset($_GET['ontology']) && in_array(strtolower($_GET['ontology']),$arr_ontologies)
+            ? strtolower($_GET['ontology'])
+            : die('"ontology" is a required parameter and must match an available data field.');
+        
         $qval = $_GET['qval'];
         
         $qval = isset($_GET['qval']) && strlen($_GET['qval']) > 0 
@@ -27,17 +32,33 @@ if(isset($_GET['user']) && ($_GET['user']) == 'paw') {
             ? strtolower($_GET['format']) 
             : 'json'; //json is the default
         
-        /* connect to the db */
-        $link = mysql_connect($_SERVER['dev_po_host'], $_SERVER['dev_po_user'], $_SERVER['dev_po_pw']) or die('Cannot connect to the DB');
-        mysql_select_db($_SERVER['dev_po_db'],$link) or die('Cannot select the DB');
+        /* connect to the appropriate db */
+        switch ($ont) {
+            case 'po':
+                $link = mysql_connect($_SERVER['dev_po_host'], $_SERVER['dev_po_user'], $_SERVER['dev_po_pw']) or die('Cannot connect to the DB');
+                mysql_select_db($_SERVER['dev_po_db'],$link) or die('Cannot select the DB');
+
+                $term_types = "'plant_anatomy','plant_growth_and_development_stage'"; 
+                break;
+
+            case 'go':
+                $link = mysql_connect($_SERVER['dev_go_host'], $_SERVER['dev_go_user'], $_SERVER['dev_go_pw']) or die('Cannot connect to the DB');
+                mysql_select_db($_SERVER['dev_go_db'],$link) or die('Cannot select the DB');
 
+                $term_types = "'biological_process','cellular_component','molecular_function'"; 
+                break;
+
+            default:
+                die('Sorry, this ontology type is not available.');
+        }
+        
         switch ($type) {
             case 'autocomplete':
                 /* grab the terms from the db */
                 $query = "SELECT t.$field FROM term t"
                     . " LEFT JOIN term_definition d ON d.term_id = t.id"
                     . " WHERE t.$field LIKE '%$qval%'"
-                    . " AND t.term_type in ('plant_anatomy','plant_growth_and_development_stage')"
+                    . " AND t.term_type in ($term_types)"
                     . " AND t.is_obsolete = 0"
                     . " AND UCASE(t.name) NOT LIKE 'OBSOLETE%'"
                     . " AND UCASE(d.term_definition) NOT LIKE 'OBSOLETE%'"
@@ -64,11 +85,11 @@ if(isset($_GET['user']) && ($_GET['user']) == 'paw') {
 
             case 'term_detail':
                 /* grab the ontology data from the db */
-                $query = "SELECT DISTINCT t.acc as 'acc', t.term_type as 'type', d.term_definition as 'definition', d.term_comment as 'comment'"
+                $query = "SELECT DISTINCT t.name as 'name', t.acc as 'acc', t.term_type as 'type', d.term_definition as 'definition', d.term_comment as 'comment'"
                     . " FROM term t"
                     . " LEFT JOIN term_definition d ON d.term_id = t.id"
-                    . " WHERE t.name = '$qval'"
-                    . " AND t.term_type in ('plant_anatomy','plant_growth_and_development_stage')"
+                    . " WHERE t.$field = '$qval'"
+                    . " AND t.term_type in ($term_types)"
                     . " AND t.is_obsolete = 0"
                     . " AND UCASE(t.name) NOT LIKE 'OBSOLETE%'"
                     . " AND UCASE(d.term_definition) NOT LIKE 'OBSOLETE%'"
@@ -79,9 +100,22 @@ if(isset($_GET['user']) && ($_GET['user']) == 'paw') {
                 $terms = array();
                 if(mysql_num_rows($result)) {
                     while($term = mysql_fetch_assoc($result)) {
+                        switch($term['type']) {
+                            case 'plant_anatomy':
+                                $term_type_formal = "Plant Anatomy"; break;
+                            case 'plant_growth_and_development_stage':
+                                $term_type_formal = "Plant Growth and Development Stage"; break;
+                            case 'biological_process':
+                                $term_type_formal = "Biological Process"; break;
+                            case 'cellular_component':
+                                $term_type_formal = "Cellular Component"; break;
+                            case 'molecular_function':
+                                $term_type_formal = "Molecular Function"; break;
+                        }
                         $terms[] = array(
+                            'name'=>$term['name'],
                             'id'=>$term['acc'],
-                            'aspect'=>$term['type'] == "plant_anatomy" ? "Plant Anatomy" : "Plant Growth and Development Stage",
+                            'aspect'=>$term_type_formal,
                             'definition'=>$term['definition'],
                             'comment'=>$term['comment']);
                     }