From 2cba79ccf103009af80ba7af981ee8ac6e294c1d Mon Sep 17 00:00:00 2001 From: Nick Booher Date: Thu, 16 Jan 2020 13:21:54 -0600 Subject: [PATCH] Add options to disable genes and transcripts tarcks --- tripal_jbrowse_api.admin.inc | 44 ++++++++++++++++++++++ tripal_jbrowse_api.module | 72 ++++++++++++++++++++++++------------ 2 files changed, 92 insertions(+), 24 deletions(-) create mode 100644 tripal_jbrowse_api.admin.inc diff --git a/tripal_jbrowse_api.admin.inc b/tripal_jbrowse_api.admin.inc new file mode 100644 index 0000000..71bfd97 --- /dev/null +++ b/tripal_jbrowse_api.admin.inc @@ -0,0 +1,44 @@ +fetchAll(PDO::FETCH_ASSOC); + + foreach ($results as $row) { + $prefix = 'tripal_jbrowse_api_' . $row['organism_id'] . '_'; + $form['organism_' . $row['organism_id']] = array( + '#type' => 'fieldset', + '#title' => sprintf('%s %s (%s)', $row['genus'], $row['species'], $row['common_name']) + ); + $form['organism_' . $row['organism_id']][$prefix . 'show_genes'] = array( + '#type' => 'checkbox', + '#title' => t('Expose genes as an available track for this organism'), + '#default_value' => variable_get($prefix . 'show_genes', TRUE), + ); + $form['organism_' . $row['organism_id']][$prefix . 'genes_is_default'] = array( + '#type' => 'checkbox', + '#title' => t('Load genes track by default when viewing this organism'), + '#default_value' => variable_get($prefix . 'genes_is_default', TRUE), + ); + $form['organism_' . $row['organism_id']][$prefix . 'show_transcripts'] = array( + '#type' => 'checkbox', + '#title' => t('Expose transcripts as an available track for this organism'), + '#default_value' => variable_get($prefix . 'show_transcripts', TRUE), + ); + $form['organism_' . $row['organism_id']][$prefix . 'transcripts_is_default'] = array( + '#type' => 'checkbox', + '#title' => t('Load transcripts track by default when viewing this organism'), + '#default_value' => variable_get($prefix . 'transcripts_is_default', TRUE), + ); + } + + return system_settings_form($form); + +} \ No newline at end of file diff --git a/tripal_jbrowse_api.module b/tripal_jbrowse_api.module index b15c840..2a1f46f 100644 --- a/tripal_jbrowse_api.module +++ b/tripal_jbrowse_api.module @@ -19,6 +19,15 @@ function tripal_jbrowse_api_permission() { */ function tripal_jbrowse_api_menu() { + $items['admin/tripal/extension/tripal_jbrowse_api'] = array( + 'title' => 'Tripal JBrowse API', + 'description' => 'Configure settings for the Tripal JBrowse API module.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('tripal_jbrowse_api_settings'), + 'access arguments' => array('administer tripal'), + 'file' => 'tripal_jbrowse_api.admin.inc', + ); + $base = array( 'type' => MENU_CALLBACK, 'access callback' => 'user_access', @@ -190,6 +199,8 @@ function tripal_jbrowse_api_callback_tracklist($organism) { $tracks = array(); + $default_tracks = array(); + $tracks[] = array( 'category' => 'Assembly - ' . $organism->common_name, 'useAsRefSeqStore' => TRUE, @@ -203,30 +214,43 @@ function tripal_jbrowse_api_callback_tracklist($organism) { ), ); - $tracks[] = array( - 'category' => 'Genes', - 'label' => 'genes', - 'key' => $organism->common_name . ' gene models', - 'type' => 'JBrowse/View/Track/CanvasFeatures', - 'trackType' => 'JBrowse/View/Track/CanvasFeatures', - 'storeClass' => 'JBrowse/Store/SeqFeature/REST', - 'style' => array( - '_defaultLabelScale' => 120, - ), - ); + $default_tracks[] = 'refseq'; + + if (variable_get('tripal_jbrowse_api_' . $organism->organism_id. '_show_genes', TRUE)) { + $tracks[] = array( + 'category' => 'Genes', + 'label' => 'genes', + 'key' => $organism->common_name . ' gene models', + 'type' => 'JBrowse/View/Track/CanvasFeatures', + 'trackType' => 'JBrowse/View/Track/CanvasFeatures', + 'storeClass' => 'JBrowse/Store/SeqFeature/REST', + 'style' => array( + '_defaultLabelScale' => 120, + ), + ); + if (variable_get('tripal_jbrowse_api_' . $organism->organism_id. '_genes_is_default', TRUE)) { + $default_tracks[] = 'genes'; + } - $tracks[] = array( - 'category' => 'Transcripts', - 'label' => 'transcripts', - 'transcriptType' => 'transcript', - 'key' => $organism->common_name . ' transcript models', - 'type' => 'JBrowse/View/Track/CanvasFeatures', - 'trackType' => 'JBrowse/View/Track/CanvasFeatures', - 'storeClass' => 'JBrowse/Store/SeqFeature/REST', - 'style' => array( - '_defaultLabelScale' => 120, - ), - ); + } + + if (variable_get('tripal_jbrowse_api_' . $organism->organism_id. '_show_transcripts', TRUE)) { + $tracks[] = array( + 'category' => 'Transcripts', + 'label' => 'transcripts', + 'transcriptType' => 'transcript', + 'key' => $organism->common_name . ' transcript models', + 'type' => 'JBrowse/View/Track/CanvasFeatures', + 'trackType' => 'JBrowse/View/Track/CanvasFeatures', + 'storeClass' => 'JBrowse/Store/SeqFeature/REST', + 'style' => array( + '_defaultLabelScale' => 120, + ), + ); + if (variable_get('tripal_jbrowse_api_' . $organism->organism_id. '_transcripts_is_default', TRUE)) { + $default_tracks[] = 'transcripts'; + } + } $other_tracks = module_invoke_all('jbrowse_tracks', $organism); @@ -234,7 +258,7 @@ function tripal_jbrowse_api_callback_tracklist($organism) { $data = array( 'dataset_id' => $organism->organism_id, - 'defaultTracks' => 'refseq,genes,transcripts', + 'defaultTracks' => implode(',', $default_tracks), 'names' => array( 'type' => 'REST', 'url' => $GLOBALS['base_url'] . '/api/jbrowse/' . $organism->organism_id . '/names',