Przeglądaj źródła

Merge branch '7.x-3.x' of github.com:tripal/tripal into 7.x-3.x

Chun-Huai Cheng 7 lat temu
rodzic
commit
3677126d7c

+ 4 - 1
tripal/tripal.module

@@ -959,6 +959,8 @@ function tripal_element_info() {
   //       stored in the 'module' column of the file_usage table.
   //    -#allowed_types:  An array of file extensions that are allowed for
   //       to be uploaded.
+  //    -#cardinality:  A numeric value indicating the number of files the
+  //       user can upload. Set to 0 for unlimited.
   $elements['html5_file'] = array(
     '#input' => 'TRUE',
     '#process' => array('tripal_html5_file_process'),
@@ -979,6 +981,7 @@ function tripal_html5_file_process($element, $form_state, $complete_form) {
   $name = $element['#name'];
   $name = preg_replace('/[^\w]/', '_', $name);
   $allowed_types = array_key_exists('#allowed_types', $element) ? $element['#allowed_types'] : array();
+  $cardinality = array_key_exists('#cardinality', $element) ? $element['#cardinality'] : 1;
 
   $headers = array(
     array('data' => 'File'),
@@ -1033,7 +1036,7 @@ function tripal_html5_file_process($element, $form_state, $complete_form) {
     'table_id' => '#tripal-html5-file-upload-table-' . $type,
     'submit_id' => '#tripal-html5-file-upload-submit-' . $type,
     'category' => array($element['#usage_id'] . '-' . $element['#usage_type']),
-    'cardinality' => 1,
+    'cardinality' => $cardinality,
     'target_id' => 'tripal-html5-upload-fid-' . $type,
     'module' => $module,
     'allowed_types' => $allowed_types,

+ 3 - 0
tripal_bulk_loader/includes/tripal_bulk_loader.chado_node.inc

@@ -189,6 +189,9 @@ function tripal_bulk_loader_load($nodes) {
   );
   foreach ($result as $record) {
     $record->num_inserted = sizeof(preg_split('/,/', $record->ids_inserted));
+    if(!isset($nodes[$record->nid]->inserted_records)) {
+      $nodes[$record->nid]->inserted_records = new stdClass();
+    }
     $nodes[$record->nid]->inserted_records->{$record->table_inserted_into} = $record;
   }
 

+ 1 - 1
tripal_chado/api/modules/tripal_chado.organism.api.inc

@@ -145,7 +145,7 @@ function tripal_get_organism_select_options($syncd_only = TRUE) {
   if ($syncd_only) {
     $sql = "
       SELECT *
-      FROM {chado_organism} CO
+      FROM [chado_organism] CO
         INNER JOIN {organism} O ON O.organism_id = CO.organism_id
       ORDER BY O.genus, O.species
     ";

+ 57 - 12
tripal_chado/includes/setup/tripal_chado.setup.inc

@@ -144,7 +144,9 @@ function tripal_chado_prepare_chado($job = NULL) {
     $job->load($job);
   }
   $report_progress = TRUE;
-  if (!is_object($job)) { $report_progress = FALSE; }
+  if (!is_object($job)) {
+    $report_progress = FALSE;
+  }
 
   try {
 
@@ -178,19 +180,25 @@ function tripal_chado_prepare_chado($job = NULL) {
       tripal_chado_fix_v1_3_custom_tables();
     }
 
-    if ($report_progress) { $job->setProgress(5); }
+    if ($report_progress) {
+      $job->setProgress(5);
+    }
 
     // Import commonly used ontologies if needed.
     drush_print("Loading Ontologies...");
     tripal_chado_load_ontologies();
 
-    if ($report_progress) { $job->setProgress(50); }
+    if ($report_progress) {
+      $job->setProgress(50);
+    }
 
     // Populate the semantic web associations for Chado tables/fields.
     drush_print("Making semantic connections for Chado tables/fields...");
     tripal_chado_populate_chado_semweb_table();
 
-    if ($report_progress) { $job->setProgress(60); }
+    if ($report_progress) {
+      $job->setProgress(60);
+    }
 
     // Initialize the population of the chado_cvterm_mapping table.  This will
     // map existing data types already in Chado so that when users want to
@@ -198,7 +206,9 @@ function tripal_chado_prepare_chado($job = NULL) {
     drush_print("Map Chado Controlled vocabularies to Tripal Terms...");
     tripal_chado_map_cvterms();
 
-    if ($report_progress) { $job->setProgress(70); }
+    if ($report_progress) {
+      $job->setProgress(70);
+    }
 
     drush_print("Creating common Tripal Content Types...");
 
@@ -219,7 +229,9 @@ function tripal_chado_prepare_chado($job = NULL) {
         throw new Exception($error['!message']);
       }
     }
-    if ($report_progress) { $job->setProgress(74); }
+    if ($report_progress) {
+      $job->setProgress(74);
+    }
 
     // Create the 'Analysis' entity type. This uses the local:analysis term.
     $error = '';
@@ -238,7 +250,9 @@ function tripal_chado_prepare_chado($job = NULL) {
         throw new Exception($error['!message']);
       }
     }
-    if ($report_progress) { $job->setProgress(78); }
+    if ($report_progress) {
+      $job->setProgress(78);
+    }
 
     // Create the 'Project' entity type. This uses the local:project term.
     $error = '';
@@ -257,7 +271,9 @@ function tripal_chado_prepare_chado($job = NULL) {
         throw new Exception($error['!message']);
       }
     }
-    if ($report_progress) { $job->setProgress(82); }
+    if ($report_progress) {
+      $job->setProgress(82);
+    }
 
     // Create the 'Map' entity type. This uses the local:project term.
     $error = '';
@@ -283,7 +299,9 @@ function tripal_chado_prepare_chado($job = NULL) {
     );
     $cvterm = tripal_get_cvterm($identifier);
     tripal_chado_add_cvterm_mapping($cvterm->cvterm_id, 'featuremap', NULL);
-    if ($report_progress) { $job->setProgress(86); }
+    if ($report_progress) {
+      $job->setProgress(86);
+    }
 
     // Import a publication so we get all of the properties before
     // creating the content type.
@@ -325,7 +343,9 @@ function tripal_chado_prepare_chado($job = NULL) {
     );
     $result = chado_select_record('pub_dbxref', array('pub_id'), $values);
     chado_delete_record('pub', array('pub_id' => $result[0]->pub_id));
-    if ($report_progress) { $job->setProgress(90); }
+    if ($report_progress) {
+      $job->setProgress(90);
+    }
 
     // Create the 'Gene' entity type.
     $error = '';
@@ -345,7 +365,9 @@ function tripal_chado_prepare_chado($job = NULL) {
         throw new Exception($error['!message']);
       }
     }
-    if ($report_progress) { $job->setProgress(94); }
+    if ($report_progress) {
+      $job->setProgress(94);
+    }
 
     // Create the 'mRNA' entity type.
     $error = '';
@@ -365,7 +387,30 @@ function tripal_chado_prepare_chado($job = NULL) {
         throw new Exception($error['!message']);
       }
     }
-    if ($report_progress) { $job->setProgress(98); }
+    if ($report_progress) {
+      $job->setProgress(98);
+    }
+
+    // Create the 'biological sample' entity type.
+    $error = '';
+    $args = array(
+      'vocabulary' => 'sep',
+      'accession' => '00195',
+      'term_name' => 'biological sample',
+      'storage_args' => array(
+        'data_table' => 'biomaterial',
+      )
+    );
+    $term = tripal_load_term_entity(array('vocabulary' => 'sep', 'accession' => '00195'));
+    $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']);
+      }
+    }
+    if ($report_progress) {
+      $job->setProgress(99);
+    }
 
     // Add the supported loaders
     variable_set('tripal_pub_supported_dbs', array('PMID', 'AGL'));

+ 18 - 0
tripal_chado/includes/tripal_chado.semweb.inc

@@ -237,6 +237,24 @@ function tripal_chado_populate_vocab_SCHEMA() {
   ));
 }
 
