| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272 | 
							- <?php
 
- /**
 
-  * @file
 
-  * Implements hooks from the Schema API
 
-  */
 
- /**
 
-  * Implementation of hook_install().
 
-  */
 
- function tripal_analysis_install() {
 
-   // create the module's data directory
 
-   tripal_create_moddir('tripal_analysis');
 
-   // Use schema API to create database table.
 
-   drupal_install_schema('tripal_analysis');
 
-   // we may need the analysisfeatureprop table if it doesn't already exist
 
-   tripal_analysis_create_analysisfeatureprop();
 
-   
 
-   // add cvterms
 
-   tripal_analysis_add_cvterms();
 
-   
 
-   // add materialized views
 
-   tripal_analysis_add_mview_analysis_organism();
 
- }
 
- /**
 
-  *  Update for Drupal 6.x, Tripal 1.1, Analysis Module 1.1
 
-  *  This update adds a new analysis_organism materialized view
 
-  *
 
-  */
 
- function tripal_analysis_update_6100() {
 
-   // add the new materialized view
 
-   tripal_analysis_add_mview_analysis_organism();
 
-   
 
-   // move the analysis_type property into a new CV so that user's can change this property if
 
-   // they want too  
 
-   tripal_cv_add_cv('tripal_analysis', 'Terms used for managing analyses in Tripal');
 
-   
 
-   $sql = "
 
-     UPDATE {cvterm} SET cv_id = 
 
-       (SELECT cv_id FROM {cv} WHERE name = 'tripal_analysis')
 
-     WHERE cv_id = (SELECT cv_id FROM {cv} WHERE name = 'tripal') AND
 
-       name = 'analysis_type'
 
-   ";
 
-   chado_query($sql);
 
-   
 
-   $ret = array(
 
-     '#finished' => 1,
 
-   );
 
-   return $ret;
 
- }
 
- /*
 
-  * 
 
-  */
 
- function tripal_analysis_create_analysisfeatureprop(){
 
-   // Create analysisfeatureprop table in chado.  This is needed for Chado 
 
-   // version 1.11, the table exists in Chado 1.2. 
 
-   if (!db_table_exists('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, ".
 
-             "  value                  TEXT, ".
 
-             "  rank                   INTEGER NOT NULL, ".
 
-             "  CONSTRAINT analysisfeature_id_type_id_rank UNIQUE(analysisfeature_id, type_id, rank)".
 
-             ")";
 
-     chado_query($sql);
 
-   } 
 
- }
 
- /*
 
-  * 
 
-  */
 
- function tripal_analysis_add_cvterms(){
 
-   
 
-   tripal_cv_add_cv('tripal_analysis', 'Terms used for managing analyses in Tripal');
 
-   
 
-   // add analysis_type. This goes in the 'tripal_analysis' CV so that site admins
 
-   // change change this property
 
-   $term = 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_cv_add_cvterm($term, 'tripal_analysis', 0, 1, 'tripal');
 
-   
 
-   // add analysis_date.  This is no longer used (as far as we can tell) but we don't
 
-   // get rid of it in case it is used, so just keep it in the Tripal CV
 
-   $term = array(
 
-     'name' => 'analysis_date', 
 
-     'def' => 'The date that an analysis was performed.'
 
-   );
 
-   tripal_cv_add_cvterm($term, 'tripal', 0, 1, 'tripal');
 
-   
 
-   // add analysis_short_name.  This is no longer used (as far as we can tell) but we don't
 
-   // get rid of it in case it is used, so just keep it in the Tripal CV
 
-   $term = array(
 
-     'name' => 'analysis_short_name', 
 
-     'def' => 'A computer legible (no spaces or special characters) abbreviation for the analysis.'
 
-   );     
 
-   tripal_cv_add_cvterm($term, 'tripal', 0, 1 , 'tripal');     
 
-   
 
- }
 
- /**
 
-  * Implementation of hook_uninstall().
 
-  */
 
- function tripal_analysis_uninstall() {
 
-   // Use schema API to delete database table.
 
-   drupal_uninstall_schema('tripal_analysis');
 
-   // Remove analysis nodes from drupal.
 
-   $sql_ana_id = "SELECT nid, vid ".
 
-                  "FROM {node} ".
 
-                  "WHERE type like 'chado_analysi%'";
 
-   $result = db_query($sql_ana_id);
 
-   while ($ana = db_fetch_object($result)) {
 
-     node_delete($ana->nid);
 
-   }
 
- }
 
- /**
 
-  * Implementation of hook_schema() creates two tables.
 
-  *
 
-  * - chado_analysis table
 
-  *     stores nodes that are also saved in the analysis table of chado database.
 
-  * - tripal_analysis table
 
-  *     stores the sub-module names, such as tripal_analysis_blast, that are registered
 
-  *     with this module.
 
-  */
 
- function tripal_analysis_schema() {
 
-   // chado_analysis table
 
-   $schema['chado_analysis'] = array(
 
-     'fields' => array(
 
-       'vid' => array(
 
-         'type' => 'int',
 
-         'unsigned' => TRUE,
 
-         'not null' => TRUE,
 
-         'default' => 0
 
-       ),
 
-       'nid' => array(
 
-         'type' => 'int',
 
-         'unsigned' => TRUE,
 
-         'not null' => TRUE,
 
-         'default' => 0
 
-       ),
 
-       'analysis_id' => array(
 
-         'type' => 'int',
 
-         'not null' => TRUE,
 
-         'default' => 0
 
-       )
 
-     ),
 
-     'indexes' => array(
 
-       'analysis_id' => array('analysis_id')
 
-     ),
 
-     'unique keys' => array(
 
-       'nid_vid' => array('nid', 'vid'),
 
-       'vid' => array('vid')
 
-     ),
 
-     'primary key' => array('nid'),
 
-   );
 
-   // tripal_analysis table
 
-   $schema['tripal_analysis'] = array(
 
-     'description' => t('Table to store analysis sub-modules'),
 
-     'fields' => array(
 
-       'modulename' => array(
 
-         'type' => 'text',
 
-         'size' => 'small',
 
-         'not null' => TRUE,
 
-         'description' => t('The module name. Tripal Analysis will use the '.
 
-                             'module name to call module_setting_form()')
 
-       )
 
-     ),
 
-     'unique keys' => array(
 
-       'modulename' => array('modulename')
 
-     )
 
-   );
 
-   return $schema;
 
- }
 
- /**
 
-  * Provide update script for adding new cvterms
 
-  */
 
- 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(
 
-       '#finished' => 1,
 
-   );
 
-   return $ret;
 
- }
 
