Procházet zdrojové kódy

Completed custom code to support LIS targets

E.Cannon před 9 roky
rodič
revize
ac9a03eaa0
1 změnil soubory, kde provedl 74 přidání a 37 odebrání
  1. 74 37
      includes/blast_ui.custom.inc

+ 74 - 37
includes/blast_ui.custom.inc

@@ -10,80 +10,117 @@ function tripal_custom_generate_linkout($url_prefix, $hit, $info, $options = arr
 // uncomment to see contents of info object
 //echo "info:<pre>";var_dump($info);echo "</pre>";
 
+  $url = false;
   $hit_name = $hit->{'Hit_def'};
+//echo "hit name: $hit_name ... ";
 
   if ($info['Target'] == 'All genomes') {
-    if (preg_match('/.*(aradu).*/i', $hit_name) == 1) {
+    if (preg_match('/^aradu/', $hit_name) == 1) {
       $blastdb_name = 'PeanutBase_aradu_gbrowse';
     }
-    else if (preg_match('/.*(araip).*/i', $hit_name) == 1) {
+    else if (preg_match('/^araip/', $hit_name) == 1) {
       $blastdb_name = 'PeanutBase_araip_gbrowse';
     }
-    else if (preg_match('/^Cc/', $hit_name) == 1) {
+    else if (preg_match('/^cajca/', $hit_name) == 1) {
       $blastdb_name = 'LegumeInfo_cajca_gbrowse';
     }
-    else if (preg_match('/^Ca/', $hit_name) == 1) {
+    else if (preg_match('/^cicar/', $hit_name) == 1) {
       $blastdb_name = 'LegumeInfo_cicar_gbrowse';
-      $hit_name = preg_replace("/(.*?)\s.*/", '$1', $hit_name);
     }
-    else if (preg_match('/^Gm/', $hit_name) == 1) {
+    else if (preg_match('/^glyma/', $hit_name) == 1) {
       $blastdb_name = 'SoyBase_glyma_gbrowse';
     }
-    else if (preg_match('/^Lj/', $hit_name) == 1) {
+    else if (preg_match('/^lotja/', $hit_name) == 1) {
       $blastdb_name = 'LegumeInfo_lotja_gbrowse';
     }
-    else if (preg_match('/^Mt/', $hit_name) == 1) {
+    else if (preg_match('/^medtr/', $hit_name) == 1) {
       $blastdb_name = 'LegumeInfo_medtr_gbrowse';
     }
-    else if (preg_match('/^Pv/', $hit_name) == 1) {
+    else if (preg_match('/^phavu/', $hit_name) == 1) {
       $blastdb_name = 'LegumeInfo_phavu_gbrowse';
     }
-    else if (preg_match('/^Vr/', $hit_name) == 1) {
+    else if (preg_match('/^vigra/', $hit_name) == 1) {
       $blastdb_name = 'LegumeInfo_vigra_gbrowse';
     }
+    else {
+      // Don't know what to do with this hit
+      drupal_set_message("Don't know how to create GBrowse linkout for $hit_name", 'error');
+    }  
 
+    $hit_name = preg_replace("/^\w+\.(\S+).*/", '$1', $hit_name);
     $hit->{'linkout_id'} = $hit_name;
-    $url_prefix = tripal_custom_getURLprefix($blastdb_name);
-    $url = tripal_blast_generate_linkout_gbrowse($url_prefix, $hit, $info, $options);
+    if ($blastdb_info = tripal_custom_getBLASTdbinfo($blastdb_name)) {
+//echo "generate gbrowse link with " . $blastdb_info['urlprefix'] . " $hit<br>";
+      $url = tripal_blast_generate_linkout_gbrowse($blastdb_info['urlprefix'], $hit, $info, $options);
+    }
   }//handle All genomes BLAST target
   
   else {
-    if (preg_match('/.*(aradu).*/i', $hit_name) == 1) {
-      preg_match("/\w+\.(\w+\.\w+)/", $hit_name, $linkout_match);
-      $linkout_id = $linkout_match[1];
-      $hit->{'linkout_id'} = $linkout_id;
-      $url =   "/gbrowse_aradu1.0?query=q=$linkout_id;h_feat=$linkout_id";
-    }
-    else if(preg_match('/.*(araip).*/i', $hit_name) == 1) {
-      preg_match("/\w+\.(\w+\.\w+)/", $hit_name, $linkout_match);
-      $linkout_id = $linkout_match[1];
-      $hit->{'linkout_id'} = $linkout_id;
-      $url =  "/gbrowse_araip1.0?query=q=$linkout_id;h_feat=$linkout_id";
-    }
-    else if(preg_match('/.*(phytozome).*/i', $hit_name) == 1) {
-      preg_match("/(.*?)\s.*/", $hit_name, $linkout_match);
-      $linkout_id = $linkout_match[1];
-      $hit->{'linkout_id'} = $linkout_id;
-      $url = "http://legumeinfo.org/chado_phylotree/$linkout_id";
+    // default regex:
+    $regex = "/^\w+\.(\S+)/";
+    
+    if (preg_match('/^aradu/', $hit_name) == 1) {
+      $blastdb_name = 'PeanutBase_aradu_gene';
+    }
+    else if (preg_match('/^araip/', $hit_name) == 1) {
+      $blastdb_name = 'PeanutBase_araip_gene';
+    }
+    else if (preg_match('/^cajca/', $hit_name) == 1) {
+      $blastdb_name = 'LegumeInfo_cajca_gene';
+    }
+    else if (preg_match('/^cicar/', $hit_name) == 1) {
+      $blastdb_name = 'LegumeInfo_cicar_gene';
+    }
+    else if (preg_match('/^glyma/', $hit_name) == 1) {
+      $blastdb_name = 'LegumeInfo_glyma_gene';
+      if (preg_match("/^\w+\.(\S+)\.p/", $hit_name)) {
+        //glyma protein
+        $regex = "/^\w+\.(\S+)\.p/";
+      }
+    }
+    else if (preg_match('/^lotja/', $hit_name) == 1) {
+      $blastdb_name = 'LegumeInfo_lotja_gene';
+    }
+    else if (preg_match('/^medtr/', $hit_name) == 1) {
+      $blastdb_name = 'LegumeInfo_medtr_gene';
+    }
+    else if (preg_match('/^phavu/', $hit_name) == 1) {
+      $blastdb_name = 'LegumeInfo_phavu_gene';
+    }
+    else if (preg_match('/^vigra/', $hit_name) == 1) {
+      $blastdb_name = 'LegumeInfo_vigra_gene';
     }
     else {
       // Don't know what to do with this hit
       drupal_set_message("Don't know how to create linkout for $hit_name", 'error');
-      $url = false;
     }  
-  }//handle remaining BLAST targets 
-    
-  return "$url";
+
+    $hit_name = preg_match($regex, $hit_name, $matches);
+//echo "<br>Using $regex, found matches:<pre>" . var_dump($matches);echo "</pre>";
+//echo "<br>Use [" . $matches[1] . "]<br>";
+    $hit->{'linkout_id'} = $matches[1];
+//echo "look for gene link for $blastdb_name with " . $hit->{'linkout_id'} . "<br>";
+    if ($blastdb_info = tripal_custom_getBLASTdbinfo($blastdb_name)) {
+//echo "generate gbrowse link with " . $blastdb_info['urlprefix'] . " $hit<br>";
+      $url = tripal_blast_generate_linkout_link($blastdb_info['urlprefix'], $hit, $info, $options);
+    }
+  }
+  return $url;
 }
 
 
-function tripal_custom_getURLprefix($blastdb_name) {
-  $sql = "SELECT urlprefix FROM db WHERE name='$blastdb_name'";
+function tripal_custom_getBLASTdbinfo($blastdb_name) {
+  $sql = "
+    SELECT urlprefix 
+    FROM {db} WHERE name='$blastdb_name'";
+//echo "$sql<br>";
   if ($res = chado_query($sql)) {
     if ($row=$res->fetchObject()) {
-      return $row->urlprefix;
+      return array(
+        'urlprefix' => $row->urlprefix, 
+      );
     }
   }
   
   return false;
-}//tripal_custom_getURLprefix
+}//tripal_custom_getBLASTdbinfo