|
@@ -402,22 +402,20 @@ function theme_tripal_library_search_index($node) {
|
|
if ($node->type == 'chado_organism') {
|
|
if ($node->type == 'chado_organism') {
|
|
$content = "";
|
|
$content = "";
|
|
// get the libraries for the organism
|
|
// get the libraries for the organism
|
|
- $previous_db = tripal_db_set_active('chado');
|
|
|
|
$sql = "SELECT * FROM {library} L ".
|
|
$sql = "SELECT * FROM {library} L ".
|
|
"WHERE L.organism_id = %d";
|
|
"WHERE L.organism_id = %d";
|
|
$libraries = array();
|
|
$libraries = array();
|
|
- $results = db_query($sql, $node->organism->organism_id);
|
|
|
|
|
|
+ $results = chado_query($sql, $node->organism->organism_id);
|
|
while ($library = db_fetch_object($results)) {
|
|
while ($library = db_fetch_object($results)) {
|
|
// get the description
|
|
// get the description
|
|
$sql = "SELECT * FROM {libraryprop} LP ".
|
|
$sql = "SELECT * FROM {libraryprop} LP ".
|
|
" INNER JOIN CVTerm CVT ON CVT.cvterm_id = LP.type_id ".
|
|
" INNER JOIN CVTerm CVT ON CVT.cvterm_id = LP.type_id ".
|
|
"WHERE LP.library_id = $library->library_id ".
|
|
"WHERE LP.library_id = $library->library_id ".
|
|
" AND CVT.name = 'library_description'";
|
|
" AND CVT.name = 'library_description'";
|
|
- $desc = db_fetch_object(db_query($sql));
|
|
|
|
|
|
+ $desc = db_fetch_object(chado_query($sql));
|
|
$library->description = $desc->value;
|
|
$library->description = $desc->value;
|
|
$libraries[] = $library;
|
|
$libraries[] = $library;
|
|
}
|
|
}
|
|
- tripal_db_set_active($previous_db);
|
|
|
|
if (count($libraries) > 0) {
|
|
if (count($libraries) > 0) {
|
|
foreach ($libraries as $library) {
|
|
foreach ($libraries as $library) {
|
|
$content .= "$library->name ";
|
|
$content .= "$library->name ";
|
|
@@ -429,16 +427,14 @@ function theme_tripal_library_search_index($node) {
|
|
elseif ($node->type == 'chado_feature') {
|
|
elseif ($node->type == 'chado_feature') {
|
|
$content = "";
|
|
$content = "";
|
|
$organism_id = $node->feature->organism_id;
|
|
$organism_id = $node->feature->organism_id;
|
|
- $previous_db = tripal_db_set_active('chado');
|
|
|
|
$sql = "SELECT * FROM {library} L ".
|
|
$sql = "SELECT * FROM {library} L ".
|
|
" INNER JOIN Library_feature LF ON L.library_id = LF.library_id ".
|
|
" INNER JOIN Library_feature LF ON L.library_id = LF.library_id ".
|
|
"WHERE LF.feature_id = " . $node->feature->feature_id;
|
|
"WHERE LF.feature_id = " . $node->feature->feature_id;
|
|
$libraries = array();
|
|
$libraries = array();
|
|
- $results = db_query($sql);
|
|
|
|
|
|
+ $results = chado_query($sql);
|
|
while ($library = db_fetch_object($results)) {
|
|
while ($library = db_fetch_object($results)) {
|
|
$libraries[] = $library;
|
|
$libraries[] = $library;
|
|
}
|
|
}
|
|
- tripal_db_set_active($previous_db);
|
|
|
|
if (count($libraries) > 0) {
|
|
if (count($libraries) > 0) {
|
|
$lib_additions = array();
|
|
$lib_additions = array();
|
|
foreach ($libraries as $library) {
|
|
foreach ($libraries as $library) {
|
|
@@ -473,16 +469,14 @@ function theme_tripal_library_node_libraries($node) {
|
|
// when a feature is previewed at its creation
|
|
// when a feature is previewed at its creation
|
|
elseif ($node->type == 'chado_feature' && $node->feature->feature_id) {
|
|
elseif ($node->type == 'chado_feature' && $node->feature->feature_id) {
|
|
$organism_id = $node->feature->organism_id;
|
|
$organism_id = $node->feature->organism_id;
|
|
- $previous_db = tripal_db_set_active('chado');
|
|
|
|
$sql = "SELECT * FROM {library} L ".
|
|
$sql = "SELECT * FROM {library} L ".
|
|
" INNER JOIN Library_feature LF ON L.library_id = LF.library_id ".
|
|
" INNER JOIN Library_feature LF ON L.library_id = LF.library_id ".
|
|
"WHERE LF.feature_id = " . $node->feature->feature_id;
|
|
"WHERE LF.feature_id = " . $node->feature->feature_id;
|
|
$libraries = array();
|
|
$libraries = array();
|
|
- $results = db_query($sql);
|
|
|
|
|
|
+ $results = chado_query($sql);
|
|
while ($library = db_fetch_object($results)) {
|
|
while ($library = db_fetch_object($results)) {
|
|
$libraries[] = $library;
|
|
$libraries[] = $library;
|
|
- }
|
|
|
|
- tripal_db_set_active($previous_db);
|
|
|
|
|
|
+ }
|
|
if (count($libraries) > 0) {
|
|
if (count($libraries) > 0) {
|
|
$lib_additions = array();
|
|
$lib_additions = array();
|
|
foreach ($libraries as $library) {
|
|
foreach ($libraries as $library) {
|
|
@@ -538,9 +532,7 @@ function get_tripal_library_admin_form_taxonomy_set(&$form) {
|
|
|
|
|
|
// get the list of libraries
|
|
// get the list of libraries
|
|
$sql = "SELECT * FROM {Library} ORDER BY uniquename";
|
|
$sql = "SELECT * FROM {Library} ORDER BY uniquename";
|
|
- $previous_db = tripal_db_set_active('chado'); // use chado database
|
|
|
|
- $lib_rset = db_query($sql);
|
|
|
|
- tripal_db_set_active($previous_db); // now use drupal database
|
|
|
|
|
|
+ $lib_rset = chado_query($sql);
|
|
|
|
|
|
// iterate through all of the libraries
|
|
// iterate through all of the libraries
|
|
$lib_boxes = array();
|
|
$lib_boxes = array();
|
|
@@ -585,9 +577,7 @@ function get_tripal_library_admin_form_reindex_set(&$form) {
|
|
|
|
|
|
// get the list of libraries
|
|
// get the list of libraries
|
|
$sql = "SELECT * FROM {Library} ORDER BY uniquename";
|
|
$sql = "SELECT * FROM {Library} ORDER BY uniquename";
|
|
- $previous_db = tripal_db_set_active('chado'); // use chado database
|
|
|
|
- $lib_rset = db_query($sql);
|
|
|
|
- tripal_db_set_active($previous_db); // now use drupal database
|
|
|
|
|
|
+ $lib_rset = chado_query($sql);
|
|
|
|
|
|
// iterate through all of the libraries
|
|
// iterate through all of the libraries
|
|
$lib_boxes = array();
|
|
$lib_boxes = array();
|
|
@@ -630,9 +620,7 @@ function get_tripal_library_admin_form_sync_set(&$form) {
|
|
|
|
|
|
// get the list of libraries
|
|
// get the list of libraries
|
|
$sql = "SELECT * FROM {Library} ORDER BY uniquename";
|
|
$sql = "SELECT * FROM {Library} ORDER BY uniquename";
|
|
- $previous_db = tripal_db_set_active('chado'); // use chado database
|
|
|
|
- $lib_rset = db_query($sql);
|
|
|
|
- tripal_db_set_active($previous_db); // now use drupal database
|
|
|
|
|
|
+ $lib_rset = chado_query($sql);
|
|
|
|
|
|
// if we've added any libraries to the list that can be synced
|
|
// if we've added any libraries to the list that can be synced
|
|
// then we want to build the form components to allow the user
|
|
// then we want to build the form components to allow the user
|
|
@@ -709,9 +697,7 @@ function tripal_library_admin_validate($form, &$form_state) {
|
|
if ($library_id and preg_match("/^\d+$/i", $library_id)) {
|
|
if ($library_id and preg_match("/^\d+$/i", $library_id)) {
|
|
// get the library info
|
|
// get the library info
|
|
$sql = "SELECT * FROM {Library} WHERE library_id = %d";
|
|
$sql = "SELECT * FROM {Library} WHERE library_id = %d";
|
|
- $previous_db = tripal_db_set_active('chado'); // use chado database
|
|
|
|
- $library = db_fetch_object(db_query($sql, $library_id));
|
|
|
|
- tripal_db_set_active($previous_db); // now use drupal database
|
|
|
|
|
|
+ $library = db_fetch_object(chado_query($sql, $library_id));
|
|
$to_sync[$library_id] = $library->name;
|
|
$to_sync[$library_id] = $library->name;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -736,9 +722,7 @@ function tripal_library_admin_validate($form, &$form_state) {
|
|
if ($library_id and preg_match("/^\d+$/i", $library_id)) {
|
|
if ($library_id and preg_match("/^\d+$/i", $library_id)) {
|
|
// get the library info
|
|
// get the library info
|
|
$sql = "SELECT * FROM {Library} WHERE library_id = %d";
|
|
$sql = "SELECT * FROM {Library} WHERE library_id = %d";
|
|
- $previous_db = tripal_db_set_active('chado'); // use chado database
|
|
|
|
- $library = db_fetch_object(db_query($sql, $library_id));
|
|
|
|
- tripal_db_set_active($previous_db); // now use drupal database
|
|
|
|
|
|
+ $library = db_fetch_object(chado_query($sql, $library_id));
|
|
$job_args[0] = $library_id;
|
|
$job_args[0] = $library_id;
|
|
tripal_add_job("Reindex features for library: $library->name", 'tripal_library',
|
|
tripal_add_job("Reindex features for library: $library->name", 'tripal_library',
|
|
'tripal_library_reindex_features', $job_args, $user->uid);
|
|
'tripal_library_reindex_features', $job_args, $user->uid);
|
|
@@ -754,9 +738,7 @@ function tripal_library_admin_validate($form, &$form_state) {
|
|
if ($library_id and preg_match("/^\d+$/i", $library_id)) {
|
|
if ($library_id and preg_match("/^\d+$/i", $library_id)) {
|
|
// get the library info
|
|
// get the library info
|
|
$sql = "SELECT * FROM {Library} WHERE library_id = %d";
|
|
$sql = "SELECT * FROM {Library} WHERE library_id = %d";
|
|
- $previous_db = tripal_db_set_active('chado'); // use chado database
|
|
|
|
- $library = db_fetch_object(db_query($sql, $library_id));
|
|
|
|
- tripal_db_set_active($previous_db); // now use drupal database
|
|
|
|
|
|
+ $library = db_fetch_object(chado_query($sql, $library_id));
|
|
$job_args[0] = $library_id;
|
|
$job_args[0] = $library_id;
|
|
tripal_add_job("Set taxonomy for features in library: $library->name", 'tripal_library',
|
|
tripal_add_job("Set taxonomy for features in library: $library->name", 'tripal_library',
|
|
'tripal_library_taxonify_features', $job_args, $user->uid);
|
|
'tripal_library_taxonify_features', $job_args, $user->uid);
|
|
@@ -851,18 +833,13 @@ function chado_library_validate($node) {
|
|
"{Library} WHERE ".
|
|
"{Library} WHERE ".
|
|
"uniquename = '%s' ".
|
|
"uniquename = '%s' ".
|
|
"AND NOT library_id = %d";
|
|
"AND NOT library_id = %d";
|
|
- $previous_db = tripal_db_set_active('chado');
|
|
|
|
- $lib = db_fetch_object(db_query($sql, $node->uniquename,
|
|
|
|
- $node->library_id));
|
|
|
|
- tripal_db_set_active($previous_db);
|
|
|
|
|
|
+ $lib = db_fetch_object(chado_query($sql, $node->uniquename, $node->library_id));
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
$sql = "SELECT * FROM ".
|
|
$sql = "SELECT * FROM ".
|
|
"{Library} ".
|
|
"{Library} ".
|
|
"WHERE uniquename = '%s'";
|
|
"WHERE uniquename = '%s'";
|
|
- $previous_db = tripal_db_set_active('chado');
|
|
|
|
- $lib = db_fetch_object(db_query($sql, $node->uniquename));
|
|
|
|
- tripal_db_set_active($previous_db);
|
|
|
|
|
|
+ $lib = db_fetch_object(chado_query($sql, $node->uniquename));
|
|
}
|
|
}
|
|
if ($lib) {
|
|
if ($lib) {
|
|
form_set_error('uniquename', t('The unique library name already exists. '.
|
|
form_set_error('uniquename', t('The unique library name already exists. '.
|
|
@@ -1091,9 +1068,7 @@ function chado_library_form($node) {
|
|
|
|
|
|
// get the list of organisms
|
|
// get the list of organisms
|
|
$sql = "SELECT * FROM {Organism}";
|
|
$sql = "SELECT * FROM {Organism}";
|
|
- $previous_db = tripal_db_set_active('chado'); // use chado database
|
|
|
|
- $org_rset = db_query($sql);
|
|
|
|
- tripal_db_set_active($previous_db); // now use drupal database
|
|
|
|
|
|
+ $org_rset = chado_query($sql);
|
|
|
|
|
|
$organisms = array();
|
|
$organisms = array();
|
|
$organisms[''] = '';
|
|
$organisms[''] = '';
|
|
@@ -1137,15 +1112,11 @@ function tripal_library_sync_libraries($library_id = NULL, $job_id = NULL) {
|
|
// get the list of libraries and create new nodes
|
|
// get the list of libraries and create new nodes
|
|
if (!$library_id) {
|
|
if (!$library_id) {
|
|
$sql = "SELECT * FROM {Library} L";
|
|
$sql = "SELECT * FROM {Library} L";
|
|
- $previous_db = tripal_db_set_active('chado'); // use chado database
|
|
|
|
- $results = db_query($sql);
|
|
|
|
- tripal_db_set_active($previous_db); // now use drupal database
|
|
|
|
|
|
+ $results = chado_query($sql);
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
$sql = "SELECT * FROM {Library} L WHERE library_id = %d";
|
|
$sql = "SELECT * FROM {Library} L WHERE library_id = %d";
|
|
- $previous_db = tripal_db_set_active('chado'); // use chado database
|
|
|
|
- $results = db_query($sql, $library_id);
|
|
|
|
- tripal_db_set_active($previous_db); // now use drupal database
|
|
|
|
|
|
+ $results = chado_query($sql, $library_id);
|
|
}
|
|
}
|
|
|
|
|
|
// We'll use the following SQL statement for checking if the library
|
|
// We'll use the following SQL statement for checking if the library
|
|
@@ -1225,13 +1196,11 @@ function chado_library_view($node, $teaser = FALSE, $page = FALSE) {
|
|
// but not genus/species/common_name. We need to get those from chado
|
|
// but not genus/species/common_name. We need to get those from chado
|
|
// database so they will show up in preview
|
|
// database so they will show up in preview
|
|
if (!$node->genus) {
|
|
if (!$node->genus) {
|
|
- $previous_db = tripal_db_set_active('chado');
|
|
|
|
$sql = "SELECT * FROM {organism} WHERE organism_id = %d";
|
|
$sql = "SELECT * FROM {organism} WHERE organism_id = %d";
|
|
- $data = db_fetch_object(db_query($sql, $node->organism_id));
|
|
|
|
|
|
+ $data = db_fetch_object(chado_query($sql, $node->organism_id));
|
|
$node->genus = $data->genus;
|
|
$node->genus = $data->genus;
|
|
$node->species = $data->species;
|
|
$node->species = $data->species;
|
|
$node->common_name = $data->common_name;
|
|
$node->common_name = $data->common_name;
|
|
- tripal_db_set_active($previous_db);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return $node;
|
|
return $node;
|
|
@@ -1315,9 +1284,7 @@ function tripal_library_feature_set_taxonomy($library_id = NULL) {
|
|
"INNER JOIN Library L ON LF.library_id = L.library_id ".
|
|
"INNER JOIN Library L ON LF.library_id = L.library_id ".
|
|
"WHERE L.library_id = $library_id ".
|
|
"WHERE L.library_id = $library_id ".
|
|
"ORDER BY LF.feature_id";
|
|
"ORDER BY LF.feature_id";
|
|
- $previous_db = tripal_db_set_active('chado'); // use chado database
|
|
|
|
- $features = db_query($sql);
|
|
|
|
- tripal_db_set_active($previous_db); // now use drupal database
|
|
|
|
|
|
+ $features = chado_query($sql);
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
print "Finding features for all libraries\n";
|
|
print "Finding features for all libraries\n";
|
|
@@ -1325,9 +1292,7 @@ function tripal_library_feature_set_taxonomy($library_id = NULL) {
|
|
"FROM {library_feature} LF ".
|
|
"FROM {library_feature} LF ".
|
|
"INNER JOIN Library L ON LF.library_id = L.library_id ".
|
|
"INNER JOIN Library L ON LF.library_id = L.library_id ".
|
|
"ORDER BY LF.feature_id";
|
|
"ORDER BY LF.feature_id";
|
|
- $previous_db = tripal_db_set_active('chado'); // use chado database
|
|
|
|
- $features = db_query($sql);
|
|
|
|
- tripal_db_set_active($previous_db); // now use drupal database
|
|
|
|
|
|
+ $features = chado_query($sql);
|
|
}
|
|
}
|
|
|
|
|
|
$node_sql = "SELECT * FROM {chado_feature} CF ".
|
|
$node_sql = "SELECT * FROM {chado_feature} CF ".
|
|
@@ -1359,18 +1324,14 @@ function tripal_library_reindex_features($library_id = NULL, $job_id = NULL) {
|
|
" INNER JOIN Library L ON LF.library_id = L.library_id ".
|
|
" INNER JOIN Library L ON LF.library_id = L.library_id ".
|
|
"WHERE L.library_id = $library_id ".
|
|
"WHERE L.library_id = $library_id ".
|
|
"ORDER BY LF.feature_id";
|
|
"ORDER BY LF.feature_id";
|
|
- $previous_db = tripal_db_set_active('chado'); // use chado database
|
|
|
|
- $results = db_query($sql);
|
|
|
|
- tripal_db_set_active($previous_db); // now use drupal database
|
|
|
|
|
|
+ $results = chado_query($sql);
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
$sql = "SELECT LF.feature_id, L.library_id, L.name as libname ".
|
|
$sql = "SELECT LF.feature_id, L.library_id, L.name as libname ".
|
|
" FROM {library_feature} LF ".
|
|
" FROM {library_feature} LF ".
|
|
" INNER JOIN Library L ON LF.library_id = L.library_id ".
|
|
" INNER JOIN Library L ON LF.library_id = L.library_id ".
|
|
"ORDER BY LF.feature_id";
|
|
"ORDER BY LF.feature_id";
|
|
- $previous_db = tripal_db_set_active('chado'); // use chado database
|
|
|
|
- $results = db_query($sql);
|
|
|
|
- tripal_db_set_active($previous_db); // now use drupal database
|
|
|
|
|
|
+ $results = chado_query($sql);
|
|
}
|
|
}
|
|
|
|
|
|
// load into ids array
|
|
// load into ids array
|
|
@@ -1407,18 +1368,14 @@ function tripal_library_taxonify_features($library_id = NULL, $job_id = NULL) {
|
|
" INNER JOIN Library L ON LF.library_id = L.library_id ".
|
|
" INNER JOIN Library L ON LF.library_id = L.library_id ".
|
|
"WHERE L.library_id = $library_id ".
|
|
"WHERE L.library_id = $library_id ".
|
|
"ORDER BY LF.feature_id";
|
|
"ORDER BY LF.feature_id";
|
|
- $previous_db = tripal_db_set_active('chado'); // use chado database
|
|
|
|
- $results = db_query($sql);
|
|
|
|
- tripal_db_set_active($previous_db); // now use drupal database
|
|
|
|
|
|
+ $results = chado_query($sql);
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
$sql = "SELECT LF.feature_id, L.library_id, L.name as libname ".
|
|
$sql = "SELECT LF.feature_id, L.library_id, L.name as libname ".
|
|
" FROM {library_feature} LF ".
|
|
" FROM {library_feature} LF ".
|
|
" INNER JOIN Library L ON LF.library_id = L.library_id ".
|
|
" INNER JOIN Library L ON LF.library_id = L.library_id ".
|
|
"ORDER BY LF.feature_id";
|
|
"ORDER BY LF.feature_id";
|
|
- $previous_db = tripal_db_set_active('chado'); // use chado database
|
|
|
|
- $results = db_query($sql);
|
|
|
|
- tripal_db_set_active($previous_db); // now use drupal database
|
|
|
|
|
|
+ $results = chado_query($sql);
|
|
}
|
|
}
|
|
|
|
|
|
// load into ids array
|
|
// load into ids array
|
|
@@ -1479,10 +1436,8 @@ function chado_library_delete(&$node) {
|
|
db_query($sql_del, $node->nid, $node->vid);
|
|
db_query($sql_del, $node->nid, $node->vid);
|
|
|
|
|
|
// Remove data from library and libraryprop tables of chado database as well
|
|
// Remove data from library and libraryprop tables of chado database as well
|
|
- $previous_db = tripal_db_set_active('chado');
|
|
|
|
- db_query("DELETE FROM {library} WHERE library_id = %d", $library_id);
|
|
|
|
- db_query("DELETE FROM {libraryprop} WHERE library_id = %d", $library_id);
|
|
|
|
- tripal_db_set_active($previous_db);
|
|
|
|
|
|
+ chado_query("DELETE FROM {library} WHERE library_id = %d", $library_id);
|
|
|
|
+ chado_query("DELETE FROM {libraryprop} WHERE library_id = %d", $library_id);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1573,7 +1528,6 @@ function get_chado_libraries() {
|
|
// Get library_id's from drupal
|
|
// Get library_id's from drupal
|
|
$sql = "SELECT library_id, nid FROM {chado_library}";
|
|
$sql = "SELECT library_id, nid FROM {chado_library}";
|
|
$result = db_query($sql);
|
|
$result = db_query($sql);
|
|
- $previous_db = tripal_db_set_active('chado');
|
|
|
|
// Get library info from chado's library, organism, and cvterm tables
|
|
// Get library info from chado's library, organism, and cvterm tables
|
|
$sql_info = "SELECT L.name, uniquename, genus, species, common_name, ".
|
|
$sql_info = "SELECT L.name, uniquename, genus, species, common_name, ".
|
|
" CVT.name as type_name ".
|
|
" CVT.name as type_name ".
|
|
@@ -1588,9 +1542,9 @@ function get_chado_libraries() {
|
|
"WHERE library_id = %d AND CVT.name = 'library_description'";
|
|
"WHERE library_id = %d AND CVT.name = 'library_description'";
|
|
$libraries = array();
|
|
$libraries = array();
|
|
while ($data = db_fetch_object($result)) {
|
|
while ($data = db_fetch_object($result)) {
|
|
- $library = db_fetch_object(db_query($sql_info, $data->library_id));
|
|
|
|
|
|
+ $library = db_fetch_object(chado_query($sql_info, $data->library_id));
|
|
$library->node_id = $data->nid;
|
|
$library->node_id = $data->nid;
|
|
- $desc = db_fetch_object(db_query($sql_desc, $data->library_id))->value;
|
|
|
|
|
|
+ $desc = db_fetch_object(chado_query($sql_desc, $data->library_id))->value;
|
|
if ($desc) {
|
|
if ($desc) {
|
|
$library->library_description = $desc;
|
|
$library->library_description = $desc;
|
|
}
|
|
}
|
|
@@ -1601,7 +1555,6 @@ function get_chado_libraries() {
|
|
$key = drupal_strtolower($library->uniquename);
|
|
$key = drupal_strtolower($library->uniquename);
|
|
$libraries [$key] = $library;
|
|
$libraries [$key] = $library;
|
|
}
|
|
}
|
|
- tripal_db_set_active($previous_db);
|
|
|
|
|
|
|
|
//Sort libraries by uniquename
|
|
//Sort libraries by uniquename
|
|
ksort($libraries, SORT_STRING);
|
|
ksort($libraries, SORT_STRING);
|