| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 | 
							- <?php
 
- //$Id:
 
- /*******************************************************************************
 
-  * Implementation of hook_install().
 
-  */
 
- function tripal_analysis_unigene_install() {
 
-    // create the module's data directory
 
-    tripal_create_moddir('tripal_analysis_unigene');
 
-    // We need to register to tripal_analysis module so it can provide a control
 
-    // for our unigene result. Basically the registration is done by inserting
 
-    // required information into the {tripal_analysis} table.
 
-    tripal_analysis_register_child('tripal_analysis_unigene');
 
-    $previous_db = tripal_db_set_active('chado');
 
-    if (db_table_exists('unigene_libraries_mview')) {
 
-       $sql = "DROP TABLE unigene_libraries_mview";
 
-       db_query($sql);
 
-    }
 
-    if (db_table_exists('unigene_mview')) {
 
-       $sql = "DROP TABLE unigene_mview";
 
-       db_query($sql);
 
-    }
 
-    tripal_db_set_active($previous_db);
 
-    
 
-    tripal_analysis_unigene_add_cvterms();
 
-    tripal_analysis_unigene_add_organism_unigene_mview();
 
- }
 
- /**
 
- *
 
- */
 
- function tripal_analysis_unigene_update_6000(){
 
-    // we have some new cvterms to add
 
-    tripal_analysis_unigene_add_cvterms();
 
-    // remove the old unigene materialized view and add the new one.
 
-    $mview = tripal_mviews_get_mview_id('unigene_mview');
 
-    if($mview){
 
-       tripal_mviews_action('delete',$mview);
 
-    }
 
-    tripal_analysis_unigene_add_organism_unigene_mview();
 
-    $ret = array(
 
-       '#finished' => 1,
 
-    );
 
-    
 
-    return $ret;
 
- }
 
- /**
 
- *
 
- */
 
- function tripal_analysis_unigene_add_cvterms(){
 
-    tripal_add_cvterms('unigene_version','The version number for the unigene ".
 
-      "(e.g. v1, v2, etc...) ');
 
-    tripal_add_cvterms('analysis_unigene_name', 'The name for a unigene.');
 
-    tripal_add_cvterms('analysis_unigene_num_contigs','The number of contigs in the unigene assembly');
 
-    tripal_add_cvterms('analysis_unigene_num_singlets','The number of singlets remaining in the unigene assembly');
 
-    tripal_add_cvterms('analysis_unigene_num_clusters','The number of clusters in the unigene assembly');
 
-    tripal_add_cvterms('analysis_unigene_num_reads','The number of reads, after filtering, used as input for the assembly');
 
-    tripal_add_cvterms('singlet',"Indicates the feature is a singlet in a ".
 
-      "specific unigene version (e.g. v1, v2, etc...). The value specified ".
 
-      "should match that of the unigene_version");
 
-    // Add cveterm 'analysis_unigene_settings' for inserting into analysisprop table   
 
-    tripal_add_cvterms('analysis_unigene_settings', 'Settings of a unigene analysis');
 
- }
 
- /**
 
- *
 
- */
 
- function tripal_analysis_unigene_add_organism_unigene_mview(){
 
-    $view_name = 'organism_unigene_mview';
 
-    // Drop the MView table if it exists
 
-    $mview_id = tripal_mviews_get_mview_id($view_name);
 
-    if($mview_id){
 
-       tripal_mviews_action("delete",$mview_id);
 
-    }
 
-    tripal_add_mview(
 
-       // view name
 
-       $view_name,
 
-       // tripal module name
 
-       'tripal_analysis_unigene',
 
-       // table name
 
-       $view_name,
 
-       // table schema definition
 
-       'analysis_id integer, organism_id integer',
 
-       // columns for indexing
 
-       'analysis_id, organism_id',
 
-       // SQL statement to populate the view
 
- 	   "SELECT DISTINCT A.analysis_id, O.organism_id ".
 
-       "FROM {Analysis} A ".
 
-       "  INNER JOIN analysisprop AP    ON AP.analysis_id = A.analysis_id ".
 
-       "  INNER JOIN cvterm CVT         ON AP.type_id = CVT.cvterm_id ".
 
-       "  INNER JOIN cv CV              ON CV.cv_id = CVT.cv_id ".
 
-       "  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 F.organism_id = O.organism_id ".
 
-       "WHERE CV.name = 'tripal' AND CVT.name='analysis_unigene_name'",
 
-       // special index 
 
- 	   ''
 
-    );
 
-    // add a job to the job queue so this view gets updated automatically next
 
-    // time the job facility is run
 
-    $mview_id = tripal_mviews_get_mview_id($view_name);
 
-    if($mview_id){
 
-       tripal_mviews_action('update',$mview_id);
 
-    }
 
- }
 
- /*******************************************************************************
 
-  * Implementation of hook_uninstall().
 
-  */
 
- function tripal_analysis_unigene_uninstall() {
 
-    $mview = tripal_mviews_get_mview_id('unigene_mview');
 
-    if($mview){
 
-       tripal_mviews_action('delete',$mview);
 
-    }
 
-    $mview = tripal_mviews_get_mview_id('unigene_libraries_mview');
 
-    if($mview){
 
-       tripal_mviews_action('delete',$mview);
 
-    }
 
-    // Delete the settings from {tripal_analysis} table
 
-    // Drupal complains when the user tries to uninstall tripal_analysis 
 
-    // and tripal_analysis_unigene at the same time. This is because Drupal drops
 
-    // the {tripal_analysis} table before we can delete anything from it. Thus,
 
-    // we perform a db_table_exists() check before the deletion
 
-    tripal_analysis_unregister_child('tripal_analysis_unigene');
 
-    // Delete module's variables from variables table.
 
-    db_query("DELETE FROM {variable} WHERE name='%s'",
 
-             'tripal_analysis_unigene_setting');
 
-    
 
- }
 
- /*******************************************************************************
 
-  * Implementation of hook_requirements(). Make sure 'Tripal Core' and 'Tripal
 
-  * Analysis' are enabled before installation
 
-  */
 
- function tripal_analysis_unigene_requirements($phase) {
 
-    $requirements = array();
 
-    if ($phase == 'install') {
 
-       if (!function_exists('tripal_create_moddir') || !function_exists('tripal_analysis_register_child')) {
 
-          $requirements ['tripal_analysis_unigene'] = array(
 
-             'title' => "tripal_analysis_unigene",
 
-             'value' => "error. Some required modules are just being installed. Please try again.",
 
-             'severity' => REQUIREMENT_ERROR,
 
-          );
 
-       }
 
-    }
 
-    return $requirements;
 
- }
 
 
  |