galaxy-commits
Threads by month
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
January 2012
- 1 participants
- 95 discussions
commit/galaxy-central: jgoecks: Update functional tests to be compatible with 0d1d62b8be2e
by Bitbucket 17 Jan '12
by Bitbucket 17 Jan '12
17 Jan '12
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/changeset/6b635cb8191d/
changeset: 6b635cb8191d
user: jgoecks
date: 2012-01-17 15:05:11
summary: Update functional tests to be compatible with 0d1d62b8be2e
affected #: 2 files
diff -r 2272101e8c292bd33e78cdcee37bac4a62cd5cb4 -r 6b635cb8191d0ce91e60f8e2cc5ec1606b1c1720 test/base/twilltestcase.py
--- a/test/base/twilltestcase.py
+++ b/test/base/twilltestcase.py
@@ -831,12 +831,12 @@
previously_created = True
except:
try:
- self.check_page_for_string( 'This user name is not available' )
+ self.check_page_for_string( 'Public name is taken; please choose another' )
username_taken = True
except:
try:
# Note that we're only checking if the usr name is >< 4 chars here...
- self.check_page_for_string( 'User name must be at least 4 characters in length' )
+ self.check_page_for_string( 'Public name must be at least 4 characters in length' )
invalid_username = True
except:
pass
@@ -1218,12 +1218,12 @@
previously_created = True
except:
try:
- self.check_page_for_string( 'This user name is not available' )
+ self.check_page_for_string( 'Public name is taken; please choose another' )
username_taken = True
except:
try:
# Note that we're only checking if the usr name is >< 4 chars here...
- self.check_page_for_string( 'User name must be at least 4 characters in length' )
+ self.check_page_for_string( 'Public name must be at least 4 characters in length' )
invalid_username = True
except:
pass
diff -r 2272101e8c292bd33e78cdcee37bac4a62cd5cb4 -r 6b635cb8191d0ce91e60f8e2cc5ec1606b1c1720 test/functional/test_admin_features.py
--- a/test/functional/test_admin_features.py
+++ b/test/functional/test_admin_features.py
@@ -32,7 +32,7 @@
webapp='galaxy',
referer='' )
if not username_taken:
- raise AssertionError, "The user name (%s) is already being used by another user, but no error was displayed" \
+ raise AssertionError, "The public name (%s) is already being used by another user, but no error was displayed" \
% 'admin-user'
# Test setting the user name to an invalid one. Note that the account must not exist in order
# for this test to work as desired, so the email we're passing is important...
@@ -42,7 +42,7 @@
webapp='galaxy',
referer='' )
if not invalid_username:
- raise AssertionError, "The user name (%s) is is invalid, but no error was displayed" % username
+ raise AssertionError, "The public name (%s) is is invalid, but no error was displayed" % username
previously_created, username_taken, invalid_username = self.create_new_account_as_admin( email=email,
password=password,
username='regular-user3',
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/galaxy-central: jgoecks: Subset GFF datasets correctly when running tools in Trackster.
by Bitbucket 17 Jan '12
by Bitbucket 17 Jan '12
17 Jan '12
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/changeset/2272101e8c29/
changeset: 2272101e8c29
user: jgoecks
date: 2012-01-17 04:40:13
summary: Subset GFF datasets correctly when running tools in Trackster.
affected #: 1 file
diff -r ec85ba64a5b751f53c2288fdbd27ae228a8d89c3 -r 2272101e8c292bd33e78cdcee37bac4a62cd5cb4 lib/galaxy/visualization/tracks/data_providers.py
--- a/lib/galaxy/visualization/tracks/data_providers.py
+++ b/lib/galaxy/visualization/tracks/data_providers.py
@@ -857,7 +857,7 @@
reader = GFFReaderWrapper( source, fix_strand=True )
feature = reader.next()
for interval in feature.intervals:
- out.write(interval.raw_line + '\n')
+ out.write( '\t'.join( interval.fields ) + '\n' )
out.close()
def get_iterator( self, chrom, start, end ):
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/galaxy-central: jgoecks: Trackster: true replacement of a track with a group when running a tool.
by Bitbucket 16 Jan '12
by Bitbucket 16 Jan '12
16 Jan '12
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/changeset/ec85ba64a5b7/
changeset: ec85ba64a5b7
user: jgoecks
date: 2012-01-16 23:36:04
summary: Trackster: true replacement of a track with a group when running a tool.
affected #: 1 file
diff -r a5703335e20544613416329c2fbd2a5c7af965e4 -r ec85ba64a5b751f53c2288fdbd27ae228a8d89c3 static/scripts/trackster.js
--- a/static/scripts/trackster.js
+++ b/static/scripts/trackster.js
@@ -974,9 +974,8 @@
if (update_html) {
old_drawable.container_div.replaceWith(new_drawable.container_div);
}
- return true;
- }
- return false;
+ }
+ return index;
},
/**
* Remove drawable from this collection.
@@ -1839,18 +1838,13 @@
// Create new group.
var group = new DrawableGroup(this.name, this.track.view);
+ // Replace track with group.
+ var index = current_track.container.replace_drawable(current_track, group, false);
+
+ // Update HTML.
// FIXME: this is ugly way to replace a track with a group -- make this easier via
// a Drawable or DrawableCollection function.
- // NOTE: doing this:
- // current_track.container.replace_drawable(current_track, group, true);
- // causes problems with sliders, so it's not used right now.
-
- // Add group to view.
- current_track.view.add_drawable(group);
- current_track.view.content_div.append(group.container_div);
-
- // Move track from view to group.
- current_track.container.remove_drawable(current_track);
+ group.container_div.insertBefore(current_track.view.content_div.children()[index]);
group.add_drawable(current_track);
current_track.container_div.appendTo(group.content_div);
container = group;
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/galaxy-central: natefoo: Avoid annoying errors produced by the Googlebot hitting the import library datasets to history page (it doesn't have a history).
by Bitbucket 16 Jan '12
by Bitbucket 16 Jan '12
16 Jan '12
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/changeset/a8b733b58fec/
changeset: a8b733b58fec
user: natefoo
date: 2012-01-16 18:38:03
summary: Avoid annoying errors produced by the Googlebot hitting the import library datasets to history page (it doesn't have a history).
affected #: 1 file
diff -r 096f4040e90d3516c8ad6093f4e2fcd618c43f6b -r a8b733b58fec15f2aa664eb2b3f7e72e10b622bc lib/galaxy/web/controllers/library_common.py
--- a/lib/galaxy/web/controllers/library_common.py
+++ b/lib/galaxy/web/controllers/library_common.py
@@ -1956,7 +1956,12 @@
# to the lddas in order for the menu optin to be available.
ldda = trans.sa_session.query( trans.model.LibraryDatasetDatasetAssociation ).get( ldda_id )
source_lddas.append( ldda )
- target_histories = [ current_history ]
+ if current_history is not None:
+ target_histories = [ current_history ]
+ else:
+ target_histories = []
+ message = 'You must have a history before you can import datasets. You can do this by <a href="%s" target="_top">loading the analysis interface</a>.' % url_for(controller='root')
+ status = 'error'
if user:
target_histories = user.active_histories
if action == 'import_to_current_history' and library_id:
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/galaxy-central: natefoo: Filesystem free space checking for the object store.
by Bitbucket 16 Jan '12
by Bitbucket 16 Jan '12
16 Jan '12
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/changeset/096f4040e90d/
changeset: 096f4040e90d
user: natefoo
date: 2012-01-16 18:04:45
summary: Filesystem free space checking for the object store.
affected #: 5 files
diff -r d3b6789cbc90c65ca78a5205547a1b6d4bc39064 -r 096f4040e90d3516c8ad6093f4e2fcd618c43f6b lib/galaxy/jobs/__init__.py
--- a/lib/galaxy/jobs/__init__.py
+++ b/lib/galaxy/jobs/__init__.py
@@ -9,6 +9,7 @@
from galaxy.util.json import from_json_string
from galaxy.util.expressions import ExpressionContext
from galaxy.jobs.actions.post import ActionBox
+from galaxy.exceptions import ObjectInvalid
from sqlalchemy.sql.expression import and_, or_
@@ -321,9 +322,12 @@
# directory to be set before prepare is run, or else premature deletion
# and job recovery fail.
# Create the working dir if necessary
- self.app.object_store.create(job, base_dir='job_work', dir_only=True, extra_dir=str(self.job_id))
- self.working_directory = self.app.object_store.get_filename(job, base_dir='job_work', dir_only=True, extra_dir=str(self.job_id))
- log.debug('(%s) Working directory for job is: %s' % (self.job_id, self.working_directory))
+ try:
+ self.app.object_store.create(job, base_dir='job_work', dir_only=True, extra_dir=str(self.job_id))
+ self.working_directory = self.app.object_store.get_filename(job, base_dir='job_work', dir_only=True, extra_dir=str(self.job_id))
+ log.debug('(%s) Working directory for job is: %s' % (self.job_id, self.working_directory))
+ except ObjectInvalid:
+ raise Exception('Unable to create job working directory, job failure')
self.output_paths = None
self.output_dataset_paths = None
self.tool_provided_job_metadata = None
diff -r d3b6789cbc90c65ca78a5205547a1b6d4bc39064 -r 096f4040e90d3516c8ad6093f4e2fcd618c43f6b lib/galaxy/objectstore/__init__.py
--- a/lib/galaxy/objectstore/__init__.py
+++ b/lib/galaxy/objectstore/__init__.py
@@ -8,6 +8,7 @@
import time
import random
import shutil
+import statvfs
import logging
import threading
import subprocess
@@ -40,7 +41,6 @@
def shutdown(self):
self.running = False
- self.extra_dirs = {}
def exists(self, obj, base_dir=None, dir_only=False, extra_dir=None, extra_dir_at_root=False, alt_name=None):
"""
@@ -170,6 +170,12 @@
See `exists` method for the description of the fields.
"""
raise NotImplementedError()
+
+ def get_store_usage_percent(self):
+ """
+ Return the percentage indicating how full the store is
+ """
+ raise NotImplementedError()
## def get_staging_command( id ):
## """
@@ -342,6 +348,9 @@
def get_object_url(self, obj, **kwargs):
return None
+ def get_store_usage_percent(self):
+ st = os.statvfs(self.file_path)
+ return (float(st.f_blocks - st.f_bavail)/st.f_blocks) * 100
class CachingObjectStore(ObjectStore):
@@ -831,6 +840,9 @@
log.warning("Trouble generating URL for dataset '%s': %s" % (rel_path, ex))
return None
+ def get_store_usage_percent(self):
+ return 0.0
+
class DistributedObjectStore(ObjectStore):
"""
@@ -847,18 +859,29 @@
"'distributed_object_store_config_file')"
self.backends = {}
self.weighted_backend_ids = []
+ self.original_weighted_backend_ids = []
+ self.max_percent_full = {}
+ self.global_max_percent_full = 0.0
random.seed()
self.__parse_distributed_config(config)
+ if self.global_max_percent_full or filter(lambda x: x is not None, self.max_percent_full.values()):
+ self.sleeper = Sleeper()
+ self.filesystem_monitor_thread = threading.Thread(target=self.__filesystem_monitor)
+ self.filesystem_monitor_thread.start()
+ log.info("Filesystem space monitor started")
+
def __parse_distributed_config(self, config):
tree = util.parse_xml(self.distributed_config)
root = tree.getroot()
log.debug('Loading backends for distributed object store from %s' % self.distributed_config)
+ self.global_max_percent_full = float(root.get('maxpctfull', 0))
for elem in [ e for e in root if e.tag == 'backend' ]:
id = elem.get('id')
weight = int(elem.get('weight', 1))
+ maxpctfull = float(elem.get('maxpctfull', 0))
if elem.get('type', 'disk'):
path = None
extra_dirs = {}
@@ -869,6 +892,7 @@
type = sub.get('type')
extra_dirs[type] = sub.get('path')
self.backends[id] = DiskObjectStore(config, file_path=path, extra_dirs=extra_dirs)
+ self.max_percent_full[id] = maxpctfull
log.debug("Loaded disk backend '%s' with weight %s and file_path: %s" % (id, weight, path))
if extra_dirs:
log.debug(" Extra directories:")
@@ -879,13 +903,26 @@
# sequence the number of times equalling weight, then randomly
# choose a backend from that sequence at creation
self.weighted_backend_ids.append(id)
+ self.original_weighted_backend_ids = self.weighted_backend_ids
+
+ def __filesystem_monitor(self):
+ while self.running:
+ new_weighted_backend_ids = self.original_weighted_backend_ids
+ for id, backend in self.backends.items():
+ maxpct = self.max_percent_full[id] or self.global_max_percent_full
+ pct = backend.get_store_usage_percent()
+ if pct > maxpct:
+ new_weighted_backend_ids = filter(lambda x: x != id, new_weighted_backend_ids)
+ self.weighted_backend_ids = new_weighted_backend_ids
+ self.sleeper.sleep(120) # Test free space every 2 minutes
+
+ def shutdown(self):
+ super(DistributedObjectStore, self).shutdown()
+ self.sleeper.wake()
def exists(self, obj, **kwargs):
return self.__call_method('exists', obj, False, False, **kwargs)
- #def store_id(self, obj, **kwargs):
- # return self.__get_store_id_for(obj, **kwargs)[0]
-
def file_ready(self, obj, **kwargs):
return self.__call_method('file_ready', obj, False, False, **kwargs)
@@ -894,8 +931,11 @@
create() is the only method in which obj.object_store_id may be None
"""
if obj.object_store_id is None or not self.exists(obj, **kwargs):
- if obj.object_store_id is None or obj.object_store_id not in self.backends:
- obj.object_store_id = random.choice(self.weighted_backend_ids)
+ if obj.object_store_id is None or obj.object_store_id not in self.weighted_backend_ids:
+ try:
+ obj.object_store_id = random.choice(self.weighted_backend_ids)
+ except IndexError:
+ raise ObjectInvalid()
object_session( obj ).add( obj )
object_session( obj ).flush()
log.debug("Selected backend '%s' for creation of %s %s" % (obj.object_store_id, obj.__class__.__name__, obj.id))
diff -r d3b6789cbc90c65ca78a5205547a1b6d4bc39064 -r 096f4040e90d3516c8ad6093f4e2fcd618c43f6b lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -1142,7 +1142,11 @@
return "tool_form.mako", dict( errors=errors, tool_state=state, incoming=incoming, error_message=error_message )
# If we've completed the last page we can execute the tool
elif state.page == self.last_page:
- _, out_data = self.execute( trans, incoming=params, history=history )
+ try:
+ _, out_data = self.execute( trans, incoming=params, history=history )
+ except Exception, e:
+ log.exception('Exception caught while attempting tool execution:')
+ return 'message.mako', dict( status='error', message='Error executing tool: %s' % str(e), refresh_frames=[] )
try:
assert isinstance( out_data, odict )
return 'tool_executed.mako', dict( out_data=out_data )
diff -r d3b6789cbc90c65ca78a5205547a1b6d4bc39064 -r 096f4040e90d3516c8ad6093f4e2fcd618c43f6b lib/galaxy/tools/actions/__init__.py
--- a/lib/galaxy/tools/actions/__init__.py
+++ b/lib/galaxy/tools/actions/__init__.py
@@ -6,6 +6,7 @@
from galaxy.util.template import fill_template
from galaxy.util.none_like import NoneDataset
from galaxy.web import url_for
+from galaxy.exceptions import ObjectInvalid
import galaxy.tools
from types import *
@@ -295,7 +296,10 @@
# created in the "default" store, all others will be created in
# the same store as the first.
data.dataset.object_store_id = object_store_id
- trans.app.object_store.create( data.dataset )
+ try:
+ trans.app.object_store.create( data.dataset )
+ except ObjectInvalid:
+ raise Exception('Unable to create output dataset: object store is full')
object_store_id = data.dataset.object_store_id # these will be the same thing after the first output
# This may not be neccesary with the new parent/child associations
data.designation = name
diff -r d3b6789cbc90c65ca78a5205547a1b6d4bc39064 -r 096f4040e90d3516c8ad6093f4e2fcd618c43f6b lib/galaxy/tools/actions/upload_common.py
--- a/lib/galaxy/tools/actions/upload_common.py
+++ b/lib/galaxy/tools/actions/upload_common.py
@@ -5,6 +5,7 @@
from galaxy.datatypes import sniff
from galaxy.util.json import to_json_string
from galaxy.model.orm import eagerload_all
+from galaxy.exceptions import ObjectInvalid
import logging
log = logging.getLogger( __name__ )
@@ -328,7 +329,10 @@
# Create an empty file immediately
if not dataset.dataset.external_filename:
dataset.dataset.object_store_id = object_store_id
- trans.app.object_store.create( dataset.dataset )
+ try:
+ trans.app.object_store.create( dataset.dataset )
+ except ObjectInvalid:
+ raise Exception('Unable to create output dataset: object store is full')
object_store_id = dataset.dataset.object_store_id
trans.sa_session.add( dataset )
# open( dataset.file_name, "w" ).close()
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
16 Jan '12
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/changeset/b36526f8edbc/
changeset: b36526f8edbc
user: greg
date: 2012-01-16 16:43:33
summary: Fix for reloading a tool in the tool panel - make sure to keep the tool's tool shed related attributes when the tool is reloaded. Also make sure to send the guid attribute when loading a tool into the tool panel if the tool is contained in an installed tool shed repository.
affected #: 3 files
diff -r e2ac92093afda6743ea68766be96c9c7a454568d -r b36526f8edbc2776225b5b9a8da7657771186025 lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -163,6 +163,7 @@
tool.repository_name = repository_name
tool.repository_owner = repository_owner
tool.installed_changeset_revision = installed_changeset_revision
+ tool.guid = guid
tool.old_id = elem.find( "id" ).text
tool.version = elem.find( "version" ).text
if self.app.config.get_bool( 'enable_tool_tags', False ):
@@ -261,6 +262,15 @@
else:
old_tool = self.tools_by_id[ tool_id ]
new_tool = self.load_tool( old_tool.config_file )
+ # The tool may have been installed from a tool shed, so set the tool shed attributes.
+ # Since the tool version may have changed, we don't override it here.
+ new_tool.id = old_tool.id
+ new_tool.guid = old_tool.guid
+ new_tool.tool_shed = old_tool.tool_shed
+ new_tool.repository_name = old_tool.repository_name
+ new_tool.repository_owner = old_tool.repository_owner
+ new_tool.installed_changeset_revision = old_tool.installed_changeset_revision
+ new_tool.old_id = old_tool.old_id
# Replace old_tool with new_tool in self.tool_panel
tool_key = 'tool_' + tool_id
for key, val in self.tool_panel.items():
@@ -268,11 +278,9 @@
self.tool_panel[ key ] = new_tool
break
elif key.startswith( 'section' ):
- section = val
- for section_key, section_val in section.elems.items():
- if section_key == tool_key:
- self.tool_panel[ key ].elems[ section_key ] = new_tool
- break
+ if tool_key in val.elems:
+ self.tool_panel[ key ].elems[ tool_key ] = new_tool
+ break
self.tools_by_id[ tool_id ] = new_tool
message = "Reloaded the tool:<br/>"
message += "<b>name:</b> %s<br/>" % old_tool.name
@@ -462,18 +470,19 @@
self.repository_name = None
self.repository_owner = None
self.installed_changeset_revision = None
+ # The tool.id value will be the value of guid, but we'll keep the
+ # guid attribute since it is useful to have.
+ self.guid = guid
self.old_id = None
self.version = None
# Parse XML element containing configuration
self.parse( root, guid=guid )
-
@property
def sa_session( self ):
"""
Returns a SQLAlchemy session
"""
return self.app.model.context
-
def parse( self, root, guid=None ):
"""
Read tool configuration from the element `root` and fill in `self`.
@@ -625,7 +634,6 @@
self.trackster_conf = TracksterConfig.parse( trackster_conf )
else:
self.trackster_conf = None
-
def parse_inputs( self, root ):
"""
Parse the "<inputs>" element and create appropriate `ToolParameter`s.
@@ -683,7 +691,6 @@
if not isinstance( param, ( HiddenToolParameter, BaseURLToolParameter ) ):
self.input_required = True
break
-
def parse_help( self, root ):
"""
Parse the help text for the tool. Formatted in reStructuredText.
@@ -715,7 +722,6 @@
# Pad out help pages to match npages ... could this be done better?
while len( self.help_by_page ) < self.npages:
self.help_by_page.append( self.help )
-
def parse_outputs( self, root ):
"""
Parse <outputs> elements and fill in self.outputs (keyed by name)
@@ -739,7 +745,6 @@
output.tool = self
output.actions = ToolOutputActionGroup( output, data_elem.find( 'actions' ) )
self.outputs[ output.name ] = output
-
def parse_tests( self, tests_elem ):
"""
Parse any "<test>" elements, create a `ToolTestBuilder` for each and
@@ -853,7 +858,6 @@
test.error = True
test.exception = e
self.tests.append( test )
-
def parse_input_page( self, input_elem, enctypes ):
"""
Parse a page of inputs. This basically just calls 'parse_input_elem',
@@ -868,7 +872,6 @@
else:
display = None
return display, inputs
-
def parse_input_elem( self, parent_elem, enctypes, context=None ):
"""
Parse a parent element whose children are inputs -- these could be
@@ -960,7 +963,6 @@
param.ref_input = context[ param.data_ref ]
self.input_params.append( param )
return rval
-
def parse_param_elem( self, input_elem, enctypes, context ):
"""
Parse a single "<param>" element and return a ToolParameter instance.
@@ -976,7 +978,6 @@
for name in param.get_dependencies():
context[ name ].refresh_on_change = True
return param
-
def parse_requirements( self, requirements_elem ):
"""
Parse each requirement from the <requirements> element and add to
@@ -999,7 +1000,6 @@
method = None
requirement = ToolRequirement( name=name, type=type, version=version, fabfile=fabfile, method=method )
self.requirements.append( requirement )
-
def check_workflow_compatible( self ):
"""
Determine if a tool can be used in workflows. External tools and the
@@ -1020,7 +1020,6 @@
# TODO: Anyway to capture tools that dynamically change their own
# outputs?
return True
-
def new_state( self, trans, all_pages=False ):
"""
Create a new `DefaultToolState` for this tool. It will be initialized
@@ -1037,7 +1036,6 @@
inputs = self.inputs_by_page[ 0 ]
self.fill_in_new_state( trans, inputs, state.inputs )
return state
-
def fill_in_new_state( self, trans, inputs, state, context=None ):
"""
Fill in a tool state dictionary with default values for all parameters
@@ -1046,7 +1044,6 @@
context = ExpressionContext( state, context )
for input in inputs.itervalues():
state[ input.name ] = input.get_initial_value( trans, context )
-
def get_param_html_map( self, trans, page=0, other_values={} ):
"""
Return a dictionary containing the HTML representation of each
@@ -1062,14 +1059,12 @@
raise Exception( "'get_param_html_map' only supported for simple paramters" )
rval[key] = param.get_html( trans, other_values=other_values )
return rval
-
def get_param( self, key ):
"""
Returns the parameter named `key` or None if there is no such
parameter.
"""
return self.inputs.get( key, None )
-
def get_hook(self, name):
"""
Returns an object from the code file referenced by `code_namespace`
@@ -1082,7 +1077,6 @@
elif name in self.code_namespace:
return self.code_namespace[name]
return None
-
def visit_inputs( self, value, callback ):
"""
Call the function `callback` on each parameter of this tool. Visits
@@ -1099,7 +1093,6 @@
callback( "", input, value[input.name] )
else:
input.visit_inputs( "", value[input.name], callback )
-
def handle_input( self, trans, incoming, history=None ):
"""
Process incoming parameters for this tool from the dict `incoming`,
@@ -1177,7 +1170,6 @@
pass
# Just a refresh, render the form with updated state and errors.
return 'tool_form.mako', dict( errors=errors, tool_state=state )
-
def find_fieldstorage( self, x ):
if isinstance( x, FieldStorage ):
raise InterruptedUpload( None )
@@ -1185,7 +1177,6 @@
[ self.find_fieldstorage( y ) for y in x.values() ]
elif type( x ) is types.ListType:
[ self.find_fieldstorage( y ) for y in x ]
-
def handle_interrupted( self, trans, inputs ):
"""
Upon handling inputs, if it appears that we have received an incomplete
@@ -1216,7 +1207,6 @@
return 'message.mako', dict( status='error',
message='Your upload was interrupted. If this was uninentional, please retry it.',
refresh_frames=[], cont=None )
-
def update_state( self, trans, inputs, state, incoming, prefix="", context=None,
update_only=False, old_errors={}, item_callback=None ):
"""
@@ -1458,7 +1448,6 @@
else:
raise Exception( "Unexpected parameter type" )
return args
-
def execute( self, trans, incoming={}, set_output_hid=True, history=None, **kwargs ):
"""
Execute the tool using parameter values in `incoming`. This just
@@ -1467,13 +1456,10 @@
when run will build the tool's outputs, e.g. `DefaultToolAction`.
"""
return self.tool_action.execute( self, trans, incoming=incoming, set_output_hid=set_output_hid, history=history, **kwargs )
-
def params_to_strings( self, params, app ):
return params_to_strings( self.inputs, params, app )
-
def params_from_strings( self, params, app, ignore_errors=False ):
return params_from_strings( self.inputs, params, app, ignore_errors )
-
def check_and_update_param_values( self, values, trans ):
"""
Check that all parameters have values, and fill in with default
@@ -1483,7 +1469,6 @@
messages = {}
self.check_and_update_param_values_helper( self.inputs, values, trans, messages )
return messages
-
def check_and_update_param_values_helper( self, inputs, values, trans, messages, context=None, prefix="" ):
"""
Recursive helper for `check_and_update_param_values_helper`
@@ -1529,7 +1514,6 @@
else:
# Regular tool parameter, no recursion needed
pass
-
def handle_unvalidated_param_values( self, input_values, app ):
"""
Find any instances of `UnvalidatedValue` within input_values and
@@ -1540,7 +1524,6 @@
if not self.check_values:
return
self.handle_unvalidated_param_values_helper( self.inputs, input_values, app )
-
def handle_unvalidated_param_values_helper( self, inputs, input_values, app, context=None, prefix="" ):
"""
Recursive helper for `handle_unvalidated_param_values`
@@ -1582,7 +1565,6 @@
% ( prefix, input.label, e )
raise LateValidationError( message )
input_values[ input.name ] = value
-
def handle_job_failure_exception( self, e ):
"""
Called by job.fail when an exception is generated to allow generation
@@ -1594,7 +1576,6 @@
if isinstance( e, LateValidationError ):
message = e.message
return message
-
def build_param_dict( self, incoming, input_datasets, output_datasets, output_paths, job_working_directory ):
"""
Build the dictionary of parameters for substituting into the command
@@ -1734,7 +1715,6 @@
param_dict['__datatypes_config__'] = param_dict['GALAXY_DATATYPES_CONF_FILE'] = self.app.datatypes_registry.integrated_datatypes_configs
# Return the dictionary of parameters
return param_dict
-
def build_param_file( self, param_dict, directory=None ):
"""
Build temporary file for file based parameter transfer if needed
@@ -1754,7 +1734,6 @@
return param_filename
else:
return None
-
def build_config_files( self, param_dict, directory=None ):
"""
Build temporary file for file based parameter transfer if needed
@@ -1775,7 +1754,6 @@
param_dict[name] = config_filename
config_filenames.append( config_filename )
return config_filenames
-
def build_command_line( self, param_dict ):
"""
Build command line to invoke this tool given a populated param_dict
@@ -1799,7 +1777,6 @@
command_line = command_line.replace(executable, abs_executable, 1)
command_line = self.interpreter + " " + command_line
return command_line
-
def build_dependency_shell_commands( self ):
"""
Return a list of commands to be run to populate the current
@@ -1820,7 +1797,6 @@
else:
commands.append( 'PACKAGE_BASE=%s; export PACKAGE_BASE; . %s' % ( base_path, script_file ) )
return commands
-
def build_redirect_url_params( self, param_dict ):
"""
Substitute parameter values into self.redirect_url_params
@@ -1833,7 +1809,6 @@
# Remove newlines
redirect_url_params = redirect_url_params.replace( "\n", " " ).replace( "\r", " " )
return redirect_url_params
-
def parse_redirect_url( self, data, param_dict ):
"""
Parse the REDIRECT_URL tool param. Tools that send data to an external
@@ -1873,7 +1848,6 @@
USERNAME = 'Anonymous'
redirect_url += "&USERNAME=%s" % USERNAME
return redirect_url
-
def call_hook( self, hook_name, *args, **kwargs ):
"""
Call the custom code hook function identified by 'hook_name' if any,
@@ -1886,19 +1860,15 @@
except Exception, e:
e.args = ( "Error in '%s' hook '%s', original message: %s" % ( self.name, hook_name, e.args[0] ) )
raise
-
def exec_before_job( self, app, inp_data, out_data, param_dict={} ):
pass
-
def exec_after_process( self, app, inp_data, out_data, param_dict, job = None ):
pass
-
def job_failed( self, job_wrapper, message, exception = False ):
"""
Called when a job has failed
"""
pass
-
def collect_associated_files( self, output, job_working_directory ):
"""
Find extra files in the job working directory and move them into
@@ -1922,7 +1892,6 @@
shutil.rmtree(temp_file_path)
except:
continue
-
def collect_child_datasets( self, output):
"""
Look for child dataset files, create HDA and attach to parent.
@@ -1983,7 +1952,6 @@
self.sa_session.add( child_dataset )
self.sa_session.flush()
return children
-
def collect_primary_datasets( self, output):
"""
Find any additional datasets generated by a tool and attach (for
@@ -2062,12 +2030,10 @@
def _build_GALAXY_URL_parameter( self ):
return ToolParameter.build( self, ElementTree.XML( '<param name="GALAXY_URL" type="baseurl" value="/tool_runner?tool_id=%s" />' % self.id ) )
-
def parse_inputs( self, root ):
Tool.parse_inputs( self, root )
if 'GALAXY_URL' not in self.inputs:
self.inputs[ 'GALAXY_URL' ] = self._build_GALAXY_URL_parameter()
-
def _prepare_datasource_json_list( self, param_list ):
rval = []
for value in param_list:
@@ -2088,7 +2054,6 @@
else:
rval[ key ] = str( value )
return rval
-
def exec_before_job( self, app, inp_data, out_data, param_dict=None ):
if param_dict is None:
param_dict = {}
@@ -2111,7 +2076,6 @@
cur_dbkey = param_dict.get( cur_base_param_name + 'dkey', dbkey )
cur_info = param_dict.get( cur_base_param_name + 'info', info )
cur_data_type = param_dict.get( cur_base_param_name + 'data_type', data_type )
-
if cur_name:
data.name = cur_name
if not data.info and cur_info:
@@ -2122,16 +2086,13 @@
data.extension = cur_data_type
file_name = str( wrapped_data )
extra_files_path = str( wrapped_data.files_path )
-
data_dict = dict( out_data_name = out_name,
ext = data.ext,
dataset_id = data.dataset.id,
hda_id = data.id,
file_name = file_name,
extra_files_path = extra_files_path )
-
json_params[ 'output_data' ].append( data_dict )
-
if json_filename is None:
json_filename = file_name
out = open( json_filename, 'w' )
@@ -2176,7 +2137,6 @@
dataset.set_peek()
self.sa_session.add( dataset )
self.sa_session.flush()
-
def job_failed( self, job_wrapper, message, exception = False ):
job = job_wrapper.sa_session.query( model.Job ).get( job_wrapper.job_id )
if job:
@@ -2334,19 +2294,16 @@
self.dataset = dataset
self.metadata = self.MetadataWrapper( dataset.metadata )
self.false_path = false_path
-
def __str__( self ):
if self.false_path is not None:
return self.false_path
else:
return self.dataset.file_name
-
def __getattr__( self, key ):
if self.false_path is not None and key == 'file_name':
return self.false_path
else:
return getattr( self.dataset, key )
-
def __nonzero__( self ):
return bool( self.dataset )
diff -r e2ac92093afda6743ea68766be96c9c7a454568d -r b36526f8edbc2776225b5b9a8da7657771186025 lib/galaxy/util/shed_util.py
--- a/lib/galaxy/util/shed_util.py
+++ b/lib/galaxy/util/shed_util.py
@@ -347,7 +347,7 @@
for tool_dict in metadata_dict[ 'tools' ]:
relative_path = tool_dict[ 'tool_config' ]
guid = tool_dict[ 'guid' ]
- tool = app.toolbox.load_tool( os.path.abspath( relative_path ) )
+ tool = app.toolbox.load_tool( os.path.abspath( relative_path ), guid=guid )
repository_tools_tups.append( ( relative_path, guid, tool ) )
return repository_tools_tups
def get_tool_id_guid_map( app, tool_id, version, tool_shed, repository_owner, repository_name ):
@@ -398,7 +398,7 @@
# TODO: Do more here than logging an exception.
log.debug( exception_msg )
# Reload the tool into the local list of repository_tools_tups.
- repository_tool = app.toolbox.load_tool( os.path.join( tool_path, tup_path ) )
+ repository_tool = app.toolbox.load_tool( os.path.join( tool_path, tup_path ), guid=guid )
repository_tools_tups[ index ] = ( tup_path, repository_tool )
return repository_tools_tups
def handle_missing_index_file( app, tool_path, sample_files, repository_tools_tups ):
@@ -425,7 +425,7 @@
missing_files_handled.append( missing_tail )
break
# Reload the tool into the local list of repository_tools_tups.
- repository_tool = app.toolbox.load_tool( os.path.join( tool_path, tup_path ) )
+ repository_tool = app.toolbox.load_tool( os.path.join( tool_path, tup_path ), guid=guid )
repository_tools_tups[ index ] = ( tup_path, guid, repository_tool )
return repository_tools_tups
def handle_tool_dependencies( current_working_dir, repo_files_dir, repository_tools_tups ):
diff -r e2ac92093afda6743ea68766be96c9c7a454568d -r b36526f8edbc2776225b5b9a8da7657771186025 lib/galaxy/web/controllers/admin_toolshed.py
--- a/lib/galaxy/web/controllers/admin_toolshed.py
+++ b/lib/galaxy/web/controllers/admin_toolshed.py
@@ -467,6 +467,7 @@
tool.repository_name = repository.name
tool.repository_owner = repository.owner
tool.installed_changeset_revision = repository.installed_changeset_revision
+ tool.guid = guid
# Set the tool's old_id to the id used before the tool shed existed.
tool.old_id = tool.id
# Set the tool's id to the tool shed guid.
@@ -610,7 +611,7 @@
for tool_metadata_dict in repository.metadata[ 'tools' ]:
if tool_metadata_dict[ 'id' ] == tool_id:
metadata = tool_metadata_dict
- tool = trans.app.toolbox.load_tool( os.path.abspath( metadata[ 'tool_config' ] ) )
+ tool = trans.app.toolbox.load_tool( os.path.abspath( metadata[ 'tool_config' ] ), guid=metadata[ 'guid' ] )
break
return trans.fill_template( "/admin/tool_shed_repository/view_tool_metadata.mako",
repository=repository,
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/galaxy-central: jgoecks: Add href to trackster icons in history pane so that browser treats it as a URL and not an anchor.
by Bitbucket 13 Jan '12
by Bitbucket 13 Jan '12
13 Jan '12
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/changeset/e2ac92093afd/
changeset: e2ac92093afd
user: jgoecks
date: 2012-01-13 22:22:29
summary: Add href to trackster icons in history pane so that browser treats it as a URL and not an anchor.
affected #: 1 file
diff -r a5e1ad623f390f1daceaa21aaa52868b4ce50c30 -r e2ac92093afda6743ea68766be96c9c7a454568d templates/root/history_common.mako
--- a/templates/root/history_common.mako
+++ b/templates/root/history_common.mako
@@ -220,7 +220,7 @@
else:
data_url = h.url_for( controller='tracks', action='list_tracks' )
%>
- <a data-url="${data_url}" class="icon-button chart_curve tooltip trackster-add"
+ <a href="javascript:void(0)" data-url="${data_url}" class="icon-button chart_curve tooltip trackster-add"
action-url="${h.url_for( controller='tracks', action='browser', dataset_id=dataset_id)}"
new-url="${h.url_for( controller='tracks', action='index', dataset_id=dataset_id, default_dbkey=data.dbkey)}" title="View in Trackster"></a>
%endif
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/galaxy-central: greg: Fixes for Galaxy instance , => tool shed communciation where Galaxy instance is running behind apache with rewrite rules.
by Bitbucket 13 Jan '12
by Bitbucket 13 Jan '12
13 Jan '12
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/changeset/a5e1ad623f39/
changeset: a5e1ad623f39
user: greg
date: 2012-01-13 22:09:41
summary: Fixes for Galaxy instance ,=> tool shed communciation where Galaxy instance is running behind apache with rewrite rules.
affected #: 2 files
diff -r 3d9f0ce7bb6138b20c200203014e60a4e9342160 -r a5e1ad623f390f1daceaa21aaa52868b4ce50c30 lib/galaxy/web/controllers/admin_toolshed.py
--- a/lib/galaxy/web/controllers/admin_toolshed.py
+++ b/lib/galaxy/web/controllers/admin_toolshed.py
@@ -169,21 +169,21 @@
@web.require_admin
def find_tools_in_tool_shed( self, trans, **kwd ):
tool_shed_url = kwd[ 'tool_shed_url' ]
- galaxy_url = url_for( '', qualified=True )
+ galaxy_url = url_for( '/', qualified=True )
url = '%s/repository/find_tools?galaxy_url=%s&webapp=galaxy' % ( tool_shed_url, galaxy_url )
return trans.response.send_redirect( url )
@web.expose
@web.require_admin
def find_workflows_in_tool_shed( self, trans, **kwd ):
tool_shed_url = kwd[ 'tool_shed_url' ]
- galaxy_url = url_for( '', qualified=True )
+ galaxy_url = url_for( '/', qualified=True )
url = '%s/repository/find_workflows?galaxy_url=%s&webapp=galaxy' % ( tool_shed_url, galaxy_url )
return trans.response.send_redirect( url )
@web.expose
@web.require_admin
def browse_tool_shed( self, trans, **kwd ):
tool_shed_url = kwd[ 'tool_shed_url' ]
- galaxy_url = url_for( '', qualified=True )
+ galaxy_url = url_for( '/', qualified=True )
url = '%s/repository/browse_valid_repositories?galaxy_url=%s&webapp=galaxy' % ( tool_shed_url, galaxy_url )
return trans.response.send_redirect( url )
@web.expose
diff -r 3d9f0ce7bb6138b20c200203014e60a4e9342160 -r a5e1ad623f390f1daceaa21aaa52868b4ce50c30 lib/galaxy/webapps/community/controllers/repository.py
--- a/lib/galaxy/webapps/community/controllers/repository.py
+++ b/lib/galaxy/webapps/community/controllers/repository.py
@@ -437,7 +437,7 @@
if operation == "install":
galaxy_url = trans.get_cookie( name='toolshedgalaxyurl' )
encoded_repo_info_dict, includes_tools = self.__encode_repo_info_dict( trans, webapp, util.listify( item_id ) )
- url = '%s/admin_toolshed/install_repository?tool_shed_url=%s&webapp=%s&repo_info_dict=%s&includes_tools=%s' % \
+ url = '%sadmin_toolshed/install_repository?tool_shed_url=%s&webapp=%s&repo_info_dict=%s&includes_tools=%s' % \
( galaxy_url, url_for( '', qualified=True ), webapp, encoded_repo_info_dict, str( includes_tools ) )
return trans.response.send_redirect( url )
else:
@@ -513,7 +513,7 @@
if operation == "install":
galaxy_url = trans.get_cookie( name='toolshedgalaxyurl' )
encoded_repo_info_dict, includes_tools = self.__encode_repo_info_dict( trans, webapp, util.listify( item_id ) )
- url = '%s/admin_toolshed/install_repository?tool_shed_url=%s&webapp=%s&repo_info_dict=%s&includes_tools=%s' % \
+ url = '%sadmin_toolshed/install_repository?tool_shed_url=%s&webapp=%s&repo_info_dict=%s&includes_tools=%s' % \
( galaxy_url, url_for( '', qualified=True ), webapp, encoded_repo_info_dict, str( includes_tools ) )
return trans.response.send_redirect( url )
else:
@@ -766,7 +766,7 @@
repo_info_dict[ repository.name ] = ( repository.description, repository_clone_url, changeset_revision )
encoded_repo_info_dict = encode( repo_info_dict )
# Redirect back to local Galaxy to perform install.
- url = '%s/admin_toolshed/install_repository?tool_shed_url=%s&repo_info_dict=%s&includes_tools=%s' % \
+ url = '%sadmin_toolshed/install_repository?tool_shed_url=%s&repo_info_dict=%s&includes_tools=%s' % \
( galaxy_url, url_for( '', qualified=True ), encoded_repo_info_dict, str( includes_tools ) )
return trans.response.send_redirect( url )
@web.expose
@@ -789,7 +789,7 @@
no_update = 'false'
else:
# Start building up the url to redirect back to the calling Galaxy instance.
- url = '%s/admin_toolshed/update_to_changeset_revision?tool_shed_url=%s' % ( galaxy_url, url_for( '', qualified=True ) )
+ url = '%sadmin_toolshed/update_to_changeset_revision?tool_shed_url=%s' % ( galaxy_url, url_for( '', qualified=True ) )
url += '&name=%s&owner=%s&changeset_revision=%s&latest_changeset_revision=' % \
( repository.name, repository.user.username, changeset_revision )
if changeset_revision == repository.tip:
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/changeset/3d9f0ce7bb61/
changeset: 3d9f0ce7bb61
user: greg
date: 2012-01-13 21:29:04
summary: Add the ability to deactivate / activate installed tool shed repositories. When a repository is deactivated, it's contained tools are eliminated from the tool panel on the fly. Similarly, if a deactivated repository is activated, it's contained tools are loaded into the tool panel on the fly. This works for tools contained in sections or outside sections in the tool panel.
Also fix a bug which resulted in a server error when installing a tool shed repository that includs a .loc.sample file.
affected #: 10 files
diff -r 4a130280e6142f2c241e33a2bacc6d52e566047c -r 3d9f0ce7bb6138b20c200203014e60a4e9342160 lib/galaxy/tool_shed/install_manager.py
--- a/lib/galaxy/tool_shed/install_manager.py
+++ b/lib/galaxy/tool_shed/install_manager.py
@@ -38,13 +38,13 @@
self.install_section( elem )
def install_repository( self, elem, section_name='', section_id='' ):
# Install a single repository into the tool config. If outside of any sections, the entry looks something like:
- # <repository name="cut_wrapper" description="Galaxy wrapper for the Cut tool" changeset_revision="f3ed6cfe6402">
+ # <repository name="cut_wrapper" description="Galaxy wrapper for the Cut tool" installed_changeset_revision="f3ed6cfe6402">
# <tool id="Cut1" version="1.0.1" />
# </repository>
name = elem.get( 'name' )
description = elem.get( 'description' )
changeset_revision = elem.get( 'changeset_revision' )
- # Install path is of the form: <tool path>/<tool shed>/repos/<repository owner>/<repository name>/<changeset revision>
+ # Install path is of the form: <tool path>/<tool shed>/repos/<repository owner>/<repository name>/<installed changeset revision>
clone_dir = os.path.join( self.tool_path, self.tool_shed, 'repos', self.repository_owner, name, changeset_revision )
if self.__isinstalled( elem, clone_dir ):
log.debug( "Skipping automatic install of repository '%s' because it has already been installed in location '%s'" % ( name, clone_dir ) )
@@ -61,6 +61,7 @@
new_section_elem = Element( 'section' )
new_section_elem.attrib[ 'name' ] = section_name
new_section_elem.attrib[ 'id' ] = section_id
+ new_section_elem.attrib[ 'version' ] = ''
tool_section = ToolSection( new_section_elem )
self.app.toolbox.tool_panel[ section_key ] = tool_section
else:
@@ -74,7 +75,7 @@
returncode, tmp_name = update_repository( current_working_dir, relative_install_dir, changeset_revision )
if returncode == 0:
metadata_dict = load_repository_contents( app=self.app,
- name=name,
+ repository_name=name,
description=description,
owner=self.repository_owner,
changeset_revision=changeset_revision,
@@ -124,7 +125,7 @@
def install_section( self, elem ):
# Install 1 or more repositories into a section in the tool config. An entry looks something like:
# <section name="EMBOSS" id="EMBOSSLite">
- # <repository name="emboss_5" description="Galaxy wrappers for EMBOSS version 5 tools" changeset_revision="bdd88ae5d0ac">
+ # <repository name="emboss_5" description="Galaxy wrappers for EMBOSS version 5 tools" installed_changeset_revision="bdd88ae5d0ac">
# <tool file="emboss_5/emboss_antigenic.xml" id="EMBOSS: antigenic1" version="5.0.0" />
# ...
# </repository>
diff -r 4a130280e6142f2c241e33a2bacc6d52e566047c -r 3d9f0ce7bb6138b20c200203014e60a4e9342160 lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -24,6 +24,7 @@
from galaxy.tools.actions import DefaultToolAction
from galaxy.tools.deps import DependencyManager
from galaxy.model import directory_hash_id
+from galaxy.model.orm import *
from galaxy.util.none_like import NoneDataset
from galaxy.datatypes import sniff
from cgi import FieldStorage
@@ -37,15 +38,11 @@
pass
class ToolBox( object ):
- """
- Container for a collection of tools
- """
-
+ """Container for a collection of tools"""
def __init__( self, config_filenames, tool_root_dir, app ):
"""
- Create a toolbox from the config file names by `config_filename`,
- using `tool_root_directory` as the base directory for finding
- individual tool config files.
+ Create a toolbox from the config files named by `config_filenames`, using
+ `tool_root_dir` as the base directory for finding individual tool config files.
"""
# The shed_tool_confs dictionary contains shed_conf_filename : tool_path pairs.
self.shed_tool_confs = {}
@@ -62,7 +59,7 @@
try:
self.init_tools( config_filename )
except:
- log.exception( "ToolBox error reading %s", config_filename )
+ log.exception( "Error loading tools defined in config %s", config_filename )
def init_tools( self, config_filename ):
"""
Read the configuration file and load each tool.
@@ -82,7 +79,7 @@
log.info("removing all tool tag associations (" + str( self.sa_session.query( self.app.model.ToolTagAssociation ).count() ) + ")")
self.sa_session.query( self.app.model.ToolTagAssociation ).delete()
self.sa_session.flush()
- log.info( "parsing the tool configuration %s" % config_filename )
+ log.info( "Parsing the tool configuration %s" % config_filename )
tree = util.parse_xml( config_filename )
root = tree.getroot()
tool_path = root.get( 'tool_path' )
@@ -94,53 +91,107 @@
tool_path = self.tool_root_dir
for elem in root:
if elem.tag == 'tool':
- self.load_tool_tag_set( elem, self.tool_panel, tool_path, guid=elem.get( 'guid' ) )
+ self.load_tool_tag_set( elem, self.tool_panel, tool_path, guid=elem.get( 'guid' ), section=None )
elif elem.tag == 'workflow':
self.load_workflow_tag_set( elem, self.tool_panel )
- elif elem.tag == 'section' :
+ elif elem.tag == 'section':
self.load_section_tag_set( elem, self.tool_panel, tool_path )
elif elem.tag == 'label':
self.load_label_tag_set( elem, self.tool_panel )
- def load_tool_tag_set( self, elem, panel_dict, tool_path, guid=None ):
+ def __get_tool_shed_repository( self, tool_shed, name, owner, installed_changeset_revision ):
+ return self.sa_session.query( self.app.model.ToolShedRepository ) \
+ .filter( and_( self.app.model.ToolShedRepository.table.c.tool_shed == tool_shed,
+ self.app.model.ToolShedRepository.table.c.name == name,
+ self.app.model.ToolShedRepository.table.c.owner == owner,
+ self.app.model.ToolShedRepository.table.c.installed_changeset_revision == installed_changeset_revision ) ) \
+ .first()
+ def load_tool_tag_set( self, elem, panel_dict, tool_path, guid=None, section=None ):
try:
path = elem.get( "file" )
- tool = self.load_tool( os.path.join( tool_path, path ), guid=guid )
if guid is not None:
- # Tool was installed from a Galaxy tool shed.
- tool.tool_shed = elem.find( "tool_shed" ).text
- tool.repository_name = elem.find( "repository_name" ).text
- tool.repository_owner = elem.find( "repository_owner" ).text
- tool.changeset_revision = elem.find( "changeset_revision" ).text
- tool.old_id = elem.find( "id" ).text
- tool.version = elem.find( "version" ).text
- if self.app.config.get_bool( 'enable_tool_tags', False ):
- tag_names = elem.get( "tags", "" ).split( "," )
- for tag_name in tag_names:
- if tag_name == '':
- continue
- tag = self.sa_session.query( self.app.model.Tag ).filter_by( name=tag_name ).first()
- if not tag:
- tag = self.app.model.Tag( name=tag_name )
- self.sa_session.add( tag )
- self.sa_session.flush()
- tta = self.app.model.ToolTagAssociation( tool_id=tool.id, tag_id=tag.id )
- self.sa_session.add( tta )
- self.sa_session.flush()
- else:
- for tagged_tool in tag.tagged_tools:
- if tagged_tool.tool_id == tool.id:
- break
+ # The tool is contained in an installed tool shed repository, so load
+ # the tool only if the repository has not been marked deleted.
+ tool_shed = elem.find( "tool_shed" ).text
+ repository_name = elem.find( "repository_name" ).text
+ repository_owner = elem.find( "repository_owner" ).text
+ installed_changeset_revision_elem = elem.find( "installed_changeset_revision" )
+ if installed_changeset_revision_elem is None:
+ # Backward compatibility issue - the tag used to be named 'changeset_revision'.
+ installed_changeset_revision_elem = elem.find( "changeset_revision" )
+ installed_changeset_revision = installed_changeset_revision_elem.text
+ tool_shed_repository = self.__get_tool_shed_repository( tool_shed, repository_name, repository_owner, installed_changeset_revision )
+ if tool_shed_repository:
+ # Only load tools if the repository is not deactivated or uninstalled.
+ can_load = not tool_shed_repository.deleted
+ if can_load:
+ metadata = tool_shed_repository.metadata
+ update_needed = False
+ if 'tool_panel_section' in metadata:
+ if section:
+ # If the tool_panel_section dictionary is included in the metadata, update it if necessary.
+ tool_panel_section = metadata[ 'tool_panel_section' ]
+ if tool_panel_section [ 'id' ] != section.id or \
+ tool_panel_section [ 'version' ] != section.version or \
+ tool_panel_section [ 'name' ] != section.name:
+ tool_panel_section [ 'id' ] = section.id
+ tool_panel_section [ 'version' ] = section.version
+ tool_panel_section [ 'name' ] = section.name
+ update_needed = True
else:
+ # The tool_panel_section was introduced late, so set it's value if its missing in the metadata.
+ if section:
+ tool_panel_section = dict( id=section.id, version=section.version, name=section.name )
+ update_needed = True
+ else:
+ tool_panel_section = dict( id='', version='', name='' )
+ update_needed = True
+ if update_needed:
+ metadata[ 'tool_panel_section' ] = tool_panel_section
+ tool_shed_repository.metadata = metadata
+ self.sa_session.add( tool_shed_repository )
+ self.sa_session.flush()
+ else:
+ # If there is not yet a tool_shed_repository record, we're in the process of installing
+ # a new repository, so any included tools can be loaded into the tool panel.
+ can_load = True
+ else:
+ can_load = True
+ if can_load:
+ tool = self.load_tool( os.path.join( tool_path, path ), guid=guid )
+ if guid is not None:
+ tool.tool_shed = tool_shed
+ tool.repository_name = repository_name
+ tool.repository_owner = repository_owner
+ tool.installed_changeset_revision = installed_changeset_revision
+ tool.old_id = elem.find( "id" ).text
+ tool.version = elem.find( "version" ).text
+ if self.app.config.get_bool( 'enable_tool_tags', False ):
+ tag_names = elem.get( "tags", "" ).split( "," )
+ for tag_name in tag_names:
+ if tag_name == '':
+ continue
+ tag = self.sa_session.query( self.app.model.Tag ).filter_by( name=tag_name ).first()
+ if not tag:
+ tag = self.app.model.Tag( name=tag_name )
+ self.sa_session.add( tag )
+ self.sa_session.flush()
tta = self.app.model.ToolTagAssociation( tool_id=tool.id, tag_id=tag.id )
self.sa_session.add( tta )
self.sa_session.flush()
- if tool.id not in self.tools_by_id:
- # Allow for the same tool to be loaded into multiple places in the
- # tool panel.
- self.tools_by_id[ tool.id ] = tool
- key = 'tool_' + tool.id
- panel_dict[ key ] = tool
- log.debug( "Loaded tool: %s %s" % ( tool.id, tool.version ) )
+ else:
+ for tagged_tool in tag.tagged_tools:
+ if tagged_tool.tool_id == tool.id:
+ break
+ else:
+ tta = self.app.model.ToolTagAssociation( tool_id=tool.id, tag_id=tag.id )
+ self.sa_session.add( tta )
+ self.sa_session.flush()
+ if tool.id not in self.tools_by_id:
+ # Allow for the same tool to be loaded into multiple places in the tool panel.
+ self.tools_by_id[ tool.id ] = tool
+ key = 'tool_' + tool.id
+ panel_dict[ key ] = tool
+ log.debug( "Loaded tool: %s %s" % ( tool.id, tool.version ) )
except:
log.exception( "error reading tool from path: %s" % path )
def load_workflow_tag_set( self, elem, panel_dict ):
@@ -161,22 +212,23 @@
def load_section_tag_set( self, elem, panel_dict, tool_path ):
key = 'section_' + elem.get( "id" )
if key in panel_dict:
- # Appending a tool to an existing section in self.tool_panel
- elems = panel_dict[ key ].elems
- log.debug( "Appending to section: %s" % elem.get( "name" ) )
+ # Loading an existing section in self.tool_panel
+ section = panel_dict[ key ]
+ elems = section.elems
+ log.debug( "Reloading section: %s" % elem.get( "name" ) )
else:
- # Appending a new section to self.tool_panel
+ # Adding a new section to self.tool_panel
section = ToolSection( elem )
elems = section.elems
log.debug( "Loading section: %s" % section.name )
- for section_elem in elem:
- if section_elem.tag == 'tool':
- self.load_tool_tag_set( section_elem, elems, tool_path, guid=section_elem.get( 'guid' ) )
- elif section_elem.tag == 'workflow':
- self.load_workflow_tag_set( section_elem, elems )
- elif section_elem.tag == 'label':
- self.load_label_tag_set( section_elem, elems )
- if key not in panel_dict:
+ for sub_elem in elem:
+ if sub_elem.tag == 'tool':
+ self.load_tool_tag_set( sub_elem, elems, tool_path, guid=sub_elem.get( 'guid' ), section=section )
+ elif sub_elem.tag == 'workflow':
+ self.load_workflow_tag_set( sub_elem, elems )
+ elif sub_elem.tag == 'label':
+ self.load_label_tag_set( sub_elem, elems )
+ if key not in panel_dict and section.elems:
panel_dict[ key ] = section
def load_tool( self, config_file, guid=None ):
"""
@@ -409,7 +461,7 @@
self.tool_shed = None
self.repository_name = None
self.repository_owner = None
- self.changeset_revision = None
+ self.installed_changeset_revision = None
self.old_id = None
self.version = None
# Parse XML element containing configuration
diff -r 4a130280e6142f2c241e33a2bacc6d52e566047c -r 3d9f0ce7bb6138b20c200203014e60a4e9342160 lib/galaxy/util/shed_util.py
--- a/lib/galaxy/util/shed_util.py
+++ b/lib/galaxy/util/shed_util.py
@@ -3,7 +3,6 @@
from time import strftime
from galaxy import util
from galaxy.util.json import *
-from galaxy.tools import ToolSection
from galaxy.tools.search import ToolBoxSearch
from galaxy.model.orm import *
@@ -78,6 +77,17 @@
os.chdir( current_working_dir )
tmp_stderr.close()
return returncode, tmp_name
+def copy_sample_loc_file( app, filename ):
+ """Copy xxx.loc.sample to ~/tool-data/xxx.loc.sample and ~/tool-data/xxx.loc"""
+ head, sample_loc_file = os.path.split( filename )
+ loc_file = sample_loc_file.replace( '.sample', '' )
+ tool_data_path = os.path.abspath( app.config.tool_data_path )
+ # It's ok to overwrite the .sample version of the file.
+ shutil.copy( os.path.abspath( filename ), os.path.join( tool_data_path, sample_loc_file ) )
+ # Only create the .loc file if it does not yet exist. We don't
+ # overwrite it in case it contains stuff proprietary to the local instance.
+ if not os.path.exists( os.path.join( tool_data_path, loc_file ) ):
+ shutil.copy( os.path.abspath( filename ), os.path.join( tool_data_path, loc_file ) )
def create_or_update_tool_shed_repository( app, name, description, changeset_revision, repository_clone_url, metadata_dict, owner='' ):
# This method is used by the InstallManager, which does not have access to trans.
sa_session = app.model.context.current
@@ -149,7 +159,7 @@
if datatypes:
metadata_dict[ 'datatypes' ] = datatypes
return metadata_dict
-def generate_metadata( toolbox, relative_install_dir, repository_clone_url ):
+def generate_metadata( toolbox, relative_install_dir, repository_clone_url, tool_section_dict=None ):
"""
Browse the repository files on disk to generate metadata. Since we are using disk files, it
is imperative that the repository is updated to the desired change set revision before metadata
@@ -158,6 +168,11 @@
metadata_dict = {}
sample_files = []
datatypes_config = None
+ # Keep track of the section in the tool panel in which this repository's tools will be contained.
+ if tool_section_dict:
+ metadata_dict[ 'tool_panel_section' ] = tool_section_dict
+ else:
+ metadata_dict[ 'tool_panel_section' ] = dict( id='', version='', name='' )
# Find datatypes_conf.xml if it exists.
for root, dirs, files in os.walk( relative_install_dir ):
if root.find( '.hg' ) < 0:
@@ -264,6 +279,7 @@
def generate_tool_panel_elem_list( repository_name, repository_clone_url, changeset_revision, repository_tools_tups, tool_section=None, owner='' ):
"""Generate a list of ElementTree Element objects for each section or list of tools."""
elem_list = []
+ tool_elem = None
tmp_url = clean_repository_clone_url( repository_clone_url )
if not owner:
owner = get_repository_owner( tmp_url )
@@ -271,6 +287,7 @@
root_elem = Element( 'section' )
root_elem.attrib[ 'name' ] = tool_section.name
root_elem.attrib[ 'id' ] = tool_section.id
+ root_elem.attrib[ 'version' ] = tool_section.version
for repository_tool_tup in repository_tools_tups:
tool_file_path, guid, tool = repository_tool_tup
if tool_section:
@@ -285,7 +302,7 @@
repository_name_elem.text = repository_name
repository_owner_elem = SubElement( tool_elem, 'repository_owner' )
repository_owner_elem.text = owner
- changeset_revision_elem = SubElement( tool_elem, 'changeset_revision' )
+ changeset_revision_elem = SubElement( tool_elem, 'installed_changeset_revision' )
changeset_revision_elem.text = changeset_revision
id_elem = SubElement( tool_elem, 'id' )
id_elem.text = tool.id
@@ -293,7 +310,7 @@
version_elem.text = tool.version
if tool_section:
elem_list.append( root_elem )
- else:
+ elif tool_elem:
elem_list.append( tool_elem )
return elem_list
def generate_workflow_metadata( relative_path, exported_workflow_dict, metadata_dict ):
@@ -324,6 +341,15 @@
if repo_path.startswith( '/' ):
repo_path = repo_path.replace( '/', '', 1 )
return repo_path.lstrip( '/' ).split( '/' )[ 0 ]
+def get_repository_tools_tups( app, metadata_dict ):
+ repository_tools_tups = []
+ if 'tools' in metadata_dict:
+ for tool_dict in metadata_dict[ 'tools' ]:
+ relative_path = tool_dict[ 'tool_config' ]
+ guid = tool_dict[ 'guid' ]
+ tool = app.toolbox.load_tool( os.path.abspath( relative_path ) )
+ repository_tools_tups.append( ( relative_path, guid, tool ) )
+ return repository_tools_tups
def get_tool_id_guid_map( app, tool_id, version, tool_shed, repository_owner, repository_name ):
# This method is used by the InstallManager, which does not have access to trans.
sa_session = app.model.context.current
@@ -545,7 +571,7 @@
# Load proprietary datatypes
app.datatypes_registry.load_datatypes( root_dir=app.config.root, config=datatypes_config, imported_modules=imported_modules )
return converter_path, display_path
-def load_repository_contents( app, name, description, owner, changeset_revision, tool_path, repository_clone_url, relative_install_dir,
+def load_repository_contents( app, repository_name, description, owner, changeset_revision, tool_path, repository_clone_url, relative_install_dir,
current_working_dir, tmp_name, tool_section=None, shed_tool_conf=None, new_install=True ):
# This method is used by the InstallManager, which does not have access to trans.
# Generate the metadata for the installed tool shed repository. It is imperative that
@@ -556,7 +582,16 @@
# and when updates have been pulled to previously installed repositories (in which case the
# default value None is set for tool_section and shed_tool_conf, and the value of new_install
# is passed as False).
- metadata_dict = generate_metadata( app.toolbox, relative_install_dir, repository_clone_url )
+ if tool_section:
+ section_id = tool_section.id
+ section_version = tool_section.version
+ section_name = tool_section.name
+ else:
+ section_id = ''
+ section_version = ''
+ section_name = ''
+ tool_section_dict = dict( id=section_id, version=section_version, name=section_name )
+ metadata_dict = generate_metadata( app.toolbox, relative_install_dir, repository_clone_url, tool_section_dict=tool_section_dict )
if 'datatypes_config' in metadata_dict:
datatypes_config = os.path.abspath( metadata_dict[ 'datatypes_config' ] )
# Load data types required by tools.
@@ -568,12 +603,7 @@
# Load proprietary datatype display applications
app.datatypes_registry.load_display_applications( display_path=display_path )
if 'tools' in metadata_dict:
- repository_tools_tups = []
- for tool_dict in metadata_dict[ 'tools' ]:
- relative_path = tool_dict[ 'tool_config' ]
- guid = tool_dict[ 'guid' ]
- tool = app.toolbox.load_tool( os.path.abspath( relative_path ) )
- repository_tools_tups.append( ( relative_path, guid, tool ) )
+ repository_tools_tups = get_repository_tools_tups( app, metadata_dict )
if repository_tools_tups:
sample_files = metadata_dict.get( 'sample_files', [] )
# Handle missing data table entries for tool parameters that are dynamically generated select lists.
@@ -583,28 +613,20 @@
# Handle tools that use fabric scripts to install dependencies.
handle_tool_dependencies( current_working_dir, relative_install_dir, repository_tools_tups )
if new_install:
- # Generate a new entry for the tool config.
- elem_list = generate_tool_panel_elem_list( name,
- repository_clone_url,
- changeset_revision,
- repository_tools_tups,
- tool_section=tool_section,
- owner=owner )
- if tool_section:
- for section_elem in elem_list:
- # Load the section into the tool panel.
- app.toolbox.load_section_tag_set( section_elem, app.toolbox.tool_panel, tool_path )
- else:
- # Load the tools into the tool panel outside of any sections.
- for tool_elem in elem_list:
- guid = tool_elem.get( 'guid' )
- app.toolbox.load_tool_tag_set( tool_elem, app.toolbox.tool_panel, tool_path=tool_path, guid=guid )
- for elem_entry in elem_list:
- # Append the new entry (either section or list of tools) to the shed_tool_config file.
- add_shed_tool_conf_entry( app, shed_tool_conf, elem_entry )
- if app.toolbox_search.enabled:
- # If search support for tools is enabled, index the new installed tools.
- app.toolbox_search = ToolBoxSearch( app.toolbox )
+ load_altered_part_of_tool_panel( app=app,
+ repository_name=repository_name,
+ repository_clone_url=repository_clone_url,
+ changeset_revision=changeset_revision,
+ repository_tools_tups=repository_tools_tups,
+ tool_section=tool_section,
+ shed_tool_conf=shed_tool_conf,
+ tool_path=tool_path,
+ owner=owner,
+ add_to_config=True )
+ else:
+ if app.toolbox_search.enabled:
+ # If search support for tools is enabled, index the new installed tools.
+ app.toolbox_search = ToolBoxSearch( app.toolbox )
# Remove the temporary file
try:
os.unlink( tmp_name )
@@ -612,9 +634,34 @@
pass
# Add a new record to the tool_shed_repository table if one doesn't
# already exist. If one exists but is marked deleted, undelete it.
- log.debug( "Adding new row (or updating an existing row) for repository '%s' in the tool_shed_repository table." % name )
- create_or_update_tool_shed_repository( app, name, description, changeset_revision, repository_clone_url, metadata_dict )
+ log.debug( "Adding new row (or updating an existing row) for repository '%s' in the tool_shed_repository table." % repository_name )
+ create_or_update_tool_shed_repository( app, repository_name, description, changeset_revision, repository_clone_url, metadata_dict )
return metadata_dict
+def load_altered_part_of_tool_panel( app, repository_name, repository_clone_url, changeset_revision, repository_tools_tups,
+ tool_section, shed_tool_conf, tool_path, owner, add_to_config=True ):
+ # Generate a new entry for the tool config.
+ elem_list = generate_tool_panel_elem_list( repository_name,
+ repository_clone_url,
+ changeset_revision,
+ repository_tools_tups,
+ tool_section=tool_section,
+ owner=owner )
+ if tool_section:
+ for section_elem in elem_list:
+ # Load the section into the tool panel.
+ app.toolbox.load_section_tag_set( section_elem, app.toolbox.tool_panel, tool_path )
+ else:
+ # Load the tools into the tool panel outside of any sections.
+ for tool_elem in elem_list:
+ guid = tool_elem.get( 'guid' )
+ app.toolbox.load_tool_tag_set( tool_elem, app.toolbox.tool_panel, tool_path=tool_path, guid=guid )
+ if add_to_config:
+ # Append the new entry (either section or list of tools) to the shed_tool_config file.
+ for elem_entry in elem_list:
+ add_shed_tool_conf_entry( app, shed_tool_conf, elem_entry )
+ if app.toolbox_search.enabled:
+ # If search support for tools is enabled, index the new installed tools.
+ app.toolbox_search = ToolBoxSearch( app.toolbox )
def pull_repository( current_working_dir, repo_files_dir, name ):
# Pull the latest possible contents to the repository.
log.debug( "Pulling latest updates to the repository named '%s'" % name )
diff -r 4a130280e6142f2c241e33a2bacc6d52e566047c -r 3d9f0ce7bb6138b20c200203014e60a4e9342160 lib/galaxy/web/base/controller.py
--- a/lib/galaxy/web/base/controller.py
+++ b/lib/galaxy/web/base/controller.py
@@ -1323,7 +1323,6 @@
status = kwd.get( 'status', 'done' )
if webapp == 'galaxy':
cloned_repositories = trans.sa_session.query( trans.model.ToolShedRepository ) \
- .filter( trans.model.ToolShedRepository.deleted == False ) \
.first()
return trans.fill_template( '/webapps/galaxy/admin/index.mako',
webapp=webapp,
@@ -2422,17 +2421,6 @@
## ---- Utility methods -------------------------------------------------------
-def copy_sample_loc_file( app, filename ):
- """Copy xxx.loc.sample to ~/tool-data/xxx.loc.sample and ~/tool-data/xxx.loc"""
- head, sample_loc_file = os.path.split( filename )
- loc_file = sample_loc_file.replace( '.sample', '' )
- tool_data_path = os.path.abspath( app.config.tool_data_path )
- # It's ok to overwrite the .sample version of the file.
- shutil.copy( os.path.abspath( filename ), os.path.join( tool_data_path, sample_loc_file ) )
- # Only create the .loc file if it does not yet exist. We don't
- # overwrite it in case it contains stuff proprietary to the local instance.
- if not os.path.exists( os.path.join( tool_data_path, loc_file ) ):
- shutil.copy( os.path.abspath( filename ), os.path.join( tool_data_path, loc_file ) )
def get_user( trans, user_id ):
"""Get a User from the database by id."""
user = trans.sa_session.query( trans.model.User ).get( trans.security.decode_id( user_id ) )
diff -r 4a130280e6142f2c241e33a2bacc6d52e566047c -r 3d9f0ce7bb6138b20c200203014e60a4e9342160 lib/galaxy/web/controllers/admin_toolshed.py
--- a/lib/galaxy/web/controllers/admin_toolshed.py
+++ b/lib/galaxy/web/controllers/admin_toolshed.py
@@ -1,5 +1,6 @@
from galaxy.web.controllers.admin import *
from galaxy.util.shed_util import *
+from galaxy import tools
log = logging.getLogger( __name__ )
@@ -101,6 +102,14 @@
operations = [ grids.GridOperation( "Get updates",
allow_multiple=False,
condition=( lambda item: not item.deleted ),
+ async_compatible=False ),
+ grids.GridOperation( "Deactivate or uninstall",
+ allow_multiple=False,
+ condition=( lambda item: not item.deleted ),
+ async_compatible=False ),
+ grids.GridOperation( "Activate or reinstall",
+ allow_multiple=False,
+ condition=( lambda item: item.deleted ),
async_compatible=False ) ]
standard_filters = []
default_filter = dict( deleted="False" )
@@ -108,8 +117,7 @@
preserve_state = False
use_paging = True
def build_initial_query( self, trans, **kwd ):
- return trans.sa_session.query( self.model_class ) \
- .filter( self.model_class.table.c.deleted == False )
+ return trans.sa_session.query( self.model_class )
class AdminToolshed( AdminGalaxy ):
@@ -140,7 +148,12 @@
return self.manage_repository( trans, **kwd )
if operation == "get updates":
return self.check_for_updates( trans, **kwd )
- kwd[ 'message' ] = 'Names of repositories for which updates are available are highlighted in red.'
+ if operation == "activate or reinstall":
+ return self.activate_or_reinstall_repository( trans, **kwd )
+ if operation == "deactivate or uninstall":
+ return self.deactivate_or_uninstall_repository( trans, **kwd )
+ if 'message' not in kwd or not kwd[ 'message' ]:
+ kwd[ 'message' ] = 'Names of repositories for which updates are available are highlighted in red.'
return self.repository_list_grid( trans, **kwd )
@web.expose
@web.require_admin
@@ -218,7 +231,8 @@
elem = Element( 'section' )
elem.attrib[ 'name' ] = new_tool_panel_section
elem.attrib[ 'id' ] = section_id
- tool_section = ToolSection( elem )
+ elem.attrib[ 'version' ] = ''
+ tool_section = tools.ToolSection( elem )
trans.app.toolbox.tool_panel[ new_section_key ] = tool_section
else:
section_key = 'section_%s' % tool_panel_section
@@ -245,7 +259,7 @@
if returncode == 0:
owner = get_repository_owner( clean_repository_clone_url( repository_clone_url ) )
metadata_dict = load_repository_contents( app=trans.app,
- name=name,
+ repository_name=name,
description=description,
owner=owner,
changeset_revision=changeset_revision,
@@ -305,13 +319,180 @@
status=status )
@web.expose
@web.require_admin
+ def deactivate_or_uninstall_repository( self, trans, **kwd ):
+ # TODO: handle elimination of workflows loaded into the tool panel that are in the repository being deactivated.
+ params = util.Params( kwd )
+ message = util.restore_text( params.get( 'message', '' ) )
+ status = params.get( 'status', 'done' )
+ remove_from_disk = params.get( 'remove_from_disk', '' )
+ remove_from_disk_checked = CheckboxField.is_checked( remove_from_disk )
+ repository = get_repository( trans, kwd[ 'id' ] )
+ if params.get( 'deactivate_or_uninstall_repository_button', False ):
+ shed_tool_conf, tool_path, relative_install_dir = self.__get_tool_path_and_relative_install_dir( trans, repository )
+ metadata = repository.metadata
+ repository_tools_tups = get_repository_tools_tups( trans.app, metadata )
+ # Generate the list of tool panel keys derived from the tools included in the repository.
+ repository_tool_panel_keys = []
+ if repository_tools_tups:
+ repository_tool_panel_keys = [ 'tool_%s' % repository_tools_tup[ 1 ] for repository_tools_tup in repository_tools_tups ]
+ tool_panel_section = metadata[ 'tool_panel_section' ]
+ section_id = tool_panel_section[ 'id' ]
+ if section_id in [ '' ]:
+ # If the repository includes tools, they were loaded into the tool panel outside of any sections.
+ tool_section = None
+ self.__deactivate( trans, repository_tool_panel_keys )
+ else:
+ # If the repository includes tools, they were loaded into the tool panel inside a section.
+ section_key = 'section_%s' % str( section_id )
+ if section_key in trans.app.toolbox.tool_panel:
+ tool_section = trans.app.toolbox.tool_panel[ section_key ]
+ self.__deactivate( trans, repository_tool_panel_keys, tool_section=tool_section, section_key=section_key )
+ else:
+ # The tool panel section could not be found, so handle deactivating tools
+ # as if they were loaded into the tool panel outside of any sections.
+ tool_section = None
+ self.__deactivate( trans, repository_tool_panel_keys )
+ repository.deleted = True
+ trans.sa_session.add( repository )
+ trans.sa_session.flush()
+ repository_clone_url = self.__generate_clone_url( trans, repository )
+ load_altered_part_of_tool_panel( app=trans.app,
+ repository_name=repository.name,
+ repository_clone_url=repository_clone_url,
+ changeset_revision=repository.installed_changeset_revision,
+ repository_tools_tups=repository_tools_tups,
+ tool_section=tool_section,
+ shed_tool_conf=shed_tool_conf,
+ tool_path=tool_path,
+ owner=repository.owner,
+ add_to_config=False )
+ if remove_from_disk_checked:
+ # TODO: Remove repository from disk and alter the shed tool config.
+ message = 'The repository named <b>%s</b> has been uninstalled.' % repository.name
+ else:
+ message = 'The repository named <b>%s</b> has been deactivated.' % repository.name
+ status = 'done'
+ return trans.response.send_redirect( web.url_for( controller='admin_toolshed',
+ action='browse_repositories',
+ message=message,
+ status=status ) )
+ remove_from_disk_check_box = CheckboxField( 'remove_from_disk', checked=remove_from_disk_checked )
+ return trans.fill_template( '/admin/tool_shed_repository/deactivate_or_uninstall_repository.mako',
+ repository=repository,
+ remove_from_disk_check_box=remove_from_disk_check_box,
+ message=message,
+ status=status )
+ def __deactivate( self, trans, repository_tool_panel_keys, tool_section=None, section_key=None ):
+ # Delete tools loaded into the tool panel. If the tool_panel is received,
+ # the tools were loaded into the tool panel outside of any sections. If
+ # the tool_section is received, all tools were loaded into that section.
+ if tool_section:
+ # The tool_section.elems dictionary looks something like:
+ # {'tool_gvk.bx.psu.edu:9009/repos/test/filter/Filter1/1.0.1': <galaxy.tools.Tool instance at 0x10769ae60>}
+ for item_id, item in tool_section.elems.items():
+ if item_id in repository_tool_panel_keys:
+ del tool_section.elems[ item_id ]
+ if not tool_section.elems:
+ del trans.app.toolbox.tool_panel[ section_key ]
+ else:
+ # The tool panel looks something like:
+ # {'tool_gvk.bx.psu.edu:9009/repos/test/blast2go/blast2go/0.0.2': <galaxy.tools.Tool instance at 0x1076a5f80>}
+ for item_id, item in trans.app.toolbox.tool_panel.items():
+ if item_id in repository_tool_panel_keys:
+ del trans.app.toolbox.tool_panel[ item_id ]
+ @web.expose
+ @web.require_admin
+ def activate_or_reinstall_repository( self, trans, **kwd ):
+ # TODO: handle re-introduction of workflows loaded into the tool panel that are in the repository being activated.
+ repository = get_repository( trans, kwd[ 'id' ] )
+ repository.deleted = False
+ trans.sa_session.add( repository )
+ trans.sa_session.flush()
+ shed_tool_conf, tool_path, relative_install_dir = self.__get_tool_path_and_relative_install_dir( trans, repository )
+ metadata = repository.metadata
+ repository_tools_tups = get_repository_tools_tups( trans.app, metadata )
+ tool_panel_section = metadata[ 'tool_panel_section' ]
+ section_id = tool_panel_section[ 'id' ]
+ # Generate the list of tool panel keys derived from the tools included in the repository.
+ #repository_tool_panel_keys = []
+ #if repository_tools_tups:
+ # repository_tool_panel_keys = [ 'tool_%s' % repository_tools_tup[ 1 ] for repository_tools_tup in repository_tools_tups ]
+ if section_id in [ '' ]:
+ # If the repository includes tools, reload them into the tool panel outside of any sections.
+ self.__activate( trans, repository, repository_tools_tups, tool_section=None, section_key=None )
+ else:
+ # If the repository includes tools, reload them into the appropriate tool panel section.
+ section_key = 'section_%s' % str( section_id )
+ if section_key in trans.app.toolbox.tool_panel:
+ # Load the repository tools into a section that still exists in the tool panel.
+ tool_section = trans.app.toolbox.tool_panel[ section_key ]
+ self.__activate( trans, repository, repository_tools_tups, tool_section=tool_section, section_key=section_key )
+ else:
+ # Load the repository tools into a section that no longer exists in the tool panel.
+ # We first see if the section exists in the tool config, which will be the case if
+ # the repository was only deactivated and not uninstalled.
+ section_loaded = False
+ for tcf in trans.app.config.tool_configs:
+ # Only inspect tool configs that contain installed tool shed repositories.
+ if tcf not in [ 'tool_conf.xml' ]:
+ log.info( "Parsing the tool configuration %s" % tcf )
+ tree = util.parse_xml( tcf )
+ root = tree.getroot()
+ tool_path = root.get( 'tool_path' )
+ if tool_path is not None:
+ # Tool configs that contain tools installed from tool shed repositories
+ # must have a tool_path attribute.
+ for elem in root:
+ if elem.tag == 'section':
+ id_attr = elem.get( 'id' )
+ if id_attr == section_id:
+ tool_section = elem
+ trans.app.toolbox.load_section_tag_set( tool_section, trans.app.toolbox.tool_panel, tool_path )
+ section_loaded = True
+ break
+ if section_loaded:
+ break
+ message = 'The repository named <b>%s</b> has been activated.' % repository.name
+ status = 'done'
+ return trans.response.send_redirect( web.url_for( controller='admin_toolshed',
+ action='browse_repositories',
+ message=message,
+ status=status ) )
+ def __activate( self, trans, repository, repository_tools_tups, tool_section=None, section_key=None ):
+ if tool_section:
+ elems = tool_section.elems
+ for repository_tools_tup in repository_tools_tups:
+ relative_path, guid, tool = repository_tools_tup
+ tool.tool_shed = repository.tool_shed
+ tool.repository_name = repository.name
+ tool.repository_owner = repository.owner
+ tool.installed_changeset_revision = repository.installed_changeset_revision
+ # Set the tool's old_id to the id used before the tool shed existed.
+ tool.old_id = tool.id
+ # Set the tool's id to the tool shed guid.
+ tool.id = guid
+ if tool_section:
+ if tool.id not in elems:
+ elems[ 'tool_%s' % tool.id ] = tool
+ log.debug( "Reactivated tool: %s %s" % ( tool.id, tool.version ) )
+ else:
+ if tool.id not in trans.app.toolbox.tools_by_id:
+ # Allow for the same tool to be loaded into multiple places in the tool panel.
+ trans.app.toolbox.tools_by_id[ tool.id ] = tool
+ trans.app.toolbox.tool_panel[ 'tool_%s' % tool.id ] = tool
+ log.debug( "Reactivated tool: %s %s" % ( tool.id, tool.version ) )
+ if tool_section:
+ trans.app.toolbox.tool_panel[ section_key ] = tool_section
+ log.debug( "Appended reactivated tool to section: %s" % tool_section.name )
+ @web.expose
+ @web.require_admin
def manage_repository( self, trans, **kwd ):
params = util.Params( kwd )
message = util.restore_text( params.get( 'message', '' ) )
status = params.get( 'status', 'done' )
repository = get_repository( trans, kwd[ 'id' ] )
description = util.restore_text( params.get( 'description', repository.description ) )
- tool_path, relative_install_dir = self.__get_tool_path_and_relative_install_dir( trans, repository )
+ shed_tool_conf, tool_path, relative_install_dir = self.__get_tool_path_and_relative_install_dir( trans, repository )
repo_files_dir = os.path.abspath( os.path.join( relative_install_dir, repository.name ) )
if params.get( 'edit_repository_button', False ):
if description != repository.description:
@@ -321,7 +502,12 @@
message = "The repository information has been updated."
elif params.get( 'set_metadata_button', False ):
repository_clone_url = self.__generate_clone_url( trans, repository )
- metadata_dict = generate_metadata( trans.app.toolbox, relative_install_dir, repository_clone_url )
+ # In case metadata was previously generated for this repository, we'll
+ # check to see if it has information needed for the tool_section_dict.
+ metadata = repository.metadata
+ if 'tool_panel_section' in metadata:
+ tool_section_dict = metadata[ 'tool_panel_section' ]
+ metadata_dict = generate_metadata( trans.app.toolbox, relative_install_dir, repository_clone_url, tool_section_dict=tool_section_dict )
if metadata_dict:
repository.metadata = metadata_dict
trans.sa_session.add( repository )
@@ -360,7 +546,7 @@
message = "The cloned tool shed repository named '%s' is current (there are no updates available)." % name
else:
current_working_dir = os.getcwd()
- tool_path, relative_install_dir = self.__get_tool_path_and_relative_install_dir( trans, repository )
+ shed_tool_conf, tool_path, relative_install_dir = self.__get_tool_path_and_relative_install_dir( trans, repository )
if relative_install_dir:
repo_files_dir = os.path.join( relative_install_dir, name )
returncode, tmp_name = pull_repository( current_working_dir, repo_files_dir, name )
@@ -440,17 +626,17 @@
# Get the relative tool installation paths from each of the shed tool configs.
shed_tool_confs = trans.app.toolbox.shed_tool_confs
relative_install_dir = None
- # The shed_tool_confs dictionary contains { shed_conf_filename : tool_path } pairs.
- for shed_conf_filename, tool_path in shed_tool_confs.items():
+ # The shed_tool_confs dictionary contains { shed_tool_conf : tool_path } pairs.
+ for shed_tool_conf, tool_path in shed_tool_confs.items():
relative_install_dir = os.path.join( tool_path, partial_install_dir )
if os.path.isdir( relative_install_dir ):
break
- return tool_path, relative_install_dir
+ return shed_tool_conf, tool_path, relative_install_dir
def __generate_tool_path( self, repository_clone_url, changeset_revision ):
"""
Generate a tool path that guarantees repositories with the same name will always be installed
in different directories. The tool path will be of the form:
- <tool shed url>/repos/<repository owner>/<repository name>/<changeset revision>
+ <tool shed url>/repos/<repository owner>/<repository name>/<installed changeset revision>
http://test@bx.psu.edu:9009/repos/test/filter
"""
tmp_url = clean_repository_clone_url( repository_clone_url )
diff -r 4a130280e6142f2c241e33a2bacc6d52e566047c -r 3d9f0ce7bb6138b20c200203014e60a4e9342160 lib/galaxy/webapps/community/controllers/common.py
--- a/lib/galaxy/webapps/community/controllers/common.py
+++ b/lib/galaxy/webapps/community/controllers/common.py
@@ -4,7 +4,7 @@
from galaxy.tools import *
from galaxy.util.json import from_json_string, to_json_string
from galaxy.util.hash_util import *
-from galaxy.util.shed_util import generate_datatypes_metadata, generate_tool_metadata, generate_workflow_metadata
+from galaxy.util.shed_util import copy_sample_loc_file, generate_datatypes_metadata, generate_tool_metadata, generate_workflow_metadata
from galaxy.web.base.controller import *
from galaxy.webapps.community import model
from galaxy.model.orm import *
diff -r 4a130280e6142f2c241e33a2bacc6d52e566047c -r 3d9f0ce7bb6138b20c200203014e60a4e9342160 templates/admin/tool_shed_repository/browse_repository.mako
--- a/templates/admin/tool_shed_repository/browse_repository.mako
+++ b/templates/admin/tool_shed_repository/browse_repository.mako
@@ -10,6 +10,7 @@
<div popupmenu="repository-${repository.id}-popup"><a class="action-button" href="${h.url_for( controller='admin_toolshed', action='manage_repository', id=trans.security.encode_id( repository.id ) )}">Manage repository</a><a class="action-button" href="${h.url_for( controller='admin_toolshed', action='check_for_updates', id=trans.security.encode_id( repository.id ) )}">Get updates</a>
+ <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='deactivate_or_uninstall_repository', id=trans.security.encode_id( repository.id ) )}">Deactivate or Uninstall</a></div></ul>
diff -r 4a130280e6142f2c241e33a2bacc6d52e566047c -r 3d9f0ce7bb6138b20c200203014e60a4e9342160 templates/admin/tool_shed_repository/deactivate_or_uninstall_repository.mako
--- /dev/null
+++ b/templates/admin/tool_shed_repository/deactivate_or_uninstall_repository.mako
@@ -0,0 +1,77 @@
+<%inherit file="/base.mako"/>
+<%namespace file="/message.mako" import="render_msg" />
+<%namespace file="/admin/tool_shed_repository/common.mako" import="*" />
+
+<br/><br/>
+<ul class="manage-table-actions">
+ <li><a class="action-button" id="repository-${repository.id}-popup" class="menubutton">Repository Actions</a></li>
+ <div popupmenu="repository-${repository.id}-popup">
+ <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='browse_repository', id=trans.security.encode_id( repository.id ) )}">Browse repository</a>
+ <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='manage_repository', id=trans.security.encode_id( repository.id ) )}">Manage repository</a>
+ <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='check_for_updates', id=trans.security.encode_id( repository.id ) )}">Get updates</a>
+ </div>
+</ul>
+
+%if message:
+ ${render_msg( message, status )}
+%endif
+
+<div class="toolForm">
+ <div class="toolFormTitle">${repository.name}</div>
+ <div class="toolFormBody">
+ <form name="uninstall_repository" id="uninstall_repository" action="${h.url_for( controller='admin_toolshed', action='deactivate_or_uninstall_repository', id=trans.security.encode_id( repository.id ) )}" method="post" >
+ <div class="form-row">
+ <label>Description:</label>
+ ${repository.description}
+ <div style="clear: both"></div>
+ </div>
+ <div class="form-row">
+ <label>Revision:</label>
+ ${repository.changeset_revision}</a>
+ </div>
+ <div class="form-row">
+ <label>Tool shed:</label>
+ ${repository.tool_shed}
+ <div style="clear: both"></div>
+ </div>
+ <div class="form-row">
+ <label>Owner:</label>
+ ${repository.owner}
+ </div>
+ <div class="form-row">
+ <label>Deleted:</label>
+ ${repository.deleted}
+ </div>
+ <div class="form-row">
+ ${remove_from_disk_check_box.get_html( disabled=True )}
+ <label for="repository" style="display: inline;font-weight:normal;">Check to uninstall (not yet implemented) or leave blank to deactivate</label>
+ <br/><br/>
+ <label>Deactivating this repository will result in the following:</label>
+ <div class="toolParamHelp" style="clear: both;">
+ 1. This repository record's deleted column in the tool_shed_repository database table will be set to True.
+ </div>
+ <div class="toolParamHelp" style="clear: both;">
+ 2. The repository and all of it's contents will remain on disk.
+ </div>
+ <div class="toolParamHelp" style="clear: both;">
+ 3. If this repository includes tools, they will not be loaded into the tool panel, but the tool config file in which they are defined will not be altered.
+ </div>
+ <br/>
+ <label>Uninstalling (not yet implemented) this repository will result in the following:</label>
+ <div class="toolParamHelp" style="clear: both;">
+ 1. This repository record's deleted column in the tool_shed_repository database table will be set to True.
+ </div>
+ <div class="toolParamHelp" style="clear: both;">
+ 2. The repository and all of it's contents will be removed from disk.
+ </div>
+ <div class="toolParamHelp" style="clear: both;">
+ 3. If this repository includes tools, they will be removed from the tool config file in which they are defined and they will not be loaded into the tool panel.
+ </div>
+ <div style="clear: both"></div>
+ </div>
+ <div class="form-row">
+ <input type="submit" name="deactivate_or_uninstall_repository_button" value="Deactivate or Uninstall"/>
+ </div>
+ </form>
+ </div>
+</div>
diff -r 4a130280e6142f2c241e33a2bacc6d52e566047c -r 3d9f0ce7bb6138b20c200203014e60a4e9342160 templates/admin/tool_shed_repository/manage_repository.mako
--- a/templates/admin/tool_shed_repository/manage_repository.mako
+++ b/templates/admin/tool_shed_repository/manage_repository.mako
@@ -8,6 +8,7 @@
<div popupmenu="repository-${repository.id}-popup"><a class="action-button" href="${h.url_for( controller='admin_toolshed', action='browse_repository', id=trans.security.encode_id( repository.id ) )}">Browse repository</a><a class="action-button" href="${h.url_for( controller='admin_toolshed', action='check_for_updates', id=trans.security.encode_id( repository.id ) )}">Get updates</a>
+ <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='deactivate_or_uninstall_repository', id=trans.security.encode_id( repository.id ) )}">Deactivate or Uninstall</a></div></ul>
diff -r 4a130280e6142f2c241e33a2bacc6d52e566047c -r 3d9f0ce7bb6138b20c200203014e60a4e9342160 templates/admin/tool_shed_repository/view_tool_metadata.mako
--- a/templates/admin/tool_shed_repository/view_tool_metadata.mako
+++ b/templates/admin/tool_shed_repository/view_tool_metadata.mako
@@ -8,6 +8,7 @@
<a class="action-button" href="${h.url_for( controller='admin_toolshed', action='browse_repository', id=trans.security.encode_id( repository.id ) )}">Browse repository</a><a class="action-button" href="${h.url_for( controller='admin_toolshed', action='manage_repository', id=trans.security.encode_id( repository.id ) )}">Manage repository</a><a class="action-button" href="${h.url_for( controller='admin_toolshed', action='check_for_updates', id=trans.security.encode_id( repository.id ) )}">Get updates</a>
+ <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='deactivate_or_uninstall_repository', id=trans.security.encode_id( repository.id ) )}">Deactivate or Uninstall</a></div></ul>
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
13 Jan '12
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/changeset/4a130280e614/
changeset: 4a130280e614
user: jgoecks
date: 2012-01-13 17:47:32
summary: Trackster: fix reference track display bug.
affected #: 2 files
diff -r da1c34c70e254fa559830342c9fa2b5752375e77 -r 4a130280e6142f2c241e33a2bacc6d52e566047c static/scripts/packed/trackster.js
--- a/static/scripts/packed/trackster.js
+++ b/static/scripts/packed/trackster.js
@@ -1,1 +1,1 @@
-var class_module=function(b,a){var c=function(){var f=arguments[0];for(var e=1;e<arguments.length;e++){var d=arguments[e];for(key in d){f[key]=d[key]}}return f};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(var 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(e,X){var p=e("class").extend,s=e("slotting"),L=e("painters");var ae=function(af,ag){this.document=af;this.default_font=ag!==undefined?ag:"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")};p(ae.prototype,{load_pattern:function(af,aj){var ag=this.patterns,ah=this.dummy_context,ai=new Image();ai.src=image_path+aj;ai.onload=function(){ag[af]=ah.createPattern(ai,"repeat")}},get_pattern:function(af){return this.patterns[af]},new_canvas:function(){var af=this.document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(af)}af.manager=this;return af}});var n={};var l=function(af,ag){n[af.attr("id")]=ag};var m=function(af,ah,aj,ai){aj=".group";var ag={};n[af.attr("id")]=ai;af.bind("drag",{handle:"."+ah,relative:true},function(ar,at){var aq=$(this);var aw=$(this).parent(),an=aw.children(),ap=n[$(this).attr("id")],am,al,au,ak,ao;al=$(this).parents(aj);if(al.length!==0){au=al.position().top;ak=au+al.outerHeight();if(at.offsetY<au){$(this).insertBefore(al);var av=n[al.attr("id")];av.remove_drawable(ap);av.container.add_drawable_before(ap,av);return}else{if(at.offsetY>ak){$(this).insertAfter(al);var av=n[al.attr("id")];av.remove_drawable(ap);av.container.add_drawable(ap);return}}}al=null;for(ao=0;ao<an.length;ao++){am=$(an.get(ao));au=am.position().top;ak=au+am.outerHeight();if(am.is(aj)&&this!==am.get(0)&&at.offsetY>=au&&at.offsetY<=ak){if(at.offsetY-au<ak-at.offsetY){am.find(".content-div").prepend(this)}else{am.find(".content-div").append(this)}if(ap.container){ap.container.remove_drawable(ap)}n[am.attr("id")].add_drawable(ap);return}}for(ao=0;ao<an.length;ao++){if(at.offsetY<$(an.get(ao)).position().top){break}}if(ao===an.length){if(this!==an.get(ao-1)){aw.append(this);n[aw.attr("id")].move_drawable(ap,ao)}}else{if(this!==an.get(ao)){$(this).insertBefore(an.get(ao));n[aw.attr("id")].move_drawable(ap,(at.deltaY>0?ao-1:ao))}}}).bind("dragstart",function(){ag["border-top"]=af.css("border-top");ag["border-bottom"]=af.css("border-bottom");$(this).css({"border-top":"1px solid blue","border-bottom":"1px solid blue"})}).bind("dragend",function(){$(this).css(ag)})};X.moveable=m;var ad=16,F=9,C=20,T=F+2,y=100,I=12000,Q=200,A=5,u=10,K=5000,v=100,o="There was an error in indexing this dataset. ",J="A converter for this dataset is not installed. Please check your datatypes_conf.xml file.",D="No data for this chrom/contig.",t="Currently indexing... please wait",w="Tool cannot be rerun: ",a="Loading data...",Y="Ready for display",R=10,H=20;function Z(ag,af){if(!af){af=0}var ah=Math.pow(10,af);return Math.round(ag*ah)/ah}var c=function(af){this.num_elements=af;this.clear()};p(c.prototype,{get:function(ag){var af=this.key_ary.indexOf(ag);if(af!==-1){if(this.obj_cache[ag].stale){this.key_ary.splice(af,1);delete this.obj_cache[ag]}else{this.move_key_to_end(ag,af)}}return this.obj_cache[ag]},set:function(ag,ah){if(!this.obj_cache[ag]){if(this.key_ary.length>=this.num_elements){var af=this.key_ary.shift();delete this.obj_cache[af]}this.key_ary.push(ag)}this.obj_cache[ag]=ah;return ah},move_key_to_end:function(ag,af){this.key_ary.splice(af,1);this.key_ary.push(ag)},clear:function(){this.obj_cache={};this.key_ary=[]},size:function(){return this.key_ary.length}});var S=function(ag,af,ah){c.call(this,ag);this.track=af;this.subset=(ah!==undefined?ah:true)};p(S.prototype,c.prototype,{load_data:function(ao,aj,am,ag,al){var an=this.track.view.chrom,ai={chrom:an,low:ao,high:aj,mode:am,resolution:ag,dataset_id:this.track.dataset_id,hda_ldda:this.track.hda_ldda};$.extend(ai,al);if(this.track.filters_manager){var ap=[];var af=this.track.filters_manager.filters;for(var ak=0;ak<af.length;ak++){ap[ap.length]=af[ak].name}ai.filter_cols=JSON.stringify(ap)}var ah=this;return $.getJSON(this.track.data_url,ai,function(aq){ah.set_data(ao,aj,aq)})},get_data:function(af,aj,ak,ag,ai){var ah=this.get(af,aj);if(ah&&(is_deferred(ah)||this.track.data_and_mode_compatible(ah,ak))){return ah}ah=this.load_data(af,aj,ak,ag,ai);this.set_data(af,aj,ah);return ah},DEEP_DATA_REQ:"deep",BROAD_DATA_REQ:"breadth",get_more_data:function(an,ai,am,ah,al,aj){var ao=this.get(an,ai);if(!(ao&&this.track.data_and_mode_compatible(ao,am))){console.log("ERROR: no current data for: ",this.track,an,ai,am,ah,al);return}ao.stale=true;var ag=an;if(aj===this.DEEP_DATA_REQ){$.extend(al,{start_val:ao.data.length+1})}else{if(aj===this.BROAD_DATA_REQ){ag=(ao.max_high?ao.max_high:ao.data[ao.data.length-1][2])+1}}var af=this,ak=this.load_data(ag,ai,am,ah,al);new_data_available=$.Deferred();this.set_data(an,ai,new_data_available);$.when(ak).then(function(ap){if(ap.data){ap.data=ao.data.concat(ap.data);if(ap.max_low){ap.max_low=ao.max_low}if(ap.message){ap.message=ap.message.replace(/[0-9]+/,ap.data.length)}}af.set_data(an,ai,ap);new_data_available.resolve(ap)});return new_data_available},get:function(af,ag){return c.prototype.get.call(this,this.gen_key(af,ag))},set_data:function(ag,ah,af){return this.set(this.gen_key(ag,ah),af)},gen_key:function(af,ah){var ag=af+"_"+ah;return ag},split_key:function(af){return af.split("_")}});var G=function(ag,af,ah){S.call(this,ag,af,ah)};p(G.prototype,S.prototype,c.prototype,{get:S.prototype.get,load_data:function(af,ai,aj,ag,ah){if(ag>1){return{data:null}}return S.prototype.load_data.call(this,af,ai,aj,ag,ah)}});var q=function(ai,ag,af,ah,ak){if(!q.id_counter){q.id_counter=0}this.id=q.id_counter++;this.name=ai;this.view=ag;this.container=af;this.config=new E({track:this,params:[{key:"name",label:"Name",type:"text",default_value:ai}],saved_values:ah,onchange:function(){this.track.set_name(this.track.config.values.name)}});this.prefs=this.config.values;this.drag_handle_class=ak;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(al){al.stopPropagation()});var aj=this;this.container_div.hover(function(){aj.icons_div.show()},function(){aj.icons_div.hide()});$("<div style='clear: both'/>").appendTo(this.container_div)}};q.prototype.action_icons_def=[{name:"toggle_icon",title:"Hide/show content",css_class:"toggle",on_click_fn:function(af){if(af.content_visible){af.action_icons.toggle_icon.addClass("toggle-expand").removeClass("toggle");af.hide_contents();af.content_visible=false}else{af.action_icons.toggle_icon.addClass("toggle").removeClass("toggle-expand");af.content_visible=true;af.show_contents()}}},{name:"settings_icon",title:"Edit settings",css_class:"settings-icon",on_click_fn:function(ag){var ai=function(){hide_modal();$(window).unbind("keypress.check_enter_esc")},af=function(){ag.config.update_from_form($(".dialog-box"));hide_modal();$(window).unbind("keypress.check_enter_esc")},ah=function(aj){if((aj.keyCode||aj.which)===27){ai()}else{if((aj.keyCode||aj.which)===13){af()}}};$(window).bind("keypress.check_enter_esc",ah);show_modal("Configure",ag.config.build_form(),{Cancel:ai,OK:af})}},{name:"remove_icon",title:"Remove",css_class:"remove-icon",on_click_fn:function(af){$(".tipsy").remove();af.remove()}}];p(q.prototype,{init:function(){},can_draw:function(){if(this.enabled&&this.content_visible){return true}return false},request_draw:function(){},_draw:function(){},to_dict:function(){},from_dict:function(af){},update_icons:function(){},set_name:function(af){this.old_name=this.name;this.name=af;this.name_div.text(this.name)},revert_name:function(){this.name=this.old_name;this.name_div.text(this.name)},remove:function(){this.container.remove_drawable(this);this.container_div.hide(0,function(){$(this).remove();view.update_intro_div();view.has_changes=true})},build_container_div:function(){},build_header_div:function(){},add_action_icon:function(ag,ak,aj,ai,af){var ah=this;this.action_icons[ag]=$("<a/>").attr("href","javascript:void(0);").attr("title",ak).addClass("icon-button").addClass(aj).tipsy({gravity:"s"}).click(function(){ai(ah)}).appendTo(this.icons_div)},build_action_icons:function(af){var ah;for(var ag=0;ag<af.length;ag++){ah=af[ag];this.add_action_icon(ah.name,ah.title,ah.css_class,ah.on_click_fn,ah.prepend)}},update_icons:function(){},hide_contents:function(){},show_contents:function(){}});var x=function(aj,ai,ag,af,ah,ak){q.call(this,ai,ag,af,ah,ak);this.obj_type=aj;this.drawables=[]};p(x.prototype,q.prototype,{init:function(){for(var af=0;af<this.drawables.length;af++){this.drawables[af].init()}},_draw:function(){for(var af=0;af<this.drawables.length;af++){this.drawables[af]._draw()}},to_dict:function(){var ag=[];for(var af=0;af<this.drawables.length;af++){ag.push(this.drawables[af].to_dict())}return{name:this.name,prefs:this.prefs,obj_type:this.obj_type,drawables:ag}},from_dict:function(al,af){var ak=new this.constructor(al.name,view,af,al.prefs,view.viewport_container,view);var ag,aj,ai;for(var ah=0;ah<al.drawables.length;ah++){ag=al.drawables[ah];aj=ag.obj_type;if(!aj){aj=ag.track_type}ai=addable_objects[aj].prototype.from_dict(ag,ak);ak.add_drawable(ai)}return ak},add_drawable:function(af){this.drawables.push(af);af.container=this},add_drawable_before:function(ah,af){var ag=this.drawables.indexOf(af);if(ag!=-1){this.drawables.splice(ag,0,ah);return true}return false},replace_drawable:function(ah,af,ag){var ai=this.drawables.indexOf(ah);if(ai!==-1){this.drawables[ai]=af;if(ag){ah.container_div.replaceWith(af.container_div)}return true}return false},remove_drawable:function(ag){var af=this.drawables.indexOf(ag);if(af!=-1){this.drawables.splice(af,1);ag.container=null;return true}return false},move_drawable:function(ag,ah){var af=this.drawables.indexOf(ag);if(af!=-1){this.drawables.splice(af,1);this.drawables.splice(ah,0,ag);return true}return false}});var P=function(ai,ag,af,ah){x.call(this,"DrawableGroup",ai,ag,af,ah,"group-handle");this.content_div=$("<div/>").addClass("content-div").attr("id","group_"+this.id+"_content_div").appendTo(this.container_div);l(this.container_div,this);l(this.content_div,this);m(this.container_div,this.drag_handle_class,".group",this)};p(P.prototype,q.prototype,x.prototype,{action_icons_def:[{name:"composite_icon",title:"Show composite track",css_class:"layers-stack",on_click_fn:function(af){af.show_composite_track()}}].concat(q.prototype.action_icons_def),build_container_div:function(){var af=$("<div/>").addClass("group").attr("id","group_"+this.id);if(this.container){this.container.content_div.append(af)}return af},build_header_div:function(){var af=$("<div/>").addClass("track-header");af.append($("<div/>").addClass(this.drag_handle_class));this.name_div=$("<div/>").addClass("track-name").text(this.name).appendTo(af);return af},hide_contents:function(){this.content_div.hide()},show_contents:function(){this.content_div.show();this.request_draw()},update_icons:function(){var ah,aj=true,ai=this.drawables[0].get_type(),af=0;for(var ag=0;ag<this.drawables.length;ag++){ah=this.drawables[ag];if(ah.get_type()!==ai){can_composite=false;break}if(ah instanceof d){af++}}if(aj||af===1){this.action_icons.composite_icon.show()}else{this.action_icons.composite_icon.hide();$(".tipsy").remove()}},show_composite_track:function(){var af=new h("Composite Track",this.view,this,this.drawables);this.add_drawable(af);af.request_draw()},add_drawable:function(af){x.prototype.add_drawable.call(this,af);this.update_icons()},remove_drawable:function(af){x.prototype.remove_drawable.call(this,af);this.update_icons()},from_dict:function(ai,af){var ah=x.prototype.from_dict.call(this,ai,af);for(var ag=0;ag<ah.drawables.length;ag++){ah.content_div.append(ah.drawables[ag].container_div)}return ah}});var ac=function(af,ai,ah,ag){x.call(this,"View");this.container=af;this.chrom=null;this.vis_id=ah;this.dbkey=ag;this.title=ai;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 ae(af.get(0).ownerDocument);this.reset()};p(ac.prototype,x.prototype,{init:function(){var ah=this.container,af=this;this.top_container=$("<div/>").addClass("top-container").appendTo(ah);this.browser_content_div=$("<div/>").addClass("content").css("position","relative").appendTo(ah);this.bottom_container=$("<div/>").addClass("bottom-container").appendTo(ah);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;l(this.viewport_container,af);this.intro_div=$("<div/>").addClass("intro").appendTo(this.viewport_container).hide();var ai=$("<div/>").text("Add Datasets to Visualization").addClass("action-button").appendTo(this.intro_div).click(function(){add_tracks()});this.nav_labeltrack=$("<div/>").addClass("nav-labeltrack").appendTo(this.bottom_container);this.nav_container=$("<div/>").addClass("nav-container").prependTo(this.top_container);this.nav=$("<div/>").addClass("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 ag=function(aj){if(aj.type==="focusout"||(aj.keyCode||aj.which)===13||(aj.keyCode||aj.which)===27){if((aj.keyCode||aj.which)!==27){af.go_to($(this).val())}$(this).hide();$(this).val("");af.location_span.show();af.chrom_select.show()}};this.nav_input=$("<input/>").addClass("nav-input").hide().bind("keyup focusout",ag).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(){af.location_span.hide();af.chrom_select.hide();af.nav_input.val(af.chrom+":"+af.low+"-"+af.high);af.nav_input.css("display","inline-block");af.nav_input.select();af.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(){af.zoom_out();af.request_redraw()}).appendTo(this.nav_controls);this.zi_link=$("<a/>").attr("id","zoom-in").attr("title","Zoom in").tipsy({gravity:"n"}).click(function(){af.zoom_in();af.request_redraw()}).appendTo(this.nav_controls);this.load_chroms_deferred=this.load_chroms({low:0});this.chrom_select.bind("change",function(){af.change_chrom(af.chrom_select.val())});this.browser_content_div.click(function(aj){$(this).find("input").trigger("blur")});this.browser_content_div.bind("dblclick",function(aj){af.zoom_in(aj.pageX,this.viewport_container)});this.overview_box.bind("dragstart",function(aj,ak){this.current_x=ak.offsetX}).bind("drag",function(aj,al){var am=al.offsetX-this.current_x;this.current_x=al.offsetX;var ak=Math.round(am/af.viewport_container.width()*(af.max_high-af.max_low));af.move_delta(-ak)});this.overview_close.click(function(){af.reset_overview()});this.viewport_container.bind("draginit",function(aj,ak){if(aj.clientX>af.viewport_container.width()-16){return false}}).bind("dragstart",function(aj,ak){ak.original_low=af.low;ak.current_height=aj.clientY;ak.current_x=ak.offsetX}).bind("drag",function(al,an){var aj=$(this);var ao=an.offsetX-an.current_x;var ak=aj.scrollTop()-(al.clientY-an.current_height);aj.scrollTop(ak);an.current_height=al.clientY;an.current_x=an.offsetX;var am=Math.round(ao/af.viewport_container.width()*(af.high-af.low));af.move_delta(am)}).bind("mousewheel",function(al,an,ak,aj){if(ak){ak*=50;var am=Math.round(-ak/af.viewport_container.width()*(af.high-af.low));af.move_delta(am)}});this.top_labeltrack.bind("dragstart",function(aj,ak){return $("<div />").css({height:af.browser_content_div.height()+af.top_labeltrack.height()+af.nav_labeltrack.height()+1,top:"0px",position:"absolute","background-color":"#ccf",opacity:0.5,"z-index":1000}).appendTo($(this))}).bind("drag",function(an,ao){$(ao.proxy).css({left:Math.min(an.pageX,ao.startX),width:Math.abs(an.pageX-ao.startX)});var ak=Math.min(an.pageX,ao.startX)-af.container.offset().left,aj=Math.max(an.pageX,ao.startX)-af.container.offset().left,am=(af.high-af.low),al=af.viewport_container.width();af.update_location(Math.round(ak/al*am)+af.low,Math.round(aj/al*am)+af.low)}).bind("dragend",function(ao,ap){var ak=Math.min(ao.pageX,ap.startX),aj=Math.max(ao.pageX,ap.startX),am=(af.high-af.low),al=af.viewport_container.width(),an=af.low;af.low=Math.round(ak/al*am)+an;af.high=Math.round(aj/al*am)+an;$(ap.proxy).remove();af.request_redraw()});this.add_label_track(new ab(this,{content_div:this.top_labeltrack}));this.add_label_track(new ab(this,{content_div:this.nav_labeltrack}));$(window).bind("resize",function(){af.resize_window()});$(document).bind("redraw",function(){af.redraw()});this.reset();$(window).trigger("resize")},update_intro_div:function(){if(this.drawables.length===0){this.intro_div.show()}else{this.intro_div.hide()}},update_location:function(af,ag){this.location_span.text(commatize(af)+" - "+commatize(ag));this.nav_input.val(this.chrom+":"+commatize(af)+"-"+commatize(ag))},load_chroms:function(ah){ah.num=v;ah.dbkey=this.dbkey;var af=this,ag=$.Deferred();$.ajax({url:chrom_url,data:ah,dataType:"json",success:function(aj){if(aj.chrom_info.length===0){alert("Invalid chromosome: "+ah.chrom);return}if(aj.reference){af.add_label_track(new z(af))}af.chrom_data=aj.chrom_info;var am='<option value="">Select Chrom/Contig</option>';for(var al=0,ai=af.chrom_data.length;al<ai;al++){var ak=af.chrom_data[al].chrom;am+='<option value="'+ak+'">'+ak+"</option>"}if(aj.prev_chroms){am+='<option value="previous">Previous '+v+"</option>"}if(aj.next_chroms){am+='<option value="next">Next '+v+"</option>"}af.chrom_select.html(am);af.chrom_start_index=aj.start_index;ag.resolve(aj)},error:function(){alert("Could not load chroms for this dbkey:",af.dbkey)}});return ag},change_chrom:function(ak,ag,am){if(!ak||ak==="None"){return}var ah=this;if(ak==="previous"){ah.load_chroms({low:this.chrom_start_index-v});return}if(ak==="next"){ah.load_chroms({low:this.chrom_start_index+v});return}var al=$.grep(ah.chrom_data,function(an,ao){return an.chrom===ak})[0];if(al===undefined){ah.load_chroms({chrom:ak},function(){ah.change_chrom(ak,ag,am)});return}else{if(ak!==ah.chrom){ah.chrom=ak;ah.chrom_select.val(ah.chrom);ah.max_high=al.len-1;ah.reset();ah.request_redraw(true);for(var aj=0,af=ah.drawables.length;aj<af;aj++){var ai=ah.drawables[aj];if(ai.init){ai.init()}}}if(ag!==undefined&&am!==undefined){ah.low=Math.max(ag,0);ah.high=Math.min(am,ah.max_high)}ah.reset_overview();ah.request_redraw()}},go_to:function(aj){aj=aj.replace(/ |,/g,"");var an=this,af,ai,ag=aj.split(":"),al=ag[0],am=ag[1];if(am!==undefined){try{var ak=am.split("-");af=parseInt(ak[0],10);ai=parseInt(ak[1],10)}catch(ah){return false}}an.change_chrom(al,af,ai)},move_fraction:function(ah){var af=this;var ag=af.high-af.low;this.move_delta(ah*ag)},move_delta:function(ah){var af=this;var ag=af.high-af.low;if(af.low-ah<af.max_low){af.low=af.max_low;af.high=af.max_low+ag}else{if(af.high-ah>af.max_high){af.high=af.max_high;af.low=af.max_high-ag}else{af.high-=ah;af.low-=ah}}af.request_redraw()},add_drawable:function(af){x.prototype.add_drawable.call(this,af);af.init();this.has_changes=true;this.update_intro_div()},add_label_track:function(af){af.view=this;af.init();this.label_tracks.push(af)},remove_drawable:function(ah,ag){x.prototype.remove_drawable.call(this,ah);if(ag){var af=this;ah.container_div.hide(0,function(){$(this).remove();af.update_intro_div()});this.has_changes=true}},reset:function(){this.low=this.max_low;this.high=this.max_high;this.viewport_container.find(".yaxislabel").remove()},request_redraw:function(an,af,am,ag){var al=this,aj=(ag?[ag]:al.drawables),ah;var ag;for(var ak=0;ak<aj.length;ak++){ag=aj[ak];ah=-1;for(var ai=0;ai<al.tracks_to_be_redrawn.length;ai++){if(al.tracks_to_be_redrawn[ai][0]===ag){ah=ai;break}}if(ah<0){al.tracks_to_be_redrawn.push([ag,af,am])}else{al.tracks_to_be_redrawn[ak][1]=af;al.tracks_to_be_redrawn[ak][2]=am}}requestAnimationFrame(function(){al._redraw(an)})},_redraw:function(ap){var am=this.low,ai=this.high;if(am<this.max_low){am=this.max_low}if(ai>this.max_high){ai=this.max_high}var ao=this.high-this.low;if(this.high!==0&&ao<this.min_separation){ai=am+this.min_separation}this.low=Math.floor(am);this.high=Math.ceil(ai);this.resolution=Math.pow(A,Math.ceil(Math.log((this.high-this.low)/Q)/Math.log(A)));this.zoom_res=Math.pow(u,Math.max(0,Math.ceil(Math.log(this.resolution,u)/Math.log(u))));var af=(this.low/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var al=((this.high-this.low)/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var aq=13;this.overview_box.css({left:af,width:Math.max(aq,al)}).show();if(al<aq){this.overview_box.css("left",af-(aq-al)/2)}if(this.overview_highlight){this.overview_highlight.css({left:af,width:al})}this.update_location(this.low,this.high);if(!ap){var ah,ag,an;for(var aj=0,ak=this.tracks_to_be_redrawn.length;aj<ak;aj++){ah=this.tracks_to_be_redrawn[aj][0];ag=this.tracks_to_be_redrawn[aj][1];an=this.tracks_to_be_redrawn[aj][2];if(ah){ah._draw(ag,an)}}this.tracks_to_be_redrawn=[];for(aj=0,ak=this.label_tracks.length;aj<ak;aj++){this.label_tracks[aj]._draw()}}},zoom_in:function(ag,ah){if(this.max_high===0||this.high-this.low<this.min_separation){return}var ai=this.high-this.low,aj=ai/2+this.low,af=(ai/this.zoom_factor)/2;if(ag){aj=ag/this.viewport_container.width()*(this.high-this.low)+this.low}this.low=Math.round(aj-af);this.high=Math.round(aj+af);this.request_redraw()},zoom_out:function(){if(this.max_high===0){return}var ag=this.high-this.low,ah=ag/2+this.low,af=(ag*this.zoom_factor)/2;this.low=Math.round(ah-af);this.high=Math.round(ah+af);this.request_redraw()},resize_window:function(){this.viewport_container.height(this.container.height()-this.top_container.height()-this.bottom_container.height());this.nav_container.width(this.container.width());this.request_redraw()},set_overview:function(ah){if(this.overview_drawable){if(this.overview_drawable.dataset_id===ah.dataset_id){return}this.overview_viewport.find(".track").remove()}var ag=ah.copy({content_div:this.overview_viewport}),af=this;ag.header_div.hide();ag.is_overview=true;af.overview_drawable=ag;this.overview_drawable.postdraw_actions=function(){af.overview_highlight.show().height(af.overview_drawable.content_div.height());af.overview_viewport.height(af.overview_drawable.content_div.height()+af.overview_box.outerHeight());af.overview_close.show();af.resize_window()};af.overview_drawable.request_draw();af.has_changes=true},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 r=function(ah,al){this.track=ah;this.name=al.name;this.params=[];var at=al.params;for(var ai=0;ai<at.length;ai++){var an=at[ai],ag=an.name,ar=an.label,aj=unescape(an.html),au=an.value,ap=an.type;if(ap==="number"){this.params[this.params.length]=new f(ag,ar,aj,au,an.min,an.max)}else{if(ap=="select"){this.params[this.params.length]=new N(ag,ar,aj,au)}else{console.log("WARNING: unrecognized tool parameter type:",ag,ap)}}}this.parent_div=$("<div/>").addClass("dynamic-tool").hide();this.parent_div.bind("drag",function(aw){aw.stopPropagation()}).click(function(aw){aw.stopPropagation()}).bind("dblclick",function(aw){aw.stopPropagation()});var aq=$("<div class='tool-name'>").appendTo(this.parent_div).text(this.name);var ao=this.params;var am=this;$.each(this.params,function(ax,aA){var az=$("<div>").addClass("param-row").appendTo(am.parent_div);var aw=$("<div>").addClass("param-label").text(aA.label).appendTo(az);var ay=$("<div/>").addClass("slider").html(aA.html).appendTo(az);ay.find(":input").val(aA.value);$("<div style='clear: both;'/>").appendTo(az)});this.parent_div.find("input").click(function(){$(this).select()});var av=$("<div>").addClass("param-row").appendTo(this.parent_div);var ak=$("<input type='submit'>").attr("value","Run on complete dataset").appendTo(av);var af=$("<input type='submit'>").attr("value","Run on visible region").css("margin-left","3em").appendTo(av);var am=this;af.click(function(){am.run_on_region()});ak.click(function(){am.run_on_dataset()})};p(r.prototype,{get_param_values_dict:function(){var af={};this.parent_div.find(":input").each(function(){var ag=$(this).attr("name"),ah=$(this).val();af[ag]=JSON.stringify(ah)});return af},get_param_values:function(){var ag=[];var af={};this.parent_div.find(":input").each(function(){var ah=$(this).attr("name"),ai=$(this).val();if(ah){ag[ag.length]=ai}});return ag},run_on_dataset:function(){var af=this;af.run({dataset_id:this.track.original_dataset_id,tool_id:af.name},null,function(ag){show_modal(af.name+" is Running",af.name+" is running on the complete dataset. Tool outputs are in dataset's history.",{Close:hide_modal})})},run_on_region:function(){var ag={dataset_id:this.track.original_dataset_id,chrom:this.track.view.chrom,low:this.track.view.low,high:this.track.view.high,tool_id:this.name},aj=this.track,ah=ag.tool_id+aj.tool_region_and_parameters_str(ag.chrom,ag.low,ag.high),af;if(aj.container===view){var ai=new P(this.name,this.track.view);aj.container.replace_drawable(aj,ai,true);aj.container.remove_drawable(aj);ai.add_drawable(aj);aj.container_div.appendTo(ai.content_div);af=ai}else{af=aj.container}var ak=new aj.constructor(ah,view,af,"hda");ak.init_for_tool_data();ak.change_mode(aj.mode);af.add_drawable(ak);ak.content_div.text("Starting job.");this.run(ag,ak,function(al){ak.dataset_id=al.dataset_id;ak.content_div.text("Running job.");ak.init()})},run:function(ag,ah,ai){$.extend(ag,this.get_param_values_dict());var af=function(){$.getJSON(rerun_tool_url,ag,function(aj){if(aj==="no converter"){ah.container_div.addClass("error");ah.content_div.text(J)}else{if(aj.error){ah.container_div.addClass("error");ah.content_div.text(w+aj.message)}else{if(aj==="pending"){ah.container_div.addClass("pending");ah.content_div.text("Converting input data so that it can be used quickly with tool.");setTimeout(af,2000)}else{ai(aj)}}}})};af()}});var N=function(ag,af,ah,ai){this.name=ag;this.label=af;this.html=ah;this.value=ai};var f=function(ah,ag,aj,ak,ai,af){N.call(this,ah,ag,aj,ak);this.min=ai;this.max=af};var g=function(ag,af,ah,ai){this.name=ag;this.index=af;this.tool_id=ah;this.tool_exp_name=ai};var V=function(ag,af,ah,ai){g.call(this,ag,af,ah,ai);this.low=-Number.MAX_VALUE;this.high=Number.MAX_VALUE;this.min=Number.MAX_VALUE;this.max=-Number.MAX_VALUE;this.container=null;this.slider=null;this.slider_label=null};p(V.prototype,{applies_to:function(af){if(af.length>this.index){return true}return false},keep:function(af){if(!this.applies_to(af)){return true}var ag=af[this.index];return(isNaN(ag)||(ag>=this.low&&ag<=this.high))},update_attrs:function(ag){var af=false;if(!this.applies_to(ag)){return af}if(ag[this.index]<this.min){this.min=Math.floor(ag[this.index]);af=true}if(ag[this.index]>this.max){this.max=Math.ceil(ag[this.index]);af=true}return af},update_ui_elt:function(){if(this.min!=this.max){this.container.show()}else{this.container.hide()}var ah=function(ak,ai){var aj=ai-ak;return(aj<=2?0.01:1)};var ag=this.slider.slider("option","min"),af=this.slider.slider("option","max");if(this.min<ag||this.max>af){this.slider.slider("option","min",this.min);this.slider.slider("option","max",this.max);this.slider.slider("option","step",ah(this.min,this.max));this.slider.slider("option","values",[this.min,this.max])}}});var aa=function(ah,aq){this.track=ah;this.filters=[];for(var al=0;al<aq.length;al++){var af=aq[al],ag=af.name,ap=af.type,an=af.index,at=af.tool_id,ai=af.tool_exp_name;if(ap==="int"||ap==="float"){this.filters[al]=new V(ag,an,at,ai)}else{console.log("ERROR: unsupported filter: ",ag,ap)}}var ao=function(au,av,aw){au.click(function(){var ax=av.text();max=parseFloat(aw.slider("option","max")),input_size=(max<=1?4:max<=1000000?max.toString().length:6),multi_value=false;if(aw.slider("option","values")){input_size=2*input_size+1;multi_value=true}av.text("");$("<input type='text'/>").attr("size",input_size).attr("maxlength",input_size).attr("value",ax).appendTo(av).focus().select().click(function(ay){ay.stopPropagation()}).blur(function(){$(this).remove();av.text(ax)}).keyup(function(aC){if(aC.keyCode===27){$(this).trigger("blur")}else{if(aC.keyCode===13){var aA=aw.slider("option","min"),ay=aw.slider("option","max"),aB=function(aD){return(isNaN(aD)||aD>ay||aD<aA)},az=$(this).val();if(!multi_value){az=parseFloat(az);if(aB(az)){alert("Parameter value must be in the range ["+aA+"-"+ay+"]");return $(this)}}else{az=az.split("-");az=[parseFloat(az[0]),parseFloat(az[1])];if(aB(az[0])||aB(az[1])){alert("Parameter value must be in the range ["+aA+"-"+ay+"]");return $(this)}}aw.slider((multi_value?"values":"value"),az)}}})})};this.parent_div=$("<div/>").addClass("filters").hide();this.parent_div.bind("drag",function(au){au.stopPropagation()}).click(function(au){au.stopPropagation()}).bind("dblclick",function(au){au.stopPropagation()}).bind("keydown",function(au){au.stopPropagation()});var aj=this;$.each(this.filters,function(aA,av){av.container=$("<div/>").addClass("filter-row slider-row").appendTo(aj.parent_div);var au=$("<div/>").addClass("elt-label").appendTo(av.container);var aD=$("<span/>").addClass("slider-name").text(av.name+" ").appendTo(au);var aw=$("<span/>");var ax=$("<span/>").addClass("slider-value").appendTo(au).append("[").append(aw).append("]");var aC=$("<div/>").addClass("slider").appendTo(av.container);av.control_element=$("<div/>").attr("id",av.name+"-filter-control").appendTo(aC);var ay=[0,0];av.control_element.slider({range:true,min:Number.MAX_VALUE,max:-Number.MIN_VALUE,values:[0,0],slide:function(aG,aH){var aF=aH.values;aw.text(aF[0]+"-"+aF[1]);av.low=aF[0];av.high=aF[1];aj.track.request_draw(true,true)},change:function(aF,aG){av.control_element.slider("option","slide").call(av.control_element,aF,aG)}});av.slider=av.control_element;av.slider_label=aw;ao(ax,aw,av.control_element);var aE=$("<div/>").addClass("display-controls").appendTo(av.container),az=create_action_icon("Use filter for data transparency","layer-transparent",function(){if(aj.alpha_filter!==av){aj.alpha_filter=av;$(".layer-transparent").removeClass("active").hide();az.addClass("active").show()}else{aj.alpha_filter=null;az.removeClass("active")}aj.track.request_draw(true,true)}).appendTo(aE).hide(),aB=create_action_icon("Use filter for data height","arrow-resize-090",function(){if(aj.height_filter!==av){aj.height_filter=av;$(".arrow-resize-090").removeClass("active").hide();aB.addClass("active").show()}else{aj.height_filter=null;aB.removeClass("active")}aj.track.request_draw(true,true)}).appendTo(aE).hide();av.container.hover(function(){az.show();aB.show()},function(){if(aj.alpha_filter!==av){az.hide()}if(aj.height_filter!==av){aB.hide()}});$("<div style='clear: both;'/>").appendTo(av.container)});if(this.filters.length!==0){var ar=$("<div/>").addClass("param-row").appendTo(this.parent_div);var am=$("<input type='submit'/>").attr("value","Run on complete dataset").appendTo(ar);var ak=this;am.click(function(){ak.run_on_dataset()})}};p(aa.prototype,{reset_filters:function(){for(var af=0;af<this.filters.length;af++){filter=this.filters[af];filter.slider.slider("option","values",[filter.min,filter.max])}this.alpha_filter=null;this.height_filter=null},run_on_dataset:function(){var an=function(ar,ap,aq){if(!(ap in ar)){ar[ap]=aq}return ar[ap]};var ah={},af,ag,ai;for(var aj=0;aj<this.filters.length;aj++){af=this.filters[aj];if(af.tool_id){if(af.min!=af.low){ag=an(ah,af.tool_id,[]);ag[ag.length]=af.tool_exp_name+" >= "+af.low}if(af.max!=af.high){ag=an(ah,af.tool_id,[]);ag[ag.length]=af.tool_exp_name+" <= "+af.high}}}var al=[];for(var ao in ah){al[al.length]=[ao,ah[ao]]}var am=al.length;(function ak(aw,at){var aq=at[0],ar=aq[0],av=aq[1],au="("+av.join(") and (")+")",ap={cond:au,input:aw,target_dataset_id:aw,tool_id:ar},at=at.slice(1);$.getJSON(run_tool_url,ap,function(ax){if(ax.error){show_modal("Filter Dataset","Error running tool "+ar,{Close:hide_modal})}else{if(at.length===0){show_modal("Filtering Dataset","Filter(s) are running on the complete dataset. Outputs are in dataset's history.",{Close:hide_modal})}else{ak(ax.dataset_id,at)}}})})(this.track.dataset_id,al)}});var B=function(af,ag){L.Scaler.call(this,ag);this.filter=af};B.prototype.gen_val=function(af){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(af[this.filter.index])-this.filter.low)/(this.filter.high-this.filter.low))};var E=function(af){this.track=af.track;this.params=af.params;this.values={};this.restore_values((af.saved_values?af.saved_values:{}));this.onchange=af.onchange};p(E.prototype,{restore_values:function(af){var ag=this;$.each(this.params,function(ah,ai){if(af[ai.key]!==undefined){ag.values[ai.key]=af[ai.key]}else{ag.values[ai.key]=ai.default_value}})},build_form:function(){var ai=this;var af=$("<div />");var ah;function ag(al,aj){for(var an=0;an<al.length;an++){ah=al[an];if(ah.hidden){continue}var ak="param_"+an;var ar=ai.values[ah.key];var at=$("<div class='form-row' />").appendTo(aj);at.append($("<label />").attr("for",ak).text(ah.label+":"));if(ah.type==="bool"){at.append($('<input type="checkbox" />').attr("id",ak).attr("name",ak).attr("checked",ar))}else{if(ah.type==="text"){at.append($('<input type="text"/>').attr("id",ak).val(ar).click(function(){$(this).select()}))}else{if(ah.type=="select"){var ap=$("<select />").attr("id",ak);for(var am=0;am<ah.options.length;am++){$("<option/>").text(ah.options[am].label).attr("value",ah.options[am].value).appendTo(ap)}ap.val(ar);at.append(ap)}else{if(ah.type==="color"){var ao=$("<input />").attr("id",ak).attr("name",ak).val(ar);var aq=$("<div class='tipsy tipsy-west' style='position: absolute;' />").hide();(function(au,av){var ax=$("<div style='background-color: black; padding: 10px;'></div>").appendTo(av);var aw=$("<div/>").appendTo(ax).farbtastic({width:100,height:100,callback:au,color:ar});$("<div />").append(au).append(av).appendTo(at).bind("click",function(ay){$(".tipsy").hide();av.css({left:$(this).position().left+$(au).width()+5,top:$(this).position().top-($(av).height()/2)+($(au).height()/2)}).show();$(document).bind("click.color-picker",function(){av.hide();$(document).unbind("click.color-picker")});ay.stopPropagation()})})(ao,aq)}else{at.append($("<input />").attr("id",ak).attr("name",ak).val(ar))}}}}if(ah.help){at.append($("<div class='help'/>").text(ah.help))}}}ag(this.params,af);return af},update_from_form:function(af){var ah=this;var ag=false;$.each(this.params,function(ai,ak){if(!ak.hidden){var al="param_"+ai;var aj=af.find("#"+al).val();if(ak.type==="float"){aj=parseFloat(aj)}else{if(ak.type==="int"){aj=parseInt(aj)}else{if(ak.type==="bool"){aj=af.find("#"+al).is(":checked")}}}if(aj!==ah.values[ak.key]){ah.values[ak.key]=aj;ag=true}}});if(ag){this.onchange()}}});var b=function(af,ai,ah,ag,aj){this.track=af;this.index=ai;this.low=ai*Q*ah;this.high=(ai+1)*Q*ah;this.resolution=ah;this.html_elt=$("<div class='track-tile'/>").append(ag);this.data=aj;this.stale=false};b.prototype.predisplay_actions=function(){};var k=function(af,ai,ah,ag,aj,ak){b.call(this,af,ai,ah,ag,aj);this.max_val=ak};p(k.prototype,b.prototype);var O=function(ai,an,aj,ah,al,at,am,au,ag,aq){b.call(this,ai,an,aj,ah,al);this.mode=am;this.feature_mapper=aq;this.has_icons=false;if(this.message||!ag){this.has_icons=true;var ao=this;ah=this.html_elt.children()[0],message_div=$("<div/>").addClass("tile-message").css({height:C-1,width:ah.width}).prependTo(this.html_elt);if(!ag){var ap=$("<a href='javascript:void(0);'/>").addClass("icon exclamation").attr("title","To minimize track height, not all features in this region are displayed. Click to display more.").tipsy({gravity:"s"}).appendTo(message_div).click(function(){$(".tipsy").hide();ao.track.slotters[at].max_rows*=2;ao.track.request_draw(true)})}if(this.message){var ar=al.length,ak=$("<a href='javascript:void(0);'/>").addClass("icon more-down").attr("title","For speed, only the first "+ar+" features in this region were obtained from server. Click to get more data including depth").tipsy({gravity:"s"}).appendTo(message_div),af=$("<a href='javascript:void(0);'/>").addClass("icon more-across").attr("title","For speed, only the first "+ar+" features in this region were obtained from server. Click to get more data excluding depth").tipsy({gravity:"s"}).appendTo(message_div);ak.click(function(){ao.stale=true;ai.data_manager.get_more_data(ao.low,ao.high,ai.mode,ao.resolution,{},ai.data_manager.DEEP_DATA_REQ);$(".tipsy").hide();ai.request_draw()}).dblclick(function(av){av.stopPropagation()});af.click(function(){ao.stale=true;ai.data_manager.get_more_data(ao.low,ao.high,ai.mode,ao.resolution,{},ai.data_manager.BROAD_DATA_REQ);$(".tipsy").hide();ai.request_draw()}).dblclick(function(av){av.stopPropagation()})}}};p(O.prototype,b.prototype);O.prototype.predisplay_actions=function(){var ag=this,af={};if(ag.mode!=="Pack"){return}$(this.html_elt).hover(function(){this.hovered=true;$(this).mousemove()},function(){this.hovered=false;$(this).siblings(".feature-popup").remove()}).mousemove(function(ar){if(!this.hovered){return}var am=$(this).offset(),aq=ar.pageX-am.left,ap=ar.pageY-am.top,aw=ag.feature_mapper.get_feature_data(aq,ap),an=(aw?aw[0]:null);$(this).siblings(".feature-popup").each(function(){if(!an||$(this).attr("id")!==an.toString()){$(this).remove()}});if(aw){var ai=af[an];if(!ai){var an=aw[0],at={name:aw[3],start:aw[1],end:aw[2],strand:aw[4]},al=ag.track.filters_manager.filters,ak;for(var ao=0;ao<al.length;ao++){ak=al[ao];at[ak.name]=aw[ak.index]}var ai=$("<div/>").attr("id",an).addClass("feature-popup"),ax=$("<table/>"),av,au,ay;for(av in at){au=at[av];ay=$("<tr/>").appendTo(ax);$("<th/>").appendTo(ay).text(av);$("<td/>").attr("align","left").appendTo(ay).text(typeof(au)=="number"?Z(au,2):au)}ai.append($("<div class='feature-popup-inner'>").append(ax));af[an]=ai}ai.appendTo($(ag.html_elt).parent());var aj=aq+parseInt(ag.html_elt.css("left"))-ai.width()/2,ah=ap+parseInt(ag.html_elt.css("top"))+7;ai.css("left",aj+"px").css("top",ah+"px")}else{if(!ar.isPropagationStopped()){ar.stopPropagation();$(this).siblings().each(function(){$(this).trigger(ar)})}}}).mouseleave(function(){$(this).siblings(".feature-popup").remove()})};var i=function(ai,ag,af,ah,ak,aj,al){q.call(this,ai,ag,af,{},"draghandle");this.data_url=(aj?aj:default_data_url);this.data_url_extra_params={};this.data_query_wait=(al?al:K);this.dataset_check_url=converted_datasets_state_url;this.data_manager=(ak?ak:new S(H,this));this.content_div=$("<div class='track-content'>").appendTo(this.container_div);if(this.container){this.container.content_div.append(this.container_div)}};p(i.prototype,q.prototype,{action_icons_def:[{name:"mode_icon",title:"Set display mode",css_class:"chevron-expand",on_click_fn:function(){}},q.prototype.action_icons_def[0],{name:"overview_icon",title:"Set as overview",css_class:"overview-icon",on_click_fn:function(af){af.view.set_overview(af)}},q.prototype.action_icons_def[1],{name:"filters_icon",title:"Filters",css_class:"filters-icon",on_click_fn:function(af){af.filters_div.toggle();af.filters_manager.reset_filters()}},{name:"tools_icon",title:"Tools",css_class:"tools-icon",on_click_fn:function(af){af.dynamic_tool_div.toggle();if(af.dynamic_tool_div.is(":visible")){af.set_name(af.name+af.tool_region_and_parameters_str())}else{af.revert_name()}$(".tipsy").remove()}},q.prototype.action_icons_def[2]],can_draw:function(){if(this.dataset_id&&q.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 af=$("<div class='track-header'/>");if(this.view.editor){this.drag_div=$("<div/>").addClass(this.drag_handle_class).appendTo(af)}this.name_div=$("<div/>").addClass("track-name").appendTo(af).text(this.name).attr("id",this.name.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9\-]/g,"").toLowerCase());return af},build_action_icons:function(){q.prototype.build_action_icons.call(this,this.action_icons_def);var ag=this;if(ag.display_modes!==undefined){var ak=(ag.config&&ag.config.values.mode?ag.config.values.mode:ag.display_modes[0]);ag.mode=ak;this.action_icons.mode_icon.attr("title","Set display mode (now: "+ag.mode+")");var ai={};for(var ah=0,af=ag.display_modes.length;ah<af;ah++){var aj=ag.display_modes[ah];ai[aj]=function(al){return function(){ag.change_mode(al);ag.icons_div.show();ag.container_div.mouseleave(function(){ag.icons_div.hide()})}}(aj)}make_popupmenu(this.action_icons.mode_icon,ai)}},hide_contents:function(){this.content_div.children().remove();this.content_div.hide();this.container_div.find(".yaxislabel, .track-resize").hide()},show_contents:function(){this.content_div.show();this.container_div.find(".yaxislabel, .track-resize").show();this.request_draw()},get_type:function(){if(this instanceof ab){return"LabelTrack"}else{if(this instanceof z){return"ReferenceTrack"}else{if(this instanceof j){return"LineTrack"}else{if(this instanceof W){return"ReadTrack"}else{if(this instanceof U){return"VcfTrack"}else{if(this instanceof h){return"CompositeTrack"}else{if(this instanceof d){return"FeatureTrack"}}}}}}}return""},init:function(){var af=this;af.enabled=false;af.tile_cache.clear();af.data_manager.clear();af.content_div.css("height","auto");af.content_div.children().remove();af.container_div.removeClass("nodata error pending");if(!af.dataset_id){return}$.getJSON(converted_datasets_state_url,{hda_ldda:af.hda_ldda,dataset_id:af.dataset_id,chrom:af.view.chrom},function(ag){if(!ag||ag==="error"||ag.kind==="error"){af.container_div.addClass("error");af.content_div.text(o);if(ag.message){var ah=$(" <a href='javascript:void(0);'></a>").text("View error").click(function(){show_modal("Trackster Error","<pre>"+ag.message+"</pre>",{Close:hide_modal})});af.content_div.append(ah)}}else{if(ag==="no converter"){af.container_div.addClass("error");af.content_div.text(J)}else{if(ag==="no data"||(ag.data!==undefined&&(ag.data===null||ag.data.length===0))){af.container_div.addClass("nodata");af.content_div.text(D)}else{if(ag==="pending"){af.container_div.addClass("pending");af.content_div.text(t);setTimeout(function(){af.init()},af.data_query_wait)}else{if(ag.status==="data"){if(ag.valid_chroms){af.valid_chroms=ag.valid_chroms;af.update_icons()}af.content_div.text(Y);if(af.view.chrom){af.content_div.text("");af.content_div.css("height",af.height_px+"px");af.enabled=true;$.when(af.predraw_init()).done(function(){af.container_div.removeClass("nodata error pending");af.request_draw()})}}}}}}});this.update_icons()},predraw_init:function(){}});var M=function(aj,ah,ag,ai,am,al,ak){i.call(this,aj,ah,ag,ai,ak);var af=this,ah=af.view;m(af.container_div,af.drag_handle_class,".group",af);this.filters_manager=new aa(this,(am!==undefined?am:{}));this.filters_available=false;this.filters_visible=false;this.tool=(al!==undefined&&obj_length(al)>0?new r(this,al):undefined);this.tile_cache=new c(R);if(this.header_div){if(this.filters_manager){this.filters_div=this.filters_manager.parent_div;this.header_div.after(this.filters_div)}if(this.tool){this.dynamic_tool_div=this.tool.parent_div;this.header_div.after(this.dynamic_tool_div)}}};p(M.prototype,q.prototype,i.prototype,{copy:function(af){var ag=new this.constructor(this.name,this.view,af,this.hda_ldda,this.dataset_id,this.prefs,this.filters,this.tool,this.data_manager);ag.change_mode(this.mode);ag.enabled=this.enabled;return ag},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,}},from_dict:function(ah,ag){var af=new this.constructor(ah.name,view,ag,ah.hda_ldda,ah.dataset_id,ah.prefs,ah.filters,ah.tool);if(ah.mode){af.change_mode(ah.mode)}return af},change_mode:function(ag){var af=this;af.mode=ag;af.config.values.mode=ag;af.tile_cache.clear();af.request_draw();this.action_icons.mode_icon.attr("title","Set display mode (now: "+af.mode+")");return af},update_icons:function(){var af=this;if(af.filters_available){af.action_icons.filters_icon.show()}else{af.action_icons.filters_icon.hide()}if(af.tool){af.action_icons.tools_icon.show()}else{af.action_icons.tools_icon.hide()}},_gen_tile_cache_key:function(ag,ah,af){return ag+"_"+ah+"_"+af},request_draw:function(ag,af){this.view.request_redraw(false,ag,af,this)},_draw:function(ah,ar){if(!this.can_draw()){return}var ap=this.view.low,al=this.view.high,an=al-ap,ai=this.view.container.width(),av=ai/an,ak=this.view.resolution,au=this.content_div;if(this.is_overview){ap=this.view.max_low;al=this.view.max_high;ak=Math.pow(A,Math.ceil(Math.log((view.max_high-view.max_low)/Q)/Math.log(A)));av=ai/(view.max_high-view.max_low)}if(!ar){this.content_div.children().addClass("remove")}this.max_height=0;var ag=Math.floor(ap/ak/Q);var ao=true;var at=[];var af=0;var am=function(aw){return(aw&&"track" in aw)};while((ag*Q*ak)<al){var aq=this.draw_helper(ah,ai,ag,ak,au,av);if(am(aq)){at.push(aq)}else{ao=false}ag+=1;af++}if(!ar){this.content_div.children(".remove").remove()}var aj=this;if(ao){aj.postdraw_actions(at,ai,av,ar)}},postdraw_actions:function(ai,aj,al,af){var ah=this;var ak=false;for(var ag=0;ag<ai.length;ag++){if(ai[ag].has_icons){ak=true;break}}if(ak){for(var ag=0;ag<ai.length;ag++){tile=ai[ag];if(!tile.has_icons){tile.html_elt.css("padding-top",C)}}}},draw_helper:function(af,ar,ax,av,ak,al,at){var aq=this,aA=this._gen_tile_cache_key(ar,al,ax),ay=ax*Q*av,ag=ay+Q*av;if(!at){at={}}var az=(af?undefined:aq.tile_cache.get(aA));if(az){aq.show_tile(az,ak,al);return az}var ao=true;var aw=aq.data_manager.get_data(ay,ag,aq.mode,av,aq.data_url_extra_params);if(is_deferred(aw)){ao=false}var am;if(view.reference_track&&al>view.canvas_manager.char_width_px){am=view.reference_track.data_manager.get_data(ay,ag,aq.mode,av,view.reference_track.data_url_extra_params);if(is_deferred(am)){ao=false}}if(ao){p(aw,at.more_tile_data);var an=aq.mode;if(an==="Auto"){an=aq.get_mode(aw);aq.update_auto_mode(an)}var ah=aq.view.canvas_manager.new_canvas(),ai=aq._get_tile_bounds(ax,av),ay=ai[0],ag=ai[1],ar=Math.ceil((ag-ay)*al)+aq.left_offset,ap=aq.get_canvas_height(aw,an,al,ar);ah.width=ar;ah.height=ap;var au=ah.getContext("2d");au.translate(this.left_offset,0);var az=aq.draw_tile(aw,au,an,av,ax,al,am);if(az!==undefined){aq.tile_cache.set(aA,az);aq.show_tile(az,ak,al)}return az}var aj=$.Deferred();$.when(aw,am).then(function(){view.request_redraw(false,false,false,aq);aj.resolve()});return aj},get_canvas_height:function(af,ah,ai,ag){return this.height_px},draw_tile:function(af,ah,ak,aj,ag,al,ai){console.log("Warning: TiledTrack.draw_tile() not implemented.")},show_tile:function(ah,aj,ak){var ag=this,af=ah.html_elt;ah.predisplay_actions();var ai=(ah.low-(this.is_overview?this.view.max_low:this.view.low))*ak;if(this.left_offset){ai-=this.left_offset}af.css({position:"absolute",top:0,left:ai,height:""});if(af.hasClass("remove")){af.removeClass("remove")}else{aj.append(af)}ag.max_height=Math.max(ag.max_height,af.height());ag.content_div.css("height",ag.max_height+"px");aj.children().css("height",ag.max_height+"px")},_get_tile_bounds:function(af,ag){var ai=af*Q*ag,aj=Q*ag,ah=(ai+aj<=this.view.max_high?ai+aj:this.view.max_high);return[ai,ah]},tool_region_and_parameters_str:function(ah,af,ai){var ag=this,aj=(ah!==undefined&&af!==undefined&&ai!==undefined?ah+":"+af+"-"+ai:"all");return" - region=["+aj+"], parameters=["+ag.tool.get_param_values().join(", ")+"]"},data_and_mode_compatible:function(af,ag){return true},init_for_tool_data:function(){this.data_url=raw_data_url;this.data_query_wait=1000;this.dataset_check_url=dataset_state_url;this.predraw_init=function(){var ag=this;var af=function(){if(ag.data_manager.size()===0){setTimeout(af,300)}else{ag.data_url=default_data_url;ag.data_query_wait=K;ag.dataset_state_url=converted_datasets_state_url;$.getJSON(ag.dataset_state_url,{dataset_id:ag.dataset_id,hda_ldda:ag.hda_ldda},function(ah){})}};af()}}});var ab=function(ag,af){i.call(this,"label",ag,af,false,{});this.container_div.addClass("label-track")};p(ab.prototype,i.prototype,{build_header_div:function(){},init:function(){this.enabled=true},_draw:function(){var ah=this.view,ai=ah.high-ah.low,al=Math.floor(Math.pow(10,Math.floor(Math.log(ai)/Math.log(10)))),af=Math.floor(ah.low/al)*al,aj=this.view.container.width(),ag=$("<div style='position: relative; height: 1.3em;'></div>");while(af<ah.high){var ak=(af-ah.low)/ai*aj;ag.append($("<div class='label'>"+commatize(af)+"</div>").css({position:"absolute",left:ak-1}));af+=al}this.content_div.children(":first").remove();this.content_div.append(ag)}});var h=function(ai,ah,ag,af){this.display_modes=af[0].display_modes;M.call(this,ai,ah,ag);this.drawables=[];this.left_offset=0;if(af){var al=[],ak;for(var aj=0;aj<af.length;aj++){ak=af[aj];al.push(ak.dataset_id);this.drawables[aj]=ak.copy();if(ak.left_offset>this.left_offset){this.left_offset=ak.left_offset}}this.enabled=true}this.update_icons();this.obj_type="CompositeTrack"};p(h.prototype,M.prototype,{to_dict:x.prototype.to_dict,add_drawable:x.prototype.add_drawable,from_dict:function(al,af){var ak=new this.constructor(al.name,view,af,al.prefs,view.viewport_container,view);var ag,aj,ai;for(var ah=0;ah<al.drawables.length;ah++){ag=al.drawables[ah];aj=ag.obj_type;if(!aj){aj=ag.track_type}ai=addable_objects[aj].prototype.from_dict(ag);ak.add_drawable(ai)}return ak},change_mode:function(af){M.prototype.change_mode.call(this,af);for(var ag=0;ag<this.drawables.length;ag++){this.drawables[ag].change_mode(af)}},init:function(){this.enabled=true;this.request_draw()},update_icons:function(){this.action_icons.filters_icon.hide();this.action_icons.tools_icon.hide()},can_draw:q.prototype.can_draw,draw_helper:function(ag,av,aB,ay,am,ao,aw){var au=this,aF=this._gen_tile_cache_key(av,ao,aB),aC=aB*Q*ay,ah=aC+Q*ay;if(!aw){aw={}}var aE=(ag?undefined:au.tile_cache.get(aF));if(aE){au.show_tile(aE,am,ao);return aE}var an=[],au,ar=true,az,ap;for(var aA=0;aA<this.drawables.length;aA++){au=this.drawables[aA];az=au.data_manager.get_data(aC,ah,au.mode,ay,au.data_url_extra_params);if(is_deferred(az)){ar=false}an.push(az);ap=null;if(view.reference_track&&ao>view.canvas_manager.char_width_px){ap=view.reference_track.data_manager.get_data(aC,ah,au.mode,ay,view.reference_track.data_url_extra_params);if(is_deferred(ap)){ar=false}}an.push(ap)}if(ar){p(az,aw.more_tile_data);this.tile_predraw_init();var aj=au.view.canvas_manager.new_canvas(),ak=au._get_tile_bounds(aB,ay),aC=ak[0],ah=ak[1],aD=0,av=Math.ceil((ah-aC)*ao)+this.left_offset,at=0,ai=[];var af=0;for(var aA=0;aA<this.drawables.length;aA++,aD+=2){au=this.drawables[aA];az=an[aD];var aq=au.mode;if(aq==="Auto"){aq=au.get_mode(az);au.update_auto_mode(aq)}ai.push(aq);af=au.get_canvas_height(az,aq,ao,av);if(af>at){at=af}}aj.width=av;aj.height=(aw.height?aw.height:at);aD=0;var ax=aj.getContext("2d");ax.translate(this.left_offset,0);ax.globalAlpha=0.5;ax.globalCompositeOperation="source-over";for(var aA=0;aA<this.drawables.length;aA++,aD+=2){au=this.drawables[aA];az=an[aD];ap=an[aD+1];aE=au.draw_tile(az,ax,ai[aA],ay,aB,ao,ap)}this.tile_cache.set(aF,aE);this.show_tile(aE,am,ao);return aE}var al=$.Deferred(),au=this;$.when.apply($,an).then(function(){view.request_redraw(false,false,false,au);al.resolve()});return al},tile_predraw_init:function(){var ai=Number.MAX_VALUE,af=-ai,ag;for(var ah=0;ah<this.drawables.length;ah++){ag=this.drawables[ah];if(ag instanceof j){if(ag.prefs.min_value<ai){ai=ag.prefs.min_value}if(ag.prefs.max_value>af){af=ag.prefs.max_value}}}for(var ah=0;ah<this.drawables.length;ah++){ag=this.drawables[ah];ag.prefs.min_value=ai;ag.prefs.max_value=af}},postdraw_actions:function(ah,ak,am,ag){M.prototype.postdraw_actions.call(this,ah,ak,am,ag);var aj=-1;for(var ai=0;ai<ah.length;ai++){var af=ah[ai].html_elt.find("canvas").height();if(af>aj){aj=af}}for(var ai=0;ai<ah.length;ai++){var al=ah[ai];if(al.html_elt.find("canvas").height()!==aj){this.draw_helper(true,ak,al.index,al.resolution,al.html_elt.parent(),am,{height:aj});al.html_elt.remove()}}}});var z=function(af){M.call(this,"reference",af,{content_div:af.top_labeltrack},{});af.reference_track=this;this.left_offset=200;this.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:af.dbkey};this.data_manager=new G(H,this,false)};p(z.prototype,q.prototype,M.prototype,{build_header_div:function(){},init:function(){this.enabled=true},can_draw:q.prototype.can_draw,draw_tile:function(an,ao,ak,aj,ag,ap){var ai=this;if(ap>this.view.canvas_manager.char_width_px){if(an.data===null){ai.content_div.css("height","0px");return}var ah=ao.canvas;ao.font=ao.canvas.manager.default_font;ao.textAlign="center";an=an.data;for(var al=0,am=an.length;al<am;al++){var af=Math.round(al*ap);ao.fillText(an[al],af+ai.left_offset,10)}return new b(ai,ag,aj,ah,an)}this.content_div.css("height","0px")}});var j=function(af,am,ag,al,ao,an,aj,ak,ah){var ai=this;this.display_modes=["Histogram","Line","Filled","Intensity"];this.mode="Histogram";M.call(this,af,am,ag,an,aj,ak,ah);this.min_height_px=16;this.max_height_px=400;this.height_px=32;this.hda_ldda=al;this.dataset_id=ao;this.original_dataset_id=ao;this.left_offset=0;this.config=new E({track:this,params:[{key:"name",label:"Name",type:"text",default_value:af},{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:this.height_px,hidden:true}],saved_values:an,onchange:function(){ai.set_name(ai.prefs.name);ai.vertical_range=ai.prefs.max_value-ai.prefs.min_value;$("#linetrack_"+ai.dataset_id+"_minval").text(ai.prefs.min_value);$("#linetrack_"+ai.dataset_id+"_maxval").text(ai.prefs.max_value);ai.tile_cache.clear();ai.request_draw()}});this.prefs=this.config.values;this.height_px=this.config.values.height;this.vertical_range=this.config.values.max_value-this.config.values.min_value;this.add_resize_handle()};p(j.prototype,q.prototype,M.prototype,{add_resize_handle:function(){var af=this;var ai=false;var ah=false;var ag=$("<div class='track-resize'>");$(af.container_div).hover(function(){if(af.content_visible){ai=true;ag.show()}},function(){ai=false;if(!ah){ag.hide()}});ag.hide().bind("dragstart",function(aj,ak){ah=true;ak.original_height=$(af.content_div).height()}).bind("drag",function(ak,al){var aj=Math.min(Math.max(al.original_height+al.deltaY,af.min_height_px),af.max_height_px);$(af.content_div).css("height",aj);af.height_px=aj;af.request_draw(true)}).bind("dragend",function(aj,ak){af.tile_cache.clear();ah=false;if(!ai){ag.hide()}af.config.values.height=af.height_px}).appendTo(af.container_div)},predraw_init:function(){var af=this;af.vertical_range=undefined;return $.getJSON(af.data_url,{stats:true,chrom:af.view.chrom,low:null,high:null,hda_ldda:af.hda_ldda,dataset_id:af.dataset_id},function(ag){af.container_div.addClass("line-track");var aj=ag.data;if(isNaN(parseFloat(af.prefs.min_value))||isNaN(parseFloat(af.prefs.max_value))){var ah=aj.min;var al=aj.max;ah=Math.floor(Math.min(0,Math.max(ah,aj.mean-2*aj.sd)));al=Math.ceil(Math.max(0,Math.min(al,aj.mean+2*aj.sd)));af.prefs.min_value=ah;af.prefs.max_value=al;$("#track_"+af.dataset_id+"_minval").val(af.prefs.min_value);$("#track_"+af.dataset_id+"_maxval").val(af.prefs.max_value)}af.vertical_range=af.prefs.max_value-af.prefs.min_value;af.total_frequency=aj.total_frequency;af.container_div.find(".yaxislabel").remove();var ak=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+af.dataset_id+"_minval").text(Z(af.prefs.min_value,3));var ai=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+af.dataset_id+"_maxval").text(Z(af.prefs.max_value,3));ai.css({position:"absolute",top:"24px",left:"10px"});ai.prependTo(af.container_div);ak.css({position:"absolute",bottom:"2px",left:"10px"});ak.prependTo(af.container_div)})},draw_tile:function(ap,an,ak,ai,ag,ao){if(this.vertical_range===undefined){return}var ah=an.canvas,af=this._get_tile_bounds(ag,ai),aj=af[0],am=af[1],al=new L.LinePainter(ap.data,aj,am,this.prefs,ak);al.draw(an,ah.width,ah.height,ao);return new b(this.track,ag,ai,ah,ap.data)}});var d=function(af,am,ag,al,ao,an,aj,ak,ah){var ai=this;this.display_modes=["Auto","Histogram","Dense","Squish","Pack"];M.call(this,af,am,ag,an,aj,ak,ah);this.config=new E({track:this,params:[{key:"name",label:"Name",type:"text",default_value:af},{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_counts",label:"Show summary counts",type:"bool",default_value:true,help:"Show the number of items in each bin when drawing summary histogram"},{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},],saved_values:an,onchange:function(){ai.set_name(ai.prefs.name);ai.tile_cache.clear();ai.set_painter_from_config();ai.request_draw()}});this.prefs=this.config.values;this.height_px=0;this.container_div.addClass("feature-track");this.hda_ldda=al;this.dataset_id=ao;this.original_dataset_id=ao;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()};p(d.prototype,q.prototype,M.prototype,{set_painter_from_config:function(){if(this.config.values.connector_style=="arcs"){this.painter=L.ArcLinkedFeaturePainter}else{this.painter=L.LinkedFeaturePainter}},postdraw_actions:function(at,an,aj,ah){M.prototype.postdraw_actions.call(this,at,ah);var am=this;if(ah){var ax=am.content_div.children();var aw=false;for(var ap=ax.length-1,aq=0;ap>=aq;ap--){var ai=$(ax[ap]);if(aw){ai.remove()}else{if(ai.children().length!==0){aw=true}}}}if(am.mode=="Histogram"){var ag=-1;for(var ap=0;ap<at.length;ap++){var ao=at[ap].max_val;if(ao>ag){ag=ao}}for(var ap=0;ap<at.length;ap++){var av=at[ap];if(av.max_val!==ag){av.html_elt.remove();am.draw_helper(true,an,av.index,av.resolution,av.html_elt.parent(),aj,{more_tile_data:{max:ag}})}}}if(am.filters_manager){var ak=am.filters_manager.filters;for(var ar=0;ar<ak.length;ar++){ak[ar].update_ui_elt()}var au=false,af,al;for(var ap=0;ap<at.length;ap++){if(at[ap].data.length){af=at[ap].data[0];for(var ar=0;ar<ak.length;ar++){al=ak[ar];if(al.applies_to(af)&&al.min!==al.max){au=true;break}}}}if(am.filters_available!==au){am.filters_available=au;if(!am.filters_available){am.filters_div.hide()}am.update_icons()}}},update_auto_mode:function(af){var af;if(this.mode=="Auto"){if(af=="no_detail"){af="feature spans"}else{if(af=="summary_tree"){af="coverage histogram"}}this.action_icons.mode_icon.attr("title","Set display mode (now: Auto/"+af+")")}},incremental_slots:function(aj,af,ai){var ag=this.view.canvas_manager.dummy_context,ah=this.slotters[aj];if(!ah||(ah.mode!==ai)){ah=new (s.FeatureSlotter)(aj,ai,y,function(ak){return ag.measureText(ak)});this.slotters[aj]=ah}return ah.slot_features(af)},get_summary_tree_data:function(aj,am,ah,av){if(av>ah-am){av=ah-am}var aq=Math.floor((ah-am)/av),au=[],ai=0;var ak=0,al=0,ap,at=0,an=[],ar,ao;var ag=function(ay,ax,az,aw){ay[0]=ax+az*aw;ay[1]=ax+(az+1)*aw};while(at<av&&ak!==aj.length){var af=false;for(;at<av&&!af;at++){ag(an,am,at,aq);for(al=ak;al<aj.length;al++){ap=aj[al].slice(1,3);if(is_overlap(ap,an)){af=true;break}}if(af){break}}data_start_index=al;au[au.length]=ar=[an[0],0];for(;al<aj.length;al++){ap=aj[al].slice(1,3);if(is_overlap(ap,an)){ar[1]++}else{break}}if(ar[1]>ai){ai=ar[1]}at++}return{max:ai,delta:aq,data:au}},get_mode:function(af){if(af.dataset_type==="summary_tree"){mode="summary_tree"}else{if(af.extra_info==="no_detail"||this.is_overview){mode="no_detail"}else{if(this.view.high-this.view.low>I){mode="Squish"}else{mode="Pack"}}}return mode},get_canvas_height:function(af,aj,ak,ag){if(aj==="summary_tree"||aj==="Histogram"){return this.summary_draw_height+T}else{var ai=this.incremental_slots(ak,af.data,aj);var ah=new (this.painter)(null,null,null,this.prefs,aj);return Math.max(ad,ah.get_required_height(ai,ag))}},draw_tile:function(ar,aw,au,ax,aB,an,ai){var av=this,ah=aw.canvas,ak=this._get_tile_bounds(aB,ax),aE=ak[0],ag=ak[1],aJ=25,aj=this.left_offset;if(au==="summary_tree"||au==="Histogram"){this.container_div.find(".yaxislabel").remove();var af=$("<div />").addClass("yaxislabel");af.text(ar.max);af.css({position:"absolute",top:"24px",left:"10px",color:this.prefs.label_color});af.prependTo(this.container_div);if(ar.dataset_type!="summary_tree"){var ao=this.get_summary_tree_data(ar.data,aE,ag,200);if(ar.max){ao.max=ar.max}ar=ao}var aG=new L.SummaryTreePainter(ar,aE,ag,this.prefs);aw.translate(0,T);aG.draw(aw,ah.width,ah.height,an);return new k(av,aB,ax,ah,ar.data,ar.max)}var am=[],at=this.slotters[an].slots;all_slotted=true;if(ar.data){var ap=this.filters_manager.filters;for(var ay=0,aA=ar.data.length;ay<aA;ay++){var al=ar.data[ay];var az=false;var aq;for(var aD=0,aI=ap.length;aD<aI;aD++){aq=ap[aD];aq.update_attrs(al);if(!aq.keep(al)){az=true;break}}if(!az){am.push(al);if(!(al[0] in at)){all_slotted=false}}}}var aH=(this.filters_manager.alpha_filter?new B(this.filters_manager.alpha_filter):null);var aF=(this.filters_manager.height_filter?new B(this.filters_manager.height_filter):null);var aG=new (this.painter)(am,aE,ag,this.prefs,au,aH,aF,ai);var aC=null;aw.fillStyle=this.prefs.block_color;aw.font=aw.canvas.manager.default_font;aw.textAlign="right";this.container_div.find(".yaxislabel").remove();if(ar.data){aC=aG.draw(aw,ah.width,ah.height,an,at);aC.translation=-aj}return new O(av,aB,ax,ah,ar.data,an,au,ar.message,all_slotted,aC)},data_and_mode_compatible:function(af,ag){if(ag==="Auto"){return true}else{if(af.extra_info==="no_detail"||af.dataset_type==="summary_tree"){return false}else{return true}}},});var U=function(af,al,ag,ak,an,am,ai,aj,ah){d.call(this,af,al,ag,ak,an,am,ai,aj,ah);this.config=new E({track:this,params:[{key:"name",label:"Name",type:"text",default_value:af},{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:am,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=L.ReadPainter};p(U.prototype,q.prototype,M.prototype,d.prototype);var W=function(af,al,ag,ak,ao,an,ai,ah){d.call(this,af,al,ag,ak,ao,an,ai,ah);var aj=get_random_color(),am=get_random_color([aj,"#ffffff"]);this.config=new E({track:this,params:[{key:"name",label:"Name",type:"text",default_value:af},{key:"block_color",label:"Block and sense strand color",type:"color",default_value:aj},{key:"reverse_strand_color",label:"Antisense strand color",type:"color",default_value:am},{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:"mode",type:"string",default_value:this.mode,hidden:true},],saved_values:an,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=L.ReadPainter;this.update_icons()};p(W.prototype,q.prototype,M.prototype,d.prototype);X.View=ac;X.DrawableGroup=P;X.LineTrack=j;X.FeatureTrack=d;X.ReadTrack=W;X.VcfTrack=U;X.CompositeTrack=h};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)}else{}}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(M,z,L,N){var E=this.view_start,O=this.view_end-this.view_start;var J=this.data.data,I=this.data.delta,G=this.data.max,B=L;delta_x_px=Math.ceil(I*N);M.save();for(var C=0,D=J.length;C<D;C++){var H=Math.floor((J[C][0]-E)*N);var F=J[C][1];if(!F){continue}var K=F/G*L;if(F!==0&&K<1){K=1}M.fillStyle=this.prefs.block_color;M.fillRect(H,B-K,delta_x_px,K);var A=4;if(this.prefs.show_counts&&(M.measureText(F).width+A)<delta_x_px){M.fillStyle=this.prefs.label_color;M.textAlign="center";M.fillText(F,H+(delta_x_px/2),10)}}M.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,aj,an,ap,y){var T=X[0],al=X[1],ad=X[2]-1,Q=X[3],ae=Math.floor(Math.max(0,(al-O)*an)),N=Math.ceil(Math.min(y,Math.max(0,(ad-O)*an))),ac=ae,ao=N,aa=(D==="Dense"?0:(0+H))*ap+this.get_top_padding(y),L,ah,R=null,ar=null,B=this.prefs.block_color,ag=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 K=X[4],Z=X[5],af=X[6],C=X[7],V=true;if(Z&&af){R=Math.floor(Math.max(0,(Z-O)*an));ar=Math.ceil(Math.min(y,Math.max(0,(af-O)*an)))}var am,U;if(D==="Squish"){am=1;U=e;V=false}else{if(D==="Dense"){am=5;U=s}else{am=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 ak=0,A=C.length;ak<A;ak++){var F=C[ak],z=Math.floor(Math.max(0,(F[0]-O)*an)),Y=Math.ceil(Math.min(y,Math.max((F[1]-1-O)*an))),S,ab;if(z>Y){continue}M.fillStyle=B;M.fillRect(z,aa+(U-am)/2+1,Y-z,am);if(R!==undefined&&af>Z&&!(z>ar||Y<R)){var ai=Math.max(z,R),I=Math.min(Y,ar);M.fillRect(ai,aa+1,I-ai,U);if(C.length==1&&D=="Pack"){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")}}if(ai+14<I){ai+=2;I-=2}M.fillRect(ai,aa+1,I-ai,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),aq=Math.round((U-P)/2);if(G!==1){M.fillRect(ae,J+1,N-ae,aq);M.fillRect(ae,J+U-aq+1,N-ae,aq)}}}M.globalAlpha=1;if(D==="Pack"&&al>O){M.fillStyle=ag;if(O===0&&ae-M.measureText(Q).width<0){M.textAlign="left";M.fillText(Q,N+j,aa+8);ao+=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,ao]}});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&&this.ref_seq){var P=this.ref_seq[U-L+af];if(!P||P.toLowerCase()===N[af].toLowerCase()){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 f=arguments[0];for(var e=1;e<arguments.length;e++){var d=arguments[e];for(key in d){f[key]=d[key]}}return f};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(var 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(e,X){var p=e("class").extend,s=e("slotting"),L=e("painters");var ae=function(af,ag){this.document=af;this.default_font=ag!==undefined?ag:"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")};p(ae.prototype,{load_pattern:function(af,aj){var ag=this.patterns,ah=this.dummy_context,ai=new Image();ai.src=image_path+aj;ai.onload=function(){ag[af]=ah.createPattern(ai,"repeat")}},get_pattern:function(af){return this.patterns[af]},new_canvas:function(){var af=this.document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(af)}af.manager=this;return af}});var n={};var l=function(af,ag){n[af.attr("id")]=ag};var m=function(af,ah,aj,ai){aj=".group";var ag={};n[af.attr("id")]=ai;af.bind("drag",{handle:"."+ah,relative:true},function(ar,at){var aq=$(this);var aw=$(this).parent(),an=aw.children(),ap=n[$(this).attr("id")],am,al,au,ak,ao;al=$(this).parents(aj);if(al.length!==0){au=al.position().top;ak=au+al.outerHeight();if(at.offsetY<au){$(this).insertBefore(al);var av=n[al.attr("id")];av.remove_drawable(ap);av.container.add_drawable_before(ap,av);return}else{if(at.offsetY>ak){$(this).insertAfter(al);var av=n[al.attr("id")];av.remove_drawable(ap);av.container.add_drawable(ap);return}}}al=null;for(ao=0;ao<an.length;ao++){am=$(an.get(ao));au=am.position().top;ak=au+am.outerHeight();if(am.is(aj)&&this!==am.get(0)&&at.offsetY>=au&&at.offsetY<=ak){if(at.offsetY-au<ak-at.offsetY){am.find(".content-div").prepend(this)}else{am.find(".content-div").append(this)}if(ap.container){ap.container.remove_drawable(ap)}n[am.attr("id")].add_drawable(ap);return}}for(ao=0;ao<an.length;ao++){if(at.offsetY<$(an.get(ao)).position().top){break}}if(ao===an.length){if(this!==an.get(ao-1)){aw.append(this);n[aw.attr("id")].move_drawable(ap,ao)}}else{if(this!==an.get(ao)){$(this).insertBefore(an.get(ao));n[aw.attr("id")].move_drawable(ap,(at.deltaY>0?ao-1:ao))}}}).bind("dragstart",function(){ag["border-top"]=af.css("border-top");ag["border-bottom"]=af.css("border-bottom");$(this).css({"border-top":"1px solid blue","border-bottom":"1px solid blue"})}).bind("dragend",function(){$(this).css(ag)})};X.moveable=m;var ad=16,F=9,C=20,T=F+2,y=100,I=12000,Q=200,A=5,u=10,K=5000,v=100,o="There was an error in indexing this dataset. ",J="A converter for this dataset is not installed. Please check your datatypes_conf.xml file.",D="No data for this chrom/contig.",t="Currently indexing... please wait",w="Tool cannot be rerun: ",a="Loading data...",Y="Ready for display",R=10,H=20;function Z(ag,af){if(!af){af=0}var ah=Math.pow(10,af);return Math.round(ag*ah)/ah}var c=function(af){this.num_elements=af;this.clear()};p(c.prototype,{get:function(ag){var af=this.key_ary.indexOf(ag);if(af!==-1){if(this.obj_cache[ag].stale){this.key_ary.splice(af,1);delete this.obj_cache[ag]}else{this.move_key_to_end(ag,af)}}return this.obj_cache[ag]},set:function(ag,ah){if(!this.obj_cache[ag]){if(this.key_ary.length>=this.num_elements){var af=this.key_ary.shift();delete this.obj_cache[af]}this.key_ary.push(ag)}this.obj_cache[ag]=ah;return ah},move_key_to_end:function(ag,af){this.key_ary.splice(af,1);this.key_ary.push(ag)},clear:function(){this.obj_cache={};this.key_ary=[]},size:function(){return this.key_ary.length}});var S=function(ag,af,ah){c.call(this,ag);this.track=af;this.subset=(ah!==undefined?ah:true)};p(S.prototype,c.prototype,{load_data:function(ao,aj,am,ag,al){var an=this.track.view.chrom,ai={chrom:an,low:ao,high:aj,mode:am,resolution:ag,dataset_id:this.track.dataset_id,hda_ldda:this.track.hda_ldda};$.extend(ai,al);if(this.track.filters_manager){var ap=[];var af=this.track.filters_manager.filters;for(var ak=0;ak<af.length;ak++){ap[ap.length]=af[ak].name}ai.filter_cols=JSON.stringify(ap)}var ah=this;return $.getJSON(this.track.data_url,ai,function(aq){ah.set_data(ao,aj,aq)})},get_data:function(af,aj,ak,ag,ai){var ah=this.get(af,aj);if(ah&&(is_deferred(ah)||this.track.data_and_mode_compatible(ah,ak))){return ah}ah=this.load_data(af,aj,ak,ag,ai);this.set_data(af,aj,ah);return ah},DEEP_DATA_REQ:"deep",BROAD_DATA_REQ:"breadth",get_more_data:function(an,ai,am,ah,al,aj){var ao=this.get(an,ai);if(!(ao&&this.track.data_and_mode_compatible(ao,am))){console.log("ERROR: no current data for: ",this.track,an,ai,am,ah,al);return}ao.stale=true;var ag=an;if(aj===this.DEEP_DATA_REQ){$.extend(al,{start_val:ao.data.length+1})}else{if(aj===this.BROAD_DATA_REQ){ag=(ao.max_high?ao.max_high:ao.data[ao.data.length-1][2])+1}}var af=this,ak=this.load_data(ag,ai,am,ah,al);new_data_available=$.Deferred();this.set_data(an,ai,new_data_available);$.when(ak).then(function(ap){if(ap.data){ap.data=ao.data.concat(ap.data);if(ap.max_low){ap.max_low=ao.max_low}if(ap.message){ap.message=ap.message.replace(/[0-9]+/,ap.data.length)}}af.set_data(an,ai,ap);new_data_available.resolve(ap)});return new_data_available},get:function(af,ag){return c.prototype.get.call(this,this.gen_key(af,ag))},set_data:function(ag,ah,af){return this.set(this.gen_key(ag,ah),af)},gen_key:function(af,ah){var ag=af+"_"+ah;return ag},split_key:function(af){return af.split("_")}});var G=function(ag,af,ah){S.call(this,ag,af,ah)};p(G.prototype,S.prototype,c.prototype,{get:S.prototype.get,load_data:function(af,ai,aj,ag,ah){if(ag>1){return{data:null}}return S.prototype.load_data.call(this,af,ai,aj,ag,ah)}});var q=function(ai,ag,af,ah,ak){if(!q.id_counter){q.id_counter=0}this.id=q.id_counter++;this.name=ai;this.view=ag;this.container=af;this.config=new E({track:this,params:[{key:"name",label:"Name",type:"text",default_value:ai}],saved_values:ah,onchange:function(){this.track.set_name(this.track.config.values.name)}});this.prefs=this.config.values;this.drag_handle_class=ak;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(al){al.stopPropagation()});var aj=this;this.container_div.hover(function(){aj.icons_div.show()},function(){aj.icons_div.hide()});$("<div style='clear: both'/>").appendTo(this.container_div)}};q.prototype.action_icons_def=[{name:"toggle_icon",title:"Hide/show content",css_class:"toggle",on_click_fn:function(af){if(af.content_visible){af.action_icons.toggle_icon.addClass("toggle-expand").removeClass("toggle");af.hide_contents();af.content_visible=false}else{af.action_icons.toggle_icon.addClass("toggle").removeClass("toggle-expand");af.content_visible=true;af.show_contents()}}},{name:"settings_icon",title:"Edit settings",css_class:"settings-icon",on_click_fn:function(ag){var ai=function(){hide_modal();$(window).unbind("keypress.check_enter_esc")},af=function(){ag.config.update_from_form($(".dialog-box"));hide_modal();$(window).unbind("keypress.check_enter_esc")},ah=function(aj){if((aj.keyCode||aj.which)===27){ai()}else{if((aj.keyCode||aj.which)===13){af()}}};$(window).bind("keypress.check_enter_esc",ah);show_modal("Configure",ag.config.build_form(),{Cancel:ai,OK:af})}},{name:"remove_icon",title:"Remove",css_class:"remove-icon",on_click_fn:function(af){$(".tipsy").remove();af.remove()}}];p(q.prototype,{init:function(){},can_draw:function(){if(this.enabled&&this.content_visible){return true}return false},request_draw:function(){},_draw:function(){},to_dict:function(){},from_dict:function(af){},update_icons:function(){},set_name:function(af){this.old_name=this.name;this.name=af;this.name_div.text(this.name)},revert_name:function(){this.name=this.old_name;this.name_div.text(this.name)},remove:function(){this.container.remove_drawable(this);this.container_div.hide(0,function(){$(this).remove();view.update_intro_div();view.has_changes=true})},build_container_div:function(){},build_header_div:function(){},add_action_icon:function(ag,ak,aj,ai,af){var ah=this;this.action_icons[ag]=$("<a/>").attr("href","javascript:void(0);").attr("title",ak).addClass("icon-button").addClass(aj).tipsy({gravity:"s"}).click(function(){ai(ah)}).appendTo(this.icons_div)},build_action_icons:function(af){var ah;for(var ag=0;ag<af.length;ag++){ah=af[ag];this.add_action_icon(ah.name,ah.title,ah.css_class,ah.on_click_fn,ah.prepend)}},update_icons:function(){},hide_contents:function(){},show_contents:function(){}});var x=function(aj,ai,ag,af,ah,ak){q.call(this,ai,ag,af,ah,ak);this.obj_type=aj;this.drawables=[]};p(x.prototype,q.prototype,{init:function(){for(var af=0;af<this.drawables.length;af++){this.drawables[af].init()}},_draw:function(){for(var af=0;af<this.drawables.length;af++){this.drawables[af]._draw()}},to_dict:function(){var ag=[];for(var af=0;af<this.drawables.length;af++){ag.push(this.drawables[af].to_dict())}return{name:this.name,prefs:this.prefs,obj_type:this.obj_type,drawables:ag}},from_dict:function(al,af){var ak=new this.constructor(al.name,view,af,al.prefs,view.viewport_container,view);var ag,aj,ai;for(var ah=0;ah<al.drawables.length;ah++){ag=al.drawables[ah];aj=ag.obj_type;if(!aj){aj=ag.track_type}ai=addable_objects[aj].prototype.from_dict(ag,ak);ak.add_drawable(ai)}return ak},add_drawable:function(af){this.drawables.push(af);af.container=this},add_drawable_before:function(ah,af){var ag=this.drawables.indexOf(af);if(ag!=-1){this.drawables.splice(ag,0,ah);return true}return false},replace_drawable:function(ah,af,ag){var ai=this.drawables.indexOf(ah);if(ai!==-1){this.drawables[ai]=af;if(ag){ah.container_div.replaceWith(af.container_div)}return true}return false},remove_drawable:function(ag){var af=this.drawables.indexOf(ag);if(af!=-1){this.drawables.splice(af,1);ag.container=null;return true}return false},move_drawable:function(ag,ah){var af=this.drawables.indexOf(ag);if(af!=-1){this.drawables.splice(af,1);this.drawables.splice(ah,0,ag);return true}return false}});var P=function(ai,ag,af,ah){x.call(this,"DrawableGroup",ai,ag,af,ah,"group-handle");this.content_div=$("<div/>").addClass("content-div").attr("id","group_"+this.id+"_content_div").appendTo(this.container_div);l(this.container_div,this);l(this.content_div,this);m(this.container_div,this.drag_handle_class,".group",this)};p(P.prototype,q.prototype,x.prototype,{action_icons_def:[{name:"composite_icon",title:"Show composite track",css_class:"layers-stack",on_click_fn:function(af){af.show_composite_track()}}].concat(q.prototype.action_icons_def),build_container_div:function(){var af=$("<div/>").addClass("group").attr("id","group_"+this.id);if(this.container){this.container.content_div.append(af)}return af},build_header_div:function(){var af=$("<div/>").addClass("track-header");af.append($("<div/>").addClass(this.drag_handle_class));this.name_div=$("<div/>").addClass("track-name").text(this.name).appendTo(af);return af},hide_contents:function(){this.content_div.hide()},show_contents:function(){this.content_div.show();this.request_draw()},update_icons:function(){var ah,aj=true,ai=this.drawables[0].get_type(),af=0;for(var ag=0;ag<this.drawables.length;ag++){ah=this.drawables[ag];if(ah.get_type()!==ai){can_composite=false;break}if(ah instanceof d){af++}}if(aj||af===1){this.action_icons.composite_icon.show()}else{this.action_icons.composite_icon.hide();$(".tipsy").remove()}},show_composite_track:function(){var af=new h("Composite Track",this.view,this,this.drawables);this.add_drawable(af);af.request_draw()},add_drawable:function(af){x.prototype.add_drawable.call(this,af);this.update_icons()},remove_drawable:function(af){x.prototype.remove_drawable.call(this,af);this.update_icons()},from_dict:function(ai,af){var ah=x.prototype.from_dict.call(this,ai,af);for(var ag=0;ag<ah.drawables.length;ag++){ah.content_div.append(ah.drawables[ag].container_div)}return ah}});var ac=function(af,ai,ah,ag){x.call(this,"View");this.container=af;this.chrom=null;this.vis_id=ah;this.dbkey=ag;this.title=ai;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 ae(af.get(0).ownerDocument);this.reset()};p(ac.prototype,x.prototype,{init:function(){var ah=this.container,af=this;this.top_container=$("<div/>").addClass("top-container").appendTo(ah);this.browser_content_div=$("<div/>").addClass("content").css("position","relative").appendTo(ah);this.bottom_container=$("<div/>").addClass("bottom-container").appendTo(ah);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;l(this.viewport_container,af);this.intro_div=$("<div/>").addClass("intro").appendTo(this.viewport_container).hide();var ai=$("<div/>").text("Add Datasets to Visualization").addClass("action-button").appendTo(this.intro_div).click(function(){add_tracks()});this.nav_labeltrack=$("<div/>").addClass("nav-labeltrack").appendTo(this.bottom_container);this.nav_container=$("<div/>").addClass("nav-container").prependTo(this.top_container);this.nav=$("<div/>").addClass("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 ag=function(aj){if(aj.type==="focusout"||(aj.keyCode||aj.which)===13||(aj.keyCode||aj.which)===27){if((aj.keyCode||aj.which)!==27){af.go_to($(this).val())}$(this).hide();$(this).val("");af.location_span.show();af.chrom_select.show()}};this.nav_input=$("<input/>").addClass("nav-input").hide().bind("keyup focusout",ag).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(){af.location_span.hide();af.chrom_select.hide();af.nav_input.val(af.chrom+":"+af.low+"-"+af.high);af.nav_input.css("display","inline-block");af.nav_input.select();af.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(){af.zoom_out();af.request_redraw()}).appendTo(this.nav_controls);this.zi_link=$("<a/>").attr("id","zoom-in").attr("title","Zoom in").tipsy({gravity:"n"}).click(function(){af.zoom_in();af.request_redraw()}).appendTo(this.nav_controls);this.load_chroms_deferred=this.load_chroms({low:0});this.chrom_select.bind("change",function(){af.change_chrom(af.chrom_select.val())});this.browser_content_div.click(function(aj){$(this).find("input").trigger("blur")});this.browser_content_div.bind("dblclick",function(aj){af.zoom_in(aj.pageX,this.viewport_container)});this.overview_box.bind("dragstart",function(aj,ak){this.current_x=ak.offsetX}).bind("drag",function(aj,al){var am=al.offsetX-this.current_x;this.current_x=al.offsetX;var ak=Math.round(am/af.viewport_container.width()*(af.max_high-af.max_low));af.move_delta(-ak)});this.overview_close.click(function(){af.reset_overview()});this.viewport_container.bind("draginit",function(aj,ak){if(aj.clientX>af.viewport_container.width()-16){return false}}).bind("dragstart",function(aj,ak){ak.original_low=af.low;ak.current_height=aj.clientY;ak.current_x=ak.offsetX}).bind("drag",function(al,an){var aj=$(this);var ao=an.offsetX-an.current_x;var ak=aj.scrollTop()-(al.clientY-an.current_height);aj.scrollTop(ak);an.current_height=al.clientY;an.current_x=an.offsetX;var am=Math.round(ao/af.viewport_container.width()*(af.high-af.low));af.move_delta(am)}).bind("mousewheel",function(al,an,ak,aj){if(ak){ak*=50;var am=Math.round(-ak/af.viewport_container.width()*(af.high-af.low));af.move_delta(am)}});this.top_labeltrack.bind("dragstart",function(aj,ak){return $("<div />").css({height:af.browser_content_div.height()+af.top_labeltrack.height()+af.nav_labeltrack.height()+1,top:"0px",position:"absolute","background-color":"#ccf",opacity:0.5,"z-index":1000}).appendTo($(this))}).bind("drag",function(an,ao){$(ao.proxy).css({left:Math.min(an.pageX,ao.startX),width:Math.abs(an.pageX-ao.startX)});var ak=Math.min(an.pageX,ao.startX)-af.container.offset().left,aj=Math.max(an.pageX,ao.startX)-af.container.offset().left,am=(af.high-af.low),al=af.viewport_container.width();af.update_location(Math.round(ak/al*am)+af.low,Math.round(aj/al*am)+af.low)}).bind("dragend",function(ao,ap){var ak=Math.min(ao.pageX,ap.startX),aj=Math.max(ao.pageX,ap.startX),am=(af.high-af.low),al=af.viewport_container.width(),an=af.low;af.low=Math.round(ak/al*am)+an;af.high=Math.round(aj/al*am)+an;$(ap.proxy).remove();af.request_redraw()});this.add_label_track(new ab(this,{content_div:this.top_labeltrack}));this.add_label_track(new ab(this,{content_div:this.nav_labeltrack}));$(window).bind("resize",function(){af.resize_window()});$(document).bind("redraw",function(){af.redraw()});this.reset();$(window).trigger("resize")},update_intro_div:function(){if(this.drawables.length===0){this.intro_div.show()}else{this.intro_div.hide()}},update_location:function(af,ag){this.location_span.text(commatize(af)+" - "+commatize(ag));this.nav_input.val(this.chrom+":"+commatize(af)+"-"+commatize(ag))},load_chroms:function(ah){ah.num=v;ah.dbkey=this.dbkey;var af=this,ag=$.Deferred();$.ajax({url:chrom_url,data:ah,dataType:"json",success:function(aj){if(aj.chrom_info.length===0){alert("Invalid chromosome: "+ah.chrom);return}if(aj.reference){af.add_label_track(new z(af))}af.chrom_data=aj.chrom_info;var am='<option value="">Select Chrom/Contig</option>';for(var al=0,ai=af.chrom_data.length;al<ai;al++){var ak=af.chrom_data[al].chrom;am+='<option value="'+ak+'">'+ak+"</option>"}if(aj.prev_chroms){am+='<option value="previous">Previous '+v+"</option>"}if(aj.next_chroms){am+='<option value="next">Next '+v+"</option>"}af.chrom_select.html(am);af.chrom_start_index=aj.start_index;ag.resolve(aj)},error:function(){alert("Could not load chroms for this dbkey:",af.dbkey)}});return ag},change_chrom:function(ak,ag,am){if(!ak||ak==="None"){return}var ah=this;if(ak==="previous"){ah.load_chroms({low:this.chrom_start_index-v});return}if(ak==="next"){ah.load_chroms({low:this.chrom_start_index+v});return}var al=$.grep(ah.chrom_data,function(an,ao){return an.chrom===ak})[0];if(al===undefined){ah.load_chroms({chrom:ak},function(){ah.change_chrom(ak,ag,am)});return}else{if(ak!==ah.chrom){ah.chrom=ak;ah.chrom_select.val(ah.chrom);ah.max_high=al.len-1;ah.reset();ah.request_redraw(true);for(var aj=0,af=ah.drawables.length;aj<af;aj++){var ai=ah.drawables[aj];if(ai.init){ai.init()}}}if(ag!==undefined&&am!==undefined){ah.low=Math.max(ag,0);ah.high=Math.min(am,ah.max_high)}ah.reset_overview();ah.request_redraw()}},go_to:function(aj){aj=aj.replace(/ |,/g,"");var an=this,af,ai,ag=aj.split(":"),al=ag[0],am=ag[1];if(am!==undefined){try{var ak=am.split("-");af=parseInt(ak[0],10);ai=parseInt(ak[1],10)}catch(ah){return false}}an.change_chrom(al,af,ai)},move_fraction:function(ah){var af=this;var ag=af.high-af.low;this.move_delta(ah*ag)},move_delta:function(ah){var af=this;var ag=af.high-af.low;if(af.low-ah<af.max_low){af.low=af.max_low;af.high=af.max_low+ag}else{if(af.high-ah>af.max_high){af.high=af.max_high;af.low=af.max_high-ag}else{af.high-=ah;af.low-=ah}}af.request_redraw()},add_drawable:function(af){x.prototype.add_drawable.call(this,af);af.init();this.has_changes=true;this.update_intro_div()},add_label_track:function(af){af.view=this;af.init();this.label_tracks.push(af)},remove_drawable:function(ah,ag){x.prototype.remove_drawable.call(this,ah);if(ag){var af=this;ah.container_div.hide(0,function(){$(this).remove();af.update_intro_div()});this.has_changes=true}},reset:function(){this.low=this.max_low;this.high=this.max_high;this.viewport_container.find(".yaxislabel").remove()},request_redraw:function(an,af,am,ag){var al=this,aj=(ag?[ag]:al.drawables),ah;var ag;for(var ak=0;ak<aj.length;ak++){ag=aj[ak];ah=-1;for(var ai=0;ai<al.tracks_to_be_redrawn.length;ai++){if(al.tracks_to_be_redrawn[ai][0]===ag){ah=ai;break}}if(ah<0){al.tracks_to_be_redrawn.push([ag,af,am])}else{al.tracks_to_be_redrawn[ak][1]=af;al.tracks_to_be_redrawn[ak][2]=am}}requestAnimationFrame(function(){al._redraw(an)})},_redraw:function(ap){var am=this.low,ai=this.high;if(am<this.max_low){am=this.max_low}if(ai>this.max_high){ai=this.max_high}var ao=this.high-this.low;if(this.high!==0&&ao<this.min_separation){ai=am+this.min_separation}this.low=Math.floor(am);this.high=Math.ceil(ai);this.resolution=Math.pow(A,Math.ceil(Math.log((this.high-this.low)/Q)/Math.log(A)));this.zoom_res=Math.pow(u,Math.max(0,Math.ceil(Math.log(this.resolution,u)/Math.log(u))));var af=(this.low/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var al=((this.high-this.low)/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var aq=13;this.overview_box.css({left:af,width:Math.max(aq,al)}).show();if(al<aq){this.overview_box.css("left",af-(aq-al)/2)}if(this.overview_highlight){this.overview_highlight.css({left:af,width:al})}this.update_location(this.low,this.high);if(!ap){var ah,ag,an;for(var aj=0,ak=this.tracks_to_be_redrawn.length;aj<ak;aj++){ah=this.tracks_to_be_redrawn[aj][0];ag=this.tracks_to_be_redrawn[aj][1];an=this.tracks_to_be_redrawn[aj][2];if(ah){ah._draw(ag,an)}}this.tracks_to_be_redrawn=[];for(aj=0,ak=this.label_tracks.length;aj<ak;aj++){this.label_tracks[aj]._draw()}}},zoom_in:function(ag,ah){if(this.max_high===0||this.high-this.low<this.min_separation){return}var ai=this.high-this.low,aj=ai/2+this.low,af=(ai/this.zoom_factor)/2;if(ag){aj=ag/this.viewport_container.width()*(this.high-this.low)+this.low}this.low=Math.round(aj-af);this.high=Math.round(aj+af);this.request_redraw()},zoom_out:function(){if(this.max_high===0){return}var ag=this.high-this.low,ah=ag/2+this.low,af=(ag*this.zoom_factor)/2;this.low=Math.round(ah-af);this.high=Math.round(ah+af);this.request_redraw()},resize_window:function(){this.viewport_container.height(this.container.height()-this.top_container.height()-this.bottom_container.height());this.nav_container.width(this.container.width());this.request_redraw()},set_overview:function(ah){if(this.overview_drawable){if(this.overview_drawable.dataset_id===ah.dataset_id){return}this.overview_viewport.find(".track").remove()}var ag=ah.copy({content_div:this.overview_viewport}),af=this;ag.header_div.hide();ag.is_overview=true;af.overview_drawable=ag;this.overview_drawable.postdraw_actions=function(){af.overview_highlight.show().height(af.overview_drawable.content_div.height());af.overview_viewport.height(af.overview_drawable.content_div.height()+af.overview_box.outerHeight());af.overview_close.show();af.resize_window()};af.overview_drawable.request_draw();af.has_changes=true},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 r=function(ah,al){this.track=ah;this.name=al.name;this.params=[];var at=al.params;for(var ai=0;ai<at.length;ai++){var an=at[ai],ag=an.name,ar=an.label,aj=unescape(an.html),au=an.value,ap=an.type;if(ap==="number"){this.params[this.params.length]=new f(ag,ar,aj,au,an.min,an.max)}else{if(ap=="select"){this.params[this.params.length]=new N(ag,ar,aj,au)}else{console.log("WARNING: unrecognized tool parameter type:",ag,ap)}}}this.parent_div=$("<div/>").addClass("dynamic-tool").hide();this.parent_div.bind("drag",function(aw){aw.stopPropagation()}).click(function(aw){aw.stopPropagation()}).bind("dblclick",function(aw){aw.stopPropagation()});var aq=$("<div class='tool-name'>").appendTo(this.parent_div).text(this.name);var ao=this.params;var am=this;$.each(this.params,function(ax,aA){var az=$("<div>").addClass("param-row").appendTo(am.parent_div);var aw=$("<div>").addClass("param-label").text(aA.label).appendTo(az);var ay=$("<div/>").addClass("slider").html(aA.html).appendTo(az);ay.find(":input").val(aA.value);$("<div style='clear: both;'/>").appendTo(az)});this.parent_div.find("input").click(function(){$(this).select()});var av=$("<div>").addClass("param-row").appendTo(this.parent_div);var ak=$("<input type='submit'>").attr("value","Run on complete dataset").appendTo(av);var af=$("<input type='submit'>").attr("value","Run on visible region").css("margin-left","3em").appendTo(av);var am=this;af.click(function(){am.run_on_region()});ak.click(function(){am.run_on_dataset()})};p(r.prototype,{get_param_values_dict:function(){var af={};this.parent_div.find(":input").each(function(){var ag=$(this).attr("name"),ah=$(this).val();af[ag]=JSON.stringify(ah)});return af},get_param_values:function(){var ag=[];var af={};this.parent_div.find(":input").each(function(){var ah=$(this).attr("name"),ai=$(this).val();if(ah){ag[ag.length]=ai}});return ag},run_on_dataset:function(){var af=this;af.run({dataset_id:this.track.original_dataset_id,tool_id:af.name},null,function(ag){show_modal(af.name+" is Running",af.name+" is running on the complete dataset. Tool outputs are in dataset's history.",{Close:hide_modal})})},run_on_region:function(){var ag={dataset_id:this.track.original_dataset_id,chrom:this.track.view.chrom,low:this.track.view.low,high:this.track.view.high,tool_id:this.name},aj=this.track,ah=ag.tool_id+aj.tool_region_and_parameters_str(ag.chrom,ag.low,ag.high),af;if(aj.container===view){var ai=new P(this.name,this.track.view);aj.container.replace_drawable(aj,ai,true);aj.container.remove_drawable(aj);ai.add_drawable(aj);aj.container_div.appendTo(ai.content_div);af=ai}else{af=aj.container}var ak=new aj.constructor(ah,view,af,"hda");ak.init_for_tool_data();ak.change_mode(aj.mode);af.add_drawable(ak);ak.content_div.text("Starting job.");this.run(ag,ak,function(al){ak.dataset_id=al.dataset_id;ak.content_div.text("Running job.");ak.init()})},run:function(ag,ah,ai){$.extend(ag,this.get_param_values_dict());var af=function(){$.getJSON(rerun_tool_url,ag,function(aj){if(aj==="no converter"){ah.container_div.addClass("error");ah.content_div.text(J)}else{if(aj.error){ah.container_div.addClass("error");ah.content_div.text(w+aj.message)}else{if(aj==="pending"){ah.container_div.addClass("pending");ah.content_div.text("Converting input data so that it can be used quickly with tool.");setTimeout(af,2000)}else{ai(aj)}}}})};af()}});var N=function(ag,af,ah,ai){this.name=ag;this.label=af;this.html=ah;this.value=ai};var f=function(ah,ag,aj,ak,ai,af){N.call(this,ah,ag,aj,ak);this.min=ai;this.max=af};var g=function(ag,af,ah,ai){this.name=ag;this.index=af;this.tool_id=ah;this.tool_exp_name=ai};var V=function(ag,af,ah,ai){g.call(this,ag,af,ah,ai);this.low=-Number.MAX_VALUE;this.high=Number.MAX_VALUE;this.min=Number.MAX_VALUE;this.max=-Number.MAX_VALUE;this.container=null;this.slider=null;this.slider_label=null};p(V.prototype,{applies_to:function(af){if(af.length>this.index){return true}return false},keep:function(af){if(!this.applies_to(af)){return true}var ag=af[this.index];return(isNaN(ag)||(ag>=this.low&&ag<=this.high))},update_attrs:function(ag){var af=false;if(!this.applies_to(ag)){return af}if(ag[this.index]<this.min){this.min=Math.floor(ag[this.index]);af=true}if(ag[this.index]>this.max){this.max=Math.ceil(ag[this.index]);af=true}return af},update_ui_elt:function(){if(this.min!=this.max){this.container.show()}else{this.container.hide()}var ah=function(ak,ai){var aj=ai-ak;return(aj<=2?0.01:1)};var ag=this.slider.slider("option","min"),af=this.slider.slider("option","max");if(this.min<ag||this.max>af){this.slider.slider("option","min",this.min);this.slider.slider("option","max",this.max);this.slider.slider("option","step",ah(this.min,this.max));this.slider.slider("option","values",[this.min,this.max])}}});var aa=function(ah,aq){this.track=ah;this.filters=[];for(var al=0;al<aq.length;al++){var af=aq[al],ag=af.name,ap=af.type,an=af.index,at=af.tool_id,ai=af.tool_exp_name;if(ap==="int"||ap==="float"){this.filters[al]=new V(ag,an,at,ai)}else{console.log("ERROR: unsupported filter: ",ag,ap)}}var ao=function(au,av,aw){au.click(function(){var ax=av.text();max=parseFloat(aw.slider("option","max")),input_size=(max<=1?4:max<=1000000?max.toString().length:6),multi_value=false;if(aw.slider("option","values")){input_size=2*input_size+1;multi_value=true}av.text("");$("<input type='text'/>").attr("size",input_size).attr("maxlength",input_size).attr("value",ax).appendTo(av).focus().select().click(function(ay){ay.stopPropagation()}).blur(function(){$(this).remove();av.text(ax)}).keyup(function(aC){if(aC.keyCode===27){$(this).trigger("blur")}else{if(aC.keyCode===13){var aA=aw.slider("option","min"),ay=aw.slider("option","max"),aB=function(aD){return(isNaN(aD)||aD>ay||aD<aA)},az=$(this).val();if(!multi_value){az=parseFloat(az);if(aB(az)){alert("Parameter value must be in the range ["+aA+"-"+ay+"]");return $(this)}}else{az=az.split("-");az=[parseFloat(az[0]),parseFloat(az[1])];if(aB(az[0])||aB(az[1])){alert("Parameter value must be in the range ["+aA+"-"+ay+"]");return $(this)}}aw.slider((multi_value?"values":"value"),az)}}})})};this.parent_div=$("<div/>").addClass("filters").hide();this.parent_div.bind("drag",function(au){au.stopPropagation()}).click(function(au){au.stopPropagation()}).bind("dblclick",function(au){au.stopPropagation()}).bind("keydown",function(au){au.stopPropagation()});var aj=this;$.each(this.filters,function(aA,av){av.container=$("<div/>").addClass("filter-row slider-row").appendTo(aj.parent_div);var au=$("<div/>").addClass("elt-label").appendTo(av.container);var aD=$("<span/>").addClass("slider-name").text(av.name+" ").appendTo(au);var aw=$("<span/>");var ax=$("<span/>").addClass("slider-value").appendTo(au).append("[").append(aw).append("]");var aC=$("<div/>").addClass("slider").appendTo(av.container);av.control_element=$("<div/>").attr("id",av.name+"-filter-control").appendTo(aC);var ay=[0,0];av.control_element.slider({range:true,min:Number.MAX_VALUE,max:-Number.MIN_VALUE,values:[0,0],slide:function(aG,aH){var aF=aH.values;aw.text(aF[0]+"-"+aF[1]);av.low=aF[0];av.high=aF[1];aj.track.request_draw(true,true)},change:function(aF,aG){av.control_element.slider("option","slide").call(av.control_element,aF,aG)}});av.slider=av.control_element;av.slider_label=aw;ao(ax,aw,av.control_element);var aE=$("<div/>").addClass("display-controls").appendTo(av.container),az=create_action_icon("Use filter for data transparency","layer-transparent",function(){if(aj.alpha_filter!==av){aj.alpha_filter=av;$(".layer-transparent").removeClass("active").hide();az.addClass("active").show()}else{aj.alpha_filter=null;az.removeClass("active")}aj.track.request_draw(true,true)}).appendTo(aE).hide(),aB=create_action_icon("Use filter for data height","arrow-resize-090",function(){if(aj.height_filter!==av){aj.height_filter=av;$(".arrow-resize-090").removeClass("active").hide();aB.addClass("active").show()}else{aj.height_filter=null;aB.removeClass("active")}aj.track.request_draw(true,true)}).appendTo(aE).hide();av.container.hover(function(){az.show();aB.show()},function(){if(aj.alpha_filter!==av){az.hide()}if(aj.height_filter!==av){aB.hide()}});$("<div style='clear: both;'/>").appendTo(av.container)});if(this.filters.length!==0){var ar=$("<div/>").addClass("param-row").appendTo(this.parent_div);var am=$("<input type='submit'/>").attr("value","Run on complete dataset").appendTo(ar);var ak=this;am.click(function(){ak.run_on_dataset()})}};p(aa.prototype,{reset_filters:function(){for(var af=0;af<this.filters.length;af++){filter=this.filters[af];filter.slider.slider("option","values",[filter.min,filter.max])}this.alpha_filter=null;this.height_filter=null},run_on_dataset:function(){var an=function(ar,ap,aq){if(!(ap in ar)){ar[ap]=aq}return ar[ap]};var ah={},af,ag,ai;for(var aj=0;aj<this.filters.length;aj++){af=this.filters[aj];if(af.tool_id){if(af.min!=af.low){ag=an(ah,af.tool_id,[]);ag[ag.length]=af.tool_exp_name+" >= "+af.low}if(af.max!=af.high){ag=an(ah,af.tool_id,[]);ag[ag.length]=af.tool_exp_name+" <= "+af.high}}}var al=[];for(var ao in ah){al[al.length]=[ao,ah[ao]]}var am=al.length;(function ak(aw,at){var aq=at[0],ar=aq[0],av=aq[1],au="("+av.join(") and (")+")",ap={cond:au,input:aw,target_dataset_id:aw,tool_id:ar},at=at.slice(1);$.getJSON(run_tool_url,ap,function(ax){if(ax.error){show_modal("Filter Dataset","Error running tool "+ar,{Close:hide_modal})}else{if(at.length===0){show_modal("Filtering Dataset","Filter(s) are running on the complete dataset. Outputs are in dataset's history.",{Close:hide_modal})}else{ak(ax.dataset_id,at)}}})})(this.track.dataset_id,al)}});var B=function(af,ag){L.Scaler.call(this,ag);this.filter=af};B.prototype.gen_val=function(af){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(af[this.filter.index])-this.filter.low)/(this.filter.high-this.filter.low))};var E=function(af){this.track=af.track;this.params=af.params;this.values={};this.restore_values((af.saved_values?af.saved_values:{}));this.onchange=af.onchange};p(E.prototype,{restore_values:function(af){var ag=this;$.each(this.params,function(ah,ai){if(af[ai.key]!==undefined){ag.values[ai.key]=af[ai.key]}else{ag.values[ai.key]=ai.default_value}})},build_form:function(){var ai=this;var af=$("<div />");var ah;function ag(al,aj){for(var an=0;an<al.length;an++){ah=al[an];if(ah.hidden){continue}var ak="param_"+an;var ar=ai.values[ah.key];var at=$("<div class='form-row' />").appendTo(aj);at.append($("<label />").attr("for",ak).text(ah.label+":"));if(ah.type==="bool"){at.append($('<input type="checkbox" />').attr("id",ak).attr("name",ak).attr("checked",ar))}else{if(ah.type==="text"){at.append($('<input type="text"/>').attr("id",ak).val(ar).click(function(){$(this).select()}))}else{if(ah.type=="select"){var ap=$("<select />").attr("id",ak);for(var am=0;am<ah.options.length;am++){$("<option/>").text(ah.options[am].label).attr("value",ah.options[am].value).appendTo(ap)}ap.val(ar);at.append(ap)}else{if(ah.type==="color"){var ao=$("<input />").attr("id",ak).attr("name",ak).val(ar);var aq=$("<div class='tipsy tipsy-west' style='position: absolute;' />").hide();(function(au,av){var ax=$("<div style='background-color: black; padding: 10px;'></div>").appendTo(av);var aw=$("<div/>").appendTo(ax).farbtastic({width:100,height:100,callback:au,color:ar});$("<div />").append(au).append(av).appendTo(at).bind("click",function(ay){$(".tipsy").hide();av.css({left:$(this).position().left+$(au).width()+5,top:$(this).position().top-($(av).height()/2)+($(au).height()/2)}).show();$(document).bind("click.color-picker",function(){av.hide();$(document).unbind("click.color-picker")});ay.stopPropagation()})})(ao,aq)}else{at.append($("<input />").attr("id",ak).attr("name",ak).val(ar))}}}}if(ah.help){at.append($("<div class='help'/>").text(ah.help))}}}ag(this.params,af);return af},update_from_form:function(af){var ah=this;var ag=false;$.each(this.params,function(ai,ak){if(!ak.hidden){var al="param_"+ai;var aj=af.find("#"+al).val();if(ak.type==="float"){aj=parseFloat(aj)}else{if(ak.type==="int"){aj=parseInt(aj)}else{if(ak.type==="bool"){aj=af.find("#"+al).is(":checked")}}}if(aj!==ah.values[ak.key]){ah.values[ak.key]=aj;ag=true}}});if(ag){this.onchange()}}});var b=function(af,ai,ah,ag,aj){this.track=af;this.index=ai;this.low=ai*Q*ah;this.high=(ai+1)*Q*ah;this.resolution=ah;this.html_elt=$("<div class='track-tile'/>").append(ag);this.data=aj;this.stale=false};b.prototype.predisplay_actions=function(){};var k=function(af,ai,ah,ag,aj,ak){b.call(this,af,ai,ah,ag,aj);this.max_val=ak};p(k.prototype,b.prototype);var O=function(ai,an,aj,ah,al,at,am,au,ag,aq){b.call(this,ai,an,aj,ah,al);this.mode=am;this.feature_mapper=aq;this.has_icons=false;if(this.message||!ag){this.has_icons=true;var ao=this;ah=this.html_elt.children()[0],message_div=$("<div/>").addClass("tile-message").css({height:C-1,width:ah.width}).prependTo(this.html_elt);if(!ag){var ap=$("<a href='javascript:void(0);'/>").addClass("icon exclamation").attr("title","To minimize track height, not all features in this region are displayed. Click to display more.").tipsy({gravity:"s"}).appendTo(message_div).click(function(){$(".tipsy").hide();ao.track.slotters[at].max_rows*=2;ao.track.request_draw(true)})}if(this.message){var ar=al.length,ak=$("<a href='javascript:void(0);'/>").addClass("icon more-down").attr("title","For speed, only the first "+ar+" features in this region were obtained from server. Click to get more data including depth").tipsy({gravity:"s"}).appendTo(message_div),af=$("<a href='javascript:void(0);'/>").addClass("icon more-across").attr("title","For speed, only the first "+ar+" features in this region were obtained from server. Click to get more data excluding depth").tipsy({gravity:"s"}).appendTo(message_div);ak.click(function(){ao.stale=true;ai.data_manager.get_more_data(ao.low,ao.high,ai.mode,ao.resolution,{},ai.data_manager.DEEP_DATA_REQ);$(".tipsy").hide();ai.request_draw()}).dblclick(function(av){av.stopPropagation()});af.click(function(){ao.stale=true;ai.data_manager.get_more_data(ao.low,ao.high,ai.mode,ao.resolution,{},ai.data_manager.BROAD_DATA_REQ);$(".tipsy").hide();ai.request_draw()}).dblclick(function(av){av.stopPropagation()})}}};p(O.prototype,b.prototype);O.prototype.predisplay_actions=function(){var ag=this,af={};if(ag.mode!=="Pack"){return}$(this.html_elt).hover(function(){this.hovered=true;$(this).mousemove()},function(){this.hovered=false;$(this).siblings(".feature-popup").remove()}).mousemove(function(ar){if(!this.hovered){return}var am=$(this).offset(),aq=ar.pageX-am.left,ap=ar.pageY-am.top,aw=ag.feature_mapper.get_feature_data(aq,ap),an=(aw?aw[0]:null);$(this).siblings(".feature-popup").each(function(){if(!an||$(this).attr("id")!==an.toString()){$(this).remove()}});if(aw){var ai=af[an];if(!ai){var an=aw[0],at={name:aw[3],start:aw[1],end:aw[2],strand:aw[4]},al=ag.track.filters_manager.filters,ak;for(var ao=0;ao<al.length;ao++){ak=al[ao];at[ak.name]=aw[ak.index]}var ai=$("<div/>").attr("id",an).addClass("feature-popup"),ax=$("<table/>"),av,au,ay;for(av in at){au=at[av];ay=$("<tr/>").appendTo(ax);$("<th/>").appendTo(ay).text(av);$("<td/>").attr("align","left").appendTo(ay).text(typeof(au)=="number"?Z(au,2):au)}ai.append($("<div class='feature-popup-inner'>").append(ax));af[an]=ai}ai.appendTo($(ag.html_elt).parent());var aj=aq+parseInt(ag.html_elt.css("left"))-ai.width()/2,ah=ap+parseInt(ag.html_elt.css("top"))+7;ai.css("left",aj+"px").css("top",ah+"px")}else{if(!ar.isPropagationStopped()){ar.stopPropagation();$(this).siblings().each(function(){$(this).trigger(ar)})}}}).mouseleave(function(){$(this).siblings(".feature-popup").remove()})};var i=function(ai,ag,af,ah,ak,aj,al){q.call(this,ai,ag,af,{},"draghandle");this.data_url=(aj?aj:default_data_url);this.data_url_extra_params={};this.data_query_wait=(al?al:K);this.dataset_check_url=converted_datasets_state_url;this.data_manager=(ak?ak:new S(H,this));this.content_div=$("<div class='track-content'>").appendTo(this.container_div);if(this.container){this.container.content_div.append(this.container_div)}};p(i.prototype,q.prototype,{action_icons_def:[{name:"mode_icon",title:"Set display mode",css_class:"chevron-expand",on_click_fn:function(){}},q.prototype.action_icons_def[0],{name:"overview_icon",title:"Set as overview",css_class:"overview-icon",on_click_fn:function(af){af.view.set_overview(af)}},q.prototype.action_icons_def[1],{name:"filters_icon",title:"Filters",css_class:"filters-icon",on_click_fn:function(af){af.filters_div.toggle();af.filters_manager.reset_filters()}},{name:"tools_icon",title:"Tools",css_class:"tools-icon",on_click_fn:function(af){af.dynamic_tool_div.toggle();if(af.dynamic_tool_div.is(":visible")){af.set_name(af.name+af.tool_region_and_parameters_str())}else{af.revert_name()}$(".tipsy").remove()}},q.prototype.action_icons_def[2]],can_draw:function(){if(this.dataset_id&&q.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 af=$("<div class='track-header'/>");if(this.view.editor){this.drag_div=$("<div/>").addClass(this.drag_handle_class).appendTo(af)}this.name_div=$("<div/>").addClass("track-name").appendTo(af).text(this.name).attr("id",this.name.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9\-]/g,"").toLowerCase());return af},build_action_icons:function(){q.prototype.build_action_icons.call(this,this.action_icons_def);var ag=this;if(ag.display_modes!==undefined){var ak=(ag.config&&ag.config.values.mode?ag.config.values.mode:ag.display_modes[0]);ag.mode=ak;this.action_icons.mode_icon.attr("title","Set display mode (now: "+ag.mode+")");var ai={};for(var ah=0,af=ag.display_modes.length;ah<af;ah++){var aj=ag.display_modes[ah];ai[aj]=function(al){return function(){ag.change_mode(al);ag.icons_div.show();ag.container_div.mouseleave(function(){ag.icons_div.hide()})}}(aj)}make_popupmenu(this.action_icons.mode_icon,ai)}},hide_contents:function(){this.content_div.children().remove();this.content_div.hide();this.container_div.find(".yaxislabel, .track-resize").hide()},show_contents:function(){this.content_div.show();this.container_div.find(".yaxislabel, .track-resize").show();this.request_draw()},get_type:function(){if(this instanceof ab){return"LabelTrack"}else{if(this instanceof z){return"ReferenceTrack"}else{if(this instanceof j){return"LineTrack"}else{if(this instanceof W){return"ReadTrack"}else{if(this instanceof U){return"VcfTrack"}else{if(this instanceof h){return"CompositeTrack"}else{if(this instanceof d){return"FeatureTrack"}}}}}}}return""},init:function(){var af=this;af.enabled=false;af.tile_cache.clear();af.data_manager.clear();af.content_div.css("height","auto");af.content_div.children().remove();af.container_div.removeClass("nodata error pending");if(!af.dataset_id){return}$.getJSON(converted_datasets_state_url,{hda_ldda:af.hda_ldda,dataset_id:af.dataset_id,chrom:af.view.chrom},function(ag){if(!ag||ag==="error"||ag.kind==="error"){af.container_div.addClass("error");af.content_div.text(o);if(ag.message){var ah=$(" <a href='javascript:void(0);'></a>").text("View error").click(function(){show_modal("Trackster Error","<pre>"+ag.message+"</pre>",{Close:hide_modal})});af.content_div.append(ah)}}else{if(ag==="no converter"){af.container_div.addClass("error");af.content_div.text(J)}else{if(ag==="no data"||(ag.data!==undefined&&(ag.data===null||ag.data.length===0))){af.container_div.addClass("nodata");af.content_div.text(D)}else{if(ag==="pending"){af.container_div.addClass("pending");af.content_div.text(t);setTimeout(function(){af.init()},af.data_query_wait)}else{if(ag.status==="data"){if(ag.valid_chroms){af.valid_chroms=ag.valid_chroms;af.update_icons()}af.content_div.text(Y);if(af.view.chrom){af.content_div.text("");af.content_div.css("height",af.height_px+"px");af.enabled=true;$.when(af.predraw_init()).done(function(){af.container_div.removeClass("nodata error pending");af.request_draw()})}}}}}}});this.update_icons()},predraw_init:function(){}});var M=function(aj,ah,ag,ai,am,al,ak){i.call(this,aj,ah,ag,ai,ak);var af=this,ah=af.view;m(af.container_div,af.drag_handle_class,".group",af);this.filters_manager=new aa(this,(am!==undefined?am:{}));this.filters_available=false;this.filters_visible=false;this.tool=(al!==undefined&&obj_length(al)>0?new r(this,al):undefined);this.tile_cache=new c(R);if(this.header_div){if(this.filters_manager){this.filters_div=this.filters_manager.parent_div;this.header_div.after(this.filters_div)}if(this.tool){this.dynamic_tool_div=this.tool.parent_div;this.header_div.after(this.dynamic_tool_div)}}};p(M.prototype,q.prototype,i.prototype,{copy:function(af){var ag=new this.constructor(this.name,this.view,af,this.hda_ldda,this.dataset_id,this.prefs,this.filters,this.tool,this.data_manager);ag.change_mode(this.mode);ag.enabled=this.enabled;return ag},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,}},from_dict:function(ah,ag){var af=new this.constructor(ah.name,view,ag,ah.hda_ldda,ah.dataset_id,ah.prefs,ah.filters,ah.tool);if(ah.mode){af.change_mode(ah.mode)}return af},change_mode:function(ag){var af=this;af.mode=ag;af.config.values.mode=ag;af.tile_cache.clear();af.request_draw();this.action_icons.mode_icon.attr("title","Set display mode (now: "+af.mode+")");return af},update_icons:function(){var af=this;if(af.filters_available){af.action_icons.filters_icon.show()}else{af.action_icons.filters_icon.hide()}if(af.tool){af.action_icons.tools_icon.show()}else{af.action_icons.tools_icon.hide()}},_gen_tile_cache_key:function(ag,ah,af){return ag+"_"+ah+"_"+af},request_draw:function(ag,af){this.view.request_redraw(false,ag,af,this)},_draw:function(ah,ar){if(!this.can_draw()){return}var ap=this.view.low,al=this.view.high,an=al-ap,ai=this.view.container.width(),av=ai/an,ak=this.view.resolution,au=this.content_div;if(this.is_overview){ap=this.view.max_low;al=this.view.max_high;ak=Math.pow(A,Math.ceil(Math.log((view.max_high-view.max_low)/Q)/Math.log(A)));av=ai/(view.max_high-view.max_low)}if(!ar){this.content_div.children().addClass("remove")}this.max_height=0;var ag=Math.floor(ap/ak/Q);var ao=true;var at=[];var af=0;var am=function(aw){return(aw&&"track" in aw)};while((ag*Q*ak)<al){var aq=this.draw_helper(ah,ai,ag,ak,au,av);if(am(aq)){at.push(aq)}else{ao=false}ag+=1;af++}if(!ar){this.content_div.children(".remove").remove()}var aj=this;if(ao){aj.postdraw_actions(at,ai,av,ar)}},postdraw_actions:function(ai,aj,al,af){var ah=this;var ak=false;for(var ag=0;ag<ai.length;ag++){if(ai[ag].has_icons){ak=true;break}}if(ak){for(var ag=0;ag<ai.length;ag++){tile=ai[ag];if(!tile.has_icons){tile.html_elt.css("padding-top",C)}}}},draw_helper:function(af,ar,ax,av,ak,al,at){var aq=this,aA=this._gen_tile_cache_key(ar,al,ax),ay=ax*Q*av,ag=ay+Q*av;if(!at){at={}}var az=(af?undefined:aq.tile_cache.get(aA));if(az){aq.show_tile(az,ak,al);return az}var ao=true;var aw=aq.data_manager.get_data(ay,ag,aq.mode,av,aq.data_url_extra_params);if(is_deferred(aw)){ao=false}var am;if(view.reference_track&&al>view.canvas_manager.char_width_px){am=view.reference_track.data_manager.get_data(ay,ag,aq.mode,av,view.reference_track.data_url_extra_params);if(is_deferred(am)){ao=false}}if(ao){p(aw,at.more_tile_data);var an=aq.mode;if(an==="Auto"){an=aq.get_mode(aw);aq.update_auto_mode(an)}var ah=aq.view.canvas_manager.new_canvas(),ai=aq._get_tile_bounds(ax,av),ay=ai[0],ag=ai[1],ar=Math.ceil((ag-ay)*al)+aq.left_offset,ap=aq.get_canvas_height(aw,an,al,ar);ah.width=ar;ah.height=ap;var au=ah.getContext("2d");au.translate(this.left_offset,0);var az=aq.draw_tile(aw,au,an,av,ax,al,am);if(az!==undefined){aq.tile_cache.set(aA,az);aq.show_tile(az,ak,al)}return az}var aj=$.Deferred();$.when(aw,am).then(function(){view.request_redraw(false,false,false,aq);aj.resolve()});return aj},get_canvas_height:function(af,ah,ai,ag){return this.height_px},draw_tile:function(af,ah,ak,aj,ag,al,ai){console.log("Warning: TiledTrack.draw_tile() not implemented.")},show_tile:function(ah,aj,ak){var ag=this,af=ah.html_elt;ah.predisplay_actions();var ai=(ah.low-(this.is_overview?this.view.max_low:this.view.low))*ak;if(this.left_offset){ai-=this.left_offset}af.css({position:"absolute",top:0,left:ai,height:""});if(af.hasClass("remove")){af.removeClass("remove")}else{aj.append(af)}ag.max_height=Math.max(ag.max_height,af.height());ag.content_div.css("height",ag.max_height+"px");aj.children().css("height",ag.max_height+"px")},_get_tile_bounds:function(af,ag){var ai=af*Q*ag,aj=Q*ag,ah=(ai+aj<=this.view.max_high?ai+aj:this.view.max_high);return[ai,ah]},tool_region_and_parameters_str:function(ah,af,ai){var ag=this,aj=(ah!==undefined&&af!==undefined&&ai!==undefined?ah+":"+af+"-"+ai:"all");return" - region=["+aj+"], parameters=["+ag.tool.get_param_values().join(", ")+"]"},data_and_mode_compatible:function(af,ag){return true},init_for_tool_data:function(){this.data_url=raw_data_url;this.data_query_wait=1000;this.dataset_check_url=dataset_state_url;this.predraw_init=function(){var ag=this;var af=function(){if(ag.data_manager.size()===0){setTimeout(af,300)}else{ag.data_url=default_data_url;ag.data_query_wait=K;ag.dataset_state_url=converted_datasets_state_url;$.getJSON(ag.dataset_state_url,{dataset_id:ag.dataset_id,hda_ldda:ag.hda_ldda},function(ah){})}};af()}}});var ab=function(ag,af){i.call(this,"label",ag,af,false,{});this.container_div.addClass("label-track")};p(ab.prototype,i.prototype,{build_header_div:function(){},init:function(){this.enabled=true},_draw:function(){var ah=this.view,ai=ah.high-ah.low,al=Math.floor(Math.pow(10,Math.floor(Math.log(ai)/Math.log(10)))),af=Math.floor(ah.low/al)*al,aj=this.view.container.width(),ag=$("<div style='position: relative; height: 1.3em;'></div>");while(af<ah.high){var ak=(af-ah.low)/ai*aj;ag.append($("<div class='label'>"+commatize(af)+"</div>").css({position:"absolute",left:ak-1}));af+=al}this.content_div.children(":first").remove();this.content_div.append(ag)}});var h=function(ai,ah,ag,af){this.display_modes=af[0].display_modes;M.call(this,ai,ah,ag);this.drawables=[];this.left_offset=0;if(af){var al=[],ak;for(var aj=0;aj<af.length;aj++){ak=af[aj];al.push(ak.dataset_id);this.drawables[aj]=ak.copy();if(ak.left_offset>this.left_offset){this.left_offset=ak.left_offset}}this.enabled=true}this.update_icons();this.obj_type="CompositeTrack"};p(h.prototype,M.prototype,{to_dict:x.prototype.to_dict,add_drawable:x.prototype.add_drawable,from_dict:function(al,af){var ak=new this.constructor(al.name,view,af,al.prefs,view.viewport_container,view);var ag,aj,ai;for(var ah=0;ah<al.drawables.length;ah++){ag=al.drawables[ah];aj=ag.obj_type;if(!aj){aj=ag.track_type}ai=addable_objects[aj].prototype.from_dict(ag);ak.add_drawable(ai)}return ak},change_mode:function(af){M.prototype.change_mode.call(this,af);for(var ag=0;ag<this.drawables.length;ag++){this.drawables[ag].change_mode(af)}},init:function(){this.enabled=true;this.request_draw()},update_icons:function(){this.action_icons.filters_icon.hide();this.action_icons.tools_icon.hide()},can_draw:q.prototype.can_draw,draw_helper:function(ag,av,aB,ay,am,ao,aw){var au=this,aF=this._gen_tile_cache_key(av,ao,aB),aC=aB*Q*ay,ah=aC+Q*ay;if(!aw){aw={}}var aE=(ag?undefined:au.tile_cache.get(aF));if(aE){au.show_tile(aE,am,ao);return aE}var an=[],au,ar=true,az,ap;for(var aA=0;aA<this.drawables.length;aA++){au=this.drawables[aA];az=au.data_manager.get_data(aC,ah,au.mode,ay,au.data_url_extra_params);if(is_deferred(az)){ar=false}an.push(az);ap=null;if(view.reference_track&&ao>view.canvas_manager.char_width_px){ap=view.reference_track.data_manager.get_data(aC,ah,au.mode,ay,view.reference_track.data_url_extra_params);if(is_deferred(ap)){ar=false}}an.push(ap)}if(ar){p(az,aw.more_tile_data);this.tile_predraw_init();var aj=au.view.canvas_manager.new_canvas(),ak=au._get_tile_bounds(aB,ay),aC=ak[0],ah=ak[1],aD=0,av=Math.ceil((ah-aC)*ao)+this.left_offset,at=0,ai=[];var af=0;for(var aA=0;aA<this.drawables.length;aA++,aD+=2){au=this.drawables[aA];az=an[aD];var aq=au.mode;if(aq==="Auto"){aq=au.get_mode(az);au.update_auto_mode(aq)}ai.push(aq);af=au.get_canvas_height(az,aq,ao,av);if(af>at){at=af}}aj.width=av;aj.height=(aw.height?aw.height:at);aD=0;var ax=aj.getContext("2d");ax.translate(this.left_offset,0);ax.globalAlpha=0.5;ax.globalCompositeOperation="source-over";for(var aA=0;aA<this.drawables.length;aA++,aD+=2){au=this.drawables[aA];az=an[aD];ap=an[aD+1];aE=au.draw_tile(az,ax,ai[aA],ay,aB,ao,ap)}this.tile_cache.set(aF,aE);this.show_tile(aE,am,ao);return aE}var al=$.Deferred(),au=this;$.when.apply($,an).then(function(){view.request_redraw(false,false,false,au);al.resolve()});return al},tile_predraw_init:function(){var ai=Number.MAX_VALUE,af=-ai,ag;for(var ah=0;ah<this.drawables.length;ah++){ag=this.drawables[ah];if(ag instanceof j){if(ag.prefs.min_value<ai){ai=ag.prefs.min_value}if(ag.prefs.max_value>af){af=ag.prefs.max_value}}}for(var ah=0;ah<this.drawables.length;ah++){ag=this.drawables[ah];ag.prefs.min_value=ai;ag.prefs.max_value=af}},postdraw_actions:function(ah,ak,am,ag){M.prototype.postdraw_actions.call(this,ah,ak,am,ag);var aj=-1;for(var ai=0;ai<ah.length;ai++){var af=ah[ai].html_elt.find("canvas").height();if(af>aj){aj=af}}for(var ai=0;ai<ah.length;ai++){var al=ah[ai];if(al.html_elt.find("canvas").height()!==aj){this.draw_helper(true,ak,al.index,al.resolution,al.html_elt.parent(),am,{height:aj});al.html_elt.remove()}}}});var z=function(af){M.call(this,"reference",af,{content_div:af.top_labeltrack},{});af.reference_track=this;this.left_offset=200;this.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:af.dbkey};this.data_manager=new G(H,this,false)};p(z.prototype,q.prototype,M.prototype,{build_header_div:function(){},init:function(){this.enabled=true},can_draw:q.prototype.can_draw,draw_tile:function(an,ao,ak,aj,ag,ap){var ai=this;if(ap>this.view.canvas_manager.char_width_px){if(an.data===null){ai.content_div.css("height","0px");return}var ah=ao.canvas;ao.font=ao.canvas.manager.default_font;ao.textAlign="center";an=an.data;for(var al=0,am=an.length;al<am;al++){var af=Math.round(al*ap);ao.fillText(an[al],af,10)}return new b(ai,ag,aj,ah,an)}this.content_div.css("height","0px")}});var j=function(af,am,ag,al,ao,an,aj,ak,ah){var ai=this;this.display_modes=["Histogram","Line","Filled","Intensity"];this.mode="Histogram";M.call(this,af,am,ag,an,aj,ak,ah);this.min_height_px=16;this.max_height_px=400;this.height_px=32;this.hda_ldda=al;this.dataset_id=ao;this.original_dataset_id=ao;this.left_offset=0;this.config=new E({track:this,params:[{key:"name",label:"Name",type:"text",default_value:af},{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:this.height_px,hidden:true}],saved_values:an,onchange:function(){ai.set_name(ai.prefs.name);ai.vertical_range=ai.prefs.max_value-ai.prefs.min_value;$("#linetrack_"+ai.dataset_id+"_minval").text(ai.prefs.min_value);$("#linetrack_"+ai.dataset_id+"_maxval").text(ai.prefs.max_value);ai.tile_cache.clear();ai.request_draw()}});this.prefs=this.config.values;this.height_px=this.config.values.height;this.vertical_range=this.config.values.max_value-this.config.values.min_value;this.add_resize_handle()};p(j.prototype,q.prototype,M.prototype,{add_resize_handle:function(){var af=this;var ai=false;var ah=false;var ag=$("<div class='track-resize'>");$(af.container_div).hover(function(){if(af.content_visible){ai=true;ag.show()}},function(){ai=false;if(!ah){ag.hide()}});ag.hide().bind("dragstart",function(aj,ak){ah=true;ak.original_height=$(af.content_div).height()}).bind("drag",function(ak,al){var aj=Math.min(Math.max(al.original_height+al.deltaY,af.min_height_px),af.max_height_px);$(af.content_div).css("height",aj);af.height_px=aj;af.request_draw(true)}).bind("dragend",function(aj,ak){af.tile_cache.clear();ah=false;if(!ai){ag.hide()}af.config.values.height=af.height_px}).appendTo(af.container_div)},predraw_init:function(){var af=this;af.vertical_range=undefined;return $.getJSON(af.data_url,{stats:true,chrom:af.view.chrom,low:null,high:null,hda_ldda:af.hda_ldda,dataset_id:af.dataset_id},function(ag){af.container_div.addClass("line-track");var aj=ag.data;if(isNaN(parseFloat(af.prefs.min_value))||isNaN(parseFloat(af.prefs.max_value))){var ah=aj.min;var al=aj.max;ah=Math.floor(Math.min(0,Math.max(ah,aj.mean-2*aj.sd)));al=Math.ceil(Math.max(0,Math.min(al,aj.mean+2*aj.sd)));af.prefs.min_value=ah;af.prefs.max_value=al;$("#track_"+af.dataset_id+"_minval").val(af.prefs.min_value);$("#track_"+af.dataset_id+"_maxval").val(af.prefs.max_value)}af.vertical_range=af.prefs.max_value-af.prefs.min_value;af.total_frequency=aj.total_frequency;af.container_div.find(".yaxislabel").remove();var ak=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+af.dataset_id+"_minval").text(Z(af.prefs.min_value,3));var ai=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+af.dataset_id+"_maxval").text(Z(af.prefs.max_value,3));ai.css({position:"absolute",top:"24px",left:"10px"});ai.prependTo(af.container_div);ak.css({position:"absolute",bottom:"2px",left:"10px"});ak.prependTo(af.container_div)})},draw_tile:function(ap,an,ak,ai,ag,ao){if(this.vertical_range===undefined){return}var ah=an.canvas,af=this._get_tile_bounds(ag,ai),aj=af[0],am=af[1],al=new L.LinePainter(ap.data,aj,am,this.prefs,ak);al.draw(an,ah.width,ah.height,ao);return new b(this.track,ag,ai,ah,ap.data)}});var d=function(af,am,ag,al,ao,an,aj,ak,ah){var ai=this;this.display_modes=["Auto","Histogram","Dense","Squish","Pack"];M.call(this,af,am,ag,an,aj,ak,ah);this.config=new E({track:this,params:[{key:"name",label:"Name",type:"text",default_value:af},{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_counts",label:"Show summary counts",type:"bool",default_value:true,help:"Show the number of items in each bin when drawing summary histogram"},{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},],saved_values:an,onchange:function(){ai.set_name(ai.prefs.name);ai.tile_cache.clear();ai.set_painter_from_config();ai.request_draw()}});this.prefs=this.config.values;this.height_px=0;this.container_div.addClass("feature-track");this.hda_ldda=al;this.dataset_id=ao;this.original_dataset_id=ao;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()};p(d.prototype,q.prototype,M.prototype,{set_painter_from_config:function(){if(this.config.values.connector_style=="arcs"){this.painter=L.ArcLinkedFeaturePainter}else{this.painter=L.LinkedFeaturePainter}},postdraw_actions:function(at,an,aj,ah){M.prototype.postdraw_actions.call(this,at,ah);var am=this;if(ah){var ax=am.content_div.children();var aw=false;for(var ap=ax.length-1,aq=0;ap>=aq;ap--){var ai=$(ax[ap]);if(aw){ai.remove()}else{if(ai.children().length!==0){aw=true}}}}if(am.mode=="Histogram"){var ag=-1;for(var ap=0;ap<at.length;ap++){var ao=at[ap].max_val;if(ao>ag){ag=ao}}for(var ap=0;ap<at.length;ap++){var av=at[ap];if(av.max_val!==ag){av.html_elt.remove();am.draw_helper(true,an,av.index,av.resolution,av.html_elt.parent(),aj,{more_tile_data:{max:ag}})}}}if(am.filters_manager){var ak=am.filters_manager.filters;for(var ar=0;ar<ak.length;ar++){ak[ar].update_ui_elt()}var au=false,af,al;for(var ap=0;ap<at.length;ap++){if(at[ap].data.length){af=at[ap].data[0];for(var ar=0;ar<ak.length;ar++){al=ak[ar];if(al.applies_to(af)&&al.min!==al.max){au=true;break}}}}if(am.filters_available!==au){am.filters_available=au;if(!am.filters_available){am.filters_div.hide()}am.update_icons()}}},update_auto_mode:function(af){var af;if(this.mode=="Auto"){if(af=="no_detail"){af="feature spans"}else{if(af=="summary_tree"){af="coverage histogram"}}this.action_icons.mode_icon.attr("title","Set display mode (now: Auto/"+af+")")}},incremental_slots:function(aj,af,ai){var ag=this.view.canvas_manager.dummy_context,ah=this.slotters[aj];if(!ah||(ah.mode!==ai)){ah=new (s.FeatureSlotter)(aj,ai,y,function(ak){return ag.measureText(ak)});this.slotters[aj]=ah}return ah.slot_features(af)},get_summary_tree_data:function(aj,am,ah,av){if(av>ah-am){av=ah-am}var aq=Math.floor((ah-am)/av),au=[],ai=0;var ak=0,al=0,ap,at=0,an=[],ar,ao;var ag=function(ay,ax,az,aw){ay[0]=ax+az*aw;ay[1]=ax+(az+1)*aw};while(at<av&&ak!==aj.length){var af=false;for(;at<av&&!af;at++){ag(an,am,at,aq);for(al=ak;al<aj.length;al++){ap=aj[al].slice(1,3);if(is_overlap(ap,an)){af=true;break}}if(af){break}}data_start_index=al;au[au.length]=ar=[an[0],0];for(;al<aj.length;al++){ap=aj[al].slice(1,3);if(is_overlap(ap,an)){ar[1]++}else{break}}if(ar[1]>ai){ai=ar[1]}at++}return{max:ai,delta:aq,data:au}},get_mode:function(af){if(af.dataset_type==="summary_tree"){mode="summary_tree"}else{if(af.extra_info==="no_detail"||this.is_overview){mode="no_detail"}else{if(this.view.high-this.view.low>I){mode="Squish"}else{mode="Pack"}}}return mode},get_canvas_height:function(af,aj,ak,ag){if(aj==="summary_tree"||aj==="Histogram"){return this.summary_draw_height+T}else{var ai=this.incremental_slots(ak,af.data,aj);var ah=new (this.painter)(null,null,null,this.prefs,aj);return Math.max(ad,ah.get_required_height(ai,ag))}},draw_tile:function(ar,aw,au,ax,aB,an,ai){var av=this,ah=aw.canvas,ak=this._get_tile_bounds(aB,ax),aE=ak[0],ag=ak[1],aJ=25,aj=this.left_offset;if(au==="summary_tree"||au==="Histogram"){this.container_div.find(".yaxislabel").remove();var af=$("<div />").addClass("yaxislabel");af.text(ar.max);af.css({position:"absolute",top:"24px",left:"10px",color:this.prefs.label_color});af.prependTo(this.container_div);if(ar.dataset_type!="summary_tree"){var ao=this.get_summary_tree_data(ar.data,aE,ag,200);if(ar.max){ao.max=ar.max}ar=ao}var aG=new L.SummaryTreePainter(ar,aE,ag,this.prefs);aw.translate(0,T);aG.draw(aw,ah.width,ah.height,an);return new k(av,aB,ax,ah,ar.data,ar.max)}var am=[],at=this.slotters[an].slots;all_slotted=true;if(ar.data){var ap=this.filters_manager.filters;for(var ay=0,aA=ar.data.length;ay<aA;ay++){var al=ar.data[ay];var az=false;var aq;for(var aD=0,aI=ap.length;aD<aI;aD++){aq=ap[aD];aq.update_attrs(al);if(!aq.keep(al)){az=true;break}}if(!az){am.push(al);if(!(al[0] in at)){all_slotted=false}}}}var aH=(this.filters_manager.alpha_filter?new B(this.filters_manager.alpha_filter):null);var aF=(this.filters_manager.height_filter?new B(this.filters_manager.height_filter):null);var aG=new (this.painter)(am,aE,ag,this.prefs,au,aH,aF,ai);var aC=null;aw.fillStyle=this.prefs.block_color;aw.font=aw.canvas.manager.default_font;aw.textAlign="right";this.container_div.find(".yaxislabel").remove();if(ar.data){aC=aG.draw(aw,ah.width,ah.height,an,at);aC.translation=-aj}return new O(av,aB,ax,ah,ar.data,an,au,ar.message,all_slotted,aC)},data_and_mode_compatible:function(af,ag){if(ag==="Auto"){return true}else{if(af.extra_info==="no_detail"||af.dataset_type==="summary_tree"){return false}else{return true}}},});var U=function(af,al,ag,ak,an,am,ai,aj,ah){d.call(this,af,al,ag,ak,an,am,ai,aj,ah);this.config=new E({track:this,params:[{key:"name",label:"Name",type:"text",default_value:af},{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:am,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=L.ReadPainter};p(U.prototype,q.prototype,M.prototype,d.prototype);var W=function(af,al,ag,ak,ao,an,ai,ah){d.call(this,af,al,ag,ak,ao,an,ai,ah);var aj=get_random_color(),am=get_random_color([aj,"#ffffff"]);this.config=new E({track:this,params:[{key:"name",label:"Name",type:"text",default_value:af},{key:"block_color",label:"Block and sense strand color",type:"color",default_value:aj},{key:"reverse_strand_color",label:"Antisense strand color",type:"color",default_value:am},{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:"mode",type:"string",default_value:this.mode,hidden:true},],saved_values:an,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=L.ReadPainter;this.update_icons()};p(W.prototype,q.prototype,M.prototype,d.prototype);X.View=ac;X.DrawableGroup=P;X.LineTrack=j;X.FeatureTrack=d;X.ReadTrack=W;X.VcfTrack=U;X.CompositeTrack=h};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)}else{}}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(M,z,L,N){var E=this.view_start,O=this.view_end-this.view_start;var J=this.data.data,I=this.data.delta,G=this.data.max,B=L;delta_x_px=Math.ceil(I*N);M.save();for(var C=0,D=J.length;C<D;C++){var H=Math.floor((J[C][0]-E)*N);var F=J[C][1];if(!F){continue}var K=F/G*L;if(F!==0&&K<1){K=1}M.fillStyle=this.prefs.block_color;M.fillRect(H,B-K,delta_x_px,K);var A=4;if(this.prefs.show_counts&&(M.measureText(F).width+A)<delta_x_px){M.fillStyle=this.prefs.label_color;M.textAlign="center";M.fillText(F,H+(delta_x_px/2),10)}}M.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,aj,an,ap,y){var T=X[0],al=X[1],ad=X[2]-1,Q=X[3],ae=Math.floor(Math.max(0,(al-O)*an)),N=Math.ceil(Math.min(y,Math.max(0,(ad-O)*an))),ac=ae,ao=N,aa=(D==="Dense"?0:(0+H))*ap+this.get_top_padding(y),L,ah,R=null,ar=null,B=this.prefs.block_color,ag=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 K=X[4],Z=X[5],af=X[6],C=X[7],V=true;if(Z&&af){R=Math.floor(Math.max(0,(Z-O)*an));ar=Math.ceil(Math.min(y,Math.max(0,(af-O)*an)))}var am,U;if(D==="Squish"){am=1;U=e;V=false}else{if(D==="Dense"){am=5;U=s}else{am=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 ak=0,A=C.length;ak<A;ak++){var F=C[ak],z=Math.floor(Math.max(0,(F[0]-O)*an)),Y=Math.ceil(Math.min(y,Math.max((F[1]-1-O)*an))),S,ab;if(z>Y){continue}M.fillStyle=B;M.fillRect(z,aa+(U-am)/2+1,Y-z,am);if(R!==undefined&&af>Z&&!(z>ar||Y<R)){var ai=Math.max(z,R),I=Math.min(Y,ar);M.fillRect(ai,aa+1,I-ai,U);if(C.length==1&&D=="Pack"){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")}}if(ai+14<I){ai+=2;I-=2}M.fillRect(ai,aa+1,I-ai,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),aq=Math.round((U-P)/2);if(G!==1){M.fillRect(ae,J+1,N-ae,aq);M.fillRect(ae,J+U-aq+1,N-ae,aq)}}}M.globalAlpha=1;if(D==="Pack"&&al>O){M.fillStyle=ag;if(O===0&&ae-M.measureText(Q).width<0){M.textAlign="left";M.fillText(Q,N+j,aa+8);ao+=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,ao]}});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&&this.ref_seq){var P=this.ref_seq[U-L+af];if(!P||P.toLowerCase()===N[af].toLowerCase()){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 da1c34c70e254fa559830342c9fa2b5752375e77 -r 4a130280e6142f2c241e33a2bacc6d52e566047c static/scripts/trackster.js
--- a/static/scripts/trackster.js
+++ b/static/scripts/trackster.js
@@ -3699,7 +3699,7 @@
seq = seq.data;
for (var c = 0, str_len = seq.length; c < str_len; c++) {
var c_start = Math.round(c * w_scale);
- ctx.fillText(seq[c], c_start + track.left_offset, 10);
+ ctx.fillText(seq[c], c_start, 10);
}
return new Tile(track, tile_index, resolution, canvas, seq);
}
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0