|
@@ -4,6 +4,24 @@
|
|
* Implements hooks from the Schema API
|
|
* Implements hooks from the Schema API
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * 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;
|
|
|
|
+}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Implementation of hook_install().
|
|
* Implementation of hook_install().
|
|
*/
|
|
*/
|
|
@@ -22,6 +40,22 @@ function tripal_analysis_install() {
|
|
tripal_analysis_add_mview_analysis_organism();
|
|
tripal_analysis_add_mview_analysis_organism();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * Implementation of hook_uninstall().
|
|
|
|
+ */
|
|
|
|
+function tripal_analysis_uninstall() {
|
|
|
|
+
|
|
|
|
+ // 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 = $result->fetchObject()) {
|
|
|
|
+ node_delete($ana->nid);
|
|
|
|
+ }
|
|
|
|
+}
|
|
/*
|
|
/*
|
|
*
|
|
*
|
|
*/
|
|
*/
|
|
@@ -29,17 +63,17 @@ function tripal_analysis_create_analysisfeatureprop() {
|
|
|
|
|
|
// Create analysisfeatureprop table in chado. This is needed for Chado
|
|
// Create analysisfeatureprop table in chado. This is needed for Chado
|
|
// version 1.11, the table exists in Chado 1.2.
|
|
// 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)" .
|
|
|
|
- ")";
|
|
|
|
|
|
+ if (!db_table_exists('chado.analysisfeatureprop')) {
|
|
|
|
+ $sql = "
|
|
|
|
+ CREATE TABLE chado.analysisfeatureprop (
|
|
|
|
+ analysisfeatureprop_id SERIAL PRIMARY KEY,
|
|
|
|
+ analysisfeature_id INTEGER NOT NULL REFERENCES chado.analysisfeature(analysisfeature_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
|
|
|
+ type_id INTEGER NOT NULL REFERENCES chdo.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);
|
|
chado_query($sql);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -84,22 +118,6 @@ function tripal_analysis_add_cvterms() {
|
|
tripal_cv_add_cvterm(array('name' => 'Analysis Type', 'def' => 'The type of analysis was performed.'),
|
|
tripal_cv_add_cvterm(array('name' => 'Analysis Type', 'def' => 'The type of analysis was performed.'),
|
|
'analysis_property', 0, 1, 'tripal');
|
|
'analysis_property', 0, 1, 'tripal');
|
|
}
|
|
}
|
|
-/**
|
|
|
|
- * Implementation of hook_uninstall().
|
|
|
|
- */
|
|
|
|
-function tripal_analysis_uninstall() {
|
|
|
|
-
|
|
|
|
- // 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 = $result->fetchObject()) {
|
|
|
|
- node_delete($ana->nid);
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* Implementation of hook_schema() creates two tables.
|
|
* Implementation of hook_schema() creates two tables.
|
|
@@ -111,6 +129,7 @@ function tripal_analysis_uninstall() {
|
|
* with this module.
|
|
* with this module.
|
|
*/
|
|
*/
|
|
function tripal_analysis_schema() {
|
|
function tripal_analysis_schema() {
|
|
|
|
+
|
|
// chado_analysis table
|
|
// chado_analysis table
|
|
$schema['chado_analysis'] = array(
|
|
$schema['chado_analysis'] = array(
|
|
'fields' => array(
|
|
'fields' => array(
|
|
@@ -161,29 +180,13 @@ function tripal_analysis_schema() {
|
|
return $schema;
|
|
return $schema;
|
|
}
|
|
}
|
|
|
|
|
|
-/**
|
|
|
|
- * 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
|
|
* @ingroup tripal_network
|
|
*/
|
|
*/
|
|
function tripal_analysis_add_mview_analysis_organism() {
|
|
function tripal_analysis_add_mview_analysis_organism() {
|
|
|
|
+ $view_name = 'analysis_organism';
|
|
|
|
+ $comment = t('This view is for associating an organism (via it\'s associated features) to an analysis.');
|
|
|
|
|
|
// this is the SQL used to identify the organism to which an analsysis
|
|
// this is the SQL used to identify the organism to which an analsysis
|
|
// has been used. This is obtained though the analysisfeature -> feature -> organism
|
|
// has been used. This is obtained though the analysisfeature -> feature -> organism
|
|
@@ -198,7 +201,8 @@ function tripal_analysis_add_mview_analysis_organism() {
|
|
|
|
|
|
// the schema array for describing this view
|
|
// the schema array for describing this view
|
|
$schema = array(
|
|
$schema = array(
|
|
- 'table' => 'analysis_organism',
|
|
|
|
|
|
+ 'table' => $view_name,
|
|
|
|
+ 'description' => $comment,
|
|
'fields' => array(
|
|
'fields' => array(
|
|
'analysis_id' => array(
|
|
'analysis_id' => array(
|
|
'type' => 'int',
|
|
'type' => 'int',
|
|
@@ -229,10 +233,6 @@ function tripal_analysis_add_mview_analysis_organism() {
|
|
),
|
|
),
|
|
);
|
|
);
|
|
|
|
|
|
- // 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
|
|
// add the view
|
|
- tripal_add_mview('analysis_organism', 'tripal_analysis', NULL, NULL, NULL,
|
|
|
|
- $sql, NULL, $comment, $schema);
|
|
|
|
-}
|
|
|
|
|
|
+ tripal_add_mview($view_name, 'tripal_analysis', $schema, $sql, $comment);
|
|
|
|
+}
|