Jelajahi Sumber

Tripal Analysis adheres to Drupal coding standards

Pubudu Basnayaka 12 tahun lalu
induk
melakukan
ab377e3619

+ 2 - 2
tripal_analysis/tripal_analysis.admin.inc

@@ -73,8 +73,8 @@ function tripal_analysis_module_description_page() {
             </ul>
             </p>';
 
-   $text .= '<h3>Page Customizations</h3>';
-   $text .= '<p>There are several ways to customize the look-and-feel for the way Chado data is presented through Tripal.
+  $text .= '<h3>Page Customizations</h3>';
+  $text .= '<p>There are several ways to customize the look-and-feel for the way Chado data is presented through Tripal.
              Below is a description of several methods.  These methods may be used in conjunction with one another to
              provide fine-grained control.
              <ul>

+ 8 - 8
tripal_analysis/tripal_analysis.api.inc

@@ -10,9 +10,9 @@
  * @ingroup tripal_analysis
  * @ingroup tripal_api
  */
-/****************************************************************************
+/**
  * @section Chado Table Descriptions
- ****************************************************************************/
+ */
 /**
  * Implements hook_chado_analysis_schema()
  * Purpose: To add descriptions and foreign keys to default table description
@@ -143,7 +143,7 @@ function tripal_analysis_chado_analysisprop_schema() {
  * @ingroup tripal_analysis_api
  */
 function tripal_analysis_get_property($analysis_id, $property) {
-   return tripal_core_get_property('analysis', $analysis_id, $property, 'tripal');
+  return tripal_core_get_property('analysis', $analysis_id, $property, 'tripal');
 }
 
 /**
@@ -188,7 +188,7 @@ function tripal_analysis_insert_property($analysis_id, $property, $value, $updat
  * @ingroup tripal_analysis_api
  */
 function tripal_analysis_update_property($analysis_id, $property, $value, $insert_if_missing = 0) {
-   return tripal_core_update_property('analysis', $analysis_id, $property, 'tripal', $value, $insert_if_missing);
+  return tripal_core_update_property('analysis', $analysis_id, $property, 'tripal', $value, $insert_if_missing);
 }
 
 /**
@@ -208,7 +208,7 @@ function tripal_analysis_update_property($analysis_id, $property, $value, $inser
  * @ingroup tripal_analysis_api
  */
 function tripal_analysis_delete_property($analysis_id, $property) {
-   return tripal_core_delete_property('analysis', $analysis_id, $property, 'tripal');
+  return tripal_core_delete_property('analysis', $analysis_id, $property, 'tripal');
 }
 /**
  * Retreives the node of a sync'ed analysis
@@ -222,10 +222,10 @@ function tripal_analysis_delete_property($analysis_id, $property) {
  * @ingroup tripal_analysis_api
  */
 function tripal_analysis_get_node($analysis_id) {
-   $sql = "SELECT *
+  $sql = "SELECT *
            FROM chado_analysis CA
               INNER JOIN node N on CA.nid = N.nid
            WHERE analysis_id = %d";
-   $node = db_fetch_object(db_query($sql, $analysis_id));
-   return $node;
+  $node = db_fetch_object(db_query($sql, $analysis_id));
+  return $node;
 }

+ 15 - 15
tripal_analysis/tripal_analysis.install

@@ -20,7 +20,7 @@ function tripal_analysis_install() {
   // table is used to store Blast xml and Interpro html/goterms
   $previous_db = tripal_db_set_active('chado');
   if (!db_table_exists('analysisfeatureprop')) {
-     $sql = "CREATE TABLE {analysisfeatureprop} (".
+    $sql = "CREATE TABLE {analysisfeatureprop} (".
             "  analysisfeatureprop_id SERIAL PRIMARY KEY, ".
             "  analysisfeature_id INTEGER NOT NULL REFERENCES analysisfeature(analysisfeature_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, ".
             "  type_id INTEGER NOT NULL REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, ".
@@ -28,11 +28,11 @@ function tripal_analysis_install() {
             "  rank INTEGER NOT NULL, ".
             "  CONSTRAINT analysisfeature_id_type_id_rank UNIQUE(analysisfeature_id, type_id, rank)".
             ")";
-     db_query($sql);
+    db_query($sql);
   }
   tripal_db_set_active($previous_db);
 
-   tripal_cv_add_cvterm(array('name' => 'analysis_type', 'def' => 'The type of analysis was performed. This value is automatically set by each Tripal Analysis module and should be equal to the module name (e.g. tripal_analysis_blast, tripal_analysis_go).'), 'tripal', 0, 1, 'tripal');
+  tripal_cv_add_cvterm(array('name' => 'analysis_type', 'def' => 'The type of analysis was performed. This value is automatically set by each Tripal Analysis module and should be equal to the module name (e.g. tripal_analysis_blast, tripal_analysis_go).'), 'tripal', 0, 1, 'tripal');
   tripal_cv_add_cvterm(array('name' => 'analysis_date', 'def' => 'The date that an analysis was performed.'), 'tripal', 0, 1, 'tripal');
   tripal_cv_add_cvterm(array('name' => 'analysis_short_name', 'def' => 'A computer legible (no spaces ' .
       'or special characters) abbreviation for the analysis.'), 'tripal', 0, 1 , 'tripal');
@@ -116,17 +116,17 @@ function tripal_analysis_schema() {
  * before installation
  */
 function tripal_analysis_requirements($phase) {
-   $requirements = array();
-   if ($phase == 'install') {
-      if (!function_exists('tripal_create_moddir')) {
-         $requirements ['tripal_analysis'] = array(
+  $requirements = array();
+  if ($phase == 'install') {
+    if (!function_exists('tripal_create_moddir')) {
+      $requirements ['tripal_analysis'] = array(
             'title' => "tripal_analysis",
             'value' => "error. Some required modules are just being installed. Please try again.",
             'severity' => REQUIREMENT_ERROR,
-         );
+      );
       }
-   }
-   return $requirements;
+  }
+  return $requirements;
 }
 
 /*******************************************************************************
@@ -134,10 +134,10 @@ function tripal_analysis_requirements($phase) {
  */
 function tripal_analysis_update_6001() {
    // we have some new cvterms to add
-   tripal_cv_add_cvterm(array('name' => 'based_on_analysis', 'def' => 'The analysis that this analysis was based on. For example, blast/kegg/interpro analyses are based on a unigene analysis. The unigene analysis_id should be stored in analysisprop as the rank using this cvterm. The name of said unigene analysis can be inserted as the value in analysisprop.'), 'tripal', 0, 1, 'tripal');
-   tripal_cv_add_cvterm(array('name' => 'additional_files', 'def' => 'Additional files for this analysis. Each file should be separated by a semi-colon and have this format: <file description>, <file path>;'), 'tripal', 0, 1, 'tripal');
-   $ret = array(
+  tripal_cv_add_cvterm(array('name' => 'based_on_analysis', 'def' => 'The analysis that this analysis was based on. For example, blast/kegg/interpro analyses are based on a unigene analysis. The unigene analysis_id should be stored in analysisprop as the rank using this cvterm. The name of said unigene analysis can be inserted as the value in analysisprop.'), 'tripal', 0, 1, 'tripal');
+  tripal_cv_add_cvterm(array('name' => 'additional_files', 'def' => 'Additional files for this analysis. Each file should be separated by a semi-colon and have this format: <file description>, <file path>;'), 'tripal', 0, 1, 'tripal');
+  $ret = array(
       '#finished' => 1,
-   );
-   return $ret;
+  );
+  return $ret;
 }

+ 92 - 92
tripal_analysis/tripal_analysis.module

@@ -23,8 +23,8 @@ require('tripal_analysis_privacy.inc');
  * @ingroup tripal_analysis
  */
 function tripal_analysis_register_child($modulename) {
-   $sql = "INSERT INTO {tripal_analysis} (modulename) VALUES ('%s')";
-   db_query($sql, $modulename);
+  $sql = "INSERT INTO {tripal_analysis} (modulename) VALUES ('%s')";
+  db_query($sql, $modulename);
 }
 /**
  *
@@ -32,10 +32,10 @@ function tripal_analysis_register_child($modulename) {
  * @ingroup tripal_analysis
  */
 function tripal_analysis_unregister_child($modulename) {
-   if (db_table_exists('tripal_analysis')) {
+  if (db_table_exists('tripal_analysis')) {
       $sql = "DELETE FROM {tripal_analysis} WHERE modulename = '%s'";
       db_query($sql, $modulename);
-   }
+  }
 }
 
 /**
@@ -43,12 +43,12 @@ function tripal_analysis_unregister_child($modulename) {
  * @ingroup tripal_analysis
  */
 function tripal_analysis_init() {
-   drupal_add_js(drupal_get_path('theme', 'tripal') . '/js/tripal_analysis.js');
+  drupal_add_js(drupal_get_path('theme', 'tripal') . '/js/tripal_analysis.js');
 }
 
 /**
- * tripal_analysis_menu()
- * HOOK: Implementation of hook_menu()
+ * tripal_analysis_menu().
+ * Implementation of hook_menu().
  * Entry points and paths of the module
  *
  * @ingroup tripal_analysis
@@ -57,14 +57,14 @@ function tripal_analysis_menu() {
   // Display available analyses
   $items['analyses'] = array(
       'menu_name' => ('primary-links'), //Enable the 'Analysis' primary link
-      'title' => t('Analyses'),
+      'title' => 'Analyses',
       'page callback' => 'tripal_analysis_show_analyses',
       'access arguments' => array('access chado_analysis content'),
       'type' => MENU_NORMAL_ITEM
   );
   //Sync analysis
   $items['chado_sync_analyses'] = array(
-     'title' => t('Sync Data'),
+     'title' => 'Sync Data',
      'page callback' => 'tripal_analysis_sync_analyses',
      'access arguments' => array('administer site configuration'),
      'type' => MENU_CALLBACK
@@ -174,8 +174,8 @@ function chado_analysis_insert($node) {
           'timeexecuted' => $timestamp
       );
       if (tripal_core_chado_insert('analysis', $values)) {
-         $analysis = tripal_core_chado_select('analysis', array('*'), $values);
-         $analysis_id = $analysis[0]->analysis_id;
+        $analysis = tripal_core_chado_select('analysis', array('*'), $values);
+        $analysis_id = $analysis[0]->analysis_id;
       }
   }
 
@@ -215,8 +215,8 @@ function chado_analysis_insert($node) {
 
    // add the analysis to the node object for
    // use by other analysis modules that may be using this function
-   $node->analysis = $analysis;
-   $node->analysis_id = $analysis_id; // we need to set this for children
+    $node->analysis = $analysis;
+    $node->analysis_id = $analysis_id; // we need to set this for children
 }
 /**
  *
@@ -327,53 +327,53 @@ function chado_analysis_update($node) {
  */
 function chado_analysis_form($node) {
 
-   $analysis = $node->analysis;
-
-   // add in the description column. It is a text field and may not be included
-   // if the text is too big.
-   $analysis = tripal_core_expand_chado_vars($analysis, 'field', 'analysis.description');
-
-   // get form defaults
-   $analysis_id = $node->analysis_id;
-   if (!$analysis_id) {
-      $analysis_id = $analysis->analysis_id;
-   }
-   $analysisname = $node->analysisname;
-   if (!$analysisname) {
-      $analysisname = $analysis->name;
-   }
-   $program = $node->program;
-   if (!$program) {
-      $program = $analysis->program;
-   }
-   $programversion = $node->programversion;
-   if (!$programversion) {
-      $programversion = $analysis->programversion;
-   }
-   $algorithm = $node->algorithm;
-   if (!$algorithm) {
-      $algorithm = $analysis->algorithm;
-   }
-   $sourcename = $node->sourcename;
-   if (!$sourcename) {
-      $sourcename = $analysis->sourcename;
-   }
-   $sourceversion = $node->sourceversion;
-   if (!$sourceversion) {
-      $sourceversion = $analysis->sourceversion;
-   }
-   $sourceuri = $node->sourceuri;
-   if (!$sourceuri) {
-      $sourceuri = $analysis->sourceuri;
-   }
-   $timeexecuted = $node->timeexecuted;
-   if (!$timeexecuted) {
-      $timeexecuted = $analysis->timeexecuted;
-   }
-   $description = $node->description;
-   if (!$description) {
-      $description = $analysis->description;
-   }
+  $analysis = $node->analysis;
+
+  // add in the description column. It is a text field and may not be included
+  // if the text is too big.
+  $analysis = tripal_core_expand_chado_vars($analysis, 'field', 'analysis.description');
+
+  // get form defaults
+  $analysis_id = $node->analysis_id;
+  if (!$analysis_id) {
+    $analysis_id = $analysis->analysis_id;
+  }
+    $analysisname = $node->analysisname;
+  if (!$analysisname) {
+    $analysisname = $analysis->name;
+  }
+    $program = $node->program;
+  if (!$program) {
+    $program = $analysis->program;
+  }
+    $programversion = $node->programversion;
+  if (!$programversion) {
+    $programversion = $analysis->programversion;
+  }
+    $algorithm = $node->algorithm;
+  if (!$algorithm) {
+    $algorithm = $analysis->algorithm;
+  }
+    $sourcename = $node->sourcename;
+  if (!$sourcename) {
+    $sourcename = $analysis->sourcename;
+  }
+    $sourceversion = $node->sourceversion;
+  if (!$sourceversion) {
+    $sourceversion = $analysis->sourceversion;
+  }
+    $sourceuri = $node->sourceuri;
+  if (!$sourceuri) {
+    $sourceuri = $analysis->sourceuri;
+  }
+    $timeexecuted = $node->timeexecuted;
+  if (!$timeexecuted) {
+    $timeexecuted = $analysis->timeexecuted;
+  }
+    $description = $node->description;
+  if (!$description) {
+    $description = $analysis->description;
+  }
   $form = array();
   $form['title']= array(
       '#type' => 'hidden',
@@ -482,23 +482,23 @@ function chado_analysis_form($node) {
   return $form;
 }
 
-/**
- *  When a node is requested by the user this function is called to allow us
- *  to add auxiliary data to the node object.
- *
- * @ingroup tripal_analysis
- */
+ /**
+  *  When a node is requested by the user this function is called to allow us
+  *  to add auxiliary data to the node object.
+  *
+  * @ingroup tripal_analysis
+  */
 function chado_analysis_load($node) {
 
    // get the feature details from chado
-   $analysis_id = chado_get_id_for_node('analysis', $node);
+  $analysis_id = chado_get_id_for_node('analysis', $node);
 
-   $values = array('analysis_id' => $analysis_id);
-   $analysis = tripal_core_generate_chado_var('analysis', $values);
+  $values = array('analysis_id' => $analysis_id);
+  $analysis = tripal_core_generate_chado_var('analysis', $values);
 
-   $additions = new stdClass();
-   $additions->analysis = $analysis;
-   return $additions;
+  $additions = new stdClass();
+  $additions->analysis = $analysis;
+  return $additions;
 }
 
 /**
@@ -601,10 +601,10 @@ function tripal_analysis_sync_analyses($analysis_id = NULL, $job_id = NULL) {
          // This is a kegg analysis
         }
         elseif ($analysis_type->value == 'tripal_analysis_kegg' ) {
-           $new_node->type = 'chado_analysis_kegg';
+          $new_node->type = 'chado_analysis_kegg';
         }
         else {
-           $new_node->type = 'chado_analysis';
+          $new_node->type = 'chado_analysis';
         }
       // If it doesn't exist, this analysis is generic
       }
@@ -649,12 +649,12 @@ function tripal_analysis_sync_analyses($analysis_id = NULL, $job_id = NULL) {
         node_save($node);
 
         if ($node->nid) {
-          $page_content .= "Added $new_node->title<br>";
+          $page_content .= "Added $new_node->title<br />";
         }
       }
     }
     else {
-      $page_content .= "Skipped $new_node->title<br>";
+      $page_content .= "Skipped $new_node->title<br />";
     }
   }
   return $page_content;
@@ -666,12 +666,12 @@ function tripal_analysis_sync_analyses($analysis_id = NULL, $job_id = NULL) {
  */
 function chado_analysis_validate($node, &$form) {
    // use the analysis parent to validate the node
-   tripal_analysis_validate($node, $form);
+  tripal_analysis_validate($node, $form);
 }
 /**
- *
- *@ingroup tripal_analysis
- */
+  *
+  * @ingroup tripal_analysis
+  */
 function tripal_analysis_validate($node, &$form) {
 ##dprint_r($node);
 
@@ -715,9 +715,9 @@ function tripal_analysis_validate($node, &$form) {
             );
             $analysis = tripal_core_chado_select('analysis', array('analysis_id'), $values);
             if (sizeof($analysis) > 0) {
-               form_set_error('program', 'Cannot add the analysis with this program,
+              form_set_error('program', 'Cannot add the analysis with this program,
                   program version and source name. An analysis with these values already exists.');
-               return;
+              return;
             }
         }
     }
@@ -767,10 +767,10 @@ function chado_analysis_access($op, $node, $account) {
   }
   if ($op == 'view') {
     if (!user_access('access chado_analysis content', $account)) {
-         return FALSE;
+      return FALSE;
       }
   }
-   return NULL;
+    return NULL;
 }
 
 /**
@@ -853,13 +853,13 @@ function get_chado_analyses() {
  */
 function theme_tripal_analysis_analysis_page($analyses) {
 
-  $output = "<br>Analyses are listed in the descending order of their execution time.<br><a id=\"tripal_expandableBox_toggle_button\" onClick=\"toggleExpandableBoxes()\">[-] Collapse All</a>";
+  $output = "<br />Analyses are listed in the descending order of their execution time.<br /><a id=\"tripal_expandableBox_toggle_button\" onClick=\"toggleExpandableBoxes()\">[-] Collapse All</a>";
 
-   foreach ($analyses as $analysis) {
+  foreach ($analyses as $analysis) {
     // Prepare information for html output
     $ana_node_url = url("node/$analysis->node_id");
-     if ($analysis->sourceversion) {
-         $ver = "($analysis->sourceversion)";
+    if ($analysis->sourceversion) {
+      $ver = "($analysis->sourceversion)";
       }
       $date =  preg_replace("/^(\d+-\d+-\d+) .*/", "$1", $analysis->timeexecuted);
 
@@ -1057,7 +1057,7 @@ function tripal_analysis_taxonify_features ($analysis_id = NULL, $job_id = NULL)
     $i++;
   }
 }
-*/
+ */
 /**
  * Implements hook_views_api()
  * Purpose: Essentially this hook tells drupal that there is views support for
@@ -1067,7 +1067,7 @@ function tripal_analysis_taxonify_features ($analysis_id = NULL, $job_id = NULL)
  * @ingroup tripal_analysis
  */
 function tripal_analysis_views_api() {
-   return array(
-      'api' => 2.0,
-   );
+    return array(
+    'api' => 2.0,
+  );
 }

+ 6 - 6
tripal_analysis/tripal_analysis.views.inc

@@ -33,12 +33,12 @@ function tripal_analysis_views_data()  {
   $data = array();
 
   if (module_exists('tripal_views')) {
-		// Base Table: Analysis
-		$tablename = 'analysis';
-		if (!tripal_views_is_integrated($tablename, 10)) {
-			$table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, TRUE);
-			tripal_views_integration_add_entry($table_integration_array);
-		}
+    // Base Table: Analysis
+    $tablename = 'analysis';
+    if (!tripal_views_is_integrated($tablename, 10)) {
+      $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, TRUE);
+      tripal_views_integration_add_entry($table_integration_array);
+    }
 
 
     $tables = array(