diff --git a/lib/galaxy/datatypes/coverage.py b/lib/galaxy/datatypes/coverage.py index 4bd76425a71..60a3d12a1d4 100644 --- a/lib/galaxy/datatypes/coverage.py +++ b/lib/galaxy/datatypes/coverage.py @@ -27,4 +27,4 @@ class LastzCoverage( Tabular ): MetadataElement( name="forwardCol", default=3, desc="Forward or aggregate read column", param=metadata.ColumnParameter ) MetadataElement( name="reverseCol", desc="Optional reverse read column", param=metadata.ColumnParameter, optional=True, no_value=0 ) MetadataElement( name="columns", default=3, desc="Number of columns", readonly=True, visible=False ) - \ No newline at end of file + diff --git a/lib/galaxy/security/__init__.py b/lib/galaxy/security/__init__.py index d747416d537..f1ff64a7b2d 100644 --- a/lib/galaxy/security/__init__.py +++ b/lib/galaxy/security/__init__.py @@ -17,8 +17,6 @@ class Action( object ): class RBACAgent: """Class that handles galaxy security""" permitted_actions = Bunch( - #DATASET_EDIT_METADATA = Action( - # "edit metadata", "Role members can edit this dataset's metadata in the library", "grant" ), DATASET_MANAGE_PERMISSIONS = Action( "manage permissions", "Role members can manage the roles associated with this dataset", "grant" ), DATASET_ACCESS = Action( @@ -482,7 +480,9 @@ class LibraryRBACAgent( RBACAgent ): alira.flush() def show_library_item( self, user, library_item ): - if self.allow_action( user, self.permitted_actions.LIBRARY_MODIFY, library_item ) or self.allow_action( user, self.permitted_actions.LIBRARY_MANAGE, library_item ) or self.allow_action( trans.user, self.permitted_actions.LIBRARY_ADD, library_item ): + if self.allow_action( user, self.permitted_actions.LIBRARY_MODIFY, library_item ) or \ + self.allow_action( user, self.permitted_actions.LIBRARY_MANAGE, library_item ) or \ + self.allow_action( user, self.permitted_actions.LIBRARY_ADD, library_item ): return True if isinstance( library_item, self.model.Library ): return self.show_library_item( user, library_item.root_folder ) diff --git a/lib/galaxy/web/controllers/admin.py b/lib/galaxy/web/controllers/admin.py index 754e2086f23..755f2024181 100644 --- a/lib/galaxy/web/controllers/admin.py +++ b/lib/galaxy/web/controllers/admin.py @@ -873,7 +873,7 @@ class Admin( BaseController ): library.flush() msg = "Library '%s' and all of its contents have been marked deleted" % library.name return trans.response.send_redirect( web.url_for( action='library_browser', msg=util.sanitize_text( msg ), messagetype='done' ) ) - elif action =='update_roles': + elif action == 'update_roles': # The user clicked the Save button on the 'Associate With Roles' form permissions = {} for k, v in trans.app.model.library_security_agent.permitted_actions.items(): @@ -989,7 +989,7 @@ class Admin( BaseController ): folder.name = new_name folder.description = new_description folder.flush() - msg = "Folder '%s'has been renamed to '%s'" % ( old_name, new_name ) + msg = "Folder '%s' has been renamed to '%s'" % ( old_name, new_name ) return trans.response.send_redirect( web.url_for( action='library_browser', msg=util.sanitize_text( msg ), messagetype='done' ) ) return trans.fill_template( '/admin/library/rename_folder.mako', folder=folder, msg=msg, messagetype=messagetype ) elif action == 'delete': diff --git a/lib/galaxy/web/controllers/genetrack.py b/lib/galaxy/web/controllers/genetrack.py index f4b13e2b09c..019239d0da3 100644 --- a/lib/galaxy/web/controllers/genetrack.py +++ b/lib/galaxy/web/controllers/genetrack.py @@ -1,5 +1,6 @@ import time, glob, os from itertools import cycle +import hashlib from mako import exceptions from mako.template import Template @@ -27,7 +28,6 @@ import paste.httpexceptions # Database helpers SHOW_LABEL_LIMIT = 10000 -color = cycle( [LIGHT, WHITE] ) def list_labels(session): """ @@ -102,10 +102,9 @@ def build_tracks( param, conf, data_label, fit_label, pred_label, strand, show=F return charts -def feature_chart(param=None, session=None, label=None, label_dict={}): +def feature_chart(param=None, session=None, label=None, label_dict={}, color=cycle( [LIGHT, WHITE] ) ): # draw the ORF tracks all = feature_filter(feature_query(session=session, param=param), name=label, kdict=label_dict) - if len(all) == 0: return [] opts = track_options( xscale=param.xscale, w=param.width, fgColor=PURPLE, show_labels=param.show_labels, ylabel=str(label), @@ -164,13 +163,8 @@ class WebRoot(BaseController): FIT_LABEL = "%s-SIGMA-%d" % (data.metadata.label, 20), PRED_LABEL = "PRED-%s-SIGMA-%d" % (data.metadata.label, 20), ) - from atlas import hdf - db = hdf.hdf_open( conf.HDF_DATABASE, mode='r' ) - conf.CHROM_FIELDS = [(x,x) for x in hdf.GroupData(db=db, name=conf.LABEL).labels] - db.close() param = atlas.Param( word=word ) - # search with features based on param.feature # search for a given session = sql.get_session( conf.SQL_URI ) @@ -252,32 +246,38 @@ class WebRoot(BaseController): # go and search for these return trans.response.send_redirect( web.url_for( controller='genetrack', action='search', word=param.feature, dataset_id=dataset_id ) ) - # keep image at a sane size param.width = min( [2000, int(param.img_size)] ) + param.xscale = [ param.start, param.end ] + param.show_labels = ( param.end - param.start ) <= SHOW_LABEL_LIMIT # get the template and the function used to generate the tracks tmpl_name, track_maker = conf.PLOT_MAPPER[param.plot] - charts = [] + # check against a hash, display an image that already exists if it was previously created. + hash = hashlib.sha1() + hash.update(str(dataset_id)) + for key in sorted(kwds.keys()): + hash.update(str(kwds[key])) + fname = "%s.png" % hash.hexdigest() + fpath = os.path.join(conf.IMAGE_DIR, fname) - fname, fpath = atlas_utils.make_tempfile( dir=conf.IMAGE_DIR, suffix='.png') + charts = [] param.fname = fname - # set the scale of the plot - param.xscale = [ param.start, param.end ] - - # when visualizing on wide scales labels are not useful - param.show_labels = ( param.end - param.start ) <= SHOW_LABEL_LIMIT - + # The SHA1 hash should uniquely identify the qs that created the plot... + if os.path.exists(fpath): + os.utime(fpath, (time.time(), time.time())) + return trans.fill_template_mako(tmpl_name, conf=conf, form=form, param=param, dataset_id=dataset_id) + + # If the hashed filename doesn't exist, create it. if track_maker is not None and os.path.exists( conf.HDF_DATABASE ): # generate the fit track charts = track_maker( param=param, conf=conf ) for label in list_labels( session ): - charts.extend( feature_chart(param=param, session=session, label=label.name, label_dict={label.name:label.id}) ) + charts.extend( feature_chart(param=param, session=session, label=label.name, label_dict={label.name:label.id}, color=color)) + track_chart = consolidate_charts( charts, param ) track_chart.save(fname=fpath) - + return trans.fill_template_mako(tmpl_name, conf=conf, form=form, param=param, dataset_id=dataset_id) - - diff --git a/lib/galaxy/web/controllers/library.py b/lib/galaxy/web/controllers/library.py index 22e1b9a3ed4..30cb797bc71 100644 --- a/lib/galaxy/web/controllers/library.py +++ b/lib/galaxy/web/controllers/library.py @@ -15,7 +15,11 @@ class Library( BaseController ): def browse( self, trans, msg=None, messagetype=None, **kwd ): libraries = trans.app.model.Library.filter( trans.app.model.Library.table.c.deleted==False ) \ .order_by( trans.app.model.Library.table.c.name ).all() - return trans.fill_template( '/library/browser.mako', libraries=libraries, default_action=kwd.get( 'default_action', None ), msg=msg, messagetype=messagetype ) + return trans.fill_template( '/library/browser.mako', + libraries=libraries, + default_action=kwd.get( 'default_action', None ), + msg=msg, + messagetype=messagetype ) index = browse @web.expose def import_datasets( self, trans, import_ids=[], **kwd ): @@ -33,7 +37,7 @@ class Library( BaseController ): history.add_dataset( dataset ) dataset.flush() history.flush() - return trans.show_ok_message( "%i dataset(s) have been imported in to your history" % len( import_ids ), refresh_frames=['history'] ) + return trans.show_ok_message( "%i dataset(s) have been imported into your history" % len( import_ids ), refresh_frames=['history'] ) else: # Can't use mkstemp - the file must not exist first try: diff --git a/setup.sh b/setup.sh index 1c6d6944be5..b0f504ccac9 100644 --- a/setup.sh +++ b/setup.sh @@ -27,6 +27,7 @@ database/compiled_templates database/job_working_directory database/import database/pbs +static/genetrack/plots " for sample in $SAMPLES; do diff --git a/templates/admin/library/add_dataset_from_history.mako b/templates/admin/library/add_dataset_from_history.mako index 6d3799c5a2d..2184648d21e 100644 --- a/templates/admin/library/add_dataset_from_history.mako +++ b/templates/admin/library/add_dataset_from_history.mako @@ -10,14 +10,14 @@