Implementation

The so__transcript field is only ever attached to a gene. The entity that is passed into the field is the gene entity (feature_id belongs to the gene).

Dynamic Gene Pages

  1. Work on branch named 100-tv3-gene_pages
  2. Let's use the orange data that comes with the Tripal Tutorial
  3. so__transcript.inc file: (Stephen)
    • Add the following in the $default_instance_settings
      • $transcript_fields = []
    • Implement the instanceSettingsForm function
      • This function allows the site admin to specify which fields should be automaticaly attached to each transcript when it is viewed.
      • Get list of fields that can be attached to an 'mRNA' content type
      • List them all as a checkboxes.
  4. Add an update function to the tripal_chado.install file that will force Drupal to see the new $transcript_fields setting for the so__transcript field. (Stephen)
  5. so__transcript_formatter.inc file. (Katheryn)
    • view() function:
      • Iterate through each transcript (mRNA):
        • Iterate through each field in the $this->instance['settings']['transcript_fields']' variable.
          • use the field_info_field function to get field ID. Save all field IDs in an array
        • Load an entity object for the mRNA using the tripal_load_entity() function. pass in the list of field IDs to include with the entity.
        • Iterate through the each field again and render it using the following code
          โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹    $instance = field_info_instance('TripalEntity', $field_name, $entity->bundle);
          โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹    $items = field_get_items('TripalEntity', $entity, $field_name);
          โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹    $element = field_view_field('TripalEntity', $entity, $field_name, $instance['display']['default']);
          โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹    $element['#label_display'] = 'hidden';
          โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹    $content = drupal_render($element);
          
      • These are field names that can be used for testing. To get the list of fields use this code:
        โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹    $bundle = tripal_load_bundle_entity(['accession' => 'SO:0000234']);
        โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹    $fields = field_info_instances('TripalEntity', $bundle->name);
        
  6. Display considerations
    • Check the cardinatlity of a field.
      • If it has a cardinality of 1 it should go into a table that will appear at the top of the fieldset
      • If it has a cardinality > 1 then we let the field display as it wants to but we need to add some sort of header with a title and description.
    • If the content type is setup to hide fields with no values then we need to honor that for fields with no values. <ksbuble note: if the field is required, then it is still shown with no value>
    • for full details under each transcript add link to mRNA page.
  7. If time permits
    • test this with the JBrowse module

Code Helps

Fieldsets

Here's some code to create a working fieldset outside of a Form. By default fieldsets don't open and close if they are not in a form.

$fset[$transcript_id] = [
  '#type' => 'fieldset',
  '#title' => 'Transcript Name',
  '#description' => '',
  '#collapsible' => TRUE,
  '#collapsed' => TRUE,
  '#attributes' => ['class' => ['collapsible', 'collapsed']],
];
$fset[$transcript_id][$field_name] = [
  '#type' => markup,
  '#markup' => drupal_render($field_element),
];
drupal_add_library('system', 'drupal.collapse');

Sequence Field (Stephen)

  1. Add an option to get FASTA formatted sequences.
  2. The sequence record field seems to not be working on the demo site
  3. The accessionedtime field is always the current time.
  4. Code issue with the GFFloader and PHP 7.0