diff --git a/lib/galaxy/visualization/tracks/data_providers.py b/lib/galaxy/visualization/tracks/data_providers.py index 30792835d2d..a909699ab69 100644 --- a/lib/galaxy/visualization/tracks/data_providers.py +++ b/lib/galaxy/visualization/tracks/data_providers.py @@ -363,14 +363,18 @@ class RawBedDataProvider( BedDataProvider ): for large datasets. """ - def get_iterator( self, chrom, start, end ): + def get_iterator( self, chrom=None, start=None, end=None ): def line_filter_iter(): for line in open( self.original_dataset.file_name ): + if line.startswith( "track" ) or line.startswith( "browser" ): + continue feature = line.split() feature_chrom = feature[0] feature_start = int( feature[1] ) feature_end = int( feature[2] ) - if feature_chrom != chrom or feature_start > int( end ) or feature_end < int( start ): + if ( chrom is not None and feature_chrom != chrom ) \ + or ( start is not None and feature_start > int( end ) ) \ + or ( end is not None and feature_end < int( start ) ): continue yield line return line_filter_iter() diff --git a/lib/galaxy/web/controllers/tracks.py b/lib/galaxy/web/controllers/tracks.py index 3ae6cea5063..8dd0d3fa22f 100644 --- a/lib/galaxy/web/controllers/tracks.py +++ b/lib/galaxy/web/controllers/tracks.py @@ -13,7 +13,7 @@ from galaxy.web.controllers.library import LibraryListGrid from galaxy.web.framework import simplejson from galaxy.web.framework.helpers import time_ago, grids from galaxy.util.bunch import Bunch -from galaxy.datatypes.interval import Gff +from galaxy.datatypes.interval import Gff, Bed from galaxy.model import NoConverterException, ConverterDependencyException from galaxy.visualization.tracks.data_providers import * from galaxy.visualization.tracks.visual_analytics import get_tool_def, get_dataset_job @@ -246,6 +246,27 @@ class TracksController( BaseUIController, UsesVisualization, UsesHistoryDatasetA "tool": get_tool_def( trans, dataset ) } return track + + @web.json + def bookmarks_from_dataset( self, trans, hda_id=None, ldda_id=None ): + if hda_id: + hda_ldda = "hda" + dataset = self.get_dataset( trans, hda_id, check_ownership=False, check_accessible=True ) + elif ldda_id: + hda_ldda = "ldda" + dataset = trans.sa_session.query( trans.app.model.LibraryDatasetDatasetAssociation ).get( trans.security.decode_id( ldda_id ) ) + rows = [] + if isinstance( dataset.datatype, Bed ): + data = RawBedDataProvider( original_dataset=dataset ).get_iterator() + for i, line in enumerate( data ): + if ( i > 500 ): break + fields = line.split() + location = name = "%s:%s-%s" % ( fields[0], fields[1], fields[2] ) + if len( fields ) > 3: + name = fields[4] + rows.append( [location, name] ) + return { 'data': rows } + @web.expose @web.require_login() diff --git a/static/june_2007_style/base.css.tmpl b/static/june_2007_style/base.css.tmpl index d53be3086af..2e2f1e4c4d9 100644 --- a/static/june_2007_style/base.css.tmpl +++ b/static/june_2007_style/base.css.tmpl @@ -909,6 +909,14 @@ div.permissionContainer { -sprite-group: fugue; -sprite-image: fugue/plus-circle.png; } +.icon-button.plus-button { + -sprite-group: fugue; + -sprite-image: fugue/plus-button.png; +} +.icon-button.gear { + -sprite-group: fugue; + -sprite-image: fugue/gear.png; +} .tipsy { padding: 5px; diff --git a/static/june_2007_style/blue/base.css b/static/june_2007_style/blue/base.css index 70bc7fede74..432582606d5 100644 --- a/static/june_2007_style/blue/base.css +++ b/static/june_2007_style/blue/base.css @@ -163,6 +163,8 @@ div.permissionContainer{padding-left:20px;} .icon-button.vis-chart{background:url(fugue.png) no-repeat 0px -286px;} .icon-button.go-to-full-screen{background:url(fugue.png) no-repeat 0px -312px;} .icon-button.import{background:url(fugue.png) no-repeat 0px -338px;} +.icon-button.plus-button{background:url(fugue.png) no-repeat 0px -364px;} +.icon-button.gear{background:url(fugue.png) no-repeat 0px -390px;} .tipsy{padding:5px;font-size:10px;filter:alpha(opacity=80);background-repeat:no-repeat;background-image:url(../images/tipsy.gif);} .tipsy-inner{padding:5px 8px 4px 8px;background-color:black;color:white;max-width:200px;text-align:center;} .tipsy-north{background-position:top center;} @@ -171,7 +173,7 @@ div.permissionContainer{padding-left:20px;} .tipsy-west{background-position:left center;} .editable-text{cursor:pointer;} .editable-text:hover{cursor:text;border:dotted #999999 1px;} -.text-and-autocomplete-select{background:url(fugue.png) no-repeat right -364px;} +.text-and-autocomplete-select{background:url(fugue.png) no-repeat right -416px;} .icon-button.multiinput{background:url(../images/documents-stack.png) no-repeat;cursor:pointer;float:none;display:inline-block;margin-left:10px;} .icon-button.multiinput.disabled{background:url(../images/documents-stack-faded.png) no-repeat;cursor:auto;} .workflow-invocation-complete{border:solid 1px #6A6;border-left-width:5px;margin:10px 0;padding-left:5px;} diff --git a/static/june_2007_style/blue/fugue.png b/static/june_2007_style/blue/fugue.png index d6212bec398..393ca9daedb 100644 Binary files a/static/june_2007_style/blue/fugue.png and b/static/june_2007_style/blue/fugue.png differ diff --git a/static/scripts/trackster.js b/static/scripts/trackster.js index b0874d450b9..40bae40def9 100644 --- a/static/scripts/trackster.js +++ b/static/scripts/trackster.js @@ -3313,7 +3313,6 @@ var FeatureTrack = function(name, view, container, hda_ldda, dataset_id, prefs, }; extend(FeatureTrack.prototype, Drawable.prototype, TiledTrack.prototype, { set_painter_from_config: function() { - console.log( this, this.config ); if ( this.config.values['connector_style'] == 'arcs' ) { this.painter = painters.ArcLinkedFeaturePainter; } else { diff --git a/templates/tracks/browser.mako b/templates/tracks/browser.mako index 8b9b7069714..113bc5e1129 100644 --- a/templates/tracks/browser.mako +++ b/templates/tracks/browser.mako @@ -110,6 +110,52 @@ ${h.js( "galaxy.base", "galaxy.panels", "json2", "jquery", "jstorage", "jquery.e } }); }; + + /** + * Use a popup grid to bookmarks from a dataset. + */ + var add_bookmarks = function() { + show_modal( "Select dataset for new bookmarks", "progress" ); + $.ajax({ + url: "${h.url_for( action='list_histories' )}", + data: { "f-dbkey": view.dbkey }, + error: function() { alert( "Grid failed" ); }, + success: function(table_html) { + show_modal( + "Select dataset for new bookmarks", + table_html, { + "Cancel": function() { + hide_modal(); + }, + "Insert": function() { + // Just use the first selected + $('input[name=id]:checked,input[name=ldda_ids]:checked').first().each(function(){ + var data, id = $(this).val(); + if ($(this).attr("name") === "id") { + data = { hda_id: id }; + } else { + data = { ldda_id: id}; + } + + $.ajax({ + url: "${h.url_for( action='bookmarks_from_dataset' )}", + data: data, + dataType: "json", + }).then( function(data) { + for( i = 0; i < data.data.length; i++ ) { + var row = data.data[i]; + console.log( row[0], row[1] ); + add_bookmark( row[0], row[1] ); + } + }); + }); + hide_modal(); + } + } + ); + } + }); + }; $(function() { // Manual tipsy config because default gravity is S and cannot be changed. @@ -240,7 +286,13 @@ ${h.js( "galaxy.base", "galaxy.panels", "json2", "jquery", "jstorage", "jquery.e annotation = "Bookmark description"; return add_bookmark(position, annotation); }); - + + // make_popupmenu( $("#bookmarks-more-button"), { + // "Add from BED dataset": function() { + // add_bookmarks(); + // } + // }); + init_keyboard_nav(view); }; @@ -271,14 +323,15 @@ ${h.js( "galaxy.base", "galaxy.panels", "json2", "jquery", "jstorage", "jquery.e