Browse Source

Removed unneeded indexFeatures.inc file

Ficklin 10 years ago
parent
commit
83e06c6f3d
2 changed files with 37 additions and 215 deletions
  1. 0 177
      tripal_feature/includes/indexFeatures.inc
  2. 37 38
      tripal_feature/tripal_feature.module

+ 0 - 177
tripal_feature/includes/indexFeatures.inc

@@ -1,177 +0,0 @@
-<?php
-/**
- * @file
- * @todo Add file header description
- */
-
-
-// This script can be run as a stand-alone script to sync all the features from chado to drupal
-//
-// To index a single feature
-// -i feature_id
-// -n node_id
-//
-// To index all features
-// -i 0
-
-$arguments = getopt("i:n:");
-
-if (isset($arguments['i'])) {
-  $drupal_base_url = parse_url('http://www.example.com');
-  $_SERVER['HTTP_HOST'] = $drupal_base_url['host'];
-  $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF'];
-  $_SERVER['REMOTE_ADDR'] = NULL;
-  $_SERVER['REQUEST_METHOD'] = NULL;
-
-  require_once 'includes/bootstrap.inc';
-  drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
-
-  $feature_id = $arguments['i'];
-  $nid        = $arguments['n'];
-
-  # print "\n";
-  # print "feature id is $feature_id\n";
-  # print "nid is $nid\n";
-  # print "\n";
-
-  if ($feature_id > 0) {
-    # print "indexing feature $feature_id\n";
-   // We register a shutdown function to ensure that the nodes
-   // that are indexed will have proper entries in the search_totals
-   // table.  Without these entries, the searching doesn't work
-   // properly. This function may run for quite a while since
-   // it must calculate the sum of the scores of all entries in
-   // the search_index table.  In the case of common words like
-   // 'contig', this will take quite a while
-    register_shutdown_function('search_update_totals');
-    tripal_feature_index_feature($feature_id, $nid);
-  }
-  else{
-    print "indexing all features...\n";
-    tripal_features_reindex(0);
-  }
-
-}
-
-/**
- *
- *
- * @ingroup tripal_feature
- */
-function tripal_features_reindex($max_sync, $job_id = NULL) {
-  $i = 0;
-
-  // We register a shutdown function to ensure that the nodes
-  // that are indexed will have proper entries in the search_totals
-  // table.  Without these entries, the searching doesn't work
-  // properly. This function may run for quite a while since
-  // it must calculate the sum of the scores of all entries in
-  // the search_index table.  In the case of common words like
-  // 'contig', this will take quite a while
-  register_shutdown_function('search_update_totals');
-
-  // use this SQL statement to get the features that we're going to index. This
-  // SQL statement is derived from the hook_search function in the Drupal API.
-  // Essentially, this is the SQL statement that finds all nodes that need
-  // reindexing, but adjusted to include the chado_feature
-  $sql = "SELECT N.nid, N.title, CF.feature_id ".
-        "FROM {node} N ".
-        "  INNER JOIN {chado_feature} CF ON CF.nid = N.nid ";
-  $results = db_query($sql);
-
-  // load into ids array
-  $count = 0;
-  $chado_features = array();
-  while ($chado_feature = db_fetch_object($results)) {
-    $chado_features[$count] = $chado_feature;
-    $count++;
-  }
-
-  // Iterate through features that need to be indexed
-  $interval = intval($count * 0.01);
-  if ($interval >= 0) {
-    $interval = 1;
-  }
-  foreach ($chado_features as $chado_feature) {
-
-    // update the job status every 1% features
-    if ($job_id and $i % $interval == 0) {
-      $prog = intval(($i/$count)*100);
-      tripal_job_set_progress($job_id, $prog);
-      print "$prog%\n";
-    }
-
-    // sync only the max requested
-    if ($max_sync and $i == $max_sync) {
-      return '';
-    }
-    $i++;
-
-  /**
-    * tripal_feature_index_feature ($chado_feature->feature_id,$chado_feature->nid);
-    * parsing all the features can cause memory overruns
-    * we are not sure why PHP does not clean up the memory as it goes
-    * to avoid this problem we will call this script through an
-    * independent system call
-    */
-
-    $cmd = "php " . drupal_get_path('module', 'tripal_feature') . "/indexFeatures.php ";
-    $cmd .= "-i $chado_feature->feature_id -n $chado_feature->nid ";
-
-    # print "\t$cmd\n";
-    # print "\tfeature id is $chado_feature->feature_id\n";
-    # print "\tnid is $chado_feature->nid\n";
-    # print "\n";
-
-    system($cmd);
-    }
-
-  return '';
-}
-
-/**
- *
- *
- * @ingroup tripal_feature
- */
-function tripal_feature_index_feature($feature_id, $nid) {
-  #print "\tfeature $feature_id nid $nid\n";
-  // return if we haven't been provided with a feature_id
-  if (!$feature_id) {
-    return 0;
-  }
-
-  // if we only have a feature_id then let's find a corresponding
-  // node.  If we can't find a node then return.
-  if (!$nid) {
-    $nsql = "SELECT N.nid,N.title FROM {chado_feature} CF ".
-            "  INNER JOIN {node} N ON N.nid = CF.nid ".
-            "WHERE CF.feature_id = %d";
-    $node = db_fetch_object(db_query($nsql, $feature_id));
-    if (!$node) {
-      return 0;
-    }
-    $node = node_load($node->nid);
-  }
-  else {
-    $node = node_load($nid);
-  }
-
-  // node load the noad, the comments and the taxonomy and
-  // index
-  $node->build_mode = NODE_BUILD_SEARCH_INDEX;
-  $node = node_build_content($node, FALSE, FALSE);
-  $node->body = drupal_render($node->content);
-  node_invoke_nodeapi($node, 'view', FALSE, FALSE);
-  //   $node->body .= module_invoke('comment', 'nodeapi', $node, 'update index');
-  //   $node->body .= module_invoke('taxonomy','nodeapi', $node, 'update index');
-  //   print "$node->title: $node->body\n";
-  search_index($node->nid, 'node', $node->body);
-
-  # $mem = memory_get_usage(TRUE);
-  # $mb = $mem/1048576;
-  # print "$mb mb\n";
-
-  return 1;
-}
-