- /**
 
-  * Implementation of hook_requirements(). 
 
-  */
 
- function tripal_analysis_requirements($phase) {
 
-   $requirements = array();
 
-   if ($phase == 'install') {
 
-     // make sure chado is installed
 
-     if (!tripal_core_is_chado_installed()) {
 
-       $requirements ['tripal_analysis'] = array(
 
-             'title' => "tripal_analysis",
 
-             'value' => "ERROR: Chado most be installed before this module can be enabled",
 
-             'severity' => REQUIREMENT_ERROR,
 
-       );
 
-     }
 
-   }
 
-   return $requirements;
 
- }
 
- /*
 
-  * 
 
-  * @ingroup tripal_network
 
-  */
 
- function tripal_analysis_add_mview_analysis_organism() {
 
-   
 
-   // this is the SQL used to identify the organism to which an analsysis
 
-   // has been used.  This is obtained though the analysisfeature -> feature -> organism
 
-   // joins
 
-   $sql = "
 
-     SELECT DISTINCT A.analysis_id, O.organism_id
 
-     FROM analysis A
 
-       INNER JOIN analysisfeature AF ON A.analysis_id = AF.analysis_id
 
-       INNER JOIN feature F          ON AF.feature_id = F.feature_id
 
-       INNER JOIN organism O         ON O.organism_id = F.organism_id
 
-   ";
 
-   
 
-   // the schema array for describing this view
 
-   $schema = array(
 
-     'table' => 'analysis_organism',
 
-     'fields' => array(  
 
-       'analysis_id' => array(
 
-         'type' => 'int',
 
-         'not null' => TRUE,
 
-       ),
 
-       'organism_id' => array(
 
-         'type' => 'int',
 
-         'not null' => TRUE,
 
-       ),       
 
-     ),
 
-     'indexes' => array(
 
-       'networkmod_qtl_indx0' => array('analysis_id'),
 
-       'networkmod_qtl_indx1' => array('organism_id'),
 
-     ),
 
-     'foreign keys' => array(
 
-       'analysis' => array(
 
-         'table' => 'analysis',
 
-         'columns' => array(
 
-           'analysis_id' => 'analysis_id',
 
-         ),
 
-       ),
 
-       'organism' => array(
 
-         'table' => 'organism',
 
-         'columns' => array(
 
-           'organism_id' => 'organism_id',
 
-         ),
 
-       ),      
 
-     ),
 
-   );
 
-   
 
-   // add a comment to make sure this view makes sense to the site administator
 
-   $comment = t('This view is for associating an organism (via it\'s associated features) to an analysis.');
 
-   
 
-   // add the view
 
-   tripal_add_mview('analysis_organism', 'tripal_analysis', NULL, NULL, NULL,
 
-     $sql, NULL, $comment, $schema);
 
- }
 
 
  |