mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Trackster: code for adding multiple bookmarks from a dataset. Currently the button is commented out until this can be made more usable
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 7.4 KiB |
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
<div class="unified-panel-header" unselectable="on">
|
||||
<div class="unified-panel-header-inner">
|
||||
<div style="float: right">
|
||||
<a id="add-bookmark-button" class='icon-button menu-button plus-button' href="javascript:void(0);" title="Add bookmark"></a>
|
||||
## <a id="bookmarks-more-button" class='icon-button menu-button gear popup' href="javascript:void(0);" title="More actions"></a>
|
||||
</div>
|
||||
Bookmarks
|
||||
</div>
|
||||
</div>
|
||||
<div class="unified-panel-body" style="overflow: auto;">
|
||||
<div id="bookmarks-container"></div>
|
||||
<div>
|
||||
<a class="icon-button import" style="margin-left: .5em; width: 100%" original-title="Add Bookmark" id="add-bookmark-button" href="javascript:void(0);">Add Bookmark</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</%def>
|
||||
|
||||
Reference in New Issue
Block a user