Browse Source

Sequence Coordinate Table Formatter: added option to expand strand.

Lacey Sanderson 6 years ago
parent
commit
15224f763f

+ 24 - 1
tripal_chado/includes/TripalFields/data__sequence_coordinates_table/data__sequence_coordinates_table_formatter.inc

@@ -9,6 +9,7 @@ class data__sequence_coordinates_table_formatter extends ChadoFieldFormatter {
 
   public static $default_settings = array(
     'caption' => 'This @content_type is aligned to the following:',
+    'expand_strand' => TRUE,
   );
 
   /**
@@ -26,6 +27,14 @@ class data__sequence_coordinates_table_formatter extends ChadoFieldFormatter {
     }
 
     $element = array();
+
+    $element['expand_strand'] = array(
+      '#type' => 'textfield',
+      '#title' => 'Expand Strand',
+      '#description' => 'Expands the strand to full words versus "+" or "-".',
+      '#default_value' => $settings['expand_strand'],
+    );
+
     $element['caption'] = array(
       '#type' => 'textfield',
       '#title' => 'Caption',
@@ -90,10 +99,24 @@ class data__sequence_coordinates_table_formatter extends ChadoFieldFormatter {
     $rows = array();
     foreach ($items as $item) {
       if (!empty($item['value'])) {
+
+        $strand = $item['value'][$strand_term];
+        if ($settings['expand_strand']) {
+          if ($item['value'][$strand_term] == '+') {
+            $strand = 'positive';
+          }
+          elseif ($item['value'][$strand_term] == '-') {
+            $strand = 'negative';
+          }
+          else {
+            $strand = '<span style="color:#B3B3B3">unknown</span>';
+          }
+        }
+
         $rows[] = array(
           $item['value'][$reference_term],
           $item['value'][$fmin_term] . '..' . $fmax = $item['value'][$fmax_term],
-          $item['value'][$strand_term]
+          $strand
         );
       }
     }