Pārlūkot izejas kodu

include alignment tracks bam and cram in commands

Jiu9Shen 5 gadi atpakaļ
vecāks
revīzija
2a460cd39c

+ 1 - 0
tripal_jbrowse_mgmt/includes/tripal_jbrowse_mgmt.api.inc

@@ -612,6 +612,7 @@ function tripal_jbrowse_mgmt_get_track_types() {
   return [
     'FeatureTrack',
     'CanvasFeatures',
+    'Alignment',
     'HTMLFeatures',
     'HTMLVariants',
     'XYPlot',

+ 28 - 0
tripal_jbrowse_mgmt/includes/tripal_jbrowse_mgmt_commands.inc

@@ -111,6 +111,34 @@ function tripal_jbrowse_mgmt_cmd_add_track($track) {
       tripal_jbrowse_mgmt_save_json($instance, $json);
       break;
 
+    case 'Alignment':
+      $json = tripal_jbrowse_mgmt_get_json($instance);
+      $directory = 'bam';
+      $file_name = $track->file;
+      if (is_dir($track->file)) {
+        $file_name = glob($track->file . '/' . '*.[bam][cram]')[0];
+      }
+      $file_name = pathinfo($file_name)['basename'];
+
+      $track_in_json = [
+        'label' => tripal_jbrowse_mgmt_make_slug($track->label),
+        'key' => $track->label,
+        'urlTemplate' => $directory . '/' . $file_name,
+        'type' => 'JBrowse/View/Track/Alignment2',
+      ];
+
+      $extension = pathinfo($file_name)['extension'];
+      switch($extension){
+        case 'bam':
+          $track_in_json['storeClass'] = 'JBrowse/Store/SeqFeature/BAM';
+          break;
+        case 'cram':
+          $track_in_json['storeClass'] = 'JBrowse/Store/SeqFeature/CRAM';
+          break;
+      }
+      tripal_jbrowse_mgmt_save_json($instance, $json);
+      break;
+
     case 'XYPlot':
       $json = tripal_jbrowse_mgmt_get_json($instance);
       $basename = pathinfo($track->file)['basename'];

+ 1 - 1
tripal_jbrowse_mgmt/includes/tripal_jbrowse_mgmt_tracks.form.inc

@@ -52,7 +52,7 @@ function tripal_jbrowse_mgmt_add_track_form($form, &$form_state, $instance_id) {
   $form['data']['file_type'] = [
     '#type' => 'select',
     '#title' => t('File Type'),
-    '#options' => drupal_map_assoc(['gff', 'bed', 'gbk', 'vcf', 'bw']),
+    '#options' => drupal_map_assoc(['gff', 'bed', 'gbk', 'bam', 'cram', 'vcf', 'bw']),
     '#description' => t('See http://gmod.org/wiki/JBrowse_Configuration_Guide#flatfile-to-json.pl for more info.'),
     '#required' => TRUE,
   ];