Skip to content

Commit

Permalink
Add options to disable genes and transcripts tarcks
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Booher committed Jan 16, 2020
1 parent 1f41188 commit 2cba79c
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 24 deletions.
44 changes: 44 additions & 0 deletions tripal_jbrowse_api.admin.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

require_once 'includes/tripal_jbrowse_api.queries.inc';

/**
* @file
* Admin page callbacks for the tripal_jbrowse_api module.
*/

function tripal_jbrowse_api_settings() {

$results = chado_query(TRIPAL_JBROWSE_API_QUERY_ALL_ORGANISMS)->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);

}
72 changes: 48 additions & 24 deletions tripal_jbrowse_api.module
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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,
Expand All @@ -203,38 +214,51 @@ 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);

$datasets = tripal_jbrowse_api_callback_datasets();

$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',
Expand Down

0 comments on commit 2cba79c

Please sign in to comment.