+ 37 - 38
tripal_feature/tripal_feature.module

@@ -15,7 +15,6 @@
 
 require_once "includes/tripal_feature.admin.inc";
 require_once "includes/tripal_feature.sync_features.inc";
-require_once "includes/indexFeatures.inc";
 require_once "includes/fasta_loader.inc";
 require_once "includes/gff_loader.inc";
 require_once "includes/seq_extract.inc";
@@ -134,9 +133,9 @@ function tripal_feature_perm() {
  *  @return
  *  If the permission for the specified operation is not set then return FALSE. If the
  *  permission is set then return NULL as this allows other modules to disable
- *  access.  The only exception is when the $op == 'create'.  We will always 
+ *  access.  The only exception is when the $op == 'create'.  We will always
  *  return TRUE if the permission is set.
- *  
+ *
  * @ingroup tripal_feature
  */
 function chado_feature_access($op, $node, $account) {
@@ -182,14 +181,14 @@ function tripal_feature_menu() {
     'access arguments' => array('access chado_feature content'),
     'type' => MENU_CALLBACK,
   );
-  
+
   $items['find/sequences/ajax'] = array(
     'title' => 'Sequence Retrieval',
     'page callback' => 'tripal_feature_seq_extract_form_ahah_update',
     'access arguments' => array('access chado_feature content'),
     'type' => MENU_CALLBACK,
   );
-  
+
   // the administative settings menu
   $items['admin/tripal/tripal_feature'] = array(
     'title' => 'Features',
@@ -332,7 +331,7 @@ function tripal_feature_theme() {
       'arguments' =>  array(NULL),
       'path' => drupal_get_path('module', 'tripal_feature') . '/theme'
     ),
-    
+
     // themed forms
     'tripal_feature_seq_extract_form' => array(
        'arguments' => array('form'),
@@ -501,7 +500,7 @@ function chado_feature_insert($node) {
     'type_id' => $type[0]->cvterm_id,
   );
   $feature = tripal_core_chado_select('feature', array('feature_id'), $values);
-    
+
   // add the genbank accession and synonyms
   chado_feature_add_synonyms($node->synonyms, $feature[0]->feature_id);
 
@@ -562,7 +561,7 @@ function chado_feature_update($node) {
     );
     $options = array('return_record' => TRUE);
     $status = tripal_core_chado_update('feature', $match, $values, $options);
-    
+
     // add the genbank synonyms
     chado_feature_add_synonyms($node->synonyms, $feature_id);
   }
@@ -574,7 +573,7 @@ function chado_feature_update($node) {
     WATCHDOG_WARNING
     );
   }
-  
+
 
 }
 /**
@@ -831,8 +830,8 @@ function chado_feature_form($node, $param) {
 
   // get the sequence ontology CV ID
   $values = array('name' => 'sequence');
-  $cv = tripal_core_chado_select('cv', array('cv_id'), $values); 
-  $cv_id = $cv[0]->cv_id; 
+  $cv = tripal_core_chado_select('cv', array('cv_id'), $values);
+  $cv_id = $cv[0]->cv_id;
 
   $form['feature_type'] = array(
    '#title'       => t('Feature Type'),
@@ -907,11 +906,11 @@ function chado_feature_form($node, $param) {
  */
 function chado_feature_validate($node) {
   $result = 0;
-  
+
   // make sure the feature type is a real sequence ontology term
   $type = tripal_cv_get_cvterm_by_name($node->feature_type, NULL, 'sequence');
   if (!$type) {
-     form_set_error('feature_type', t("The feature type is not a valid name from the Sequence Ontology."));	
+     form_set_error('feature_type', t("The feature type is not a valid name from the Sequence Ontology."));
   }
 
   // if this is an update, we want to make sure that a different feature for
@@ -970,10 +969,10 @@ function chado_feature_load($node) {
     if (strcmp($feature->name, $feature->uniquename)==0) {
       $node->title = $feature->name . " (" . $feature->type_id->name . ") " . $feature->organism_id->genus . " " . $feature->organism_id->species ;
     }
-    // in previous version of Tripal, the feature title was simply the unique name. 
+    // in previous version of Tripal, the feature title was simply the unique name.
     // so, we recreate the title just to be sure all of our feature pages are consistent
     else {
-      $node->title = $feature->name . ", " . $feature->uniquename . " (" . $feature->type_id->name . ") " . $feature->organism_id->genus . " " . $feature->organism_id->species ;  
+      $node->title = $feature->name . ", " . $feature->uniquename . " (" . $feature->type_id->name . ") " . $feature->organism_id->genus . " " . $feature->organism_id->species ;
     }
   }
   // set the title to be the feature name or uniquename as configured
@@ -981,7 +980,7 @@ function chado_feature_load($node) {
     $node->title = $feature->name;
   }
   if($title_type == 'feature_unique_name') {
-    $node->title = $feature->uniquename;  
+    $node->title = $feature->uniquename;
   }
 
   $additions = new stdClass();
@@ -1840,23 +1839,23 @@ function chado_feature_view($node, $teaser = FALSE, $page = FALSE) {
  * @ingroup tripal_feature
  */
 function tripal_feature_nodeapi(&$node, $op, $teaser, $page) {
-  
+
   switch ($op) {
-    
+
      // set the title to ensure it is always unique
     case 'presave':
       switch ($node->type) {
         case 'chado_feature':
-          
+
           $values = array('organism_id' => $node->organism_id);
           $organism = tripal_core_chado_select('organism', array('genus','species'), $values);
           $node->title = $node->fname . ', ' . $node->uniquename . ' (' . $node->feature_type . ') ' . $organism[0]->genus . ' ' . $organism[0]->species;
           break;
       }
       break;
-      
-    // set the URL path after inserting.  We do it here because we do not 
-    // know the feature_id in the presave  
+
+    // set the URL path after inserting.  We do it here because we do not
+    // know the feature_id in the presave
     case 'insert':
       switch ($node->type) {
         case 'chado_feature':
@@ -1866,34 +1865,34 @@ function tripal_feature_nodeapi(&$node, $op, $teaser, $page) {
             $node->feature_id = $chado_feature->feature_id;
           }
 
-          
+
           // remove any previous alias
           db_query("DELETE FROM {url_alias} WHERE src = '%s'", "node/$node->nid");
-          
+
           // set the URL for this feature page
           $url_alias = tripal_feature_get_feature_url($node);
           path_set_alias("node/$node->nid", $url_alias);
           break;
       }
       break;
-      
-    // set the URL path after inserting.  We do it here because we do not 
-    // know the feature_id in the presave  
+
+    // set the URL path after inserting.  We do it here because we do not
+    // know the feature_id in the presave
     case 'update':
       switch ($node->type) {
         case 'chado_feature':
-          
+
           // remove any previous alias
           db_query("DELETE FROM {url_alias} WHERE src = '%s'", "node/$node->nid");
-          
+
           // set the URL for this feature page
           $url_alias = tripal_feature_get_feature_url($node);
           path_set_alias("node/$node->nid", $url_alias);
           break;
       }
       break;
-      
-      
+
+
     // add items to other nodes, build index and search results
     case 'view':
       switch ($node->type) {
@@ -2304,15 +2303,15 @@ function tripal_feature_coder_ignore() {
  * features is shown.
  */
 function tripal_feature_match_features_page($id) {
-  
+
   // if the URL alias configuration is set such that the URL
   // always begins with 'feature' then we want to use the ID as it is and
   // forward it on. Otherwise, try to find the matching feature.
-  $url_alias = variable_get('chado_feature_url_string', '/feature/[genus]/[species]/[type]/[uniquename]'); 
+  $url_alias = variable_get('chado_feature_url_string', '/feature/[genus]/[species]/[type]/[uniquename]');
   if (!$url_alias) {
     $url_alias = '/feature/[genus]/[species]/[type]/[uniquename]';
-  } 
-  $url_alias = preg_replace('/^\//', '', $url_alias); // remove any preceeding forward slash  
+  }
+  $url_alias = preg_replace('/^\//', '', $url_alias); // remove any preceeding forward slash
   if (preg_match('/^feature\//', $url_alias)) {
     drupal_goto($id);
   }
@@ -2377,16 +2376,16 @@ function tripal_feature_match_features_page($id) {
 }
 
 /**
- * 
+ *
  * @param unknown_type $form
  * @param unknown_type $form_state
  * @param unknown_type $form_id
  */
 function tripal_feature_form_alter(&$form, &$form_state, $form_id) {
-  if ($form_id == "tripal_feature_seq_extract_form") {    
+  if ($form_id == "tripal_feature_seq_extract_form") {
     // updating the form through the ahah callback sets the action of
     // the form to the ahah callback URL. We need to set it back
     // to the normal form URL
     $form['#action'] = url("find/sequences");
   }
-} 
+}