|
@@ -369,6 +369,12 @@ function chado_analysis_load($node){
|
|
|
"WHERE Analysis_id = $ana_node->analysis_id";
|
|
|
$previous_db = db_set_active('chado'); // use chado database
|
|
|
$additions = db_fetch_object(db_query($sql));
|
|
|
+ // get number of features assc with this analysis
|
|
|
+ $sql = "SELECT count(feature_id) as featurecount ".
|
|
|
+ "FROM {Analysisfeature} ".
|
|
|
+ "WHERE Analysis_id = %d";
|
|
|
+ $additions->featurecount = db_result(db_query($sql, $ana_node->analysis_id));
|
|
|
+
|
|
|
db_set_active($previous_db); // now use drupal database
|
|
|
}
|
|
|
// If the analysis has a name, use it as the node title. If not, construct
|
|
@@ -410,7 +416,7 @@ function chado_analysis_view ($node, $teaser = FALSE, $page = FALSE) {
|
|
|
function tripal_analysis_sync_analyses ($analysis_id = NULL, $job_id = NULL){
|
|
|
global $user;
|
|
|
$page_content = '';
|
|
|
-
|
|
|
+
|
|
|
if(!$analysis_id){
|
|
|
$sql = "SELECT Analysis_id, name AS analysisname, description, program, ".
|
|
|
" programversion, algorithm, sourcename, sourceversion, sourceuri, ".
|
|
@@ -430,10 +436,6 @@ function tripal_analysis_sync_analyses ($analysis_id = NULL, $job_id = NULL){
|
|
|
db_set_active($previous_db); // now use drupal database
|
|
|
}
|
|
|
|
|
|
- ##REMOVE
|
|
|
- print "results:\n";
|
|
|
- print $results;
|
|
|
- print "\n";
|
|
|
|
|
|
// We'll use the following SQL statement for checking if the analysis
|
|
|
// already exists as a drupal node.
|
|
@@ -441,40 +443,43 @@ function tripal_analysis_sync_analyses ($analysis_id = NULL, $job_id = NULL){
|
|
|
"WHERE analysis_id = %d";
|
|
|
|
|
|
while($analysis = db_fetch_object($results)){
|
|
|
+ print "syncing analysis ";
|
|
|
+ print $analysis->analysisname;
|
|
|
+ print ", ";
|
|
|
+ print $analysis->analysis_id;
|
|
|
+ print "\n";
|
|
|
+
|
|
|
// check if this analysis already exists in the drupal database. if it
|
|
|
// does then skip this analysis and go to the next one.
|
|
|
if(!db_fetch_object(db_query($sql,$analysis->analysis_id))){
|
|
|
-
|
|
|
+
|
|
|
$new_node = new stdClass();
|
|
|
|
|
|
- // try to access analysisprop for this analysis
|
|
|
- $sql = "SELECT * FROM {analysisprop} WHERE analysis_id = %d";
|
|
|
+ // try to access analysis type for this analysis
|
|
|
+ $sql = "SELECT * FROM {analysisprop}
|
|
|
+ WHERE analysis_id = %d
|
|
|
+ AND type_id =
|
|
|
+ (SELECT cvterm_id from {cvterm} where name = '%s')
|
|
|
+ ";
|
|
|
$previous_db = db_set_active('chado');
|
|
|
- $analysisprop = db_fetch_object(db_query($sql, $analysis->analysis_id));
|
|
|
+ $analysis_type = db_fetch_object(db_query($sql, $analysis->analysis_id, "analysis_type"));
|
|
|
db_set_active($previous_db);
|
|
|
|
|
|
// Get the type of analysis using cvterm_id
|
|
|
// Current possibilities: kegg, unigene, interpro, blast
|
|
|
- if ($analysisprop) {
|
|
|
-
|
|
|
- $sql = "SELECT name, definition FROM {cvterm} WHERE cvterm_id = %d";
|
|
|
- $previous_db = db_set_active('chado');
|
|
|
- $result = db_fetch_object(db_query($sql, $analysisprop->type_id));
|
|
|
- db_set_active($previous_db);
|
|
|
+ if ($analysis_type) {
|
|
|
|
|
|
// This is a unigene analysis
|
|
|
- if ($result->name == 'analysis_unigene_settings') {
|
|
|
- $new_node->type = 'chado_unigene_blast';
|
|
|
+ if ($analysis_type->value == 'tripal_analysis_unigene') {
|
|
|
+ $new_node->type = 'chado_analysis_unigene';
|
|
|
// This is a blast analysis
|
|
|
- } else if ($result->name == 'analysis_blast_settings') {
|
|
|
+ } else if ($result->name == 'tripal_analysis_blast') {
|
|
|
$new_node->type = 'chado_analysis_blast';
|
|
|
// This is a interpro analysis
|
|
|
- } else if ($result->name == 'analysis_interpro_settings') {
|
|
|
+ } else if ($result->name == 'tripal_analysis_interpro') {
|
|
|
$new_node->type = 'chado_analysis_interpro';
|
|
|
// This is a kegg analysis
|
|
|
- } else if ($result->name == 'analysis_kegg_settings' ||
|
|
|
- $result->name == 'kegg_brite_data' ||
|
|
|
- preg_match("/KEGG BRITE term:/", $result->definition)) {
|
|
|
+ } else if ($result->name == 'tripal_analysis_kegg' ){
|
|
|
$new_node->type = 'chado_analysis_kegg';
|
|
|
} else {
|
|
|
$new_node->type = 'chado_analysis';
|
|
@@ -484,6 +489,8 @@ function tripal_analysis_sync_analyses ($analysis_id = NULL, $job_id = NULL){
|
|
|
$new_node->type = 'chado_analysis';
|
|
|
}
|
|
|
|
|
|
+ print "analysis type is $new_node->type\n";
|
|
|
+
|
|
|
$new_node->uid = $user->uid;
|
|
|
$new_node->analysis_id = $analysis->analysis_id;
|
|
|
$new_node->analysisname = $analysis->analysisname;
|
|
@@ -607,6 +614,7 @@ function tripal_analysis_theme () {
|
|
|
* objects sorted by program
|
|
|
*/
|
|
|
function get_chado_analyses() {
|
|
|
+
|
|
|
$sql_drupal = "SELECT COUNT (analysis_id) FROM {chado_analysis}";
|
|
|
$no_orgs = db_result(db_query($sql_drupal));
|
|
|
if ($no_orgs != 0) {
|
|
@@ -634,6 +642,7 @@ function get_chado_analyses() {
|
|
|
|
|
|
//Sort analyses by time, descending order
|
|
|
krsort($analyses, SORT_STRING);
|
|
|
+
|
|
|
return $analyses;
|
|
|
}
|
|
|
}
|