galaxy-commits
Threads by month
- ----- 2026 -----
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- 15302 discussions
commit/galaxy-central: natefoo: Condor runner: Allow for per-destination ClassAd query params, don't delete the submit file if submission fails and cleanup_job != always.
by commits-noreply@bitbucket.org 13 Jun '13
by commits-noreply@bitbucket.org 13 Jun '13
13 Jun '13
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/827ff13a7291/
Changeset: 827ff13a7291
User: natefoo
Date: 2013-06-13 23:09:20
Summary: Condor runner: Allow for per-destination ClassAd query params, don't delete the submit file if submission fails and cleanup_job != always.
Affected #: 2 files
diff -r 6f9e73ec3e99d43f14e3d735ecfe7b66ea38472a -r 827ff13a72914ed3ddacace717cc07af66af718e job_conf.xml.sample_advanced
--- a/job_conf.xml.sample_advanced
+++ b/job_conf.xml.sample_advanced
@@ -54,7 +54,15 @@
<param id="shell_hostname">foo.example.org</param><param id="Job_Execution_Time">24:00:00</param></destination>
- <destination id="condor" runner="condor"/>
+ <destination id="condor" runner="condor">
+ <!-- With no params, jobs are submitted to the 'vanilla' universe with:
+ notification = NEVER
+ getenv = true
+ Additional/override query ClassAd params can be specified with
+ <param> tags.
+ -->
+ <param id="request_cpus">8</param>
+ </destination></destinations><tools><!-- Tools can be configured to use specific destinations or handlers,
diff -r 6f9e73ec3e99d43f14e3d735ecfe7b66ea38472a -r 827ff13a72914ed3ddacace717cc07af66af718e lib/galaxy/jobs/runners/condor.py
--- a/lib/galaxy/jobs/runners/condor.py
+++ b/lib/galaxy/jobs/runners/condor.py
@@ -32,6 +32,12 @@
%s
"""
+default_query_classad = dict(
+ universe = 'vanilla',
+ getenv = 'true',
+ notification = 'NEVER',
+)
+
class CondorJobState( AsynchronousJobState ):
def __init__( self, **kwargs ):
"""
@@ -71,6 +77,10 @@
# wrapper.get_id_tag() instead of job_id for compatibility with TaskWrappers.
galaxy_id_tag = job_wrapper.get_id_tag()
+ # get destination params
+ query_params = default_query_classad.copy()
+ query_params.update( job_destination.params )
+
# define job attributes
cjs = CondorJobState( files_dir=self.app.config.cluster_files_directory, job_wrapper=job_wrapper )
cjs.user_log = os.path.join( self.app.config.cluster_files_directory, 'galaxy_%s.condor.log' % galaxy_id_tag )
@@ -78,13 +88,12 @@
submit_file = os.path.join( self.app.config.cluster_files_directory, 'galaxy_%s.condor.desc' % galaxy_id_tag )
executable = cjs.job_file
submit_desc = [ ]
- submit_desc.append( 'universe = vanilla' )
- submit_desc.append( 'getenv = true' )
+ for k, v in query_params.items():
+ submit_desc.append( '%s = %s' % ( k, v ) )
submit_desc.append( 'executable = ' + executable )
submit_desc.append( 'output = ' + cjs.output_file )
submit_desc.append( 'error = ' + cjs.error_file )
submit_desc.append( 'log = ' + cjs.user_log )
- submit_desc.append( 'notification = NEVER' )
submit_desc.append( 'queue' )
script = drm_template % (job_wrapper.galaxy_lib_dir, os.path.abspath( job_wrapper.working_directory ), command_line)
@@ -138,15 +147,16 @@
# TODO Add extra except for OSError?
s_out = str(e)
- os.unlink( submit_file )
-
if external_job_id is None:
log.debug( "condor_submit failed for job %s: %s" % (job_wrapper.get_id_tag(), s_out) )
if self.app.config.cleanup_job == "always":
+ os.unlink( submit_file )
cjs.cleanup()
job_wrapper.fail( "condor_submit failed", exception=True )
return
+ os.unlink( submit_file )
+
log.info( "(%s) queued as %s" % ( galaxy_id_tag, external_job_id ) )
# store runner information for tracking if Galaxy restarts
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
4 new commits in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/56b18b56417f/
Changeset: 56b18b56417f
User: jmchilton
Date: 2012-11-10 21:26:29
Summary: Refactor setting up valid extensions in DataToolParameter to eliminate code duplication, extra computation (multiple loading of same datatypes in unit tests for instance), and reduce code nesting.
Affected #: 1 file
diff -r 340438c62171578078323d39da398d5053b69d0a -r 56b18b56417f0c2613c79055b21170a3a92379ac lib/galaxy/tools/parameters/basic.py
--- a/lib/galaxy/tools/parameters/basic.py
+++ b/lib/galaxy/tools/parameters/basic.py
@@ -1371,24 +1371,25 @@
# Add metadata validator
if not string_as_bool( elem.get( 'no_validation', False ) ):
self.validators.append( validation.MetadataValidator() )
+ # Find datatypes_registry
+ if tool is None:
+ if trans:
+ # Must account for "Input Dataset" types, which while not a tool still need access to the real registry.
+ # A handle to the transaction (and thus app) will be given by the module.
+ datatypes_registry = trans.app.datatypes_registry
+ else:
+ #This occurs for things such as unit tests
+ import galaxy.datatypes.registry
+ datatypes_registry = galaxy.datatypes.registry.Registry()
+ datatypes_registry.load_datatypes()
+ else:
+ datatypes_registry = tool.app.datatypes_registry
# Build tuple of classes for supported data formats
formats = []
self.extensions = elem.get( 'format', 'data' ).split( "," )
for extension in self.extensions:
extension = extension.strip()
- if tool is None:
- if trans:
- # Must account for "Input Dataset" types, which while not a tool still need access to the real registry.
- # A handle to the transaction (and thus app) will be given by the module.
- formats.append( trans.app.datatypes_registry.get_datatype_by_extension( extension.lower() ).__class__ )
- else:
- #This occurs for things such as unit tests
- import galaxy.datatypes.registry
- datatypes_registry = galaxy.datatypes.registry.Registry()
- datatypes_registry.load_datatypes()
- formats.append( datatypes_registry.get_datatype_by_extension( extension.lower() ).__class__ )
- else:
- formats.append( tool.app.datatypes_registry.get_datatype_by_extension( extension.lower() ).__class__ )
+ formats.append( datatypes_registry.get_datatype_by_extension( extension.lower() ).__class__ )
self.formats = tuple( formats )
self.multiple = string_as_bool( elem.get( 'multiple', False ) )
# TODO: Enhance dynamic options for DataToolParameters. Currently,
https://bitbucket.org/galaxy/galaxy-central/commits/b999689a0130/
Changeset: b999689a0130
User: jmchilton
Date: 2012-11-15 15:11:02
Summary: Centeralize logic for checking if a given galaxy datatype is any of the datatypes in a given iterator (tuple, list) (used when building up tool input options and evaluating tools, checking conversions, etc...). I think this is a solid (though slight) design improvement in its own right, but it will also ease the eventually merging of composite multifiles (https://bitbucket.org/galaxyp/galaxy-central-homogeneous-composite-datatypes) into galaxy-central or at least limit the divergence between galaxy-central and that fork long term.
Affected #: 4 files
diff -r 56b18b56417f0c2613c79055b21170a3a92379ac -r b999689a013025f2a009e313a3b6e6f65354e005 lib/galaxy/datatypes/data.py
--- a/lib/galaxy/datatypes/data.py
+++ b/lib/galaxy/datatypes/data.py
@@ -529,7 +529,13 @@
def has_resolution(self):
return False
-
+ def matches_any( self, target_datatypes ):
+ """
+ Check if this datatype is of any of the target_datatypes or is
+ a subtype thereof.
+ """
+ datatype_classes = tuple( [ datatype.__class__ for datatype in target_datatypes ] )
+ return isinstance( self, datatype_classes )
def merge( split_files, output_file):
"""
diff -r 56b18b56417f0c2613c79055b21170a3a92379ac -r b999689a013025f2a009e313a3b6e6f65354e005 lib/galaxy/datatypes/registry.py
--- a/lib/galaxy/datatypes/registry.py
+++ b/lib/galaxy/datatypes/registry.py
@@ -586,7 +586,7 @@
def find_conversion_destination_for_dataset_by_extensions( self, dataset, accepted_formats, converter_safe = True ):
"""Returns ( target_ext, existing converted dataset )"""
for convert_ext in self.get_converters_by_datatype( dataset.ext ):
- if isinstance( self.get_datatype_by_extension( convert_ext ), accepted_formats ):
+ if self.get_datatype_by_extension( convert_ext ).matches_any( accepted_formats ):
converted_dataset = dataset.get_converted_files_by_type( convert_ext )
if converted_dataset:
ret_data = converted_dataset
diff -r 56b18b56417f0c2613c79055b21170a3a92379ac -r b999689a013025f2a009e313a3b6e6f65354e005 lib/galaxy/tools/actions/__init__.py
--- a/lib/galaxy/tools/actions/__init__.py
+++ b/lib/galaxy/tools/actions/__init__.py
@@ -36,7 +36,7 @@
def process_dataset( data, formats = None ):
if formats is None:
formats = input.formats
- if data and not isinstance( data.datatype, formats ):
+ if data and not data.datatype.matches_any( formats ):
# Need to refresh in case this conversion just took place, i.e. input above in tool performed the same conversion
trans.sa_session.refresh( data )
target_ext, converted_dataset = data.find_conversion_destination( formats )
@@ -66,7 +66,7 @@
conversions = []
for conversion_name, conversion_extensions, conversion_datatypes in input.conversions:
new_data = process_dataset( input_datasets[ prefix + input.name + str( i + 1 ) ], conversion_datatypes )
- if not new_data or isinstance( new_data.datatype, conversion_datatypes ):
+ if not new_data or new_data.datatype.matches_any( conversion_datatypes ):
input_datasets[ prefix + conversion_name + str( i + 1 ) ] = new_data
conversions.append( ( conversion_name, new_data ) )
else:
@@ -86,7 +86,7 @@
conversions = []
for conversion_name, conversion_extensions, conversion_datatypes in input.conversions:
new_data = process_dataset( input_datasets[ prefix + input.name ], conversion_datatypes )
- if not new_data or isinstance( new_data.datatype, conversion_datatypes ):
+ if not new_data or new_data.datatype.matches_any( conversion_datatypes ):
input_datasets[ prefix + conversion_name ] = new_data
conversions.append( ( conversion_name, new_data ) )
else:
@@ -261,7 +261,9 @@
ext = input_ext
if output.format_source is not None and output.format_source in inp_data:
try:
- ext = inp_data[output.format_source].ext
+ input_dataset = inp_data[output.format_source]
+ input_extension = input_dataset.ext
+ ext = input_extension
except Exception, e:
pass
diff -r 56b18b56417f0c2613c79055b21170a3a92379ac -r b999689a013025f2a009e313a3b6e6f65354e005 lib/galaxy/tools/parameters/basic.py
--- a/lib/galaxy/tools/parameters/basic.py
+++ b/lib/galaxy/tools/parameters/basic.py
@@ -785,7 +785,7 @@
if isinstance( dep_value, RuntimeValue ):
return True
#dataset not ready yet
- if hasattr( self, 'ref_input' ) and isinstance( dep_value, self.tool.app.model.HistoryDatasetAssociation ) and ( dep_value.is_pending or not isinstance( dep_value.datatype, self.ref_input.formats ) ):
+ if hasattr( self, 'ref_input' ) and isinstance( dep_value, self.tool.app.model.HistoryDatasetAssociation ) and ( dep_value.is_pending or not dep_value.datatype.matches_any( self.ref_input.formats ) ):
return True
# Dynamic, but all dependenceis are known and have values
return False
@@ -1037,7 +1037,7 @@
if not dataset.metadata.columns:
# Only allow late validation if the dataset is not yet ready
# (since we have reason to expect the metadata to be ready eventually)
- if dataset.is_pending or not isinstance( dataset.datatype, self.ref_input.formats ):
+ if dataset.is_pending or not dataset.datatype.matches_any( self.ref_input.formats ):
return True
# No late validation
return False
@@ -1389,8 +1389,8 @@
self.extensions = elem.get( 'format', 'data' ).split( "," )
for extension in self.extensions:
extension = extension.strip()
- formats.append( datatypes_registry.get_datatype_by_extension( extension.lower() ).__class__ )
- self.formats = tuple( formats )
+ formats.append( datatypes_registry.get_datatype_by_extension( extension.lower() ) )
+ self.formats = formats
self.multiple = string_as_bool( elem.get( 'multiple', False ) )
# TODO: Enhance dynamic options for DataToolParameters. Currently,
# only the special case key='build' of type='data_meta' is
@@ -1414,7 +1414,7 @@
conv_extensions = conv_elem.get( "type" ) #target datatype extension
# FIXME: conv_extensions should be able to be an ordered list
assert None not in [ name, type ], 'A name (%s) and type (%s) are required for explicit conversion' % ( name, type )
- conv_types = tool.app.datatypes_registry.get_datatype_by_extension( conv_extensions.lower() ).__class__
+ conv_types = tool.app.datatypes_registry.get_datatype_by_extension( conv_extensions.lower() )
self.conversions.append( ( name, conv_extensions, conv_types ) )
def get_html_field( self, trans=None, value=None, other_values={} ):
@@ -1452,7 +1452,7 @@
continue
if self.options and self._options_filter_attribute( hda ) != filter_value:
continue
- if isinstance( hda.datatype, self.formats):
+ if hda.datatype.matches_any( self.formats ):
selected = ( value and ( hda in value ) )
if hda.visible:
hidden_text = ""
@@ -1519,7 +1519,7 @@
for i, data in enumerate( datasets ):
if data.visible and not data.deleted and data.state not in [data.states.ERROR, data.states.DISCARDED]:
is_valid = False
- if isinstance( data.datatype, self.formats ):
+ if data.datatype.matches_any( self.formats ):
is_valid = True
else:
target_ext, converted_dataset = data.find_conversion_destination( self.formats )
https://bitbucket.org/galaxy/galaxy-central/commits/c011bbda72b3/
Changeset: c011bbda72b3
User: jmchilton
Date: 2012-11-15 15:23:15
Summary: Small refactoring of logic used to build up list of valid formats for an input data parameter.
Affected #: 1 file
diff -r b999689a013025f2a009e313a3b6e6f65354e005 -r c011bbda72b3e3fd974a759a53e4baef7b6121a2 lib/galaxy/tools/parameters/basic.py
--- a/lib/galaxy/tools/parameters/basic.py
+++ b/lib/galaxy/tools/parameters/basic.py
@@ -1387,9 +1387,9 @@
# Build tuple of classes for supported data formats
formats = []
self.extensions = elem.get( 'format', 'data' ).split( "," )
- for extension in self.extensions:
- extension = extension.strip()
- formats.append( datatypes_registry.get_datatype_by_extension( extension.lower() ) )
+ normalized_extensions = [extension.strip().lower() for extension in self.extensions]
+ for extension in normalized_extensions:
+ formats.append( datatypes_registry.get_datatype_by_extension( extension ) )
self.formats = formats
self.multiple = string_as_bool( elem.get( 'multiple', False ) )
# TODO: Enhance dynamic options for DataToolParameters. Currently,
https://bitbucket.org/galaxy/galaxy-central/commits/ada2dca97078/
Changeset: ada2dca97078
User: jmchilton
Date: 2012-12-04 06:04:36
Summary: Leave process_dataset immediately if input data is `None` in collect_input_datasets of DefaultToolAction, simplifies code and eliminates some unneeded computation.
Affected #: 1 file
diff -r c011bbda72b3e3fd974a759a53e4baef7b6121a2 -r ada2dca97078b552d12b28e7da65d9667e28b125 lib/galaxy/tools/actions/__init__.py
--- a/lib/galaxy/tools/actions/__init__.py
+++ b/lib/galaxy/tools/actions/__init__.py
@@ -34,9 +34,11 @@
input_datasets = dict()
def visitor( prefix, input, value, parent = None ):
def process_dataset( data, formats = None ):
+ if not data:
+ return data
if formats is None:
formats = input.formats
- if data and not data.datatype.matches_any( formats ):
+ if not data.datatype.matches_any( formats ):
# Need to refresh in case this conversion just took place, i.e. input above in tool performed the same conversion
trans.sa_session.refresh( data )
target_ext, converted_dataset = data.find_conversion_destination( formats )
@@ -54,7 +56,7 @@
trans.sa_session.flush()
data = new_data
current_user_roles = trans.get_current_user_roles()
- if data and not trans.app.security_agent.can_access_dataset( current_user_roles, data.dataset ):
+ if not trans.app.security_agent.can_access_dataset( current_user_roles, data.dataset ):
raise "User does not have permission to use a dataset (%s) provided for input." % data.id
return data
if isinstance( input, DataToolParameter ):
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
2 new commits in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/d8d4683308d9/
Changeset: d8d4683308d9
User: dannon
Date: 2013-06-13 21:29:57
Summary: Refactor logic in migration 0032, fix sqlite duplicate index.
Affected #: 1 file
diff -r b509d742abb83380ed03e9c01780ab9a8ed184bc -r d8d4683308d9c7e391982787fdee07bebe07e892 lib/galaxy/model/migrate/versions/0032_stored_workflow_slug_column.py
--- a/lib/galaxy/model/migrate/versions/0032_stored_workflow_slug_column.py
+++ b/lib/galaxy/model/migrate/versions/0032_stored_workflow_slug_column.py
@@ -19,22 +19,16 @@
StoredWorkflow_table = Table( "stored_workflow", metadata, autoload=True )
- if migrate_engine.name not in ['mysql', 'sqlite']:
- # Create slug column.
- c = Column( "slug", TEXT, index=True )
- c.create( StoredWorkflow_table, index_name='ix_stored_workflow_slug' )
- else:
- # Create slug column.
- c = Column( "slug", TEXT )
- c.create( StoredWorkflow_table )
- i = Index( "ix_page_slug", StoredWorkflow_table.c.slug, mysql_length = 200)
- i.create()
+ # Create slug column.
+ c = Column( "slug", TEXT )
+ c.create( StoredWorkflow_table )
+
assert c is StoredWorkflow_table.c.slug
# Create slug index.
if migrate_engine.name != 'sqlite':
try:
- i = Index( "ix_stored_workflow_slug", StoredWorkflow_table.c.slug )
+ i = Index( "ix_stored_workflow_slug", StoredWorkflow_table.c.slug, mysql_length = 200 )
i.create()
except:
# Mysql doesn't have a named index, but alter should work
https://bitbucket.org/galaxy/galaxy-central/commits/aea50b1c8d91/
Changeset: aea50b1c8d91
Branch: stable
User: dannon
Date: 2013-06-13 21:29:57
Summary: Refactor logic in migration 0032, fix sqlite duplicate index.
Affected #: 1 file
diff -r f7671ce77430d38e74015f05dfe6ca79e422efe8 -r aea50b1c8d9178de429e58805ca6c12e7f0465ee lib/galaxy/model/migrate/versions/0032_stored_workflow_slug_column.py
--- a/lib/galaxy/model/migrate/versions/0032_stored_workflow_slug_column.py
+++ b/lib/galaxy/model/migrate/versions/0032_stored_workflow_slug_column.py
@@ -19,22 +19,16 @@
StoredWorkflow_table = Table( "stored_workflow", metadata, autoload=True )
- if migrate_engine.name not in ['mysql', 'sqlite']:
- # Create slug column.
- c = Column( "slug", TEXT, index=True )
- c.create( StoredWorkflow_table, index_name='ix_stored_workflow_slug' )
- else:
- # Create slug column.
- c = Column( "slug", TEXT )
- c.create( StoredWorkflow_table )
- i = Index( "ix_page_slug", StoredWorkflow_table.c.slug, mysql_length = 200)
- i.create()
+ # Create slug column.
+ c = Column( "slug", TEXT )
+ c.create( StoredWorkflow_table )
+
assert c is StoredWorkflow_table.c.slug
# Create slug index.
if migrate_engine.name != 'sqlite':
try:
- i = Index( "ix_stored_workflow_slug", StoredWorkflow_table.c.slug )
+ i = Index( "ix_stored_workflow_slug", StoredWorkflow_table.c.slug, mysql_length = 200 )
i.create()
except:
# Mysql doesn't have a named index, but alter should work
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
3 new commits in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/99dad50eb440/
Changeset: 99dad50eb440
User: jmchilton
Date: 2013-04-20 08:33:57
Summary: Implement dynamic toolbox filters.
Overview: Right now these filters are implemented via python code, but a higher level configuration mechanism could be implemented on top of this one easily. Added the well documented file lib/galaxy/tools/filters/examples.py.sample that outlines the implementations of some possible filters and how to configure them in universe_wsgi.ini.
Implementation: Refactored Toolbox.to_dict and remove Tool._is_hidden_for_user, moving and unifying all filter building functionality into tools/filters/__init.py. Implemented new dynamic filters for tools, labels, and sections. Multiple such filters can be specified by giving module (relative to galaxy.tools.filters) and function names for each as comma seperated list to the respective options tool_filters, tool_label_filters, and tool_section_filters in universe_wsgi.ini. Explicit example lines to add to universe_wsgi.ini can be found in examples.py.sample (described above).
WARNING: This mechanism only controls what tools are visible to the user. I imagine a savy user could call any tool by building custom requests or utilizing the API, to truely block users from accessing certain tools I recommend using the dynamic job runners.
Affected #: 4 files
diff -r 8d72c9adccf92f8a1971ec7d9b622de43cbd6f48 -r 99dad50eb44062d66d41f609afac00d23cbf4899 lib/galaxy/config.py
--- a/lib/galaxy/config.py
+++ b/lib/galaxy/config.py
@@ -64,6 +64,9 @@
tcf = kwargs[ 'tool_config_files' ]
else:
tcf = 'tool_conf.xml'
+ self.tool_filters = listify( kwargs.get( "tool_filters", [] ) )
+ self.tool_label_filters = listify( kwargs.get( "tool_label_filters", [] ) )
+ self.tool_section_filters = listify( kwargs.get( "tool_section_filters", [] ) )
self.tool_configs = [ resolve_path( p, self.root ) for p in listify( tcf ) ]
self.tool_data_table_config_path = resolve_path( kwargs.get( 'tool_data_table_config_path', 'tool_data_table_conf.xml' ), self.root )
self.shed_tool_data_table_config = resolve_path( kwargs.get( 'shed_tool_data_table_config', 'shed_tool_data_table_conf.xml' ), self.root )
diff -r 8d72c9adccf92f8a1971ec7d9b622de43cbd6f48 -r 99dad50eb44062d66d41f609afac00d23cbf4899 lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -47,6 +47,7 @@
from galaxy.tools.parameters.input_translation import ToolInputTranslator
from galaxy.tools.parameters.output import ToolOutputActionGroup
from galaxy.tools.parameters.validation import LateValidationError
+from galaxy.tools.filters import FilterFactory
from galaxy.tools.test import ToolTestBuilder
from galaxy.util import listify, parse_xml, rst_to_html, string_as_bool, string_to_object, xml_text, xml_to_string
from galaxy.util.bunch import Bunch
@@ -119,6 +120,7 @@
# (e.g., shed_tool_conf.xml) files include the tool_path attribute within the <toolbox> tag.
self.tool_root_dir = tool_root_dir
self.app = app
+ self.filter_factory = FilterFactory( self )
self.init_dependency_manager()
config_filenames = listify( config_filenames )
for config_filename in config_filenames:
@@ -679,76 +681,19 @@
"""
return self.app.model.context
- def to_dict( self, trans, in_panel=True, trackster=False ):
-
- def filter_for_panel( item, filters ):
- """
- Filters tool panel elements so that only those that are compatible
- with provided filters are kept.
- """
- def _apply_filter( filter_item, filter_list ):
- for filter_method in filter_list:
- if not filter_method( filter_item ):
- return False
- return True
- if isinstance( item, Tool ):
- if _apply_filter( item, filters[ 'tool' ] ):
- return item
- elif isinstance( item, ToolSectionLabel ):
- if _apply_filter( item, filters[ 'label' ] ):
- return item
- elif isinstance( item, ToolSection ):
- # Filter section item-by-item. Only show a label if there are
- # non-filtered tools below it.
-
- if _apply_filter( item, filters[ 'section' ] ):
- cur_label_key = None
- tools_under_label = False
- filtered_elems = item.elems.copy()
- for key, section_item in item.elems.items():
- if isinstance( section_item, Tool ):
- # Filter tool.
- if _apply_filter( section_item, filters[ 'tool' ] ):
- tools_under_label = True
- else:
- del filtered_elems[ key ]
- elif isinstance( section_item, ToolSectionLabel ):
- # If there is a label and it does not have tools,
- # remove it.
- if ( cur_label_key and not tools_under_label ) or not _apply_filter( section_item, filters[ 'label' ] ):
- del filtered_elems[ cur_label_key ]
-
- # Reset attributes for new label.
- cur_label_key = key
- tools_under_label = False
-
-
- # Handle last label.
- if cur_label_key and not tools_under_label:
- del filtered_elems[ cur_label_key ]
-
- # Only return section if there are elements.
- if len( filtered_elems ) != 0:
- copy = item.copy()
- copy.elems = filtered_elems
- return copy
-
- return None
-
+ def to_dict( self, trans, in_panel=True, **kwds ):
#
# Dictify toolbox.
#
-
+ context = Bunch( toolbox=self, trans=trans, **kwds )
if in_panel:
panel_elts = [ val for val in self.tool_panel.itervalues() ]
- # Filter if necessary.
- filters = dict( tool=[ lambda x: not x._is_hidden_for_user( trans.user ) ], section=[], label=[] ) #hidden tools filter
- if trackster:
- filters[ 'tool' ].append( lambda x: x.trackster_conf ) # If tool has a trackster config, it can be used in Trackster.
+ filters = self.filter_factory.build_filters( trans, **kwds )
+
filtered_panel_elts = []
for index, elt in enumerate( panel_elts ):
- elt = filter_for_panel( elt, filters )
+ elt = _filter_for_panel( elt, filters, context )
if elt:
filtered_panel_elts.append( elt )
panel_elts = filtered_panel_elts
@@ -759,13 +704,68 @@
rval.append( elt.to_dict( trans, for_link=True ) )
else:
tools = []
- for id, tool in self.app.toolbox.tools_by_id.items():
+ for id, tool in self.toolbox.tools_by_id.items():
tools.append( tool.to_dict( trans ) )
rval = tools
return rval
+def _filter_for_panel( item, filters, context ):
+ """
+ Filters tool panel elements so that only those that are compatible
+ with provided filters are kept.
+ """
+ def _apply_filter( filter_item, filter_list ):
+ for filter_method in filter_list:
+ if not filter_method( context, filter_item ):
+ return False
+ return True
+ if isinstance( item, Tool ):
+ if _apply_filter( item, filters[ 'tool' ] ):
+ return item
+ elif isinstance( item, ToolSectionLabel ):
+ if _apply_filter( item, filters[ 'label' ] ):
+ return item
+ elif isinstance( item, ToolSection ):
+ # Filter section item-by-item. Only show a label if there are
+ # non-filtered tools below it.
+
+ if _apply_filter( item, filters[ 'section' ] ):
+ cur_label_key = None
+ tools_under_label = False
+ filtered_elems = item.elems.copy()
+ for key, section_item in item.elems.items():
+ if isinstance( section_item, Tool ):
+ # Filter tool.
+ if _apply_filter( section_item, filters[ 'tool' ] ):
+ tools_under_label = True
+ else:
+ del filtered_elems[ key ]
+ elif isinstance( section_item, ToolSectionLabel ):
+ # If there is a label and it does not have tools,
+ # remove it.
+ if ( cur_label_key and not tools_under_label ) or not _apply_filter( section_item, filters[ 'label' ] ):
+ del filtered_elems[ cur_label_key ]
+
+ # Reset attributes for new label.
+ cur_label_key = key
+ tools_under_label = False
+
+ # Handle last label.
+ if cur_label_key and not tools_under_label:
+ del filtered_elems[ cur_label_key ]
+
+ # Only return section if there are elements.
+ if len( filtered_elems ) != 0:
+ copy = item.copy()
+ copy.elems = filtered_elems
+ return copy
+
+ return None
+
+
+
class ToolSection( object ):
"""
A group of tools with similar type/purpose that will be displayed as a
@@ -2897,11 +2897,6 @@
self.sa_session.flush()
return primary_datasets
- def _is_hidden_for_user( self, user ):
- if self.hidden or ( not user and self.require_login ):
- return True
- return False
-
def to_dict( self, trans, for_link=False, for_display=False ):
""" Returns dict of tool. """
diff -r 8d72c9adccf92f8a1971ec7d9b622de43cbd6f48 -r 99dad50eb44062d66d41f609afac00d23cbf4899 lib/galaxy/tools/filters/__init__.py
--- /dev/null
+++ b/lib/galaxy/tools/filters/__init__.py
@@ -0,0 +1,67 @@
+
+
+class FilterFactory( object ):
+ """
+ An instance of this class is responsible for filtering the list
+ of tools presented to a given user in a given context.
+ """
+
+ def __init__( self, toolbox ):
+ self.toolbox = toolbox
+
+ # Prepopulate dict containing filters that are always checked,
+ # other filters that get checked depending on context (e.g. coming from
+ # trackster or no user found are added in build filters).
+ self.default_filters = dict( tool=[ _not_hidden ], section=[], label=[] )
+ # Add dynamic filters to these default filters.
+ config = toolbox.app.config
+ self.__init_filters( "tool", config.tool_filters )
+ self.__init_filters( "section", config.tool_section_filters )
+ self.__init_filters( "label", config.tool_label_filters )
+
+ def build_filters( self, trans, **kwds ):
+ """
+ Build list of filters to check tools against given current context.
+ """
+ filters = self.default_filters.copy()
+
+ if not trans.user:
+ filters[ "tool" ].append( _requires_login )
+
+ if kwds.get( "trackster", False ):
+ filters[ "tool" ].append( _has_trackster_conf )
+
+ return filters
+
+ def __init_filters( self, key, filters ):
+ for filter in filters:
+ filter_function = self.__build_filter_function( filter )
+ self.default_filters[ key ].append( filter_function )
+
+ def __build_filter_function( self, filter_name ):
+ """Obtain python function (importing a submodule if needed)
+ corresponding to filter_name.
+ """
+ if ":" in filter_name:
+ # Should be a submodule of filters (e.g. examples:restrict_development_tools)
+ (module_name, function_name) = filter_name.rsplit(":", 1)
+ module = __import__( module_name, globals() )
+ function = getattr( module, function_name )
+ else:
+ # No module found, just load a function from this file or
+ # one that has be explicitly imported.
+ function = getattr( globals(), filter_name )
+ return function
+
+
+## Stock Filter Functions
+def _not_hidden( context, tool ):
+ return not tool.hidden
+
+
+def _requires_login( context, tool ):
+ return not tool.require_login
+
+
+def _has_trackster_conf( context, tool ):
+ return tool.trackster_conf
diff -r 8d72c9adccf92f8a1971ec7d9b622de43cbd6f48 -r 99dad50eb44062d66d41f609afac00d23cbf4899 lib/galaxy/tools/filters/examples.py.sample
--- /dev/null
+++ b/lib/galaxy/tools/filters/examples.py.sample
@@ -0,0 +1,87 @@
+import logging
+log = logging.getLogger( __name__ )
+
+
+def restrict_upload_to_admins( context, tool ):
+ """
+ This tool filter will hide the upload tool from all users except admin
+ users. This can be enabled by renaming this file to examples.py and adding
+ the following to the ``app:main`` section of ``universe_wsgi.ini``:
+
+ tool_filters = examples:restrict_upload_to_admins
+ """
+ if tool.name == "Upload File":
+ return context.trans.user_is_admin()
+ return True
+
+
+def disable_gatk( context, tool ):
+ """
+ This tool filter will disable all gatk tools when enabled. This can be
+ enabled by renaming this file to examples.py and adding the following to the
+ ``app:main`` section of ``universe_wsgi.ini``:
+
+ tool_filters = examples:disable_gatk
+ """
+ return not any( [ requirement.name == "gatk" for requirement in tool.requirements ] )
+
+
+def explicit_user_mapping( context, section ):
+ """
+ This tool section filter uses an explicit mapping to describe what users can view
+ which tool sections. Anonymous users will only be able to view the "Get Data"
+ tool section (with id getext). This can be enabled by renaming this file to
+ examples.py and adding the following to the ``app:main`` section of
+ ``universe_wsgi.ini``:
+
+ tool_section_filters = examples:explicit_user_mapping
+ """
+ users_sections = {
+ None: [ "getext" ],
+ "bob(a)example.com": [ "getext", "textutil", "filter" ],
+ "mary(a)example.com": [ "getext", "textutil", "filter", "ngs" ],
+ }
+ user = context.trans.user
+ email = user and user.email
+ valid_sections = users_sections.get( email, [] )
+ return section.id in valid_sections
+
+
+DEVELOPERS = [ "mary(a)example.com" ]
+
+
+def restrict_development_tools( context, tool ):
+ """
+ This tool filter will disable all tools with the string alpha appearing in
+ the version for all users except those explicitly appearing in the DEVELOPERS list
+ defined above. This can be enabled by renaming this file to examples.py and
+ adding the following to the ``app:main`` section of ``universe_wsgi.ini``:
+
+ tool_filters = examples:restrict_development_tools
+ """
+ version = tool.version
+ user = context.trans.user
+ email = user and user.email
+ return "alpha" not in version or email in DEVELOPERS
+
+
+def per_host_tool_sections( context, section ):
+ """
+ This tool section filter results in different sections being display based on
+ the URL the user is making the request to. This could allow a single Galaxy instance
+ to seem like several different instances hosting different tools based on the URL used
+ to access the Galxy. This can be enabled by renaming this file to examples.py and adding
+ the following to the ``app:main`` section of ``universe_wsgi.ini``:
+
+ tool_section_filters = examples:per_host_tool_sections
+ """
+ host = context.trans.request.host
+ # Core tools used by all virtual hosts.
+ valid_sections = [ "getext", "textutil", "filter" ]
+ if "ngs.galaxy.example.com" in host:
+ valid_sections += [ "ngs" ]
+ elif "microarray.galaxy.example.com" in host:
+ valid_sections += [ "microarray" ]
+ elif "proteomics.galaxy.example.com" in host:
+ valid_sections += [ "proteomics" ]
+ return section.id in valid_sections
https://bitbucket.org/galaxy/galaxy-central/commits/94a81104e8f4/
Changeset: 94a81104e8f4
User: jmchilton
Date: 2013-04-20 18:10:23
Summary: Dynamic Toolbox Filtering: Allow whitespace around commas between filters in configuration file.
Affected #: 1 file
diff -r 99dad50eb44062d66d41f609afac00d23cbf4899 -r 94a81104e8f442d1c40e5b6b681ffdd8c684d963 lib/galaxy/tools/filters/__init__.py
--- a/lib/galaxy/tools/filters/__init__.py
+++ b/lib/galaxy/tools/filters/__init__.py
@@ -45,12 +45,12 @@
if ":" in filter_name:
# Should be a submodule of filters (e.g. examples:restrict_development_tools)
(module_name, function_name) = filter_name.rsplit(":", 1)
- module = __import__( module_name, globals() )
- function = getattr( module, function_name )
+ module = __import__( module_name.strip(), globals() )
+ function = getattr( module, function_name.strip() )
else:
# No module found, just load a function from this file or
# one that has be explicitly imported.
- function = getattr( globals(), filter_name )
+ function = getattr( globals(), filter_name.strip() )
return function
https://bitbucket.org/galaxy/galaxy-central/commits/b509d742abb8/
Changeset: b509d742abb8
User: dannon
Date: 2013-06-13 21:23:52
Summary: Merged in jmchilton/galaxy-central-multi-input-tool-fixes-2 (pull request #160)
Implement dynamic toolbox filters.
Affected #: 4 files
diff -r 75aa82cbcaedbaa471f9f44ee19b0e201f8bb55b -r b509d742abb83380ed03e9c01780ab9a8ed184bc lib/galaxy/config.py
--- a/lib/galaxy/config.py
+++ b/lib/galaxy/config.py
@@ -64,6 +64,9 @@
tcf = kwargs[ 'tool_config_files' ]
else:
tcf = 'tool_conf.xml'
+ self.tool_filters = listify( kwargs.get( "tool_filters", [] ) )
+ self.tool_label_filters = listify( kwargs.get( "tool_label_filters", [] ) )
+ self.tool_section_filters = listify( kwargs.get( "tool_section_filters", [] ) )
self.tool_configs = [ resolve_path( p, self.root ) for p in listify( tcf ) ]
self.shed_tool_data_path = kwargs.get( "shed_tool_data_path", None )
if self.shed_tool_data_path:
diff -r 75aa82cbcaedbaa471f9f44ee19b0e201f8bb55b -r b509d742abb83380ed03e9c01780ab9a8ed184bc lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -48,6 +48,7 @@
from galaxy.tools.parameters.input_translation import ToolInputTranslator
from galaxy.tools.parameters.output import ToolOutputActionGroup
from galaxy.tools.parameters.validation import LateValidationError
+from galaxy.tools.filters import FilterFactory
from galaxy.tools.test import ToolTestBuilder
from galaxy.util import listify, parse_xml, rst_to_html, string_as_bool, string_to_object, xml_text, xml_to_string
from galaxy.util.bunch import Bunch
@@ -120,6 +121,7 @@
# (e.g., shed_tool_conf.xml) files include the tool_path attribute within the <toolbox> tag.
self.tool_root_dir = tool_root_dir
self.app = app
+ self.filter_factory = FilterFactory( self )
self.init_dependency_manager()
config_filenames = listify( config_filenames )
for config_filename in config_filenames:
@@ -680,76 +682,19 @@
"""
return self.app.model.context
- def to_dict( self, trans, in_panel=True, trackster=False ):
-
- def filter_for_panel( item, filters ):
- """
- Filters tool panel elements so that only those that are compatible
- with provided filters are kept.
- """
- def _apply_filter( filter_item, filter_list ):
- for filter_method in filter_list:
- if not filter_method( filter_item ):
- return False
- return True
- if isinstance( item, Tool ):
- if _apply_filter( item, filters[ 'tool' ] ):
- return item
- elif isinstance( item, ToolSectionLabel ):
- if _apply_filter( item, filters[ 'label' ] ):
- return item
- elif isinstance( item, ToolSection ):
- # Filter section item-by-item. Only show a label if there are
- # non-filtered tools below it.
-
- if _apply_filter( item, filters[ 'section' ] ):
- cur_label_key = None
- tools_under_label = False
- filtered_elems = item.elems.copy()
- for key, section_item in item.elems.items():
- if isinstance( section_item, Tool ):
- # Filter tool.
- if _apply_filter( section_item, filters[ 'tool' ] ):
- tools_under_label = True
- else:
- del filtered_elems[ key ]
- elif isinstance( section_item, ToolSectionLabel ):
- # If there is a label and it does not have tools,
- # remove it.
- if ( cur_label_key and not tools_under_label ) or not _apply_filter( section_item, filters[ 'label' ] ):
- del filtered_elems[ cur_label_key ]
-
- # Reset attributes for new label.
- cur_label_key = key
- tools_under_label = False
-
-
- # Handle last label.
- if cur_label_key and not tools_under_label:
- del filtered_elems[ cur_label_key ]
-
- # Only return section if there are elements.
- if len( filtered_elems ) != 0:
- copy = item.copy()
- copy.elems = filtered_elems
- return copy
-
- return None
-
+ def to_dict( self, trans, in_panel=True, **kwds ):
#
# Dictify toolbox.
#
-
+ context = Bunch( toolbox=self, trans=trans, **kwds )
if in_panel:
panel_elts = [ val for val in self.tool_panel.itervalues() ]
- # Filter if necessary.
- filters = dict( tool=[ lambda x: not x._is_hidden_for_user( trans.user ) ], section=[], label=[] ) #hidden tools filter
- if trackster:
- filters[ 'tool' ].append( lambda x: x.trackster_conf ) # If tool has a trackster config, it can be used in Trackster.
+ filters = self.filter_factory.build_filters( trans, **kwds )
+
filtered_panel_elts = []
for index, elt in enumerate( panel_elts ):
- elt = filter_for_panel( elt, filters )
+ elt = _filter_for_panel( elt, filters, context )
if elt:
filtered_panel_elts.append( elt )
panel_elts = filtered_panel_elts
@@ -760,13 +705,68 @@
rval.append( elt.to_dict( trans, for_link=True ) )
else:
tools = []
- for id, tool in self.app.toolbox.tools_by_id.items():
+ for id, tool in self.toolbox.tools_by_id.items():
tools.append( tool.to_dict( trans ) )
rval = tools
return rval
+def _filter_for_panel( item, filters, context ):
+ """
+ Filters tool panel elements so that only those that are compatible
+ with provided filters are kept.
+ """
+ def _apply_filter( filter_item, filter_list ):
+ for filter_method in filter_list:
+ if not filter_method( context, filter_item ):
+ return False
+ return True
+ if isinstance( item, Tool ):
+ if _apply_filter( item, filters[ 'tool' ] ):
+ return item
+ elif isinstance( item, ToolSectionLabel ):
+ if _apply_filter( item, filters[ 'label' ] ):
+ return item
+ elif isinstance( item, ToolSection ):
+ # Filter section item-by-item. Only show a label if there are
+ # non-filtered tools below it.
+
+ if _apply_filter( item, filters[ 'section' ] ):
+ cur_label_key = None
+ tools_under_label = False
+ filtered_elems = item.elems.copy()
+ for key, section_item in item.elems.items():
+ if isinstance( section_item, Tool ):
+ # Filter tool.
+ if _apply_filter( section_item, filters[ 'tool' ] ):
+ tools_under_label = True
+ else:
+ del filtered_elems[ key ]
+ elif isinstance( section_item, ToolSectionLabel ):
+ # If there is a label and it does not have tools,
+ # remove it.
+ if ( cur_label_key and not tools_under_label ) or not _apply_filter( section_item, filters[ 'label' ] ):
+ del filtered_elems[ cur_label_key ]
+
+ # Reset attributes for new label.
+ cur_label_key = key
+ tools_under_label = False
+
+ # Handle last label.
+ if cur_label_key and not tools_under_label:
+ del filtered_elems[ cur_label_key ]
+
+ # Only return section if there are elements.
+ if len( filtered_elems ) != 0:
+ copy = item.copy()
+ copy.elems = filtered_elems
+ return copy
+
+ return None
+
+
+
class ToolSection( object ):
"""
A group of tools with similar type/purpose that will be displayed as a
@@ -2914,11 +2914,6 @@
self.sa_session.flush()
return primary_datasets
- def _is_hidden_for_user( self, user ):
- if self.hidden or ( not user and self.require_login ):
- return True
- return False
-
def to_dict( self, trans, for_link=False, for_display=False ):
""" Returns dict of tool. """
diff -r 75aa82cbcaedbaa471f9f44ee19b0e201f8bb55b -r b509d742abb83380ed03e9c01780ab9a8ed184bc lib/galaxy/tools/filters/__init__.py
--- /dev/null
+++ b/lib/galaxy/tools/filters/__init__.py
@@ -0,0 +1,67 @@
+
+
+class FilterFactory( object ):
+ """
+ An instance of this class is responsible for filtering the list
+ of tools presented to a given user in a given context.
+ """
+
+ def __init__( self, toolbox ):
+ self.toolbox = toolbox
+
+ # Prepopulate dict containing filters that are always checked,
+ # other filters that get checked depending on context (e.g. coming from
+ # trackster or no user found are added in build filters).
+ self.default_filters = dict( tool=[ _not_hidden ], section=[], label=[] )
+ # Add dynamic filters to these default filters.
+ config = toolbox.app.config
+ self.__init_filters( "tool", config.tool_filters )
+ self.__init_filters( "section", config.tool_section_filters )
+ self.__init_filters( "label", config.tool_label_filters )
+
+ def build_filters( self, trans, **kwds ):
+ """
+ Build list of filters to check tools against given current context.
+ """
+ filters = self.default_filters.copy()
+
+ if not trans.user:
+ filters[ "tool" ].append( _requires_login )
+
+ if kwds.get( "trackster", False ):
+ filters[ "tool" ].append( _has_trackster_conf )
+
+ return filters
+
+ def __init_filters( self, key, filters ):
+ for filter in filters:
+ filter_function = self.__build_filter_function( filter )
+ self.default_filters[ key ].append( filter_function )
+
+ def __build_filter_function( self, filter_name ):
+ """Obtain python function (importing a submodule if needed)
+ corresponding to filter_name.
+ """
+ if ":" in filter_name:
+ # Should be a submodule of filters (e.g. examples:restrict_development_tools)
+ (module_name, function_name) = filter_name.rsplit(":", 1)
+ module = __import__( module_name.strip(), globals() )
+ function = getattr( module, function_name.strip() )
+ else:
+ # No module found, just load a function from this file or
+ # one that has be explicitly imported.
+ function = getattr( globals(), filter_name.strip() )
+ return function
+
+
+## Stock Filter Functions
+def _not_hidden( context, tool ):
+ return not tool.hidden
+
+
+def _requires_login( context, tool ):
+ return not tool.require_login
+
+
+def _has_trackster_conf( context, tool ):
+ return tool.trackster_conf
diff -r 75aa82cbcaedbaa471f9f44ee19b0e201f8bb55b -r b509d742abb83380ed03e9c01780ab9a8ed184bc lib/galaxy/tools/filters/examples.py.sample
--- /dev/null
+++ b/lib/galaxy/tools/filters/examples.py.sample
@@ -0,0 +1,87 @@
+import logging
+log = logging.getLogger( __name__ )
+
+
+def restrict_upload_to_admins( context, tool ):
+ """
+ This tool filter will hide the upload tool from all users except admin
+ users. This can be enabled by renaming this file to examples.py and adding
+ the following to the ``app:main`` section of ``universe_wsgi.ini``:
+
+ tool_filters = examples:restrict_upload_to_admins
+ """
+ if tool.name == "Upload File":
+ return context.trans.user_is_admin()
+ return True
+
+
+def disable_gatk( context, tool ):
+ """
+ This tool filter will disable all gatk tools when enabled. This can be
+ enabled by renaming this file to examples.py and adding the following to the
+ ``app:main`` section of ``universe_wsgi.ini``:
+
+ tool_filters = examples:disable_gatk
+ """
+ return not any( [ requirement.name == "gatk" for requirement in tool.requirements ] )
+
+
+def explicit_user_mapping( context, section ):
+ """
+ This tool section filter uses an explicit mapping to describe what users can view
+ which tool sections. Anonymous users will only be able to view the "Get Data"
+ tool section (with id getext). This can be enabled by renaming this file to
+ examples.py and adding the following to the ``app:main`` section of
+ ``universe_wsgi.ini``:
+
+ tool_section_filters = examples:explicit_user_mapping
+ """
+ users_sections = {
+ None: [ "getext" ],
+ "bob(a)example.com": [ "getext", "textutil", "filter" ],
+ "mary(a)example.com": [ "getext", "textutil", "filter", "ngs" ],
+ }
+ user = context.trans.user
+ email = user and user.email
+ valid_sections = users_sections.get( email, [] )
+ return section.id in valid_sections
+
+
+DEVELOPERS = [ "mary(a)example.com" ]
+
+
+def restrict_development_tools( context, tool ):
+ """
+ This tool filter will disable all tools with the string alpha appearing in
+ the version for all users except those explicitly appearing in the DEVELOPERS list
+ defined above. This can be enabled by renaming this file to examples.py and
+ adding the following to the ``app:main`` section of ``universe_wsgi.ini``:
+
+ tool_filters = examples:restrict_development_tools
+ """
+ version = tool.version
+ user = context.trans.user
+ email = user and user.email
+ return "alpha" not in version or email in DEVELOPERS
+
+
+def per_host_tool_sections( context, section ):
+ """
+ This tool section filter results in different sections being display based on
+ the URL the user is making the request to. This could allow a single Galaxy instance
+ to seem like several different instances hosting different tools based on the URL used
+ to access the Galxy. This can be enabled by renaming this file to examples.py and adding
+ the following to the ``app:main`` section of ``universe_wsgi.ini``:
+
+ tool_section_filters = examples:per_host_tool_sections
+ """
+ host = context.trans.request.host
+ # Core tools used by all virtual hosts.
+ valid_sections = [ "getext", "textutil", "filter" ]
+ if "ngs.galaxy.example.com" in host:
+ valid_sections += [ "ngs" ]
+ elif "microarray.galaxy.example.com" in host:
+ valid_sections += [ "microarray" ]
+ elif "proteomics.galaxy.example.com" in host:
+ valid_sections += [ "proteomics" ]
+ return section.id in valid_sections
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
2 new commits in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/4c44f42191f5/
Changeset: 4c44f42191f5
Branch: stable
User: jgoecks
Date: 2013-06-12 22:02:19
Summary: Trackster performance fix: extend Cache to support any object that can be converted to a String. Use this enhancement to avoid creating Backbone objects, which can be slow.
Affected #: 2 files
diff -r 9d42f1e32efb654fda1e011dc66a4aa5888717f1 -r 4c44f42191f512ac0faf03df8cfa94e0a3e941eb static/scripts/packed/viz/visualization.js
--- a/static/scripts/packed/viz/visualization.js
+++ b/static/scripts/packed/viz/visualization.js
@@ -1,1 +1,1 @@
-define(["libs/underscore","mvc/data","viz/trackster/util","utils/config"],function(s,i,l,o){var a=function(u,x,w,v){$.ajax({url:u,data:w,error:function(){alert("Grid failed")},success:function(y){show_modal("Select datasets for new tracks",y,{Cancel:function(){hide_modal()},Add:function(){var z=[];$("input[name=id]:checked,input[name=ldda_ids]:checked").each(function(){var A={data_type:"track_config",hda_ldda:"hda"},B=$(this).val();if($(this).attr("name")!=="id"){A.hda_ldda="ldda"}z[z.length]=$.ajax({url:x+"/"+B,data:A,dataType:"json"})});$.when.apply($,z).then(function(){var A=(arguments[0] instanceof Array?$.map(arguments,function(B){return B[0]}):[arguments[0]]);v(A)});hide_modal()}})}})};var j=function(u){return("promise" in u)};var f=function(u){this.default_font=u!==undefined?u:"9px Monaco, Lucida Console, monospace";this.dummy_canvas=this.new_canvas();this.dummy_context=this.dummy_canvas.getContext("2d");this.dummy_context.font=this.default_font;this.char_width_px=this.dummy_context.measureText("A").width;this.patterns={};this.load_pattern("right_strand","/visualization/strand_right.png");this.load_pattern("left_strand","/visualization/strand_left.png");this.load_pattern("right_strand_inv","/visualization/strand_right_inv.png");this.load_pattern("left_strand_inv","/visualization/strand_left_inv.png")};s.extend(f.prototype,{load_pattern:function(u,y){var v=this.patterns,w=this.dummy_context,x=new Image();x.src=galaxy_paths.attributes.image_path+y;x.onload=function(){v[u]=w.createPattern(x,"repeat")}},get_pattern:function(u){return this.patterns[u]},new_canvas:function(){var u=$("<canvas/>")[0];if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(u)}u.manager=this;return u}});var q=Backbone.Model.extend({defaults:{num_elements:20,obj_cache:null,key_ary:null},initialize:function(u){this.clear()},get_elt:function(v){var w=this.attributes.obj_cache,x=this.attributes.key_ary,u=x.indexOf(v);if(u!==-1){if(w[v].stale){x.splice(u,1);delete w[v]}else{this.move_key_to_end(v,u)}}return w[v]},set_elt:function(v,x){var y=this.attributes.obj_cache,z=this.attributes.key_ary,w=this.attributes.num_elements;if(!y[v]){if(z.length>=w){var u=z.shift();delete y[u]}z.push(v)}y[v]=x;return x},move_key_to_end:function(v,u){this.attributes.key_ary.splice(u,1);this.attributes.key_ary.push(v)},clear:function(){this.attributes.obj_cache={};this.attributes.key_ary=[]},size:function(){return this.attributes.key_ary.length},most_recently_added:function(){return this.size()===0?null:this.attributes.key_ary[this.attributes.key_ary.length-1]}});var d=q.extend({defaults:s.extend({},q.prototype.defaults,{dataset:null,genome:null,init_data:null,min_region_size:200,filters_manager:null,data_type:"data",data_mode_compatible:function(u,v){return true},can_subset:function(u){return false}}),initialize:function(u){q.prototype.initialize.call(this);var v=this.get("init_data");if(v){this.add_data(v)}},add_data:function(u){if(this.get("num_elements")<u.length){this.set("num_elements",u.length)}var v=this;s.each(u,function(w){v.set_data(w.region,w)})},data_is_ready:function(){var x=this.get("dataset"),w=$.Deferred(),u=(this.get("data_type")==="raw_data"?"state":this.get("data_type")==="data"?"converted_datasets_state":"error"),v=new l.ServerStateDeferred({ajax_settings:{url:this.get("dataset").url(),data:{hda_ldda:x.get("hda_ldda"),data_type:u},dataType:"json"},interval:5000,success_fn:function(y){return y!=="pending"}});$.when(v.go()).then(function(y){w.resolve(y==="ok"||y==="data")});return w},search_features:function(u){var v=this.get("dataset"),w={query:u,hda_ldda:v.get("hda_ldda"),data_type:"features"};return $.getJSON(v.url(),w)},load_data:function(C,B,v,A){var y=this.get("dataset"),x={data_type:this.get("data_type"),chrom:C.get("chrom"),low:C.get("start"),high:C.get("end"),mode:B,resolution:v,hda_ldda:y.get("hda_ldda")};$.extend(x,A);var E=this.get("filters_manager");if(E){var F=[];var u=E.filters;for(var z=0;z<u.length;z++){F.push(u[z].name)}x.filter_cols=JSON.stringify(F)}var w=this,D=$.getJSON(y.url(),x,function(G){G.region=C;w.set_data(C,G)});this.set_data(C,D);return D},get_data:function(B,A,w,y){var C=this.get_elt(B);if(C&&(j(C)||this.get("data_mode_compatible")(C,A))){return C}var D=this.get("key_ary"),v=this.get("obj_cache"),E,u,z;for(var x=0;x<D.length;x++){E=D[x];u=new g({from_str:E});if(u.contains(B)){z=true;C=v[E];if(j(C)||(this.get("data_mode_compatible")(C,A)&&this.get("can_subset")(C))){this.move_key_to_end(E,x);if(!j(C)){var G=this.subset_entry(C,B);this.set(B,G);C=G}return C}}}if(!z&&B.length()<this.attributes.min_region_size){var F=new g({from_str:this.most_recently_added()});if(!F||(B.get("start")>F.get("start"))){B.set("end",B.get("start")+this.attributes.min_region_size)}else{B.set("start",B.get("end")-this.attributes.min_region_size)}B.set("genome",this.attributes.genome);B.trim()}return this.load_data(B,A,w,y)},set_data:function(v,u){this.set_elt(v,u)},DEEP_DATA_REQ:"deep",BROAD_DATA_REQ:"breadth",get_more_data:function(C,B,x,A,y){var E=this._mark_stale(C);if(!(E&&this.get("data_mode_compatible")(E,B))){console.log("ERROR: problem with getting more data: current data is not compatible");return}var w=C.get("start");if(y===this.DEEP_DATA_REQ){$.extend(A,{start_val:E.data.length+1})}else{if(y===this.BROAD_DATA_REQ){w=(E.max_high?E.max_high:E.data[E.data.length-1][2])+1}}var D=C.copy().set("start",w);var v=this,z=this.load_data(D,B,x,A),u=$.Deferred();this.set_data(C,u);$.when(z).then(function(F){if(F.data){F.data=E.data.concat(F.data);if(F.max_low){F.max_low=E.max_low}if(F.message){F.message=F.message.replace(/[0-9]+/,F.data.length)}}v.set_data(C,F);u.resolve(F)});return u},can_get_more_detailed_data:function(v){var u=this.get_elt(v);return(u.dataset_type==="bigwig"&&u.data.length<8000)},get_more_detailed_data:function(x,z,v,y,w){var u=this._mark_stale(x);if(!u){console.log("ERROR getting more detailed data: no current data");return}if(!w){w={}}if(u.dataset_type==="bigwig"){w.num_samples=1000*y}return this.load_data(x,z,v,w)},_mark_stale:function(v){var u=this.get_elt(v);if(!u){console.log("ERROR: no data to mark as stale: ",this.get("dataset"),v.toString())}u.stale=true;return u},get_genome_wide_data:function(u){var w=this,y=true,x=s.map(u.get("chroms_info").chrom_info,function(A){var z=w.get_elt(new g({chrom:A.chrom,start:0,end:A.len}));if(!z){y=false}return z});if(y){return x}var v=$.Deferred();$.getJSON(this.get("dataset").url(),{data_type:"genome_data"},function(z){w.add_data(z.data);v.resolve(z.data)});return v},subset_entry:function(w,x){var u={bigwig:function(y,z){return s.filter(y,function(A){return A[0]>=z.get("start")&&A[0]<=z.get("end")})},refseq:function(z,A){var B=A.get("start")-w.region.get("start"),y=w.data.length-(w.region.get("end")-A.get("end"));return w.data.slice(B,y)}};var v=w.data;if(!w.region.same(x)&&w.dataset_type in u){v=u[w.dataset_type](w.data,x)}return{region:x,data:v,dataset_type:w.dataset_type}},get_elt:function(u){return q.prototype.get_elt.call(this,u.toString())},set_elt:function(v,u){return q.prototype.set_elt.call(this,v.toString(),u)}});var p=d.extend({initialize:function(u){var v=new Backbone.Model();v.urlRoot=u.data_url;this.set("dataset",v)},load_data:function(w,x,u,v){return(w.length()<=100000?d.prototype.load_data.call(this,w,x,u,v):{data:null,region:w})}});var c=Backbone.Model.extend({defaults:{name:null,key:null,chroms_info:null},initialize:function(u){this.id=u.dbkey},get_chroms_info:function(){return this.attributes.chroms_info.chrom_info},get_chrom_region:function(u){var v=s.find(this.get_chroms_info(),function(w){return w.chrom===u});return new g({chrom:v.chrom,end:v.len})},get_chrom_len:function(u){return s.find(this.get_chroms_info(),function(v){return v.chrom===u}).len}});var g=Backbone.RelationalModel.extend({defaults:{chrom:null,start:0,end:0,genome:null},same:function(u){return this.attributes.chrom===u.get("chrom")&&this.attributes.start===u.get("start")&&this.attributes.end===u.get("end")},initialize:function(v){if(v.from_str){var x=v.from_str.split(":"),w=x[0],u=x[1].split("-");this.set({chrom:w,start:parseInt(u[0],10),end:parseInt(u[1],10)})}},copy:function(){return new g({chrom:this.get("chrom"),start:this.get("start"),end:this.get("end")})},length:function(){return this.get("end")-this.get("start")},toString:function(){return this.get("chrom")+":"+this.get("start")+"-"+this.get("end")},toJSON:function(){return{chrom:this.get("chrom"),start:this.get("start"),end:this.get("end")}},compute_overlap:function(B){var v=this.get("chrom"),A=B.get("chrom"),z=this.get("start"),x=B.get("start"),y=this.get("end"),w=B.get("end"),u;if(v&&A&&v!==A){return g.overlap_results.DIF_CHROMS}if(z<x){if(y<x){u=g.overlap_results.BEFORE}else{if(y<w){u=g.overlap_results.OVERLAP_START}else{u=g.overlap_results.CONTAINS}}}else{if(z>x){if(z>w){u=g.overlap_results.AFTER}else{if(y<=w){u=g.overlap_results.CONTAINED_BY}else{u=g.overlap_results.OVERLAP_END}}}else{u=(y>=w?g.overlap_results.CONTAINS:g.overlap_results.CONTAINED_BY)}}return u},trim:function(u){if(this.attributes.start<0){this.attributes.start=0}if(this.attributes.genome){var v=this.attributes.genome.get_chrom_len(this.attributes.chrom);if(this.attributes.end>v){this.attributes.end=v-1}}return this},contains:function(u){return this.compute_overlap(u)===g.overlap_results.CONTAINS},overlaps:function(u){return s.intersection([this.compute_overlap(u)],[g.overlap_results.DIF_CHROMS,g.overlap_results.BEFORE,g.overlap_results.AFTER]).length===0}},{overlap_results:{DIF_CHROMS:1000,BEFORE:1001,CONTAINS:1002,OVERLAP_START:1003,OVERLAP_END:1004,CONTAINED_BY:1005,AFTER:1006}});var m=Backbone.Collection.extend({model:g});var e=Backbone.RelationalModel.extend({defaults:{region:null,note:""},relations:[{type:Backbone.HasOne,key:"region",relatedModel:g}]});var r=Backbone.Collection.extend({model:e});var t=Backbone.RelationalModel.extend({relations:[{type:Backbone.HasOne,key:"dataset",relatedModel:i.Dataset}],initialize:function(u){this.set("config",o.ConfigSettingCollection.from_config_dict(u.prefs));this.get("config").add([{key:"name",value:this.get("name")},{key:"color"}]);var v=this.get("preloaded_data");if(v){v=v.data}else{v=[]}this.set("data_manager",new d({dataset:this.get("dataset"),init_data:v}))}});var n=Backbone.RelationalModel.extend({defaults:{title:"",type:""},url:galaxy_paths.get("visualization_url"),save:function(){return $.ajax({url:this.url(),type:"POST",dataType:"json",data:{vis_json:JSON.stringify(this)}})}});var k=n.extend({defaults:s.extend({},n.prototype.defaults,{dbkey:"",tracks:null,bookmarks:null,viewport:null}),relations:[{type:Backbone.HasMany,key:"tracks",relatedModel:t}],add_tracks:function(u){this.get("tracks").add(u)}});var b=Backbone.Model.extend({});var h=Backbone.Router.extend({initialize:function(v){this.view=v.view;this.route(/([\w]+)$/,"change_location");this.route(/([\w]+\:[\d,]+-[\d,]+)$/,"change_location");var u=this;u.view.on("navigate",function(w){u.navigate(w)})},change_location:function(u){this.view.go_to(u)}});return{BackboneTrack:t,BrowserBookmark:e,BrowserBookmarkCollection:r,Cache:q,CanvasManager:f,Genome:c,GenomeDataManager:d,GenomeRegion:g,GenomeRegionCollection:m,GenomeVisualization:k,GenomeReferenceDataManager:p,TrackBrowserRouter:h,TrackConfig:b,Visualization:n,select_datasets:a}});
\ No newline at end of file
+define(["libs/underscore","mvc/data","viz/trackster/util","utils/config"],function(s,i,l,o){var a=function(u,x,w,v){$.ajax({url:u,data:w,error:function(){alert("Grid failed")},success:function(y){show_modal("Select datasets for new tracks",y,{Cancel:function(){hide_modal()},Add:function(){var z=[];$("input[name=id]:checked,input[name=ldda_ids]:checked").each(function(){var A={data_type:"track_config",hda_ldda:"hda"},B=$(this).val();if($(this).attr("name")!=="id"){A.hda_ldda="ldda"}z[z.length]=$.ajax({url:x+"/"+B,data:A,dataType:"json"})});$.when.apply($,z).then(function(){var A=(arguments[0] instanceof Array?$.map(arguments,function(B){return B[0]}):[arguments[0]]);v(A)});hide_modal()}})}})};var j=function(u){return("promise" in u)};var f=function(u){this.default_font=u!==undefined?u:"9px Monaco, Lucida Console, monospace";this.dummy_canvas=this.new_canvas();this.dummy_context=this.dummy_canvas.getContext("2d");this.dummy_context.font=this.default_font;this.char_width_px=this.dummy_context.measureText("A").width;this.patterns={};this.load_pattern("right_strand","/visualization/strand_right.png");this.load_pattern("left_strand","/visualization/strand_left.png");this.load_pattern("right_strand_inv","/visualization/strand_right_inv.png");this.load_pattern("left_strand_inv","/visualization/strand_left_inv.png")};s.extend(f.prototype,{load_pattern:function(u,y){var v=this.patterns,w=this.dummy_context,x=new Image();x.src=galaxy_paths.attributes.image_path+y;x.onload=function(){v[u]=w.createPattern(x,"repeat")}},get_pattern:function(u){return this.patterns[u]},new_canvas:function(){var u=$("<canvas/>")[0];if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(u)}u.manager=this;return u}});var q=Backbone.Model.extend({defaults:{num_elements:20,obj_cache:null,key_ary:null},initialize:function(u){this.clear()},get_elt:function(w){var x=this.attributes.obj_cache,y=this.attributes.key_ary,v=w.toString(),u=s.indexOf(y,function(z){return z.toString()===v});if(u!==-1){if(x[v].stale){y.splice(u,1);delete x[v]}else{this.move_key_to_end(w,u)}}return x[v]},set_elt:function(w,y){var z=this.attributes.obj_cache,A=this.attributes.key_ary,v=w.toString(),x=this.attributes.num_elements;if(!z[v]){if(A.length>=x){var u=A.shift();delete z[u.toString()]}A.push(w)}z[v]=y;return y},move_key_to_end:function(v,u){this.attributes.key_ary.splice(u,1);this.attributes.key_ary.push(v)},clear:function(){this.attributes.obj_cache={};this.attributes.key_ary=[]},size:function(){return this.attributes.key_ary.length},most_recently_added:function(){return this.size()===0?null:this.attributes.key_ary[this.attributes.key_ary.length-1]}});var d=q.extend({defaults:s.extend({},q.prototype.defaults,{dataset:null,genome:null,init_data:null,min_region_size:200,filters_manager:null,data_type:"data",data_mode_compatible:function(u,v){return true},can_subset:function(u){return false}}),initialize:function(u){q.prototype.initialize.call(this);var v=this.get("init_data");if(v){this.add_data(v)}},add_data:function(u){if(this.get("num_elements")<u.length){this.set("num_elements",u.length)}var v=this;s.each(u,function(w){v.set_data(w.region,w)})},data_is_ready:function(){var x=this.get("dataset"),w=$.Deferred(),u=(this.get("data_type")==="raw_data"?"state":this.get("data_type")==="data"?"converted_datasets_state":"error"),v=new l.ServerStateDeferred({ajax_settings:{url:this.get("dataset").url(),data:{hda_ldda:x.get("hda_ldda"),data_type:u},dataType:"json"},interval:5000,success_fn:function(y){return y!=="pending"}});$.when(v.go()).then(function(y){w.resolve(y==="ok"||y==="data")});return w},search_features:function(u){var v=this.get("dataset"),w={query:u,hda_ldda:v.get("hda_ldda"),data_type:"features"};return $.getJSON(v.url(),w)},load_data:function(C,B,v,A){var y=this.get("dataset"),x={data_type:this.get("data_type"),chrom:C.get("chrom"),low:C.get("start"),high:C.get("end"),mode:B,resolution:v,hda_ldda:y.get("hda_ldda")};$.extend(x,A);var E=this.get("filters_manager");if(E){var F=[];var u=E.filters;for(var z=0;z<u.length;z++){F.push(u[z].name)}x.filter_cols=JSON.stringify(F)}var w=this,D=$.getJSON(y.url(),x,function(G){G.region=C;w.set_data(C,G)});this.set_data(C,D);return D},get_data:function(B,A,w,y){var C=this.get_elt(B);if(C&&(j(C)||this.get("data_mode_compatible")(C,A))){return C}var D=this.get("key_ary"),u=this.get("obj_cache"),v,z;for(var x=0;x<D.length;x++){v=D[x];if(v.contains(B)){z=true;C=u[v.toString()];if(j(C)||(this.get("data_mode_compatible")(C,A)&&this.get("can_subset")(C))){this.move_key_to_end(v,x);if(!j(C)){var F=this.subset_entry(C,B);this.set(B,F);C=F}return C}}}if(!z&&B.length()<this.attributes.min_region_size){var E=this.most_recently_added();if(!E||(B.get("start")>E.get("start"))){B.set("end",B.get("start")+this.attributes.min_region_size)}else{B.set("start",B.get("end")-this.attributes.min_region_size)}B.set("genome",this.attributes.genome);B.trim()}return this.load_data(B,A,w,y)},set_data:function(v,u){this.set_elt(v,u)},DEEP_DATA_REQ:"deep",BROAD_DATA_REQ:"breadth",get_more_data:function(C,B,x,A,y){var E=this._mark_stale(C);if(!(E&&this.get("data_mode_compatible")(E,B))){console.log("ERROR: problem with getting more data: current data is not compatible");return}var w=C.get("start");if(y===this.DEEP_DATA_REQ){$.extend(A,{start_val:E.data.length+1})}else{if(y===this.BROAD_DATA_REQ){w=(E.max_high?E.max_high:E.data[E.data.length-1][2])+1}}var D=C.copy().set("start",w);var v=this,z=this.load_data(D,B,x,A),u=$.Deferred();this.set_data(C,u);$.when(z).then(function(F){if(F.data){F.data=E.data.concat(F.data);if(F.max_low){F.max_low=E.max_low}if(F.message){F.message=F.message.replace(/[0-9]+/,F.data.length)}}v.set_data(C,F);u.resolve(F)});return u},can_get_more_detailed_data:function(v){var u=this.get_elt(v);return(u.dataset_type==="bigwig"&&u.data.length<8000)},get_more_detailed_data:function(x,z,v,y,w){var u=this._mark_stale(x);if(!u){console.log("ERROR getting more detailed data: no current data");return}if(!w){w={}}if(u.dataset_type==="bigwig"){w.num_samples=1000*y}return this.load_data(x,z,v,w)},_mark_stale:function(v){var u=this.get_elt(v);if(!u){console.log("ERROR: no data to mark as stale: ",this.get("dataset"),v.toString())}u.stale=true;return u},get_genome_wide_data:function(u){var w=this,y=true,x=s.map(u.get("chroms_info").chrom_info,function(A){var z=w.get_elt(new g({chrom:A.chrom,start:0,end:A.len}));if(!z){y=false}return z});if(y){return x}var v=$.Deferred();$.getJSON(this.get("dataset").url(),{data_type:"genome_data"},function(z){w.add_data(z.data);v.resolve(z.data)});return v},subset_entry:function(w,x){var u={bigwig:function(y,z){return s.filter(y,function(A){return A[0]>=z.get("start")&&A[0]<=z.get("end")})},refseq:function(z,A){var B=A.get("start")-w.region.get("start"),y=w.data.length-(w.region.get("end")-A.get("end"));return w.data.slice(B,y)}};var v=w.data;if(!w.region.same(x)&&w.dataset_type in u){v=u[w.dataset_type](w.data,x)}return{region:x,data:v,dataset_type:w.dataset_type}}});var p=d.extend({initialize:function(u){var v=new Backbone.Model();v.urlRoot=u.data_url;this.set("dataset",v)},load_data:function(w,x,u,v){return(w.length()<=100000?d.prototype.load_data.call(this,w,x,u,v):{data:null,region:w})}});var c=Backbone.Model.extend({defaults:{name:null,key:null,chroms_info:null},initialize:function(u){this.id=u.dbkey},get_chroms_info:function(){return this.attributes.chroms_info.chrom_info},get_chrom_region:function(u){var v=s.find(this.get_chroms_info(),function(w){return w.chrom===u});return new g({chrom:v.chrom,end:v.len})},get_chrom_len:function(u){return s.find(this.get_chroms_info(),function(v){return v.chrom===u}).len}});var g=Backbone.RelationalModel.extend({defaults:{chrom:null,start:0,end:0,str_val:null,genome:null},same:function(u){return this.attributes.chrom===u.get("chrom")&&this.attributes.start===u.get("start")&&this.attributes.end===u.get("end")},initialize:function(v){if(v.from_str){var x=v.from_str.split(":"),w=x[0],u=x[1].split("-");this.set({chrom:w,start:parseInt(u[0],10),end:parseInt(u[1],10)})}this.attributes.str_val=this.get("chrom")+":"+this.get("start")+"-"+this.get("end")},copy:function(){return new g({chrom:this.get("chrom"),start:this.get("start"),end:this.get("end")})},length:function(){return this.get("end")-this.get("start")},toString:function(){return this.attributes.str_val},toJSON:function(){return{chrom:this.get("chrom"),start:this.get("start"),end:this.get("end")}},compute_overlap:function(B){var v=this.get("chrom"),A=B.get("chrom"),z=this.get("start"),x=B.get("start"),y=this.get("end"),w=B.get("end"),u;if(v&&A&&v!==A){return g.overlap_results.DIF_CHROMS}if(z<x){if(y<x){u=g.overlap_results.BEFORE}else{if(y<w){u=g.overlap_results.OVERLAP_START}else{u=g.overlap_results.CONTAINS}}}else{if(z>x){if(z>w){u=g.overlap_results.AFTER}else{if(y<=w){u=g.overlap_results.CONTAINED_BY}else{u=g.overlap_results.OVERLAP_END}}}else{u=(y>=w?g.overlap_results.CONTAINS:g.overlap_results.CONTAINED_BY)}}return u},trim:function(u){if(this.attributes.start<0){this.attributes.start=0}if(this.attributes.genome){var v=this.attributes.genome.get_chrom_len(this.attributes.chrom);if(this.attributes.end>v){this.attributes.end=v-1}}return this},contains:function(u){return this.compute_overlap(u)===g.overlap_results.CONTAINS},overlaps:function(u){return s.intersection([this.compute_overlap(u)],[g.overlap_results.DIF_CHROMS,g.overlap_results.BEFORE,g.overlap_results.AFTER]).length===0}},{overlap_results:{DIF_CHROMS:1000,BEFORE:1001,CONTAINS:1002,OVERLAP_START:1003,OVERLAP_END:1004,CONTAINED_BY:1005,AFTER:1006}});var m=Backbone.Collection.extend({model:g});var e=Backbone.RelationalModel.extend({defaults:{region:null,note:""},relations:[{type:Backbone.HasOne,key:"region",relatedModel:g}]});var r=Backbone.Collection.extend({model:e});var t=Backbone.RelationalModel.extend({relations:[{type:Backbone.HasOne,key:"dataset",relatedModel:i.Dataset}],initialize:function(u){this.set("config",o.ConfigSettingCollection.from_config_dict(u.prefs));this.get("config").add([{key:"name",value:this.get("name")},{key:"color"}]);var v=this.get("preloaded_data");if(v){v=v.data}else{v=[]}this.set("data_manager",new d({dataset:this.get("dataset"),init_data:v}))}});var n=Backbone.RelationalModel.extend({defaults:{title:"",type:""},url:galaxy_paths.get("visualization_url"),save:function(){return $.ajax({url:this.url(),type:"POST",dataType:"json",data:{vis_json:JSON.stringify(this)}})}});var k=n.extend({defaults:s.extend({},n.prototype.defaults,{dbkey:"",tracks:null,bookmarks:null,viewport:null}),relations:[{type:Backbone.HasMany,key:"tracks",relatedModel:t}],add_tracks:function(u){this.get("tracks").add(u)}});var b=Backbone.Model.extend({});var h=Backbone.Router.extend({initialize:function(v){this.view=v.view;this.route(/([\w]+)$/,"change_location");this.route(/([\w]+\:[\d,]+-[\d,]+)$/,"change_location");var u=this;u.view.on("navigate",function(w){u.navigate(w)})},change_location:function(u){this.view.go_to(u)}});return{BackboneTrack:t,BrowserBookmark:e,BrowserBookmarkCollection:r,Cache:q,CanvasManager:f,Genome:c,GenomeDataManager:d,GenomeRegion:g,GenomeRegionCollection:m,GenomeVisualization:k,GenomeReferenceDataManager:p,TrackBrowserRouter:h,TrackConfig:b,Visualization:n,select_datasets:a}});
\ No newline at end of file
diff -r 9d42f1e32efb654fda1e011dc66a4aa5888717f1 -r 4c44f42191f512ac0faf03df8cfa94e0a3e941eb static/scripts/viz/visualization.js
--- a/static/scripts/viz/visualization.js
+++ b/static/scripts/viz/visualization.js
@@ -120,49 +120,75 @@
});
/**
- * Generic cache that handles key/value pairs.
+ * Generic cache that handles key/value pairs. Keys can be any object that can be
+ * converted to a String and compared.
*/
var Cache = Backbone.Model.extend({
defaults: {
num_elements: 20,
+ // Objects in cache; indexes into cache are strings of keys.
obj_cache: null,
+ // key_ary contains keys for objects in cache.
key_ary: null
},
initialize: function(options) {
this.clear();
},
-
+
+ /**
+ * Get an element from the cache using its key.
+ */
get_elt: function(key) {
var obj_cache = this.attributes.obj_cache,
key_ary = this.attributes.key_ary,
- index = key_ary.indexOf(key);
+ key_str = key.toString(),
+ index = _.indexOf(key_ary, function(k) {
+ return k.toString() === key_str;
+ });
+
+ // Update cache.
if (index !== -1) {
- if (obj_cache[key].stale) {
- // Object is stale, so remove key and object.
+ // Object is in cache, so update it.
+ if (obj_cache[key_str].stale) {
+ // Object is stale: remove key and object.
key_ary.splice(index, 1);
- delete obj_cache[key];
+ delete obj_cache[key_str];
}
else {
+ // Move key to back because it is most recently used.
this.move_key_to_end(key, index);
}
}
- return obj_cache[key];
+
+ return obj_cache[key_str];
},
+ /**
+ * Put an element into the cache.
+ */
set_elt: function(key, value) {
var obj_cache = this.attributes.obj_cache,
key_ary = this.attributes.key_ary,
+ key_str = key.toString(),
num_elements = this.attributes.num_elements;
- if (!obj_cache[key]) {
+
+ // Update keys, objects.
+ if (!obj_cache[key_str]) {
+ // Add object to cache.
+
if (key_ary.length >= num_elements) {
- // Remove first element
+ // Cache full, so remove first element.
var deleted_key = key_ary.shift();
- delete obj_cache[deleted_key];
+ delete obj_cache[deleted_key.toString()];
}
+
+ // Add key.
key_ary.push(key);
}
- obj_cache[key] = value;
+
+ // Add object.
+ obj_cache[key_str] = value;
return value;
},
@@ -346,20 +372,19 @@
//
var key_ary = this.get('key_ary'),
obj_cache = this.get('obj_cache'),
- key, entry_region, is_subregion;
+ entry_region, is_subregion;
for (var i = 0; i < key_ary.length; i++) {
- key = key_ary[i];
- entry_region = new GenomeRegion({from_str: key});
-
+ entry_region = key_ary[i];
+
if (entry_region.contains(region)) {
is_subregion = true;
// This entry has data in the requested range. Return if data
// is compatible and can be subsetted.
- entry = obj_cache[key];
+ entry = obj_cache[entry_region.toString()];
if ( is_deferred(entry) ||
( this.get('data_mode_compatible')(entry, mode) && this.get('can_subset')(entry) ) ) {
- this.move_key_to_end(key, i);
+ this.move_key_to_end(entry_region, i);
// If there's data, subset it.
if ( !is_deferred(entry) ) {
@@ -383,7 +408,7 @@
// below.
// Use heuristic to extend region: extend relative to last data request.
- var last_request = new GenomeRegion({from_str: this.most_recently_added()});
+ var last_request = this.most_recently_added();
if (!last_request || (region.get('start') > last_request.get('start'))) {
// This request is after the last request, so extend right.
region.set('end', region.get('start') + this.attributes.min_region_size);
@@ -586,20 +611,6 @@
data: subregion_data,
dataset_type: entry.dataset_type
};
- },
-
- /**
- * Get data from the cache.
- */
- get_elt: function(region) {
- return Cache.prototype.get_elt.call(this, region.toString());
- },
-
- /**
- * Sets data in the cache.
- */
- set_elt: function(region, result) {
- return Cache.prototype.set_elt.call(this, region.toString(), result);
}
});
@@ -671,6 +682,7 @@
chrom: null,
start: 0,
end: 0,
+ str_val: null,
genome: null
},
@@ -698,6 +710,9 @@
end: parseInt(start_end[1], 10)
});
}
+
+ // Keep a copy of region's string value for fast lookup.
+ this.attributes.str_val = this.get('chrom') + ":" + this.get('start') + "-" + this.get('end');
},
copy: function() {
@@ -714,7 +729,7 @@
/** Returns region in canonical form chrom:start-end */
toString: function() {
- return this.get('chrom') + ":" + this.get('start') + "-" + this.get('end');
+ return this.attributes.str_val;
},
toJSON: function() {
https://bitbucket.org/galaxy/galaxy-central/commits/a5c3090f1701/
Changeset: a5c3090f1701
User: jgoecks
Date: 2013-06-12 22:02:42
Summary: Automated merge of stable branch
Affected #: 2 files
diff -r b6a6fc1a7d4112026beb5de34f627f7848860d4f -r a5c3090f1701d73d4db190141d054617bbe45af5 static/scripts/packed/viz/visualization.js
--- a/static/scripts/packed/viz/visualization.js
+++ b/static/scripts/packed/viz/visualization.js
@@ -1,1 +1,1 @@
-define(["libs/underscore","mvc/data","viz/trackster/util","utils/config"],function(s,i,l,o){var a=function(u,x,w,v){$.ajax({url:u,data:w,error:function(){alert("Grid failed")},success:function(y){show_modal("Select datasets for new tracks",y,{Cancel:function(){hide_modal()},Add:function(){var z=[];$("input[name=id]:checked,input[name=ldda_ids]:checked").each(function(){var A={data_type:"track_config",hda_ldda:"hda"},B=$(this).val();if($(this).attr("name")!=="id"){A.hda_ldda="ldda"}z[z.length]=$.ajax({url:x+"/"+B,data:A,dataType:"json"})});$.when.apply($,z).then(function(){var A=(arguments[0] instanceof Array?$.map(arguments,function(B){return B[0]}):[arguments[0]]);v(A)});hide_modal()}})}})};var j=function(u){return("promise" in u)};var f=function(u){this.default_font=u!==undefined?u:"9px Monaco, Lucida Console, monospace";this.dummy_canvas=this.new_canvas();this.dummy_context=this.dummy_canvas.getContext("2d");this.dummy_context.font=this.default_font;this.char_width_px=this.dummy_context.measureText("A").width;this.patterns={};this.load_pattern("right_strand","/visualization/strand_right.png");this.load_pattern("left_strand","/visualization/strand_left.png");this.load_pattern("right_strand_inv","/visualization/strand_right_inv.png");this.load_pattern("left_strand_inv","/visualization/strand_left_inv.png")};s.extend(f.prototype,{load_pattern:function(u,y){var v=this.patterns,w=this.dummy_context,x=new Image();x.src=galaxy_paths.attributes.image_path+y;x.onload=function(){v[u]=w.createPattern(x,"repeat")}},get_pattern:function(u){return this.patterns[u]},new_canvas:function(){var u=$("<canvas/>")[0];if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(u)}u.manager=this;return u}});var q=Backbone.Model.extend({defaults:{num_elements:20,obj_cache:null,key_ary:null},initialize:function(u){this.clear()},get_elt:function(v){var w=this.attributes.obj_cache,x=this.attributes.key_ary,u=x.indexOf(v);if(u!==-1){if(w[v].stale){x.splice(u,1);delete w[v]}else{this.move_key_to_end(v,u)}}return w[v]},set_elt:function(v,x){var y=this.attributes.obj_cache,z=this.attributes.key_ary,w=this.attributes.num_elements;if(!y[v]){if(z.length>=w){var u=z.shift();delete y[u]}z.push(v)}y[v]=x;return x},move_key_to_end:function(v,u){this.attributes.key_ary.splice(u,1);this.attributes.key_ary.push(v)},clear:function(){this.attributes.obj_cache={};this.attributes.key_ary=[]},size:function(){return this.attributes.key_ary.length},most_recently_added:function(){return this.size()===0?null:this.attributes.key_ary[this.attributes.key_ary.length-1]}});var d=q.extend({defaults:s.extend({},q.prototype.defaults,{dataset:null,genome:null,init_data:null,min_region_size:200,filters_manager:null,data_type:"data",data_mode_compatible:function(u,v){return true},can_subset:function(u){return false}}),initialize:function(u){q.prototype.initialize.call(this);var v=this.get("init_data");if(v){this.add_data(v)}},add_data:function(u){if(this.get("num_elements")<u.length){this.set("num_elements",u.length)}var v=this;s.each(u,function(w){v.set_data(w.region,w)})},data_is_ready:function(){var x=this.get("dataset"),w=$.Deferred(),u=(this.get("data_type")==="raw_data"?"state":this.get("data_type")==="data"?"converted_datasets_state":"error"),v=new l.ServerStateDeferred({ajax_settings:{url:this.get("dataset").url(),data:{hda_ldda:x.get("hda_ldda"),data_type:u},dataType:"json"},interval:5000,success_fn:function(y){return y!=="pending"}});$.when(v.go()).then(function(y){w.resolve(y==="ok"||y==="data")});return w},search_features:function(u){var v=this.get("dataset"),w={query:u,hda_ldda:v.get("hda_ldda"),data_type:"features"};return $.getJSON(v.url(),w)},load_data:function(C,B,v,A){var y=this.get("dataset"),x={data_type:this.get("data_type"),chrom:C.get("chrom"),low:C.get("start"),high:C.get("end"),mode:B,resolution:v,hda_ldda:y.get("hda_ldda")};$.extend(x,A);var E=this.get("filters_manager");if(E){var F=[];var u=E.filters;for(var z=0;z<u.length;z++){F.push(u[z].name)}x.filter_cols=JSON.stringify(F)}var w=this,D=$.getJSON(y.url(),x,function(G){G.region=C;w.set_data(C,G)});this.set_data(C,D);return D},get_data:function(B,A,w,y){var C=this.get_elt(B);if(C&&(j(C)||this.get("data_mode_compatible")(C,A))){return C}var D=this.get("key_ary"),v=this.get("obj_cache"),E,u,z;for(var x=0;x<D.length;x++){E=D[x];u=new g({from_str:E});if(u.contains(B)){z=true;C=v[E];if(j(C)||(this.get("data_mode_compatible")(C,A)&&this.get("can_subset")(C))){this.move_key_to_end(E,x);if(!j(C)){var G=this.subset_entry(C,B);this.set(B,G);C=G}return C}}}if(!z&&B.length()<this.attributes.min_region_size){var F=new g({from_str:this.most_recently_added()});if(!F||(B.get("start")>F.get("start"))){B.set("end",B.get("start")+this.attributes.min_region_size)}else{B.set("start",B.get("end")-this.attributes.min_region_size)}B.set("genome",this.attributes.genome);B.trim()}return this.load_data(B,A,w,y)},set_data:function(v,u){this.set_elt(v,u)},DEEP_DATA_REQ:"deep",BROAD_DATA_REQ:"breadth",get_more_data:function(C,B,x,A,y){var E=this._mark_stale(C);if(!(E&&this.get("data_mode_compatible")(E,B))){console.log("ERROR: problem with getting more data: current data is not compatible");return}var w=C.get("start");if(y===this.DEEP_DATA_REQ){$.extend(A,{start_val:E.data.length+1})}else{if(y===this.BROAD_DATA_REQ){w=(E.max_high?E.max_high:E.data[E.data.length-1][2])+1}}var D=C.copy().set("start",w);var v=this,z=this.load_data(D,B,x,A),u=$.Deferred();this.set_data(C,u);$.when(z).then(function(F){if(F.data){F.data=E.data.concat(F.data);if(F.max_low){F.max_low=E.max_low}if(F.message){F.message=F.message.replace(/[0-9]+/,F.data.length)}}v.set_data(C,F);u.resolve(F)});return u},can_get_more_detailed_data:function(v){var u=this.get_elt(v);return(u.dataset_type==="bigwig"&&u.data.length<8000)},get_more_detailed_data:function(x,z,v,y,w){var u=this._mark_stale(x);if(!u){console.log("ERROR getting more detailed data: no current data");return}if(!w){w={}}if(u.dataset_type==="bigwig"){w.num_samples=1000*y}return this.load_data(x,z,v,w)},_mark_stale:function(v){var u=this.get_elt(v);if(!u){console.log("ERROR: no data to mark as stale: ",this.get("dataset"),v.toString())}u.stale=true;return u},get_genome_wide_data:function(u){var w=this,y=true,x=s.map(u.get("chroms_info").chrom_info,function(A){var z=w.get_elt(new g({chrom:A.chrom,start:0,end:A.len}));if(!z){y=false}return z});if(y){return x}var v=$.Deferred();$.getJSON(this.get("dataset").url(),{data_type:"genome_data"},function(z){w.add_data(z.data);v.resolve(z.data)});return v},subset_entry:function(w,x){var u={bigwig:function(y,z){return s.filter(y,function(A){return A[0]>=z.get("start")&&A[0]<=z.get("end")})},refseq:function(z,A){var B=A.get("start")-w.region.get("start"),y=w.data.length-(w.region.get("end")-A.get("end"));return w.data.slice(B,y)}};var v=w.data;if(!w.region.same(x)&&w.dataset_type in u){v=u[w.dataset_type](w.data,x)}return{region:x,data:v,dataset_type:w.dataset_type}},get_elt:function(u){return q.prototype.get_elt.call(this,u.toString())},set_elt:function(v,u){return q.prototype.set_elt.call(this,v.toString(),u)}});var p=d.extend({initialize:function(u){var v=new Backbone.Model();v.urlRoot=u.data_url;this.set("dataset",v)},load_data:function(w,x,u,v){return(w.length()<=100000?d.prototype.load_data.call(this,w,x,u,v):{data:null,region:w})}});var c=Backbone.Model.extend({defaults:{name:null,key:null,chroms_info:null},initialize:function(u){this.id=u.dbkey},get_chroms_info:function(){return this.attributes.chroms_info.chrom_info},get_chrom_region:function(u){var v=s.find(this.get_chroms_info(),function(w){return w.chrom===u});return new g({chrom:v.chrom,end:v.len})},get_chrom_len:function(u){return s.find(this.get_chroms_info(),function(v){return v.chrom===u}).len}});var g=Backbone.RelationalModel.extend({defaults:{chrom:null,start:0,end:0,genome:null},same:function(u){return this.attributes.chrom===u.get("chrom")&&this.attributes.start===u.get("start")&&this.attributes.end===u.get("end")},initialize:function(v){if(v.from_str){var x=v.from_str.split(":"),w=x[0],u=x[1].split("-");this.set({chrom:w,start:parseInt(u[0],10),end:parseInt(u[1],10)})}},copy:function(){return new g({chrom:this.get("chrom"),start:this.get("start"),end:this.get("end")})},length:function(){return this.get("end")-this.get("start")},toString:function(){return this.get("chrom")+":"+this.get("start")+"-"+this.get("end")},toJSON:function(){return{chrom:this.get("chrom"),start:this.get("start"),end:this.get("end")}},compute_overlap:function(B){var v=this.get("chrom"),A=B.get("chrom"),z=this.get("start"),x=B.get("start"),y=this.get("end"),w=B.get("end"),u;if(v&&A&&v!==A){return g.overlap_results.DIF_CHROMS}if(z<x){if(y<x){u=g.overlap_results.BEFORE}else{if(y<w){u=g.overlap_results.OVERLAP_START}else{u=g.overlap_results.CONTAINS}}}else{if(z>x){if(z>w){u=g.overlap_results.AFTER}else{if(y<=w){u=g.overlap_results.CONTAINED_BY}else{u=g.overlap_results.OVERLAP_END}}}else{u=(y>=w?g.overlap_results.CONTAINS:g.overlap_results.CONTAINED_BY)}}return u},trim:function(u){if(this.attributes.start<0){this.attributes.start=0}if(this.attributes.genome){var v=this.attributes.genome.get_chrom_len(this.attributes.chrom);if(this.attributes.end>v){this.attributes.end=v-1}}return this},contains:function(u){return this.compute_overlap(u)===g.overlap_results.CONTAINS},overlaps:function(u){return s.intersection([this.compute_overlap(u)],[g.overlap_results.DIF_CHROMS,g.overlap_results.BEFORE,g.overlap_results.AFTER]).length===0}},{overlap_results:{DIF_CHROMS:1000,BEFORE:1001,CONTAINS:1002,OVERLAP_START:1003,OVERLAP_END:1004,CONTAINED_BY:1005,AFTER:1006}});var m=Backbone.Collection.extend({model:g});var e=Backbone.RelationalModel.extend({defaults:{region:null,note:""},relations:[{type:Backbone.HasOne,key:"region",relatedModel:g}]});var r=Backbone.Collection.extend({model:e});var t=Backbone.RelationalModel.extend({relations:[{type:Backbone.HasOne,key:"dataset",relatedModel:i.Dataset}],initialize:function(u){this.set("config",o.ConfigSettingCollection.from_config_dict(u.prefs));this.get("config").add([{key:"name",value:this.get("name")},{key:"color"}]);var v=this.get("preloaded_data");if(v){v=v.data}else{v=[]}this.set("data_manager",new d({dataset:this.get("dataset"),init_data:v}))}});var n=Backbone.RelationalModel.extend({defaults:{title:"",type:""},url:galaxy_paths.get("visualization_url"),save:function(){return $.ajax({url:this.url(),type:"POST",dataType:"json",data:{vis_json:JSON.stringify(this)}})}});var k=n.extend({defaults:s.extend({},n.prototype.defaults,{dbkey:"",tracks:null,bookmarks:null,viewport:null}),relations:[{type:Backbone.HasMany,key:"tracks",relatedModel:t}],add_tracks:function(u){this.get("tracks").add(u)}});var b=Backbone.Model.extend({});var h=Backbone.Router.extend({initialize:function(v){this.view=v.view;this.route(/([\w]+)$/,"change_location");this.route(/([\w]+\:[\d,]+-[\d,]+)$/,"change_location");var u=this;u.view.on("navigate",function(w){u.navigate(w)})},change_location:function(u){this.view.go_to(u)}});return{BackboneTrack:t,BrowserBookmark:e,BrowserBookmarkCollection:r,Cache:q,CanvasManager:f,Genome:c,GenomeDataManager:d,GenomeRegion:g,GenomeRegionCollection:m,GenomeVisualization:k,GenomeReferenceDataManager:p,TrackBrowserRouter:h,TrackConfig:b,Visualization:n,select_datasets:a}});
\ No newline at end of file
+define(["libs/underscore","mvc/data","viz/trackster/util","utils/config"],function(s,i,l,o){var a=function(u,x,w,v){$.ajax({url:u,data:w,error:function(){alert("Grid failed")},success:function(y){show_modal("Select datasets for new tracks",y,{Cancel:function(){hide_modal()},Add:function(){var z=[];$("input[name=id]:checked,input[name=ldda_ids]:checked").each(function(){var A={data_type:"track_config",hda_ldda:"hda"},B=$(this).val();if($(this).attr("name")!=="id"){A.hda_ldda="ldda"}z[z.length]=$.ajax({url:x+"/"+B,data:A,dataType:"json"})});$.when.apply($,z).then(function(){var A=(arguments[0] instanceof Array?$.map(arguments,function(B){return B[0]}):[arguments[0]]);v(A)});hide_modal()}})}})};var j=function(u){return("promise" in u)};var f=function(u){this.default_font=u!==undefined?u:"9px Monaco, Lucida Console, monospace";this.dummy_canvas=this.new_canvas();this.dummy_context=this.dummy_canvas.getContext("2d");this.dummy_context.font=this.default_font;this.char_width_px=this.dummy_context.measureText("A").width;this.patterns={};this.load_pattern("right_strand","/visualization/strand_right.png");this.load_pattern("left_strand","/visualization/strand_left.png");this.load_pattern("right_strand_inv","/visualization/strand_right_inv.png");this.load_pattern("left_strand_inv","/visualization/strand_left_inv.png")};s.extend(f.prototype,{load_pattern:function(u,y){var v=this.patterns,w=this.dummy_context,x=new Image();x.src=galaxy_paths.attributes.image_path+y;x.onload=function(){v[u]=w.createPattern(x,"repeat")}},get_pattern:function(u){return this.patterns[u]},new_canvas:function(){var u=$("<canvas/>")[0];if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(u)}u.manager=this;return u}});var q=Backbone.Model.extend({defaults:{num_elements:20,obj_cache:null,key_ary:null},initialize:function(u){this.clear()},get_elt:function(w){var x=this.attributes.obj_cache,y=this.attributes.key_ary,v=w.toString(),u=s.indexOf(y,function(z){return z.toString()===v});if(u!==-1){if(x[v].stale){y.splice(u,1);delete x[v]}else{this.move_key_to_end(w,u)}}return x[v]},set_elt:function(w,y){var z=this.attributes.obj_cache,A=this.attributes.key_ary,v=w.toString(),x=this.attributes.num_elements;if(!z[v]){if(A.length>=x){var u=A.shift();delete z[u.toString()]}A.push(w)}z[v]=y;return y},move_key_to_end:function(v,u){this.attributes.key_ary.splice(u,1);this.attributes.key_ary.push(v)},clear:function(){this.attributes.obj_cache={};this.attributes.key_ary=[]},size:function(){return this.attributes.key_ary.length},most_recently_added:function(){return this.size()===0?null:this.attributes.key_ary[this.attributes.key_ary.length-1]}});var d=q.extend({defaults:s.extend({},q.prototype.defaults,{dataset:null,genome:null,init_data:null,min_region_size:200,filters_manager:null,data_type:"data",data_mode_compatible:function(u,v){return true},can_subset:function(u){return false}}),initialize:function(u){q.prototype.initialize.call(this);var v=this.get("init_data");if(v){this.add_data(v)}},add_data:function(u){if(this.get("num_elements")<u.length){this.set("num_elements",u.length)}var v=this;s.each(u,function(w){v.set_data(w.region,w)})},data_is_ready:function(){var x=this.get("dataset"),w=$.Deferred(),u=(this.get("data_type")==="raw_data"?"state":this.get("data_type")==="data"?"converted_datasets_state":"error"),v=new l.ServerStateDeferred({ajax_settings:{url:this.get("dataset").url(),data:{hda_ldda:x.get("hda_ldda"),data_type:u},dataType:"json"},interval:5000,success_fn:function(y){return y!=="pending"}});$.when(v.go()).then(function(y){w.resolve(y==="ok"||y==="data")});return w},search_features:function(u){var v=this.get("dataset"),w={query:u,hda_ldda:v.get("hda_ldda"),data_type:"features"};return $.getJSON(v.url(),w)},load_data:function(C,B,v,A){var y=this.get("dataset"),x={data_type:this.get("data_type"),chrom:C.get("chrom"),low:C.get("start"),high:C.get("end"),mode:B,resolution:v,hda_ldda:y.get("hda_ldda")};$.extend(x,A);var E=this.get("filters_manager");if(E){var F=[];var u=E.filters;for(var z=0;z<u.length;z++){F.push(u[z].name)}x.filter_cols=JSON.stringify(F)}var w=this,D=$.getJSON(y.url(),x,function(G){G.region=C;w.set_data(C,G)});this.set_data(C,D);return D},get_data:function(B,A,w,y){var C=this.get_elt(B);if(C&&(j(C)||this.get("data_mode_compatible")(C,A))){return C}var D=this.get("key_ary"),u=this.get("obj_cache"),v,z;for(var x=0;x<D.length;x++){v=D[x];if(v.contains(B)){z=true;C=u[v.toString()];if(j(C)||(this.get("data_mode_compatible")(C,A)&&this.get("can_subset")(C))){this.move_key_to_end(v,x);if(!j(C)){var F=this.subset_entry(C,B);this.set(B,F);C=F}return C}}}if(!z&&B.length()<this.attributes.min_region_size){var E=this.most_recently_added();if(!E||(B.get("start")>E.get("start"))){B.set("end",B.get("start")+this.attributes.min_region_size)}else{B.set("start",B.get("end")-this.attributes.min_region_size)}B.set("genome",this.attributes.genome);B.trim()}return this.load_data(B,A,w,y)},set_data:function(v,u){this.set_elt(v,u)},DEEP_DATA_REQ:"deep",BROAD_DATA_REQ:"breadth",get_more_data:function(C,B,x,A,y){var E=this._mark_stale(C);if(!(E&&this.get("data_mode_compatible")(E,B))){console.log("ERROR: problem with getting more data: current data is not compatible");return}var w=C.get("start");if(y===this.DEEP_DATA_REQ){$.extend(A,{start_val:E.data.length+1})}else{if(y===this.BROAD_DATA_REQ){w=(E.max_high?E.max_high:E.data[E.data.length-1][2])+1}}var D=C.copy().set("start",w);var v=this,z=this.load_data(D,B,x,A),u=$.Deferred();this.set_data(C,u);$.when(z).then(function(F){if(F.data){F.data=E.data.concat(F.data);if(F.max_low){F.max_low=E.max_low}if(F.message){F.message=F.message.replace(/[0-9]+/,F.data.length)}}v.set_data(C,F);u.resolve(F)});return u},can_get_more_detailed_data:function(v){var u=this.get_elt(v);return(u.dataset_type==="bigwig"&&u.data.length<8000)},get_more_detailed_data:function(x,z,v,y,w){var u=this._mark_stale(x);if(!u){console.log("ERROR getting more detailed data: no current data");return}if(!w){w={}}if(u.dataset_type==="bigwig"){w.num_samples=1000*y}return this.load_data(x,z,v,w)},_mark_stale:function(v){var u=this.get_elt(v);if(!u){console.log("ERROR: no data to mark as stale: ",this.get("dataset"),v.toString())}u.stale=true;return u},get_genome_wide_data:function(u){var w=this,y=true,x=s.map(u.get("chroms_info").chrom_info,function(A){var z=w.get_elt(new g({chrom:A.chrom,start:0,end:A.len}));if(!z){y=false}return z});if(y){return x}var v=$.Deferred();$.getJSON(this.get("dataset").url(),{data_type:"genome_data"},function(z){w.add_data(z.data);v.resolve(z.data)});return v},subset_entry:function(w,x){var u={bigwig:function(y,z){return s.filter(y,function(A){return A[0]>=z.get("start")&&A[0]<=z.get("end")})},refseq:function(z,A){var B=A.get("start")-w.region.get("start"),y=w.data.length-(w.region.get("end")-A.get("end"));return w.data.slice(B,y)}};var v=w.data;if(!w.region.same(x)&&w.dataset_type in u){v=u[w.dataset_type](w.data,x)}return{region:x,data:v,dataset_type:w.dataset_type}}});var p=d.extend({initialize:function(u){var v=new Backbone.Model();v.urlRoot=u.data_url;this.set("dataset",v)},load_data:function(w,x,u,v){return(w.length()<=100000?d.prototype.load_data.call(this,w,x,u,v):{data:null,region:w})}});var c=Backbone.Model.extend({defaults:{name:null,key:null,chroms_info:null},initialize:function(u){this.id=u.dbkey},get_chroms_info:function(){return this.attributes.chroms_info.chrom_info},get_chrom_region:function(u){var v=s.find(this.get_chroms_info(),function(w){return w.chrom===u});return new g({chrom:v.chrom,end:v.len})},get_chrom_len:function(u){return s.find(this.get_chroms_info(),function(v){return v.chrom===u}).len}});var g=Backbone.RelationalModel.extend({defaults:{chrom:null,start:0,end:0,str_val:null,genome:null},same:function(u){return this.attributes.chrom===u.get("chrom")&&this.attributes.start===u.get("start")&&this.attributes.end===u.get("end")},initialize:function(v){if(v.from_str){var x=v.from_str.split(":"),w=x[0],u=x[1].split("-");this.set({chrom:w,start:parseInt(u[0],10),end:parseInt(u[1],10)})}this.attributes.str_val=this.get("chrom")+":"+this.get("start")+"-"+this.get("end")},copy:function(){return new g({chrom:this.get("chrom"),start:this.get("start"),end:this.get("end")})},length:function(){return this.get("end")-this.get("start")},toString:function(){return this.attributes.str_val},toJSON:function(){return{chrom:this.get("chrom"),start:this.get("start"),end:this.get("end")}},compute_overlap:function(B){var v=this.get("chrom"),A=B.get("chrom"),z=this.get("start"),x=B.get("start"),y=this.get("end"),w=B.get("end"),u;if(v&&A&&v!==A){return g.overlap_results.DIF_CHROMS}if(z<x){if(y<x){u=g.overlap_results.BEFORE}else{if(y<w){u=g.overlap_results.OVERLAP_START}else{u=g.overlap_results.CONTAINS}}}else{if(z>x){if(z>w){u=g.overlap_results.AFTER}else{if(y<=w){u=g.overlap_results.CONTAINED_BY}else{u=g.overlap_results.OVERLAP_END}}}else{u=(y>=w?g.overlap_results.CONTAINS:g.overlap_results.CONTAINED_BY)}}return u},trim:function(u){if(this.attributes.start<0){this.attributes.start=0}if(this.attributes.genome){var v=this.attributes.genome.get_chrom_len(this.attributes.chrom);if(this.attributes.end>v){this.attributes.end=v-1}}return this},contains:function(u){return this.compute_overlap(u)===g.overlap_results.CONTAINS},overlaps:function(u){return s.intersection([this.compute_overlap(u)],[g.overlap_results.DIF_CHROMS,g.overlap_results.BEFORE,g.overlap_results.AFTER]).length===0}},{overlap_results:{DIF_CHROMS:1000,BEFORE:1001,CONTAINS:1002,OVERLAP_START:1003,OVERLAP_END:1004,CONTAINED_BY:1005,AFTER:1006}});var m=Backbone.Collection.extend({model:g});var e=Backbone.RelationalModel.extend({defaults:{region:null,note:""},relations:[{type:Backbone.HasOne,key:"region",relatedModel:g}]});var r=Backbone.Collection.extend({model:e});var t=Backbone.RelationalModel.extend({relations:[{type:Backbone.HasOne,key:"dataset",relatedModel:i.Dataset}],initialize:function(u){this.set("config",o.ConfigSettingCollection.from_config_dict(u.prefs));this.get("config").add([{key:"name",value:this.get("name")},{key:"color"}]);var v=this.get("preloaded_data");if(v){v=v.data}else{v=[]}this.set("data_manager",new d({dataset:this.get("dataset"),init_data:v}))}});var n=Backbone.RelationalModel.extend({defaults:{title:"",type:""},url:galaxy_paths.get("visualization_url"),save:function(){return $.ajax({url:this.url(),type:"POST",dataType:"json",data:{vis_json:JSON.stringify(this)}})}});var k=n.extend({defaults:s.extend({},n.prototype.defaults,{dbkey:"",tracks:null,bookmarks:null,viewport:null}),relations:[{type:Backbone.HasMany,key:"tracks",relatedModel:t}],add_tracks:function(u){this.get("tracks").add(u)}});var b=Backbone.Model.extend({});var h=Backbone.Router.extend({initialize:function(v){this.view=v.view;this.route(/([\w]+)$/,"change_location");this.route(/([\w]+\:[\d,]+-[\d,]+)$/,"change_location");var u=this;u.view.on("navigate",function(w){u.navigate(w)})},change_location:function(u){this.view.go_to(u)}});return{BackboneTrack:t,BrowserBookmark:e,BrowserBookmarkCollection:r,Cache:q,CanvasManager:f,Genome:c,GenomeDataManager:d,GenomeRegion:g,GenomeRegionCollection:m,GenomeVisualization:k,GenomeReferenceDataManager:p,TrackBrowserRouter:h,TrackConfig:b,Visualization:n,select_datasets:a}});
\ No newline at end of file
diff -r b6a6fc1a7d4112026beb5de34f627f7848860d4f -r a5c3090f1701d73d4db190141d054617bbe45af5 static/scripts/viz/visualization.js
--- a/static/scripts/viz/visualization.js
+++ b/static/scripts/viz/visualization.js
@@ -120,49 +120,75 @@
});
/**
- * Generic cache that handles key/value pairs.
+ * Generic cache that handles key/value pairs. Keys can be any object that can be
+ * converted to a String and compared.
*/
var Cache = Backbone.Model.extend({
defaults: {
num_elements: 20,
+ // Objects in cache; indexes into cache are strings of keys.
obj_cache: null,
+ // key_ary contains keys for objects in cache.
key_ary: null
},
initialize: function(options) {
this.clear();
},
-
+
+ /**
+ * Get an element from the cache using its key.
+ */
get_elt: function(key) {
var obj_cache = this.attributes.obj_cache,
key_ary = this.attributes.key_ary,
- index = key_ary.indexOf(key);
+ key_str = key.toString(),
+ index = _.indexOf(key_ary, function(k) {
+ return k.toString() === key_str;
+ });
+
+ // Update cache.
if (index !== -1) {
- if (obj_cache[key].stale) {
- // Object is stale, so remove key and object.
+ // Object is in cache, so update it.
+ if (obj_cache[key_str].stale) {
+ // Object is stale: remove key and object.
key_ary.splice(index, 1);
- delete obj_cache[key];
+ delete obj_cache[key_str];
}
else {
+ // Move key to back because it is most recently used.
this.move_key_to_end(key, index);
}
}
- return obj_cache[key];
+
+ return obj_cache[key_str];
},
+ /**
+ * Put an element into the cache.
+ */
set_elt: function(key, value) {
var obj_cache = this.attributes.obj_cache,
key_ary = this.attributes.key_ary,
+ key_str = key.toString(),
num_elements = this.attributes.num_elements;
- if (!obj_cache[key]) {
+
+ // Update keys, objects.
+ if (!obj_cache[key_str]) {
+ // Add object to cache.
+
if (key_ary.length >= num_elements) {
- // Remove first element
+ // Cache full, so remove first element.
var deleted_key = key_ary.shift();
- delete obj_cache[deleted_key];
+ delete obj_cache[deleted_key.toString()];
}
+
+ // Add key.
key_ary.push(key);
}
- obj_cache[key] = value;
+
+ // Add object.
+ obj_cache[key_str] = value;
return value;
},
@@ -346,20 +372,19 @@
//
var key_ary = this.get('key_ary'),
obj_cache = this.get('obj_cache'),
- key, entry_region, is_subregion;
+ entry_region, is_subregion;
for (var i = 0; i < key_ary.length; i++) {
- key = key_ary[i];
- entry_region = new GenomeRegion({from_str: key});
-
+ entry_region = key_ary[i];
+
if (entry_region.contains(region)) {
is_subregion = true;
// This entry has data in the requested range. Return if data
// is compatible and can be subsetted.
- entry = obj_cache[key];
+ entry = obj_cache[entry_region.toString()];
if ( is_deferred(entry) ||
( this.get('data_mode_compatible')(entry, mode) && this.get('can_subset')(entry) ) ) {
- this.move_key_to_end(key, i);
+ this.move_key_to_end(entry_region, i);
// If there's data, subset it.
if ( !is_deferred(entry) ) {
@@ -383,7 +408,7 @@
// below.
// Use heuristic to extend region: extend relative to last data request.
- var last_request = new GenomeRegion({from_str: this.most_recently_added()});
+ var last_request = this.most_recently_added();
if (!last_request || (region.get('start') > last_request.get('start'))) {
// This request is after the last request, so extend right.
region.set('end', region.get('start') + this.attributes.min_region_size);
@@ -586,20 +611,6 @@
data: subregion_data,
dataset_type: entry.dataset_type
};
- },
-
- /**
- * Get data from the cache.
- */
- get_elt: function(region) {
- return Cache.prototype.get_elt.call(this, region.toString());
- },
-
- /**
- * Sets data in the cache.
- */
- set_elt: function(region, result) {
- return Cache.prototype.set_elt.call(this, region.toString(), result);
}
});
@@ -671,6 +682,7 @@
chrom: null,
start: 0,
end: 0,
+ str_val: null,
genome: null
},
@@ -698,6 +710,9 @@
end: parseInt(start_end[1], 10)
});
}
+
+ // Keep a copy of region's string value for fast lookup.
+ this.attributes.str_val = this.get('chrom') + ":" + this.get('start') + "-" + this.get('end');
},
copy: function() {
@@ -714,7 +729,7 @@
/** Returns region in canonical form chrom:start-end */
toString: function() {
- return this.get('chrom') + ":" + this.get('start') + "-" + this.get('end');
+ return this.attributes.str_val;
},
toJSON: function() {
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/galaxy-central: greg: Fix for setting Galaxy's time interval for checking for updates available for install tool shed repositories.
by commits-noreply@bitbucket.org 12 Jun '13
by commits-noreply@bitbucket.org 12 Jun '13
12 Jun '13
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/b6a6fc1a7d41/
Changeset: b6a6fc1a7d41
User: greg
Date: 2013-06-12 20:30:21
Summary: Fix for setting Galaxy's time interval for checking for updates available for install tool shed repositories.
Affected #: 1 file
diff -r b4a373d86c513b542abbedeacfbbab6d5b962379 -r b6a6fc1a7d4112026beb5de34f627f7848860d4f lib/galaxy/config.py
--- a/lib/galaxy/config.py
+++ b/lib/galaxy/config.py
@@ -73,17 +73,21 @@
self.tool_data_table_config_path = resolve_path( kwargs.get( 'tool_data_table_config_path', 'tool_data_table_conf.xml' ), self.root )
self.shed_tool_data_table_config = resolve_path( kwargs.get( 'shed_tool_data_table_config', 'shed_tool_data_table_conf.xml' ), self.root )
self.enable_tool_shed_check = string_as_bool( kwargs.get( 'enable_tool_shed_check', False ) )
+ self.hours_between_check = kwargs.get( 'hours_between_check', 12 )
try:
- self.hours_between_check = kwargs.get( 'hours_between_check', 12 )
- if isinstance( self.hours_between_check, float ):
+ hbc_test = int( self.hours_between_check )
+ self.hours_between_check = hbc_test
+ if self.hours_between_check < 1 or self.hours_between_check > 24:
+ self.hours_between_check = 12
+ except:
+ try:
# Float values are supported for functional tests.
+ hbc_test = float( self.hours_between_check )
+ self.hours_between_check = hbc_test
if self.hours_between_check < 0.001 or self.hours_between_check > 24.0:
self.hours_between_check = 12.0
- else:
- if self.hours_between_check < 1 or self.hours_between_check > 24:
- self.hours_between_check = 12
- except:
- self.hours_between_check = 12
+ except:
+ self.hours_between_check = 12
self.update_integrated_tool_panel = kwargs.get( "update_integrated_tool_panel", True )
self.enable_data_manager_user_view = string_as_bool( kwargs.get( "enable_data_manager_user_view", "False" ) )
self.data_manager_config_file = resolve_path( kwargs.get('data_manager_config_file', 'data_manager_conf.xml' ), self.root )
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/galaxy-central: greg: Add targets to Repository Actions menu items.
by commits-noreply@bitbucket.org 12 Jun '13
by commits-noreply@bitbucket.org 12 Jun '13
12 Jun '13
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/b4a373d86c51/
Changeset: b4a373d86c51
User: greg
Date: 2013-06-12 17:48:09
Summary: Add targets to Repository Actions menu items.
Affected #: 1 file
diff -r 471484ff8be60229e17f289a7b8cc3e868f95eb0 -r b4a373d86c513b542abbedeacfbbab6d5b962379 templates/webapps/tool_shed/common/repository_actions_menu.mako
--- a/templates/webapps/tool_shed/common/repository_actions_menu.mako
+++ b/templates/webapps/tool_shed/common/repository_actions_menu.mako
@@ -126,52 +126,52 @@
<ul class="manage-table-actions">
%if is_new:
%if can_upload:
- <a class="action-button" href="${h.url_for( controller='upload', action='upload', repository_id=trans.security.encode_id( repository.id ) )}">Upload files to repository</a>
+ <a class="action-button" target="galaxy_main" href="${h.url_for( controller='upload', action='upload', repository_id=trans.security.encode_id( repository.id ) )}">Upload files to repository</a>
%endif
%if can_undeprecate:
- <a class="action-button" href="${h.url_for( controller='repository', action='deprecate', id=trans.security.encode_id( repository.id ), mark_deprecated=False )}">Mark repository as not deprecated</a>
+ <a class="action-button" target="galaxy_main" href="${h.url_for( controller='repository', action='deprecate', id=trans.security.encode_id( repository.id ), mark_deprecated=False )}">Mark repository as not deprecated</a>
%endif
%else:
<li><a class="action-button" id="repository-${repository.id}-popup" class="menubutton">Repository Actions</a></li><div popupmenu="repository-${repository.id}-popup">
%if can_review_repository:
%if reviewed_by_user:
- <a class="action-button" href="${h.url_for( controller='repository_review', action='edit_review', id=review_id )}">Manage my review of this revision</a>
+ <a class="action-button" target="galaxy_main" href="${h.url_for( controller='repository_review', action='edit_review', id=review_id )}">Manage my review of this revision</a>
%else:
- <a class="action-button" href="${h.url_for( controller='repository_review', action='create_review', id=trans.app.security.encode_id( repository.id ), changeset_revision=changeset_revision )}">Add a review to this revision</a>
+ <a class="action-button" target="galaxy_main" href="${h.url_for( controller='repository_review', action='create_review', id=trans.app.security.encode_id( repository.id ), changeset_revision=changeset_revision )}">Add a review to this revision</a>
%endif
%endif
%if can_browse_reviews:
- <a class="action-button" href="${h.url_for( controller='repository_review', action='manage_repository_reviews', id=trans.app.security.encode_id( repository.id ) )}">Browse reviews of this repository</a>
+ <a class="action-button" target="galaxy_main" href="${h.url_for( controller='repository_review', action='manage_repository_reviews', id=trans.app.security.encode_id( repository.id ) )}">Browse reviews of this repository</a>
%endif
%if can_upload:
- <a class="action-button" href="${h.url_for( controller='upload', action='upload', repository_id=trans.security.encode_id( repository.id ) )}">Upload files to repository</a>
+ <a class="action-button" target="galaxy_main" href="${h.url_for( controller='upload', action='upload', repository_id=trans.security.encode_id( repository.id ) )}">Upload files to repository</a>
%endif
%if can_manage:
- <a class="action-button" href="${h.url_for( controller='repository', action='manage_repository', id=trans.app.security.encode_id( repository.id ), changeset_revision=repository.tip( trans.app ) )}">Manage repository</a>
+ <a class="action-button" target="galaxy_main" href="${h.url_for( controller='repository', action='manage_repository', id=trans.app.security.encode_id( repository.id ), changeset_revision=repository.tip( trans.app ) )}">Manage repository</a>
%else:
- <a class="action-button" href="${h.url_for( controller='repository', action='view_repository', id=trans.app.security.encode_id( repository.id ), changeset_revision=repository.tip( trans.app ) )}">View repository</a>
+ <a class="action-button" target="galaxy_main" href="${h.url_for( controller='repository', action='view_repository', id=trans.app.security.encode_id( repository.id ), changeset_revision=repository.tip( trans.app ) )}">View repository</a>
%endif
%if can_view_change_log:
- <a class="action-button" href="${h.url_for( controller='repository', action='view_changelog', id=trans.app.security.encode_id( repository.id ) )}">View change log</a>
+ <a class="action-button" target="galaxy_main" href="${h.url_for( controller='repository', action='view_changelog', id=trans.app.security.encode_id( repository.id ) )}">View change log</a>
%endif
%if can_browse_contents:
- <a class="action-button" href="${h.url_for( controller='repository', action='browse_repository', id=trans.app.security.encode_id( repository.id ) )}">${browse_label | h}</a>
+ <a class="action-button" target="galaxy_main" href="${h.url_for( controller='repository', action='browse_repository', id=trans.app.security.encode_id( repository.id ) )}">${browse_label | h}</a>
%endif
%if can_rate:
- <a class="action-button" href="${h.url_for( controller='repository', action='rate_repository', id=trans.app.security.encode_id( repository.id ) )}">Rate repository</a>
+ <a class="action-button" target="galaxy_main" href="${h.url_for( controller='repository', action='rate_repository', id=trans.app.security.encode_id( repository.id ) )}">Rate repository</a>
%endif
%if can_contact_owner:
- <a class="action-button" href="${h.url_for( controller='repository', action='contact_owner', id=trans.security.encode_id( repository.id ) )}">Contact repository owner</a>
+ <a class="action-button" target="galaxy_main" href="${h.url_for( controller='repository', action='contact_owner', id=trans.security.encode_id( repository.id ) )}">Contact repository owner</a>
%endif
%if can_reset_all_metadata:
- <a class="action-button" href="${h.url_for( controller='repository', action='reset_all_metadata', id=trans.security.encode_id( repository.id ) )}">Reset all repository metadata</a>
+ <a class="action-button" target="galaxy_main" href="${h.url_for( controller='repository', action='reset_all_metadata', id=trans.security.encode_id( repository.id ) )}">Reset all repository metadata</a>
%endif
%if can_deprecate:
- <a class="action-button" href="${h.url_for( controller='repository', action='deprecate', id=trans.security.encode_id( repository.id ), mark_deprecated=True )}" confirm="Click Ok to deprecate this repository.">Mark repository as deprecated</a>
+ <a class="action-button" target="galaxy_main" href="${h.url_for( controller='repository', action='deprecate', id=trans.security.encode_id( repository.id ), mark_deprecated=True )}" confirm="Click Ok to deprecate this repository.">Mark repository as deprecated</a>
%endif
%if can_undeprecate:
- <a class="action-button" href="${h.url_for( controller='repository', action='deprecate', id=trans.security.encode_id( repository.id ), mark_deprecated=False )}">Mark repository as not deprecated</a>
+ <a class="action-button" target="galaxy_main" href="${h.url_for( controller='repository', action='deprecate', id=trans.security.encode_id( repository.id ), mark_deprecated=False )}">Mark repository as not deprecated</a>
%endif
%if can_download:
<a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), changeset_revision=repository.tip( trans.app ), file_type='gz' )}">Download as a .tar.gz file</a>
@@ -187,18 +187,18 @@
<br/><br/><ul class="manage-table-actions">
%if repository:
- <li><a class="action-button" href="${h.url_for( controller='repository', action='install_repositories_by_revision', repository_ids=trans.security.encode_id( repository.id ), changeset_revisions=changeset_revision )}">Install to Galaxy</a></li>
- <li><a class="action-button" href="${h.url_for( controller='repository', action='preview_tools_in_changeset', repository_id=trans.security.encode_id( repository.id ), changeset_revision=changeset_revision )}">Browse repository</a></li>
+ <li><a class="action-button" target="galaxy_main" href="${h.url_for( controller='repository', action='install_repositories_by_revision', repository_ids=trans.security.encode_id( repository.id ), changeset_revisions=changeset_revision )}">Install to Galaxy</a></li>
+ <li><a class="action-button" target="galaxy_main" href="${h.url_for( controller='repository', action='preview_tools_in_changeset', repository_id=trans.security.encode_id( repository.id ), changeset_revision=changeset_revision )}">Browse repository</a></li><li><a class="action-button" id="repository-${repository.id}-popup" class="menubutton">Tool Shed Actions</a></li><div popupmenu="repository-${repository.id}-popup">
- <a class="action-button" href="${h.url_for( controller='repository', action='browse_valid_categories' )}">Browse valid repositories</a>
- <a class="action-button" href="${h.url_for( controller='repository', action='find_tools' )}">Search for valid tools</a>
- <a class="action-button" href="${h.url_for( controller='repository', action='find_workflows' )}">Search for workflows</a>
+ <a class="action-button" target="galaxy_main" href="${h.url_for( controller='repository', action='browse_valid_categories' )}">Browse valid repositories</a>
+ <a class="action-button" target="galaxy_main" href="${h.url_for( controller='repository', action='find_tools' )}">Search for valid tools</a>
+ <a class="action-button" target="galaxy_main" href="${h.url_for( controller='repository', action='find_workflows' )}">Search for workflows</a></div>
%else:
- <li><a class="action-button" href="${h.url_for( controller='repository', action='browse_valid_categories' )}">Browse valid repositories</a></li>
- <a class="action-button" href="${h.url_for( controller='repository', action='find_tools' )}">Search for valid tools</a>
- <li><a class="action-button" href="${h.url_for( controller='repository', action='find_workflows' )}">Search for workflows</a></li>
+ <li><a class="action-button" target="galaxy_main" href="${h.url_for( controller='repository', action='browse_valid_categories' )}">Browse valid repositories</a></li>
+ <a class="action-button" target="galaxy_main" href="${h.url_for( controller='repository', action='find_tools' )}">Search for valid tools</a>
+ <li><a class="action-button" target="galaxy_main" href="${h.url_for( controller='repository', action='find_workflows' )}">Search for workflows</a></li>
%endif
</ul></%def>
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/galaxy-central: dannon: For user impersonation, fully log the admin out prior to assuming user persona to avoid any history/session corruption.
by commits-noreply@bitbucket.org 12 Jun '13
by commits-noreply@bitbucket.org 12 Jun '13
12 Jun '13
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/9d42f1e32efb/
Changeset: 9d42f1e32efb
Branch: stable
User: dannon
Date: 2013-06-12 16:39:09
Summary: For user impersonation, fully log the admin out prior to assuming user persona to avoid any history/session corruption.
Affected #: 1 file
diff -r e79a60e7c67a68279c2c976ada9ddaa1095fadb4 -r 9d42f1e32efb654fda1e011dc66a4aa5888717f1 lib/galaxy/webapps/galaxy/controllers/admin.py
--- a/lib/galaxy/webapps/galaxy/controllers/admin.py
+++ b/lib/galaxy/webapps/galaxy/controllers/admin.py
@@ -682,7 +682,8 @@
if email is not None:
user = trans.sa_session.query( trans.app.model.User ).filter_by( email=email ).first()
if user:
- trans.set_user( user )
+ trans.handle_user_logout()
+ trans.handle_user_login(user)
message = 'You are now logged in as %s, <a target="_top" href="%s">return to the home page</a>' % ( email, url_for( controller='root' ) )
emails = []
else:
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/galaxy-central: dannon: For user impersonation, fully log the admin out prior to assuming user persona to avoid any history/session corruption.
by commits-noreply@bitbucket.org 12 Jun '13
by commits-noreply@bitbucket.org 12 Jun '13
12 Jun '13
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/471484ff8be6/
Changeset: 471484ff8be6
User: dannon
Date: 2013-06-12 16:39:09
Summary: For user impersonation, fully log the admin out prior to assuming user persona to avoid any history/session corruption.
Affected #: 1 file
diff -r eb89d0a2fe4426888a7589b8a4e9906269bd4fbc -r 471484ff8be60229e17f289a7b8cc3e868f95eb0 lib/galaxy/webapps/galaxy/controllers/admin.py
--- a/lib/galaxy/webapps/galaxy/controllers/admin.py
+++ b/lib/galaxy/webapps/galaxy/controllers/admin.py
@@ -682,7 +682,8 @@
if email is not None:
user = trans.sa_session.query( trans.app.model.User ).filter_by( email=email ).first()
if user:
- trans.set_user( user )
+ trans.handle_user_logout()
+ trans.handle_user_login(user)
message = 'You are now logged in as %s, <a target="_top" href="%s">return to the home page</a>' % ( email, url_for( controller='root' ) )
emails = []
else:
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/galaxy-central: carlfeberhard: scripts/api: Fixes to upload_to_history.py
by commits-noreply@bitbucket.org 12 Jun '13
by commits-noreply@bitbucket.org 12 Jun '13
12 Jun '13
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/eb89d0a2fe44/
Changeset: eb89d0a2fe44
User: carlfeberhard
Date: 2013-06-12 16:35:11
Summary: scripts/api: Fixes to upload_to_history.py
Affected #: 1 file
diff -r 253c49c5b4977a49d2f87ff7729a2fe575c0c355 -r eb89d0a2fe4426888a7589b8a4e9906269bd4fbc scripts/api/upload_to_history.py
--- a/scripts/api/upload_to_history.py
+++ b/scripts/api/upload_to_history.py
@@ -17,7 +17,7 @@
# -----------------------------------------------------------------------------
-def upload_file( full_url, api_key, history_id, filepath, **kwargs ):
+def upload_file( base_url, api_key, history_id, filepath, **kwargs ):
full_url = base_url + '/api/tools'
payload = {
@@ -33,7 +33,7 @@
'dbkey' : '?',
'file_type' : kwargs.get( 'file_type', 'auto' ),
'ajax_upload' : u'true',
- 'async_datasets': '1',
+ #'async_datasets': '1',
}
payload[ 'inputs' ] = json.dumps( inputs )
@@ -41,7 +41,7 @@
with open( filepath, 'rb' ) as file_to_upload:
files = { 'files_0|file_data' : file_to_upload }
response = requests.post( full_url, data=payload, files=files )
- return response
+ return response.json()
# -----------------------------------------------------------------------------
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0