Browse Source

Merge pull request #453 from tripal/415-tv3-cds_sequence_order

Fixed so__cds, so__transcript, added a local__gbrowse_image field.
Stephen Ficklin 6 years ago
parent
commit
37a2184079

+ 2 - 1
tripal/api/tripal.entities.api.inc

@@ -636,6 +636,7 @@ function tripal_get_content_type($bundle_name) {
  * @ingroup tripal_entities_api
  */
 function tripal_create_bundle_fields($bundle, $term) {
+
   $added = array();
 
   // Allow modules to add fields to the new bundle.
@@ -663,7 +664,7 @@ function tripal_create_bundle_fields($bundle, $term) {
     $field = field_info_field($details['field_name']);
     if ($field) {
       continue;
-    }    
+    }
 
     // Create the field.
     $field = field_create_field($details);

+ 1 - 1
tripal/includes/TripalBundleUIController.inc

@@ -338,7 +338,7 @@ function tripal_tripal_bundle_form($form, &$form_state, $entityDataType) {
   );
 
 
-  $tokens = tripal_get_entity_tokens($bundle, array('required only' => TRUE));
+  $tokens = tripal_get_entity_tokens($bundle);
   $form['url']['tokens'] = array(
     '#type' => 'hidden',
     '#value' => serialize($tokens)

+ 9 - 12
tripal_chado/includes/TripalFields/so__transcript/so__transcript.inc

@@ -133,15 +133,12 @@ class so__transcript extends ChadoField {
 
     // Set some defaults for the empty record.
     $entity->{$field_name}['und'][0] = array(
-      'value' => array(
-        'rdfs:type' => '',
-        'schema:name' => '',
-        // Identifier
-        'data:0842' => '',
-        // sequence location
-        'SO:0000735' => '',
-      ),
+      'value' => ''
     );
+    
+    if (!$record) {
+      return;
+    }
 
     // Get the mRNA features for this gene.
     $sql = "
@@ -176,10 +173,10 @@ class so__transcript extends ChadoField {
         'data:0842' => $transcript->uniquename,
         'SO:0000735' => $loc,
       );
-      $entity_id = chado_get_record_entity_by_bundle($entity->bundle, $record_id);
-      if ($entity_id) {
-         $entity->{$field_name}['und'][$i]['value']['entity'] = 'TripalEntity:' . $entity_id;
-       }
+      $feature = chado_generate_var('feature', ['feature_id' => $transcript->feature_id]);
+      if (property_exists($feature, 'entity_id')) {
+         $entity->{$field_name}['und'][$i]['value']['entity'] = 'TripalEntity:' . $feature->entity_id;
+      }
       $i++;
     }
   }

+ 96 - 96
tripal_chado/includes/tripal_chado.fields.inc

@@ -386,7 +386,7 @@ function tripal_chado_bundle_fields_info_custom(&$info, $details, $entity_type,
 
   // PROTEIN & CDS
   if ($table_name == 'feature' and
-      ($bundle->label == 'mRNA' or $bundle->label == 'transcript'))  {
+    ($bundle->term->name == 'mRNA' or $bundle->term->name == 'transcript'))  {
     $field_name = 'data__protein_sequence';
     $field_type = 'data__protein_sequence';
     $info[$field_name] = array(
@@ -399,34 +399,34 @@ function tripal_chado_bundle_fields_info_custom(&$info, $details, $entity_type,
       ),
     );
 
-//     $field_name = 'so__cds';
-//     $field_type = 'so__cds';
-//     $info[$field_name] = array(
-//       'field_name' => $field_name,
-//       'type' => $field_type,
-//       'cardinality' => 1,
-//       'locked' => FALSE,
-//       'storage' => array(
-//         'type' => 'field_chado_storage',
-//       ),
-//     );
+    $field_name = 'so__cds';
+    $field_type = 'so__cds';
+    $info[$field_name] = array(
+      'field_name' => $field_name,
+      'type' => $field_type,
+      'cardinality' => 1,
+      'locked' => FALSE,
+      'storage' => array(
+        'type' => 'field_chado_storage',
+      ),
+    );
   }
 
-//   // GENE TRANSCRIPTS
-//   $rel_table = $table_name . '_relationship';
-//   if (chado_table_exists($rel_table) and $bundle->label == 'gene') {
-//     $field_name = 'so__transcript';
-//     $field_type = 'so__transcript';
-//     $info[$field_name] = array(
-//       'field_name' => $field_name,
-//       'type' => $field_type,
-//       'cardinality' => FIELD_CARDINALITY_UNLIMITED,
-//       'locked' => FALSE,
-//       'storage' => array(
-//         'type' => 'field_chado_storage',
-//       ),
-//     );
-//   }
+  // GENE TRANSCRIPTS
+  $rel_table = $table_name . '_relationship';
+  if (chado_table_exists($rel_table) and ($bundle->term->name == 'gene')) {
+    $field_name = 'so__transcript';
+    $field_type = 'so__transcript';
+    $info[$field_name] = array(
+      'field_name' => $field_name,
+      'type' => $field_type,
+      'cardinality' => FIELD_CARDINALITY_UNLIMITED,
+      'locked' => FALSE,
+      'storage' => array(
+        'type' => 'field_chado_storage',
+      ),
+    );
+  }
 
   // ORGANISM TYPE_ID
   if ($table_name == 'organism' and array_key_exists('type_id', $schema['fields'])) {
@@ -1739,7 +1739,7 @@ function tripal_chado_bundle_instances_info_custom(&$info, $entity_type, $bundle
 
   // PROTEIN & CDS SEQUENCES.
   if ($table_name == 'feature' and
-      ($bundle->label == 'mRNA' or $bundle->label == 'transcript'))  {
+    ($bundle->term->name == 'mRNA' or $bundle->term->name == 'transcript'))  {
     $field_name = 'data__protein_sequence';
     $info[$field_name] = array(
       'field_name' => $field_name,
@@ -1772,76 +1772,75 @@ function tripal_chado_bundle_instances_info_custom(&$info, $entity_type, $bundle
       ),
     );
 
-//     $field_name = 'so__cds';
-//     $info[$field_name] = array(
-//       'field_name' => $field_name,
-//       'entity_type' => $entity_type,
-//       'bundle' => $bundle->name,
-//       'label' => 'Coding Sequence',
-//       'description' => 'Coding sequences.',
-//       'required' => FALSE,
-//       'settings' => array(
-//         'auto_attach' => FALSE,
-//         'chado_table' => 'featureloc',
-//         'chado_column' => '',
-//         'base_table' => 'featureloc',
-//         'term_accession' => '',
-//         'term_vocabulary' => '',
-//         'term_name' => '',
-//       ),
-//       'widget' => array(
-//         'type' => 'so__cds_widget',
-//         'settings' => array(
-//           'display_label' => 1,
-//         ),
-//       ),
-//       'display' => array(
-//         'default' => array(
-//           'label' => 'above',
-//           'type' => 'so__cds_formatter',
-//           'settings' => array(),
-//         ),
-//       ),
-//     );
+    $field_name = 'so__cds';
+    $info[$field_name] = array(
+     'field_name' => $field_name,
+     'entity_type' => $entity_type,
+     'bundle' => $bundle->name,
+     'label' => 'Coding Sequence (CDS)',
+     'description' => 'Coding sequences.',
+     'required' => FALSE,
+     'settings' => array(
+       'auto_attach' => FALSE,
+       'chado_table' => 'featureprop',
+       'chado_column' => 'value',
+       'base_table' => 'feature',
+       'term_vocabulary' => 'SO',
+       'term_name' => 'CDS',
+       'term_accession' => '0000316',
+     ),
+     'widget' => array(
+       'type' => 'so__cds_widget',
+       'settings' => array(
+         'display_label' => 1,
+       ),
+     ),
+     'display' => array(
+       'default' => array(
+         'label' => 'above',
+         'type' => 'so__cds_formatter',
+         'settings' => array(),
+       ),
+     ),
+    );
+  }
+
+  // GENE TRANSCRIPTS
+  $rel_table = $table_name . '_relationship';
+  if (chado_table_exists($rel_table) and ($bundle->term->name == 'gene')) {
+    $field_name = 'so__transcript';
+    $info[$field_name] = array(
+      'field_name' => $field_name,
+      'entity_type' => $entity_type,
+      'bundle' => $bundle->name,
+      'label' => 'Transcripts',
+      'description' => 'Transcripts that are part of this gene.',
+      'required' => FALSE,
+      'settings' => array(
+        'auto_attach' => FALSE,
+        'chado_table' => $rel_table,
+        'chado_column' => '',
+        'base_table' => $table_name,
+        'term_vocabulary' => 'SO',
+        'term_name' => 'transcript',
+        'term_accession' => '0000673',
+      ),
+      'widget' => array(
+        'type' => 'so__transcript_widget',
+        'settings' => array(
+          'display_label' => 1,
+        ),
+      ),
+      'display' => array(
+        'default' => array(
+          'label' => 'above',
+          'type' => 'so__transcript_formatter',
+          'settings' => array(),
+        ),
+      ),
+    );
   }
 
-
-//   // GENE TRANSCRIPTS
-//   $rel_table = $table_name . '_relationship';
-//   if (chado_table_exists($rel_table) and $bundle->label == 'gene') {
-//     $field_name = 'so__transcript';
-//     $info[$field_name] = array(
-//       'field_name' => $field_name,
-//       'entity_type' => $entity_type,
-//       'bundle' => $bundle->name,
-//       'label' => 'Transcripts',
-//       'description' => 'Transcripts that are part of this gene.',
-//       'required' => FALSE,
-//       'settings' => array(
-//         'auto_attach' => FALSE,
-//         'chado_table' => $rel_table,
-//         'chado_column' => '',
-//         'base_table' => $table_name,
-//         'term_accession' => '',
-//         'term_vocabulary' => '',
-//         'term_name' => '',
-//       ),
-//       'widget' => array(
-//         'type' => 'so__transcript_widget',
-//         'settings' => array(
-//           'display_label' => 1,
-//         ),
-//       ),
-//       'display' => array(
-//         'default' => array(
-//           'label' => 'above',
-//           'type' => 'so__transcript_formatter',
-//           'settings' => array(),
-//         ),
-//       ),
-//     );
-//   }
-
   // ORGANISM TYPE_ID
   if ($table_name == 'organism' and array_key_exists('type_id', $schema['fields'])) {
     $field_name = 'taxrank__infraspecific_taxon';
@@ -2114,6 +2113,7 @@ function tripal_chado_bundle_instances_info_custom(&$info, $entity_type, $bundle
         'term_vocabulary' => 'NCIT',
         'term_name' => 'Operator',
         'term_accession' => 'C48036',
+        
       ),
       'widget' => array(
         'type' => 'local__contact_widget',

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

@@ -642,6 +642,12 @@ function tripal_chado_populate_vocab_EDAM() {
     'cv_name' => 'EDAM',
     'definition' => 'A phylogenetic tree that is an estimate of the character\'s phylogeny.',
   ));
+  $term = chado_insert_cvterm(array(
+    'id' => 'operation:0564',
+    'name' => 'Sequence visualisation',
+    'cv_name' => 'EDAM',
+    'definition' => 'Visualise, format or render a molecular sequence or sequences such as a sequence alignment, possibly with sequence features or properties shown.',
+  ));
 
 }
 /**

+ 1 - 1
tripal_chado/theme/css/tripal_chado.css

@@ -36,7 +36,7 @@
 
 .residues-formatter {
   color: black;
-  height: 300px;
+  height: 100px;
   max-width: 500px;
   overflow: scroll;
   white-space: normal;

+ 17 - 0
tripal_chado/tripal_chado.install

@@ -1550,5 +1550,22 @@ function tripal_chado_update_7326() {
   }
 }
 
+/**
+ * Adding terms for sequence visualization.
+ */
+function tripal_chado_update_7327() {
+  try {
+    $term = chado_insert_cvterm(array(
+      'id' => 'operation:0564',
+      'name' => 'Sequence visualisation',
+      'cv_name' => 'EDAM',
+      'definition' => 'Visualise, format or render a molecular sequence or sequences such as a sequence alignment, possibly with sequence features or properties shown.',
+    ));
+  }
+  catch (\PDOException $e) {
+    $error = $e->getMessage();
+    throw new DrupalUpdateException('Could not perform update: '. $error);
+  }
+}