123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- <?php
- //$Id:
- /*******************************************************************************
- * Implementation of hook_install().
- */
- function tripal_analysis_blast_install() {
- // create the module's data directory
- tripal_create_moddir('tripal_analysis_blast');
- // We need to register to tripal_analysis module so it can provide a control
- // for our blast result. Basically the registration is done by inserting
- // modulename into the drupal {tripal_analysis} table AND inserting required
- // information to the chado Analysis table. Also in tripal_analysis_blast.module,
- // we need to define HOOK_get_settings() for the module to work properly.
-
- // Inert into drupal's {tripal_analysis}
- tripal_analysis_register_child('tripal_analysis_blast');
-
- // Add cvterm 'analysis_blast_output_iteration_hits' for inserting into featureprop table
- tripal_add_cvterms('analysis_blast_output_iteration_hits', 'Hits of a blast '.
- 'output iteration. Each iteration corresponds to a chado feature, and is '.
- 'the content between <iteration> and </iteration> tags in the blast xml '.
- 'output file. This cvterm represents all hits in the iteration');
- // Add cveterm 'analysis_blast_settings' for inserting into analysisprop table
- tripal_add_cvterms('analysis_blast_settings', 'Settings of a blast analysis, '.
- 'including db_id, output file, and run parameters separated by a bar |');
-
- // Create a tripal_analysis_blast table to store parsers
- drupal_install_schema('tripal_analysis_blast');
-
- // Create default parser for swissprot, DB:genbank, and go-seqdb
- $sql_db = "SELECT db_id, name FROM {db} WHERE name like '%s'";
- $sql_parser = "INSERT INTO {tripal_analysis_blast} ".
- " (db_id, displayname, regex_hit_id, regex_hit_def, regex_hit_accession, genbank_style) ".
- "VALUES (%d, '%s', '%s', '%s', '%s', %d)";
-
- // Add swissprot parser
- $previous_db = tripal_db_set_active ('chado');
- $results = db_query($sql_db, "%swissprot%");
- tripal_db_set_active($previous_db);
- while ($db = db_fetch_object($results)) {
- db_query($sql_parser, $db->db_id, 'ExPASy Swissprot', '^sp\|.*?\|(.*?)\s.*?$', '^sp\|.*?\|.*?\s(.*)$', 'sp\|(.*?)\|.*?\s.*?$', 0);
- }
-
- // Add trembl parser
- $previous_db = tripal_db_set_active ('chado');
- $results = db_query($sql_db, "%trembl%");
- tripal_db_set_active($previous_db);
- while ($db = db_fetch_object($results)) {
- db_query($sql_parser, $db->db_id, 'ExPASy TrEMBL', '^.*?\|(.*?)\s.*?$', '^.*?\|.*?\s(.*)$', '^(.*?)\|.*?\s.*?$', 0);
- }
-
- // Add genbank parser
- $previous_db = tripal_db_set_active ('chado');
- $results = db_query($sql_db, "%genbank%");
- tripal_db_set_active($previous_db);
- while ($db = db_fetch_object($results)) {
- db_query($sql_parser, $db->db_id, 'Genbank', '', '', '', 1);
- }
- }
- /*******************************************************************************
- * Implementation of hook_uninstall().
- */
- function tripal_analysis_blast_uninstall() {
-
- // Delete all information associate with the module
- // Drupal complains when the user tries to uninstall tripal_analysis
- // and tripal_analysis_blast 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
-
- //Delete the settings from {tripal_analysis} table
- tripal_analysis_unregister_child('tripal_analysis_blast');
- // Delete module's variables from variables table.
- db_query("DELETE FROM {variable} WHERE name='%s'",
- 'tripal_analysis_blast_setting');
-
- // Delete a tripal_analysis_blast table
- drupal_uninstall_schema('tripal_analysis_blast');
- }
- /*******************************************************************************
- * Implementation of hook_schema(). This table stores the parsers for blast xml
- * xml results.
- */
- function tripal_analysis_blast_schema() {
- $schema = array();
- $schema['tripal_analysis_blast'] = array(
- 'fields' => array(
- 'db_id' => array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'default' => 0
- ),
- 'displayname' => array(
- 'type' => 'varchar',
- 'length' => 100,
- 'not null' => TRUE,
- ),
- 'regex_hit_id' => array(
- 'type' => 'varchar',
- 'length' => 30,
- ),
- 'regex_hit_def' => array(
- 'type' => 'varchar',
- 'length' => 30,
- ),
- 'regex_hit_accession' => array(
- 'type' => 'varchar',
- 'length' => 30,
- ),
- 'genbank_style' => array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'default' => 0
- ),
- ),
- 'indexes' => array(
- 'db_id' => array('db_id')
- ),
- 'primary key' => array('db_id'),
- );
- return $schema;
- }
- /*******************************************************************************
- * Implementation of hook_requirements(). Make sure 'Tripal Core' and 'Tripal
- * Analysis' are enabled before installation
- */
- function tripal_analysis_blast_requirements($phase) {
- $requirements = array();
- if ($phase == 'install') {
- if (!function_exists('tripal_create_moddir') || !function_exists('tripal_analysis_register_child')) {
- $requirements ['tripal_analysis_blast'] = array(
- 'title' => "tripal_analysis_blast",
- 'value' => "error. Some required modules are just being installed. Please try again.",
- 'severity' => REQUIREMENT_ERROR,
- );
- }
- }
- return $requirements;
- }
|