commit/galaxy-central: 2 new changesets
2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/c1e85a294a6e/ changeset: c1e85a294a6e user: rmarenco date: 2012-07-17 23:12:51 summary: eXpress tool wrapped in Galaxy. Added in "NGS: RNA Analysis". affected #: 6 files Diff too large to display. https://bitbucket.org/galaxy/galaxy-central/changeset/58c24c93bc9a/ changeset: 58c24c93bc9a user: rmarenco date: 2012-07-18 16:48:59 summary: Merge Hg: changed lib/galaxy/datatypes/converters/sam_or_bam_to_summary_tree_converter.py affected #: 39 files diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c lib/galaxy/datatypes/converters/interval_to_summary_tree_converter.py --- a/lib/galaxy/datatypes/converters/interval_to_summary_tree_converter.py +++ b/lib/galaxy/datatypes/converters/interval_to_summary_tree_converter.py @@ -49,7 +49,7 @@ end_col=end_col, strand_col=strand_col, fix_strand=True ) - st = SummaryTree(block_size=25, levels=6, draw_cutoff=150, detail_cutoff=30) + st = SummaryTree() for feature in list( reader_wrapper ): if isinstance( feature, GenomicInterval ): # Tree expects BED coordinates. diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c lib/galaxy/datatypes/converters/sam_or_bam_to_summary_tree_converter.py --- a/lib/galaxy/datatypes/converters/sam_or_bam_to_summary_tree_converter.py +++ b/lib/galaxy/datatypes/converters/sam_or_bam_to_summary_tree_converter.py @@ -32,7 +32,7 @@ out_fname = args[1] samfile = csamtools.Samfile( filename=input_fname, mode='r' ) - st = SummaryTree(block_size=25, levels=6, draw_cutoff=150, detail_cutoff=30) + st = SummaryTree() for read in samfile.fetch(): st.insert_range( samfile.getrname( read.rname ), read.pos, read.pos + read.rlen ) diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c lib/galaxy/datatypes/converters/vcf_to_summary_tree_converter.py --- a/lib/galaxy/datatypes/converters/vcf_to_summary_tree_converter.py +++ b/lib/galaxy/datatypes/converters/vcf_to_summary_tree_converter.py @@ -18,7 +18,7 @@ in_file, out_file = args # Do conversion. - st = SummaryTree(block_size=25, levels=6, draw_cutoff=150, detail_cutoff=30) + st = SummaryTree() for line in list( galaxy_utils.sequence.vcf.Reader( open( in_file ) ) ): # VCF format provides a chrom and 1-based position for each variant. # SummaryTree expects 0-based coordinates. diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c lib/galaxy/jobs/splitters/basic.py --- a/lib/galaxy/jobs/splitters/basic.py +++ b/lib/galaxy/jobs/splitters/basic.py @@ -15,9 +15,9 @@ # add in the missing information for splitting the one input and merging the one output set_basic_defaults(job_wrapper) return multi.do_split(job_wrapper) - + def do_merge( job_wrapper, task_wrappers): # add in the missing information for splitting the one input and merging the one output set_basic_defaults(job_wrapper) return multi.do_merge(job_wrapper, task_wrappers) - + diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c lib/galaxy/jobs/splitters/multi.py --- a/lib/galaxy/jobs/splitters/multi.py +++ b/lib/galaxy/jobs/splitters/multi.py @@ -3,13 +3,13 @@ log = logging.getLogger( __name__ ) - + def do_split (job_wrapper): parent_job = job_wrapper.get_job() working_directory = os.path.abspath(job_wrapper.working_directory) parallel_settings = job_wrapper.tool.parallelism.attributes - # Syntax: split_inputs="input1,input2" shared_inputs="genome" + # Syntax: split_inputs="input1,input2" shared_inputs="genome" # Designates inputs to be split or shared split_inputs=parallel_settings.get("split_inputs") if split_inputs is None: @@ -25,7 +25,7 @@ illegal_inputs = [x for x in shared_inputs if x in split_inputs] if len(illegal_inputs) > 0: raise Exception("Inputs have conflicting parallelism attributes: %s" % str( illegal_inputs )) - + subdir_index = [0] # use a list to get around Python 2.x lame closure support task_dirs = [] def get_new_working_directory_name(): @@ -35,7 +35,7 @@ os.makedirs(dir) task_dirs.append(dir) return dir - + # For things like paired end alignment, we need two inputs to be split. Since all inputs to all # derived subtasks need to be correlated, allow only one input type to be split type_to_input_map = {} @@ -53,7 +53,7 @@ log_error = "The multi splitter does not support splitting inputs of more than one type" log.error(log_error) raise Exception(log_error) - + # split the first one to build up the task directories input_datasets = [] for input in parent_job.input_datasets: @@ -64,7 +64,7 @@ log.error(log_error) raise Exception(log_error) input_datasets.append(input.dataset) - + input_type = type_to_input_map.keys()[0] # DBTODO execute an external task to do the splitting, this should happen at refactor. # If the number of tasks is sufficiently high, we can use it to calculate job completion % and give a running status. @@ -88,10 +88,9 @@ task = model.Task(parent_job, dir, prepare_files % dir) tasks.append(task) return tasks - + def do_merge( job_wrapper, task_wrappers): - parent_job = job_wrapper.get_job() parallel_settings = job_wrapper.tool.parallelism.attributes # Syntax: merge_outputs="export" pickone_outputs="genomesize" # Designates outputs to be merged, or selected from as a representative @@ -105,14 +104,14 @@ pickone_outputs = [] else: pickone_outputs = [x.strip() for x in pickone_outputs.split(",")] - + illegal_outputs = [x for x in merge_outputs if x in pickone_outputs] if len(illegal_outputs) > 0: return ('Tool file error', 'Outputs have conflicting parallelism attributes: %s' % str( illegal_outputs )) - + stdout = '' stderr = '' - + try: working_directory = job_wrapper.working_directory task_dirs = [os.path.join(working_directory, x) for x in os.listdir(working_directory) if x.startswith('task_')] @@ -120,6 +119,7 @@ outputs = job_wrapper.get_output_hdas_and_fnames() pickone_done = [] task_dirs = [os.path.join(working_directory, x) for x in os.listdir(working_directory) if x.startswith('task_')] + task_dirs.sort(key = lambda x: int(x.split('task_')[-1])) for output in outputs: output_file_name = str(outputs[output][1]) base_output_name = os.path.basename(output_file_name) @@ -144,7 +144,6 @@ stdout = 'Error merging files'; log.exception( stdout ) stderr = str(e) - for tw in task_wrappers: # Prevent repetitive output, e.g. "Sequence File Aligned"x20 diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c lib/galaxy/tool_shed/install_manager.py --- a/lib/galaxy/tool_shed/install_manager.py +++ b/lib/galaxy/tool_shed/install_manager.py @@ -138,7 +138,7 @@ self.app.sa_session.flush() if 'tool_dependencies' in metadata_dict: # All tool_dependency objects must be created before the tools are processed even if no tool dependencies will be installed. - tool_dependencies = create_tool_dependency_objects( self.app, tool_shed_repository, tool_shed_repository.installed_changeset_revision ) + tool_dependencies = create_tool_dependency_objects( self.app, tool_shed_repository, tool_shed_repository.installed_changeset_revision, set_status=True ) else: tool_dependencies = None if 'tools' in metadata_dict: diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c lib/galaxy/tool_shed/tool_dependencies/install_util.py --- a/lib/galaxy/tool_shed/tool_dependencies/install_util.py +++ b/lib/galaxy/tool_shed/tool_dependencies/install_util.py @@ -11,13 +11,14 @@ from elementtree import ElementTree, ElementInclude from elementtree.ElementTree import Element, SubElement -def create_or_update_tool_dependency( app, tool_shed_repository, name, version, type, status ): +def create_or_update_tool_dependency( app, tool_shed_repository, name, version, type, status, set_status=True ): # Called from Galaxy (never the tool shed) when a new repository is being installed or when an uninstalled repository is being reinstalled. sa_session = app.model.context.current # First see if an appropriate tool_dependency record exists for the received tool_shed_repository. tool_dependency = get_tool_dependency_by_name_version_type_repository( app, tool_shed_repository, name, version, type ) if tool_dependency: - tool_dependency.status = status + if set_status: + tool_dependency.status = status else: # Create a new tool_dependency record for the tool_shed_repository. tool_dependency = app.model.ToolDependency( tool_shed_repository.id, name, version, type, status ) @@ -59,7 +60,8 @@ name=package_name, version=package_version, type='package', - status=app.model.ToolDependency.installation_status.INSTALLING ) + status=app.model.ToolDependency.installation_status.INSTALLING, + set_status=True ) if package_install_version == '1.0': # Handle tool dependency installation using a fabric method included in the Galaxy framework. for actions_elem in package_elem: @@ -81,6 +83,10 @@ # print 'Installing tool dependencies via fabric script ', proprietary_fabfile_path else: print '\nSkipping installation of tool dependency', package_name, 'version', package_version, 'since it is installed in', install_dir, '\n' + tool_dependency = get_tool_dependency_by_name_version_type_repository( app, tool_shed_repository, package_name, package_version, 'package' ) + tool_dependency.status = app.model.ToolDependency.installation_status.INSTALLED + sa_session.add( tool_dependency ) + sa_session.flush() return tool_dependency def install_via_fabric( app, tool_dependency, actions_elem, install_dir, package_name=None, proprietary_fabfile_path=None, **kwd ): """Parse a tool_dependency.xml file's <actions> tag set to gather information for the installation via fabric.""" diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c lib/galaxy/util/shed_util.py --- a/lib/galaxy/util/shed_util.py +++ b/lib/galaxy/util/shed_util.py @@ -380,7 +380,7 @@ sa_session.add( tool_shed_repository ) sa_session.flush() return tool_shed_repository -def create_tool_dependency_objects( app, tool_shed_repository, current_changeset_revision ): +def create_tool_dependency_objects( app, tool_shed_repository, current_changeset_revision, set_status=True ): # Create or update a ToolDependency for each entry in tool_dependencies_config. This method is called when installing a new tool_shed_repository. tool_dependency_objects = [] work_dir = make_tmp_directory() @@ -404,7 +404,8 @@ name=package_name, version=package_version, type='package', - status=app.model.ToolDependency.installation_status.NEVER_INSTALLED ) + status=app.model.ToolDependency.installation_status.NEVER_INSTALLED, + set_status=set_status ) tool_dependency_objects.append( tool_dependency ) try: shutil.rmtree( work_dir ) @@ -1210,6 +1211,8 @@ ElementInclude.include( root ) fabric_version_checked = False for elem in root: + # Only install the package if it is not already installed. + can_install = False if elem.tag == 'package': package_name = elem.get( 'name', None ) package_version = elem.get( 'version', None ) @@ -1217,8 +1220,6 @@ # The value of tool_dependencies will be None only when this method is called by the InstallManager. In that case, tool # dependency installation is not ajaxian, so the ToolDependency objects do not yet exist. if tool_dependencies: - # Only install the package if it is not already installed. - can_install = False for tool_dependency in tool_dependencies: if tool_dependency.name==package_name and tool_dependency.version==package_version: can_install = tool_dependency.status in [ app.model.ToolDependency.installation_status.NEVER_INSTALLED, @@ -1457,6 +1458,7 @@ log.debug( error_message ) if removed: tool_dependency.status = trans.model.ToolDependency.installation_status.UNINSTALLED + tool_dependency.error_message = None trans.sa_session.add( tool_dependency ) trans.sa_session.flush() return removed, error_message diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c lib/galaxy/visualization/tracks/data_providers.py --- a/lib/galaxy/visualization/tracks/data_providers.py +++ b/lib/galaxy/visualization/tracks/data_providers.py @@ -621,13 +621,13 @@ """ dataset_summary = [] for chrom_info in chroms_info[ 'chrom_info' ]: - summary = self.get_summary( chrom_info[ 'chrom' ], 0, chrom_info[ 'len' ], level=4 ) + summary = self.get_summary( chrom_info[ 'chrom' ], 0, chrom_info[ 'len' ], level=3, detail_cutoff=0, draw_cutoff=0 ) dataset_summary.append( summary ) return dataset_summary # TODO: rename to get_data to match other providers. - def get_summary( self, chrom, start, end, level=None, resolution=None ): + def get_summary( self, chrom, start, end, level=None, resolution=None, detail_cutoff=None, draw_cutoff=None ): """ Returns summary tree data for a given genomic region. """ @@ -663,7 +663,7 @@ # Use level to get results. stats = st.chrom_stats[ chrom ] - results = st.query( chrom, int(start), int(end), level ) + results = st.query( chrom, int(start), int(end), level, detail_cutoff=detail_cutoff, draw_cutoff=draw_cutoff ) if results == "detail" or results == "draw": return results else: diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c lib/galaxy/visualization/tracks/summary.py --- a/lib/galaxy/visualization/tracks/summary.py +++ b/lib/galaxy/visualization/tracks/summary.py @@ -11,7 +11,7 @@ MIN_LEVEL = 2 class SummaryTree: - def __init__( self, block_size, levels, draw_cutoff, detail_cutoff ): + def __init__( self, block_size=25, levels=6, draw_cutoff=150, detail_cutoff=30 ): self.chrom_blocks = {} self.levels = levels self.draw_cutoff = draw_cutoff @@ -47,38 +47,46 @@ block_level[ block ] = 1 def finish( self ): - """ Checks for cutoff and only stores levels above it """ + """ Compute stats for levels. """ - # TODO: not storing all counts is lossy. To fix, store all counts - # and then dynamically set draw/detail level either on load or - # use cutoffs in query function. for chrom, blocks in self.chrom_blocks.iteritems(): - cur_best = 999 - for level in range( self.levels, MIN_LEVEL-1, -1 ): + for level in range( self.levels, MIN_LEVEL - 1, -1 ): + # Set level's stats. max_val = max( blocks[ level ].values() ) - if max_val < self.draw_cutoff: - if "draw_level" not in self.chrom_stats[ chrom ]: - self.chrom_stats[ chrom ][ "draw_level" ] = level - elif max_val < self.detail_cutoff: - self.chrom_stats[ chrom ][ "detail_level" ] = level - break - else: - self.chrom_stats[ chrom ][ level ] = {} - self.chrom_stats[ chrom ][ level ][ "delta" ] = self.block_size ** level - self.chrom_stats[ chrom ][ level ][ "max" ] = max_val - self.chrom_stats[ chrom ][ level ][ "avg" ] = float( max_val ) / len( blocks[ level ] ) - cur_best = level + self.chrom_stats[ chrom ][ level ] = {} + self.chrom_stats[ chrom ][ level ][ "delta" ] = self.block_size ** level + self.chrom_stats[ chrom ][ level ][ "max" ] = max_val + self.chrom_stats[ chrom ][ level ][ "avg" ] = float( max_val ) / len( blocks[ level ] ) - self.chrom_blocks[ chrom ] = dict( [ ( key, value ) for key, value in blocks.iteritems() if key >= cur_best ] ) + self.chrom_blocks[ chrom ] = dict( [ ( key, value ) for key, value in blocks.iteritems() ] ) - def query( self, chrom, start, end, level ): + def query( self, chrom, start, end, level, draw_cutoff=None, detail_cutoff=None ): """ Queries tree for data. """ + + # Set cutoffs to self's attributes if not defined. + if draw_cutoff != 0: + draw_cutoff = self.draw_cutoff + if detail_cutoff != 0: + detail_cutoff = self.detail_cutoff + + # Get data. if chrom in self.chrom_blocks: stats = self.chrom_stats[ chrom ] + + # For backwards compatibility: if "detail_level" in stats and level <= stats[ "detail_level" ]: return "detail" elif "draw_level" in stats and level <= stats[ "draw_level" ]: return "draw" + + # If below draw, detail level, return string to denote this. + max = stats[ level ][ "max" ] + if max < detail_cutoff: + return "detail" + if max < draw_cutoff: + return "draw" + + # Return block data. blocks = self.chrom_blocks[ chrom ] results = [] multiplier = self.block_size ** level diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c lib/galaxy/web/controllers/admin_toolshed.py --- a/lib/galaxy/web/controllers/admin_toolshed.py +++ b/lib/galaxy/web/controllers/admin_toolshed.py @@ -437,6 +437,7 @@ tool_shed_repository.deleted = True if remove_from_disk_checked: tool_shed_repository.status = trans.model.ToolShedRepository.installation_status.UNINSTALLED + tool_shed_repository.error_message = None else: tool_shed_repository.status = trans.model.ToolShedRepository.installation_status.DEACTIVATED trans.sa_session.add( tool_shed_repository ) @@ -607,6 +608,7 @@ tool_section = None for tup in zip( tool_shed_repositories, repo_info_dicts ): tool_shed_repository, repo_info_dict = tup + repo_info_dict = tool_shed_decode( repo_info_dict ) # Clone each repository to the configured location. update_tool_shed_repository_status( trans.app, tool_shed_repository, trans.model.ToolShedRepository.installation_status.CLONING ) repo_info_tuple = repo_info_dict[ tool_shed_repository.name ] @@ -687,7 +689,7 @@ trans.sa_session.add( tool_shed_repository ) trans.sa_session.flush() if 'tool_dependencies' in metadata_dict and not reinstalling: - tool_dependencies = create_tool_dependency_objects( trans.app, tool_shed_repository, tool_shed_repository.installed_changeset_revision ) + tool_dependencies = create_tool_dependency_objects( trans.app, tool_shed_repository, tool_shed_repository.installed_changeset_revision, set_status=True ) if 'tools' in metadata_dict: tool_panel_dict = generate_tool_panel_dict_for_new_install( metadata_dict[ 'tools' ], tool_section ) repository_tools_tups = get_repository_tools_tups( trans.app, metadata_dict ) @@ -943,7 +945,7 @@ @web.expose @web.require_admin def prepare_for_install( self, trans, **kwd ): - if not trans.app.toolbox.shed_tool_confs: + if not have_shed_tool_conf_for_install( trans ): message = 'The <b>tool_config_file</b> setting in <b>universe_wsgi.ini</b> must include at least one shed tool configuration file name with a ' message += '<b><toolbox></b> tag that includes a <b>tool_path</b> attribute value which is a directory relative to the Galaxy installation ' message += 'directory in order to automatically install tools from a Galaxy tool shed (e.g., the file name <b>shed_tool_conf.xml</b> whose ' @@ -1047,7 +1049,7 @@ owner=owner, dist_to_shed=False ) created_or_updated_tool_shed_repositories.append( tool_shed_repository ) - filtered_repo_info_dicts.append( repo_info_dict ) + filtered_repo_info_dicts.append( tool_shed_encode( repo_info_dict ) ) if created_or_updated_tool_shed_repositories: if includes_tools and ( new_tool_panel_section or tool_panel_section ): if new_tool_panel_section: @@ -1126,7 +1128,11 @@ break else: readme_text = '' - install_tool_dependencies_check_box = CheckboxField( 'install_tool_dependencies', checked=True ) + if trans.app.config.tool_dependency_dir is None: + checked = False + else: + checked = True + install_tool_dependencies_check_box = CheckboxField( 'install_tool_dependencies', checked=checked ) return trans.fill_template( '/admin/tool_shed_repository/select_tool_panel_section.mako', encoded_repo_info_dicts=encoded_repo_info_dicts, includes_tools=includes_tools, @@ -1225,6 +1231,7 @@ tool_shed_repository.dist_to_shed ) ctx_rev = get_ctx_rev( tool_shed_url, tool_shed_repository.name, tool_shed_repository.owner, tool_shed_repository.installed_changeset_revision ) repo_info_dict = kwd.get( 'repo_info_dict', None ) + # The repo_info_dict should be encoded. if not repo_info_dict: # This should only happen if the tool_shed_repository does not include any valid tools. repo_info_dict = create_repo_info_dict( tool_shed_repository, @@ -1233,6 +1240,7 @@ tool_shed_repository.installed_changeset_revision, ctx_rev, metadata ) + repo_info_dict = tool_shed_encode( repo_info_dict ) new_kwd = dict( includes_tool_dependencies=tool_shed_repository.includes_tool_dependencies, includes_tools=tool_shed_repository.includes_tools, install_tool_dependencies=install_tool_dependencies, @@ -1340,6 +1348,7 @@ message = "The tools contained in your <b>%s</b> repository were last loaded into the tool panel outside of any sections. " % repository.name message += "Uncheck the <b>No changes</b> check box and select a tool panel section to load the tools into that section." status = 'done' + includes_tool_dependencies = 'tool_dependencies' in metadata install_tool_dependencies_check_box = CheckboxField( 'install_tool_dependencies', checked=True ) return trans.fill_template( '/admin/tool_shed_repository/reselect_tool_panel_section.mako', repository=repository, @@ -1347,7 +1356,8 @@ original_section_name=original_section_name, install_tool_dependencies_check_box=install_tool_dependencies_check_box, tool_panel_section_select_field=tool_panel_section_select_field, - repo_info_dict=tool_shed_encode( repo_info_dict ), + encoded_repo_info_dict=tool_shed_encode( repo_info_dict ), + repo_info_dict=repo_info_dict, includes_tool_dependencies=includes_tool_dependencies, message=message, status=status ) @@ -1479,7 +1489,7 @@ trans.sa_session.flush() # Create tool_dependency records if necessary. if 'tool_dependencies' in metadata_dict: - tool_dependencies = create_tool_dependency_objects( trans.app, repository, repository.changeset_revision ) + tool_dependencies = create_tool_dependency_objects( trans.app, repository, repository.changeset_revision, set_status=False ) message = "The installed repository named '%s' has been updated to change set revision '%s'. " % ( name, latest_changeset_revision ) # See if any tool dependencies can be installed. shed_tool_conf, tool_path, relative_install_dir = get_tool_panel_config_tool_path_install_dir( trans.app, repository ) @@ -1556,3 +1566,13 @@ def get_tool_dependency( trans, id ): """Get a tool_dependency from the database via id""" return trans.sa_session.query( trans.model.ToolDependency ).get( trans.security.decode_id( id ) ) +def have_shed_tool_conf_for_install( trans ): + if not trans.app.toolbox.shed_tool_confs: + return False + migrated_tools_conf_path, migrated_tools_conf_name = os.path.split( trans.app.config.migrated_tools_config ) + for shed_tool_conf_dict in trans.app.toolbox.shed_tool_confs: + shed_tool_conf = shed_tool_conf_dict[ 'config_filename' ] + shed_tool_conf_path, shed_tool_conf_name = os.path.split( shed_tool_conf ) + if shed_tool_conf_name != migrated_tools_conf_name: + return True + return False diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c lib/galaxy/web/controllers/requests_common.py --- a/lib/galaxy/web/controllers/requests_common.py +++ b/lib/galaxy/web/controllers/requests_common.py @@ -104,13 +104,15 @@ if ids is not None and states is not None: ids = map( int, ids.split( "," ) ) states = states.split( "," ) - for id, state in zip( ids, states ): - sample = trans.sa_session.query( self.app.model.Sample ).get( id ) - if sample.state.name != state: - rval[ id ] = { "state": sample.state.name, - "html_state": unicode( trans.fill_template( "requests/common/sample_state.mako", - sample=sample), - 'utf-8' ) } + for tup in zip( ids, states ): + id, state = tup + if id and state: + sample = trans.sa_session.query( self.app.model.Sample ).get( id ) + if sample.state.name != state: + rval[ id ] = { "state": sample.state.name, + "html_state": unicode( trans.fill_template( "requests/common/sample_state.mako", + sample=sample), + 'utf-8' ) } return rval @web.json def sample_datasets_updates( self, trans, ids=None, datasets=None ): @@ -121,14 +123,16 @@ rval = {} if ids is not None and datasets is not None: ids = map( int, ids.split( "," ) ) - number_of_datasets_list = map(int, datasets.split( "," ) ) - for id, number_of_datasets in zip( ids, number_of_datasets_list ): - sample = trans.sa_session.query( self.app.model.Sample ).get( id ) - if len(sample.datasets) != number_of_datasets: - rval[ id ] = { "datasets": len( sample.datasets ), - "html_datasets": unicode( trans.fill_template( "requests/common/sample_datasets.mako", - sample=sample), - 'utf-8' ) } + number_of_datasets_list = map( int, datasets.split( "," ) ) + for tup in zip( ids, number_of_datasets_list ): + id, number_of_datasets = tup + if id and number_of_datasets: + sample = trans.sa_session.query( self.app.model.Sample ).get( id ) + if len( sample.datasets ) != number_of_datasets: + rval[ id ] = { "datasets": len( sample.datasets ), + "html_datasets": unicode( trans.fill_template( "requests/common/sample_datasets.mako", + sample=sample), + 'utf-8' ) } return rval @web.json def dataset_transfer_status_updates( self, trans, ids=None, transfer_status_list=None ): @@ -140,13 +144,15 @@ if ids is not None and transfer_status_list is not None: ids = ids.split( "," ) transfer_status_list = transfer_status_list.split( "," ) - for id, transfer_status in zip( ids, transfer_status_list ): - sample_dataset = trans.sa_session.query( self.app.model.SampleDataset ).get( trans.security.decode_id( id ) ) - if sample_dataset.status != transfer_status: - rval[ id ] = { "status": sample_dataset.status, - "html_status": unicode( trans.fill_template( "requests/common/sample_dataset_transfer_status.mako", - sample_dataset=sample_dataset), - 'utf-8' ) } + for tup in zip( ids, transfer_status_list ): + id, transfer_status = tup + if id and transfer_status: + sample_dataset = trans.sa_session.query( self.app.model.SampleDataset ).get( trans.security.decode_id( id ) ) + if sample_dataset.status != transfer_status: + rval[ id ] = { "status": sample_dataset.status, + "html_status": unicode( trans.fill_template( "requests/common/sample_dataset_transfer_status.mako", + sample_dataset=sample_dataset), + 'utf-8' ) } return rval @web.expose @web.require_login( "create sequencing requests" ) diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c lib/galaxy/web/controllers/workflow.py --- a/lib/galaxy/web/controllers/workflow.py +++ b/lib/galaxy/web/controllers/workflow.py @@ -1409,6 +1409,9 @@ nh_name = '%s on %s' % (nh_name, mx_ds_name) new_history = trans.app.model.History( user=trans.user, name=nh_name ) trans.sa_session.add( new_history ) + target_history = new_history + else: + target_history = trans.get_history() # Run each step, connecting outputs to inputs workflow_invocation = model.WorkflowInvocation() workflow_invocation.workflow = workflow @@ -1429,7 +1432,7 @@ except KeyError, k: error( "Error due to input mapping of '%s' in '%s'. A common cause of this is conditional outputs that cannot be determined until runtime, please review your workflow." % (tool.name, k.message)) # Execute it - job, out_data = tool.execute( trans, step.state.inputs, history=new_history) + job, out_data = tool.execute( trans, step.state.inputs, history=target_history) outputs[ step.id ] = out_data # Create new PJA associations with the created job, to be run on completion. # PJA Parameter Replacement (only applies to immediate actions-- rename specifically, for now) diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c lib/galaxy/webapps/community/app.py --- a/lib/galaxy/webapps/community/app.py +++ b/lib/galaxy/webapps/community/app.py @@ -17,13 +17,12 @@ config.configure_logging( self.config ) # Set up datatypes registry self.datatypes_registry = galaxy.datatypes.registry.Registry() - # TODO: Handle datatypes included in repositories - the following will only load datatypes_conf.xml. self.datatypes_registry.load_datatypes( self.config.root, self.config.datatypes_config ) # Determine the database url if self.config.database_connection: db_url = self.config.database_connection else: - db_url = "sqlite://%s?isolation_level=IMMEDIATE" % self.config.database + db_url = "sqlite:///%s?isolation_level=IMMEDIATE" % self.config.database # Initialize database / check for appropriate schema version from galaxy.webapps.community.model.migrate.check import create_or_verify_database create_or_verify_database( db_url, self.config.database_engine_options ) diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c scripts/migrate_tools/0003_tools.xml --- a/scripts/migrate_tools/0003_tools.xml +++ b/scripts/migrate_tools/0003_tools.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?><toolshed name="toolshed.g2.bx.psu.edu"> - <repository name="freebayes" description="Galaxy Freebayes Bayesian genetic variant detector tool" changeset_revision="046c7983e2ff"> + <repository name="freebayes" description="Galaxy Freebayes Bayesian genetic variant detector tool" changeset_revision="213a3d6b579a"><tool id="freebayes" version="0.0.2 " file="freebayes.xml" /></repository></toolshed> diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c static/images/fugue/globe-bw.png Binary file static/images/fugue/globe-bw.png has changed diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c static/images/fugue/globe.png Binary file static/images/fugue/globe.png has changed diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c static/june_2007_style/base.less --- a/static/june_2007_style/base.less +++ b/static/june_2007_style/base.less @@ -694,9 +694,11 @@ font: inherit; } -select, textarea, input[type="text"], input[type="file"], input[type="password"] { - // -webkit-box-sizing: border-box; - max-width: 90%; +.form-row { + select, textarea, input[type="text"], input[type="file"], input[type="password"] { + // -webkit-box-sizing: border-box; + max-width: 90%; + } } textarea, input[type="text"], input[type="password"] { @@ -999,8 +1001,6 @@ cursor: pointer; margin: 0; padding: 0; - display: block; - //float: right; border: 1px solid #aaa; border-left: none; } @@ -1248,7 +1248,7 @@ text-decoration: none; } - .label { + .label, > label { position: relative; display: inline-block; border-right: none; diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c static/june_2007_style/blue/base.css --- a/static/june_2007_style/blue/base.css +++ b/static/june_2007_style/blue/base.css @@ -576,7 +576,7 @@ .form-row.form-actions{background:whiteSmoke;border-top:solid #ddd 1px;padding-top:10px;padding-bottom:10px;margin-top:5px;} select{padding:2px;font-size:12px;line-height:16px;} select,input,textarea{font:inherit;} -select,textarea,input[type="text"],input[type="file"],input[type="password"]{max-width:90%;} +.form-row select,.form-row textarea,.form-row input[type="text"],.form-row input[type="file"],.form-row input[type="password"]{max-width:90%;} textarea,input[type="text"],input[type="password"]{font-size:12px;line-height:16px;border:1px solid #999999;padding:3px;} .search-query{display:inline-block;padding:4px;font-size:12px;line-height:16px;color:#555555;border:1px solid #999999;padding-left:14px !important;padding-right:14px !important;margin-bottom:0;-webkit-border-radius:14px;-moz-border-radius:14px;border-radius:14px;max-width:auto;} .search-query:focus{border-color:rgba(24, 132, 218, 0.8);-webkit-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075),0 0 8px rgba(82, 168, 236, 0.6);-moz-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075),0 0 8px rgba(82, 168, 236, 0.6);box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075),0 0 8px rgba(82, 168, 236, 0.6);outline:0;outline:thin dotted \9;} @@ -624,7 +624,7 @@ .text-filter-val{border:solid 1px #AAAAAA;padding:1px 2px 1px 3px;margin-right:5px;-moz-border-radius:.5em;-webkit-border-radius:.5em;font-style:italic;} .page-link a,.inactive-link{padding:0px 7px 0px 7px;color:#555;} .inactive-link,.current-filter{font-weight:bold;color:#000;} -.submit-image{background:url(../images/fugue/magnifier-left.png) no-repeat center transparent;background-color:#eee;width:24px;height:24px;cursor:pointer;margin:0;padding:0;display:block;border:1px solid #aaa;border-left:none;} +.submit-image{background:url(../images/fugue/magnifier-left.png) no-repeat center transparent;background-color:#eee;width:24px;height:24px;cursor:pointer;margin:0;padding:0;border:1px solid #aaa;border-left:none;} #advanced-search td{padding:3px;} #advanced-search table{border-collapse:separate;} .delete-search-icon{background:url(../images/delete_tag_icon_gray.png) center no-repeat;display:inline-block;width:10px;cursor:pointer;height:18px;vertical-align:middle;margin-left:2px;} @@ -666,7 +666,7 @@ .menubutton:active{background-image:none;-webkit-box-shadow:inset 0 2px 4px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05);-moz-box-shadow:inset 0 2px 4px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05);box-shadow:inset 0 2px 4px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05);background-color:#e6e6e6;background-color:#d9d9d9 \9;outline:0;} .menubutton:focus{outline:thin dotted;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px;} .menubutton a{text-decoration:none;} -.menubutton .label{position:relative;display:inline-block;border-right:none;text-decoration:none;text-align:left;max-height:32px;line-height:16px;overflow:hidden;text-overflow:ellipsis;} +.menubutton .label,.menubutton>label{position:relative;display:inline-block;border-right:none;text-decoration:none;text-align:left;max-height:32px;line-height:16px;overflow:hidden;text-overflow:ellipsis;} .menubutton.popup .label{border-right:solid #999999 1px;padding-right:6px;} .menubutton.popup,.menubutton.popup.split{padding-right:18px;}.menubutton.popup:after,.menubutton.popup.split:after{margin-top:6px;position:absolute;top:2px;right:6px;display:inline-block;width:0;height:0;text-indent:-99999px;*text-indent:0;vertical-align:top;border-left:4px solid transparent;border-right:4px solid transparent;border-top:4px solid #000000;opacity:0.3;filter:alpha(opacity=30);content:"\2193";} div.popmenu-wrapper{position:absolute;top:100%;z-index:20000;}div.popmenu-wrapper ul.dropdown-menu{display:block;position:relative;float:none;} diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c static/june_2007_style/blue/trackster.css --- a/static/june_2007_style/blue/trackster.css +++ b/static/june_2007_style/blue/trackster.css @@ -76,6 +76,8 @@ .toolbox:hover{background:transparent url(../images/fugue/toolbox.png) no-repeat;} .filters-icon{background:transparent url(../images/fugue/ui-slider-050-bw.png) no-repeat;} .filters-icon:hover{background:transparent url(../images/fugue/ui-slider-050.png) no-repeat;} +.globe{background:transparent url(../images/fugue/globe-bw.png) no-repeat;} +.globe:hover{background:transparent url(../images/fugue/globe.png) no-repeat;} .remove-icon,.overview-close{background:transparent url(../images/fugue/cross-small-bw.png) no-repeat;} .icon-button.remove-icon:hover,.overview-close:hover{background:transparent url(../images/fugue/cross-circle.png) no-repeat;} .icon-button.toggle{background:transparent url(../images/fugue/toggle-bw.png) no-repeat;margin-right:0px;} diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c static/june_2007_style/trackster.css.tmpl --- a/static/june_2007_style/trackster.css.tmpl +++ b/static/june_2007_style/trackster.css.tmpl @@ -386,6 +386,12 @@ .filters-icon:hover { background: transparent url(../images/fugue/ui-slider-050.png) no-repeat; } +.globe { + background: transparent url(../images/fugue/globe-bw.png) no-repeat; +} +.globe:hover { + background: transparent url(../images/fugue/globe.png) no-repeat; +} .remove-icon, .overview-close { background: transparent url(../images/fugue/cross-small-bw.png) no-repeat; } diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c static/scripts/packed/viz/paramamonster.js --- a/static/scripts/packed/viz/paramamonster.js +++ b/static/scripts/packed/viz/paramamonster.js @@ -1,1 +1,1 @@ -var ToolInputsSettings=Backbone.Model.extend({defaults:{inputs:null,values:null}});var ToolParameterTree=Backbone.RelationalModel.extend({defaults:{tool:null,tree_data:null},initialize:function(b){var a=this;this.get("tool").get("inputs").each(function(c){if(!c.get_samples()){return}c.on("change:min change:max change:num_samples",function(d){if(d.get("in_ptree")){a.set_tree_data()}},a);c.on("change:in_ptree",function(d){if(d.get("in_ptree")){a.add_param(d)}else{a.remove_param(d)}a.set_tree_data()},a)});if(b.config){_.each(b.config,function(d){var c=a.get("tool").get("inputs").find(function(e){return e.get("name")===d.name});a.add_param(c);c.set(d)})}},add_param:function(a){if(a.get("ptree_index")){return}a.set("in_ptree",true);a.set("ptree_index",this.get_tree_params().length)},remove_param:function(a){a.set("in_ptree",false);a.set("ptree_index",null);_(this.get_tree_params()).each(function(b,c){b.set("ptree_index",c+1)})},set_tree_data:function(){var b=_.map(this.get_tree_params(),function(d){return{param:d,samples:d.get_samples()}});var a=0,c=function(g,d){var i=g[d],h=i.param,f=h.get("label"),e=i.samples;if(g.length-1===d){return _.map(e,function(j){return{id:a++,name:j,param:h,value:j}})}return _.map(e,function(j){return{id:a++,name:j,param:h,value:j,children:c(g,d+1)}})};this.set("tree_data",{name:"Root",id:a++,children:(b.length!==0?c(b,0):null)})},get_tree_params:function(){return _(this.get("tool").get("inputs").where({in_ptree:true})).sortBy(function(a){return a.get("ptree_index")})},get_num_leaves:function(){return this.get_tree_params().reduce(function(a,b){return a*b.get_samples().length},1)},get_node_settings:function(e){var c=this.get("tool").get_inputs_dict();var f=e.parent;if(f){while(f.depth!==0){c[f.param.get("name")]=f.value;f=f.parent}}var a=this,b=function(h,g){if(h.param){g[h.param.get("name")]=h.value}if(!h.children){return new ToolInputsSettings({inputs:a.get("tool").get("inputs"),values:g})}else{return _.flatten(_.map(h.children,function(i){return b(i,_.clone(g))}))}},d=b(e,c);if(!_.isArray(d)){d=[d]}return d},get_connected_nodes:function(c){var d=function(e){if(!e.children){return e}else{return _.flatten([e,_.map(e.children,function(f){return d(f)})])}};var b=[],a=c.parent;while(a){b.push(a);a=a.parent}return _.flatten([b,d(c)])},get_leaf:function(b){var c=this.get("tree_data"),a=function(d){return _.find(d,function(e){return b[e.param.get("name")]===e.value})};while(c.children){c=a(c.children)}return c},toJSON:function(){return this.get_tree_params().map(function(a){return{name:a.get("name"),min:a.get("min"),max:a.get("max"),num_samples:a.get("num_samples")}})}});var ParamaMonsterTrack=Backbone.RelationalModel.extend({defaults:{track:null,mode:"Pack",settings:null,regions:null},relations:[{type:Backbone.HasMany,key:"regions",relatedModel:"GenomeRegion"}],initialize:function(a){if(a.track){var b=_.extend({data_url:galaxy_paths.get("raw_data_url"),converted_datasets_state_url:galaxy_paths.get("dataset_state_url")},a.track);this.set("track",object_from_template(b,{},null))}},same_settings:function(a){var b=this.get("settings"),c=a.get("settings");for(var d in b){if(!c[d]||b[d]!==c[d]){return false}}return true},toJSON:function(){return{track:this.get("track").to_dict(),settings:this.get("settings"),regions:this.get("regions")}}});var TrackCollection=Backbone.Collection.extend({model:ParamaMonsterTrack});var ParamaMonsterVisualization=Visualization.extend({defaults:_.extend({},Visualization.prototype.defaults,{dataset:null,tool:null,parameter_tree:null,regions:null,tracks:null,default_mode:"Pack"}),relations:[{type:Backbone.HasOne,key:"dataset",relatedModel:"Dataset"},{type:Backbone.HasOne,key:"tool",relatedModel:"Tool"},{type:Backbone.HasMany,key:"regions",relatedModel:"GenomeRegion"},{type:Backbone.HasMany,key:"tracks",relatedModel:"ParamaMonsterTrack"}],initialize:function(a){var b=this.get("tool").copy(true);this.set("tool_with_samplable_inputs",b);this.set("parameter_tree",new ToolParameterTree({tool:b,config:a.tree_config}))},add_track:function(a){this.get("tracks").add(a)},toJSON:function(){return{id:this.get("id"),title:"Parameter exploration for dataset '"+this.get("dataset").get("name")+"'",type:"paramamonster",dataset_id:this.get("dataset").id,tool_id:this.get("tool").id,regions:this.get("regions").toJSON(),tree_config:this.get("parameter_tree").toJSON(),tracks:this.get("tracks").toJSON()}}});var ParamaMonsterTrackView=Backbone.View.extend({tagName:"tr",TILE_LEN:250,initialize:function(a){this.canvas_manager=a.canvas_manager;this.render();this.model.on("change:track change:mode",this.draw_tiles,this)},render:function(){var f=this.model.get("settings"),b=f.get("values"),d=$("<td/>").addClass("settings").appendTo(this.$el),c=$("<div/>").addClass("track-info").hide().appendTo(d);c.append($("<div/>").css("font-weight","bold").text("Track Settings"));f.get("inputs").each(function(h){c.append(h.get("label")+": "+b[h.get("name")]+"<br/>")});var a=this,g=$("<button/>").appendTo(c).text("Run on complete dataset").click(function(){c.toggle();a.trigger("run_on_dataset",f)});var e=create_icon_buttons_menu([{title:"Settings",icon_class:"gear track-settings",on_click:function(){c.toggle()},tipsy_config:{gravity:"s"}},{title:"Remove",icon_class:"cross-circle",on_click:function(){a.$el.remove();$(".tipsy").remove()}}]);d.prepend(e.$el);this.model.get("regions").each(function(){a.$el.append($("<td/>").addClass("tile").html($("<img/>").attr("src",galaxy_paths.get("image_path")+"/loading_large_white_bg.gif")))});if(this.model.get("track")){this.draw_tiles()}},draw_tiles:function(){var b=this,a=this.model.get("track"),d=this.model.get("regions"),c=this.$el.find("td.tile");if(!a){return}$.when(a.data_manager.data_is_ready()).then(function(e){d.each(function(h,g){var f=h.length()/b.TILE_LEN,j=1/f,i=b.model.get("mode");$.when(a.data_manager.get_data(h,i,f,{})).then(function(l){var k=b.canvas_manager.new_canvas();k.width=b.TILE_LEN;k.height=a.get_canvas_height(l,i,j,k.width);a.draw_tile(l,k.getContext("2d"),i,f,h,j);$(c[g]).empty().append(k)})})})}});var ToolInputValOrSweepView=Backbone.View.extend({number_input_template:'<div class="form-row-input sweep"><input class="min" type="text" size="6" value="<%= min %>"> - <input class="max" type="text" size="6" value="<%= max %>"> samples: <input class="num_samples" type="text" size="1" value="<%= num_samples %>"></div>',select_input_template:'<div class="form-row-input sweep"><%= options %></div>',initialize:function(a){this.$el=a.tool_row;this.render()},render:function(){var b=this.model,f=b.get("type"),h=this.$el.find(".form-row-input"),d=null;h.find(":input").change(function(){b.set("value",$(this).val())});if(f==="number"){d=$(_.template(this.number_input_template,this.model.toJSON()))}else{if(f==="select"){var c=_.map(this.$el.find("select option"),function(i){return $(i).val()}),e=c.join(", ");d=$(_.template(this.select_input_template,{options:e}))}}d.insertAfter(h);var a=this,g=create_icon_buttons_menu([{title:"Add parameter to tree",icon_class:"plus-button",on_click:function(){b.set("in_ptree",true);h.hide();d.show();$(this).hide();a.$el.find(".icon-button.toggle").show()}},{title:"Remove parameter from tree",icon_class:"toggle",on_click:function(){b.set("in_ptree",false);d.hide();h.show();$(this).hide();a.$el.find(".icon-button.plus-button").show()}}],{tipsy_config:{gravity:"s"}});this.$el.prepend(g.$el);if(b.get("in_ptree")){h.hide();a.$el.find(".icon-button.plus-button").hide()}else{a.$el.find(".icon-button.toggle").hide();d.hide()}_.each(["min","max","num_samples"],function(i){d.find("."+i).change(function(){b.set(i,parseFloat($(this).val()))})})}});var ToolParameterTreeDesignView=Backbone.View.extend({className:"tree-design",initialize:function(a){this.render()},render:function(){var c=new ToolFormView({model:this.model.get("tool")});c.render();this.$el.append(c.$el);var b=this,a=b.model.get("tool").get("inputs");this.$el.find(".form-row").not(".form-actions").each(function(d){var e=new ToolInputValOrSweepView({model:a.at(d),tool_row:$(this)})})}});var ToolParameterTreeView=Backbone.View.extend({className:"tool-parameter-tree",initialize:function(a){this.model.on("change:tree_data",this.render,this)},render:function(){this.$el.children().remove();var i=this.model.get_tree_params();if(!i.length){return}this.width=100*(2+i.length);this.height=15*this.model.get_num_leaves();var h=this;var g=d3.layout.cluster().size([this.height,this.width-160]);var c=d3.svg.diagonal().projection(function(j){return[j.y,j.x]});var a=g.nodes(this.model.get("tree_data"));var d=_.uniq(_.pluck(a,"y"));_.each(i,function(l,k){var j=d[k+1],m=$("#center").position().left;h.$el.append($("<div>").addClass("label").text(l.get("label")).css("left",j+m))});var b=d3.select(this.$el[0]).append("svg").attr("width",this.width).attr("height",this.height+20).append("g").attr("transform","translate(40, 10)");var f=b.selectAll("path.link").data(g.links(a)).enter().append("path").attr("class","link").attr("d",c);var e=b.selectAll("g.node").data(a).enter().append("g").attr("class","node").attr("transform",function(j){return"translate("+j.y+","+j.x+")"}).on("mouseover",function(k){var j=_.pluck(h.model.get_connected_nodes(k),"id");e.filter(function(l){return _.find(j,function(m){return m===l.id})!==undefined}).style("fill","#f00")}).on("mouseout",function(){e.style("fill","#000")});e.append("circle").attr("r",9);e.append("text").attr("dx",function(j){return j.children?-12:12}).attr("dy",3).attr("text-anchor",function(j){return j.children?"end":"start"}).text(function(j){return j.name})}});var ParamaMonsterVisualizationView=Backbone.View.extend({className:"paramamonster",helpText:"<div><h4>Getting Started</h4><ol><li>Create a parameter tree by using the icons next to the tool's parameter names to add or remove parameters.<li>Adjust the tree by using parameter inputs to select min, max, and number of samples<li>Run the tool with different settings by clicking on tree nodes</ol></div>",initialize:function(b){this.canvas_manager=new CanvasManager(this.$el.parents("body"));this.tool_param_tree_view=new ToolParameterTreeView({model:this.model.get("parameter_tree")});this.track_collection_container=$("<table/>").addClass("tracks");this.model.get("parameter_tree").on("change:tree_data",this.handle_node_clicks,this);var a=this;this.model.get("tracks").each(function(c){c.get("track").view=a})},render:function(){var g=new ToolParameterTreeDesignView({model:this.model.get("parameter_tree")});$("#left").append(g.$el);var j=this,d=j.model.get("regions"),h=$("<tr/>").appendTo(this.track_collection_container);d.each(function(k){h.append($("<th>").text(k.toString()))});h.children().first().attr("colspan",2);var e=$("<div>").addClass("tiles");$("#right").append(e.append(this.track_collection_container));j.model.get("tracks").each(function(k){j.add_track(k)});var i=$(this.helpText).addClass("help"),f=create_icon_buttons_menu([{title:"Close",icon_class:"cross-circle",on_click:function(){$(".tipsy").remove();i.remove()},tipsy_config:{gravity:"s"}}]);i.prepend(f.$el.css("float","right"));$("#center").append(i);this.tool_param_tree_view.render();$("#center").append(this.tool_param_tree_view.$el);this.handle_node_clicks();var c=create_icon_buttons_menu([{icon_class:"chevron-expand",title:"Set display mode"},{icon_class:"cross-circle",title:"Close",on_click:function(){window.location="${h.url_for( controller='visualization', action='list' )}"}}],{tipsy_config:{gravity:"n"}});var b=["Squish","Pack"],a={};_.each(b,function(k){a[k]=function(){j.model.set("default_mode",k);j.model.get("tracks").each(function(l){l.set("mode",k)})}});make_popupmenu(c.$el.find(".chevron-expand"),a);c.$el.attr("style","float: right");$("#right .unified-panel-header-inner").append(c.$el)},run_tool_on_dataset:function(b){var a=this.model.get("tool"),d=a.get("name"),c=this.model.get("dataset");a.set_input_values(b.get("values"));$.when(a.rerun(c)).then(function(e){});show_modal("Running "+d+" on complete dataset",d+" is running on dataset '"+c.get("name")+"'. Outputs are in the dataset's history.",{Ok:function(){hide_modal()}})},add_track:function(d){var b=this,c=this.model.get("parameter_tree");b.model.add_track(d);var a=new ParamaMonsterTrackView({model:d,canvas_manager:b.canvas_manager});a.on("run_on_dataset",b.run_tool_on_dataset,b);b.track_collection_container.append(a.$el);a.$el.hover(function(){var f=c.get_leaf(d.get("settings").get("values"));var e=_.pluck(c.get_connected_nodes(f),"id");d3.select(b.tool_param_tree_view.$el[0]).selectAll("g.node").filter(function(g){return _.find(e,function(h){return h===g.id})!==undefined}).style("fill","#f00")},function(){d3.select(b.tool_param_tree_view.$el[0]).selectAll("g.node").style("fill","#000")});return d},handle_node_clicks:function(){var a=this,b=this.model.get("parameter_tree"),d=this.model.get("regions"),c=d3.select(this.tool_param_tree_view.$el[0]).selectAll("g.node");c.on("click",function(k,g){var f=a.model.get("tool"),j=a.model.get("dataset"),h=b.get_node_settings(k),e=$.Deferred();if(h.length>=10){show_modal("Whoa there cowboy!","You clicked on a node to try "+a.model.get("tool").get("name")+" with "+h.length+" different combinations of settings. You can only run 10 jobs at a time.",{Ok:function(){hide_modal();e.resolve(false)}})}else{e.resolve(true)}$.when(e).then(function(i){if(!i){return}var l=_.map(h,function(m){var n=new ParamaMonsterTrack({settings:m,regions:d,mode:a.model.get("default_mode")});a.add_track(n);return n});_.each(l,function(n,m){setTimeout(function(){f.set_input_values(n.get("settings").get("values"));$.when(f.rerun(j,d)).then(function(p){var q=_.extend({data_url:galaxy_paths.get("raw_data_url"),converted_datasets_state_url:galaxy_paths.get("dataset_state_url")},p.first().get("track_config")),o=object_from_template(q,a,null);n.set("track",o)})},m*10000)})})})}}); \ No newline at end of file +var ToolInputsSettings=Backbone.Model.extend({defaults:{inputs:null,values:null}});var ToolParameterTree=Backbone.RelationalModel.extend({defaults:{tool:null,tree_data:null},initialize:function(b){var a=this;this.get("tool").get("inputs").each(function(c){if(!c.get_samples()){return}c.on("change:min change:max change:num_samples",function(d){if(d.get("in_ptree")){a.set_tree_data()}},a);c.on("change:in_ptree",function(d){if(d.get("in_ptree")){a.add_param(d)}else{a.remove_param(d)}a.set_tree_data()},a)});if(b.config){_.each(b.config,function(d){var c=a.get("tool").get("inputs").find(function(e){return e.get("name")===d.name});a.add_param(c);c.set(d)})}},add_param:function(a){if(a.get("ptree_index")){return}a.set("in_ptree",true);a.set("ptree_index",this.get_tree_params().length)},remove_param:function(a){a.set("in_ptree",false);a.set("ptree_index",null);_(this.get_tree_params()).each(function(b,c){b.set("ptree_index",c+1)})},set_tree_data:function(){var b=_.map(this.get_tree_params(),function(d){return{param:d,samples:d.get_samples()}});var a=0,c=function(g,d){var i=g[d],h=i.param,f=h.get("label"),e=i.samples;if(g.length-1===d){return _.map(e,function(j){return{id:a++,name:j,param:h,value:j}})}return _.map(e,function(j){return{id:a++,name:j,param:h,value:j,children:c(g,d+1)}})};this.set("tree_data",{name:"Root",id:a++,children:(b.length!==0?c(b,0):null)})},get_tree_params:function(){return _(this.get("tool").get("inputs").where({in_ptree:true})).sortBy(function(a){return a.get("ptree_index")})},get_num_leaves:function(){return this.get_tree_params().reduce(function(a,b){return a*b.get_samples().length},1)},get_node_settings:function(e){var c=this.get("tool").get_inputs_dict();var f=e.parent;if(f){while(f.depth!==0){c[f.param.get("name")]=f.value;f=f.parent}}var a=this,b=function(h,g){if(h.param){g[h.param.get("name")]=h.value}if(!h.children){return new ToolInputsSettings({inputs:a.get("tool").get("inputs"),values:g})}else{return _.flatten(_.map(h.children,function(i){return b(i,_.clone(g))}))}},d=b(e,c);if(!_.isArray(d)){d=[d]}return d},get_connected_nodes:function(c){var d=function(e){if(!e.children){return e}else{return _.flatten([e,_.map(e.children,function(f){return d(f)})])}};var b=[],a=c.parent;while(a){b.push(a);a=a.parent}return _.flatten([b,d(c)])},get_leaf:function(b){var c=this.get("tree_data"),a=function(d){return _.find(d,function(e){return b[e.param.get("name")]===e.value})};while(c.children){c=a(c.children)}return c},toJSON:function(){return this.get_tree_params().map(function(a){return{name:a.get("name"),min:a.get("min"),max:a.get("max"),num_samples:a.get("num_samples")}})}});var ParamaMonsterTrack=Backbone.RelationalModel.extend({defaults:{track:null,mode:"Pack",settings:null,regions:null},relations:[{type:Backbone.HasMany,key:"regions",relatedModel:"GenomeRegion"}],initialize:function(a){if(a.track){var b=_.extend({data_url:galaxy_paths.get("raw_data_url"),converted_datasets_state_url:galaxy_paths.get("dataset_state_url")},a.track);this.set("track",object_from_template(b,{},null))}},same_settings:function(a){var b=this.get("settings"),c=a.get("settings");for(var d in b){if(!c[d]||b[d]!==c[d]){return false}}return true},toJSON:function(){return{track:this.get("track").to_dict(),settings:this.get("settings"),regions:this.get("regions")}}});var TrackCollection=Backbone.Collection.extend({model:ParamaMonsterTrack});var ParamaMonsterVisualization=Visualization.extend({defaults:_.extend({},Visualization.prototype.defaults,{dataset:null,tool:null,parameter_tree:null,regions:null,tracks:null,default_mode:"Pack"}),relations:[{type:Backbone.HasOne,key:"dataset",relatedModel:"Dataset"},{type:Backbone.HasOne,key:"tool",relatedModel:"Tool"},{type:Backbone.HasMany,key:"regions",relatedModel:"GenomeRegion"},{type:Backbone.HasMany,key:"tracks",relatedModel:"ParamaMonsterTrack"}],initialize:function(a){var b=this.get("tool").copy(true);this.set("tool_with_samplable_inputs",b);this.set("parameter_tree",new ToolParameterTree({tool:b,config:a.tree_config}))},add_track:function(a){this.get("tracks").add(a)},toJSON:function(){return{id:this.get("id"),title:"Parameter exploration for dataset '"+this.get("dataset").get("name")+"'",type:"paramamonster",dataset_id:this.get("dataset").id,tool_id:this.get("tool").id,regions:this.get("regions").toJSON(),tree_config:this.get("parameter_tree").toJSON(),tracks:this.get("tracks").toJSON()}}});var ParamaMonsterTrackView=Backbone.View.extend({tagName:"tr",TILE_LEN:250,initialize:function(a){this.canvas_manager=a.canvas_manager;this.render();this.model.on("change:track change:mode",this.draw_tiles,this)},render:function(){var f=this.model.get("settings"),b=f.get("values"),d=$("<td/>").addClass("settings").appendTo(this.$el),c=$("<div/>").addClass("track-info").hide().appendTo(d);c.append($("<div/>").css("font-weight","bold").text("Track Settings"));f.get("inputs").each(function(h){c.append(h.get("label")+": "+b[h.get("name")]+"<br/>")});var a=this,g=$("<button/>").appendTo(c).text("Run on complete dataset").click(function(){c.toggle();a.trigger("run_on_dataset",f)});var e=create_icon_buttons_menu([{title:"Settings",icon_class:"gear track-settings",on_click:function(){c.toggle()},tipsy_config:{gravity:"s"}},{title:"Remove",icon_class:"cross-circle",on_click:function(){a.$el.remove();$(".tipsy").remove()}}]);d.prepend(e.$el);this.model.get("regions").each(function(){a.$el.append($("<td/>").addClass("tile").html($("<img/>").attr("src",galaxy_paths.get("image_path")+"/loading_large_white_bg.gif")))});if(this.model.get("track")){this.draw_tiles()}},draw_tiles:function(){var b=this,a=this.model.get("track"),d=this.model.get("regions"),c=this.$el.find("td.tile");if(!a){return}$.when(a.data_manager.data_is_ready()).then(function(e){d.each(function(h,g){var f=h.length()/b.TILE_LEN,j=1/f,i=b.model.get("mode");$.when(a.data_manager.get_data(h,i,f,{})).then(function(l){var k=b.canvas_manager.new_canvas();k.width=b.TILE_LEN;k.height=a.get_canvas_height(l,i,j,k.width);a.draw_tile(l,k.getContext("2d"),i,f,h,j);$(c[g]).empty().append(k)})})})}});var ToolInputValOrSweepView=Backbone.View.extend({number_input_template:'<div class="form-row-input sweep"><input class="min" type="text" size="6" value="<%= min %>"> - <input class="max" type="text" size="6" value="<%= max %>"> samples: <input class="num_samples" type="text" size="1" value="<%= num_samples %>"></div>',select_input_template:'<div class="form-row-input sweep"><%= options %></div>',initialize:function(a){this.$el=a.tool_row;this.render()},render:function(){var b=this.model,f=b.get("type"),h=this.$el.find(".form-row-input"),d=null;h.find(":input").change(function(){b.set("value",$(this).val())});if(f==="number"){d=$(_.template(this.number_input_template,this.model.toJSON()))}else{if(f==="select"){var c=_.map(this.$el.find("select option"),function(i){return $(i).val()}),e=c.join(", ");d=$(_.template(this.select_input_template,{options:e}))}}d.insertAfter(h);var a=this,g=create_icon_buttons_menu([{title:"Add parameter to tree",icon_class:"plus-button",on_click:function(){b.set("in_ptree",true);h.hide();d.show();$(this).hide();a.$el.find(".icon-button.toggle").show()}},{title:"Remove parameter from tree",icon_class:"toggle",on_click:function(){b.set("in_ptree",false);d.hide();h.show();$(this).hide();a.$el.find(".icon-button.plus-button").show()}}],{tipsy_config:{gravity:"s"}});this.$el.prepend(g.$el);if(b.get("in_ptree")){h.hide();a.$el.find(".icon-button.plus-button").hide()}else{a.$el.find(".icon-button.toggle").hide();d.hide()}_.each(["min","max","num_samples"],function(i){d.find("."+i).change(function(){b.set(i,parseFloat($(this).val()))})})}});var ToolParameterTreeDesignView=Backbone.View.extend({className:"tree-design",initialize:function(a){this.render()},render:function(){var c=new ToolFormView({model:this.model.get("tool")});c.render();this.$el.append(c.$el);var b=this,a=b.model.get("tool").get("inputs");this.$el.find(".form-row").not(".form-actions").each(function(d){var e=new ToolInputValOrSweepView({model:a.at(d),tool_row:$(this)})})}});var ToolParameterTreeView=Backbone.View.extend({className:"tool-parameter-tree",initialize:function(a){this.model.on("change:tree_data",this.render,this)},render:function(){this.$el.children().remove();var i=this.model.get_tree_params();if(!i.length){return}this.width=100*(2+i.length);this.height=15*this.model.get_num_leaves();var h=this;var g=d3.layout.cluster().size([this.height,this.width-160]);var c=d3.svg.diagonal().projection(function(j){return[j.y,j.x]});var a=g.nodes(this.model.get("tree_data"));var d=_.uniq(_.pluck(a,"y"));_.each(i,function(l,k){var j=d[k+1],m=$("#center").position().left;h.$el.append($("<div>").addClass("label").text(l.get("label")).css("left",j+m))});var b=d3.select(this.$el[0]).append("svg").attr("width",this.width).attr("height",this.height+30).append("g").attr("transform","translate(40, 20)");var f=b.selectAll("path.link").data(g.links(a)).enter().append("path").attr("class","link").attr("d",c);var e=b.selectAll("g.node").data(a).enter().append("g").attr("class","node").attr("transform",function(j){return"translate("+j.y+","+j.x+")"}).on("mouseover",function(k){var j=_.pluck(h.model.get_connected_nodes(k),"id");e.filter(function(l){return _.find(j,function(m){return m===l.id})!==undefined}).style("fill","#f00")}).on("mouseout",function(){e.style("fill","#000")});e.append("circle").attr("r",9);e.append("text").attr("dx",function(j){return j.children?-12:12}).attr("dy",3).attr("text-anchor",function(j){return j.children?"end":"start"}).text(function(j){return j.name})}});var ParamaMonsterVisualizationView=Backbone.View.extend({className:"paramamonster",helpText:"<div><h4>Getting Started</h4><ol><li>Create a parameter tree by using the icons next to the tool's parameter names to add or remove parameters.<li>Adjust the tree by using parameter inputs to select min, max, and number of samples<li>Run the tool with different settings by clicking on tree nodes</ol></div>",initialize:function(b){this.canvas_manager=new CanvasManager(this.$el.parents("body"));this.tool_param_tree_view=new ToolParameterTreeView({model:this.model.get("parameter_tree")});this.track_collection_container=$("<table/>").addClass("tracks");this.model.get("parameter_tree").on("change:tree_data",this.handle_node_clicks,this);var a=this;this.model.get("tracks").each(function(c){c.get("track").view=a});this.block_color=get_random_color();this.reverse_strand_color=get_random_color([this.block_color,"#ffffff"])},render:function(){var g=new ToolParameterTreeDesignView({model:this.model.get("parameter_tree")});$("#left").append(g.$el);var j=this,d=j.model.get("regions"),h=$("<tr/>").appendTo(this.track_collection_container);d.each(function(k){h.append($("<th>").text(k.toString()))});h.children().first().attr("colspan",2);var e=$("<div>").addClass("tiles");$("#right").append(e.append(this.track_collection_container));j.model.get("tracks").each(function(k){j.add_track(k)});var i=$(this.helpText).addClass("help"),f=create_icon_buttons_menu([{title:"Close",icon_class:"cross-circle",on_click:function(){$(".tipsy").remove();i.remove()},tipsy_config:{gravity:"s"}}]);i.prepend(f.$el.css("float","right"));$("#center").append(i);this.tool_param_tree_view.render();$("#center").append(this.tool_param_tree_view.$el);this.handle_node_clicks();var c=create_icon_buttons_menu([{icon_class:"chevron-expand",title:"Set display mode"},{icon_class:"cross-circle",title:"Close",on_click:function(){window.location="${h.url_for( controller='visualization', action='list' )}"}}],{tipsy_config:{gravity:"n"}});var b=["Squish","Pack"],a={};_.each(b,function(k){a[k]=function(){j.model.set("default_mode",k);j.model.get("tracks").each(function(l){l.set("mode",k)})}});make_popupmenu(c.$el.find(".chevron-expand"),a);c.$el.attr("style","float: right");$("#right .unified-panel-header-inner").append(c.$el)},run_tool_on_dataset:function(b){var a=this.model.get("tool"),d=a.get("name"),c=this.model.get("dataset");a.set_input_values(b.get("values"));$.when(a.rerun(c)).then(function(e){});show_modal("Running "+d+" on complete dataset",d+" is running on dataset '"+c.get("name")+"'. Outputs are in the dataset's history.",{Ok:function(){hide_modal()}})},add_track:function(d){var b=this,c=this.model.get("parameter_tree");b.model.add_track(d);var a=new ParamaMonsterTrackView({model:d,canvas_manager:b.canvas_manager});a.on("run_on_dataset",b.run_tool_on_dataset,b);b.track_collection_container.append(a.$el);a.$el.hover(function(){var f=c.get_leaf(d.get("settings").get("values"));var e=_.pluck(c.get_connected_nodes(f),"id");d3.select(b.tool_param_tree_view.$el[0]).selectAll("g.node").filter(function(g){return _.find(e,function(h){return h===g.id})!==undefined}).style("fill","#f00")},function(){d3.select(b.tool_param_tree_view.$el[0]).selectAll("g.node").style("fill","#000")});return d},handle_node_clicks:function(){var a=this,b=this.model.get("parameter_tree"),d=this.model.get("regions"),c=d3.select(this.tool_param_tree_view.$el[0]).selectAll("g.node");c.on("click",function(k,g){var f=a.model.get("tool"),j=a.model.get("dataset"),h=b.get_node_settings(k),e=$.Deferred();if(h.length>=10){show_modal("Whoa there cowboy!","You clicked on a node to try "+a.model.get("tool").get("name")+" with "+h.length+" different combinations of settings. You can only run 10 jobs at a time.",{Ok:function(){hide_modal();e.resolve(false)}})}else{e.resolve(true)}$.when(e).then(function(i){if(!i){return}var l=_.map(h,function(m){var n=new ParamaMonsterTrack({settings:m,regions:d,mode:a.model.get("default_mode")});a.add_track(n);return n});_.each(l,function(n,m){setTimeout(function(){f.set_input_values(n.get("settings").get("values"));$.when(f.rerun(j,d)).then(function(p){var q=_.extend({data_url:galaxy_paths.get("raw_data_url"),converted_datasets_state_url:galaxy_paths.get("dataset_state_url")},p.first().get("track_config")),o=object_from_template(q,a,null);o.prefs.block_color=a.block_color;o.prefs.reverse_strand_color=a.reverse_strand_color;n.set("track",o)})},m*10000)})})})}}); \ No newline at end of file diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c static/scripts/packed/viz/trackster.js --- a/static/scripts/packed/viz/trackster.js +++ b/static/scripts/packed/viz/trackster.js @@ -1,1 +1,1 @@ -var class_module=function(b,a){var c=function(){var g=arguments[0];for(var f=1;f<arguments.length;f++){var d=arguments[f];for(var e in d){g[e]=d[e]}}return g};a.extend=c};var requestAnimationFrame=(function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(b,a){window.setTimeout(b,1000/60)}})();var BEFORE=1001,CONTAINS=1002,OVERLAP_START=1003,OVERLAP_END=1004,CONTAINED_BY=1005,AFTER=1006;var compute_overlap=function(e,b){var g=e[0],f=e[1],d=b[0],c=b[1],a;if(g<d){if(f<d){a=BEFORE}else{if(f<=c){a=OVERLAP_START}else{a=CONTAINS}}}else{if(g>c){a=AFTER}else{if(f<=c){a=CONTAINED_BY}else{a=OVERLAP_END}}}return a};var is_overlap=function(c,b){var a=compute_overlap(c,b);return(a!==BEFORE&&a!==AFTER)};var is_deferred=function(a){return("isResolved" in a)};var get_random_color=function(a){if(!a){a="#ffffff"}if(typeof(a)==="string"){a=[a]}for(var j=0;j<a.length;j++){a[j]=parseInt(a[j].slice(1),16)}var n=function(t,s,i){return((t*299)+(s*587)+(i*114))/1000};var e=function(v,u,w,s,i,t){return(Math.max(v,s)-Math.min(v,s))+(Math.max(u,i)-Math.min(u,i))+(Math.max(w,t)-Math.min(w,t))};var g,o,f,k,q,h,r,c,d,b,p,m=false,l=0;do{g=Math.round(Math.random()*16777215);o=(g&16711680)>>16;f=(g&65280)>>8;k=g&255;d=n(o,f,k);m=true;for(j=0;j<a.length;j++){q=a[j];h=(q&16711680)>>16;r=(q&65280)>>8;c=q&255;b=n(h,r,c);p=e(o,f,k,h,r,c);if((Math.abs(d-b)<40)||(p<200)){m=false;break}}l++}while(!m&&l<=10);return"#"+(16777216+g).toString(16).substr(1,6)};var create_action_icon=function(c,b,a){return $("<a/>").attr("href","javascript:void(0);").attr("title",c).addClass("icon-button").addClass(b).tipsy({gravity:"s"}).click(a)};var trackster_module=function(d,R){var o=d("class").extend,r=d("slotting"),H=d("painters");var m={};var k=function(Y,Z){m[Y.attr("id")]=Z};var l=function(Y,aa,ac,ab){ac=".group";var Z={};m[Y.attr("id")]=ab;Y.bind("drag",{handle:"."+aa,relative:true},function(ak,al){var aj=$(this),ao=$(this).parent(),ag=ao.children(),ai=m[$(this).attr("id")],af,ae,am,ad,ah;ae=$(this).parents(ac);if(ae.length!==0){am=ae.position().top;ad=am+ae.outerHeight();if(al.offsetY<am){$(this).insertBefore(ae);var an=m[ae.attr("id")];an.remove_drawable(ai);an.container.add_drawable_before(ai,an);return}else{if(al.offsetY>ad){$(this).insertAfter(ae);var an=m[ae.attr("id")];an.remove_drawable(ai);an.container.add_drawable(ai);return}}}ae=null;for(ah=0;ah<ag.length;ah++){af=$(ag.get(ah));am=af.position().top;ad=am+af.outerHeight();if(af.is(ac)&&this!==af.get(0)&&al.offsetY>=am&&al.offsetY<=ad){if(al.offsetY-am<ad-al.offsetY){af.find(".content-div").prepend(this)}else{af.find(".content-div").append(this)}if(ai.container){ai.container.remove_drawable(ai)}m[af.attr("id")].add_drawable(ai);return}}for(ah=0;ah<ag.length;ah++){af=$(ag.get(ah));if(al.offsetY<af.position().top&&!(af.hasClass("reference-track")||af.hasClass("intro"))){break}}if(ah===ag.length){if(this!==ag.get(ah-1)){ao.append(this);m[ao.attr("id")].move_drawable(ai,ah)}}else{if(this!==ag.get(ah)){$(this).insertBefore(ag.get(ah));m[ao.attr("id")].move_drawable(ai,(al.deltaY>0?ah-1:ah))}}}).bind("dragstart",function(){Z["border-top"]=Y.css("border-top");Z["border-bottom"]=Y.css("border-bottom");$(this).css({"border-top":"1px solid blue","border-bottom":"1px solid blue"})}).bind("dragend",function(){$(this).css(Z)})};R.moveable=l;var X=16,C=9,z=20,w=100,E=12000,O=400,G=5000,t=100,n="There was an error in indexing this dataset. ",F="A converter for this dataset is not installed. Please check your datatypes_conf.xml file.",A="No data for this chrom/contig.",s="Preparing data. This can take a while for a large dataset. If the visualization is saved and closed, preparation will continue in the background.",u="Tool cannot be rerun: ",a="Loading data...",S="Ready for display",M=10,D=20;function T(Z,Y){if(!Y){Y=0}var aa=Math.pow(10,Y);return Math.round(Z*aa)/aa}var p=function(Z,Y,ab){if(!p.id_counter){p.id_counter=0}this.id=p.id_counter++;this.name=ab.name;this.view=Z;this.container=Y;this.config=new B({track:this,params:[{key:"name",label:"Name",type:"text",default_value:this.name}],saved_values:ab.prefs,onchange:function(){this.track.set_name(this.track.config.values.name)}});this.prefs=this.config.values;this.drag_handle_class=ab.drag_handle_class;this.is_overview=false;this.action_icons={};this.content_visible=true;this.container_div=this.build_container_div();this.header_div=this.build_header_div();if(this.header_div){this.container_div.append(this.header_div);this.icons_div=$("<div/>").css("float","left").hide().appendTo(this.header_div);this.build_action_icons(this.action_icons_def);this.header_div.append($("<div style='clear: both'/>"));this.header_div.dblclick(function(ac){ac.stopPropagation()});var aa=this;this.container_div.hover(function(){aa.icons_div.show()},function(){aa.icons_div.hide()});$("<div style='clear: both'/>").appendTo(this.container_div)}};p.prototype.action_icons_def=[{name:"toggle_icon",title:"Hide/show content",css_class:"toggle",on_click_fn:function(Y){if(Y.content_visible){Y.action_icons.toggle_icon.addClass("toggle-expand").removeClass("toggle");Y.hide_contents();Y.content_visible=false}else{Y.action_icons.toggle_icon.addClass("toggle").removeClass("toggle-expand");Y.content_visible=true;Y.show_contents()}}},{name:"settings_icon",title:"Edit settings",css_class:"settings-icon",on_click_fn:function(Z){var ab=function(){hide_modal();$(window).unbind("keypress.check_enter_esc")},Y=function(){Z.config.update_from_form($(".dialog-box"));hide_modal();$(window).unbind("keypress.check_enter_esc")},aa=function(ac){if((ac.keyCode||ac.which)===27){ab()}else{if((ac.keyCode||ac.which)===13){Y()}}};$(window).bind("keypress.check_enter_esc",aa);show_modal("Configure",Z.config.build_form(),{Cancel:ab,OK:Y})}},{name:"remove_icon",title:"Remove",css_class:"remove-icon",on_click_fn:function(Y){$(".tipsy").remove();Y.remove()}}];o(p.prototype,{init:function(){},changed:function(){this.view.changed()},can_draw:function(){if(this.enabled&&this.content_visible){return true}return false},request_draw:function(){},_draw:function(){},to_dict:function(){},set_name:function(Y){this.old_name=this.name;this.name=Y;this.name_div.text(this.name)},revert_name:function(){if(this.old_name){this.name=this.old_name;this.name_div.text(this.name)}},remove:function(){this.changed();this.container.remove_drawable(this);var Y=this.view;this.container_div.hide(0,function(){$(this).remove();Y.update_intro_div()})},build_container_div:function(){},build_header_div:function(){},add_action_icon:function(Z,ae,ad,ac,Y,ab){var aa=this;this.action_icons[Z]=$("<a/>").attr("href","javascript:void(0);").attr("title",ae).addClass("icon-button").addClass(ad).tipsy({gravity:"s"}).click(function(){ac(aa)}).appendTo(this.icons_div);if(ab){this.action_icons[Z].hide()}},build_action_icons:function(Y){var aa;for(var Z=0;Z<Y.length;Z++){aa=Y[Z];this.add_action_icon(aa.name,aa.title,aa.css_class,aa.on_click_fn,aa.prepend,aa.hide)}},update_icons:function(){},hide_contents:function(){},show_contents:function(){}});var v=function(Z,Y,aa){p.call(this,Z,Y,aa);this.obj_type=aa.obj_type;this.drawables=[]};o(v.prototype,p.prototype,{unpack_drawables:function(aa){this.drawables=[];var Z;for(var Y=0;Y<aa.length;Y++){Z=object_from_template(aa[Y],this);this.add_drawable(Z)}},init:function(){for(var Y=0;Y<this.drawables.length;Y++){this.drawables[Y].init()}},_draw:function(){for(var Y=0;Y<this.drawables.length;Y++){this.drawables[Y]._draw()}},to_dict:function(){var Z=[];for(var Y=0;Y<this.drawables.length;Y++){Z.push(this.drawables[Y].to_dict())}return{name:this.name,prefs:this.prefs,obj_type:this.obj_type,drawables:Z}},add_drawable:function(Y){this.drawables.push(Y);Y.container=this;this.changed()},add_drawable_before:function(aa,Y){this.changed();var Z=this.drawables.indexOf(Y);if(Z!==-1){this.drawables.splice(Z,0,aa);return true}return false},replace_drawable:function(aa,Y,Z){var ab=this.drawables.indexOf(aa);if(ab!==-1){this.drawables[ab]=Y;if(Z){aa.container_div.replaceWith(Y.container_div)}this.changed()}return ab},remove_drawable:function(Z){var Y=this.drawables.indexOf(Z);if(Y!==-1){this.drawables.splice(Y,1);Z.container=null;this.changed();return true}return false},move_drawable:function(Z,aa){var Y=this.drawables.indexOf(Z);if(Y!==-1){this.drawables.splice(Y,1);this.drawables.splice(aa,0,Z);this.changed();return true}return false}});var L=function(Z,Y,ab){o(ab,{obj_type:"DrawableGroup",drag_handle_class:"group-handle"});v.call(this,Z,Y,ab);this.content_div=$("<div/>").addClass("content-div").attr("id","group_"+this.id+"_content_div").appendTo(this.container_div);k(this.container_div,this);k(this.content_div,this);l(this.container_div,this.drag_handle_class,".group",this);this.filters_manager=new U(this);this.header_div.after(this.filters_manager.parent_div);this.saved_filters_managers=[];if("drawables" in ab){this.unpack_drawables(ab.drawables)}if("filters" in ab){var aa=this.filters_manager;this.filters_manager=new U(this,ab.filters);aa.parent_div.replaceWith(this.filters_manager.parent_div);if(ab.filters.visible){this.setup_multitrack_filtering()}}};o(L.prototype,p.prototype,v.prototype,{action_icons_def:[p.prototype.action_icons_def[0],p.prototype.action_icons_def[1],{name:"composite_icon",title:"Show composite track",css_class:"layers-stack",on_click_fn:function(Y){$(".tipsy").remove();Y.show_composite_track()}},{name:"filters_icon",title:"Filters",css_class:"filters-icon",on_click_fn:function(Y){if(Y.filters_manager.visible()){Y.filters_manager.clear_filters();Y._restore_filter_managers()}else{Y.setup_multitrack_filtering();Y.request_draw(true)}Y.filters_manager.toggle()}},p.prototype.action_icons_def[2]],build_container_div:function(){var Y=$("<div/>").addClass("group").attr("id","group_"+this.id);if(this.container){this.container.content_div.append(Y)}return Y},build_header_div:function(){var Y=$("<div/>").addClass("track-header");Y.append($("<div/>").addClass(this.drag_handle_class));this.name_div=$("<div/>").addClass("track-name").text(this.name).appendTo(Y);return Y},hide_contents:function(){this.tiles_div.hide()},show_contents:function(){this.tiles_div.show();this.request_draw()},update_icons:function(){var aa=this.drawables.length;if(aa===0){this.action_icons.composite_icon.hide();this.action_icons.filters_icon.hide()}else{if(aa===1){if(this.drawables[0] instanceof g){this.action_icons.composite_icon.show()}this.action_icons.filters_icon.hide()}else{var ah,ag,ae,ak=true,ac=this.drawables[0].get_type(),Y=0;for(ah=0;ah<aa;ah++){ae=this.drawables[ah];if(ae.get_type()!==ac){can_composite=false;break}if(ae instanceof c){Y++}}if(ak||Y===1){this.action_icons.composite_icon.show()}else{this.action_icons.composite_icon.hide();$(".tipsy").remove()}if(Y>1&&Y===this.drawables.length){var al={},Z;ae=this.drawables[0];for(ag=0;ag<ae.filters_manager.filters.length;ag++){Z=ae.filters_manager.filters[ag];al[Z.name]=[Z]}for(ah=1;ah<this.drawables.length;ah++){ae=this.drawables[ah];for(ag=0;ag<ae.filters_manager.filters.length;ag++){Z=ae.filters_manager.filters[ag];if(Z.name in al){al[Z.name].push(Z)}}}this.filters_manager.remove_all();var ab,ad,af,ai;for(var aj in al){ab=al[aj];if(ab.length===Y){ad=new P({name:ab[0].name,index:ab[0].index});this.filters_manager.add_filter(ad)}}if(this.filters_manager.filters.length>0){this.action_icons.filters_icon.show()}else{this.action_icons.filters_icon.hide()}}else{this.action_icons.filters_icon.hide()}}}},_restore_filter_managers:function(){for(var Y=0;Y<this.drawables.length;Y++){this.drawables[Y].filters_manager=this.saved_filters_managers[Y]}this.saved_filters_managers=[]},setup_multitrack_filtering:function(){if(this.filters_manager.filters.length>0){this.saved_filters_managers=[];for(var Y=0;Y<this.drawables.length;Y++){drawable=this.drawables[Y];this.saved_filters_managers.push(drawable.filters_manager);drawable.filters_manager=this.filters_manager}}this.filters_manager.init_filters()},show_composite_track:function(){var ac=[];for(var Z=0;Z<this.drawables.length;Z++){ac.push(this.drawables[Z].name)}var aa="Composite Track of "+this.drawables.length+" tracks ("+ac.join(", ")+")";var ab=new g(this.view,this.view,{name:aa,drawables:this.drawables});var Y=this.container.replace_drawable(this,ab,true);ab.request_draw()},add_drawable:function(Y){v.prototype.add_drawable.call(this,Y);this.update_icons()},remove_drawable:function(Y){v.prototype.remove_drawable.call(this,Y);this.update_icons()},to_dict:function(){if(this.filters_manager.visible()){this._restore_filter_managers()}var Y=o(v.prototype.to_dict.call(this),{filters:this.filters_manager.to_dict()});if(this.filters_manager.visible()){this.setup_multitrack_filtering()}return Y},request_draw:function(Y,aa){for(var Z=0;Z<this.drawables.length;Z++){this.drawables[Z].request_draw(Y,aa)}}});var W=function(Y){o(Y,{obj_type:"View"});v.call(this,"View",Y.container,Y);this.chrom=null;this.vis_id=Y.vis_id;this.dbkey=Y.dbkey;this.label_tracks=[];this.tracks_to_be_redrawn=[];this.max_low=0;this.max_high=0;this.zoom_factor=3;this.min_separation=30;this.has_changes=false;this.load_chroms_deferred=null;this.init();this.canvas_manager=new CanvasManager(this.container.get(0).ownerDocument);this.reset()};_.extend(W.prototype,Backbone.Events);o(W.prototype,v.prototype,{init:function(){this.requested_redraw=false;var aa=this.container,Y=this;this.top_container=$("<div/>").addClass("top-container").appendTo(aa);this.browser_content_div=$("<div/>").addClass("content").css("position","relative").appendTo(aa);this.bottom_container=$("<div/>").addClass("bottom-container").appendTo(aa);this.top_labeltrack=$("<div/>").addClass("top-labeltrack").appendTo(this.top_container);this.viewport_container=$("<div/>").addClass("viewport-container").attr("id","viewport-container").appendTo(this.browser_content_div);this.content_div=this.viewport_container;k(this.viewport_container,Y);this.intro_div=$("<div/>").addClass("intro").appendTo(this.viewport_container).hide();var ab=$("<div/>").text("Add Datasets to Visualization").addClass("action-button").appendTo(this.intro_div).click(function(){add_datasets(add_datasets_url,add_track_async_url,function(ac){_.each(ac,function(ad){Y.add_drawable(object_from_template(ad,Y,Y))})})});this.nav_labeltrack=$("<div/>").addClass("nav-labeltrack").appendTo(this.bottom_container);this.nav_container=$("<div/>").addClass("trackster-nav-container").prependTo(this.top_container);this.nav=$("<div/>").addClass("trackster-nav").appendTo(this.nav_container);this.overview=$("<div/>").addClass("overview").appendTo(this.bottom_container);this.overview_viewport=$("<div/>").addClass("overview-viewport").appendTo(this.overview);this.overview_close=$("<a/>").attr("href","javascript:void(0);").attr("title","Close overview").addClass("icon-button overview-close tooltip").hide().appendTo(this.overview_viewport);this.overview_highlight=$("<div/>").addClass("overview-highlight").hide().appendTo(this.overview_viewport);this.overview_box_background=$("<div/>").addClass("overview-boxback").appendTo(this.overview_viewport);this.overview_box=$("<div/>").addClass("overview-box").appendTo(this.overview_viewport);this.default_overview_height=this.overview_box.height();this.nav_controls=$("<div/>").addClass("nav-controls").appendTo(this.nav);this.chrom_select=$("<select/>").attr({name:"chrom"}).css("width","15em").addClass("no-autocomplete").append("<option value=''>Loading</option>").appendTo(this.nav_controls);var Z=function(ac){if(ac.type==="focusout"||(ac.keyCode||ac.which)===13||(ac.keyCode||ac.which)===27){if((ac.keyCode||ac.which)!==27){Y.go_to($(this).val())}$(this).hide();$(this).val("");Y.location_span.show();Y.chrom_select.show()}};this.nav_input=$("<input/>").addClass("nav-input").hide().bind("keyup focusout",Z).appendTo(this.nav_controls);this.location_span=$("<span/>").addClass("location").attr("original-title","Click to change location").tipsy({gravity:"n"}).appendTo(this.nav_controls);this.location_span.click(function(){Y.location_span.hide();Y.chrom_select.hide();Y.nav_input.val(Y.chrom+":"+Y.low+"-"+Y.high);Y.nav_input.css("display","inline-block");Y.nav_input.select();Y.nav_input.focus()});if(this.vis_id!==undefined){this.hidden_input=$("<input/>").attr("type","hidden").val(this.vis_id).appendTo(this.nav_controls)}this.zo_link=$("<a/>").attr("id","zoom-out").attr("title","Zoom out").tipsy({gravity:"n"}).click(function(){Y.zoom_out();Y.request_redraw()}).appendTo(this.nav_controls);this.zi_link=$("<a/>").attr("id","zoom-in").attr("title","Zoom in").tipsy({gravity:"n"}).click(function(){Y.zoom_in();Y.request_redraw()}).appendTo(this.nav_controls);this.load_chroms_deferred=this.load_chroms({low:0});this.chrom_select.bind("change",function(){Y.change_chrom(Y.chrom_select.val())});this.browser_content_div.click(function(ac){$(this).find("input").trigger("blur")});this.browser_content_div.bind("dblclick",function(ac){Y.zoom_in(ac.pageX,this.viewport_container)});this.overview_box.bind("dragstart",function(ac,ad){this.current_x=ad.offsetX}).bind("drag",function(ac,ae){var af=ae.offsetX-this.current_x;this.current_x=ae.offsetX;var ad=Math.round(af/Y.viewport_container.width()*(Y.max_high-Y.max_low));Y.move_delta(-ad)});this.overview_close.click(function(){Y.reset_overview()});this.viewport_container.bind("draginit",function(ac,ad){if(ac.clientX>Y.viewport_container.width()-16){return false}}).bind("dragstart",function(ac,ad){ad.original_low=Y.low;ad.current_height=ac.clientY;ad.current_x=ad.offsetX}).bind("drag",function(ae,ag){var ac=$(this);var ah=ag.offsetX-ag.current_x;var ad=ac.scrollTop()-(ae.clientY-ag.current_height);ac.scrollTop(ad);ag.current_height=ae.clientY;ag.current_x=ag.offsetX;var af=Math.round(ah/Y.viewport_container.width()*(Y.high-Y.low));Y.move_delta(af)}).bind("mousewheel",function(ae,ag,ad,ac){if(ad){ad*=50;var af=Math.round(-ad/Y.viewport_container.width()*(Y.high-Y.low));Y.move_delta(af)}});this.top_labeltrack.bind("dragstart",function(ac,ad){return $("<div />").css({height:Y.browser_content_div.height()+Y.top_labeltrack.height()+Y.nav_labeltrack.height()+1,top:"0px",position:"absolute","background-color":"#ccf",opacity:0.5,"z-index":1000}).appendTo($(this))}).bind("drag",function(ag,ah){$(ah.proxy).css({left:Math.min(ag.pageX,ah.startX)-Y.container.offset().left,width:Math.abs(ag.pageX-ah.startX)});var ad=Math.min(ag.pageX,ah.startX)-Y.container.offset().left,ac=Math.max(ag.pageX,ah.startX)-Y.container.offset().left,af=(Y.high-Y.low),ae=Y.viewport_container.width();Y.update_location(Math.round(ad/ae*af)+Y.low,Math.round(ac/ae*af)+Y.low)}).bind("dragend",function(ah,ai){var ad=Math.min(ah.pageX,ai.startX),ac=Math.max(ah.pageX,ai.startX),af=(Y.high-Y.low),ae=Y.viewport_container.width(),ag=Y.low;Y.low=Math.round(ad/ae*af)+ag;Y.high=Math.round(ac/ae*af)+ag;$(ai.proxy).remove();Y.request_redraw()});this.add_label_track(new V(this,{content_div:this.top_labeltrack}));this.add_label_track(new V(this,{content_div:this.nav_labeltrack}));$(window).bind("resize",function(){if(this.resize_timer){clearTimeout(this.resize_timer)}this.resize_timer=setTimeout(function(){Y.resize_window()},500)});$(document).bind("redraw",function(){Y.redraw()});this.reset();$(window).trigger("resize")},changed:function(){this.has_changes=true},update_intro_div:function(){if(this.drawables.length===0){this.intro_div.show()}else{this.intro_div.hide()}},trigger_navigate:function(Z,ab,Y,ac){if(this.timer){clearTimeout(this.timer)}if(ac){var aa=this;this.timer=setTimeout(function(){aa.trigger("navigate",Z+":"+ab+"-"+Y)},500)}else{view.trigger("navigate",Z+":"+ab+"-"+Y)}},update_location:function(Y,aa){this.location_span.text(commatize(Y)+" - "+commatize(aa));this.nav_input.val(this.chrom+":"+commatize(Y)+"-"+commatize(aa));var Z=view.chrom_select.val();if(Z!==""){this.trigger_navigate(Z,view.low,view.high,true)}},load_chroms:function(aa){aa.num=t;aa.dbkey=this.dbkey;var Y=this,Z=$.Deferred();$.ajax({url:chrom_url,data:aa,dataType:"json",success:function(ac){if(ac.chrom_info.length===0){alert("Invalid chromosome: "+aa.chrom);return}if(ac.reference){Y.add_label_track(new x(Y))}Y.chrom_data=ac.chrom_info;var af='<option value="">Select Chrom/Contig</option>';for(var ae=0,ab=Y.chrom_data.length;ae<ab;ae++){var ad=Y.chrom_data[ae].chrom;af+='<option value="'+ad+'">'+ad+"</option>"}if(ac.prev_chroms){af+='<option value="previous">Previous '+t+"</option>"}if(ac.next_chroms){af+='<option value="next">Next '+t+"</option>"}Y.chrom_select.html(af);Y.chrom_start_index=ac.start_index;Z.resolve(ac)},error:function(){alert("Could not load chroms for this dbkey:",Y.dbkey)}});return Z},change_chrom:function(ad,Z,af){var aa=this;if(!aa.chrom_data){aa.load_chroms_deferred.then(function(){aa.change_chrom(ad,Z,af)});return}if(!ad||ad==="None"){return}if(ad==="previous"){aa.load_chroms({low:this.chrom_start_index-t});return}if(ad==="next"){aa.load_chroms({low:this.chrom_start_index+t});return}var ae=$.grep(aa.chrom_data,function(ag,ah){return ag.chrom===ad})[0];if(ae===undefined){aa.load_chroms({chrom:ad},function(){aa.change_chrom(ad,Z,af)});return}else{if(ad!==aa.chrom){aa.chrom=ad;aa.chrom_select.val(aa.chrom);aa.max_high=ae.len-1;aa.reset();aa.request_redraw(true);for(var ac=0,Y=aa.drawables.length;ac<Y;ac++){var ab=aa.drawables[ac];if(ab.init){ab.init()}}if(aa.reference_track){aa.reference_track.init()}}if(Z!==undefined&&af!==undefined){aa.low=Math.max(Z,0);aa.high=Math.min(af,aa.max_high)}else{aa.low=0;aa.high=aa.max_high}aa.reset_overview();aa.request_redraw()}},go_to:function(ac){ac=ac.replace(/ |,/g,"");var ag=this,Y,ab,Z=ac.split(":"),ae=Z[0],af=Z[1];if(af!==undefined){try{var ad=af.split("-");Y=parseInt(ad[0],10);ab=parseInt(ad[1],10)}catch(aa){return false}}ag.change_chrom(ae,Y,ab)},move_fraction:function(aa){var Y=this;var Z=Y.high-Y.low;this.move_delta(aa*Z)},move_delta:function(ab){var Y=this;var aa=Y.high-Y.low;if(Y.low-ab<Y.max_low){Y.low=Y.max_low;Y.high=Y.max_low+aa}else{if(Y.high-ab>Y.max_high){Y.high=Y.max_high;Y.low=Y.max_high-aa}else{Y.high-=ab;Y.low-=ab}}Y.request_redraw();var Z=Y.chrom_select.val();this.trigger_navigate(Z,Y.low,Y.high,true)},add_drawable:function(Y){v.prototype.add_drawable.call(this,Y);Y.init();this.changed();this.update_intro_div()},add_label_track:function(Y){Y.view=this;Y.init();this.label_tracks.push(Y)},remove_drawable:function(aa,Z){v.prototype.remove_drawable.call(this,aa);if(Z){var Y=this;aa.container_div.hide(0,function(){$(this).remove();Y.update_intro_div()})}},reset:function(){this.low=this.max_low;this.high=this.max_high;this.viewport_container.find(".yaxislabel").remove()},request_redraw:function(ag,Y,af,ah){var ae=this,ad=(ah?[ah]:ae.drawables),aa;var Z;for(var ac=0;ac<ad.length;ac++){Z=ad[ac];aa=-1;for(var ab=0;ab<ae.tracks_to_be_redrawn.length;ab++){if(ae.tracks_to_be_redrawn[ab][0]===Z){aa=ab;break}}if(aa<0){ae.tracks_to_be_redrawn.push([Z,Y,af])}else{ae.tracks_to_be_redrawn[ac][1]=Y;ae.tracks_to_be_redrawn[ac][2]=af}}if(!this.requested_redraw){requestAnimationFrame(function(){ae._redraw(ag)});this.requested_redraw=true}},_redraw:function(ai){this.requested_redraw=false;var af=this.low,ab=this.high;if(af<this.max_low){af=this.max_low}if(ab>this.max_high){ab=this.max_high}var ah=this.high-this.low;if(this.high!==0&&ah<this.min_separation){ab=af+this.min_separation}this.low=Math.floor(af);this.high=Math.ceil(ab);this.update_location(this.low,this.high);this.resolution_b_px=(this.high-this.low)/this.viewport_container.width();this.resolution_px_b=this.viewport_container.width()/(this.high-this.low);var Y=(this.low/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var ae=((this.high-this.low)/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var aj=13;this.overview_box.css({left:Y,width:Math.max(aj,ae)}).show();if(ae<aj){this.overview_box.css("left",Y-(aj-ae)/2)}if(this.overview_highlight){this.overview_highlight.css({left:Y,width:ae})}if(!ai){var aa,Z,ag;for(var ac=0,ad=this.tracks_to_be_redrawn.length;ac<ad;ac++){aa=this.tracks_to_be_redrawn[ac][0];Z=this.tracks_to_be_redrawn[ac][1];ag=this.tracks_to_be_redrawn[ac][2];if(aa){aa._draw(Z,ag)}}this.tracks_to_be_redrawn=[];for(ac=0,ad=this.label_tracks.length;ac<ad;ac++){this.label_tracks[ac]._draw()}}},zoom_in:function(Z,aa){if(this.max_high===0||this.high-this.low<=this.min_separation){return}var ab=this.high-this.low,ac=ab/2+this.low,Y=(ab/this.zoom_factor)/2;if(Z){ac=Z/this.viewport_container.width()*(this.high-this.low)+this.low}this.low=Math.round(ac-Y);this.high=Math.round(ac+Y);this.changed();this.request_redraw()},zoom_out:function(){if(this.max_high===0){return}var Z=this.high-this.low,aa=Z/2+this.low,Y=(Z*this.zoom_factor)/2;this.low=Math.round(aa-Y);this.high=Math.round(aa+Y);this.changed();this.request_redraw()},resize_window:function(){this.viewport_container.height(this.container.height()-this.top_container.height()-this.bottom_container.height());this.request_redraw()},set_overview:function(aa){if(this.overview_drawable){if(this.overview_drawable.dataset_id===aa.dataset_id){return}this.overview_viewport.find(".track").remove()}var Z=aa.copy({content_div:this.overview_viewport}),Y=this;Z.header_div.hide();Z.is_overview=true;Y.overview_drawable=Z;this.overview_drawable.postdraw_actions=function(){Y.overview_highlight.show().height(Y.overview_drawable.content_div.height());Y.overview_viewport.height(Y.overview_drawable.content_div.height()+Y.overview_box.outerHeight());Y.overview_close.show();Y.resize_window()};Y.overview_drawable.request_draw();this.changed()},reset_overview:function(){$(".tipsy").remove();this.overview_viewport.find(".track-tile").remove();this.overview_viewport.height(this.default_overview_height);this.overview_box.height(this.default_overview_height);this.overview_close.hide();this.overview_highlight.hide();view.resize_window();view.overview_drawable=null}});var q=function(aa,af,ab){this.track=aa;this.name=af.name;this.params=[];var am=af.params;for(var ac=0;ac<am.length;ac++){var ah=am[ac],Z=ah.name,al=ah.label,ad=unescape(ah.html),an=ah.value,aj=ah.type;if(aj==="number"){this.params.push(new e(Z,al,ad,(Z in ab?ab[Z]:an),ah.min,ah.max))}else{if(aj==="select"){this.params.push(new J(Z,al,ad,(Z in ab?ab[Z]:an)))}else{console.log("WARNING: unrecognized tool parameter type:",Z,aj)}}}this.parent_div=$("<div/>").addClass("dynamic-tool").hide();this.parent_div.bind("drag",function(ap){ap.stopPropagation()}).click(function(ap){ap.stopPropagation()}).bind("dblclick",function(ap){ap.stopPropagation()});var ak=$("<div class='tool-name'>").appendTo(this.parent_div).text(this.name);var ai=this.params;var ag=this;$.each(this.params,function(aq,au){var at=$("<div>").addClass("param-row").appendTo(ag.parent_div);var ap=$("<div>").addClass("param-label").text(au.label).appendTo(at);var ar=$("<div/>").addClass("param-input").html(au.html).appendTo(at);ar.find(":input").val(au.value);$("<div style='clear: both;'/>").appendTo(at)});this.parent_div.find("input").click(function(){$(this).select()});var ao=$("<div>").addClass("param-row").appendTo(this.parent_div);var ae=$("<input type='submit'>").attr("value","Run on complete dataset").appendTo(ao);var Y=$("<input type='submit'>").attr("value","Run on visible region").css("margin-left","3em").appendTo(ao);Y.click(function(){ag.run_on_region()});ae.click(function(){ag.run_on_dataset()});if("visible" in ab&&ab.visible){this.parent_div.show()}};o(q.prototype,{update_params:function(){for(var Y=0;Y<this.params.length;Y++){this.params[Y].update_value()}},state_dict:function(){var Z={};for(var Y=0;Y<this.params.length;Y++){Z[this.params[Y].name]=this.params[Y].value}Z.visible=this.parent_div.is(":visible");return Z},get_param_values_dict:function(){var Y={};this.parent_div.find(":input").each(function(){var Z=$(this).attr("name"),aa=$(this).val();Y[Z]=aa});return Y},get_param_values:function(){var Y=[];this.parent_div.find(":input").each(function(){var Z=$(this).attr("name"),aa=$(this).val();if(Z){Y[Y.length]=aa}});return Y},run_on_dataset:function(){var Y=this;Y.run({target_dataset_id:this.track.original_dataset_id,tool_id:Y.name},null,function(Z){show_modal(Y.name+" is Running",Y.name+" is running on the complete dataset. Tool outputs are in dataset's history.",{Close:hide_modal})})},run_on_region:function(){var Z={target_dataset_id:this.track.original_dataset_id,action:"rerun",tool_id:this.name,regions:[{chrom:this.track.view.chrom,start:this.track.view.low,end:this.track.view.high}]},ad=this.track,aa=Z.tool_id+ad.tool_region_and_parameters_str(Z.chrom,Z.low,Z.high),Y;if(ad.container===view){var ac=new L(view,view,{name:this.name});var ab=ad.container.replace_drawable(ad,ac,false);ac.container_div.insertBefore(ad.view.content_div.children()[ab]);ac.add_drawable(ad);ad.container_div.appendTo(ac.content_div);Y=ac}else{Y=ad.container}var ae=new ad.constructor(view,Y,{name:aa,hda_ldda:"hda"});ae.init_for_tool_data();ae.change_mode(ad.mode);ae.set_filters_manager(ad.filters_manager.copy(ae));ae.update_icons();Y.add_drawable(ae);ae.tiles_div.text("Starting job.");this.update_params();this.run(Z,ae,function(af){ae.set_dataset(new Dataset(af));ae.tiles_div.text("Running job.");ae.init()})},run:function(Y,aa,ab){Y.inputs=this.get_param_values_dict();var Z=new ServerStateDeferred({ajax_settings:{url:galaxy_paths.get("tool_url"),data:JSON.stringify(Y),dataType:"json",contentType:"application/json",type:"POST"},interval:2000,success_fn:function(ac){return ac!=="pending"}});$.when(Z.go()).then(function(ac){if(ac==="no converter"){aa.container_div.addClass("error");aa.content_div.text(F)}else{if(ac.error){aa.container_div.addClass("error");aa.content_div.text(u+ac.message)}else{ab(ac)}}})}});var J=function(Z,Y,aa,ab){this.name=Z;this.label=Y;this.html=$(aa);this.value=ab};o(J.prototype,{update_value:function(){this.value=$(this.html).val()}});var e=function(aa,Z,ac,ad,ab,Y){J.call(this,aa,Z,ac,ad);this.min=ab;this.max=Y};o(e.prototype,J.prototype,{update_value:function(){J.prototype.update_value.call(this);this.value=parseFloat(this.value)}});var f=function(Y){this.manager=null;this.name=Y.name;this.index=Y.index;this.tool_id=Y.tool_id;this.tool_exp_name=Y.tool_exp_name};o(f.prototype,{to_dict:function(){return{name:this.name,index:this.index,tool_id:this.tool_id,tool_exp_name:this.tool_exp_name}}});var P=function(ah){f.call(this,ah);this.low=("low" in ah?ah.low:-Number.MAX_VALUE);this.high=("high" in ah?ah.high:Number.MAX_VALUE);this.min=("min" in ah?ah.min:Number.MAX_VALUE);this.max=("max" in ah?ah.max:-Number.MAX_VALUE);this.container=null;this.slider=null;this.slider_label=null;var ad=function(ai,aj,ak){ai.click(function(){var ap=aj.text(),an=parseFloat(ak.slider("option","max")),am=(an<=1?4:an<=1000000?an.toString().length:6),ao=false,al=$(this).parents(".slider-row");al.addClass("input");if(ak.slider("option","values")){am=2*am+1;ao=true}aj.text("");$("<input type='text'/>").attr("size",am).attr("maxlength",am).attr("value",ap).appendTo(aj).focus().select().click(function(aq){aq.stopPropagation()}).blur(function(){$(this).remove();aj.text(ap);al.removeClass("input")}).keyup(function(av){if(av.keyCode===27){$(this).trigger("blur")}else{if(av.keyCode===13){var at=ak.slider("option","min"),aq=ak.slider("option","max"),au=function(aw){return(isNaN(aw)||aw>aq||aw<at)},ar=$(this).val();if(!ao){ar=parseFloat(ar);if(au(ar)){alert("Parameter value must be in the range ["+at+"-"+aq+"]");return $(this)}}else{ar=ar.split("-");ar=[parseFloat(ar[0]),parseFloat(ar[1])];if(au(ar[0])||au(ar[1])){alert("Parameter value must be in the range ["+at+"-"+aq+"]");return $(this)}}ak.slider((ao?"values":"value"),ar);al.removeClass("input")}}})})};var Z=this;Z.parent_div=$("<div/>").addClass("filter-row slider-row");var Y=$("<div/>").addClass("elt-label").appendTo(Z.parent_div),af=$("<span/>").addClass("slider-name").text(Z.name+" ").appendTo(Y),aa=$("<span/>").text(this.low+"-"+this.high),ab=$("<span/>").addClass("slider-value").appendTo(Y).append("[").append(aa).append("]");Z.values_span=aa;var ae=$("<div/>").addClass("slider").appendTo(Z.parent_div);Z.control_element=$("<div/>").attr("id",Z.name+"-filter-control").appendTo(ae);var ac=[0,0];Z.control_element.slider({range:true,min:this.min,max:this.max,step:this.get_slider_step(this.min,this.max),values:[this.low,this.high],slide:function(ai,aj){Z.slide(ai,aj)},change:function(ai,aj){Z.control_element.slider("option","slide").call(Z.control_element,ai,aj)}});Z.slider=Z.control_element;Z.slider_label=aa;ad(ab,aa,Z.control_element);var ag=$("<div/>").addClass("display-controls").appendTo(Z.parent_div);this.transparency_icon=create_action_icon("Use filter for data transparency","layer-transparent",function(){if(Z.manager.alpha_filter!==Z){Z.manager.alpha_filter=Z;Z.manager.parent_div.find(".layer-transparent").removeClass("active").hide();Z.transparency_icon.addClass("active").show()}else{Z.manager.alpha_filter=null;Z.transparency_icon.removeClass("active")}Z.manager.track.request_draw(true,true)}).appendTo(ag).hide();this.height_icon=create_action_icon("Use filter for data height","arrow-resize-090",function(){if(Z.manager.height_filter!==Z){Z.manager.height_filter=Z;Z.manager.parent_div.find(".arrow-resize-090").removeClass("active").hide();Z.height_icon.addClass("active").show()}else{Z.manager.height_filter=null;Z.height_icon.removeClass("active")}Z.manager.track.request_draw(true,true)}).appendTo(ag).hide();Z.parent_div.hover(function(){Z.transparency_icon.show();Z.height_icon.show()},function(){if(Z.manager.alpha_filter!==Z){Z.transparency_icon.hide()}if(Z.manager.height_filter!==Z){Z.height_icon.hide()}});$("<div style='clear: both;'/>").appendTo(Z.parent_div)};o(P.prototype,{to_dict:function(){var Y=f.prototype.to_dict.call(this);return o(Y,{type:"number",min:this.min,max:this.max,low:this.low,high:this.high})},copy:function(){return new P({name:this.name,index:this.index,tool_id:this.tool_id,tool_exp_name:this.tool_exp_name})},get_slider_step:function(aa,Y){var Z=Y-aa;return(Z<=2?0.01:1)},slide:function(Z,aa){var Y=aa.values;this.values_span.text(Y[0]+"-"+Y[1]);this.low=Y[0];this.high=Y[1];this.manager.track.request_draw(true,true)},applies_to:function(Y){if(Y.length>this.index){return true}return false},_keep_val:function(Y){return(isNaN(Y)||(Y>=this.low&&Y<=this.high))},keep:function(Z){if(!this.applies_to(Z)){return true}var ab=this;var ac=Z[this.index];if(ac instanceof Array){var aa=true;for(var Y=0;Y<ac.length;Y++){if(!this._keep_val(ac[Y])){aa=false;break}}return aa}else{return this._keep_val(Z[this.index])}},update_attrs:function(ab){var Y=false;if(!this.applies_to(ab)){return Y}var Z=ab[this.index];if(!(Z instanceof Array)){Z=[Z]}for(var aa=0;aa<Z.length;aa++){var ac=Z[aa];if(ac<this.min){this.min=Math.floor(ac);Y=true}if(ac>this.max){this.max=Math.ceil(ac);Y=true}}return Y},update_ui_elt:function(){if(this.min<this.max){this.parent_div.show()}else{this.parent_div.hide()}var Z=this.slider.slider("option","min"),Y=this.slider.slider("option","max");if(this.min<Z||this.max>Y){this.slider.slider("option","min",this.min);this.slider.slider("option","max",this.max);this.slider.slider("option","step",this.get_slider_step(this.min,this.max));this.slider.slider("option","values",[this.min,this.max])}}});var U=function(aa,ag){this.track=aa;this.alpha_filter=null;this.height_filter=null;this.filters=[];this.parent_div=$("<div/>").addClass("filters").hide();this.parent_div.bind("drag",function(ai){ai.stopPropagation()}).click(function(ai){ai.stopPropagation()}).bind("dblclick",function(ai){ai.stopPropagation()}).bind("keydown",function(ai){ai.stopPropagation()});if(ag&&"filters" in ag){var Y=("alpha_filter" in ag?ag.alpha_filter:null),ab=("height_filter" in ag?ag.height_filter:null),ad=ag.filters,Z;for(var ae=0;ae<ad.length;ae++){if(ad[ae].type==="number"){Z=new P(ad[ae]);this.add_filter(Z);if(Z.name===Y){this.alpha_filter=Z;Z.transparency_icon.addClass("active").show()}if(Z.name===ab){this.height_filter=Z;Z.height_icon.addClass("active").show()}}else{console.log("ERROR: unsupported filter: ",name,type)}}if("visible" in ag&&ag.visible){this.parent_div.show()}}if(this.filters.length!==0){var ah=$("<div/>").addClass("param-row").appendTo(this.parent_div);var af=$("<input type='submit'/>").attr("value","Run on complete dataset").appendTo(ah);var ac=this;af.click(function(){ac.run_on_dataset()})}};o(U.prototype,{show:function(){this.parent_div.show()},hide:function(){this.parent_div.hide()},toggle:function(){this.parent_div.toggle()},visible:function(){return this.parent_div.is(":visible")},to_dict:function(){var ab={},aa=[],Z;for(var Y=0;Y<this.filters.length;Y++){Z=this.filters[Y];aa.push(Z.to_dict())}ab.filters=aa;ab.alpha_filter=(this.alpha_filter?this.alpha_filter.name:null);ab.height_filter=(this.height_filter?this.height_filter.name:null);ab.visible=this.parent_div.is(":visible");return ab},copy:function(Z){var aa=new U(Z);for(var Y=0;Y<this.filters.length;Y++){aa.add_filter(this.filters[Y].copy())}return aa},add_filter:function(Y){Y.manager=this;this.parent_div.append(Y.parent_div);this.filters.push(Y)},remove_all:function(){this.filters=[];this.parent_div.children().remove()},init_filters:function(){for(var Y=0;Y<this.filters.length;Y++){var Z=this.filters[Y];Z.update_ui_elt()}},clear_filters:function(){for(var Y=0;Y<this.filters.length;Y++){var Z=this.filters[Y];Z.slider.slider("option","values",[Z.min,Z.max])}this.alpha_filter=null;this.height_filter=null;this.parent_div.find(".icon-button").hide()},run_on_dataset:function(){var ae=function(ai,ag,ah){if(!(ag in ai)){ai[ag]=ah}return ai[ag]};var ad={},af,Y;for(var ac=0;ac<this.filters.length;ac++){af=this.filters[ac];if(af.tool_id){if(af.min!==af.low){Y=ae(ad,af.tool_id,[]);Y[Y.length]=af.tool_exp_name+" >= "+af.low}if(af.max!==af.high){Y=ae(ad,af.tool_id,[]);Y[Y.length]=af.tool_exp_name+" <= "+af.high}}}var Z=[];for(var ab in ad){Z[Z.length]=[ab,ad[ab]]}(function aa(am,aj){var ah=aj[0],ai=ah[0],al=ah[1],ak="("+al.join(") and (")+")",ag={cond:ak,input:am,target_dataset_id:am,tool_id:ai},aj=aj.slice(1);$.getJSON(run_tool_url,ag,function(an){if(an.error){show_modal("Filter Dataset","Error running tool "+ai,{Close:hide_modal})}else{if(aj.length===0){show_modal("Filtering Dataset","Filter(s) are running on the complete dataset. Outputs are in dataset's history.",{Close:hide_modal})}else{aa(an.dataset_id,aj)}}})})(this.track.dataset_id,Z)}});var y=function(Y,Z){H.Scaler.call(this,Z);this.filter=Y};y.prototype.gen_val=function(Y){if(this.filter.high===Number.MAX_VALUE||this.filter.low===-Number.MAX_VALUE||this.filter.low===this.filter.high){return this.default_val}return((parseFloat(Y[this.filter.index])-this.filter.low)/(this.filter.high-this.filter.low))};var B=function(Y){this.track=Y.track;this.params=Y.params;this.values={};this.restore_values((Y.saved_values?Y.saved_values:{}));this.onchange=Y.onchange};o(B.prototype,{restore_values:function(Y){var Z=this;$.each(this.params,function(aa,ab){if(Y[ab.key]!==undefined){Z.values[ab.key]=Y[ab.key]}else{Z.values[ab.key]=ab.default_value}})},build_form:function(){var ab=this;var Y=$("<div />");var aa;function Z(af,ac){for(var aj=0;aj<af.length;aj++){aa=af[aj];if(aa.hidden){continue}var ad="param_"+aj;var an=ab.values[aa.key];var aq=$("<div class='form-row' />").appendTo(ac);aq.append($("<label />").attr("for",ad).text(aa.label+":"));if(aa.type==="bool"){aq.append($('<input type="checkbox" />').attr("id",ad).attr("name",ad).attr("checked",an))}else{if(aa.type==="text"){aq.append($('<input type="text"/>').attr("id",ad).val(an).click(function(){$(this).select()}))}else{if(aa.type==="select"){var al=$("<select />").attr("id",ad);for(var ah=0;ah<aa.options.length;ah++){$("<option/>").text(aa.options[ah].label).attr("value",aa.options[ah].value).appendTo(al)}al.val(an);aq.append(al)}else{if(aa.type==="color"){var ap=$("<div/>").appendTo(aq),ak=$("<input />").attr("id",ad).attr("name",ad).val(an).css("float","left").appendTo(ap).click(function(at){$(".tipsy").hide();var ar=$(this).siblings(".tipsy");ar.css({left:$(this).position().left+$(this).width()+5,top:$(this).position().top-($(ar).height()/2)+($(this).height()/2)}).show();ar.click(function(au){au.stopPropagation()});$(document).bind("click.color-picker",function(){ar.hide();$(document).unbind("click.color-picker")});at.stopPropagation()}),ai=$("<a href='javascript:void(0)'/>").addClass("icon-button arrow-circle").appendTo(ap).attr("title","Set new random color").tipsy({gravity:"s"}),am=$("<div class='tipsy tipsy-west' style='position: absolute;' />").appendTo(ap).hide(),ae=$("<div style='background-color: black; padding: 10px;'></div>").appendTo(am),ao=$("<div/>").appendTo(ae),ag=$.farbtastic(ao,{width:100,height:100,callback:ak,color:an});ap.append($("<div/>").css("clear","both"));(function(ar){ai.click(function(){ar.setColor(get_random_color())})})(ag)}else{aq.append($("<input />").attr("id",ad).attr("name",ad).val(an))}}}}if(aa.help){aq.append($("<div class='help'/>").text(aa.help))}}}Z(this.params,Y);return Y},update_from_form:function(Y){var aa=this;var Z=false;$.each(this.params,function(ab,ad){if(!ad.hidden){var ae="param_"+ab;var ac=Y.find("#"+ae).val();if(ad.type==="float"){ac=parseFloat(ac)}else{if(ad.type==="int"){ac=parseInt(ac)}else{if(ad.type==="bool"){ac=Y.find("#"+ae).is(":checked")}}}if(ac!==aa.values[ad.key]){aa.values[ad.key]=ac;Z=true}}});if(Z){this.onchange();this.track.changed()}}});var b=function(Y,ac,aa,Z,ab){this.track=Y;this.region=ac;this.low=ac.get("start");this.high=ac.get("end");this.resolution=aa;this.html_elt=$("<div class='track-tile'/>").append(Z).height($(Z).attr("height"));this.data=ab;this.stale=false};b.prototype.predisplay_actions=function(){};var j=function(Y,ad,aa,Z,ab,ac){b.call(this,Y,ad,aa,Z,ab);this.max_val=ac};o(j.prototype,b.prototype);var K=function(ab,aj,ac,aa,ae,al,af,am,Z,ai){b.call(this,ab,aj,ac,aa,ae);this.mode=af;this.all_slotted=Z;this.feature_mapper=ai;this.has_icons=false;if(am){this.has_icons=true;var ag=this;aa=this.html_elt.children()[0],message_div=$("<div/>").addClass("tile-message").css({height:z-1,width:aa.width}).prependTo(this.html_elt);var ah=new GenomeRegion({chrom:ab.view.chrom,start:this.low,end:this.high}),ak=ae.length,ad=$("<a href='javascript:void(0);'/>").addClass("icon more-down").attr("title","For speed, only the first "+ak+" features in this region were obtained from server. Click to get more data including depth").tipsy({gravity:"s"}).appendTo(message_div),Y=$("<a href='javascript:void(0);'/>").addClass("icon more-across").attr("title","For speed, only the first "+ak+" features in this region were obtained from server. Click to get more data excluding depth").tipsy({gravity:"s"}).appendTo(message_div);ad.click(function(){ag.stale=true;ab.data_manager.get_more_data(ah,ab.mode,ag.resolution,{},ab.data_manager.DEEP_DATA_REQ);$(".tipsy").hide();ab.request_draw(true)}).dblclick(function(an){an.stopPropagation()});Y.click(function(){ag.stale=true;ab.data_manager.get_more_data(ah,ab.mode,ag.resolution,{},ab.data_manager.BROAD_DATA_REQ);$(".tipsy").hide();ab.request_draw(true)}).dblclick(function(an){an.stopPropagation()})}};o(K.prototype,b.prototype);K.prototype.predisplay_actions=function(){var Z=this,Y={};if(Z.mode!=="Pack"){return}$(this.html_elt).hover(function(){this.hovered=true;$(this).mousemove()},function(){this.hovered=false;$(this).parents(".track-content").children(".overlay").children(".feature-popup").remove()}).mousemove(function(ak){if(!this.hovered){return}var af=$(this).offset(),aj=ak.pageX-af.left,ai=ak.pageY-af.top,ao=Z.feature_mapper.get_feature_data(aj,ai),ag=(ao?ao[0]:null);$(this).parents(".track-content").children(".overlay").children(".feature-popup").each(function(){if(!ag||$(this).attr("id")!==ag.toString()){$(this).remove()}});if(ao){var ab=Y[ag];if(!ab){var ag=ao[0],al={name:ao[3],start:ao[1],end:ao[2],strand:ao[4]},ae=Z.track.filters_manager.filters,ad;for(var ah=0;ah<ae.length;ah++){ad=ae[ah];al[ad.name]=ao[ad.index]}var ab=$("<div/>").attr("id",ag).addClass("feature-popup"),ap=$("<table/>"),an,am,aq;for(an in al){am=al[an];aq=$("<tr/>").appendTo(ap);$("<th/>").appendTo(aq).text(an);$("<td/>").attr("align","left").appendTo(aq).text(typeof(am)==="number"?T(am,2):am)}ab.append($("<div class='feature-popup-inner'>").append(ap));Y[ag]=ab}ab.appendTo($(this).parents(".track-content").children(".overlay"));var ac=aj+parseInt(Z.html_elt.css("left"))-ab.width()/2,aa=ai+parseInt(Z.html_elt.css("top"))+7;ab.css("left",ac+"px").css("top",aa+"px")}else{if(!ak.isPropagationStopped()){ak.stopPropagation();$(this).siblings().each(function(){$(this).trigger(ak)})}}}).mouseleave(function(){$(this).parents(".track-content").children(".overlay").children(".feature-popup").remove()})};var h=function(aa,Z,ac){o(ac,{drag_handle_class:"draghandle"});p.call(this,aa,Z,ac);this.data_url=("data_url" in ac?ac.data_url:default_data_url);this.data_url_extra_params={};this.data_query_wait=("data_query_wait" in ac?ac.data_query_wait:G);this.dataset_check_url=("converted_datasets_state_url" in ac?ac.converted_datasets_state_url:converted_datasets_state_url);var Y=this,ab=new Dataset({id:ac.dataset_id,hda_ldda:ac.hda_ldda});this.data_manager=("data_manager" in ac?ac.data_manager:new GenomeDataManager({dataset:ab,data_url:Y.data_url,dataset_state_url:Y.dataset_check_url,data_mode_compatible:this.data_and_mode_compatible,can_subset:this.can_subset}));this.min_height_px=16;this.max_height_px=800;this.visible_height_px=0;this.content_div=$("<div class='track-content'>").appendTo(this.container_div);if(this.container){this.container.content_div.append(this.container_div);if(!("resize" in ac)||ac.resize){this.add_resize_handle()}}};o(h.prototype,p.prototype,{action_icons_def:[{name:"mode_icon",title:"Set display mode",css_class:"chevron-expand",on_click_fn:function(){}},p.prototype.action_icons_def[0],{name:"overview_icon",title:"Set as overview",css_class:"overview-icon",on_click_fn:function(Y){Y.view.set_overview(Y)}},p.prototype.action_icons_def[1],{name:"filters_icon",title:"Filters",css_class:"filters-icon",on_click_fn:function(Y){if(Y.filters_manager.visible()){Y.filters_manager.clear_filters()}else{Y.filters_manager.init_filters()}Y.filters_manager.toggle()}},{name:"tools_icon",title:"Tool",css_class:"hammer",on_click_fn:function(Y){Y.dynamic_tool_div.toggle();if(Y.dynamic_tool_div.is(":visible")){Y.set_name(Y.name+Y.tool_region_and_parameters_str())}else{Y.revert_name()}$(".tipsy").remove()}},{name:"param_space_viz_icon",title:"Tool parameter space visualization",css_class:"arrow-split",on_click_fn:function(Y){var ab='<strong>Tool</strong>: <%= track.tool.name %><br/><strong>Dataset</strong>: <%= track.name %><br/><strong>Region(s)</strong>: <select name="regions"><option value="cur">current viewing area</option><option value="bookmarks">bookmarks</option><option value="both">current viewing area and bookmarks</option></select>',aa=_.template(ab,{track:Y});var ad=function(){hide_modal();$(window).unbind("keypress.check_enter_esc")},Z=function(){var af=$('select[name="regions"] option:selected').val(),ah,ae=new GenomeRegion({chrom:view.chrom,start:view.low,end:view.high}),ag=_.map($(".bookmark"),function(ai){return new GenomeRegion({from_str:$(ai).children(".position").text()})});if(af==="cur"){ah=[ae]}else{if(af==="bookmarks"){ah=ag}else{ah=[ae].concat(ag)}}hide_modal();window.location.href=galaxy_paths.get("paramamonster_url")+"?"+$.param({dataset_id:Y.dataset_id,hda_ldda:Y.hda_ldda,regions:JSON.stringify(new Backbone.Collection(ah).toJSON())})},ac=function(ae){if((ae.keyCode||ae.which)===27){ad()}else{if((ae.keyCode||ae.which)===13){Z()}}};show_modal("Visualize tool parameter space and output from different parameter settings?",aa,{No:ad,Yes:Z})}},p.prototype.action_icons_def[2]],can_draw:function(){if(this.dataset_id&&p.prototype.can_draw.call(this)){return true}return false},build_container_div:function(){return $("<div/>").addClass("track").attr("id","track_"+this.id).css("position","relative")},build_header_div:function(){var Y=$("<div class='track-header'/>");if(this.view.editor){this.drag_div=$("<div/>").addClass(this.drag_handle_class).appendTo(Y)}this.name_div=$("<div/>").addClass("track-name").appendTo(Y).text(this.name).attr("id",this.name.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9\-]/g,"").toLowerCase());return Y},on_resize:function(){},add_resize_handle:function(){var Y=this;var ab=false;var aa=false;var Z=$("<div class='track-resize'>");$(Y.container_div).hover(function(){if(Y.content_visible){ab=true;Z.show()}},function(){ab=false;if(!aa){Z.hide()}});Z.hide().bind("dragstart",function(ac,ad){aa=true;ad.original_height=$(Y.content_div).height()}).bind("drag",function(ad,ae){var ac=Math.min(Math.max(ae.original_height+ae.deltaY,Y.min_height_px),Y.max_height_px);$(Y.tiles_div).css("height",ac);Y.visible_height_px=(Y.max_height_px===ac?0:ac);Y.on_resize()}).bind("dragend",function(ac,ad){Y.tile_cache.clear();aa=false;if(!ab){Z.hide()}Y.config.values.height=Y.visible_height_px;Y.changed()}).appendTo(Y.container_div)},set_display_modes:function(ab,ae){this.display_modes=ab;this.mode=(ae?ae:(this.config&&this.config.values.mode?this.config.values.mode:this.display_modes[0]));this.action_icons.mode_icon.attr("title","Set display mode (now: "+this.mode+")");var Z=this,ac={};for(var aa=0,Y=Z.display_modes.length;aa<Y;aa++){var ad=Z.display_modes[aa];ac[ad]=function(af){return function(){Z.change_mode(af);Z.icons_div.show();Z.container_div.mouseleave(function(){Z.icons_div.hide()})}}(ad)}make_popupmenu(this.action_icons.mode_icon,ac)},build_action_icons:function(){p.prototype.build_action_icons.call(this,this.action_icons_def);if(this.display_modes!==undefined){this.set_display_modes(this.display_modes)}},hide_contents:function(){this.tiles_div.hide();this.container_div.find(".yaxislabel, .track-resize").hide()},show_contents:function(){this.tiles_div.show();this.container_div.find(".yaxislabel, .track-resize").show();this.request_draw()},get_type:function(){if(this instanceof V){return"LabelTrack"}else{if(this instanceof x){return"ReferenceTrack"}else{if(this instanceof i){return"LineTrack"}else{if(this instanceof Q){return"ReadTrack"}else{if(this instanceof N){return"VcfTrack"}else{if(this instanceof g){return"CompositeTrack"}else{if(this instanceof c){return"FeatureTrack"}}}}}}}return""},init:function(){var Z=this;Z.enabled=false;Z.tile_cache.clear();Z.data_manager.clear();Z.content_div.css("height","auto");Z.tiles_div.children().remove();Z.container_div.removeClass("nodata error pending");if(!Z.dataset_id){return}var Y=$.Deferred();$.getJSON(this.dataset_check_url,{hda_ldda:Z.hda_ldda,dataset_id:Z.dataset_id,chrom:Z.view.chrom},function(aa){if(!aa||aa==="error"||aa.kind==="error"){Z.container_div.addClass("error");Z.tiles_div.text(n);if(aa.message){var ab=$(" <a href='javascript:void(0);'></a>").text("View error").click(function(){show_modal("Trackster Error","<pre>"+aa.message+"</pre>",{Close:hide_modal})});Z.tiles_div.append(ab)}}else{if(aa==="no converter"){Z.container_div.addClass("error");Z.tiles_div.text(F)}else{if(aa==="no data"||(aa.data!==undefined&&(aa.data===null||aa.data.length===0))){Z.container_div.addClass("nodata");Z.tiles_div.text(A)}else{if(aa==="pending"){Z.container_div.addClass("pending");Z.tiles_div.html(s);setTimeout(function(){Z.init()},Z.data_query_wait)}else{if(aa==="data"||aa.status==="data"){if(aa.valid_chroms){Z.valid_chroms=aa.valid_chroms;Z.update_icons()}Z.tiles_div.text(S);if(Z.view.chrom){Z.tiles_div.text("");Z.tiles_div.css("height",Z.visible_height_px+"px");Z.enabled=true;$.when(Z.predraw_init()).done(function(){Y.resolve();Z.container_div.removeClass("nodata error pending");Z.request_draw()})}else{Y.resolve()}}}}}}});this.update_icons();return Y},predraw_init:function(){}});var I=function(aa,Z,ab){h.call(this,aa,Z,ab);var Y=this,aa=Y.view;l(Y.container_div,Y.drag_handle_class,".group",Y);this.filters_manager=new U(this,("filters" in ab?ab.filters:null));this.data_manager.set("filters_manager",this.filters_manager);this.filters_available=false;this.tool=("tool" in ab&&ab.tool?new q(this,ab.tool,ab.tool_state):null);this.tile_cache=new Cache(M);if(this.header_div){this.set_filters_manager(this.filters_manager);if(this.tool){this.dynamic_tool_div=this.tool.parent_div;this.header_div.after(this.dynamic_tool_div)}}this.tiles_div=$("<div/>").addClass("tiles").appendTo(this.content_div);this.overlay_div=$("<div/>").addClass("overlay").appendTo(this.content_div);if(ab.mode){this.change_mode(ab.mode)}};o(I.prototype,p.prototype,h.prototype,{action_icons_def:h.prototype.action_icons_def.concat([{name:"show_more_rows_icon",title:"To minimize track height, not all feature rows are displayed. Click to display more rows.",css_class:"exclamation",on_click_fn:function(Y){$(".tipsy").remove();Y.slotters[Y.view.resolution_px_b].max_rows*=2;Y.request_draw(true)},hide:true}]),copy:function(Y){var Z=this.to_dict();o(Z,{data_manager:this.data_manager});var aa=new this.constructor(this.view,Y,Z);aa.change_mode(this.mode);aa.enabled=this.enabled;return aa},set_filters_manager:function(Y){this.filters_manager=Y;this.header_div.after(this.filters_manager.parent_div)},to_dict:function(){return{track_type:this.get_type(),name:this.name,hda_ldda:this.hda_ldda,dataset_id:this.dataset_id,prefs:this.prefs,mode:this.mode,filters:this.filters_manager.to_dict(),tool_state:(this.tool?this.tool.state_dict():{})}},change_mode:function(Z){var Y=this;Y.mode=Z;Y.config.values.mode=Z;Y.tile_cache.clear();Y.request_draw();this.action_icons.mode_icon.attr("title","Set display mode (now: "+Y.mode+")");return Y},update_icons:function(){var Y=this;if(Y.filters_available){Y.action_icons.filters_icon.show()}else{Y.action_icons.filters_icon.hide()}if(Y.tool){Y.action_icons.tools_icon.show();Y.action_icons.param_space_viz_icon.show()}else{Y.action_icons.tools_icon.hide();Y.action_icons.param_space_viz_icon.hide()}},_gen_tile_cache_key:function(Z,aa,Y){return Z+"_"+aa+"_"+Y},request_draw:function(Z,Y){this.view.request_redraw(false,Z,Y,this)},before_draw:function(){},_draw:function(Z,aj){if(!this.can_draw()){return}var ah=this.view.low,ad=this.view.high,af=ad-ah,aa=this.view.container.width(),al=this.view.resolution_px_b,ac=this.view.resolution_b_px;if(this.is_overview){ah=this.view.max_low;ad=this.view.max_high;ac=Math.pow(RESOLUTION,Math.ceil(Math.log((view.max_high-view.max_low)/O)/Math.log(RESOLUTION)));al=aa/(view.max_high-view.max_low)}this.before_draw();this.tiles_div.children().addClass("remove");var Y=Math.floor(ah/(ac*O)),ag=true,ak=[],ae=function(am){return(am&&"track" in am)};while((Y*O*ac)<ad){var ai=this.draw_helper(Z,aa,Y,ac,this.tiles_div,al);if(ae(ai)){ak.push(ai)}else{ag=false}Y+=1}if(!aj){this.tiles_div.children(".remove").removeClass("remove").remove()}var ab=this;if(ag){this.tiles_div.children(".remove").remove();ab.postdraw_actions(ak,aa,al,aj)}},postdraw_actions:function(ab,ac,ae,Y){var aa=this;var ad=false;for(var Z=0;Z<ab.length;Z++){if(ab[Z].has_icons){ad=true;break}}if(ad){for(var Z=0;Z<ab.length;Z++){tile=ab[Z];if(!tile.has_icons){tile.html_elt.css("padding-top",z)}}}},draw_helper:function(Y,ak,ap,an,ad,ae,al){var aj=this,at=this._gen_tile_cache_key(ak,ae,ap),ab=this._get_tile_bounds(ap,an);if(!al){al={}}var ar=(Y?undefined:aj.tile_cache.get_elt(at));if(ar){aj.show_tile(ar,ad,ae);return ar}var ah=true;var ao=aj.data_manager.get_data(ab,aj.mode,an,aj.data_url_extra_params);if(is_deferred(ao)){ah=false}var af;if(view.reference_track&&ae>view.canvas_manager.char_width_px){af=view.reference_track.data_manager.get_data(ab,aj.mode,an,view.reference_track.data_url_extra_params);if(is_deferred(af)){ah=false}}if(ah){o(ao,al.more_tile_data);var ag=aj.mode;if(ag==="Auto"){ag=aj.get_mode(ao);aj.update_auto_mode(ag)}var aa=aj.view.canvas_manager.new_canvas(),aq=ab.get("start"),Z=ab.get("end"),ak=Math.ceil((Z-aq)*ae)+aj.left_offset,ai=aj.get_canvas_height(ao,ag,ae,ak);aa.width=ak;aa.height=ai;var am=aa.getContext("2d");am.translate(this.left_offset,0);var ar=aj.draw_tile(ao,am,ag,an,ab,ae,af);if(ar!==undefined){aj.tile_cache.set_elt(at,ar);aj.show_tile(ar,ad,ae)}return ar}var ac=$.Deferred();$.when(ao,af).then(function(){view.request_redraw(false,false,false,aj);ac.resolve()});return ac},get_canvas_height:function(Y,aa,ab,Z){return this.visible_height_px},draw_tile:function(Y,Z,ad,ab,ac,ae,aa){console.log("Warning: TiledTrack.draw_tile() not implemented.")},show_tile:function(aa,ac,ad){var Z=this,Y=aa.html_elt;aa.predisplay_actions();var ab=(aa.low-(this.is_overview?this.view.max_low:this.view.low))*ad;if(this.left_offset){ab-=this.left_offset}Y.css({position:"absolute",top:0,left:ab});if(Y.hasClass("remove")){Y.removeClass("remove")}else{ac.append(Y)}Z.after_show_tile(aa)},after_show_tile:function(Y){},_get_tile_bounds:function(Y,Z){var ab=Math.floor(Y*O*Z),ac=Math.ceil(O*Z),aa=(ab+ac<=this.view.max_high?ab+ac:this.view.max_high);return new GenomeRegion({chrom:this.view.chrom,start:ab,end:aa})},tool_region_and_parameters_str:function(aa,Y,ab){var Z=this,ac=(aa!==undefined&&Y!==undefined&&ab!==undefined?aa+":"+Y+"-"+ab:"all");return" - region=["+ac+"], parameters=["+Z.tool.get_param_values().join(", ")+"]"},data_and_mode_compatible:function(Y,Z){return true},can_subset:function(Y){return false},init_for_tool_data:function(){this.data_manager.set("data_url",raw_data_url);this.data_query_wait=1000;this.dataset_check_url=dataset_state_url;this.normal_postdraw_actions=this.postdraw_actions;this.postdraw_actions=function(aa,ab,ad,Y){var Z=this;Z.normal_postdraw_actions(aa,ab,ad,Y);Z.dataset_state_url=converted_datasets_state_url;Z.data_query_wait=G;var ac=new ServerStateDeferred({url:Z.dataset_state_url,url_params:{dataset_id:Z.dataset_id,hda_ldda:Z.hda_ldda},interval:Z.data_query_wait,success_fn:function(ae){return ae!=="pending"}});$.when(ac.go()).then(function(){Z.data_manager.set("data_url",default_data_url)});Z.postdraw_actions=Z.normal_postdraw_actions}}});var V=function(Z,Y){var aa={resize:false};h.call(this,Z,Y,aa);this.container_div.addClass("label-track")};o(V.prototype,h.prototype,{build_header_div:function(){},init:function(){this.enabled=true},_draw:function(){var aa=this.view,ab=aa.high-aa.low,ae=Math.floor(Math.pow(10,Math.floor(Math.log(ab)/Math.log(10)))),Y=Math.floor(aa.low/ae)*ae,ac=this.view.container.width(),Z=$("<div style='position: relative; height: 1.3em;'></div>");while(Y<aa.high){var ad=(Y-aa.low)/ab*ac;Z.append($("<div class='label'>"+commatize(Y)+"</div>").css({position:"absolute",left:ad-1}));Y+=ae}this.content_div.children(":first").remove();this.content_div.append(Z)}});var g=function(Z,Y,ac){I.call(this,Z,Y,ac);this.drawables=[];this.left_offset=0;if("drawables" in ac){var ab;for(var aa=0;aa<ac.drawables.length;aa++){ab=ac.drawables[aa];this.drawables[aa]=object_from_template(ab);if(ab.left_offset>this.left_offset){this.left_offset=ab.left_offset}}this.enabled=true}if(this.drawables.length!==0){this.set_display_modes(this.drawables[0].display_modes,this.drawables[0].mode)}this.update_icons();this.obj_type="CompositeTrack"};o(g.prototype,I.prototype,{action_icons_def:[{name:"composite_icon",title:"Show individual tracks",css_class:"layers-stack",on_click_fn:function(Y){$(".tipsy").remove();Y.show_group()}}].concat(I.prototype.action_icons_def),to_dict:v.prototype.to_dict,add_drawable:v.prototype.add_drawable,unpack_drawables:v.prototype.unpack_drawables,change_mode:function(Y){I.prototype.change_mode.call(this,Y);for(var Z=0;Z<this.drawables.length;Z++){this.drawables[Z].change_mode(Y)}},init:function(){var aa=[];for(var Z=0;Z<this.drawables.length;Z++){aa.push(this.drawables[Z].init())}var Y=this;$.when.apply($,aa).then(function(){Y.enabled=true;Y.request_draw()})},update_icons:function(){this.action_icons.filters_icon.hide();this.action_icons.tools_icon.hide();this.action_icons.param_space_viz_icon.hide()},can_draw:p.prototype.can_draw,draw_helper:function(Z,an,au,aq,af,ah,ao){var am=this,ay=this._gen_tile_cache_key(an,ah,au),ad=this._get_tile_bounds(au,aq),av=ad.get("start"),aa=ad.get("end");if(!ao){ao={}}var ax=(Z?undefined:am.tile_cache.get_elt(ay));if(ax){am.show_tile(ax,af,ah);return ax}var ag=[],am,ak=true,ar,ai;for(var at=0;at<this.drawables.length;at++){am=this.drawables[at];ar=am.data_manager.get_data(av,aa,am.mode,aq,am.data_url_extra_params);if(is_deferred(ar)){ak=false}ag.push(ar);ai=null;if(view.reference_track&&ah>view.canvas_manager.char_width_px){ai=view.reference_track.data_manager.get_data(av,aa,am.mode,aq,view.reference_track.data_url_extra_params);if(is_deferred(ai)){ak=false}}ag.push(ai)}if(ak){o(ar,ao.more_tile_data);this.tile_predraw_init();var ac=am.view.canvas_manager.new_canvas(),ad=am._get_tile_bounds(au,aq),av=ad.get("start"),aa=ad.get("end"),aw=0,an=Math.ceil((aa-av)*ah)+this.left_offset,al=0,ab=[];var Y=0;for(var at=0;at<this.drawables.length;at++,aw+=2){am=this.drawables[at];ar=ag[aw];var aj=am.mode;if(aj==="Auto"){aj=am.get_mode(ar);am.update_auto_mode(aj)}ab.push(aj);Y=am.get_canvas_height(ar,aj,ah,an);if(Y>al){al=Y}}ac.width=an;ac.height=(ao.height?ao.height:al);aw=0;var ap=ac.getContext("2d");ap.translate(this.left_offset,0);ap.globalAlpha=0.5;ap.globalCompositeOperation="source-over";for(var at=0;at<this.drawables.length;at++,aw+=2){am=this.drawables[at];ar=ag[aw];ai=ag[aw+1];ax=am.draw_tile(ar,ap,ab[at],aq,ad,ah,ai)}this.tile_cache.set_elt(ay,ax);this.show_tile(ax,af,ah);return ax}var ae=$.Deferred(),am=this;$.when.apply($,ag).then(function(){view.request_redraw(false,false,false,am);ae.resolve()});return ae},show_group:function(){var ab=new L(this.view,this.container,{name:this.name}),Y;for(var aa=0;aa<this.drawables.length;aa++){Y=this.drawables[aa];ab.add_drawable(Y);Y.container=ab;ab.content_div.append(Y.container_div)}var Z=this.container.replace_drawable(this,ab,true);ab.request_draw()},tile_predraw_init:function(){var ab=Number.MAX_VALUE,Y=-ab,Z;for(var aa=0;aa<this.drawables.length;aa++){Z=this.drawables[aa];if(Z instanceof i){if(Z.prefs.min_value<ab){ab=Z.prefs.min_value}if(Z.prefs.max_value>Y){Y=Z.prefs.max_value}}}for(var aa=0;aa<this.drawables.length;aa++){Z=this.drawables[aa];Z.prefs.min_value=ab;Z.prefs.max_value=Y}},postdraw_actions:function(aa,ad,af,Z){I.prototype.postdraw_actions.call(this,aa,ad,af,Z);var ac=-1;for(var ab=0;ab<aa.length;ab++){var Y=aa[ab].html_elt.find("canvas").height();if(Y>ac){ac=Y}}for(var ab=0;ab<aa.length;ab++){var ae=aa[ab];if(ae.html_elt.find("canvas").height()!==ac){this.draw_helper(true,ad,ae.index,ae.resolution,ae.html_elt.parent(),af,{height:ac});ae.html_elt.remove()}}}});var x=function(Y){I.call(this,Y,{content_div:Y.top_labeltrack},{resize:false});Y.reference_track=this;this.left_offset=200;this.visible_height_px=12;this.container_div.addClass("reference-track");this.content_div.css("background","none");this.content_div.css("min-height","0px");this.content_div.css("border","none");this.data_url=reference_url;this.data_url_extra_params={dbkey:Y.dbkey};this.data_manager=new ReferenceTrackDataManager({data_url:reference_url});this.hide_contents()};o(x.prototype,p.prototype,I.prototype,{build_header_div:function(){},init:function(){this.data_manager.clear();this.enabled=true},can_draw:p.prototype.can_draw,draw_tile:function(ag,ah,ac,ab,ae,ai){var aa=this;if(ai>this.view.canvas_manager.char_width_px){if(ag.data===null){this.hide_contents();return}var Z=ah.canvas;ah.font=ah.canvas.manager.default_font;ah.textAlign="center";ag=ag.data;for(var ad=0,af=ag.length;ad<af;ad++){var Y=Math.floor(ad*ai);ah.fillText(ag[ad],Y,10)}this.show_contents();return new b(aa,ae,ab,Z,ag)}this.hide_contents()}});var i=function(aa,Z,ab){var Y=this;this.display_modes=["Histogram","Line","Filled","Intensity"];this.mode="Histogram";I.call(this,aa,Z,ab);this.hda_ldda=ab.hda_ldda;this.dataset_id=ab.dataset_id;this.original_dataset_id=this.dataset_id;this.left_offset=0;this.config=new B({track:this,params:[{key:"name",label:"Name",type:"text",default_value:this.name},{key:"color",label:"Color",type:"color",default_value:get_random_color()},{key:"min_value",label:"Min Value",type:"float",default_value:undefined},{key:"max_value",label:"Max Value",type:"float",default_value:undefined},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"height",type:"int",default_value:32,hidden:true}],saved_values:ab.prefs,onchange:function(){Y.set_name(Y.prefs.name);Y.vertical_range=Y.prefs.max_value-Y.prefs.min_value;Y.set_min_value(Y.prefs.min_value);Y.set_max_value(Y.prefs.max_value)}});this.prefs=this.config.values;this.visible_height_px=this.config.values.height;this.vertical_range=this.config.values.max_value-this.config.values.min_value};o(i.prototype,p.prototype,I.prototype,{on_resize:function(){this.request_draw(true)},set_min_value:function(Y){this.prefs.min_value=Y;$("#linetrack_"+this.dataset_id+"_minval").text(this.prefs.min_value);this.tile_cache.clear();this.request_draw()},set_max_value:function(Y){this.prefs.max_value=Y;$("#linetrack_"+this.dataset_id+"_maxval").text(this.prefs.max_value);this.tile_cache.clear();this.request_draw()},predraw_init:function(){var Y=this;Y.vertical_range=undefined;return $.getJSON(Y.data_url,{stats:true,chrom:Y.view.chrom,low:null,high:null,hda_ldda:Y.hda_ldda,dataset_id:Y.dataset_id},function(Z){Y.container_div.addClass("line-track");var ac=Z.data;if(isNaN(parseFloat(Y.prefs.min_value))||isNaN(parseFloat(Y.prefs.max_value))){var aa=ac.min,ae=ac.max;aa=Math.floor(Math.min(0,Math.max(aa,ac.mean-2*ac.sd)));ae=Math.ceil(Math.max(0,Math.min(ae,ac.mean+2*ac.sd)));Y.prefs.min_value=aa;Y.prefs.max_value=ae;$("#track_"+Y.dataset_id+"_minval").val(Y.prefs.min_value);$("#track_"+Y.dataset_id+"_maxval").val(Y.prefs.max_value)}Y.vertical_range=Y.prefs.max_value-Y.prefs.min_value;Y.total_frequency=ac.total_frequency;Y.container_div.find(".yaxislabel").remove();var ad=$("<div/>").text(T(Y.prefs.min_value,3)).make_text_editable({num_cols:6,on_finish:function(af){$(".tipsy").remove();var af=parseFloat(af);if(!isNaN(af)){Y.set_min_value(af)}},help_text:"Set min value"}).addClass("yaxislabel bottom").attr("id","linetrack_"+Y.dataset_id+"_minval").prependTo(Y.container_div),ab=$("<div/>").text(T(Y.prefs.max_value,3)).make_text_editable({num_cols:6,on_finish:function(af){$(".tipsy").remove();var af=parseFloat(af);if(!isNaN(af)){Y.set_max_value(af)}},help_text:"Set max value"}).addClass("yaxislabel top").attr("id","linetrack_"+Y.dataset_id+"_maxval").prependTo(Y.container_div)})},draw_tile:function(ah,af,aa,Z,ac,ag){var Y=af.canvas,ab=ac.get("start"),ae=ac.get("end"),ad=new H.LinePainter(ah.data,ab,ae,this.prefs,aa);ad.draw(af,Y.width,Y.height,ag);return new b(this,ac,Z,Y,ah.data)},can_subset:function(Y){return false}});var c=function(ab,aa,ad){var Z=this;this.display_modes=["Auto","Histogram","Dense","Squish","Pack"];I.call(this,ab,aa,ad);var ac=get_random_color(),Y=get_random_color([ac,"#ffffff"]);this.config=new B({track:this,params:[{key:"name",label:"Name",type:"text",default_value:this.name},{key:"block_color",label:"Block color",type:"color",default_value:ac},{key:"reverse_strand_color",label:"Antisense strand color",type:"color",default_value:Y},{key:"label_color",label:"Label color",type:"color",default_value:"black"},{key:"show_counts",label:"Show summary counts",type:"bool",default_value:true,help:"Show the number of items in each bin when drawing summary histogram"},{key:"histogram_max",label:"Histogram maximum",type:"float",default_value:null,help:"clear value to set automatically"},{key:"connector_style",label:"Connector style",type:"select",default_value:"fishbones",options:[{label:"Line with arrows",value:"fishbone"},{label:"Arcs",value:"arcs"}]},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"height",type:"int",default_value:this.visible_height_px,hidden:true}],saved_values:ad.prefs,onchange:function(){Z.set_name(Z.prefs.name);Z.tile_cache.clear();Z.set_painter_from_config();Z.request_draw()}});this.prefs=this.config.values;this.visible_height_px=this.config.values.height;this.container_div.addClass("feature-track");this.hda_ldda=ad.hda_ldda;this.dataset_id=ad.dataset_id;this.original_dataset_id=ad.dataset_id;this.show_labels_scale=0.001;this.showing_details=false;this.summary_draw_height=30;this.slotters={};this.start_end_dct={};this.left_offset=200;this.set_painter_from_config()};o(c.prototype,p.prototype,I.prototype,{set_dataset:function(Y){this.dataset_id=Y.get("id");this.hda_ldda=Y.get("hda_ldda");this.data_manager.set("dataset",Y)},set_painter_from_config:function(){if(this.config.values.connector_style==="arcs"){this.painter=H.ArcLinkedFeaturePainter}else{this.painter=H.LinkedFeaturePainter}},before_draw:function(){this.max_height_px=0},after_show_tile:function(Y){this.max_height_px=Math.max(this.max_height_px,Y.html_elt.height());Y.html_elt.parent().children().css("height",this.max_height_px+"px");var Z=this.max_height_px;if(this.visible_height_px!==0){Z=Math.min(this.max_height_px,this.visible_height_px)}this.tiles_div.css("height",Z+"px")},postdraw_actions:function(an,ai,ad,ac){I.prototype.postdraw_actions.call(this,an,ac);var ah=this;if(ah.mode==="Histogram"){var ak,Z=-1;for(ak=0;ak<an.length;ak++){var aj=an[ak].max_val;if(aj>Z){Z=aj}}for(ak=0;ak<an.length;ak++){var ap=an[ak];if(ap.max_val!==Z){ap.html_elt.remove();ah.draw_helper(true,ai,ap.index,ap.resolution,ap.html_elt.parent(),ad,{more_tile_data:{max:Z}})}}}if(ah.filters_manager){var ae=ah.filters_manager.filters;for(var am=0;am<ae.length;am++){ae[am].update_ui_elt()}var ao=false,Y,af;for(var ak=0;ak<an.length;ak++){if(an[ak].data.length){Y=an[ak].data[0];for(var am=0;am<ae.length;am++){af=ae[am];if(af.applies_to(Y)&&af.min!==af.max){ao=true;break}}}}if(ah.filters_available!==ao){ah.filters_available=ao;if(!ah.filters_available){ah.filters_manager.hide()}ah.update_icons()}}this.container_div.find(".yaxislabel").remove();var ab=an[0];if(ab instanceof j){var ag=(this.prefs.histogram_max?this.prefs.histogram_max:ab.max_val),aa=$("<div/>").text(ag).make_text_editable({num_cols:12,on_finish:function(aq){$(".tipsy").remove();var aq=parseFloat(aq);ah.prefs.histogram_max=(!isNaN(aq)?aq:null);ah.tile_cache.clear();ah.request_draw()},help_text:"Set max value; leave blank to use default"}).addClass("yaxislabel top").css("color",this.prefs.label_color);this.container_div.prepend(aa)}if(ab instanceof K){var al=true;for(var ak=0;ak<an.length;ak++){if(!an[ak].all_slotted){al=false;break}}if(!al){this.action_icons.show_more_rows_icon.show()}else{this.action_icons.show_more_rows_icon.hide()}}else{this.action_icons.show_more_rows_icon.hide()}},update_auto_mode:function(Y){var Y;if(this.mode==="Auto"){if(Y==="no_detail"){Y="feature spans"}else{if(Y==="summary_tree"){Y="coverage histogram"}}this.action_icons.mode_icon.attr("title","Set display mode (now: Auto/"+Y+")")}},incremental_slots:function(ac,Y,ab){var Z=this.view.canvas_manager.dummy_context,aa=this.slotters[ac];if(!aa||(aa.mode!==ab)){aa=new (r.FeatureSlotter)(ac,ab,w,function(ad){return Z.measureText(ad)});this.slotters[ac]=aa}return aa.slot_features(Y)},get_summary_tree_data:function(ac,af,aa,an){if(an>aa-af){an=aa-af}var aj=Math.floor((aa-af)/an),am=[],ab=0;var ad=0,ae=0,ai,al=0,ag=[],ak,ah;var Z=function(aq,ap,ar,ao){aq[0]=ap+ar*ao;aq[1]=ap+(ar+1)*ao};while(al<an&&ad!==ac.length){var Y=false;for(;al<an&&!Y;al++){Z(ag,af,al,aj);for(ae=ad;ae<ac.length;ae++){ai=ac[ae].slice(1,3);if(is_overlap(ai,ag)){Y=true;break}}if(Y){break}}data_start_index=ae;am[am.length]=ak=[ag[0],0];for(;ae<ac.length;ae++){ai=ac[ae].slice(1,3);if(is_overlap(ai,ag)){ak[1]++}else{break}}if(ak[1]>ab){ab=ak[1]}al++}return{max:ab,delta:aj,data:am}},get_mode:function(Y){if(Y.dataset_type==="summary_tree"){mode="summary_tree"}else{if(Y.extra_info==="no_detail"||this.is_overview){mode="no_detail"}else{if(this.view.high-this.view.low>E){mode="Squish"}else{mode="Pack"}}}return mode},get_canvas_height:function(Y,ac,ad,Z){if(ac==="summary_tree"||ac==="Histogram"){return this.summary_draw_height}else{var ab=this.incremental_slots(ad,Y.data,ac);var aa=new (this.painter)(null,null,null,this.prefs,ac);return Math.max(X,aa.get_required_height(ab,Z))}},draw_tile:function(aj,an,al,ao,ab,af,aa){var am=this,Z=an.canvas,av=ab.get("start"),Y=ab.get("end"),aA=25,ac=this.left_offset;if(al==="summary_tree"||al==="Histogram"){if(aj.dataset_type!=="summary_tree"){var ag=this.get_summary_tree_data(aj.data,av,Y,200);if(aj.max){ag.max=aj.max}aj=ag}var ax=new H.SummaryTreePainter(aj,av,Y,this.prefs);ax.draw(an,Z.width,Z.height,af);return new j(am,ab,ao,Z,aj.data,aj.max)}var ae=[],ak=this.slotters[af].slots;all_slotted=true;if(aj.data){var ah=this.filters_manager.filters;for(var ap=0,ar=aj.data.length;ap<ar;ap++){var ad=aj.data[ap];var aq=false;var ai;for(var au=0,az=ah.length;au<az;au++){ai=ah[au];ai.update_attrs(ad);if(!ai.keep(ad)){aq=true;break}}if(!aq){ae.push(ad);if(!(ad[0] in ak)){all_slotted=false}}}}var ay=(this.filters_manager.alpha_filter?new y(this.filters_manager.alpha_filter):null);var aw=(this.filters_manager.height_filter?new y(this.filters_manager.height_filter):null);var ax=new (this.painter)(ae,av,Y,this.prefs,al,ay,aw,aa);var at=null;an.fillStyle=this.prefs.block_color;an.font=an.canvas.manager.default_font;an.textAlign="right";if(aj.data){at=ax.draw(an,Z.width,Z.height,af,ak);at.translation=-ac}return new K(am,ab,ao,Z,aj.data,af,al,aj.message,all_slotted,at)},data_and_mode_compatible:function(Y,Z){if(Z==="Auto"){return true}else{if(Y.extra_info==="no_detail"||Y.dataset_type==="summary_tree"){return false}else{return true}}},can_subset:function(Y){if(Y.dataset_type==="summary_tree"||Y.message||Y.extra_info==="no_detail"){return false}return true}});var N=function(Z,Y,aa){c.call(this,Z,Y,aa);this.config=new B({track:this,params:[{key:"name",label:"Name",type:"text",default_value:this.name},{key:"block_color",label:"Block color",type:"color",default_value:get_random_color()},{key:"label_color",label:"Label color",type:"color",default_value:"black"},{key:"show_insertions",label:"Show insertions",type:"bool",default_value:false},{key:"show_counts",label:"Show summary counts",type:"bool",default_value:true},{key:"mode",type:"string",default_value:this.mode,hidden:true}],saved_values:aa.prefs,onchange:function(){this.track.set_name(this.track.prefs.name);this.track.tile_cache.clear();this.track.request_draw()}});this.prefs=this.config.values;this.painter=H.ReadPainter};o(N.prototype,p.prototype,I.prototype,c.prototype);var Q=function(aa,Z,ac){c.call(this,aa,Z,ac);var ab=get_random_color(),Y=get_random_color([ab,"#ffffff"]);this.config=new B({track:this,params:[{key:"name",label:"Name",type:"text",default_value:this.name},{key:"block_color",label:"Block and sense strand color",type:"color",default_value:ab},{key:"reverse_strand_color",label:"Antisense strand color",type:"color",default_value:Y},{key:"label_color",label:"Label color",type:"color",default_value:"black"},{key:"show_insertions",label:"Show insertions",type:"bool",default_value:false},{key:"show_differences",label:"Show differences only",type:"bool",default_value:true},{key:"show_counts",label:"Show summary counts",type:"bool",default_value:true},{key:"histogram_max",label:"Histogram maximum",type:"float",default_value:null,help:"Clear value to set automatically"},{key:"mode",type:"string",default_value:this.mode,hidden:true}],saved_values:ac.prefs,onchange:function(){this.track.set_name(this.track.prefs.name);this.track.tile_cache.clear();this.track.request_draw()}});this.prefs=this.config.values;this.painter=H.ReadPainter;this.update_icons()};o(Q.prototype,p.prototype,I.prototype,c.prototype);R.View=W;R.DrawableGroup=L;R.LineTrack=i;R.FeatureTrack=c;R.ReadTrack=Q;R.VcfTrack=N;R.CompositeTrack=g};var slotting_module=function(c,b){var e=c("class").extend;var d=2,a=5;b.FeatureSlotter=function(i,h,f,g){this.slots={};this.start_end_dct={};this.w_scale=i;this.mode=h;this.include_label=(h==="Pack");this.max_rows=f;this.measureText=g};e(b.FeatureSlotter.prototype,{slot_features:function(m){var p=this.w_scale,h=this.start_end_dct,x=[],z=[],n=0,y=this.max_rows;for(var v=0,w=m.length;v<w;v++){var k=m[v],o=k[0];if(this.slots[o]!==undefined){n=Math.max(n,this.slots[o]);z.push(this.slots[o])}else{x.push(v)}}var q=function(E,F){for(var D=0;D<=y;D++){var B=false,G=h[D];if(G!==undefined){for(var A=0,C=G.length;A<C;A++){var i=G[A];if(F>i[0]&&E<i[1]){B=true;break}}}if(!B){return D}}return -1};for(var v=0,w=x.length;v<w;v++){var k=m[x[v]],o=k[0],t=k[1],f=k[2],r=k[3],g=Math.floor(t*p),l=Math.ceil(f*p),u=this.measureText(r).width,j;if(r!==undefined&&this.include_label){u+=(d+a);if(g-u>=0){g-=u;j="left"}else{l+=u;j="right"}}var s=q(g,l);if(s>=0){if(h[s]===undefined){h[s]=[]}h[s].push([g,l]);this.slots[o]=s;n=Math.max(n,s)}}return n+1}})};var painters_module=function(i,x){var u=i("class").extend;var p=function(I,A,G,z,F,D){if(D===undefined){D=4}var C=z-A;var B=F-G;var E=Math.floor(Math.sqrt(C*C+B*B)/D);var J=C/E;var H=B/E;var y;for(y=0;y<E;y++,A+=J,G+=H){if(y%2!==0){continue}I.fillRect(A,G,D,1)}};var q=function(B,A,z,E){var D=A-E/2,C=A+E/2,F=z-Math.sqrt(E*3/2);B.beginPath();B.moveTo(D,F);B.lineTo(C,F);B.lineTo(A,z);B.lineTo(D,F);B.strokeStyle=this.fillStyle;B.fill();B.stroke();B.closePath()};var d=function(y){this.default_val=(y?y:1)};d.prototype.gen_val=function(y){return this.default_val};var l=function(A,C,y,z,B){this.data=A;this.view_start=C;this.view_end=y;this.prefs=u({},this.default_prefs,z);this.mode=B};l.prototype.default_prefs={};l.prototype.draw=function(z,A,y,B){};var v=function(A,C,y,z,B){l.call(this,A,C,y,z,B)};v.prototype.default_prefs={show_counts:false};v.prototype.draw=function(L,z,K,M){var E=this.view_start,N=this.view_end-this.view_start,I=this.data.data,G=(this.prefs.histogram_max?this.prefs.histogram_max:this.data.max),B=K;delta_x_px=Math.ceil(this.data.delta*M);L.save();for(var C=0,D=I.length;C<D;C++){var H=Math.floor((I[C][0]-E)*M);var F=I[C][1];if(!F){continue}var J=F/G*K;if(F!==0&&J<1){J=1}L.fillStyle=this.prefs.block_color;L.fillRect(H,B-J,delta_x_px,J);var A=4;if(this.prefs.show_counts&&(L.measureText(F).width+A)<delta_x_px){L.fillStyle=this.prefs.label_color;L.textAlign="center";L.fillText(F,H+(delta_x_px/2),10)}}L.restore()};var b=function(y,C,E,F,A){l.call(this,y,C,E,F,A);if(this.prefs.min_value===undefined){var G=Infinity;for(var z=0,B=this.data.length;z<B;z++){G=Math.min(G,this.data[z][1])}this.prefs.min_value=G}if(this.prefs.max_value===undefined){var D=-Infinity;for(var z=0,B=this.data.length;z<B;z++){D=Math.max(D,this.data[z][1])}this.prefs.max_value=D}};b.prototype.default_prefs={min_value:undefined,max_value:undefined,mode:"Histogram",color:"#000",overflow_color:"#F66"};b.prototype.draw=function(S,Q,N,D){var I=false,K=this.prefs.min_value,F=this.prefs.max_value,M=F-K,B=N,C=this.view_start,P=this.view_end-this.view_start,L=this.mode,aa=this.data;S.save();var ac=Math.round(N+K/M*N);if(L!=="Intensity"){S.fillStyle="#aaa";S.fillRect(0,ac,Q,1)}S.beginPath();var Y,G,E;if(aa.length>1){E=Math.ceil((aa[1][0]-aa[0][0])*D)}else{E=10}var A=parseInt(this.prefs.color.slice(1),16),H=(A&16711680)>>16,R=(A&65280)>>8,V=A&255;for(var T=0,U=aa.length;T<U;T++){S.fillStyle=S.strokeStyle=this.prefs.color;Y=Math.round((aa[T][0]-C)*D);G=aa[T][1];var W=false,J=false;if(G===null){if(I&&L==="Filled"){S.lineTo(Y,B)}I=false;continue}if(G<K){J=true;G=K}else{if(G>F){W=true;G=F}}if(L==="Histogram"){G=Math.round(G/M*B);S.fillRect(Y,ac,E,-G)}else{if(L==="Intensity"){var z=(G-K)/M,O=Math.round(H+(255-H)*(1-z)),X=Math.round(R+(255-R)*(1-z)),ab=Math.round(V+(255-V)*(1-z));S.fillStyle="rgb("+O+","+X+","+ab+")";S.fillRect(Y,0,E,B)}else{G=Math.round(B-(G-K)/M*B);if(I){S.lineTo(Y,G)}else{I=true;if(L==="Filled"){S.moveTo(Y,B);S.lineTo(Y,G)}else{S.moveTo(Y,G)}}}}S.fillStyle=this.prefs.overflow_color;if(W||J){var Z;if(L==="Histogram"||L==="Intensity"){Z=E}else{Y-=2;Z=4}if(W){S.fillRect(Y,0,Z,3)}if(J){S.fillRect(Y,B-3,Z,3)}}S.fillStyle=this.prefs.color}if(L==="Filled"){if(I){S.lineTo(Y,ac);S.lineTo(0,ac)}S.fill()}else{S.stroke()}S.restore()};var m=function(y){this.feature_positions={};this.slot_height=y;this.translation=0;this.y_translation=0};m.prototype.map_feature_data=function(z,B,y,A){if(!this.feature_positions[B]){this.feature_positions[B]=[]}this.feature_positions[B].push({data:z,x_start:y,x_end:A})};m.prototype.get_feature_data=function(z,D){var C=Math.floor((D-this.y_translation)/this.slot_height),B;if(!this.feature_positions[C]){return null}z+=this.translation;for(var A=0;A<this.feature_positions[C].length;A++){B=this.feature_positions[C][A];if(z>=B.x_start&&z<=B.x_end){return B.data}}};var o=function(A,D,y,z,C,E,B){l.call(this,A,D,y,z,C);this.alpha_scaler=(E?E:new d());this.height_scaler=(B?B:new d())};o.prototype.default_prefs={block_color:"#FFF",connector_color:"#FFF"};u(o.prototype,{get_required_height:function(A,z){var y=y_scale=this.get_row_height(),B=this.mode;if(B==="no_detail"||B==="Squish"||B==="Pack"){y=A*y_scale}return y+this.get_top_padding(z)+this.get_bottom_padding(z)},get_top_padding:function(y){return 0},get_bottom_padding:function(y){return Math.max(Math.round(this.get_row_height()/2),5)},draw:function(K,I,G,E,F){var Q=this.data,D=this.view_start,M=this.view_end;K.save();K.fillStyle=this.prefs.block_color;K.textAlign="right";var H=this.view_end-this.view_start,L=this.get_row_height(),P=new m(L),B;for(var N=0,O=Q.length;N<O;N++){var A=Q[N],C=A[0],J=A[1],y=A[2],z=(F&&F[C]!==undefined?F[C]:null);if((J<M&&y>D)&&(this.mode==="Dense"||z!==null)){B=this.draw_element(K,this.mode,A,z,D,M,E,L,I);P.map_feature_data(A,z,B[0],B[1])}}K.restore();P.y_translation=this.get_top_padding(I);return P},draw_element:function(E,A,G,C,B,D,F,z,y){console.log("WARNING: Unimplemented function.");return[0,0]}});var c=10,h=3,k=5,w=10,f=1,s=9,e=3,a=9,j=2,g="#ccc";var r=function(A,D,y,z,C,E,B){o.call(this,A,D,y,z,C,E,B);this.draw_background_connector=true;this.draw_individual_connectors=false};u(r.prototype,o.prototype,{get_row_height:function(){var z=this.mode,y;if(z==="Dense"){y=c}else{if(z==="no_detail"){y=h}else{if(z==="Squish"){y=k}else{y=w}}}return y},draw_element:function(M,D,X,H,O,ai,am,ao,y){var T=X[0],ak=X[1],ad=X[2]-1,Q=X[3],K=X[4],ae=Math.floor(Math.max(0,(ak-O)*am)),N=Math.ceil(Math.min(y,Math.max(0,(ad-O)*am))),ac=ae,an=N,aa=(D==="Dense"?0:(0+H))*ao+this.get_top_padding(y),L,ag,R=null,aq=null,B=B=(!K||K==="+"||K==="."?this.prefs.block_color:this.prefs.reverse_strand_color);label_color=this.prefs.label_color;M.globalAlpha=this.alpha_scaler.gen_val(X);if(D==="Dense"){H=1}if(D==="no_detail"){M.fillStyle=B;M.fillRect(ae,aa+5,N-ae,f)}else{var Z=X[5],af=X[6],C=X[7],V=true;if(Z&&af){R=Math.floor(Math.max(0,(Z-O)*am));aq=Math.ceil(Math.min(y,Math.max(0,(af-O)*am)))}var al,U;if(D==="Squish"){al=1;U=e;V=false}else{if(D==="Dense"){al=5;U=s}else{al=5;U=a}}if(!C){M.fillStyle=B;M.fillRect(ae,aa+1,N-ae,U);if(K&&V){if(K==="+"){M.fillStyle=M.canvas.manager.get_pattern("right_strand_inv")}else{if(K==="-"){M.fillStyle=M.canvas.manager.get_pattern("left_strand_inv")}}M.fillRect(ae,aa+1,N-ae,U)}}else{var J,W;if(D==="Squish"||D==="Dense"){J=aa+Math.floor(e/2)+1;W=1}else{if(K){J=aa;W=U}else{J+=(e/2)+1;W=1}}if(this.draw_background_connector){if(D==="Squish"||D==="Dense"){M.fillStyle=g}else{if(K){if(K==="+"){M.fillStyle=M.canvas.manager.get_pattern("right_strand")}else{if(K==="-"){M.fillStyle=M.canvas.manager.get_pattern("left_strand")}}}else{M.fillStyle=g}}M.fillRect(ae,J,N-ae,W)}var E;for(var aj=0,A=C.length;aj<A;aj++){var F=C[aj],z=Math.floor(Math.max(0,(F[0]-O)*am)),Y=Math.ceil(Math.min(y,Math.max((F[1]-1-O)*am))),S,ab;if(z>Y){continue}M.fillStyle=B;M.fillRect(z,aa+(U-al)/2+1,Y-z,al);if(R!==undefined&&af>Z&&!(z>aq||Y<R)){var ah=Math.max(z,R),I=Math.min(Y,aq);M.fillRect(ah,aa+1,I-ah,U)}if(this.draw_individual_connectors&&S){this.draw_connector(M,S,ab,z,Y,aa)}S=z;ab=Y}if(D==="Pack"){M.globalAlpha=1;M.fillStyle="white";var G=this.height_scaler.gen_val(X),P=Math.ceil(U*G),ap=Math.round((U-P)/2);if(G!==1){M.fillRect(ae,J+1,N-ae,ap);M.fillRect(ae,J+U-ap+1,N-ae,ap)}}}M.globalAlpha=1;if(D==="Pack"&&ak>O){M.fillStyle=label_color;if(O===0&&ae-M.measureText(Q).width<0){M.textAlign="left";M.fillText(Q,N+j,aa+8);an+=M.measureText(Q).width+j}else{M.textAlign="right";M.fillText(Q,ae-j,aa+8);ac-=M.measureText(Q).width+j}}}M.globalAlpha=1;return[ac,an]}});var t=function(B,E,y,A,D,F,C,z){o.call(this,B,E,y,A,D,F,C);this.ref_seq=(z?z.data:null)};u(t.prototype,o.prototype,{get_row_height:function(){var y,z=this.mode;if(z==="Dense"){y=c}else{if(z==="Squish"){y=k}else{y=w;if(this.prefs.show_insertions){y*=2}}}return y},draw_read:function(K,A,ag,V,L,aa,ad,C,B,M){K.textAlign="center";var J=this,R=[L,aa],Z=0,W=0,D=0,F=K.canvas.manager.char_width_px,y=(B==="+"?this.prefs.block_color:this.prefs.reverse_strand_color);var O=[];if((A==="Pack"||this.mode==="Auto")&&M!==undefined&&ag>F){D=Math.round(ag/2)}if(!C){C=[[0,M.length]]}for(var G=0,I=C.length;G<I;G++){var z=C[G],E="MIDNSHP=X"[z[0]],S=z[1];if(E==="H"||E==="S"){Z-=S}var U=ad+Z,Y=Math.floor(Math.max(0,(U-L)*ag)),ab=Math.floor(Math.max(0,(U+S-L)*ag));if(Y===ab){ab+=1}switch(E){case"H":break;case"S":case"M":case"=":if(is_overlap([U,U+S],R)){var N=M.slice(W,W+S);if(D>0){K.fillStyle=y;K.fillRect(Y-D,V+1,ab-Y,9);K.fillStyle=g;for(var af=0,H=N.length;af<H;af++){if(this.prefs.show_differences){if(this.ref_seq){var P=this.ref_seq[U-L+af];if(!P||P.toLowerCase()===N[af].toLowerCase()){continue}}else{continue}}if(U+af>=L&&U+af<=aa){var X=Math.floor(Math.max(0,(U+af-L)*ag));K.fillText(N[af],X,V+9)}}}else{K.fillStyle=y;K.fillRect(Y,V+4,ab-Y,e)}}W+=S;Z+=S;break;case"N":K.fillStyle=g;K.fillRect(Y-D,V+5,ab-Y,1);Z+=S;break;case"D":K.fillStyle="red";K.fillRect(Y-D,V+4,ab-Y,3);Z+=S;break;case"P":break;case"I":var ah=Y-D;if(is_overlap([U,U+S],R)){var N=M.slice(W,W+S);if(this.prefs.show_insertions){var T=Y-(ab-Y)/2;if((A==="Pack"||this.mode==="Auto")&&M!==undefined&&ag>F){K.fillStyle="yellow";K.fillRect(T-D,V-9,ab-Y,9);O[O.length]={type:"triangle",data:[ah,V+4,5]};K.fillStyle=g;switch(compute_overlap([U,U+S],R)){case (OVERLAP_START):N=N.slice(L-U);break;case (OVERLAP_END):N=N.slice(0,U-aa);break;case (CONTAINED_BY):break;case (CONTAINS):N=N.slice(L-U,U-aa);break}for(var af=0,H=N.length;af<H;af++){var X=Math.floor(Math.max(0,(U+af-L)*ag));K.fillText(N[af],X-(ab-Y)/2,V)}}else{K.fillStyle="yellow";K.fillRect(T,V+(this.mode!=="Dense"?2:5),ab-Y,(A!=="Dense"?e:s))}}else{if((A==="Pack"||this.mode==="Auto")&&M!==undefined&&ag>F){O.push({type:"text",data:[N.length,ah,V+9]})}else{}}}W+=S;break;case"X":W+=S;break}}K.fillStyle="yellow";var Q,ai,ae;for(var ac=0;ac<O.length;ac++){Q=O[ac];ai=Q.type;ae=Q.data;if(ai==="text"){K.save();K.font="bold "+K.font;K.fillText(ae[0],ae[1],ae[2]);K.restore()}else{if(ai==="triangle"){q(K,ae[0],ae[1],ae[2])}}}},draw_element:function(R,M,E,B,U,z,I,S,P){var H=E[0],Q=E[1],A=E[2],J=E[3],D=Math.floor(Math.max(0,(Q-U)*I)),F=Math.ceil(Math.min(P,Math.max(0,(A-U)*I))),C=(M==="Dense"?0:(0+B))*S,G=this.prefs.label_color,O=0;if((M==="Pack"||this.mode==="Auto")&&I>R.canvas.manager.char_width_px){var O=Math.round(I/2)}if(E[5] instanceof Array){var N=Math.floor(Math.max(0,(E[4][0]-U)*I)),L=Math.ceil(Math.min(P,Math.max(0,(E[4][1]-U)*I))),K=Math.floor(Math.max(0,(E[5][0]-U)*I)),y=Math.ceil(Math.min(P,Math.max(0,(E[5][1]-U)*I)));if(E[4][1]>=U&&E[4][0]<=z&&E[4][2]){this.draw_read(R,M,I,C,U,z,E[4][0],E[4][2],E[4][3],E[4][4])}if(E[5][1]>=U&&E[5][0]<=z&&E[5][2]){this.draw_read(R,M,I,C,U,z,E[5][0],E[5][2],E[5][3],E[5][4])}if(K>L){R.fillStyle=g;p(R,L-O,C+5,K-O,C+5)}}else{this.draw_read(R,M,I,C,U,z,Q,E[4],E[5],E[6])}if(M==="Pack"&&Q>U&&J!=="."){R.fillStyle=this.prefs.label_color;var T=1;if(T===0&&D-R.measureText(J).width<0){R.textAlign="left";R.fillText(J,F+j-O,C+8)}else{R.textAlign="right";R.fillText(J,D-j-O,C+8)}}return[0,0]}});var n=function(A,D,y,z,C,E,B){r.call(this,A,D,y,z,C,E,B);this.longest_feature_length=this.calculate_longest_feature_length();this.draw_background_connector=false;this.draw_individual_connectors=true};u(n.prototype,o.prototype,r.prototype,{calculate_longest_feature_length:function(){var z=0;for(var C=0,y=this.data.length;C<y;C++){var B=this.data[C],A=B[1],D=B[2];z=Math.max(z,D-A)}return z},get_top_padding:function(z){var y=this.view_end-this.view_start,A=z/y;return Math.min(128,Math.ceil((this.longest_feature_length/2)*A))},draw_connector:function(G,B,F,H,E,D){var y=(F+H)/2,C=H-y;var A=Math.PI,z=0;if(C>0){G.beginPath();G.arc(y,D,H-y,Math.PI,0);G.stroke()}}});x.Scaler=d;x.SummaryTreePainter=v;x.LinePainter=b;x.LinkedFeaturePainter=r;x.ReadPainter=t;x.ArcLinkedFeaturePainter=n};(function(d){var c={};var b=function(e){return c[e]};var a=function(f,g){var e={};g(b,e);c[f]=e};a("class",class_module);a("slotting",slotting_module);a("painters",painters_module);a("trackster",trackster_module);for(key in c.trackster){d[key]=c.trackster[key]}})(window); \ No newline at end of file +var class_module=function(b,a){var c=function(){var g=arguments[0];for(var f=1;f<arguments.length;f++){var d=arguments[f];for(var e in d){g[e]=d[e]}}return g};a.extend=c};var requestAnimationFrame=(function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(b,a){window.setTimeout(b,1000/60)}})();var BEFORE=1001,CONTAINS=1002,OVERLAP_START=1003,OVERLAP_END=1004,CONTAINED_BY=1005,AFTER=1006;var compute_overlap=function(e,b){var g=e[0],f=e[1],d=b[0],c=b[1],a;if(g<d){if(f<d){a=BEFORE}else{if(f<=c){a=OVERLAP_START}else{a=CONTAINS}}}else{if(g>c){a=AFTER}else{if(f<=c){a=CONTAINED_BY}else{a=OVERLAP_END}}}return a};var is_overlap=function(c,b){var a=compute_overlap(c,b);return(a!==BEFORE&&a!==AFTER)};var is_deferred=function(a){return("isResolved" in a)};var get_random_color=function(a){if(!a){a="#ffffff"}if(typeof(a)==="string"){a=[a]}for(var j=0;j<a.length;j++){a[j]=parseInt(a[j].slice(1),16)}var n=function(t,s,i){return((t*299)+(s*587)+(i*114))/1000};var e=function(v,u,w,s,i,t){return(Math.max(v,s)-Math.min(v,s))+(Math.max(u,i)-Math.min(u,i))+(Math.max(w,t)-Math.min(w,t))};var g,o,f,k,q,h,r,c,d,b,p,m=false,l=0;do{g=Math.round(Math.random()*16777215);o=(g&16711680)>>16;f=(g&65280)>>8;k=g&255;d=n(o,f,k);m=true;for(j=0;j<a.length;j++){q=a[j];h=(q&16711680)>>16;r=(q&65280)>>8;c=q&255;b=n(h,r,c);p=e(o,f,k,h,r,c);if((Math.abs(d-b)<40)||(p<200)){m=false;break}}l++}while(!m&&l<=10);return"#"+(16777216+g).toString(16).substr(1,6)};var create_action_icon=function(c,b,a){return $("<a/>").attr("href","javascript:void(0);").attr("title",c).addClass("icon-button").addClass(b).tipsy({gravity:"s"}).click(a)};var trackster_module=function(d,R){var o=d("class").extend,r=d("slotting"),H=d("painters");var m={};var k=function(Y,Z){m[Y.attr("id")]=Z};var l=function(Y,aa,ac,ab){ac=".group";var Z={};m[Y.attr("id")]=ab;Y.bind("drag",{handle:"."+aa,relative:true},function(ak,al){var aj=$(this),ao=$(this).parent(),ag=ao.children(),ai=m[$(this).attr("id")],af,ae,am,ad,ah;ae=$(this).parents(ac);if(ae.length!==0){am=ae.position().top;ad=am+ae.outerHeight();if(al.offsetY<am){$(this).insertBefore(ae);var an=m[ae.attr("id")];an.remove_drawable(ai);an.container.add_drawable_before(ai,an);return}else{if(al.offsetY>ad){$(this).insertAfter(ae);var an=m[ae.attr("id")];an.remove_drawable(ai);an.container.add_drawable(ai);return}}}ae=null;for(ah=0;ah<ag.length;ah++){af=$(ag.get(ah));am=af.position().top;ad=am+af.outerHeight();if(af.is(ac)&&this!==af.get(0)&&al.offsetY>=am&&al.offsetY<=ad){if(al.offsetY-am<ad-al.offsetY){af.find(".content-div").prepend(this)}else{af.find(".content-div").append(this)}if(ai.container){ai.container.remove_drawable(ai)}m[af.attr("id")].add_drawable(ai);return}}for(ah=0;ah<ag.length;ah++){af=$(ag.get(ah));if(al.offsetY<af.position().top&&!(af.hasClass("reference-track")||af.hasClass("intro"))){break}}if(ah===ag.length){if(this!==ag.get(ah-1)){ao.append(this);m[ao.attr("id")].move_drawable(ai,ah)}}else{if(this!==ag.get(ah)){$(this).insertBefore(ag.get(ah));m[ao.attr("id")].move_drawable(ai,(al.deltaY>0?ah-1:ah))}}}).bind("dragstart",function(){Z["border-top"]=Y.css("border-top");Z["border-bottom"]=Y.css("border-bottom");$(this).css({"border-top":"1px solid blue","border-bottom":"1px solid blue"})}).bind("dragend",function(){$(this).css(Z)})};R.moveable=l;var X=16,C=9,z=20,w=100,E=12000,O=400,G=5000,t=100,n="There was an error in indexing this dataset. ",F="A converter for this dataset is not installed. Please check your datatypes_conf.xml file.",A="No data for this chrom/contig.",s="Preparing data. This can take a while for a large dataset. If the visualization is saved and closed, preparation will continue in the background.",u="Tool cannot be rerun: ",a="Loading data...",S="Ready for display",M=10,D=20;function T(Z,Y){if(!Y){Y=0}var aa=Math.pow(10,Y);return Math.round(Z*aa)/aa}var p=function(Z,Y,ab){if(!p.id_counter){p.id_counter=0}this.id=p.id_counter++;this.name=ab.name;this.view=Z;this.container=Y;this.config=new B({track:this,params:[{key:"name",label:"Name",type:"text",default_value:this.name}],saved_values:ab.prefs,onchange:function(){this.track.set_name(this.track.config.values.name)}});this.prefs=this.config.values;this.drag_handle_class=ab.drag_handle_class;this.is_overview=false;this.action_icons={};this.content_visible=true;this.container_div=this.build_container_div();this.header_div=this.build_header_div();if(this.header_div){this.container_div.append(this.header_div);this.icons_div=$("<div/>").css("float","left").hide().appendTo(this.header_div);this.build_action_icons(this.action_icons_def);this.header_div.append($("<div style='clear: both'/>"));this.header_div.dblclick(function(ac){ac.stopPropagation()});var aa=this;this.container_div.hover(function(){aa.icons_div.show()},function(){aa.icons_div.hide()});$("<div style='clear: both'/>").appendTo(this.container_div)}};p.prototype.action_icons_def=[{name:"toggle_icon",title:"Hide/show content",css_class:"toggle",on_click_fn:function(Y){if(Y.content_visible){Y.action_icons.toggle_icon.addClass("toggle-expand").removeClass("toggle");Y.hide_contents();Y.content_visible=false}else{Y.action_icons.toggle_icon.addClass("toggle").removeClass("toggle-expand");Y.content_visible=true;Y.show_contents()}}},{name:"settings_icon",title:"Edit settings",css_class:"settings-icon",on_click_fn:function(Z){var ab=function(){hide_modal();$(window).unbind("keypress.check_enter_esc")},Y=function(){Z.config.update_from_form($(".dialog-box"));hide_modal();$(window).unbind("keypress.check_enter_esc")},aa=function(ac){if((ac.keyCode||ac.which)===27){ab()}else{if((ac.keyCode||ac.which)===13){Y()}}};$(window).bind("keypress.check_enter_esc",aa);show_modal("Configure",Z.config.build_form(),{Cancel:ab,OK:Y})}},{name:"remove_icon",title:"Remove",css_class:"remove-icon",on_click_fn:function(Y){$(".tipsy").remove();Y.remove()}}];o(p.prototype,{init:function(){},changed:function(){this.view.changed()},can_draw:function(){if(this.enabled&&this.content_visible){return true}return false},request_draw:function(){},_draw:function(){},to_dict:function(){},set_name:function(Y){this.old_name=this.name;this.name=Y;this.name_div.text(this.name)},revert_name:function(){if(this.old_name){this.name=this.old_name;this.name_div.text(this.name)}},remove:function(){this.changed();this.container.remove_drawable(this);var Y=this.view;this.container_div.hide(0,function(){$(this).remove();Y.update_intro_div()})},build_container_div:function(){},build_header_div:function(){},add_action_icon:function(Z,ae,ad,ac,Y,ab){var aa=this;this.action_icons[Z]=$("<a/>").attr("href","javascript:void(0);").attr("title",ae).addClass("icon-button").addClass(ad).tipsy({gravity:"s"}).click(function(){ac(aa)}).appendTo(this.icons_div);if(ab){this.action_icons[Z].hide()}},build_action_icons:function(Y){var aa;for(var Z=0;Z<Y.length;Z++){aa=Y[Z];this.add_action_icon(aa.name,aa.title,aa.css_class,aa.on_click_fn,aa.prepend,aa.hide)}},update_icons:function(){},hide_contents:function(){},show_contents:function(){}});var v=function(Z,Y,aa){p.call(this,Z,Y,aa);this.obj_type=aa.obj_type;this.drawables=[]};o(v.prototype,p.prototype,{unpack_drawables:function(aa){this.drawables=[];var Z;for(var Y=0;Y<aa.length;Y++){Z=object_from_template(aa[Y],this.view,this);this.add_drawable(Z)}},init:function(){for(var Y=0;Y<this.drawables.length;Y++){this.drawables[Y].init()}},_draw:function(){for(var Y=0;Y<this.drawables.length;Y++){this.drawables[Y]._draw()}},to_dict:function(){var Z=[];for(var Y=0;Y<this.drawables.length;Y++){Z.push(this.drawables[Y].to_dict())}return{name:this.name,prefs:this.prefs,obj_type:this.obj_type,drawables:Z}},add_drawable:function(Y){this.drawables.push(Y);Y.container=this;this.changed()},add_drawable_before:function(aa,Y){this.changed();var Z=this.drawables.indexOf(Y);if(Z!==-1){this.drawables.splice(Z,0,aa);return true}return false},replace_drawable:function(aa,Y,Z){var ab=this.drawables.indexOf(aa);if(ab!==-1){this.drawables[ab]=Y;if(Z){aa.container_div.replaceWith(Y.container_div)}this.changed()}return ab},remove_drawable:function(Z){var Y=this.drawables.indexOf(Z);if(Y!==-1){this.drawables.splice(Y,1);Z.container=null;this.changed();return true}return false},move_drawable:function(Z,aa){var Y=this.drawables.indexOf(Z);if(Y!==-1){this.drawables.splice(Y,1);this.drawables.splice(aa,0,Z);this.changed();return true}return false}});var L=function(Z,Y,ab){o(ab,{obj_type:"DrawableGroup",drag_handle_class:"group-handle"});v.call(this,Z,Y,ab);this.content_div=$("<div/>").addClass("content-div").attr("id","group_"+this.id+"_content_div").appendTo(this.container_div);k(this.container_div,this);k(this.content_div,this);l(this.container_div,this.drag_handle_class,".group",this);this.filters_manager=new U(this);this.header_div.after(this.filters_manager.parent_div);this.saved_filters_managers=[];if("drawables" in ab){this.unpack_drawables(ab.drawables)}if("filters" in ab){var aa=this.filters_manager;this.filters_manager=new U(this,ab.filters);aa.parent_div.replaceWith(this.filters_manager.parent_div);if(ab.filters.visible){this.setup_multitrack_filtering()}}};o(L.prototype,p.prototype,v.prototype,{action_icons_def:[p.prototype.action_icons_def[0],p.prototype.action_icons_def[1],{name:"composite_icon",title:"Show composite track",css_class:"layers-stack",on_click_fn:function(Y){$(".tipsy").remove();Y.show_composite_track()}},{name:"filters_icon",title:"Filters",css_class:"filters-icon",on_click_fn:function(Y){if(Y.filters_manager.visible()){Y.filters_manager.clear_filters();Y._restore_filter_managers()}else{Y.setup_multitrack_filtering();Y.request_draw(true)}Y.filters_manager.toggle()}},p.prototype.action_icons_def[2]],build_container_div:function(){var Y=$("<div/>").addClass("group").attr("id","group_"+this.id);if(this.container){this.container.content_div.append(Y)}return Y},build_header_div:function(){var Y=$("<div/>").addClass("track-header");Y.append($("<div/>").addClass(this.drag_handle_class));this.name_div=$("<div/>").addClass("track-name").text(this.name).appendTo(Y);return Y},hide_contents:function(){this.tiles_div.hide()},show_contents:function(){this.tiles_div.show();this.request_draw()},update_icons:function(){var aa=this.drawables.length;if(aa===0){this.action_icons.composite_icon.hide();this.action_icons.filters_icon.hide()}else{if(aa===1){if(this.drawables[0] instanceof g){this.action_icons.composite_icon.show()}this.action_icons.filters_icon.hide()}else{var ah,ag,ae,ak=true,ac=this.drawables[0].get_type(),Y=0;for(ah=0;ah<aa;ah++){ae=this.drawables[ah];if(ae.get_type()!==ac){can_composite=false;break}if(ae instanceof c){Y++}}if(ak||Y===1){this.action_icons.composite_icon.show()}else{this.action_icons.composite_icon.hide();$(".tipsy").remove()}if(Y>1&&Y===this.drawables.length){var al={},Z;ae=this.drawables[0];for(ag=0;ag<ae.filters_manager.filters.length;ag++){Z=ae.filters_manager.filters[ag];al[Z.name]=[Z]}for(ah=1;ah<this.drawables.length;ah++){ae=this.drawables[ah];for(ag=0;ag<ae.filters_manager.filters.length;ag++){Z=ae.filters_manager.filters[ag];if(Z.name in al){al[Z.name].push(Z)}}}this.filters_manager.remove_all();var ab,ad,af,ai;for(var aj in al){ab=al[aj];if(ab.length===Y){ad=new P({name:ab[0].name,index:ab[0].index});this.filters_manager.add_filter(ad)}}if(this.filters_manager.filters.length>0){this.action_icons.filters_icon.show()}else{this.action_icons.filters_icon.hide()}}else{this.action_icons.filters_icon.hide()}}}},_restore_filter_managers:function(){for(var Y=0;Y<this.drawables.length;Y++){this.drawables[Y].filters_manager=this.saved_filters_managers[Y]}this.saved_filters_managers=[]},setup_multitrack_filtering:function(){if(this.filters_manager.filters.length>0){this.saved_filters_managers=[];for(var Y=0;Y<this.drawables.length;Y++){drawable=this.drawables[Y];this.saved_filters_managers.push(drawable.filters_manager);drawable.filters_manager=this.filters_manager}}this.filters_manager.init_filters()},show_composite_track:function(){var ac=[];for(var Z=0;Z<this.drawables.length;Z++){ac.push(this.drawables[Z].name)}var aa="Composite Track of "+this.drawables.length+" tracks ("+ac.join(", ")+")";var ab=new g(this.view,this.view,{name:aa,drawables:this.drawables});var Y=this.container.replace_drawable(this,ab,true);ab.request_draw()},add_drawable:function(Y){v.prototype.add_drawable.call(this,Y);this.update_icons()},remove_drawable:function(Y){v.prototype.remove_drawable.call(this,Y);this.update_icons()},to_dict:function(){if(this.filters_manager.visible()){this._restore_filter_managers()}var Y=o(v.prototype.to_dict.call(this),{filters:this.filters_manager.to_dict()});if(this.filters_manager.visible()){this.setup_multitrack_filtering()}return Y},request_draw:function(Y,aa){for(var Z=0;Z<this.drawables.length;Z++){this.drawables[Z].request_draw(Y,aa)}}});var W=function(Y){o(Y,{obj_type:"View"});v.call(this,"View",Y.container,Y);this.chrom=null;this.vis_id=Y.vis_id;this.dbkey=Y.dbkey;this.label_tracks=[];this.tracks_to_be_redrawn=[];this.max_low=0;this.max_high=0;this.zoom_factor=3;this.min_separation=30;this.has_changes=false;this.load_chroms_deferred=null;this.init();this.canvas_manager=new CanvasManager(this.container.get(0).ownerDocument);this.reset()};_.extend(W.prototype,Backbone.Events);o(W.prototype,v.prototype,{init:function(){this.requested_redraw=false;var aa=this.container,Y=this;this.top_container=$("<div/>").addClass("top-container").appendTo(aa);this.browser_content_div=$("<div/>").addClass("content").css("position","relative").appendTo(aa);this.bottom_container=$("<div/>").addClass("bottom-container").appendTo(aa);this.top_labeltrack=$("<div/>").addClass("top-labeltrack").appendTo(this.top_container);this.viewport_container=$("<div/>").addClass("viewport-container").attr("id","viewport-container").appendTo(this.browser_content_div);this.content_div=this.viewport_container;k(this.viewport_container,Y);this.intro_div=$("<div/>").addClass("intro").appendTo(this.viewport_container).hide();var ab=$("<div/>").text("Add Datasets to Visualization").addClass("action-button").appendTo(this.intro_div).click(function(){add_datasets(add_datasets_url,add_track_async_url,function(ac){_.each(ac,function(ad){Y.add_drawable(object_from_template(ad,Y,Y))})})});this.nav_labeltrack=$("<div/>").addClass("nav-labeltrack").appendTo(this.bottom_container);this.nav_container=$("<div/>").addClass("trackster-nav-container").prependTo(this.top_container);this.nav=$("<div/>").addClass("trackster-nav").appendTo(this.nav_container);this.overview=$("<div/>").addClass("overview").appendTo(this.bottom_container);this.overview_viewport=$("<div/>").addClass("overview-viewport").appendTo(this.overview);this.overview_close=$("<a/>").attr("href","javascript:void(0);").attr("title","Close overview").addClass("icon-button overview-close tooltip").hide().appendTo(this.overview_viewport);this.overview_highlight=$("<div/>").addClass("overview-highlight").hide().appendTo(this.overview_viewport);this.overview_box_background=$("<div/>").addClass("overview-boxback").appendTo(this.overview_viewport);this.overview_box=$("<div/>").addClass("overview-box").appendTo(this.overview_viewport);this.default_overview_height=this.overview_box.height();this.nav_controls=$("<div/>").addClass("nav-controls").appendTo(this.nav);this.chrom_select=$("<select/>").attr({name:"chrom"}).css("width","15em").addClass("no-autocomplete").append("<option value=''>Loading</option>").appendTo(this.nav_controls);var Z=function(ac){if(ac.type==="focusout"||(ac.keyCode||ac.which)===13||(ac.keyCode||ac.which)===27){if((ac.keyCode||ac.which)!==27){Y.go_to($(this).val())}$(this).hide();$(this).val("");Y.location_span.show();Y.chrom_select.show()}};this.nav_input=$("<input/>").addClass("nav-input").hide().bind("keyup focusout",Z).appendTo(this.nav_controls);this.location_span=$("<span/>").addClass("location").attr("original-title","Click to change location").tipsy({gravity:"n"}).appendTo(this.nav_controls);this.location_span.click(function(){Y.location_span.hide();Y.chrom_select.hide();Y.nav_input.val(Y.chrom+":"+Y.low+"-"+Y.high);Y.nav_input.css("display","inline-block");Y.nav_input.select();Y.nav_input.focus()});if(this.vis_id!==undefined){this.hidden_input=$("<input/>").attr("type","hidden").val(this.vis_id).appendTo(this.nav_controls)}this.zo_link=$("<a/>").attr("id","zoom-out").attr("title","Zoom out").tipsy({gravity:"n"}).click(function(){Y.zoom_out();Y.request_redraw()}).appendTo(this.nav_controls);this.zi_link=$("<a/>").attr("id","zoom-in").attr("title","Zoom in").tipsy({gravity:"n"}).click(function(){Y.zoom_in();Y.request_redraw()}).appendTo(this.nav_controls);this.load_chroms_deferred=this.load_chroms({low:0});this.chrom_select.bind("change",function(){Y.change_chrom(Y.chrom_select.val())});this.browser_content_div.click(function(ac){$(this).find("input").trigger("blur")});this.browser_content_div.bind("dblclick",function(ac){Y.zoom_in(ac.pageX,this.viewport_container)});this.overview_box.bind("dragstart",function(ac,ad){this.current_x=ad.offsetX}).bind("drag",function(ac,ae){var af=ae.offsetX-this.current_x;this.current_x=ae.offsetX;var ad=Math.round(af/Y.viewport_container.width()*(Y.max_high-Y.max_low));Y.move_delta(-ad)});this.overview_close.click(function(){Y.reset_overview()});this.viewport_container.bind("draginit",function(ac,ad){if(ac.clientX>Y.viewport_container.width()-16){return false}}).bind("dragstart",function(ac,ad){ad.original_low=Y.low;ad.current_height=ac.clientY;ad.current_x=ad.offsetX}).bind("drag",function(ae,ag){var ac=$(this);var ah=ag.offsetX-ag.current_x;var ad=ac.scrollTop()-(ae.clientY-ag.current_height);ac.scrollTop(ad);ag.current_height=ae.clientY;ag.current_x=ag.offsetX;var af=Math.round(ah/Y.viewport_container.width()*(Y.high-Y.low));Y.move_delta(af)}).bind("mousewheel",function(ae,ag,ad,ac){if(ad){ad*=50;var af=Math.round(-ad/Y.viewport_container.width()*(Y.high-Y.low));Y.move_delta(af)}});this.top_labeltrack.bind("dragstart",function(ac,ad){return $("<div />").css({height:Y.browser_content_div.height()+Y.top_labeltrack.height()+Y.nav_labeltrack.height()+1,top:"0px",position:"absolute","background-color":"#ccf",opacity:0.5,"z-index":1000}).appendTo($(this))}).bind("drag",function(ag,ah){$(ah.proxy).css({left:Math.min(ag.pageX,ah.startX)-Y.container.offset().left,width:Math.abs(ag.pageX-ah.startX)});var ad=Math.min(ag.pageX,ah.startX)-Y.container.offset().left,ac=Math.max(ag.pageX,ah.startX)-Y.container.offset().left,af=(Y.high-Y.low),ae=Y.viewport_container.width();Y.update_location(Math.round(ad/ae*af)+Y.low,Math.round(ac/ae*af)+Y.low)}).bind("dragend",function(ah,ai){var ad=Math.min(ah.pageX,ai.startX),ac=Math.max(ah.pageX,ai.startX),af=(Y.high-Y.low),ae=Y.viewport_container.width(),ag=Y.low;Y.low=Math.round(ad/ae*af)+ag;Y.high=Math.round(ac/ae*af)+ag;$(ai.proxy).remove();Y.request_redraw()});this.add_label_track(new V(this,{content_div:this.top_labeltrack}));this.add_label_track(new V(this,{content_div:this.nav_labeltrack}));$(window).bind("resize",function(){if(this.resize_timer){clearTimeout(this.resize_timer)}this.resize_timer=setTimeout(function(){Y.resize_window()},500)});$(document).bind("redraw",function(){Y.redraw()});this.reset();$(window).trigger("resize")},changed:function(){this.has_changes=true},update_intro_div:function(){if(this.drawables.length===0){this.intro_div.show()}else{this.intro_div.hide()}},trigger_navigate:function(Z,ab,Y,ac){if(this.timer){clearTimeout(this.timer)}if(ac){var aa=this;this.timer=setTimeout(function(){aa.trigger("navigate",Z+":"+ab+"-"+Y)},500)}else{view.trigger("navigate",Z+":"+ab+"-"+Y)}},update_location:function(Y,aa){this.location_span.text(commatize(Y)+" - "+commatize(aa));this.nav_input.val(this.chrom+":"+commatize(Y)+"-"+commatize(aa));var Z=view.chrom_select.val();if(Z!==""){this.trigger_navigate(Z,view.low,view.high,true)}},load_chroms:function(aa){aa.num=t;aa.dbkey=this.dbkey;var Y=this,Z=$.Deferred();$.ajax({url:chrom_url,data:aa,dataType:"json",success:function(ac){if(ac.chrom_info.length===0){alert("Invalid chromosome: "+aa.chrom);return}if(ac.reference){Y.add_label_track(new x(Y))}Y.chrom_data=ac.chrom_info;var af='<option value="">Select Chrom/Contig</option>';for(var ae=0,ab=Y.chrom_data.length;ae<ab;ae++){var ad=Y.chrom_data[ae].chrom;af+='<option value="'+ad+'">'+ad+"</option>"}if(ac.prev_chroms){af+='<option value="previous">Previous '+t+"</option>"}if(ac.next_chroms){af+='<option value="next">Next '+t+"</option>"}Y.chrom_select.html(af);Y.chrom_start_index=ac.start_index;Z.resolve(ac)},error:function(){alert("Could not load chroms for this dbkey:",Y.dbkey)}});return Z},change_chrom:function(ad,Z,af){var aa=this;if(!aa.chrom_data){aa.load_chroms_deferred.then(function(){aa.change_chrom(ad,Z,af)});return}if(!ad||ad==="None"){return}if(ad==="previous"){aa.load_chroms({low:this.chrom_start_index-t});return}if(ad==="next"){aa.load_chroms({low:this.chrom_start_index+t});return}var ae=$.grep(aa.chrom_data,function(ag,ah){return ag.chrom===ad})[0];if(ae===undefined){aa.load_chroms({chrom:ad},function(){aa.change_chrom(ad,Z,af)});return}else{if(ad!==aa.chrom){aa.chrom=ad;aa.chrom_select.val(aa.chrom);aa.max_high=ae.len-1;aa.reset();aa.request_redraw(true);for(var ac=0,Y=aa.drawables.length;ac<Y;ac++){var ab=aa.drawables[ac];if(ab.init){ab.init()}}if(aa.reference_track){aa.reference_track.init()}}if(Z!==undefined&&af!==undefined){aa.low=Math.max(Z,0);aa.high=Math.min(af,aa.max_high)}else{aa.low=0;aa.high=aa.max_high}aa.reset_overview();aa.request_redraw()}},go_to:function(ac){ac=ac.replace(/ |,/g,"");var ag=this,Y,ab,Z=ac.split(":"),ae=Z[0],af=Z[1];if(af!==undefined){try{var ad=af.split("-");Y=parseInt(ad[0],10);ab=parseInt(ad[1],10)}catch(aa){return false}}ag.change_chrom(ae,Y,ab)},move_fraction:function(aa){var Y=this;var Z=Y.high-Y.low;this.move_delta(aa*Z)},move_delta:function(ab){var Y=this;var aa=Y.high-Y.low;if(Y.low-ab<Y.max_low){Y.low=Y.max_low;Y.high=Y.max_low+aa}else{if(Y.high-ab>Y.max_high){Y.high=Y.max_high;Y.low=Y.max_high-aa}else{Y.high-=ab;Y.low-=ab}}Y.request_redraw();var Z=Y.chrom_select.val();this.trigger_navigate(Z,Y.low,Y.high,true)},add_drawable:function(Y){v.prototype.add_drawable.call(this,Y);Y.init();this.changed();this.update_intro_div()},add_label_track:function(Y){Y.view=this;Y.init();this.label_tracks.push(Y)},remove_drawable:function(aa,Z){v.prototype.remove_drawable.call(this,aa);if(Z){var Y=this;aa.container_div.hide(0,function(){$(this).remove();Y.update_intro_div()})}},reset:function(){this.low=this.max_low;this.high=this.max_high;this.viewport_container.find(".yaxislabel").remove()},request_redraw:function(ag,Y,af,ah){var ae=this,ad=(ah?[ah]:ae.drawables),aa;var Z;for(var ac=0;ac<ad.length;ac++){Z=ad[ac];aa=-1;for(var ab=0;ab<ae.tracks_to_be_redrawn.length;ab++){if(ae.tracks_to_be_redrawn[ab][0]===Z){aa=ab;break}}if(aa<0){ae.tracks_to_be_redrawn.push([Z,Y,af])}else{ae.tracks_to_be_redrawn[ac][1]=Y;ae.tracks_to_be_redrawn[ac][2]=af}}if(!this.requested_redraw){requestAnimationFrame(function(){ae._redraw(ag)});this.requested_redraw=true}},_redraw:function(ai){this.requested_redraw=false;var af=this.low,ab=this.high;if(af<this.max_low){af=this.max_low}if(ab>this.max_high){ab=this.max_high}var ah=this.high-this.low;if(this.high!==0&&ah<this.min_separation){ab=af+this.min_separation}this.low=Math.floor(af);this.high=Math.ceil(ab);this.update_location(this.low,this.high);this.resolution_b_px=(this.high-this.low)/this.viewport_container.width();this.resolution_px_b=this.viewport_container.width()/(this.high-this.low);var Y=(this.low/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var ae=((this.high-this.low)/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var aj=13;this.overview_box.css({left:Y,width:Math.max(aj,ae)}).show();if(ae<aj){this.overview_box.css("left",Y-(aj-ae)/2)}if(this.overview_highlight){this.overview_highlight.css({left:Y,width:ae})}if(!ai){var aa,Z,ag;for(var ac=0,ad=this.tracks_to_be_redrawn.length;ac<ad;ac++){aa=this.tracks_to_be_redrawn[ac][0];Z=this.tracks_to_be_redrawn[ac][1];ag=this.tracks_to_be_redrawn[ac][2];if(aa){aa._draw(Z,ag)}}this.tracks_to_be_redrawn=[];for(ac=0,ad=this.label_tracks.length;ac<ad;ac++){this.label_tracks[ac]._draw()}}},zoom_in:function(Z,aa){if(this.max_high===0||this.high-this.low<=this.min_separation){return}var ab=this.high-this.low,ac=ab/2+this.low,Y=(ab/this.zoom_factor)/2;if(Z){ac=Z/this.viewport_container.width()*(this.high-this.low)+this.low}this.low=Math.round(ac-Y);this.high=Math.round(ac+Y);this.changed();this.request_redraw()},zoom_out:function(){if(this.max_high===0){return}var Z=this.high-this.low,aa=Z/2+this.low,Y=(Z*this.zoom_factor)/2;this.low=Math.round(aa-Y);this.high=Math.round(aa+Y);this.changed();this.request_redraw()},resize_window:function(){this.viewport_container.height(this.container.height()-this.top_container.height()-this.bottom_container.height());this.request_redraw()},set_overview:function(aa){if(this.overview_drawable){if(this.overview_drawable.dataset_id===aa.dataset_id){return}this.overview_viewport.find(".track").remove()}var Z=aa.copy({content_div:this.overview_viewport}),Y=this;Z.header_div.hide();Z.is_overview=true;Y.overview_drawable=Z;this.overview_drawable.postdraw_actions=function(){Y.overview_highlight.show().height(Y.overview_drawable.content_div.height());Y.overview_viewport.height(Y.overview_drawable.content_div.height()+Y.overview_box.outerHeight());Y.overview_close.show();Y.resize_window()};Y.overview_drawable.request_draw();this.changed()},reset_overview:function(){$(".tipsy").remove();this.overview_viewport.find(".track-tile").remove();this.overview_viewport.height(this.default_overview_height);this.overview_box.height(this.default_overview_height);this.overview_close.hide();this.overview_highlight.hide();view.resize_window();view.overview_drawable=null}});var q=function(aa,af,ab){this.track=aa;this.name=af.name;this.params=[];var am=af.params;for(var ac=0;ac<am.length;ac++){var ah=am[ac],Z=ah.name,al=ah.label,ad=unescape(ah.html),an=ah.value,aj=ah.type;if(aj==="number"){this.params.push(new e(Z,al,ad,(Z in ab?ab[Z]:an),ah.min,ah.max))}else{if(aj==="select"){this.params.push(new J(Z,al,ad,(Z in ab?ab[Z]:an)))}else{console.log("WARNING: unrecognized tool parameter type:",Z,aj)}}}this.parent_div=$("<div/>").addClass("dynamic-tool").hide();this.parent_div.bind("drag",function(ap){ap.stopPropagation()}).click(function(ap){ap.stopPropagation()}).bind("dblclick",function(ap){ap.stopPropagation()});var ak=$("<div class='tool-name'>").appendTo(this.parent_div).text(this.name);var ai=this.params;var ag=this;$.each(this.params,function(aq,au){var at=$("<div>").addClass("param-row").appendTo(ag.parent_div);var ap=$("<div>").addClass("param-label").text(au.label).appendTo(at);var ar=$("<div/>").addClass("param-input").html(au.html).appendTo(at);ar.find(":input").val(au.value);$("<div style='clear: both;'/>").appendTo(at)});this.parent_div.find("input").click(function(){$(this).select()});var ao=$("<div>").addClass("param-row").appendTo(this.parent_div);var ae=$("<input type='submit'>").attr("value","Run on complete dataset").appendTo(ao);var Y=$("<input type='submit'>").attr("value","Run on visible region").css("margin-left","3em").appendTo(ao);Y.click(function(){ag.run_on_region()});ae.click(function(){ag.run_on_dataset()});if("visible" in ab&&ab.visible){this.parent_div.show()}};o(q.prototype,{update_params:function(){for(var Y=0;Y<this.params.length;Y++){this.params[Y].update_value()}},state_dict:function(){var Z={};for(var Y=0;Y<this.params.length;Y++){Z[this.params[Y].name]=this.params[Y].value}Z.visible=this.parent_div.is(":visible");return Z},get_param_values_dict:function(){var Y={};this.parent_div.find(":input").each(function(){var Z=$(this).attr("name"),aa=$(this).val();Y[Z]=aa});return Y},get_param_values:function(){var Y=[];this.parent_div.find(":input").each(function(){var Z=$(this).attr("name"),aa=$(this).val();if(Z){Y[Y.length]=aa}});return Y},run_on_dataset:function(){var Y=this;Y.run({target_dataset_id:this.track.original_dataset_id,tool_id:Y.name},null,function(Z){show_modal(Y.name+" is Running",Y.name+" is running on the complete dataset. Tool outputs are in dataset's history.",{Close:hide_modal})})},run_on_region:function(){var Z={target_dataset_id:this.track.original_dataset_id,action:"rerun",tool_id:this.name,regions:[{chrom:this.track.view.chrom,start:this.track.view.low,end:this.track.view.high}]},ad=this.track,aa=Z.tool_id+ad.tool_region_and_parameters_str(Z.chrom,Z.low,Z.high),Y;if(ad.container===view){var ac=new L(view,view,{name:this.name});var ab=ad.container.replace_drawable(ad,ac,false);ac.container_div.insertBefore(ad.view.content_div.children()[ab]);ac.add_drawable(ad);ad.container_div.appendTo(ac.content_div);Y=ac}else{Y=ad.container}var ae=new ad.constructor(view,Y,{name:aa,hda_ldda:"hda"});ae.init_for_tool_data();ae.change_mode(ad.mode);ae.set_filters_manager(ad.filters_manager.copy(ae));ae.update_icons();Y.add_drawable(ae);ae.tiles_div.text("Starting job.");this.update_params();this.run(Z,ae,function(af){ae.set_dataset(new Dataset(af));ae.tiles_div.text("Running job.");ae.init()})},run:function(Y,aa,ab){Y.inputs=this.get_param_values_dict();var Z=new ServerStateDeferred({ajax_settings:{url:galaxy_paths.get("tool_url"),data:JSON.stringify(Y),dataType:"json",contentType:"application/json",type:"POST"},interval:2000,success_fn:function(ac){return ac!=="pending"}});$.when(Z.go()).then(function(ac){if(ac==="no converter"){aa.container_div.addClass("error");aa.content_div.text(F)}else{if(ac.error){aa.container_div.addClass("error");aa.content_div.text(u+ac.message)}else{ab(ac)}}})}});var J=function(Z,Y,aa,ab){this.name=Z;this.label=Y;this.html=$(aa);this.value=ab};o(J.prototype,{update_value:function(){this.value=$(this.html).val()}});var e=function(aa,Z,ac,ad,ab,Y){J.call(this,aa,Z,ac,ad);this.min=ab;this.max=Y};o(e.prototype,J.prototype,{update_value:function(){J.prototype.update_value.call(this);this.value=parseFloat(this.value)}});var f=function(Y){this.manager=null;this.name=Y.name;this.index=Y.index;this.tool_id=Y.tool_id;this.tool_exp_name=Y.tool_exp_name};o(f.prototype,{to_dict:function(){return{name:this.name,index:this.index,tool_id:this.tool_id,tool_exp_name:this.tool_exp_name}}});var P=function(ag){f.call(this,ag);this.low=("low" in ag?ag.low:-Number.MAX_VALUE);this.high=("high" in ag?ag.high:Number.MAX_VALUE);this.min=("min" in ag?ag.min:Number.MAX_VALUE);this.max=("max" in ag?ag.max:-Number.MAX_VALUE);this.container=null;this.slider=null;this.slider_label=null;var ac=function(ah,ai,aj){ah.click(function(){var ao=ai.text(),am=parseFloat(aj.slider("option","max")),al=(am<=1?4:am<=1000000?am.toString().length:6),an=false,ak=$(this).parents(".slider-row");ak.addClass("input");if(aj.slider("option","values")){al=2*al+1;an=true}ai.text("");$("<input type='text'/>").attr("size",al).attr("maxlength",al).attr("value",ao).appendTo(ai).focus().select().click(function(ap){ap.stopPropagation()}).blur(function(){$(this).remove();ai.text(ao);ak.removeClass("input")}).keyup(function(au){if(au.keyCode===27){$(this).trigger("blur")}else{if(au.keyCode===13){var ar=aj.slider("option","min"),ap=aj.slider("option","max"),at=function(av){return(isNaN(av)||av>ap||av<ar)},aq=$(this).val();if(!an){aq=parseFloat(aq);if(at(aq)){alert("Parameter value must be in the range ["+ar+"-"+ap+"]");return $(this)}}else{aq=aq.split("-");aq=[parseFloat(aq[0]),parseFloat(aq[1])];if(at(aq[0])||at(aq[1])){alert("Parameter value must be in the range ["+ar+"-"+ap+"]");return $(this)}}aj.slider((an?"values":"value"),aq);ak.removeClass("input")}}})})};var Z=this;Z.parent_div=$("<div/>").addClass("filter-row slider-row");var Y=$("<div/>").addClass("elt-label").appendTo(Z.parent_div),ae=$("<span/>").addClass("slider-name").text(Z.name+" ").appendTo(Y),aa=$("<span/>").text(this.low+"-"+this.high),ab=$("<span/>").addClass("slider-value").appendTo(Y).append("[").append(aa).append("]");Z.values_span=aa;var ad=$("<div/>").addClass("slider").appendTo(Z.parent_div);Z.control_element=$("<div/>").attr("id",Z.name+"-filter-control").appendTo(ad);Z.control_element.slider({range:true,min:this.min,max:this.max,step:this.get_slider_step(this.min,this.max),values:[this.low,this.high],slide:function(ah,ai){Z.slide(ah,ai)},change:function(ah,ai){Z.control_element.slider("option","slide").call(Z.control_element,ah,ai)}});Z.slider=Z.control_element;Z.slider_label=aa;ac(ab,aa,Z.control_element);var af=$("<div/>").addClass("display-controls").appendTo(Z.parent_div);this.transparency_icon=create_action_icon("Use filter for data transparency","layer-transparent",function(){if(Z.manager.alpha_filter!==Z){Z.manager.alpha_filter=Z;Z.manager.parent_div.find(".layer-transparent").removeClass("active").hide();Z.transparency_icon.addClass("active").show()}else{Z.manager.alpha_filter=null;Z.transparency_icon.removeClass("active")}Z.manager.track.request_draw(true,true)}).appendTo(af).hide();this.height_icon=create_action_icon("Use filter for data height","arrow-resize-090",function(){if(Z.manager.height_filter!==Z){Z.manager.height_filter=Z;Z.manager.parent_div.find(".arrow-resize-090").removeClass("active").hide();Z.height_icon.addClass("active").show()}else{Z.manager.height_filter=null;Z.height_icon.removeClass("active")}Z.manager.track.request_draw(true,true)}).appendTo(af).hide();Z.parent_div.hover(function(){Z.transparency_icon.show();Z.height_icon.show()},function(){if(Z.manager.alpha_filter!==Z){Z.transparency_icon.hide()}if(Z.manager.height_filter!==Z){Z.height_icon.hide()}});$("<div style='clear: both;'/>").appendTo(Z.parent_div)};o(P.prototype,{to_dict:function(){var Y=f.prototype.to_dict.call(this);return o(Y,{type:"number",min:this.min,max:this.max,low:this.low,high:this.high})},copy:function(){return new P({name:this.name,index:this.index,tool_id:this.tool_id,tool_exp_name:this.tool_exp_name})},get_slider_step:function(aa,Y){var Z=Y-aa;return(Z<=2?0.01:1)},slide:function(aa,ab){var Z=ab.values;this.values_span.text(Z[0]+"-"+Z[1]);this.low=Z[0];this.high=Z[1];var Y=this;setTimeout(function(){if(Z[0]===Y.low&&Z[1]===Y.high){Y.manager.track.request_draw(true,true)}},25)},applies_to:function(Y){if(Y.length>this.index){return true}return false},_keep_val:function(Y){return(isNaN(Y)||(Y>=this.low&&Y<=this.high))},keep:function(Z){if(!this.applies_to(Z)){return true}var ab=this;var ac=Z[this.index];if(ac instanceof Array){var aa=true;for(var Y=0;Y<ac.length;Y++){if(!this._keep_val(ac[Y])){aa=false;break}}return aa}else{return this._keep_val(Z[this.index])}},update_attrs:function(ab){var Y=false;if(!this.applies_to(ab)){return Y}var Z=ab[this.index];if(!(Z instanceof Array)){Z=[Z]}for(var aa=0;aa<Z.length;aa++){var ac=Z[aa];if(ac<this.min){this.min=Math.floor(ac);Y=true}if(ac>this.max){this.max=Math.ceil(ac);Y=true}}return Y},update_ui_elt:function(){if(this.min<this.max){this.parent_div.show()}else{this.parent_div.hide()}var Z=this.slider.slider("option","min"),Y=this.slider.slider("option","max");if(this.min<Z||this.max>Y){this.slider.slider("option","min",this.min);this.slider.slider("option","max",this.max);this.slider.slider("option","step",this.get_slider_step(this.min,this.max));this.slider.slider("option","values",[this.min,this.max])}}});var U=function(aa,ag){this.track=aa;this.alpha_filter=null;this.height_filter=null;this.filters=[];this.parent_div=$("<div/>").addClass("filters").hide();this.parent_div.bind("drag",function(ai){ai.stopPropagation()}).click(function(ai){ai.stopPropagation()}).bind("dblclick",function(ai){ai.stopPropagation()}).bind("keydown",function(ai){ai.stopPropagation()});if(ag&&"filters" in ag){var Y=("alpha_filter" in ag?ag.alpha_filter:null),ab=("height_filter" in ag?ag.height_filter:null),ad=ag.filters,Z;for(var ae=0;ae<ad.length;ae++){if(ad[ae].type==="number"){Z=new P(ad[ae]);this.add_filter(Z);if(Z.name===Y){this.alpha_filter=Z;Z.transparency_icon.addClass("active").show()}if(Z.name===ab){this.height_filter=Z;Z.height_icon.addClass("active").show()}}else{console.log("ERROR: unsupported filter: ",name,type)}}if("visible" in ag&&ag.visible){this.parent_div.show()}}if(this.filters.length!==0){var ah=$("<div/>").addClass("param-row").appendTo(this.parent_div);var af=$("<input type='submit'/>").attr("value","Run on complete dataset").appendTo(ah);var ac=this;af.click(function(){ac.run_on_dataset()})}};o(U.prototype,{show:function(){this.parent_div.show()},hide:function(){this.parent_div.hide()},toggle:function(){this.parent_div.toggle()},visible:function(){return this.parent_div.is(":visible")},to_dict:function(){var ab={},aa=[],Z;for(var Y=0;Y<this.filters.length;Y++){Z=this.filters[Y];aa.push(Z.to_dict())}ab.filters=aa;ab.alpha_filter=(this.alpha_filter?this.alpha_filter.name:null);ab.height_filter=(this.height_filter?this.height_filter.name:null);ab.visible=this.parent_div.is(":visible");return ab},copy:function(Z){var aa=new U(Z);for(var Y=0;Y<this.filters.length;Y++){aa.add_filter(this.filters[Y].copy())}return aa},add_filter:function(Y){Y.manager=this;this.parent_div.append(Y.parent_div);this.filters.push(Y)},remove_all:function(){this.filters=[];this.parent_div.children().remove()},init_filters:function(){for(var Y=0;Y<this.filters.length;Y++){var Z=this.filters[Y];Z.update_ui_elt()}},clear_filters:function(){for(var Y=0;Y<this.filters.length;Y++){var Z=this.filters[Y];Z.slider.slider("option","values",[Z.min,Z.max])}this.alpha_filter=null;this.height_filter=null;this.parent_div.find(".icon-button").hide()},run_on_dataset:function(){var ae=function(ai,ag,ah){if(!(ag in ai)){ai[ag]=ah}return ai[ag]};var ad={},af,Y;for(var ac=0;ac<this.filters.length;ac++){af=this.filters[ac];if(af.tool_id){if(af.min!==af.low){Y=ae(ad,af.tool_id,[]);Y[Y.length]=af.tool_exp_name+" >= "+af.low}if(af.max!==af.high){Y=ae(ad,af.tool_id,[]);Y[Y.length]=af.tool_exp_name+" <= "+af.high}}}var Z=[];for(var ab in ad){Z[Z.length]=[ab,ad[ab]]}(function aa(am,aj){var ah=aj[0],ai=ah[0],al=ah[1],ak="("+al.join(") and (")+")",ag={cond:ak,input:am,target_dataset_id:am,tool_id:ai},aj=aj.slice(1);$.getJSON(run_tool_url,ag,function(an){if(an.error){show_modal("Filter Dataset","Error running tool "+ai,{Close:hide_modal})}else{if(aj.length===0){show_modal("Filtering Dataset","Filter(s) are running on the complete dataset. Outputs are in dataset's history.",{Close:hide_modal})}else{aa(an.dataset_id,aj)}}})})(this.track.dataset_id,Z)}});var y=function(Y,Z){H.Scaler.call(this,Z);this.filter=Y};y.prototype.gen_val=function(Y){if(this.filter.high===Number.MAX_VALUE||this.filter.low===-Number.MAX_VALUE||this.filter.low===this.filter.high){return this.default_val}return((parseFloat(Y[this.filter.index])-this.filter.low)/(this.filter.high-this.filter.low))};var B=function(Y){this.track=Y.track;this.params=Y.params;this.values={};this.restore_values((Y.saved_values?Y.saved_values:{}));this.onchange=Y.onchange};o(B.prototype,{restore_values:function(Y){var Z=this;$.each(this.params,function(aa,ab){if(Y[ab.key]!==undefined){Z.values[ab.key]=Y[ab.key]}else{Z.values[ab.key]=ab.default_value}})},build_form:function(){var ab=this;var Y=$("<div />");var aa;function Z(af,ac){for(var aj=0;aj<af.length;aj++){aa=af[aj];if(aa.hidden){continue}var ad="param_"+aj;var an=ab.values[aa.key];var aq=$("<div class='form-row' />").appendTo(ac);aq.append($("<label />").attr("for",ad).text(aa.label+":"));if(aa.type==="bool"){aq.append($('<input type="checkbox" />').attr("id",ad).attr("name",ad).attr("checked",an))}else{if(aa.type==="text"){aq.append($('<input type="text"/>').attr("id",ad).val(an).click(function(){$(this).select()}))}else{if(aa.type==="select"){var al=$("<select />").attr("id",ad);for(var ah=0;ah<aa.options.length;ah++){$("<option/>").text(aa.options[ah].label).attr("value",aa.options[ah].value).appendTo(al)}al.val(an);aq.append(al)}else{if(aa.type==="color"){var ap=$("<div/>").appendTo(aq),ak=$("<input />").attr("id",ad).attr("name",ad).val(an).css("float","left").appendTo(ap).click(function(at){$(".tipsy").hide();var ar=$(this).siblings(".tipsy");ar.css({left:$(this).position().left+$(this).width()+5,top:$(this).position().top-($(ar).height()/2)+($(this).height()/2)}).show();ar.click(function(au){au.stopPropagation()});$(document).bind("click.color-picker",function(){ar.hide();$(document).unbind("click.color-picker")});at.stopPropagation()}),ai=$("<a href='javascript:void(0)'/>").addClass("icon-button arrow-circle").appendTo(ap).attr("title","Set new random color").tipsy({gravity:"s"}),am=$("<div class='tipsy tipsy-west' style='position: absolute;' />").appendTo(ap).hide(),ae=$("<div style='background-color: black; padding: 10px;'></div>").appendTo(am),ao=$("<div/>").appendTo(ae),ag=$.farbtastic(ao,{width:100,height:100,callback:ak,color:an});ap.append($("<div/>").css("clear","both"));(function(ar){ai.click(function(){ar.setColor(get_random_color())})})(ag)}else{aq.append($("<input />").attr("id",ad).attr("name",ad).val(an))}}}}if(aa.help){aq.append($("<div class='help'/>").text(aa.help))}}}Z(this.params,Y);return Y},update_from_form:function(Y){var aa=this;var Z=false;$.each(this.params,function(ab,ad){if(!ad.hidden){var ae="param_"+ab;var ac=Y.find("#"+ae).val();if(ad.type==="float"){ac=parseFloat(ac)}else{if(ad.type==="int"){ac=parseInt(ac)}else{if(ad.type==="bool"){ac=Y.find("#"+ae).is(":checked")}}}if(ac!==aa.values[ad.key]){aa.values[ad.key]=ac;Z=true}}});if(Z){this.onchange();this.track.changed()}}});var b=function(Y,ac,aa,Z,ab){this.track=Y;this.region=ac;this.low=ac.get("start");this.high=ac.get("end");this.resolution=aa;this.html_elt=$("<div class='track-tile'/>").append(Z).height($(Z).attr("height"));this.data=ab;this.stale=false};b.prototype.predisplay_actions=function(){};var j=function(Y,ad,aa,Z,ab,ac){b.call(this,Y,ad,aa,Z,ab);this.max_val=ac};o(j.prototype,b.prototype);var K=function(ab,aj,ac,aa,ae,al,af,am,Z,ai){b.call(this,ab,aj,ac,aa,ae);this.mode=af;this.all_slotted=Z;this.feature_mapper=ai;this.has_icons=false;if(am){this.has_icons=true;var ag=this;aa=this.html_elt.children()[0],message_div=$("<div/>").addClass("tile-message").css({height:z-1,width:aa.width}).prependTo(this.html_elt);var ah=new GenomeRegion({chrom:ab.view.chrom,start:this.low,end:this.high}),ak=ae.length,ad=$("<a href='javascript:void(0);'/>").addClass("icon more-down").attr("title","For speed, only the first "+ak+" features in this region were obtained from server. Click to get more data including depth").tipsy({gravity:"s"}).appendTo(message_div),Y=$("<a href='javascript:void(0);'/>").addClass("icon more-across").attr("title","For speed, only the first "+ak+" features in this region were obtained from server. Click to get more data excluding depth").tipsy({gravity:"s"}).appendTo(message_div);ad.click(function(){ag.stale=true;ab.data_manager.get_more_data(ah,ab.mode,ag.resolution,{},ab.data_manager.DEEP_DATA_REQ);$(".tipsy").hide();ab.request_draw(true)}).dblclick(function(an){an.stopPropagation()});Y.click(function(){ag.stale=true;ab.data_manager.get_more_data(ah,ab.mode,ag.resolution,{},ab.data_manager.BROAD_DATA_REQ);$(".tipsy").hide();ab.request_draw(true)}).dblclick(function(an){an.stopPropagation()})}};o(K.prototype,b.prototype);K.prototype.predisplay_actions=function(){var Z=this,Y={};if(Z.mode!=="Pack"){return}$(this.html_elt).hover(function(){this.hovered=true;$(this).mousemove()},function(){this.hovered=false;$(this).parents(".track-content").children(".overlay").children(".feature-popup").remove()}).mousemove(function(ak){if(!this.hovered){return}var af=$(this).offset(),aj=ak.pageX-af.left,ai=ak.pageY-af.top,ao=Z.feature_mapper.get_feature_data(aj,ai),ag=(ao?ao[0]:null);$(this).parents(".track-content").children(".overlay").children(".feature-popup").each(function(){if(!ag||$(this).attr("id")!==ag.toString()){$(this).remove()}});if(ao){var ab=Y[ag];if(!ab){var ag=ao[0],al={name:ao[3],start:ao[1],end:ao[2],strand:ao[4]},ae=Z.track.filters_manager.filters,ad;for(var ah=0;ah<ae.length;ah++){ad=ae[ah];al[ad.name]=ao[ad.index]}var ab=$("<div/>").attr("id",ag).addClass("feature-popup"),ap=$("<table/>"),an,am,aq;for(an in al){am=al[an];aq=$("<tr/>").appendTo(ap);$("<th/>").appendTo(aq).text(an);$("<td/>").attr("align","left").appendTo(aq).text(typeof(am)==="number"?T(am,2):am)}ab.append($("<div class='feature-popup-inner'>").append(ap));Y[ag]=ab}ab.appendTo($(this).parents(".track-content").children(".overlay"));var ac=aj+parseInt(Z.html_elt.css("left"))-ab.width()/2,aa=ai+parseInt(Z.html_elt.css("top"))+7;ab.css("left",ac+"px").css("top",aa+"px")}else{if(!ak.isPropagationStopped()){ak.stopPropagation();$(this).siblings().each(function(){$(this).trigger(ak)})}}}).mouseleave(function(){$(this).parents(".track-content").children(".overlay").children(".feature-popup").remove()})};var h=function(aa,Z,ac){o(ac,{drag_handle_class:"draghandle"});p.call(this,aa,Z,ac);this.data_url=("data_url" in ac?ac.data_url:default_data_url);this.data_url_extra_params={};this.data_query_wait=("data_query_wait" in ac?ac.data_query_wait:G);this.dataset_check_url=("converted_datasets_state_url" in ac?ac.converted_datasets_state_url:converted_datasets_state_url);var Y=this,ab=new Dataset({id:ac.dataset_id,hda_ldda:ac.hda_ldda});this.data_manager=("data_manager" in ac?ac.data_manager:new GenomeDataManager({dataset:ab,data_url:Y.data_url,dataset_state_url:Y.dataset_check_url,data_mode_compatible:this.data_and_mode_compatible,can_subset:this.can_subset}));this.min_height_px=16;this.max_height_px=800;this.visible_height_px=0;this.content_div=$("<div class='track-content'>").appendTo(this.container_div);if(this.container){this.container.content_div.append(this.container_div);if(!("resize" in ac)||ac.resize){this.add_resize_handle()}}};o(h.prototype,p.prototype,{action_icons_def:[{name:"mode_icon",title:"Set display mode",css_class:"chevron-expand",on_click_fn:function(){}},p.prototype.action_icons_def[0],{name:"overview_icon",title:"Set as overview",css_class:"overview-icon",on_click_fn:function(Y){Y.view.set_overview(Y)}},p.prototype.action_icons_def[1],{name:"filters_icon",title:"Filters",css_class:"filters-icon",on_click_fn:function(Y){if(Y.filters_manager.visible()){Y.filters_manager.clear_filters()}else{Y.filters_manager.init_filters()}Y.filters_manager.toggle()}},{name:"tools_icon",title:"Tool",css_class:"hammer",on_click_fn:function(Y){Y.dynamic_tool_div.toggle();if(Y.dynamic_tool_div.is(":visible")){Y.set_name(Y.name+Y.tool_region_and_parameters_str())}else{Y.revert_name()}$(".tipsy").remove()}},{name:"param_space_viz_icon",title:"Tool parameter space visualization",css_class:"arrow-split",on_click_fn:function(Y){var ab='<strong>Tool</strong>: <%= track.tool.name %><br/><strong>Dataset</strong>: <%= track.name %><br/><strong>Region(s)</strong>: <select name="regions"><option value="cur">current viewing area</option><option value="bookmarks">bookmarks</option><option value="both">current viewing area and bookmarks</option></select>',aa=_.template(ab,{track:Y});var ad=function(){hide_modal();$(window).unbind("keypress.check_enter_esc")},Z=function(){var af=$('select[name="regions"] option:selected').val(),ah,ae=new GenomeRegion({chrom:view.chrom,start:view.low,end:view.high}),ag=_.map($(".bookmark"),function(ai){return new GenomeRegion({from_str:$(ai).children(".position").text()})});if(af==="cur"){ah=[ae]}else{if(af==="bookmarks"){ah=ag}else{ah=[ae].concat(ag)}}hide_modal();window.location.href=galaxy_paths.get("paramamonster_url")+"?"+$.param({dataset_id:Y.dataset_id,hda_ldda:Y.hda_ldda,regions:JSON.stringify(new Backbone.Collection(ah).toJSON())})},ac=function(ae){if((ae.keyCode||ae.which)===27){ad()}else{if((ae.keyCode||ae.which)===13){Z()}}};show_modal("Visualize tool parameter space and output from different parameter settings?",aa,{No:ad,Yes:Z})}},p.prototype.action_icons_def[2]],can_draw:function(){if(this.dataset_id&&p.prototype.can_draw.call(this)){return true}return false},build_container_div:function(){return $("<div/>").addClass("track").attr("id","track_"+this.id).css("position","relative")},build_header_div:function(){var Y=$("<div class='track-header'/>");if(this.view.editor){this.drag_div=$("<div/>").addClass(this.drag_handle_class).appendTo(Y)}this.name_div=$("<div/>").addClass("track-name").appendTo(Y).text(this.name).attr("id",this.name.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9\-]/g,"").toLowerCase());return Y},on_resize:function(){},add_resize_handle:function(){var Y=this;var ab=false;var aa=false;var Z=$("<div class='track-resize'>");$(Y.container_div).hover(function(){if(Y.content_visible){ab=true;Z.show()}},function(){ab=false;if(!aa){Z.hide()}});Z.hide().bind("dragstart",function(ac,ad){aa=true;ad.original_height=$(Y.content_div).height()}).bind("drag",function(ad,ae){var ac=Math.min(Math.max(ae.original_height+ae.deltaY,Y.min_height_px),Y.max_height_px);$(Y.tiles_div).css("height",ac);Y.visible_height_px=(Y.max_height_px===ac?0:ac);Y.on_resize()}).bind("dragend",function(ac,ad){Y.tile_cache.clear();aa=false;if(!ab){Z.hide()}Y.config.values.height=Y.visible_height_px;Y.changed()}).appendTo(Y.container_div)},set_display_modes:function(ab,ae){this.display_modes=ab;this.mode=(ae?ae:(this.config&&this.config.values.mode?this.config.values.mode:this.display_modes[0]));this.action_icons.mode_icon.attr("title","Set display mode (now: "+this.mode+")");var Z=this,ac={};for(var aa=0,Y=Z.display_modes.length;aa<Y;aa++){var ad=Z.display_modes[aa];ac[ad]=function(af){return function(){Z.change_mode(af);Z.icons_div.show();Z.container_div.mouseleave(function(){Z.icons_div.hide()})}}(ad)}make_popupmenu(this.action_icons.mode_icon,ac)},build_action_icons:function(){p.prototype.build_action_icons.call(this,this.action_icons_def);if(this.display_modes!==undefined){this.set_display_modes(this.display_modes)}},hide_contents:function(){this.tiles_div.hide();this.container_div.find(".yaxislabel, .track-resize").hide()},show_contents:function(){this.tiles_div.show();this.container_div.find(".yaxislabel, .track-resize").show();this.request_draw()},get_type:function(){if(this instanceof V){return"LabelTrack"}else{if(this instanceof x){return"ReferenceTrack"}else{if(this instanceof i){return"LineTrack"}else{if(this instanceof Q){return"ReadTrack"}else{if(this instanceof N){return"VcfTrack"}else{if(this instanceof g){return"CompositeTrack"}else{if(this instanceof c){return"FeatureTrack"}}}}}}}return""},init:function(){var Z=this;Z.enabled=false;Z.tile_cache.clear();Z.data_manager.clear();Z.content_div.css("height","auto");Z.tiles_div.children().remove();Z.container_div.removeClass("nodata error pending");if(!Z.dataset_id){return}var Y=$.Deferred();$.getJSON(this.dataset_check_url,{hda_ldda:Z.hda_ldda,dataset_id:Z.dataset_id,chrom:Z.view.chrom},function(aa){if(!aa||aa==="error"||aa.kind==="error"){Z.container_div.addClass("error");Z.tiles_div.text(n);if(aa.message){var ab=$(" <a href='javascript:void(0);'></a>").text("View error").click(function(){show_modal("Trackster Error","<pre>"+aa.message+"</pre>",{Close:hide_modal})});Z.tiles_div.append(ab)}}else{if(aa==="no converter"){Z.container_div.addClass("error");Z.tiles_div.text(F)}else{if(aa==="no data"||(aa.data!==undefined&&(aa.data===null||aa.data.length===0))){Z.container_div.addClass("nodata");Z.tiles_div.text(A)}else{if(aa==="pending"){Z.container_div.addClass("pending");Z.tiles_div.html(s);setTimeout(function(){Z.init()},Z.data_query_wait)}else{if(aa==="data"||aa.status==="data"){if(aa.valid_chroms){Z.valid_chroms=aa.valid_chroms;Z.update_icons()}Z.tiles_div.text(S);if(Z.view.chrom){Z.tiles_div.text("");Z.tiles_div.css("height",Z.visible_height_px+"px");Z.enabled=true;$.when(Z.predraw_init()).done(function(){Y.resolve();Z.container_div.removeClass("nodata error pending");Z.request_draw()})}else{Y.resolve()}}}}}}});this.update_icons();return Y},predraw_init:function(){}});var I=function(aa,Z,ab){h.call(this,aa,Z,ab);var Y=this,aa=Y.view;l(Y.container_div,Y.drag_handle_class,".group",Y);this.filters_manager=new U(this,("filters" in ab?ab.filters:null));this.data_manager.set("filters_manager",this.filters_manager);this.filters_available=false;this.tool=("tool" in ab&&ab.tool?new q(this,ab.tool,ab.tool_state):null);this.tile_cache=new Cache(M);if(this.header_div){this.set_filters_manager(this.filters_manager);if(this.tool){this.dynamic_tool_div=this.tool.parent_div;this.header_div.after(this.dynamic_tool_div)}}this.tiles_div=$("<div/>").addClass("tiles").appendTo(this.content_div);this.overlay_div=$("<div/>").addClass("overlay").appendTo(this.content_div);if(ab.mode){this.change_mode(ab.mode)}};o(I.prototype,p.prototype,h.prototype,{action_icons_def:h.prototype.action_icons_def.concat([{name:"show_more_rows_icon",title:"To minimize track height, not all feature rows are displayed. Click to display more rows.",css_class:"exclamation",on_click_fn:function(Y){$(".tipsy").remove();Y.slotters[Y.view.resolution_px_b].max_rows*=2;Y.request_draw(true)},hide:true}]),copy:function(Y){var Z=this.to_dict();o(Z,{data_manager:this.data_manager});var aa=new this.constructor(this.view,Y,Z);aa.change_mode(this.mode);aa.enabled=this.enabled;return aa},set_filters_manager:function(Y){this.filters_manager=Y;this.header_div.after(this.filters_manager.parent_div)},to_dict:function(){return{track_type:this.get_type(),name:this.name,hda_ldda:this.hda_ldda,dataset_id:this.dataset_id,prefs:this.prefs,mode:this.mode,filters:this.filters_manager.to_dict(),tool_state:(this.tool?this.tool.state_dict():{})}},change_mode:function(Z){var Y=this;Y.mode=Z;Y.config.values.mode=Z;Y.tile_cache.clear();Y.request_draw();this.action_icons.mode_icon.attr("title","Set display mode (now: "+Y.mode+")");return Y},update_icons:function(){var Y=this;if(Y.filters_available){Y.action_icons.filters_icon.show()}else{Y.action_icons.filters_icon.hide()}if(Y.tool){Y.action_icons.tools_icon.show();Y.action_icons.param_space_viz_icon.show()}else{Y.action_icons.tools_icon.hide();Y.action_icons.param_space_viz_icon.hide()}},_gen_tile_cache_key:function(Z,aa,Y){return Z+"_"+aa+"_"+Y},request_draw:function(Z,Y){this.view.request_redraw(false,Z,Y,this)},before_draw:function(){},_draw:function(Z,aj){if(!this.can_draw()){return}var ah=this.view.low,ad=this.view.high,af=ad-ah,aa=this.view.container.width(),al=this.view.resolution_px_b,ac=this.view.resolution_b_px;if(this.is_overview){ah=this.view.max_low;ad=this.view.max_high;ac=Math.pow(RESOLUTION,Math.ceil(Math.log((view.max_high-view.max_low)/O)/Math.log(RESOLUTION)));al=aa/(view.max_high-view.max_low)}this.before_draw();this.tiles_div.children().addClass("remove");var Y=Math.floor(ah/(ac*O)),ag=true,ak=[],ae=function(am){return(am&&"track" in am)};while((Y*O*ac)<ad){var ai=this.draw_helper(Z,aa,Y,ac,this.tiles_div,al);if(ae(ai)){ak.push(ai)}else{ag=false}Y+=1}if(!aj){this.tiles_div.children(".remove").removeClass("remove").remove()}var ab=this;if(ag){this.tiles_div.children(".remove").remove();ab.postdraw_actions(ak,aa,al,aj)}},postdraw_actions:function(ab,ac,ae,Y){var aa=this;var ad=false;for(var Z=0;Z<ab.length;Z++){if(ab[Z].has_icons){ad=true;break}}if(ad){for(var Z=0;Z<ab.length;Z++){tile=ab[Z];if(!tile.has_icons){tile.html_elt.css("padding-top",z)}}}},draw_helper:function(Y,ak,ap,an,ad,ae,al){var aj=this,at=this._gen_tile_cache_key(ak,ae,ap),ab=this._get_tile_bounds(ap,an);if(!al){al={}}var ar=(Y?undefined:aj.tile_cache.get_elt(at));if(ar){aj.show_tile(ar,ad,ae);return ar}var ah=true;var ao=aj.data_manager.get_data(ab,aj.mode,an,aj.data_url_extra_params);if(is_deferred(ao)){ah=false}var af;if(view.reference_track&&ae>view.canvas_manager.char_width_px){af=view.reference_track.data_manager.get_data(ab,aj.mode,an,view.reference_track.data_url_extra_params);if(is_deferred(af)){ah=false}}if(ah){o(ao,al.more_tile_data);var ag=aj.mode;if(ag==="Auto"){ag=aj.get_mode(ao);aj.update_auto_mode(ag)}var aa=aj.view.canvas_manager.new_canvas(),aq=ab.get("start"),Z=ab.get("end"),ak=Math.ceil((Z-aq)*ae)+aj.left_offset,ai=aj.get_canvas_height(ao,ag,ae,ak);aa.width=ak;aa.height=ai;var am=aa.getContext("2d");am.translate(this.left_offset,0);var ar=aj.draw_tile(ao,am,ag,an,ab,ae,af);if(ar!==undefined){aj.tile_cache.set_elt(at,ar);aj.show_tile(ar,ad,ae)}return ar}var ac=$.Deferred();$.when(ao,af).then(function(){view.request_redraw(false,false,false,aj);ac.resolve()});return ac},get_canvas_height:function(Y,aa,ab,Z){return this.visible_height_px},draw_tile:function(Y,Z,ad,ab,ac,ae,aa){console.log("Warning: TiledTrack.draw_tile() not implemented.")},show_tile:function(aa,ac,ad){var Z=this,Y=aa.html_elt;aa.predisplay_actions();var ab=(aa.low-(this.is_overview?this.view.max_low:this.view.low))*ad;if(this.left_offset){ab-=this.left_offset}Y.css({position:"absolute",top:0,left:ab});if(Y.hasClass("remove")){Y.removeClass("remove")}else{ac.append(Y)}Z.after_show_tile(aa)},after_show_tile:function(Y){this.max_height_px=Math.max(this.max_height_px,Y.html_elt.height());Y.html_elt.parent().children().css("height",this.max_height_px+"px");var Z=this.max_height_px;if(this.visible_height_px!==0){Z=Math.min(this.max_height_px,this.visible_height_px)}this.tiles_div.css("height",Z+"px")},_get_tile_bounds:function(Y,Z){var ab=Math.floor(Y*O*Z),ac=Math.ceil(O*Z),aa=(ab+ac<=this.view.max_high?ab+ac:this.view.max_high);return new GenomeRegion({chrom:this.view.chrom,start:ab,end:aa})},tool_region_and_parameters_str:function(aa,Y,ab){var Z=this,ac=(aa!==undefined&&Y!==undefined&&ab!==undefined?aa+":"+Y+"-"+ab:"all");return" - region=["+ac+"], parameters=["+Z.tool.get_param_values().join(", ")+"]"},data_and_mode_compatible:function(Y,Z){return true},can_subset:function(Y){return false},init_for_tool_data:function(){this.data_manager.set("data_url",raw_data_url);this.data_query_wait=1000;this.dataset_check_url=dataset_state_url;this.normal_postdraw_actions=this.postdraw_actions;this.postdraw_actions=function(aa,ab,ad,Y){var Z=this;Z.normal_postdraw_actions(aa,ab,ad,Y);Z.dataset_state_url=converted_datasets_state_url;Z.data_query_wait=G;var ac=new ServerStateDeferred({url:Z.dataset_state_url,url_params:{dataset_id:Z.dataset_id,hda_ldda:Z.hda_ldda},interval:Z.data_query_wait,success_fn:function(ae){return ae!=="pending"}});$.when(ac.go()).then(function(){Z.data_manager.set("data_url",default_data_url)});Z.postdraw_actions=Z.normal_postdraw_actions}}});var V=function(Z,Y){var aa={resize:false};h.call(this,Z,Y,aa);this.container_div.addClass("label-track")};o(V.prototype,h.prototype,{build_header_div:function(){},init:function(){this.enabled=true},_draw:function(){var aa=this.view,ab=aa.high-aa.low,ae=Math.floor(Math.pow(10,Math.floor(Math.log(ab)/Math.log(10)))),Y=Math.floor(aa.low/ae)*ae,ac=this.view.container.width(),Z=$("<div style='position: relative; height: 1.3em;'></div>");while(Y<aa.high){var ad=(Y-aa.low)/ab*ac;Z.append($("<div class='label'>"+commatize(Y)+"</div>").css({position:"absolute",left:ad-1}));Y+=ae}this.content_div.children(":first").remove();this.content_div.append(Z)}});var g=function(Z,Y,ac){I.call(this,Z,Y,ac);this.drawables=[];this.left_offset=0;if("drawables" in ac){var ab;for(var aa=0;aa<ac.drawables.length;aa++){ab=ac.drawables[aa];this.drawables[aa]=object_from_template(ab,Z,null);if(ab.left_offset>this.left_offset){this.left_offset=ab.left_offset}}this.enabled=true}if(this.drawables.length!==0){this.set_display_modes(this.drawables[0].display_modes,this.drawables[0].mode)}this.update_icons();this.obj_type="CompositeTrack"};o(g.prototype,I.prototype,{action_icons_def:[{name:"composite_icon",title:"Show individual tracks",css_class:"layers-stack",on_click_fn:function(Y){$(".tipsy").remove();Y.show_group()}}].concat(I.prototype.action_icons_def),to_dict:v.prototype.to_dict,add_drawable:v.prototype.add_drawable,unpack_drawables:v.prototype.unpack_drawables,change_mode:function(Y){I.prototype.change_mode.call(this,Y);for(var Z=0;Z<this.drawables.length;Z++){this.drawables[Z].change_mode(Y)}},init:function(){var aa=[];for(var Z=0;Z<this.drawables.length;Z++){aa.push(this.drawables[Z].init())}var Y=this;$.when.apply($,aa).then(function(){Y.enabled=true;Y.request_draw()})},update_icons:function(){this.action_icons.filters_icon.hide();this.action_icons.tools_icon.hide();this.action_icons.param_space_viz_icon.hide()},can_draw:p.prototype.can_draw,draw_helper:function(Z,ao,av,ar,ag,ai,ap){var an=this,az=this._gen_tile_cache_key(ao,ai,av),ad=this._get_tile_bounds(av,ar);if(!ap){ap={}}var ay=(Z?undefined:an.tile_cache.get_elt(az));if(ay){an.show_tile(ay,ag,ai);return ay}var ah=[],an,al=true,at,aj;for(var au=0;au<this.drawables.length;au++){an=this.drawables[au];at=an.data_manager.get_data(ad,an.mode,ar,an.data_url_extra_params);if(is_deferred(at)){al=false}ah.push(at);aj=null;if(view.reference_track&&ai>view.canvas_manager.char_width_px){aj=view.reference_track.data_manager.get_data(ad,an.mode,ar,view.reference_track.data_url_extra_params);if(is_deferred(aj)){al=false}}ah.push(aj)}if(al){o(at,ap.more_tile_data);this.tile_predraw_init();var ac=an.view.canvas_manager.new_canvas(),ae=an._get_tile_bounds(av,ar),aw=ad.get("start"),aa=ad.get("end"),ax=0,ao=Math.ceil((aa-aw)*ai)+this.left_offset,am=0,ab=[];var Y=0;for(var au=0;au<this.drawables.length;au++,ax+=2){an=this.drawables[au];at=ah[ax];var ak=an.mode;if(ak==="Auto"){ak=an.get_mode(at);an.update_auto_mode(ak)}ab.push(ak);Y=an.get_canvas_height(at,ak,ai,ao);if(Y>am){am=Y}}ac.width=ao;ac.height=(ap.height?ap.height:am);ax=0;var aq=ac.getContext("2d");aq.translate(this.left_offset,0);aq.globalAlpha=0.5;aq.globalCompositeOperation="source-over";for(var au=0;au<this.drawables.length;au++,ax+=2){an=this.drawables[au];at=ah[ax];aj=ah[ax+1];ay=an.draw_tile(at,aq,ab[au],ar,ad,ai,aj)}this.tile_cache.set_elt(az,ay);this.show_tile(ay,ag,ai);return ay}var af=$.Deferred(),an=this;$.when.apply($,ah).then(function(){view.request_redraw(false,false,false,an);af.resolve()});return af},show_group:function(){var ab=new L(this.view,this.container,{name:this.name}),Y;for(var aa=0;aa<this.drawables.length;aa++){Y=this.drawables[aa];ab.add_drawable(Y);Y.container=ab;ab.content_div.append(Y.container_div)}var Z=this.container.replace_drawable(this,ab,true);ab.request_draw()},tile_predraw_init:function(){var ab=Number.MAX_VALUE,Y=-ab,Z;for(var aa=0;aa<this.drawables.length;aa++){Z=this.drawables[aa];if(Z instanceof i){if(Z.prefs.min_value<ab){ab=Z.prefs.min_value}if(Z.prefs.max_value>Y){Y=Z.prefs.max_value}}}for(var aa=0;aa<this.drawables.length;aa++){Z=this.drawables[aa];Z.prefs.min_value=ab;Z.prefs.max_value=Y}},postdraw_actions:function(aa,ad,af,Z){I.prototype.postdraw_actions.call(this,aa,ad,af,Z);var ac=-1;for(var ab=0;ab<aa.length;ab++){var Y=aa[ab].html_elt.find("canvas").height();if(Y>ac){ac=Y}}for(var ab=0;ab<aa.length;ab++){var ae=aa[ab];if(ae.html_elt.find("canvas").height()!==ac){this.draw_helper(true,ad,ae.index,ae.resolution,ae.html_elt.parent(),af,{height:ac});ae.html_elt.remove()}}}});var x=function(Y){I.call(this,Y,{content_div:Y.top_labeltrack},{resize:false});Y.reference_track=this;this.left_offset=200;this.visible_height_px=12;this.container_div.addClass("reference-track");this.content_div.css("background","none");this.content_div.css("min-height","0px");this.content_div.css("border","none");this.data_url=reference_url;this.data_url_extra_params={dbkey:Y.dbkey};this.data_manager=new ReferenceTrackDataManager({data_url:reference_url});this.hide_contents()};o(x.prototype,p.prototype,I.prototype,{build_header_div:function(){},init:function(){this.data_manager.clear();this.enabled=true},can_draw:p.prototype.can_draw,draw_helper:function(ac,aa,Y,Z,ad,ae,ab){if(ae>this.view.canvas_manager.char_width_px){return I.prototype.draw_helper.call(this,ac,aa,Y,Z,ad,ae,ab)}else{this.hide_contents();return null}},draw_tile:function(ag,ah,ac,ab,ae,ai){var aa=this;if(ai>this.view.canvas_manager.char_width_px){if(ag.data===null){this.hide_contents();return}var Z=ah.canvas;ah.font=ah.canvas.manager.default_font;ah.textAlign="center";ag=ag.data;for(var ad=0,af=ag.length;ad<af;ad++){var Y=Math.floor(ad*ai);ah.fillText(ag[ad],Y,10)}this.show_contents();return new b(aa,ae,ab,Z,ag)}this.hide_contents()}});var i=function(aa,Z,ab){var Y=this;this.display_modes=["Histogram","Line","Filled","Intensity"];this.mode="Histogram";I.call(this,aa,Z,ab);this.hda_ldda=ab.hda_ldda;this.dataset_id=ab.dataset_id;this.original_dataset_id=this.dataset_id;this.left_offset=0;this.config=new B({track:this,params:[{key:"name",label:"Name",type:"text",default_value:this.name},{key:"color",label:"Color",type:"color",default_value:get_random_color()},{key:"min_value",label:"Min Value",type:"float",default_value:undefined},{key:"max_value",label:"Max Value",type:"float",default_value:undefined},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"height",type:"int",default_value:32,hidden:true}],saved_values:ab.prefs,onchange:function(){Y.set_name(Y.prefs.name);Y.vertical_range=Y.prefs.max_value-Y.prefs.min_value;Y.set_min_value(Y.prefs.min_value);Y.set_max_value(Y.prefs.max_value)}});this.prefs=this.config.values;this.visible_height_px=this.config.values.height;this.vertical_range=this.config.values.max_value-this.config.values.min_value};o(i.prototype,p.prototype,I.prototype,{on_resize:function(){this.request_draw(true)},set_min_value:function(Y){this.prefs.min_value=Y;$("#linetrack_"+this.dataset_id+"_minval").text(this.prefs.min_value);this.tile_cache.clear();this.request_draw()},set_max_value:function(Y){this.prefs.max_value=Y;$("#linetrack_"+this.dataset_id+"_maxval").text(this.prefs.max_value);this.tile_cache.clear();this.request_draw()},predraw_init:function(){var Y=this;Y.vertical_range=undefined;return $.getJSON(Y.data_url,{stats:true,chrom:Y.view.chrom,low:null,high:null,hda_ldda:Y.hda_ldda,dataset_id:Y.dataset_id},function(Z){Y.container_div.addClass("line-track");var ac=Z.data;if(isNaN(parseFloat(Y.prefs.min_value))||isNaN(parseFloat(Y.prefs.max_value))){var aa=ac.min,ae=ac.max;aa=Math.floor(Math.min(0,Math.max(aa,ac.mean-2*ac.sd)));ae=Math.ceil(Math.max(0,Math.min(ae,ac.mean+2*ac.sd)));Y.prefs.min_value=aa;Y.prefs.max_value=ae;$("#track_"+Y.dataset_id+"_minval").val(Y.prefs.min_value);$("#track_"+Y.dataset_id+"_maxval").val(Y.prefs.max_value)}Y.vertical_range=Y.prefs.max_value-Y.prefs.min_value;Y.total_frequency=ac.total_frequency;Y.container_div.find(".yaxislabel").remove();var ad=$("<div/>").text(T(Y.prefs.min_value,3)).make_text_editable({num_cols:6,on_finish:function(af){$(".tipsy").remove();var af=parseFloat(af);if(!isNaN(af)){Y.set_min_value(af)}},help_text:"Set min value"}).addClass("yaxislabel bottom").attr("id","linetrack_"+Y.dataset_id+"_minval").prependTo(Y.container_div),ab=$("<div/>").text(T(Y.prefs.max_value,3)).make_text_editable({num_cols:6,on_finish:function(af){$(".tipsy").remove();var af=parseFloat(af);if(!isNaN(af)){Y.set_max_value(af)}},help_text:"Set max value"}).addClass("yaxislabel top").attr("id","linetrack_"+Y.dataset_id+"_maxval").prependTo(Y.container_div)})},draw_tile:function(ah,af,aa,Z,ac,ag){var Y=af.canvas,ab=ac.get("start"),ae=ac.get("end"),ad=new H.LinePainter(ah.data,ab,ae,this.prefs,aa);ad.draw(af,Y.width,Y.height,ag);return new b(this,ac,Z,Y,ah.data)},can_subset:function(Y){return false}});var c=function(ab,aa,ad){var Z=this;this.display_modes=["Auto","Histogram","Dense","Squish","Pack"];I.call(this,ab,aa,ad);var ac=get_random_color(),Y=get_random_color([ac,"#ffffff"]);this.config=new B({track:this,params:[{key:"name",label:"Name",type:"text",default_value:this.name},{key:"block_color",label:"Block color",type:"color",default_value:ac},{key:"reverse_strand_color",label:"Antisense strand color",type:"color",default_value:Y},{key:"label_color",label:"Label color",type:"color",default_value:"black"},{key:"show_counts",label:"Show summary counts",type:"bool",default_value:true,help:"Show the number of items in each bin when drawing summary histogram"},{key:"histogram_max",label:"Histogram maximum",type:"float",default_value:null,help:"clear value to set automatically"},{key:"connector_style",label:"Connector style",type:"select",default_value:"fishbones",options:[{label:"Line with arrows",value:"fishbone"},{label:"Arcs",value:"arcs"}]},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"height",type:"int",default_value:this.visible_height_px,hidden:true}],saved_values:ad.prefs,onchange:function(){Z.set_name(Z.prefs.name);Z.tile_cache.clear();Z.set_painter_from_config();Z.request_draw()}});this.prefs=this.config.values;this.visible_height_px=this.config.values.height;this.container_div.addClass("feature-track");this.hda_ldda=ad.hda_ldda;this.dataset_id=ad.dataset_id;this.original_dataset_id=ad.dataset_id;this.show_labels_scale=0.001;this.showing_details=false;this.summary_draw_height=30;this.slotters={};this.start_end_dct={};this.left_offset=200;this.set_painter_from_config()};o(c.prototype,p.prototype,I.prototype,{set_dataset:function(Y){this.dataset_id=Y.get("id");this.hda_ldda=Y.get("hda_ldda");this.data_manager.set("dataset",Y)},set_painter_from_config:function(){if(this.config.values.connector_style==="arcs"){this.painter=H.ArcLinkedFeaturePainter}else{this.painter=H.LinkedFeaturePainter}},before_draw:function(){this.max_height_px=0},postdraw_actions:function(an,ai,ad,ac){I.prototype.postdraw_actions.call(this,an,ac);var ah=this;if(ah.mode==="Histogram"){var ak,Z=-1;for(ak=0;ak<an.length;ak++){var aj=an[ak].max_val;if(aj>Z){Z=aj}}for(ak=0;ak<an.length;ak++){var ap=an[ak];if(ap.max_val!==Z){ap.html_elt.remove();ah.draw_helper(true,ai,ap.index,ap.resolution,ap.html_elt.parent(),ad,{more_tile_data:{max:Z}})}}}if(ah.filters_manager){var ae=ah.filters_manager.filters;for(var am=0;am<ae.length;am++){ae[am].update_ui_elt()}var ao=false,Y,af;for(var ak=0;ak<an.length;ak++){if(an[ak].data.length){Y=an[ak].data[0];for(var am=0;am<ae.length;am++){af=ae[am];if(af.applies_to(Y)&&af.min!==af.max){ao=true;break}}}}if(ah.filters_available!==ao){ah.filters_available=ao;if(!ah.filters_available){ah.filters_manager.hide()}ah.update_icons()}}this.container_div.find(".yaxislabel").remove();var ab=an[0];if(ab instanceof j){var ag=(this.prefs.histogram_max?this.prefs.histogram_max:ab.max_val),aa=$("<div/>").text(ag).make_text_editable({num_cols:12,on_finish:function(aq){$(".tipsy").remove();var aq=parseFloat(aq);ah.prefs.histogram_max=(!isNaN(aq)?aq:null);ah.tile_cache.clear();ah.request_draw()},help_text:"Set max value; leave blank to use default"}).addClass("yaxislabel top").css("color",this.prefs.label_color);this.container_div.prepend(aa)}if(ab instanceof K){var al=true;for(var ak=0;ak<an.length;ak++){if(!an[ak].all_slotted){al=false;break}}if(!al){this.action_icons.show_more_rows_icon.show()}else{this.action_icons.show_more_rows_icon.hide()}}else{this.action_icons.show_more_rows_icon.hide()}},update_auto_mode:function(Y){var Y;if(this.mode==="Auto"){if(Y==="no_detail"){Y="feature spans"}else{if(Y==="summary_tree"){Y="coverage histogram"}}this.action_icons.mode_icon.attr("title","Set display mode (now: Auto/"+Y+")")}},incremental_slots:function(ac,Y,ab){var Z=this.view.canvas_manager.dummy_context,aa=this.slotters[ac];if(!aa||(aa.mode!==ab)){aa=new (r.FeatureSlotter)(ac,ab,w,function(ad){return Z.measureText(ad)});this.slotters[ac]=aa}return aa.slot_features(Y)},get_summary_tree_data:function(ac,af,aa,an){if(an>aa-af){an=aa-af}var aj=Math.floor((aa-af)/an),am=[],ab=0;var ad=0,ae=0,ai,al=0,ag=[],ak,ah;var Z=function(aq,ap,ar,ao){aq[0]=ap+ar*ao;aq[1]=ap+(ar+1)*ao};while(al<an&&ad!==ac.length){var Y=false;for(;al<an&&!Y;al++){Z(ag,af,al,aj);for(ae=ad;ae<ac.length;ae++){ai=ac[ae].slice(1,3);if(is_overlap(ai,ag)){Y=true;break}}if(Y){break}}data_start_index=ae;am[am.length]=ak=[ag[0],0];for(;ae<ac.length;ae++){ai=ac[ae].slice(1,3);if(is_overlap(ai,ag)){ak[1]++}else{break}}if(ak[1]>ab){ab=ak[1]}al++}return{max:ab,delta:aj,data:am}},get_mode:function(Y){if(Y.dataset_type==="summary_tree"){mode="summary_tree"}else{if(Y.extra_info==="no_detail"||this.is_overview){mode="no_detail"}else{if(this.view.high-this.view.low>E){mode="Squish"}else{mode="Pack"}}}return mode},get_canvas_height:function(Y,ac,ad,Z){if(ac==="summary_tree"||ac==="Histogram"){return this.summary_draw_height}else{var ab=this.incremental_slots(ad,Y.data,ac);var aa=new (this.painter)(null,null,null,this.prefs,ac);return Math.max(X,aa.get_required_height(ab,Z))}},draw_tile:function(aj,an,al,ao,ab,af,aa){var am=this,Z=an.canvas,av=ab.get("start"),Y=ab.get("end"),aA=25,ac=this.left_offset;if(al==="summary_tree"||al==="Histogram"){if(aj.dataset_type!=="summary_tree"){var ag=this.get_summary_tree_data(aj.data,av,Y,200);if(aj.max){ag.max=aj.max}aj=ag}var ax=new H.SummaryTreePainter(aj,av,Y,this.prefs);ax.draw(an,Z.width,Z.height,af);return new j(am,ab,ao,Z,aj.data,aj.max)}var ae=[],ak=this.slotters[af].slots;all_slotted=true;if(aj.data){var ah=this.filters_manager.filters;for(var ap=0,ar=aj.data.length;ap<ar;ap++){var ad=aj.data[ap];var aq=false;var ai;for(var au=0,az=ah.length;au<az;au++){ai=ah[au];ai.update_attrs(ad);if(!ai.keep(ad)){aq=true;break}}if(!aq){ae.push(ad);if(!(ad[0] in ak)){all_slotted=false}}}}var ay=(this.filters_manager.alpha_filter?new y(this.filters_manager.alpha_filter):null);var aw=(this.filters_manager.height_filter?new y(this.filters_manager.height_filter):null);var ax=new (this.painter)(ae,av,Y,this.prefs,al,ay,aw,aa);var at=null;an.fillStyle=this.prefs.block_color;an.font=an.canvas.manager.default_font;an.textAlign="right";if(aj.data){at=ax.draw(an,Z.width,Z.height,af,ak);at.translation=-ac}return new K(am,ab,ao,Z,aj.data,af,al,aj.message,all_slotted,at)},data_and_mode_compatible:function(Y,Z){if(Z==="Auto"){return true}else{if(Y.extra_info==="no_detail"||Y.dataset_type==="summary_tree"){return false}else{return true}}},can_subset:function(Y){if(Y.dataset_type==="summary_tree"||Y.message||Y.extra_info==="no_detail"){return false}return true}});var N=function(Z,Y,aa){c.call(this,Z,Y,aa);this.config=new B({track:this,params:[{key:"name",label:"Name",type:"text",default_value:this.name},{key:"block_color",label:"Block color",type:"color",default_value:get_random_color()},{key:"label_color",label:"Label color",type:"color",default_value:"black"},{key:"show_insertions",label:"Show insertions",type:"bool",default_value:false},{key:"show_counts",label:"Show summary counts",type:"bool",default_value:true},{key:"mode",type:"string",default_value:this.mode,hidden:true}],saved_values:aa.prefs,onchange:function(){this.track.set_name(this.track.prefs.name);this.track.tile_cache.clear();this.track.request_draw()}});this.prefs=this.config.values;this.painter=H.ReadPainter};o(N.prototype,p.prototype,I.prototype,c.prototype);var Q=function(aa,Z,ac){c.call(this,aa,Z,ac);var ab=get_random_color(),Y=get_random_color([ab,"#ffffff"]);this.config=new B({track:this,params:[{key:"name",label:"Name",type:"text",default_value:this.name},{key:"block_color",label:"Block and sense strand color",type:"color",default_value:ab},{key:"reverse_strand_color",label:"Antisense strand color",type:"color",default_value:Y},{key:"label_color",label:"Label color",type:"color",default_value:"black"},{key:"show_insertions",label:"Show insertions",type:"bool",default_value:false},{key:"show_differences",label:"Show differences only",type:"bool",default_value:true},{key:"show_counts",label:"Show summary counts",type:"bool",default_value:true},{key:"histogram_max",label:"Histogram maximum",type:"float",default_value:null,help:"Clear value to set automatically"},{key:"mode",type:"string",default_value:this.mode,hidden:true}],saved_values:ac.prefs,onchange:function(){this.track.set_name(this.track.prefs.name);this.track.tile_cache.clear();this.track.request_draw()}});this.prefs=this.config.values;this.painter=H.ReadPainter;this.update_icons()};o(Q.prototype,p.prototype,I.prototype,c.prototype);R.View=W;R.DrawableGroup=L;R.LineTrack=i;R.FeatureTrack=c;R.ReadTrack=Q;R.VcfTrack=N;R.CompositeTrack=g};var slotting_module=function(c,b){var e=c("class").extend;var d=2,a=5;b.FeatureSlotter=function(i,h,f,g){this.slots={};this.start_end_dct={};this.w_scale=i;this.mode=h;this.include_label=(h==="Pack");this.max_rows=f;this.measureText=g};e(b.FeatureSlotter.prototype,{slot_features:function(m){var p=this.w_scale,h=this.start_end_dct,x=[],z=[],n=0,y=this.max_rows;for(var v=0,w=m.length;v<w;v++){var k=m[v],o=k[0];if(this.slots[o]!==undefined){n=Math.max(n,this.slots[o]);z.push(this.slots[o])}else{x.push(v)}}var q=function(E,F){for(var D=0;D<=y;D++){var B=false,G=h[D];if(G!==undefined){for(var A=0,C=G.length;A<C;A++){var i=G[A];if(F>i[0]&&E<i[1]){B=true;break}}}if(!B){return D}}return -1};for(var v=0,w=x.length;v<w;v++){var k=m[x[v]],o=k[0],t=k[1],f=k[2],r=k[3],g=Math.floor(t*p),l=Math.ceil(f*p),u=this.measureText(r).width,j;if(r!==undefined&&this.include_label){u+=(d+a);if(g-u>=0){g-=u;j="left"}else{l+=u;j="right"}}var s=q(g,l);if(s>=0){if(h[s]===undefined){h[s]=[]}h[s].push([g,l]);this.slots[o]=s;n=Math.max(n,s)}}return n+1}})};var painters_module=function(i,x){var u=i("class").extend;var p=function(I,A,G,z,F,D){if(D===undefined){D=4}var C=z-A;var B=F-G;var E=Math.floor(Math.sqrt(C*C+B*B)/D);var J=C/E;var H=B/E;var y;for(y=0;y<E;y++,A+=J,G+=H){if(y%2!==0){continue}I.fillRect(A,G,D,1)}};var q=function(B,A,z,E){var D=A-E/2,C=A+E/2,F=z-Math.sqrt(E*3/2);B.beginPath();B.moveTo(D,F);B.lineTo(C,F);B.lineTo(A,z);B.lineTo(D,F);B.strokeStyle=this.fillStyle;B.fill();B.stroke();B.closePath()};var d=function(y){this.default_val=(y?y:1)};d.prototype.gen_val=function(y){return this.default_val};var l=function(A,C,y,z,B){this.data=A;this.view_start=C;this.view_end=y;this.prefs=u({},this.default_prefs,z);this.mode=B};l.prototype.default_prefs={};l.prototype.draw=function(z,A,y,B){};var v=function(A,C,y,z,B){l.call(this,A,C,y,z,B)};v.prototype.default_prefs={show_counts:false};v.prototype.draw=function(L,z,K,M){var E=this.view_start,N=this.view_end-this.view_start,I=this.data.data,G=(this.prefs.histogram_max?this.prefs.histogram_max:this.data.max),B=K;delta_x_px=Math.ceil(this.data.delta*M);L.save();for(var C=0,D=I.length;C<D;C++){var H=Math.floor((I[C][0]-E)*M);var F=I[C][1];if(!F){continue}var J=F/G*K;if(F!==0&&J<1){J=1}L.fillStyle=this.prefs.block_color;L.fillRect(H,B-J,delta_x_px,J);var A=4;if(this.prefs.show_counts&&(L.measureText(F).width+A)<delta_x_px){L.fillStyle=this.prefs.label_color;L.textAlign="center";L.fillText(F,H+(delta_x_px/2),10)}}L.restore()};var b=function(y,C,E,F,A){l.call(this,y,C,E,F,A);if(this.prefs.min_value===undefined){var G=Infinity;for(var z=0,B=this.data.length;z<B;z++){G=Math.min(G,this.data[z][1])}this.prefs.min_value=G}if(this.prefs.max_value===undefined){var D=-Infinity;for(var z=0,B=this.data.length;z<B;z++){D=Math.max(D,this.data[z][1])}this.prefs.max_value=D}};b.prototype.default_prefs={min_value:undefined,max_value:undefined,mode:"Histogram",color:"#000",overflow_color:"#F66"};b.prototype.draw=function(S,Q,N,D){var I=false,K=this.prefs.min_value,F=this.prefs.max_value,M=F-K,B=N,C=this.view_start,P=this.view_end-this.view_start,L=this.mode,aa=this.data;S.save();var ac=Math.round(N+K/M*N);if(L!=="Intensity"){S.fillStyle="#aaa";S.fillRect(0,ac,Q,1)}S.beginPath();var Y,G,E;if(aa.length>1){E=Math.ceil((aa[1][0]-aa[0][0])*D)}else{E=10}var A=parseInt(this.prefs.color.slice(1),16),H=(A&16711680)>>16,R=(A&65280)>>8,V=A&255;for(var T=0,U=aa.length;T<U;T++){S.fillStyle=S.strokeStyle=this.prefs.color;Y=Math.round((aa[T][0]-C)*D);G=aa[T][1];var W=false,J=false;if(G===null){if(I&&L==="Filled"){S.lineTo(Y,B)}I=false;continue}if(G<K){J=true;G=K}else{if(G>F){W=true;G=F}}if(L==="Histogram"){G=Math.round(G/M*B);S.fillRect(Y,ac,E,-G)}else{if(L==="Intensity"){var z=(G-K)/M,O=Math.round(H+(255-H)*(1-z)),X=Math.round(R+(255-R)*(1-z)),ab=Math.round(V+(255-V)*(1-z));S.fillStyle="rgb("+O+","+X+","+ab+")";S.fillRect(Y,0,E,B)}else{G=Math.round(B-(G-K)/M*B);if(I){S.lineTo(Y,G)}else{I=true;if(L==="Filled"){S.moveTo(Y,B);S.lineTo(Y,G)}else{S.moveTo(Y,G)}}}}S.fillStyle=this.prefs.overflow_color;if(W||J){var Z;if(L==="Histogram"||L==="Intensity"){Z=E}else{Y-=2;Z=4}if(W){S.fillRect(Y,0,Z,3)}if(J){S.fillRect(Y,B-3,Z,3)}}S.fillStyle=this.prefs.color}if(L==="Filled"){if(I){S.lineTo(Y,ac);S.lineTo(0,ac)}S.fill()}else{S.stroke()}S.restore()};var m=function(y){this.feature_positions={};this.slot_height=y;this.translation=0;this.y_translation=0};m.prototype.map_feature_data=function(z,B,y,A){if(!this.feature_positions[B]){this.feature_positions[B]=[]}this.feature_positions[B].push({data:z,x_start:y,x_end:A})};m.prototype.get_feature_data=function(z,D){var C=Math.floor((D-this.y_translation)/this.slot_height),B;if(!this.feature_positions[C]){return null}z+=this.translation;for(var A=0;A<this.feature_positions[C].length;A++){B=this.feature_positions[C][A];if(z>=B.x_start&&z<=B.x_end){return B.data}}};var o=function(A,D,y,z,C,E,B){l.call(this,A,D,y,z,C);this.alpha_scaler=(E?E:new d());this.height_scaler=(B?B:new d())};o.prototype.default_prefs={block_color:"#FFF",connector_color:"#FFF"};u(o.prototype,{get_required_height:function(A,z){var y=y_scale=this.get_row_height(),B=this.mode;if(B==="no_detail"||B==="Squish"||B==="Pack"){y=A*y_scale}return y+this.get_top_padding(z)+this.get_bottom_padding(z)},get_top_padding:function(y){return 0},get_bottom_padding:function(y){return Math.max(Math.round(this.get_row_height()/2),5)},draw:function(K,I,G,E,F){var Q=this.data,D=this.view_start,M=this.view_end;K.save();K.fillStyle=this.prefs.block_color;K.textAlign="right";var H=this.view_end-this.view_start,L=this.get_row_height(),P=new m(L),B;for(var N=0,O=Q.length;N<O;N++){var A=Q[N],C=A[0],J=A[1],y=A[2],z=(F&&F[C]!==undefined?F[C]:null);if((J<M&&y>D)&&(this.mode==="Dense"||z!==null)){B=this.draw_element(K,this.mode,A,z,D,M,E,L,I);P.map_feature_data(A,z,B[0],B[1])}}K.restore();P.y_translation=this.get_top_padding(I);return P},draw_element:function(E,A,G,C,B,D,F,z,y){console.log("WARNING: Unimplemented function.");return[0,0]}});var c=10,h=3,k=5,w=10,f=1,s=9,e=3,a=9,j=2,g="#ccc";var r=function(A,D,y,z,C,E,B){o.call(this,A,D,y,z,C,E,B);this.draw_background_connector=true;this.draw_individual_connectors=false};u(r.prototype,o.prototype,{get_row_height:function(){var z=this.mode,y;if(z==="Dense"){y=c}else{if(z==="no_detail"){y=h}else{if(z==="Squish"){y=k}else{y=w}}}return y},draw_element:function(M,D,X,H,O,ai,am,ao,y){var T=X[0],ak=X[1],ad=X[2]-1,Q=X[3],K=X[4],ae=Math.floor(Math.max(0,(ak-O)*am)),N=Math.ceil(Math.min(y,Math.max(0,(ad-O)*am))),ac=ae,an=N,aa=(D==="Dense"?0:(0+H))*ao+this.get_top_padding(y),L,ag,R=null,aq=null,B=B=(!K||K==="+"||K==="."?this.prefs.block_color:this.prefs.reverse_strand_color);label_color=this.prefs.label_color;M.globalAlpha=this.alpha_scaler.gen_val(X);if(D==="Dense"){H=1}if(D==="no_detail"){M.fillStyle=B;M.fillRect(ae,aa+5,N-ae,f)}else{var Z=X[5],af=X[6],C=X[7],V=true;if(Z&&af){R=Math.floor(Math.max(0,(Z-O)*am));aq=Math.ceil(Math.min(y,Math.max(0,(af-O)*am)))}var al,U;if(D==="Squish"){al=1;U=e;V=false}else{if(D==="Dense"){al=5;U=s}else{al=5;U=a}}if(!C){M.fillStyle=B;M.fillRect(ae,aa+1,N-ae,U);if(K&&V){if(K==="+"){M.fillStyle=M.canvas.manager.get_pattern("right_strand_inv")}else{if(K==="-"){M.fillStyle=M.canvas.manager.get_pattern("left_strand_inv")}}M.fillRect(ae,aa+1,N-ae,U)}}else{var J,W;if(D==="Squish"||D==="Dense"){J=aa+Math.floor(e/2)+1;W=1}else{if(K){J=aa;W=U}else{J+=(e/2)+1;W=1}}if(this.draw_background_connector){if(D==="Squish"||D==="Dense"){M.fillStyle=g}else{if(K){if(K==="+"){M.fillStyle=M.canvas.manager.get_pattern("right_strand")}else{if(K==="-"){M.fillStyle=M.canvas.manager.get_pattern("left_strand")}}}else{M.fillStyle=g}}M.fillRect(ae,J,N-ae,W)}var E;for(var aj=0,A=C.length;aj<A;aj++){var F=C[aj],z=Math.floor(Math.max(0,(F[0]-O)*am)),Y=Math.ceil(Math.min(y,Math.max((F[1]-1-O)*am))),S,ab;if(z>Y){continue}M.fillStyle=B;M.fillRect(z,aa+(U-al)/2+1,Y-z,al);if(R!==undefined&&af>Z&&!(z>aq||Y<R)){var ah=Math.max(z,R),I=Math.min(Y,aq);M.fillRect(ah,aa+1,I-ah,U)}if(this.draw_individual_connectors&&S){this.draw_connector(M,S,ab,z,Y,aa)}S=z;ab=Y}if(D==="Pack"){M.globalAlpha=1;M.fillStyle="white";var G=this.height_scaler.gen_val(X),P=Math.ceil(U*G),ap=Math.round((U-P)/2);if(G!==1){M.fillRect(ae,J+1,N-ae,ap);M.fillRect(ae,J+U-ap+1,N-ae,ap)}}}M.globalAlpha=1;if(D==="Pack"&&ak>O){M.fillStyle=label_color;if(O===0&&ae-M.measureText(Q).width<0){M.textAlign="left";M.fillText(Q,N+j,aa+8);an+=M.measureText(Q).width+j}else{M.textAlign="right";M.fillText(Q,ae-j,aa+8);ac-=M.measureText(Q).width+j}}}M.globalAlpha=1;return[ac,an]}});var t=function(B,E,y,A,D,F,C,z){o.call(this,B,E,y,A,D,F,C);this.ref_seq=(z?z.data:null)};u(t.prototype,o.prototype,{get_row_height:function(){var y,z=this.mode;if(z==="Dense"){y=c}else{if(z==="Squish"){y=k}else{y=w;if(this.prefs.show_insertions){y*=2}}}return y},draw_read:function(K,A,ag,V,L,aa,ad,C,B,M){K.textAlign="center";var J=this,R=[L,aa],Z=0,W=0,D=0,F=K.canvas.manager.char_width_px,y=(B==="+"?this.prefs.block_color:this.prefs.reverse_strand_color);var O=[];if((A==="Pack"||this.mode==="Auto")&&M!==undefined&&ag>F){D=Math.round(ag/2)}if(!C){C=[[0,M.length]]}for(var G=0,I=C.length;G<I;G++){var z=C[G],E="MIDNSHP=X"[z[0]],S=z[1];if(E==="H"||E==="S"){Z-=S}var U=ad+Z,Y=Math.floor(Math.max(0,(U-L)*ag)),ab=Math.floor(Math.max(0,(U+S-L)*ag));if(Y===ab){ab+=1}switch(E){case"H":break;case"S":case"M":case"=":if(is_overlap([U,U+S],R)){var N=M.slice(W,W+S);if(D>0){K.fillStyle=y;K.fillRect(Y-D,V+1,ab-Y,9);K.fillStyle=g;for(var af=0,H=N.length;af<H;af++){if(this.prefs.show_differences){if(this.ref_seq){var P=this.ref_seq[U-L+af];if(!P||P.toLowerCase()===N[af].toLowerCase()){continue}}else{continue}}if(U+af>=L&&U+af<=aa){var X=Math.floor(Math.max(0,(U+af-L)*ag));K.fillText(N[af],X,V+9)}}}else{K.fillStyle=y;K.fillRect(Y,V+4,ab-Y,e)}}W+=S;Z+=S;break;case"N":K.fillStyle=g;K.fillRect(Y-D,V+5,ab-Y,1);Z+=S;break;case"D":K.fillStyle="red";K.fillRect(Y-D,V+4,ab-Y,3);Z+=S;break;case"P":break;case"I":var ah=Y-D;if(is_overlap([U,U+S],R)){var N=M.slice(W,W+S);if(this.prefs.show_insertions){var T=Y-(ab-Y)/2;if((A==="Pack"||this.mode==="Auto")&&M!==undefined&&ag>F){K.fillStyle="yellow";K.fillRect(T-D,V-9,ab-Y,9);O[O.length]={type:"triangle",data:[ah,V+4,5]};K.fillStyle=g;switch(compute_overlap([U,U+S],R)){case (OVERLAP_START):N=N.slice(L-U);break;case (OVERLAP_END):N=N.slice(0,U-aa);break;case (CONTAINED_BY):break;case (CONTAINS):N=N.slice(L-U,U-aa);break}for(var af=0,H=N.length;af<H;af++){var X=Math.floor(Math.max(0,(U+af-L)*ag));K.fillText(N[af],X-(ab-Y)/2,V)}}else{K.fillStyle="yellow";K.fillRect(T,V+(this.mode!=="Dense"?2:5),ab-Y,(A!=="Dense"?e:s))}}else{if((A==="Pack"||this.mode==="Auto")&&M!==undefined&&ag>F){O.push({type:"text",data:[N.length,ah,V+9]})}else{}}}W+=S;break;case"X":W+=S;break}}K.fillStyle="yellow";var Q,ai,ae;for(var ac=0;ac<O.length;ac++){Q=O[ac];ai=Q.type;ae=Q.data;if(ai==="text"){K.save();K.font="bold "+K.font;K.fillText(ae[0],ae[1],ae[2]);K.restore()}else{if(ai==="triangle"){q(K,ae[0],ae[1],ae[2])}}}},draw_element:function(R,M,E,B,U,z,I,S,P){var H=E[0],Q=E[1],A=E[2],J=E[3],D=Math.floor(Math.max(0,(Q-U)*I)),F=Math.ceil(Math.min(P,Math.max(0,(A-U)*I))),C=(M==="Dense"?0:(0+B))*S,G=this.prefs.label_color,O=0;if((M==="Pack"||this.mode==="Auto")&&I>R.canvas.manager.char_width_px){var O=Math.round(I/2)}if(E[5] instanceof Array){var N=Math.floor(Math.max(0,(E[4][0]-U)*I)),L=Math.ceil(Math.min(P,Math.max(0,(E[4][1]-U)*I))),K=Math.floor(Math.max(0,(E[5][0]-U)*I)),y=Math.ceil(Math.min(P,Math.max(0,(E[5][1]-U)*I)));if(E[4][1]>=U&&E[4][0]<=z&&E[4][2]){this.draw_read(R,M,I,C,U,z,E[4][0],E[4][2],E[4][3],E[4][4])}if(E[5][1]>=U&&E[5][0]<=z&&E[5][2]){this.draw_read(R,M,I,C,U,z,E[5][0],E[5][2],E[5][3],E[5][4])}if(K>L){R.fillStyle=g;p(R,L-O,C+5,K-O,C+5)}}else{this.draw_read(R,M,I,C,U,z,Q,E[4],E[5],E[6])}if(M==="Pack"&&Q>U&&J!=="."){R.fillStyle=this.prefs.label_color;var T=1;if(T===0&&D-R.measureText(J).width<0){R.textAlign="left";R.fillText(J,F+j-O,C+8)}else{R.textAlign="right";R.fillText(J,D-j-O,C+8)}}return[0,0]}});var n=function(A,D,y,z,C,E,B){r.call(this,A,D,y,z,C,E,B);this.longest_feature_length=this.calculate_longest_feature_length();this.draw_background_connector=false;this.draw_individual_connectors=true};u(n.prototype,o.prototype,r.prototype,{calculate_longest_feature_length:function(){var z=0;for(var C=0,y=this.data.length;C<y;C++){var B=this.data[C],A=B[1],D=B[2];z=Math.max(z,D-A)}return z},get_top_padding:function(z){var y=this.view_end-this.view_start,A=z/y;return Math.min(128,Math.ceil((this.longest_feature_length/2)*A))},draw_connector:function(G,B,F,H,E,D){var y=(F+H)/2,C=H-y;var A=Math.PI,z=0;if(C>0){G.beginPath();G.arc(y,D,H-y,Math.PI,0);G.stroke()}}});x.Scaler=d;x.SummaryTreePainter=v;x.LinePainter=b;x.LinkedFeaturePainter=r;x.ReadPainter=t;x.ArcLinkedFeaturePainter=n};(function(d){var c={};var b=function(e){return c[e]};var a=function(f,g){var e={};g(b,e);c[f]=e};a("class",class_module);a("slotting",slotting_module);a("painters",painters_module);a("trackster",trackster_module);for(key in c.trackster){d[key]=c.trackster[key]}})(window); \ No newline at end of file diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c static/scripts/packed/viz/visualization.js --- a/static/scripts/packed/viz/visualization.js +++ b/static/scripts/packed/viz/visualization.js @@ -1,1 +1,1 @@ -var ServerStateDeferred=Backbone.Model.extend({defaults:{ajax_settings:{},interval:1000,success_fn:function(a){return true}},go:function(){var d=$.Deferred(),c=this,f=c.get("ajax_settings"),e=c.get("success_fn"),b=c.get("interval"),a=function(){$.ajax(f).success(function(g){if(e(g)){d.resolve(g)}else{setTimeout(a,b)}})};a();return d}});var CanvasManager=function(a){this.default_font=a!==undefined?a:"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")};_.extend(CanvasManager.prototype,{load_pattern:function(a,e){var b=this.patterns,c=this.dummy_context,d=new Image();d.src=galaxy_paths.attributes.image_path+e;d.onload=function(){b[a]=c.createPattern(d,"repeat")}},get_pattern:function(a){return this.patterns[a]},new_canvas:function(){var a=$("<canvas/>")[0];if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(a)}a.manager=this;return a}});var Cache=Backbone.Model.extend({defaults:{num_elements:20,obj_cache:null,key_ary:null},initialize:function(a){this.clear()},get_elt:function(b){var c=this.attributes.obj_cache,d=this.attributes.key_ary,a=d.indexOf(b);if(a!==-1){if(c[b].stale){d.splice(a,1);delete c[b]}else{this.move_key_to_end(b,a)}}return c[b]},set_elt:function(b,d){var e=this.attributes.obj_cache,f=this.attributes.key_ary,c=this.attributes.num_elements;if(!e[b]){if(f.length>=c){var a=f.shift();delete e[a]}f.push(b)}e[b]=d;return d},move_key_to_end:function(b,a){this.attributes.key_ary.splice(a,1);this.attributes.key_ary.push(b)},clear:function(){this.attributes.obj_cache={};this.attributes.key_ary=[]},size:function(){return this.attributes.key_ary.length}});var GenomeDataManager=Cache.extend({defaults:_.extend({},Cache.prototype.defaults,{dataset:null,filters_manager:null,data_url:null,dataset_state_url:null,genome_wide_summary_data:null,data_mode_compatible:function(a,b){return true},can_subset:function(a){return false}}),data_is_ready:function(){var c=this.get("dataset"),b=$.Deferred(),a=new ServerStateDeferred({ajax_settings:{url:this.get("dataset_state_url"),data:{dataset_id:c.id,hda_ldda:c.get("hda_ldda")},dataType:"json"},interval:5000,success_fn:function(d){return d!=="pending"}});$.when(a.go()).then(function(d){b.resolve(d==="ok"||d==="data")});return b},load_data:function(h,g,b,f){var d={chrom:h.get("chrom"),low:h.get("start"),high:h.get("end"),mode:g,resolution:b};dataset=this.get("dataset");if(dataset){d.dataset_id=dataset.id;d.hda_ldda=dataset.get("hda_ldda")}$.extend(d,f);var j=this.get("filters_manager");if(j){var k=[];var a=j.filters;for(var e=0;e<a.length;e++){k.push(a[e].name)}d.filter_cols=JSON.stringify(k)}var c=this;return $.getJSON(this.get("data_url"),d,function(i){c.set_data(h,i)})},get_data:function(g,f,c,e){var h=this.get_elt(g);if(h&&(is_deferred(h)||this.get("data_mode_compatible")(h,f))){return h}var j=this.get("key_ary"),b=this.get("obj_cache"),k,a;for(var d=0;d<j.length;d++){k=j[d];a=new GenomeRegion({from_str:k});if(a.contains(g)){h=b[k];if(is_deferred(h)||(this.get("data_mode_compatible")(h,f)&&this.get("can_subset")(h))){this.move_key_to_end(k,d);return h}}}h=this.load_data(g,f,c,e);this.set_data(g,h);return h},set_data:function(b,a){this.set_elt(b,a)},DEEP_DATA_REQ:"deep",BROAD_DATA_REQ:"breadth",get_more_data:function(i,h,d,g,e){var k=this.get_elt(i);if(!(k&&this.get("data_mode_compatible")(k,h))){console.log("ERROR: no current data for: ",dataset,i.toString(),h,d,g);return}k.stale=true;var c=i.get("start");if(e===this.DEEP_DATA_REQ){$.extend(g,{start_val:k.data.length+1})}else{if(e===this.BROAD_DATA_REQ){c=(k.max_high?k.max_high:k.data[k.data.length-1][2])+1}}var j=i.copy().set("start",c);var b=this,f=this.load_data(j,h,d,g),a=$.Deferred();this.set_data(i,a);$.when(f).then(function(l){if(l.data){l.data=k.data.concat(l.data);if(l.max_low){l.max_low=k.max_low}if(l.message){l.message=l.message.replace(/[0-9]+/,l.data.length)}}b.set_data(i,l);a.resolve(l)});return a},get_elt:function(a){return Cache.prototype.get_elt.call(this,a.toString())},set_elt:function(b,a){return Cache.prototype.set_elt.call(this,b.toString(),a)}});var ReferenceTrackDataManager=GenomeDataManager.extend({load_data:function(a,d,e,b,c){if(b>1){return{data:null}}return GenomeDataManager.prototype.load_data.call(this,a,d,e,b,c)}});var Genome=Backbone.Model.extend({defaults:{name:null,key:null,chroms_info:null},get_chroms_info:function(){return this.attributes.chroms_info.chrom_info}});var GenomeRegion=Backbone.RelationalModel.extend({defaults:{chrom:null,start:0,end:0,DIF_CHROMS:1000,BEFORE:1001,CONTAINS:1002,OVERLAP_START:1003,OVERLAP_END:1004,CONTAINED_BY:1005,AFTER:1006},initialize:function(b){if(b.from_str){var d=b.from_str.split(":"),c=d[0],a=d[1].split("-");this.set({chrom:c,start:parseInt(a[0],10),end:parseInt(a[1],10)})}},copy:function(){return new GenomeRegion({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(h){var b=this.get("chrom"),g=h.get("chrom"),f=this.get("start"),d=h.get("start"),e=this.get("end"),c=h.get("end"),a;if(b&&g&&b!==g){return this.get("DIF_CHROMS")}if(f<d){if(e<d){a=this.get("BEFORE")}else{if(e<=c){a=this.get("OVERLAP_START")}else{a=this.get("CONTAINS")}}}else{if(f>c){a=this.get("AFTER")}else{if(e<=c){a=this.get("CONTAINED_BY")}else{a=this.get("OVERLAP_END")}}}return a},contains:function(a){return this.compute_overlap(a)===this.get("CONTAINS")},overlaps:function(a){return _.intersection([this.compute_overlap(a)],[this.get("DIF_CHROMS"),this.get("BEFORE"),this.get("AFTER")]).length===0}});var GenomeRegionCollection=Backbone.Collection.extend({model:GenomeRegion});var BrowserBookmark=Backbone.RelationalModel.extend({defaults:{region:null,note:""},relations:[{type:Backbone.HasOne,key:"region",relatedModel:"GenomeRegion"}]});var BrowserBookmarkCollection=Backbone.Collection.extend({model:BrowserBookmark});var GenomeWideSummaryData=Backbone.RelationalModel.extend({defaults:{data:null,max:0},initialize:function(b){var a=_.max(this.get("data"),function(c){if(!c||typeof c==="string"){return 0}return c[1]});this.attributes.max=(a&&typeof a!=="string"?a[1]:0)}});var BackboneTrack=Dataset.extend({initialize:function(a){this.set("id",a.dataset_id)},relations:[{type:Backbone.HasOne,key:"genome_wide_data",relatedModel:"GenomeWideSummaryData"}]});var Visualization=Backbone.RelationalModel.extend({defaults:{id:"",title:"",type:"",dbkey:"",tracks:null},relations:[{type:Backbone.HasMany,key:"tracks",relatedModel:"BackboneTrack"}],url:function(){return galaxy_paths.get("visualization_url")},save:function(){return $.ajax({url:this.url(),type:"POST",dataType:"json",data:{vis_json:JSON.stringify(this)}})}});var GenomeVisualization=Visualization.extend({defaults:_.extend({},Visualization.prototype.defaults,{bookmarks:null,viewport:null})});var TrackConfig=Backbone.Model.extend({});var CircsterHistogramDatasetLayout=Backbone.Model.extend({chroms_layout:function(){var b=this.attributes.genome.get_chroms_info(),d=d3.layout.pie().value(function(f){return f.len}).sort(null),e=d(b),a=this.attributes.total_gap/b.length,c=_.map(e,function(h,g){var f=h.endAngle-a;h.endAngle=(f>h.startAngle?f:h.startAngle);return h});return c},chrom_data_layout:function(j,b,g,f,h){if(!b||typeof b==="string"){return null}var d=b[0],i=b[3],c=d3.scale.linear().domain([0,h]).range([g,f]),e=d3.layout.pie().value(function(k){return i}).startAngle(j.startAngle).endAngle(j.endAngle),a=e(d);_.each(d,function(k,l){a[l].outerRadius=c(k[1])});return a}});var CircsterView=Backbone.View.extend({className:"circster",initialize:function(a){this.width=a.width;this.height=a.height;this.total_gap=a.total_gap;this.genome=a.genome;this.radius_start=a.radius_start;this.dataset_arc_height=a.dataset_arc_height},render:function(){var c=this.model.get("tracks").at(0).get("genome_wide_data");var e=this.radius_start,f=this.dataset_arc_height,k=new CircsterHistogramDatasetLayout({genome:this.genome,total_gap:this.total_gap}),j=k.chroms_layout(),h=_.zip(j,c.get("data")),i=c.get("max"),b=_.map(h,function(n){var o=n[0],m=n[1];return k.chrom_data_layout(o,m,e,e+f,i)});var d=d3.select(this.$el[0]).append("svg").attr("width",this.width).attr("height",this.height).append("g").attr("transform","translate("+this.width/2+","+this.height/2+")");var l=d.append("g").attr("id","inner-arc"),g=d3.svg.arc().innerRadius(e).outerRadius(e+f),a=l.selectAll("#inner-arc>path").data(j).enter().append("path").attr("d",g).style("stroke","#ccc").style("fill","#ccc").append("title").text(function(m){return m.data.chrom});_.each(b,function(m){if(!m){return}var p=d.append("g"),o=d3.svg.arc().innerRadius(e),n=p.selectAll("path").data(m).enter().append("path").attr("d",o).style("stroke","red").style("fill","red")})}});var TrackBrowserRouter=Backbone.Router.extend({initialize:function(b){this.view=b.view;this.route(/([\w]+)$/,"change_location");this.route(/([\w]+\:[\d,]+-[\d,]+)$/,"change_location");var a=this;a.view.on("navigate",function(c){a.navigate(c)})},change_location:function(a){this.view.go_to(a)}});var add_datasets=function(a,c,b){$.ajax({url:a,data:{"f-dbkey":view.dbkey},error:function(){alert("Grid failed")},success:function(d){show_modal("Select datasets for new tracks",d,{Cancel:function(){hide_modal()},Add:function(){var e=[];$("input[name=id]:checked,input[name=ldda_ids]:checked").each(function(){var f,g=$(this).val();if($(this).attr("name")==="id"){f={hda_id:g}}else{f={ldda_id:g}}e[e.length]=$.ajax({url:c,data:f,dataType:"json"})});$.when.apply($,e).then(function(){var f=(arguments[0] instanceof Array?$.map(arguments,function(g){return g[0]}):[arguments[0]]);b(f)});hide_modal()}})}})}; \ No newline at end of file +var ServerStateDeferred=Backbone.Model.extend({defaults:{ajax_settings:{},interval:1000,success_fn:function(a){return true}},go:function(){var d=$.Deferred(),c=this,f=c.get("ajax_settings"),e=c.get("success_fn"),b=c.get("interval"),a=function(){$.ajax(f).success(function(g){if(e(g)){d.resolve(g)}else{setTimeout(a,b)}})};a();return d}});var CanvasManager=function(a){this.default_font=a!==undefined?a:"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")};_.extend(CanvasManager.prototype,{load_pattern:function(a,e){var b=this.patterns,c=this.dummy_context,d=new Image();d.src=galaxy_paths.attributes.image_path+e;d.onload=function(){b[a]=c.createPattern(d,"repeat")}},get_pattern:function(a){return this.patterns[a]},new_canvas:function(){var a=$("<canvas/>")[0];if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(a)}a.manager=this;return a}});var Cache=Backbone.Model.extend({defaults:{num_elements:20,obj_cache:null,key_ary:null},initialize:function(a){this.clear()},get_elt:function(b){var c=this.attributes.obj_cache,d=this.attributes.key_ary,a=d.indexOf(b);if(a!==-1){if(c[b].stale){d.splice(a,1);delete c[b]}else{this.move_key_to_end(b,a)}}return c[b]},set_elt:function(b,d){var e=this.attributes.obj_cache,f=this.attributes.key_ary,c=this.attributes.num_elements;if(!e[b]){if(f.length>=c){var a=f.shift();delete e[a]}f.push(b)}e[b]=d;return d},move_key_to_end:function(b,a){this.attributes.key_ary.splice(a,1);this.attributes.key_ary.push(b)},clear:function(){this.attributes.obj_cache={};this.attributes.key_ary=[]},size:function(){return this.attributes.key_ary.length}});var GenomeDataManager=Cache.extend({defaults:_.extend({},Cache.prototype.defaults,{dataset:null,filters_manager:null,data_url:null,dataset_state_url:null,genome_wide_summary_data:null,data_mode_compatible:function(a,b){return true},can_subset:function(a){return false}}),data_is_ready:function(){var c=this.get("dataset"),b=$.Deferred(),a=new ServerStateDeferred({ajax_settings:{url:this.get("dataset_state_url"),data:{dataset_id:c.id,hda_ldda:c.get("hda_ldda")},dataType:"json"},interval:5000,success_fn:function(d){return d!=="pending"}});$.when(a.go()).then(function(d){b.resolve(d==="ok"||d==="data")});return b},load_data:function(h,g,b,f){var d={chrom:h.get("chrom"),low:h.get("start"),high:h.get("end"),mode:g,resolution:b};dataset=this.get("dataset");if(dataset){d.dataset_id=dataset.id;d.hda_ldda=dataset.get("hda_ldda")}$.extend(d,f);var j=this.get("filters_manager");if(j){var k=[];var a=j.filters;for(var e=0;e<a.length;e++){k.push(a[e].name)}d.filter_cols=JSON.stringify(k)}var c=this;return $.getJSON(this.get("data_url"),d,function(i){c.set_data(h,i)})},get_data:function(g,f,c,e){var h=this.get_elt(g);if(h&&(is_deferred(h)||this.get("data_mode_compatible")(h,f))){return h}var j=this.get("key_ary"),b=this.get("obj_cache"),k,a;for(var d=0;d<j.length;d++){k=j[d];a=new GenomeRegion({from_str:k});if(a.contains(g)){h=b[k];if(is_deferred(h)||(this.get("data_mode_compatible")(h,f)&&this.get("can_subset")(h))){this.move_key_to_end(k,d);return h}}}h=this.load_data(g,f,c,e);this.set_data(g,h);return h},set_data:function(b,a){this.set_elt(b,a)},DEEP_DATA_REQ:"deep",BROAD_DATA_REQ:"breadth",get_more_data:function(i,h,d,g,e){var k=this.get_elt(i);if(!(k&&this.get("data_mode_compatible")(k,h))){console.log("ERROR: no current data for: ",dataset,i.toString(),h,d,g);return}k.stale=true;var c=i.get("start");if(e===this.DEEP_DATA_REQ){$.extend(g,{start_val:k.data.length+1})}else{if(e===this.BROAD_DATA_REQ){c=(k.max_high?k.max_high:k.data[k.data.length-1][2])+1}}var j=i.copy().set("start",c);var b=this,f=this.load_data(j,h,d,g),a=$.Deferred();this.set_data(i,a);$.when(f).then(function(l){if(l.data){l.data=k.data.concat(l.data);if(l.max_low){l.max_low=k.max_low}if(l.message){l.message=l.message.replace(/[0-9]+/,l.data.length)}}b.set_data(i,l);a.resolve(l)});return a},get_elt:function(a){return Cache.prototype.get_elt.call(this,a.toString())},set_elt:function(b,a){return Cache.prototype.set_elt.call(this,b.toString(),a)}});var ReferenceTrackDataManager=GenomeDataManager.extend({load_data:function(a,d,e,b,c){if(b>1){return{data:null}}return GenomeDataManager.prototype.load_data.call(this,a,d,e,b,c)}});var Genome=Backbone.Model.extend({defaults:{name:null,key:null,chroms_info:null},get_chroms_info:function(){return this.attributes.chroms_info.chrom_info}});var GenomeRegion=Backbone.RelationalModel.extend({defaults:{chrom:null,start:0,end:0,DIF_CHROMS:1000,BEFORE:1001,CONTAINS:1002,OVERLAP_START:1003,OVERLAP_END:1004,CONTAINED_BY:1005,AFTER:1006},initialize:function(b){if(b.from_str){var d=b.from_str.split(":"),c=d[0],a=d[1].split("-");this.set({chrom:c,start:parseInt(a[0],10),end:parseInt(a[1],10)})}},copy:function(){return new GenomeRegion({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(h){var b=this.get("chrom"),g=h.get("chrom"),f=this.get("start"),d=h.get("start"),e=this.get("end"),c=h.get("end"),a;if(b&&g&&b!==g){return this.get("DIF_CHROMS")}if(f<d){if(e<d){a=this.get("BEFORE")}else{if(e<=c){a=this.get("OVERLAP_START")}else{a=this.get("CONTAINS")}}}else{if(f>c){a=this.get("AFTER")}else{if(e<=c){a=this.get("CONTAINED_BY")}else{a=this.get("OVERLAP_END")}}}return a},contains:function(a){return this.compute_overlap(a)===this.get("CONTAINS")},overlaps:function(a){return _.intersection([this.compute_overlap(a)],[this.get("DIF_CHROMS"),this.get("BEFORE"),this.get("AFTER")]).length===0}});var GenomeRegionCollection=Backbone.Collection.extend({model:GenomeRegion});var BrowserBookmark=Backbone.RelationalModel.extend({defaults:{region:null,note:""},relations:[{type:Backbone.HasOne,key:"region",relatedModel:"GenomeRegion"}]});var BrowserBookmarkCollection=Backbone.Collection.extend({model:BrowserBookmark});var GenomeWideSummaryData=Backbone.RelationalModel.extend({defaults:{data:null,max:0},initialize:function(b){var a=_.max(this.get("data"),function(c){if(!c||typeof c==="string"){return 0}return c[1]});this.attributes.max=(a&&typeof a!=="string"?a[1]:0)}});var BackboneTrack=Dataset.extend({initialize:function(a){this.set("id",a.dataset_id)},relations:[{type:Backbone.HasOne,key:"genome_wide_data",relatedModel:"GenomeWideSummaryData"}]});var Visualization=Backbone.RelationalModel.extend({defaults:{id:"",title:"",type:"",dbkey:"",tracks:null},relations:[{type:Backbone.HasMany,key:"tracks",relatedModel:"BackboneTrack"}],url:function(){return galaxy_paths.get("visualization_url")},save:function(){return $.ajax({url:this.url(),type:"POST",dataType:"json",data:{vis_json:JSON.stringify(this)}})}});var GenomeVisualization=Visualization.extend({defaults:_.extend({},Visualization.prototype.defaults,{bookmarks:null,viewport:null})});var TrackConfig=Backbone.Model.extend({});var CircsterHistogramDatasetLayout=Backbone.Model.extend({chroms_layout:function(){var b=this.attributes.genome.get_chroms_info(),d=d3.layout.pie().value(function(f){return f.len}).sort(null),e=d(b),a=this.attributes.total_gap/b.length,c=_.map(e,function(h,g){var f=h.endAngle-a;h.endAngle=(f>h.startAngle?f:h.startAngle);return h});return c},chrom_data_layout:function(j,b,g,f,h){if(!b||typeof b==="string"){return null}var d=b[0],i=b[3],c=d3.scale.linear().domain([0,h]).range([g,f]),e=d3.layout.pie().value(function(k){return i}).startAngle(j.startAngle).endAngle(j.endAngle),a=e(d);_.each(d,function(k,l){a[l].outerRadius=c(k[1])});return a}});var CircsterView=Backbone.View.extend({className:"circster",initialize:function(a){this.width=a.width;this.height=a.height;this.total_gap=a.total_gap;this.genome=a.genome;this.radius_start=a.radius_start;this.dataset_arc_height=a.dataset_arc_height;this.track_gap=5},render:function(){var b=this,c=this.dataset_arc_height;var a=d3.select(b.$el[0]).append("svg").attr("width",b.width).attr("height",b.height).append("g").attr("transform","translate("+b.width/2+","+b.height/2+")");this.model.get("tracks").each(function(e,j){var g=e.get("genome_wide_data");var i=b.radius_start+j*(c+b.track_gap),o=new CircsterHistogramDatasetLayout({genome:b.genome,total_gap:b.total_gap}),n=o.chroms_layout(),l=_.zip(n,g.get("data")),m=g.get("max"),f=_.map(l,function(s){var t=s[0],r=s[1];return o.chrom_data_layout(t,r,i,i+c,m)});var p=a.append("g").attr("id","inner-arc"),k=d3.svg.arc().innerRadius(i).outerRadius(i+c),d=p.selectAll("#inner-arc>path").data(n).enter().append("path").attr("d",k).style("stroke","#ccc").style("fill","#ccc").append("title").text(function(r){return r.data.chrom});var q=e.get("prefs"),h=q.block_color;_.each(f,function(r){if(!r){return}var u=a.append("g"),t=d3.svg.arc().innerRadius(i),s=u.selectAll("path").data(r).enter().append("path").attr("d",t).style("stroke",h).style("fill",h)})})}});var TrackBrowserRouter=Backbone.Router.extend({initialize:function(b){this.view=b.view;this.route(/([\w]+)$/,"change_location");this.route(/([\w]+\:[\d,]+-[\d,]+)$/,"change_location");var a=this;a.view.on("navigate",function(c){a.navigate(c)})},change_location:function(a){this.view.go_to(a)}});var add_datasets=function(a,c,b){$.ajax({url:a,data:{"f-dbkey":view.dbkey},error:function(){alert("Grid failed")},success:function(d){show_modal("Select datasets for new tracks",d,{Cancel:function(){hide_modal()},Add:function(){var e=[];$("input[name=id]:checked,input[name=ldda_ids]:checked").each(function(){var f,g=$(this).val();if($(this).attr("name")==="id"){f={hda_id:g}}else{f={ldda_id:g}}e[e.length]=$.ajax({url:c,data:f,dataType:"json"})});$.when.apply($,e).then(function(){var f=(arguments[0] instanceof Array?$.map(arguments,function(g){return g[0]}):[arguments[0]]);b(f)});hide_modal()}})}})}; \ No newline at end of file diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c static/scripts/viz/paramamonster.js --- a/static/scripts/viz/paramamonster.js +++ b/static/scripts/viz/paramamonster.js @@ -638,9 +638,9 @@ var vis = d3.select(this.$el[0]) .append("svg") .attr("width", this.width) - .attr("height", this.height + 20) + .attr("height", this.height + 30) .append("g") - .attr("transform", "translate(40, 10)"); + .attr("transform", "translate(40, 20)"); // Draw links. var link = vis.selectAll("path.link") @@ -703,6 +703,10 @@ this.model.get('tracks').each(function(track) { track.get('track').view = self; }); + + // Set block, reverse strand block colors; these colors will be used for all tracks. + this.block_color = get_random_color(); + this.reverse_strand_color = get_random_color( [ this.block_color, "#ffffff" ] ); }, render: function() { @@ -922,6 +926,11 @@ converted_datasets_state_url: galaxy_paths.get('dataset_state_url') }, output.first().get('track_config')), track_obj = object_from_template(track_config, self, null); + + // Set track block colors. + track_obj.prefs.block_color = self.block_color; + track_obj.prefs.reverse_strand_color = self.reverse_strand_color; + pm_track.set('track', track_obj); }); }, index * 10000); diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c static/scripts/viz/trackster.js --- a/static/scripts/viz/trackster.js +++ b/static/scripts/viz/trackster.js @@ -607,7 +607,7 @@ this.drawables = []; var drawable; for (var i = 0; i < drawables_array.length; i++) { - drawable = object_from_template(drawables_array[i], this); + drawable = object_from_template(drawables_array[i], this.view, this); this.add_drawable(drawable); } }, @@ -1413,10 +1413,10 @@ } view.change_chrom(chrom, new_low, new_high); }, - move_fraction : function( fraction ) { + move_fraction: function(fraction) { var view = this; var span = view.high - view.low; - this.move_delta( fraction * span ); + this.move_delta(fraction * span); }, move_delta: function(delta_chrom) { // Update low, high. @@ -2083,7 +2083,6 @@ // Set up slider for filter. var slider_div = $("<div/>").addClass("slider").appendTo(filter.parent_div); filter.control_element = $("<div/>").attr("id", filter.name + "-filter-control").appendTo(slider_div); - var prev_values = [0,0]; filter.control_element.slider({ range: true, min: this.min, @@ -2193,17 +2192,23 @@ * Handle slide events. */ slide: function(event, ui) { - var values = ui.values; + var values = ui.values; + + // Set new values in UI. + this.values_span.text(values[0] + "-" + values[1]); + + // Set new values in filter. + this.low = values[0]; + this.high = values[1]; - // Set new values in UI. - this.values_span.text(values[0] + "-" + values[1]); + // Set timeout to update if filter low, high are stable. + var self = this; + setTimeout(function() { + if (values[0] === self.low && values[1] === self.high) { + self.manager.track.request_draw(true, true); + } + }, 25); - // Set new values in filter. - this.low = values[0]; - this.high = values[1]; - - // Redraw track. - this.manager.track.request_draw(true, true); }, /** * Returns true if filter can be applied to element. @@ -3598,7 +3603,7 @@ var can_draw_now = true; // Get the track data, maybe a deferred - var tile_data = track.data_manager.get_data( region, track.mode, resolution, track.data_url_extra_params ); + var tile_data = track.data_manager.get_data(region, track.mode, resolution, track.data_url_extra_params); if ( is_deferred( tile_data ) ) { can_draw_now = false; } @@ -3657,6 +3662,7 @@ // Returned Deferred is resolved when tile can be drawn. return can_draw; }, + /** * Returns canvas height needed to display data; return value is an integer that denotes the * number of pixels required. @@ -3664,6 +3670,7 @@ get_canvas_height: function(result, mode, w_scale, canvas_width) { return this.visible_height_px; }, + /** * Draw a track tile. * @param result result from server @@ -3677,6 +3684,7 @@ draw_tile: function(result, ctx, mode, resolution, region, w_scale, ref_seq) { console.log("Warning: TiledTrack.draw_tile() not implemented."); }, + /** * Show track tile and perform associated actions. Showing tile may actually move * an existing tile rather than reshowing it. @@ -3711,11 +3719,24 @@ track.after_show_tile(tile); }, - + /** * Actions to be taken after showing tile. */ - after_show_tile: function(tile) {}, + after_show_tile: function(tile) { + // Update max height based on current tile. + this.max_height_px = Math.max(this.max_height_px, tile.html_elt.height()); + + // Update height for all tiles based on max height. + tile.html_elt.parent().children().css("height", this.max_height_px + "px"); + + // Update track height based on max height and visible height. + var track_height = this.max_height_px; + if (this.visible_height_px !== 0) { + track_height = Math.min(this.max_height_px, this.visible_height_px); + } + this.tiles_div.css("height", track_height + "px"); + }, /** * Returns a genome region that corresponds to a tile at a particular resolution @@ -3849,7 +3870,7 @@ var drawable; for (var i = 0; i < obj_dict.drawables.length; i++) { drawable = obj_dict.drawables[i]; - this.drawables[i] = object_from_template(drawable); + this.drawables[i] = object_from_template(drawable, view, null); // Track's left offset is the max of all tracks. if (drawable.left_offset > this.left_offset) { @@ -3928,9 +3949,7 @@ // FIXME: this function is similar to TiledTrack.draw_helper -- can the two be merged/refactored? var track = this, key = this._gen_tile_cache_key(width, w_scale, tile_index), - tile_bounds = this._get_tile_bounds(tile_index, resolution), - tile_low = tile_bounds.get('start'), - tile_high = tile_bounds.get('end'); + region = this._get_tile_bounds(tile_index, resolution); // Init kwargs if necessary to avoid having to check if kwargs defined. if (!kwargs) { kwargs = {}; } @@ -3952,7 +3971,7 @@ for (var i = 0; i < this.drawables.length; i++) { track = this.drawables[i]; // Get the track data, maybe a deferred. - tile_data = track.data_manager.get_data( tile_low, tile_high, track.mode, resolution, track.data_url_extra_params ); + tile_data = track.data_manager.get_data(region, track.mode, resolution, track.data_url_extra_params); if ( is_deferred( tile_data ) ) { can_draw_now = false; } @@ -3961,7 +3980,7 @@ // Get seq data if needed, maybe a deferred. seq_data = null; if ( view.reference_track && w_scale > view.canvas_manager.char_width_px ) { - seq_data = view.reference_track.data_manager.get_data(tile_low, tile_high, track.mode, resolution, view.reference_track.data_url_extra_params); + seq_data = view.reference_track.data_manager.get_data(region, track.mode, resolution, view.reference_track.data_url_extra_params); if ( is_deferred( seq_data ) ) { can_draw_now = false; } @@ -3979,8 +3998,8 @@ var canvas = track.view.canvas_manager.new_canvas(), tile_bounds = track._get_tile_bounds(tile_index, resolution), - tile_low = tile_bounds.get('start'), - tile_high = tile_bounds.get('end'), + tile_low = region.get('start'), + tile_high = region.get('end'), all_data_index = 0, width = Math.ceil( (tile_high - tile_low) * w_scale ) + this.left_offset, height = 0, @@ -4020,7 +4039,7 @@ track = this.drawables[i]; tile_data = all_data[ all_data_index ]; seq_data = all_data[ all_data_index + 1 ]; - tile = track.draw_tile(tile_data, ctx, track_modes[i], resolution, tile_bounds, w_scale, seq_data); + tile = track.draw_tile(tile_data, ctx, track_modes[i], resolution, region, w_scale, seq_data); } // Don't cache, show if no tile. @@ -4045,8 +4064,7 @@ */ show_group: function() { // Create group with individual tracks. - var - group = new DrawableGroup(this.view, this.container, { + var group = new DrawableGroup(this.view, this.container, { name: this.name }), track; @@ -4138,12 +4156,28 @@ }; extend(ReferenceTrack.prototype, Drawable.prototype, TiledTrack.prototype, { build_header_div: function() {}, + init: function() { this.data_manager.clear(); // Enable by default because there should always be data when drawing track. this.enabled = true; }, + can_draw: Drawable.prototype.can_draw, + + /** + * Only retrieves data and draws tile if reference data can be displayed. + */ + draw_helper: function(force, width, tile_index, resolution, parent_element, w_scale, kwargs) { + if (w_scale > this.view.canvas_manager.char_width_px) { + return TiledTrack.prototype.draw_helper.call(this, force, width, tile_index, resolution, parent_element, w_scale, kwargs); + } + else { + this.hide_contents(); + return null; + } + }, + /** * Draw ReferenceTrack tile. */ @@ -4390,23 +4424,6 @@ // Clear because this is set when drawing. this.max_height_px = 0; }, - /** - * Actions to be taken after showing tile. - */ - after_show_tile: function(tile) { - // Update max height based on current tile. - this.max_height_px = Math.max(this.max_height_px, tile.html_elt.height()); - - // Update height for all tiles based on max height. - tile.html_elt.parent().children().css("height", this.max_height_px + "px"); - - // Update track height based on max height and visible height. - var track_height = this.max_height_px; - if (this.visible_height_px !== 0) { - track_height = Math.min(this.max_height_px, this.visible_height_px); - } - this.tiles_div.css("height", track_height + "px"); - }, /** * Actions to be taken after draw has been completed. Draw is completed when all tiles have been diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c static/scripts/viz/visualization.js --- a/static/scripts/viz/visualization.js +++ b/static/scripts/viz/visualization.js @@ -564,7 +564,7 @@ if (!d || typeof d === 'string') { return 0; } return d[1]; }); - this.attributes.max = (max_data && typeof max_data !== 'string' ? max_data[1] : 0) + this.attributes.max = (max_data && typeof max_data !== 'string' ? max_data[1] : 0); } }); @@ -722,69 +722,74 @@ this.genome = options.genome; this.radius_start = options.radius_start; this.dataset_arc_height = options.dataset_arc_height; + this.track_gap = 5; }, render: function() { - // -- Layout viz. -- + var self = this, + dataset_arc_height = this.dataset_arc_height; - // FOR TESTING: - var dataset = this.model.get('tracks').at(0).get('genome_wide_data'); - - var radius_start = this.radius_start, - dataset_arc_height = this.dataset_arc_height, + // Set up SVG element. + var svg = d3.select(self.$el[0]) + .append("svg") + .attr("width", self.width) + .attr("height", self.height) + .append("g") + .attr("transform", "translate(" + self.width / 2 + "," + self.height / 2 + ")"); + + // -- Render each dataset in the visualization. -- + this.model.get('tracks').each(function(track, index) { + var dataset = track.get('genome_wide_data'); + + var radius_start = self.radius_start + index * (dataset_arc_height + self.track_gap), + // Layout chromosome arcs. + arcs_layout = new CircsterHistogramDatasetLayout({ + genome: self.genome, + total_gap: self.total_gap + }), + chrom_arcs = arcs_layout.chroms_layout(), + + // Merge chroms layout with data. + layout_and_data = _.zip(chrom_arcs, dataset.get('data')), + dataset_max = dataset.get('max'), + + // Do dataset layout for each chromosome's data using pie layout. + chroms_data_layout = _.map(layout_and_data, function(chrom_info) { + var chrom_arc = chrom_info[0], + chrom_data = chrom_info[1]; + return arcs_layout.chrom_data_layout(chrom_arc, chrom_data, radius_start, radius_start + dataset_arc_height, dataset_max); + }); - // Layout chromosome arcs. - arcs_layout = new CircsterHistogramDatasetLayout({ - genome: this.genome, - total_gap: this.total_gap - }), - chrom_arcs = arcs_layout.chroms_layout(), - - // Merge chroms layout with data. - layout_and_data = _.zip(chrom_arcs, dataset.get('data')), - dataset_max = dataset.get('max'), - - // Do dataset layout for each chromosome's data using pie layout. - chroms_data_layout = _.map(layout_and_data, function(chrom_info) { - var chrom_arc = chrom_info[0], - chrom_data = chrom_info[1]; - return arcs_layout.chrom_data_layout(chrom_arc, chrom_data, radius_start, radius_start + dataset_arc_height, dataset_max); + // -- Render. -- + + // Draw background arcs for each chromosome. + var base_arc = svg.append("g").attr("id", "inner-arc"), + arc_gen = d3.svg.arc() + .innerRadius(radius_start) + .outerRadius(radius_start + dataset_arc_height), + // Draw arcs. + chroms_elts = base_arc.selectAll("#inner-arc>path") + .data(chrom_arcs).enter().append("path") + .attr("d", arc_gen) + .style("stroke", "#ccc") + .style("fill", "#ccc") + .append("title").text(function(d) { return d.data.chrom; }); + + // For each chromosome, draw dataset. + var prefs = track.get('prefs'), + block_color = prefs.block_color; + _.each(chroms_data_layout, function(chrom_layout) { + if (!chrom_layout) { return; } + + var group = svg.append("g"), + arc_gen = d3.svg.arc().innerRadius(radius_start), + dataset_elts = group.selectAll("path") + .data(chrom_layout).enter().append("path") + .attr("d", arc_gen) + .style("stroke", block_color) + .style("fill", block_color); }); - - // -- Render viz. -- - - var svg = d3.select(this.$el[0]) - .append("svg") - .attr("width", this.width) - .attr("height", this.height) - .append("g") - .attr("transform", "translate(" + this.width / 2 + "," + this.height / 2 + ")"); - - // Draw background arcs for each chromosome. - var base_arc = svg.append("g").attr("id", "inner-arc"), - arc_gen = d3.svg.arc() - .innerRadius(radius_start) - .outerRadius(radius_start + dataset_arc_height), - // Draw arcs. - chroms_elts = base_arc.selectAll("#inner-arc>path") - .data(chrom_arcs).enter().append("path") - .attr("d", arc_gen) - .style("stroke", "#ccc") - .style("fill", "#ccc") - .append("title").text(function(d) { return d.data.chrom; }); - - // For each chromosome, draw dataset. - _.each(chroms_data_layout, function(chrom_layout) { - if (!chrom_layout) { return; } - - var group = svg.append("g"), - arc_gen = d3.svg.arc().innerRadius(radius_start), - dataset_elts = group.selectAll("path") - .data(chrom_layout).enter().append("path") - .attr("d", arc_gen) - .style("stroke", "red") - .style("fill", "red"); - }); + }); } }); diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c templates/admin/tool_shed_repository/common.mako --- a/templates/admin/tool_shed_repository/common.mako +++ b/templates/admin/tool_shed_repository/common.mako @@ -85,9 +85,14 @@ </div><div class="form-row"><label>Install tool dependencies?</label> - ${install_tool_dependencies_check_box.get_html()} + <% disabled = trans.app.config.tool_dependency_dir is None %> + ${install_tool_dependencies_check_box.get_html( disabled=disabled )} <div class="toolParamHelp" style="clear: both;"> - Un-check to skip automatic installation of these tool dependencies. + %if disabled: + Set the tool_dependency_dir configuration value in your universe_wsgi.ini to automatically install tool dependencies. + %else: + Un-check to skip automatic installation of these tool dependencies. + %endif </div></div><div style="clear: both"></div> diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c templates/admin/tool_shed_repository/reselect_tool_panel_section.mako --- a/templates/admin/tool_shed_repository/reselect_tool_panel_section.mako +++ b/templates/admin/tool_shed_repository/reselect_tool_panel_section.mako @@ -9,7 +9,7 @@ <div class="toolForm"><div class="toolFormTitle">Choose the tool panel section to contain the installed tools (optional)</div><div class="toolFormBody"> - <form name="reselect_tool_panel_section" id="reselect_tool_panel_section" action="${h.url_for( controller='admin_toolshed', action='reinstall_repository', id=trans.security.encode_id( repository.id ), repo_info_dict=repo_info_dict )}" method="post" > + <form name="reselect_tool_panel_section" id="reselect_tool_panel_section" action="${h.url_for( controller='admin_toolshed', action='reinstall_repository', id=trans.security.encode_id( repository.id ), repo_info_dict=encoded_repo_info_dict )}" method="post" ><div style="clear: both"></div> %if includes_tool_dependencies: ${render_tool_dependency_section( install_tool_dependencies_check_box, [ repo_info_dict ] )} diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c templates/admin/tool_shed_repository/select_tool_panel_section.mako --- a/templates/admin/tool_shed_repository/select_tool_panel_section.mako +++ b/templates/admin/tool_shed_repository/select_tool_panel_section.mako @@ -23,7 +23,7 @@ <br/><div class="toolForm"> - %if includes_tool_dependencies: + %if includes_tool_dependencies and trans.app.config.use_tool_dependencies: <div class="toolFormTitle">Confirm tool dependency installation</div> %else: <div class="toolFormTitle">Choose the tool panel section to contain the installed tools (optional)</div> @@ -31,7 +31,7 @@ <div class="toolFormBody"><form name="select_tool_panel_section" id="select_tool_panel_section" action="${h.url_for( controller='admin_toolshed', action='prepare_for_install', tool_shed_url=tool_shed_url, encoded_repo_info_dicts=encoded_repo_info_dicts, includes_tools=includes_tools, includes_tool_dependencies=includes_tool_dependencies )}" method="post" ><div style="clear: both"></div> - %if includes_tool_dependencies: + %if includes_tool_dependencies and trans.app.config.use_tool_dependencies: ${render_tool_dependency_section( install_tool_dependencies_check_box, repo_info_dicts )} <div style="clear: both"></div><div class="form-row"> diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c templates/tracks/browser.mako --- a/templates/tracks/browser.mako +++ b/templates/tracks/browser.mako @@ -113,6 +113,14 @@ // HACK -- use style to determine if panel is hidden and hide/show accordingly. parent.force_right_panel(($("div#right").css("right") == "0px" ? "hide" : "show")); } }, + { + icon_class: 'globe', + title: 'Circster', + on_click: function() { + // Add viz id dynamically so that newly saved visualizations work as well. + window.location = "${h.url_for( controller='tracks', action='circster' )}?id=" + view.vis_id; + } + }, { icon_class: 'disk--arrow', title: 'Save', on_click: function() { // Show saving dialog box show_modal("Saving...", "progress"); diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c templates/user/login.mako --- a/templates/user/login.mako +++ b/templates/user/login.mako @@ -53,6 +53,13 @@ ${render_openid_form( redirect, False, openid_providers )} %endif + %if trans.app.config.get( 'terms_url', None ) is not None: + <br/> + <p> + <a href="${trans.app.config.get('terms_url', None)}">Terms and Conditions for use of this service</a> + </p> + %endif + %endif </div> diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c templates/user/register.mako --- a/templates/user/register.mako +++ b/templates/user/register.mako @@ -19,6 +19,13 @@ ## But if the current user is not an admin user, then don't display the registration form. %if trans.user_is_admin() or not trans.user: ${render_registration_form()} + + %if trans.app.config.get( 'terms_url', None ) is not None: + <br/> + <p> + <a href="${trans.app.config.get('terms_url', None)}">Terms and Conditions for use of this service</a> + </p> + %endif %endif <%def name="render_registration_form( form_action=None )"> diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c templates/visualization/circster.mako --- a/templates/visualization/circster.mako +++ b/templates/visualization/circster.mako @@ -57,7 +57,6 @@ } } ]); - menu.render(); menu.$el.attr("style", "float: right"); $("#center .unified-panel-header-inner").append(menu.$el); // Manual tipsy config because default gravity is S and cannot be changed. @@ -71,11 +70,11 @@ width: 600, height: 600, // Gap is difficult to set because it very dependent on chromosome size and organization. - total_gap: 2 * Math.PI * 0.5, + total_gap: 2 * Math.PI * 0.2, genome: genome, model: visualization, radius_start: 100, - dataset_arc_height: 50 + dataset_arc_height: 15 }); // -- Render viz. -- @@ -89,7 +88,7 @@ <%def name="center_panel()"><div class="unified-panel-header" unselectable="on"><div class="unified-panel-header-inner"> - <div style="float:left;" id="title"></div> + <div style="float:left;" id="title">${viz_config[ 'title' ]} (${viz_config[ 'dbkey' ]})</div></div><div style="clear: both"></div></div> diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c templates/webapps/galaxy/base_panels.mako --- a/templates/webapps/galaxy/base_panels.mako +++ b/templates/webapps/galaxy/base_panels.mako @@ -129,6 +129,8 @@ [_('Video tutorials (screencasts)'), app.config.get( "screencasts_url", "http://galaxycast.org" ), "_blank" ], [_('How to Cite Galaxy'), app.config.get( "citation_url", "http://wiki.g2.bx.psu.edu/Citing%20Galaxy" ), "_blank" ] ] + if app.config.get( 'terms_url', None ) is not None: + menu_options.append( [_('Terms and Conditions'), app.config.get( 'terms_url', None ), '_blank'] ) tab( "help", _("Help"), None, menu_options=menu_options) %> diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c tool_conf.xml.main --- a/tool_conf.xml.main +++ b/tool_conf.xml.main @@ -208,7 +208,6 @@ <tool file="phenotype_association/lps.xml" /><tool file="phenotype_association/hilbertvis.xml" /><tool file="phenotype_association/freebayes.xml" /> - <tool file="variant_detection/freebayes.xml" /><tool file="phenotype_association/master2pg.xml" /><tool file="phenotype_association/vcf2pgSnp.xml" /><tool file="phenotype_association/dividePgSnpAlleles.xml" /> @@ -319,9 +318,6 @@ <tool file="indels/indel_sam2interval.xml" /><tool file="indels/indel_analysis.xml" /></section> - <section name="NGS: Variant Detection" id="variant_detection"> - <tool file="variant_detection/freebayes.xml" /> - </section><section name="NGS: Peak Calling" id="peak_calling"><tool file="peak_calling/macs_wrapper.xml" /><tool file="peak_calling/sicer_wrapper.xml" /> diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c tool_conf.xml.sample --- a/tool_conf.xml.sample +++ b/tool_conf.xml.sample @@ -478,7 +478,6 @@ <tool file="phenotype_association/lps.xml" /><tool file="phenotype_association/hilbertvis.xml" /><tool file="phenotype_association/freebayes.xml" /> - <tool file="variant_detection/freebayes.xml" /><tool file="phenotype_association/master2pg.xml" /><tool file="phenotype_association/vcf2pgSnp.xml" /><tool file="phenotype_association/dividePgSnpAlleles.xml" /> diff -r c1e85a294a6eafbe60285f5e2277596647b1474b -r 58c24c93bc9a68285bdc035af36116d44292403c universe_wsgi.ini.sample --- a/universe_wsgi.ini.sample +++ b/universe_wsgi.ini.sample @@ -259,6 +259,10 @@ # The URL linked by the "How to Cite..." link in the "Help" menu. #citation_url = http://wiki.g2.bx.psu.edu/Citing%20Galaxy +# The URL linked by the "Terms and Conditions" link in the "Help" menu, as well +# as on the user registration and login forms. +#terms_url = None + # Serve static content, which must be enabled if you're not serving it via a # proxy server. These options should be self explanatory and so are not # documented individually. You can use these paths (or ones in the proxy 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.
participants (1)
-
Bitbucket