|
@@ -1221,56 +1221,54 @@ function tripal_feature_load_organism_feature_browser($organism){
|
|
|
|
|
|
// don't show the browser if the settings in the admin page is turned off
|
|
|
$show_browser = variable_get('tripal_feature_browse_setting',array('show_feature_browser'));
|
|
|
- if(strcmp($show_browser[0],'show_feature_browser')!=0){
|
|
|
- return false;
|
|
|
- }
|
|
|
- if ($organism->organism_id) {
|
|
|
- # get the list of available sequence ontology terms for which
|
|
|
- # we will build drupal pages from features in chado. If a feature
|
|
|
- # is not one of the specified typse we won't build a node for it.
|
|
|
- $allowed_types = variable_get('chado_feature_types','EST contig');
|
|
|
- $allowed_types = preg_replace("/[\s\n\r]+/"," ",$allowed_types);
|
|
|
- $so_terms = split(' ',$allowed_types);
|
|
|
- $where_cvt = "";
|
|
|
- foreach ($so_terms as $term){
|
|
|
- $where_cvt .= "CVT.name = '$term' OR ";
|
|
|
- }
|
|
|
- $where_cvt = substr($where_cvt,0,strlen($where_cvt)-3); # strip trailing 'OR'
|
|
|
-
|
|
|
- // get the features for this organism
|
|
|
- $sql = "SELECT F.name,F.feature_id,F.uniquename,CVT.name as cvname ".
|
|
|
- "FROM {feature} F ".
|
|
|
- " INNER JOIN {cvterm} CVT on F.type_id = CVT.cvterm_id ".
|
|
|
- "WHERE organism_id = %s and ($where_cvt) ".
|
|
|
- "ORDER BY feature_id ASC";
|
|
|
-
|
|
|
- // the counting SQL
|
|
|
- $csql = "SELECT count(*) ".
|
|
|
- "FROM {feature} F".
|
|
|
- " INNER JOIN {cvterm} CVT on F.type_id = CVT.cvterm_id ".
|
|
|
- "WHERE organism_id = %s and ($where_cvt) ".
|
|
|
- "GROUP BY organism_id ";
|
|
|
-
|
|
|
- $previous_db = tripal_db_set_active('chado'); // use chado database
|
|
|
- $org_features = pager_query($sql,10,0,$csql,$organism->organism_id);
|
|
|
- tripal_db_set_active($previous_db); // now use drupal database
|
|
|
- $pager = theme('pager');
|
|
|
+ if(strcmp($show_browser,'show_feature_browser')!=0){
|
|
|
+ return array ('enabled' => $show_browser );
|
|
|
+ }
|
|
|
+
|
|
|
+ # get the list of available sequence ontology terms for which
|
|
|
+ # we will build drupal pages from features in chado. If a feature
|
|
|
+ # is not one of the specified typse we won't build a node for it.
|
|
|
+ $allowed_types = variable_get('chado_feature_types','EST contig');
|
|
|
+ $allowed_types = preg_replace("/[\s\n\r]+/"," ",$allowed_types);
|
|
|
+ $so_terms = split(' ',$allowed_types);
|
|
|
+ $where_cvt = "";
|
|
|
+ foreach ($so_terms as $term){
|
|
|
+ $where_cvt .= "CVT.name = '$term' OR ";
|
|
|
+ }
|
|
|
+ $where_cvt = substr($where_cvt,0,strlen($where_cvt)-3); # strip trailing 'OR'
|
|
|
+
|
|
|
+ // get the features for this organism
|
|
|
+ $sql = "SELECT F.name,F.feature_id,F.uniquename,CVT.name as cvname ".
|
|
|
+ "FROM {feature} F ".
|
|
|
+ " INNER JOIN {cvterm} CVT on F.type_id = CVT.cvterm_id ".
|
|
|
+ "WHERE organism_id = %s and ($where_cvt) ".
|
|
|
+ "ORDER BY feature_id ASC";
|
|
|
+
|
|
|
+ // the counting SQL
|
|
|
+ $csql = "SELECT count(*) ".
|
|
|
+ "FROM {feature} F".
|
|
|
+ " INNER JOIN {cvterm} CVT on F.type_id = CVT.cvterm_id ".
|
|
|
+ "WHERE organism_id = %s and ($where_cvt) ".
|
|
|
+ "GROUP BY organism_id ";
|
|
|
|
|
|
- // prepare the query that will lookup node ids
|
|
|
- $sql = "SELECT nid FROM {chado_feature} ".
|
|
|
- "WHERE feature_id = %d";
|
|
|
- $i=0;
|
|
|
- $features = array();
|
|
|
- while($feature = db_fetch_object($org_features)){
|
|
|
- $node = db_fetch_object(db_query($sql,$feature->feature_id));
|
|
|
- $feature->nid = $node->nid;
|
|
|
- $features[$i++] = $feature;
|
|
|
- }
|
|
|
-drupal_set_message("Pager $pager");
|
|
|
+ $previous_db = tripal_db_set_active('chado'); // use chado database
|
|
|
+ $org_features = pager_query($sql,10,0,$csql,$organism->organism_id);
|
|
|
+ tripal_db_set_active($previous_db); // now use drupal database
|
|
|
+ $pager = theme('pager');
|
|
|
|
|
|
- return array ( 'features' => $features, 'pager' => $pager );
|
|
|
+ // prepare the query that will lookup node ids
|
|
|
+ $sql = "SELECT nid FROM {chado_feature} ".
|
|
|
+ "WHERE feature_id = %d";
|
|
|
+ $i=0;
|
|
|
+ $features = array();
|
|
|
+ while($feature = db_fetch_object($org_features)){
|
|
|
+ $node = db_fetch_object(db_query($sql,$feature->feature_id));
|
|
|
+ $feature->nid = $node->nid;
|
|
|
+ $features[$i++] = $feature;
|
|
|
}
|
|
|
- return false;
|
|
|
+
|
|
|
+ return array ( 'features' => $features, 'pager' => $pager, 'enabled' => $show_browser );
|
|
|
+
|
|
|
}
|
|
|
/************************************************************************
|
|
|
* used to sort the list of relationship objects by start position
|
|
@@ -1394,6 +1392,9 @@ function tripal_feature_nodeapi(&$node, $op, $teaser, $page) {
|
|
|
$node->content['tripal_feature_org_counts'] = array(
|
|
|
'#value' => theme('tripal_feature_org_counts', $node),
|
|
|
);
|
|
|
+ $node->content['tripal_organism_feature_browser'] = array(
|
|
|
+ '#value' => theme('tripal_organism_feature_browser', $node),
|
|
|
+ );
|
|
|
}
|
|
|
break;
|
|
|
case 'chado_library':
|
|
@@ -1401,19 +1402,6 @@ function tripal_feature_nodeapi(&$node, $op, $teaser, $page) {
|
|
|
default:
|
|
|
}
|
|
|
break;
|
|
|
- // we're loading the data for the node
|
|
|
- case 'load':
|
|
|
- switch($node->type){
|
|
|
- case 'chado_organism':
|
|
|
- // Show feature browser
|
|
|
- $types_to_show = array('chado_organism', 'chado_library');
|
|
|
- if (in_array($node->type, $types_to_show, TRUE)) {
|
|
|
- $variables['tripal_feature']['browser'] = tripal_feature_load_organism_feature_browser($node->organism);
|
|
|
- return $variables;
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- break;
|
|
|
}
|
|
|
}
|
|
|
/************************************************************************
|