Browse Source

Merge pull request #183 from abretaud/docker_compat

Various fixes
Stephen Ficklin 7 years ago
parent
commit
beb1a605a0

+ 0 - 94
legacy/tripal_analysis/tripal_analysis.install

@@ -50,18 +50,12 @@ function tripal_analysis_requirements($phase) {
  */
 function tripal_analysis_install() {
 
-  // we may need the analysisfeatureprop table if it doesn't already exist
-  tripal_analysis_create_analysisfeatureprop();
-
   // add vocabularies
   tripal_analysis_add_cvs();
 
   // add cvterms
   tripal_analysis_add_cvterms();
 
-  // add materialized views
-  tripal_analysis_add_mview_analysis_organism();
-
   // set the default vocabularies
   tripal_set_default_cv('analysisprop', 'type_id', 'analysis_property');
 }
@@ -75,33 +69,6 @@ function tripal_analysis_uninstall() {
 
 }
 
-/**
- * Create a legacy custom chado table (analysisfeatureprop) to store properties of
- * analysisfeature links.
- *
- * @ingroup tripal_analysis
- */
-// This function was moved to tripal_chado/includes/setup/tripal_chado.setup.inc
-/* 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('chado.analysisfeatureprop')) {
-    $sql = "
-      CREATE TABLE {analysisfeatureprop} (
-        analysisfeatureprop_id SERIAL PRIMARY KEY,
-        analysisfeature_id     INTEGER NOT NULL,
-        type_id                INTEGER NOT NULL,
-        value                  TEXT,
-        rank                   INTEGER NOT NULL,
-        CONSTRAINT analysisfeature_id_type_id_rank UNIQUE (analysisfeature_id, type_id, rank),
-        CONSTRAINT analysisfeatureprop_analysisfeature_id_fkey FOREIGN KEY (analysisfeature_id) REFERENCES {analysisfeature}(analysisfeature_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
-        CONSTRAINT analysisfeatureprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES {cvterm}(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
-      )
-    ";
-    chado_query($sql);
-  }
-} */
 
 /**
  * Add cvs related to analyses
@@ -231,64 +198,3 @@ function tripal_analysis_schema() {
 
   return $schema;
 }
-
-/**
- * Creates a view showing the link between an organism & it's analysis through associated features.
- *
- * @ingroup tripal_analysis
- */
-// This function was moved to tripal_chado/includes/setup/tripal_chado.setup.inc
-/* 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
-  // 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' => $view_name,
-    'description' => $comment,
-    'fields' => array(
-      'analysis_id' => array(
-        'size' => 'big',
-        'type' => 'int',
-        'not null' => TRUE,
-      ),
-      'organism_id' => array(
-        'size' => 'big',
-        '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 the view
-  tripal_add_mview($view_name, 'tripal_analysis', $schema, $sql, $comment);
-} */

+ 0 - 191
legacy/tripal_feature/tripal_feature.install

@@ -57,14 +57,6 @@ function tripal_feature_install() {
   // $obo_id = tripal_insert_obo('Chado Feature Properties', $obo_path);
   // tripal_submit_obo_job(array('obo_id' => $obo_id));
 
-  // Add the materialized view.
-  tripal_feature_add_organism_count_mview();
-
-  // Add the custom tables.
-  tripal_feature_add_tripal_gff_temp_table();
-  tripal_feature_add_tripal_gffcds_temp_table();
-  tripal_feature_add_tripal_gffprotein_temp_table();
-
   // Add the vocabularies used by the feature module.
   tripal_feature_add_cvs();
 
@@ -82,119 +74,6 @@ function tripal_feature_install() {
 function tripal_feature_uninstall() {
 
 }
-// This function was moved to tripal_chado/includes/setup/tripal_chado.setup.inc
-/* function tripal_feature_add_tripal_gff_temp_table() {
-  $schema = array(
-    'table' => 'tripal_gff_temp',
-    'fields' => array(
-      'feature_id' => array(
-        'type' => 'int',
-        'not null' => TRUE,
-      ),
-      'organism_id' => array(
-        'type' => 'int',
-        'not null' => TRUE,
-      ),
-      'uniquename' => array(
-        'type' => 'text',
-        'not null' => TRUE,
-      ),
-      'type_name' => array(
-        'type' => 'varchar',
-        'length' => '1024',
-        'not null' => TRUE,
-      ),
-    ),
-    'indexes' => array(
-      'tripal_gff_temp_idx0' => array('feature_id'),
-      'tripal_gff_temp_idx0' => array('organism_id'),
-      'tripal_gff_temp_idx1' => array('uniquename'),
-    ),
-    'unique keys' => array(
-      'tripal_gff_temp_uq0' => array('feature_id'),
-      'tripal_gff_temp_uq1' => array('uniquename', 'organism_id', 'type_name'),
-    ),
-  );
-  chado_create_custom_table('tripal_gff_temp', $schema, TRUE);
-} */
-
-/**
- *
- */
-// This function was moved to tripal_chado/includes/setup/tripal_chado.setup.inc
-/* function tripal_feature_add_tripal_gffcds_temp_table($skip_recreate = TRUE) {
-  $schema = array(
-    'table' => 'tripal_gffcds_temp',
-    'fields' => array(
-      'feature_id' => array(
-        'type' => 'int',
-        'not null' => TRUE,
-      ),
-      'parent_id' => array(
-        'type' => 'int',
-        'not null' => TRUE,
-      ),
-      'phase' => array(
-        'type' => 'int',
-        'not null' => FALSE,
-      ),
-      'strand' => array(
-        'type' => 'int',
-        'not null' => TRUE,
-      ),
-      'fmin' => array(
-        'type' => 'int',
-        'not null' => TRUE,
-      ),
-      'fmax' => array(
-        'type' => 'int',
-        'not null' => TRUE,
-      ),
-    ),
-    'indexes' => array(
-      'tripal_gff_temp_idx0' => array('feature_id'),
-      'tripal_gff_temp_idx0' => array('parent_id'),
-    ),
-  );
-  chado_create_custom_table('tripal_gffcds_temp', $schema, $skip_recreate);
-} */
-
-/**
- *
- */
-// This function was moved to tripal_chado/includes/setup/tripal_chado.setup.inc
-/* function tripal_feature_add_tripal_gffprotein_temp_table() {
-  $schema = array(
-    'table' => 'tripal_gffprotein_temp',
-    'fields' => array(
-      'feature_id' => array(
-        'type' => 'int',
-        'not null' => TRUE,
-      ),
-      'parent_id' => array(
-        'type' => 'int',
-        'not null' => TRUE,
-      ),
-      'fmin' => array(
-        'type' => 'int',
-        'not null' => TRUE,
-      ),
-      'fmax' => array(
-        'type' => 'int',
-        'not null' => TRUE,
-      ),
-    ),
-    'indexes' => array(
-      'tripal_gff_temp_idx0' => array('feature_id'),
-      'tripal_gff_temp_idx0' => array('parent_id'),
-    ),
-    'unique keys' => array(
-      'tripal_gff_temp_uq0' => array('feature_id'),
-    ),
-  );
-  chado_create_custom_table('tripal_gffprotein_temp', $schema, TRUE);
-} */
-
 /**
  * Implementation of hook_schema().
  *
@@ -240,76 +119,6 @@ function tripal_feature_schema() {
   return $schema;
 };
 
-/**
- * Creates a materialized view that stores the type & number of features per organism
- *
- * @ingroup tripal_feature
- */
-// This function was moved to tripal_chado/includes/setup/tripal_chado.setup.inc
-/* function tripal_feature_add_organism_count_mview() {
-  $view_name = 'organism_feature_count';
-  $comment = 'Stores the type and number of features per organism';
-
-  $schema = array(
-    'description' => $comment,
-    'table' => $view_name,
-    'fields' => array(
-      'organism_id' => array(
-        'size' => 'big',
-        'type' => 'int',
-        'not null' => TRUE,
-      ),
-      'genus' => array(
-        'type' => 'varchar',
-        'length' => '255',
-        'not null' => TRUE,
-      ),
-      'species' => array(
-        'type' => 'varchar',
-        'length' => '255',
-        'not null' => TRUE,
-      ),
-      'common_name' => array(
-        'type' => 'varchar',
-        'length' => '255',
-        'not null' => FALSE,
-      ),
-      'num_features' => array(
-        'type' => 'int',
-        'not null' => TRUE,
-      ),
-      'cvterm_id' => array(
-        'size' => 'big',
-        'type' => 'int',
-        'not null' => TRUE,
-      ),
-      'feature_type' => array(
-        'type' => 'varchar',
-        'length' => '255',
-        'not null' => TRUE,
-      ),
-    ),
-    'indexes' => array(
-      'organism_feature_count_idx1' => array('organism_id'),
-      'organism_feature_count_idx2' => array('cvterm_id'),
-      'organism_feature_count_idx3' => array('feature_type'),
-    ),
-  );
-
-  $sql = "
-    SELECT
-        O.organism_id, O.genus, O.species, O.common_name,
-        count(F.feature_id) as num_features,
-        CVT.cvterm_id, CVT.name as feature_type
-     FROM organism O
-        INNER JOIN feature F  ON O.Organism_id = F.organism_id
-        INNER JOIN cvterm CVT ON F.type_id     = CVT.cvterm_id
-     GROUP BY
-        O.Organism_id, O.genus, O.species, O.common_name, CVT.cvterm_id, CVT.name
-  ";
-
-  tripal_add_mview($view_name, 'tripal_feature', $schema, $sql, $comment);
-} */
 /**
  * Add cvs related to publications
  *

+ 0 - 1
tripal/tripal.module

@@ -1295,4 +1295,3 @@ function tripal_field_group_table_rows_alter(&$element, &$children) {
     }
   }
 }
-

+ 1 - 7
tripal_chado/api/modules/tripal_chado.cv.api.inc

@@ -643,10 +643,6 @@ function tripal_update_cvtermpath_loop_checker_traverse($origin, $child_id, $cv_
     $type_id, $depth, $increment_of_depth, $possible_start_of_loop, $array_of_possible_loop,
     $traverse_of_loop, $increment) {
 
-  //watchdog('debug', '<pre>$increment: '. print_r($increment, TRUE) .'</pre>');
-  /*if ($increment > 10) {
-    die();
-  }*/
   chado_set_active('chado');
   $query = db_select('cvterm_relationship', 'cvtr')
     ->fields('cvtr')
@@ -656,7 +652,6 @@ function tripal_update_cvtermpath_loop_checker_traverse($origin, $child_id, $cv_
 
   foreach ($cterm as $item) {
     if ($array_of_possible_loop === $traverse_of_loop) {
-      watchdog('debug', 'LOOP');
       //Report the loop.
       $loop_found = end($array_of_possible_loop);
       break;
@@ -1251,7 +1246,7 @@ function tripal_insert_cvterm($term, $options = array()) {
         INNER JOIN {cv} CV on CV.cv_id = CVT.cv_id
       WHERE DBX.accession = :accession and DB.name = :dbname and CVT.name = :term and CV.name = :cvname
     ";
-    $check = chado_query($checksql, array(':accession' => $dbxref->accession, ':dbname' => $dbname, ':term' => $name, ':cvname' => $cvname))->fetchObject();
+    $check = chado_query($checksql, array(':accession' => $accession, ':dbname' => $dbname, ':term' => $name, ':cvname' => $cvname))->fetchObject();
     if (!$check) {
 
       // check to see if the dbxref exists if not, add it.
@@ -1654,4 +1649,3 @@ function tripal_set_default_cv($table, $field, $cv_name, $cv_id = FALSE) {
     return FALSE;
   }
 }
-

+ 8 - 5
tripal_chado/api/tripal_chado.schema.api.inc

@@ -87,12 +87,15 @@ function chado_column_exists($table, $column) {
 
   $default_db = $databases['default']['default']['database'];
   $cached_obj = cache_get('chado_table_columns', 'cache');
-  $cached_cols = $cached_obj->data;
-  if (is_array($cached_cols) and
-      array_key_exists($table, $cached_cols) and
-      array_key_Exists($column, $cached_cols[$table])) {
-    return $cached_cols[$table][$column]['exists'];
+  if ($cached_obj) {
+      $cached_cols = $cached_obj->data;
+      if (is_array($cached_cols) and
+          array_key_exists($table, $cached_cols) and
+          array_key_Exists($column, $cached_cols[$table])) {
+        return $cached_cols[$table][$column]['exists'];
+      }
   }
+
   $sql = "
     SELECT 1
     FROM information_schema.columns

+ 2 - 2
tripal_chado/includes/TripalImporter/FASTAImporter.inc

@@ -21,7 +21,7 @@ class FASTAImporter extends TripalImporter {
   /**
    * An array containing the extensions of allowed file types.
    */
-  public static $file_types = array('fasta', 'txt', 'fa', 'aa', 'pep', 'nuc');
+  public static $file_types = array('fasta', 'txt', 'fa', 'aa', 'pep', 'nuc', 'faa', 'fna');
 
 
   /**
@@ -936,4 +936,4 @@ class FASTAImporter extends TripalImporter {
     chado_query($sql, array(':feature_id' => $feature_id));
 
   }
-}
+}

+ 4 - 2
tripal_chado/includes/loaders/tripal_chado.pub_importer_PMID.inc

@@ -78,10 +78,12 @@ function tripal_pub_remote_validate_form_PMID($form, $form_state) {
  * @ingroup tripal_pub
  */
 function tripal_pub_remote_search_PMID($search_array, $num_to_retrieve, $page) {
-  // convert the terms list provicded by the caller into a string with words
+  // convert the terms list provided by the caller into a string with words
   // separated by a '+' symbol.
   $num_criteria = $search_array['num_criteria'];
-  $days = $search_array['days'];
+  $days = NULL;
+  if (isset($search_array['days']))
+    $days = $search_array['days'];
 
   $search_str = '';
 

+ 10 - 8
tripal_chado/includes/loaders/tripal_chado.pub_importers.inc

@@ -1222,32 +1222,35 @@ function tripal_pub_add_authors($pub_id, $authors, $do_contact) {
     // remove the 'valid' property as we don't have a CV term for it
     unset($author['valid']);
 
+    $values = array(
+      'pub_id' => $pub_id,
+      'rank' => $rank,
+    );
+
     // construct the contact.name field using the author information
     $name = '';
     $type = 'Person';
     if (isset($author['Given Name'])) {
       $name .= $author['Given Name'];
+      $values['givennames'] = $author['Given Name'];
     }
     if (isset($author['Surname'])) {
       $name .= ' ' . $author['Surname'];
+      $values['surname'] = substr($author['Surname'], 0, 100);
     }
     if (isset($author['Suffix'])) {
       $name .= ' ' . $author['Suffix'];
+      $values['suffix'] = $author['Suffix'];
     }
     if (isset($author['Collective'])) {
       $name = $author['Collective'];
       $type = 'Collective';
+      if (!isset($author['Surname']))
+        $values['surname'] = substr($author['Collective'], 0, 100);
     }
     $name = trim($name);
 
     // add an entry to the pubauthors table
-    $values = array(
-      'pub_id' => $pub_id,
-      'rank' => $rank,
-      'surname' => $author['Surname'] ? substr($author['Surname'], 0, 100) : substr($author['Collective'], 0, 100),
-      'givennames' => $author['Given Name'],
-      'suffix' => $author['Suffix'],
-    );
     $options = array('statement_name' => 'ins_pubauthor_idrasugisu');
     $pubauthor = chado_insert_record('pubauthor', $values, $options);
 
@@ -1694,4 +1697,3 @@ function tripal_pub_citation_form_submit(&$form_state) {
   $options [0] = $form_state['options']['#value'];
   tripal_add_job("Create citations ($options[0])", 'tripal_pub', 'tripal_pub_create_citations', $options, $user->uid);
 }
-

+ 2 - 2
tripal_chado/includes/loaders/tripal_chado.taxonomy_importer.inc

@@ -357,7 +357,7 @@ function tripal_chado_taxonomy_add_organism_property($organism_id, $term_name, $
   );
   $property = array(
     'type_name' => $term_name,
-    'cv_name' => organism_property,
+    'cv_name' => 'organism_property',
     'value' => $value
   );
   // Delete all properties of this type if the rank is zero.
@@ -365,4 +365,4 @@ function tripal_chado_taxonomy_add_organism_property($organism_id, $term_name, $
     chado_delete_property($record, $property);
   }
   chado_insert_property($record, $property);
-}
+}

+ 16 - 8
tripal_chado/includes/setup/tripal_chado.setup.inc

@@ -240,7 +240,8 @@ function tripal_chado_prepare_chado($job = NULL) {
       )
     );
     $term = tripal_load_term_entity(array('vocabulary' => 'OBI', 'accession' => '0100026'));
-    $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
+    if ($term)
+        $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
     if (!$term or !$bundle) {
       if (!tripal_create_bundle($args, $error)) {
         throw new Exception($error['!message']);
@@ -261,7 +262,8 @@ function tripal_chado_prepare_chado($job = NULL) {
       )
     );
     $term = tripal_load_term_entity(array('vocabulary' => 'operation', 'accession' => '2945'));
-    $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
+    if ($term)
+        $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
     if (!$term or !$bundle) {
       if (!tripal_create_bundle($args, $error)) {
         throw new Exception($error['!message']);
@@ -282,7 +284,8 @@ function tripal_chado_prepare_chado($job = NULL) {
       )
     );
     $term = tripal_load_term_entity(array('vocabulary' => 'local', 'accession' => 'project'));
-    $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
+    if ($term)
+        $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
     if (!$term or !$bundle) {
       if (!tripal_create_bundle($args, $error)) {
         throw new Exception($error['!message']);
@@ -303,7 +306,8 @@ function tripal_chado_prepare_chado($job = NULL) {
       )
     );
     $term = tripal_load_term_entity(array('vocabulary' => 'data', 'accession' => '1274'));
-    $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
+    if ($term)
+        $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
     if (!$term or !$bundle) {
       if (!tripal_create_bundle($args, $error)) {
         throw new Exception($error['!message']);
@@ -335,7 +339,8 @@ function tripal_chado_prepare_chado($job = NULL) {
       )
     );
     $term = tripal_load_term_entity(array('vocabulary' => 'TPUB', 'accession' => '0000002'));
-    $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
+    if ($term)
+        $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
     if (!$term or !$bundle) {
       if (!tripal_create_bundle($args, $error)) {
         throw new Exception($error['!message']);
@@ -376,7 +381,8 @@ function tripal_chado_prepare_chado($job = NULL) {
       )
     );
     $term = tripal_load_term_entity(array('vocabulary' => 'SO', 'accession' => '0000704'));
-    $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
+    if ($term)
+        $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
     if (!$term or !$bundle) {
       if (!tripal_create_bundle($args, $error)) {
         throw new Exception($error['!message']);
@@ -398,7 +404,8 @@ function tripal_chado_prepare_chado($job = NULL) {
       )
     );
     $term = tripal_load_term_entity(array('vocabulary' => 'SO', 'accession' => '0000234'));
-    $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
+    if ($term)
+        $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
     if (!$term or !$bundle) {
       if (!tripal_create_bundle($args, $error)) {
         throw new Exception($error['!message']);
@@ -419,7 +426,8 @@ function tripal_chado_prepare_chado($job = NULL) {
       )
     );
     $term = tripal_load_term_entity(array('vocabulary' => 'sep', 'accession' => '00195'));
-    $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
+    if ($term)
+        $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
     if (!$term or !$bundle) {
       if (!tripal_create_bundle($args, $error)) {
         throw new Exception($error['!message']);

+ 0 - 3
tripal_ds/includes/tripal_ds.ds.inc

@@ -46,9 +46,6 @@ function _ds_layout_settings_info($bundle_name, $instances) {
   $fields_with_regions = array();
   $i = 0;
   $all_fields = array();
-  watchdog('debug', '<pre>$bundle_name: '. print_r($bundle_name, TRUE) .'</pre>');
-
-  watchdog('debug', '<pre>$instances: '. print_r($instances, TRUE) .'</pre>');
 
   try {
     // Get the bundle and term objects.