'analysis_type', 'def' => 'The type of analysis that 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'); // the 'analysis_property' vocabulary is for user definable properties. Even though we already have // an analysis_type term in the 'tripal_analysis' vocabular we duplicate it here because the // tripal_analysis vocabulary is intended for use by the extension modules. user's should not be able // to directly modify properties set by extension modules for an analysis. tripal_cv_add_cvterm(array('name' => 'Analysis Type','def' => 'The type of analysis that was performed.'), 'analysis_property', 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; } /** * 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; } /** * 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: , ;'), 'tripal', 0, 1, 'tripal'); $ret = array( '#finished' => 1, ); return $ret; } /** * Update for Drupal 6.x, Tripal 1.1, Analysis Module 1.1 * This update adds a new analysis_property cv and 'Analysis Type' cvterm */ function tripal_analysis_update_6101() { // the 'analysis_property' vocabulary is for user definable properties. Even though we already have // an analysis_type term in the 'tripal_analysis' vocabular we duplicate it here because the // tripal_analysis vocabulary is intended for use by the extension modules. user's should not be able // to directly modify properties set by extension modules for an analysis. tripal_cv_add_cvterm(array('name' => 'Analysis Type','def' => 'The type of analysis was performed.'), 'analysis_property', 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); }