+/**
+ * Adds the Sample processing and separation techniques database and terms.
+ */
+function tripal_chado_populate_vocab_SEP() {
+  tripal_insert_db(array(
+    'name' => 'sep',
+    'description' => 'Sample processing and separation techniques.',
+    'url' => 'http://psidev.info/index.php?q=node/312',
+    'urlprefix' => 'http://purl.obolibrary.org/obo/{db}_{accession}',
+  ));
+  tripal_insert_cv('sep','A structured controlled vocabulary for the annotation of sample processing and separation techniques in scientific experiments.');
+  $term = tripal_insert_cvterm(array(
+    'id' => 'sep:00195',
+    'name' => 'biological sample',
+    'cv_name' => 'sep',
+    'definition' => 'A biological sample analysed by a particular technology.',
+  ));
+}
 /**
  * Adds the SemanticScience database and terms.
  */

+ 25 - 0
tripal_chado/tripal_chado.install

@@ -1285,4 +1285,29 @@ function tripal_chado_update_7317() {
     $error = $e->getMessage();
     throw new DrupalUpdateException('Could not perform update: '. $error);
   }
+}
+
+/**
+ * Adding biological sample term for biomaterial entities.
+ */
+function tripal_chado_update_7318() {
+  try {
+    tripal_insert_db(array(
+      'name' => 'sep',
+      'description' => 'Sample processing and separation techniques.',
+      'url' => 'http://psidev.info/index.php?q=node/312',
+      'urlprefix' => 'http://purl.obolibrary.org/obo/{db}_{accession}',
+    ));
+    tripal_insert_cv('sep','A structured controlled vocabulary for the annotation of sample processing and separation techniques in scientific experiments.');
+    $term = tripal_insert_cvterm(array(
+      'id' => 'sep:00195',
+      'name' => 'biological sample',
+      'cv_name' => 'sep',
+      'definition' => 'A biological sample analysed by a particular technology.',
+    ));
+  }
+  catch (\PDOException $e) {
+    $error = $e->getMessage();
+    throw new DrupalUpdateException('Could not perform update: '. $error);
+  }
 }