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
November 2010
- 1 participants
- 286 discussions
galaxy-dist commit 03b74e3675f0: sample tracking functional tests are fixed
by commits-noreply@bitbucket.org 20 Nov '10
by commits-noreply@bitbucket.org 20 Nov '10
20 Nov '10
# HG changeset patch -- Bitbucket.org
# Project galaxy-dist
# URL http://bitbucket.org/galaxy/galaxy-dist/overview
# User rc
# Date 1287161361 14400
# Node ID 03b74e3675f0344005ad491f74d2fb0aa56cb010
# Parent d4b85e30e56d605edc2236ccba5cde41bda1510a
sample tracking functional tests are fixed
--- a/test/base/twilltestcase.py
+++ b/test/base/twilltestcase.py
@@ -1540,7 +1540,7 @@ class TwillTestCase( unittest.TestCase )
def add_bar_codes( self, request_id, request_name, bar_codes, samples, strings_displayed_after_submit=[] ):
# We have to simulate the form submission here since twill barfs on the page
# gvk - 9/22/10 - TODO: make sure the mako template produces valid html
- url = "%s/requests_common/manage_request?cntrller=requests_admin&id=%s&edit_samples_button=Edit+samples" % ( self.url, request_id )
+ url = "%s/requests_common/manage_request?cntrller=requests_admin&id=%s&managing_samples=True" % ( self.url, request_id )
for index, field_value in enumerate( bar_codes ):
sample_field_name = "sample_%i_name" % index
sample_field_value = samples[ index ].name.replace( ' ', '+' )
@@ -1551,20 +1551,23 @@ class TwillTestCase( unittest.TestCase )
self.visit_url( url )
for check_str in strings_displayed_after_submit:
self.check_page_for_string( check_str )
- def change_sample_state( self, request_id, request_name, sample_name, sample_id, new_sample_state_id, new_state_name, comment='',
+ def change_sample_state( self, request_id, request_name, sample_names, sample_ids, new_sample_state_id, new_state_name, comment='',
strings_displayed=[], strings_displayed_after_submit=[] ):
# We have to simulate the form submission here since twill barfs on the page
# gvk - 9/22/10 - TODO: make sure the mako template produces valid html
url = "%s/requests_common/manage_request?cntrller=requests_admin&id=%s" % ( self.url, request_id )
- # select_sample_%i=true must be included twice to simulate a CheckboxField checked setting.
- url += "&comment=%s&select_sample_%i=true&select_sample_%i=true&sample_state_id=%i" % ( comment, sample_id, sample_id, new_sample_state_id )
+ url += "&comment=%s&sample_state_id=%s" % ( comment, self.security.encode_id( new_sample_state_id ) )
+ # select_sample_%i=true must be included twice for each sample to simulate a CheckboxField checked setting.
+ for sample_id in sample_ids:
+ url += "&select_sample_%i=true&select_sample_%i=true" % ( sample_id, sample_id )
url += "&sample_operation=Change%20state&refresh=true"
url += "&change_state_button=Save"
self.visit_url( url )
self.check_page_for_string( 'Sequencing Request "%s"' % request_name )
- self.visit_url( "%s/requests_common/sample_events?cntrller=requests_admin&sample_id=%i" % ( self.url, sample_id ) )
- self.check_page_for_string( 'Events for Sample "%s"' % sample_name )
- self.check_page_for_string( new_state_name )
+ for sample_id, sample_name in zip( sample_ids, sample_names ):
+ self.visit_url( "%s/requests_common/sample_events?cntrller=requests_admin&sample_id=%s" % ( self.url, self.security.encode_id( sample_id ) ) )
+ self.check_page_for_string( 'Events for Sample "%s"' % sample_name )
+ self.check_page_for_string( new_state_name )
def add_user_address( self, user_id, address_dict ):
self.home()
self.visit_url( "%s/user/new_address?admin_view=False&user_id=%i" % ( self.url, user_id ) )
--- a/test/functional/test_forms_and_requests.py
+++ b/test/functional/test_forms_and_requests.py
@@ -209,7 +209,7 @@ class TestFormsAndRequests( TwillTestCas
name=name,
desc=desc,
field_value_tuples=field_value_tuples,
- strings_displayed=[ 'Create a new request',
+ strings_displayed=[ 'Create a new sequencing request',
test_field_name1,
test_field_name2,
test_field_name3 ],
@@ -272,8 +272,6 @@ class TestFormsAndRequests( TwillTestCas
def test_040_request_lifecycle( self ):
"""Testing request life-cycle as it goes through all the states"""
# logged in as regular_user1
- """
- TODO: debug this test case...
self.logout()
self.login( email=admin_user.email )
self.check_request_grid( cntrller='requests_admin',
@@ -292,19 +290,18 @@ class TestFormsAndRequests( TwillTestCas
samples=request_one.samples,
strings_displayed_after_submit=strings_displayed_after_submit )
# Change the states of all the samples of this request to ultimately be COMPLETE
- for sample in request_one.samples:
- self.change_sample_state( request_id=self.security.encode_id( request_one.id ),
- request_name=request_one.name,
- sample_name=sample.name,
- sample_id=self.security.encode_id( sample.id ),
- new_sample_state_id=request_type1.states[1].id,
- new_state_name=request_type1.states[1].name )
- self.change_sample_state( request_id=self.security.encode_id( request_one.id ),
- request_name=request_one.name,
- sample_name=sample.name,
- sample_id=self.security.encode_id( sample.id ),
- new_sample_state_id=request_type1.states[2].id,
- new_state_name=request_type1.states[2].name )
+ self.change_sample_state( request_id=self.security.encode_id( request_one.id ),
+ request_name=request_one.name,
+ sample_names=[ sample.name for sample in request_one.samples ],
+ sample_ids=[ sample.id for sample in request_one.samples ],
+ new_sample_state_id=request_type1.states[1].id,
+ new_state_name=request_type1.states[1].name )
+ self.change_sample_state( request_id=self.security.encode_id( request_one.id ),
+ request_name=request_one.name,
+ sample_names=[ sample.name for sample in request_one.samples ],
+ sample_ids=[ sample.id for sample in request_one.samples ],
+ new_sample_state_id=request_type1.states[2].id,
+ new_state_name=request_type1.states[2].name )
refresh( request_one )
self.logout()
self.login( email=regular_user1.email )
@@ -314,7 +311,7 @@ class TestFormsAndRequests( TwillTestCas
strings_displayed=[ request_one.name ] )
assert request_one.state is not request_one.states.COMPLETE, "The state of the request '%s' should be set to '%s'" \
% ( request_one.name, request_one.states.COMPLETE )
- """
+
def test_045_admin_create_request_on_behalf_of_regular_user( self ):
"""Testing creating and submitting a request as an admin on behalf of a regular user"""
# Logged in as regular_user1
@@ -332,7 +329,7 @@ class TestFormsAndRequests( TwillTestCas
name=name,
desc=desc,
field_value_tuples=field_value_tuples,
- strings_displayed=[ 'Create a new request',
+ strings_displayed=[ 'Create a new sequencing request',
test_field_name1,
test_field_name2,
test_field_name3 ],
1
0
galaxy-dist commit 98739e24554c: Fix for setting columns in workflow builder for ColumnListParameter. e.g. allows splitting lists of columns by newlines and commas and strips leading 'c's.
by commits-noreply@bitbucket.org 20 Nov '10
by commits-noreply@bitbucket.org 20 Nov '10
20 Nov '10
# HG changeset patch -- Bitbucket.org
# Project galaxy-dist
# URL http://bitbucket.org/galaxy/galaxy-dist/overview
# User Dan Blankenberg <dan(a)bx.psu.edu>
# Date 1287173342 14400
# Node ID 98739e24554c777400732e8a2d8f6c18b2b8768a
# Parent 1f4d6b25a84e785c3feee1733a19ac10877a985b
Fix for setting columns in workflow builder for ColumnListParameter. e.g. allows splitting lists of columns by newlines and commas and strips leading 'c's.
--- a/lib/galaxy/tools/parameters/basic.py
+++ b/lib/galaxy/tools/parameters/basic.py
@@ -562,7 +562,8 @@ class SelectToolParameter( ToolParameter
if value == '':
value = None
else:
- value = value.split( "\n" )
+ if not isinstance( value, list ):
+ value = value.split( "\n" )
return UnvalidatedValue( value )
legal_values = self.get_legal_values( trans, context )
if isinstance( value, list ):
@@ -773,16 +774,30 @@ class ColumnListParameter( SelectToolPar
Label convention prepends column number with a 'c', but tool uses the integer. This
removes the 'c' when entered into a workflow.
"""
- if type( value ) == list:
- # We have a multi-select list
- new_value = []
- for item in value:
- if item.startswith( "c" ):
- item = item[1:]
- new_value.append( item )
- value = new_value
- elif value and value.startswith( "c" ):
- value = value[1:]
+ def _strip_c( column ):
+ column = column.strip().lower()
+ if column.startswith( 'c' ):
+ column = column[1:]
+ return column
+ if self.multiple:
+ #split on newline and ,
+ if value:
+ column_list = []
+ if not isinstance( value, list ):
+ value = value.split( '\n' )
+ for column in value:
+ for column2 in column.split( ',' ):
+ column2 = column2.strip()
+ if column2:
+ column_list.append( column2 )
+ value = map( _strip_c, column_list )
+ else:
+ value = []
+ else:
+ if value:
+ value = _strip_c( value )
+ else:
+ value = None
return super( ColumnListParameter, self ).from_html( value, trans, context )
def get_column_list( self, trans, other_values ):
"""
1
0
galaxy-dist commit e029c860e717: Added tests and more help to mutation visualization tool
by commits-noreply@bitbucket.org 20 Nov '10
by commits-noreply@bitbucket.org 20 Nov '10
20 Nov '10
# HG changeset patch -- Bitbucket.org
# Project galaxy-dist
# URL http://bitbucket.org/galaxy/galaxy-dist/overview
# User rc
# Date 1287517130 14400
# Node ID e029c860e71710d69f725e5c136b7e55fa529a42
# Parent 7c80b7c2aa6aef5fba1b3a08e6426f5c84a125b4
Added tests and more help to mutation visualization tool
--- a/tools/mutation/visualize.xml
+++ b/tools/mutation/visualize.xml
@@ -37,16 +37,42 @@
<outputs><data format="svg" name="out_file1" /></outputs>
+ <tests>
+ <test>
+ <param name="input1" value="mutation_data1.txt" ftype="tabular" />
+ <param name="position_col" value="2" />
+ <param name="ref_col" value="4" />
+ <param name="zoom_value" value="interactive" />
+ <param name="name" value="s1" />
+ <param name="a_col" value="5" />
+ <param name="totals_col" value="9" />
+ <output name="output" file="mutation_data1_interactive.svg" ftype="svg" />
+ </test>
+ <test>
+ <param name="input1" value="mutation_data1.txt" ftype="tabular" />
+ <param name="position_col" value="2" />
+ <param name="ref_col" value="4" />
+ <param name="zoom_value" value="3" />
+ <param name="name" value="s1" />
+ <param name="a_col" value="5" />
+ <param name="totals_col" value="9" />
+ <output name="output" file="mutation_data1_zoom3x.svg" ftype="svg" />
+ </test>
+ </tests><help>
**Example**
-
+This tool allows you to visualize mutations described in a tabular input file. It generates an SVG image which can be viewed in any web browser.
+
Given the input file::
gm blood gm cheek
chrM 72 73 G 26394 4 49 0 26447 26398 1 23389 3 45 0 23437 23392 1
chrM 149 150 T 11 50422 2 96 50531 50435 1 4 45417 1 65 45487 45422 1
+
+You will need to specify the position and reference columns in the input file. Then click on the 'Add new Sample' to add samples in the input file that you would like to visualize. For each sample you select, specify the column for base 'A' and the totals column.
+This tool assumes the columns specifying bases A, C, G, T are placed consecutively and in that order in an input file.
Visualization:
@@ -54,7 +80,7 @@ Visualization:
:width: 150
Interactivity::
- If interactive zoom/pan option is checked then the resultant image can be zoomed in or out: scroll mouse wheel; pan: drag using left mouse button.
+ If interactive zoom option is selected, then the resultant image can be zoomed in or out using the scroll mouse wheel and can be panned by dragging the image using left mouse button.
</help></tool>
--- a/tool_conf.xml.main
+++ b/tool_conf.xml.main
@@ -134,6 +134,7 @@
<tool file="visualization/GMAJ.xml" /><tool file="visualization/build_ucsc_custom_track.xml" /><tool file="maf/vcf_to_maf_customtrack.xml" />
+ <tool file="mutation/visualize.xml" /></section><section name="Regional Variation" id="regVar"><tool file="regVariation/windowSplitter.xml" />
--- a/tools/mutation/visualize.py
+++ b/tools/mutation/visualize.py
@@ -367,7 +367,6 @@ if __name__ == '__main__':
parser.add_option('-z', '--zoom', dest='zoom', action='store', default='1')
parser.add_option('-p', '--position_col', dest='position_col', action='store', default='c0')
parser.add_option('-r', '--ref_col', dest='ref_col', action='store', default='c1')
- #parser.add_option('-n', '--interactive', dest='interactive', action='store_false', default='True')
(opts, args) = parser.parse_args()
mainsvg(opts, args)
sys.exit(1)
1
0
galaxy-dist commit fb2a31820ccf: A bit of code cleanup / optimization in sample tracking.
by commits-noreply@bitbucket.org 20 Nov '10
by commits-noreply@bitbucket.org 20 Nov '10
20 Nov '10
# HG changeset patch -- Bitbucket.org
# Project galaxy-dist
# URL http://bitbucket.org/galaxy/galaxy-dist/overview
# User Greg Von Kuster <greg(a)bx.psu.edu>
# Date 1287069813 14400
# Node ID fb2a31820ccff6f02bb24a0632f214bfef0a8b0a
# Parent c8173a50bc9bdb0c8e07807c1b73be746557647f
A bit of code cleanup / optimization in sample tracking.
--- a/templates/requests/common/manage_request.mako
+++ b/templates/requests/common/manage_request.mako
@@ -163,7 +163,7 @@
</div></div>
-%if request.has_samples_without_library_destinations:
+%if request.samples_without_library_destinations:
${render_msg( "Select a target data library and folder for all the samples before starting the sequence run", "warning" )}
%endif
--- a/lib/galaxy/model/__init__.py
+++ b/lib/galaxy/model/__init__.py
@@ -1647,12 +1647,12 @@ class Request( object ):
def is_complete( self ):
return self.state == self.states.COMPLETE
@property
- def has_samples_without_library_destinations( self ):
+ def samples_without_library_destinations( self ):
# Return all samples that are not associated with a library
samples = []
- for s in self.samples:
- if not s.library:
- samples.append( s.name )
+ for sample in self.samples:
+ if not sample.library:
+ samples.append( sample )
return samples
def send_email_notification( self, trans, common_state, final_state=False ):
# Check if an email notification is configured to be sent when the samples
@@ -1774,25 +1774,25 @@ class Sample( object ):
return None
@property
def untransferred_dataset_files( self ):
- count = 0
- for df in self.datasets:
- if df.status == self.transfer_status.NOT_STARTED:
- count = count + 1
- return count
+ untransferred_datasets = []
+ for dataset in self.datasets:
+ if dataset.status == self.transfer_status.NOT_STARTED:
+ untransferred_datasets.append( dataset )
+ return untransferred_datasets
@property
def inprogress_dataset_files( self ):
- count = 0
- for df in self.datasets:
- if df.status not in [self.transfer_status.NOT_STARTED, self.transfer_status.COMPLETE]:
- count = count + 1
- return count
+ inprogress_datasets = []
+ for dataset in self.datasets:
+ if dataset.status not in [ self.transfer_status.NOT_STARTED, self.transfer_status.COMPLETE ]:
+ inprogress_datasets.append( dataset )
+ return inprogress_datasets
@property
def transferred_dataset_files( self ):
- count = 0
- for df in self.datasets:
- if df.status == self.transfer_status.COMPLETE:
- count = count + 1
- return count
+ transferred_datasets = []
+ for dataset in self.datasets:
+ if dataset.status == self.transfer_status.COMPLETE:
+ transferred_datasets.append( dataset )
+ return transferred_datasets
def dataset_size( self, filepath ):
def print_ticks(d):
pass
--- a/templates/requests/common/sample_datasets.mako
+++ b/templates/requests/common/sample_datasets.mako
@@ -1,5 +1,5 @@
<%def name="render_sample_datasets( sample )">
- ${sample.transferred_dataset_files} / ${len( sample.datasets )}
+ ${len( sample.transferred_dataset_files )}/${len( sample.datasets )}
</%def>
${render_sample_datasets( sample )}
--- a/lib/galaxy/web/controllers/requests_admin.py
+++ b/lib/galaxy/web/controllers/requests_admin.py
@@ -244,6 +244,11 @@ class RequestsAdmin( BaseController, Use
params = util.Params( kwd )
message = util.restore_text( params.get( 'message', '' ) )
status = params.get( 'status', 'done' )
+ sample_id = params.get( 'sample_id', None )
+ try:
+ sample = trans.sa_session.query( trans.model.Sample ).get( trans.security.decode_id ( sample_id ) )
+ except:
+ return invalid_id_redirect( trans, 'requests_admin', sample_id )
if 'operation' in kwd:
operation = kwd[ 'operation' ].lower()
sample_dataset_id = params.get( 'id', None )
@@ -262,48 +267,44 @@ class RequestsAdmin( BaseController, Use
elif operation == "delete":
not_deleted = []
for sample_dataset in selected_sample_datasets:
- sample_id = sample_dataset.sample.id
- if sample_dataset.status == trans.app.model.Sample.transfer_status.NOT_STARTED:
+ # Make sure the dataset has been transferred before deleting it.
+ if sample_dataset in sample.untransferred_dataset_files:
trans.sa_session.delete( sample_dataset )
trans.sa_session.flush()
else:
not_deleted.append( sample_dataset.name )
- message = '%i datasets have been deleted. ' % ( len( id_list ) - len( not_deleted ) )
+ message = '%i datasets have been deleted.' % ( len( id_list ) - len( not_deleted ) )
if not_deleted:
status = 'warning'
- message = message + '%s could not be deleted because their transfer status is not "Not Started". ' % str( not_deleted )
+ message = message + ' %s could not be deleted because their transfer status is not "Not Started". ' % str( not_deleted )
return trans.response.send_redirect( web.url_for( controller='requests_admin',
action='manage_datasets',
- sample_id=trans.security.encode_id( sample_id ),
+ sample_id=sample_id,
status=status,
message=message ) )
elif operation == "rename":
- # if none of the selected sample datasets are in the NOT_STARTED state,
- # then display error message
- flag = True
- for sd in selected_sample_datasets:
- if sd.status == trans.app.model.Sample.transfer_status.NOT_STARTED:
- flag = False
+ # If one of the selected sample datasets is in the NOT_STARTED state,
+ # then display an error message. A NOT_STARTED state implies the dataset
+ # has not yet been transferred.
+ no_datasets_transferred = True
+ for selected_sample_dataset in selected_sample_datasets:
+ if selected_sample_dataset in sample.untransferred_dataset_files:
+ no_datasets_transferred = False
break
- if flag:
+ if no_datasets_transferred:
status = 'error'
- message = 'A dataset can be renamed only if it is in the <b>Not Started</b> state.'
+ message = 'A dataset can be renamed only if it is in the "Not Started" state.'
return trans.response.send_redirect( web.url_for( controller='requests_admin',
action='manage_datasets',
- sample_id=trans.security.encode_id( selected_sample_datasets[0].sample.id ),
+ sample_id=sample_id,
status=status,
message=message ) )
return trans.fill_template( '/admin/requests/rename_datasets.mako',
- sample=selected_sample_datasets[0].sample,
+ sample=sample,
id_list=id_list )
elif operation == "start transfer":
- self.__start_datatx( trans, selected_sample_datasets[0].sample, selected_sample_datasets )
+ self.__start_datatx( trans, sample, selected_sample_datasets )
# Render the grid view
- sample_id = params.get( 'sample_id', None )
- try:
- sample = trans.sa_session.query( trans.model.Sample ).get( trans.security.decode_id ( sample_id ) )
- except:
- return invalid_id_redirect( trans, 'requests_admin', sample_id )
request_id = trans.security.encode_id( sample.request.id )
library_id = trans.security.encode_id( sample.library.id )
self.datatx_grid.title = 'Datasets of sample "%s"' % sample.name
@@ -392,25 +393,26 @@ class RequestsAdmin( BaseController, Use
folder_path = self.__check_path( folder_path )
if params.get( 'folder_up', False ):
if folder_path[-1] == os.sep:
- folder_path = os.path.dirname(folder_path[:-1])
+ folder_path = os.path.dirname( folder_path[:-1] )
folder_path = self.__check_path( folder_path )
elif params.get( 'select_show_datasets_button', False ) or params.get( 'select_more_button', False ):
# get the sample these datasets are associated with
try:
sample = trans.sa_session.query( trans.model.Sample ).get( trans.security.decode_id( selected_sample_id ) )
- if sample.name in sample.request.has_samples_without_library_destinations:
- raise Exception()
except:
- # if no sample (with associated library & folder) has been selected
+ return invalid_id_redirect( trans, 'requests_admin', selected_sample_id )
+ if sample in sample.request.samples_without_library_destinations:
+ # Display an error if a sample has been selected that
+ # has not yet been associated with a destination library.
status = 'error'
- message = 'Select a sample with associated data library and folder before selecting the dataset(s).'
+ message = 'Select a sample with associated data library and folder before selecting the datasets.'
return trans.response.send_redirect( web.url_for( controller='requests_admin',
action='get_data',
- request_id=trans.security.encode_id( request.id ),
+ request_id=request_id,
folder_path=folder_path,
status=status,
message=message ) )
- # save the sample datasets
+ # Save the sample datasets
sample_dataset_file_names = self.__save_sample_datasets( trans, sample, selected_files, folder_path )
if sample_dataset_file_names:
message = 'Datasets (%s) have been selected for sample (%s)' % \
@@ -419,7 +421,7 @@ class RequestsAdmin( BaseController, Use
return trans.response.send_redirect( web.url_for( controller='requests_admin',
action='manage_datasets',
request_id=request_id,
- sample_id=trans.security.encode_id( sample.id ),
+ sample_id=selected_sample_id,
message=message,
status=status ) )
else: # 'select_more_button' was clicked
--- a/templates/requests/common/find_samples.mako
+++ b/templates/requests/common/find_samples.mako
@@ -71,7 +71,7 @@
%else:
State: ${sample.state.name}<br/>
%endif
- Datasets: <a href="${h.url_for( controller='requests_common', action='view_dataset_transfer', cntrller=cntrller, sample_id=trans.security.encode_id( sample.id ) )}">${sample.transferred_dataset_files}/${len( sample.datasets )}</a><br/>
+ Datasets: <a href="${h.url_for( controller='requests_common', action='view_dataset_transfer', cntrller=cntrller, sample_id=trans.security.encode_id( sample.id ) )}">${len( sample.transferred_dataset_files )}/${len( sample.datasets )}</a><br/>
%if is_admin:
<i>User: ${sample.request.user.email}</i>
%endif
1
0
20 Nov '10
# HG changeset patch -- Bitbucket.org
# Project galaxy-dist
# URL http://bitbucket.org/galaxy/galaxy-dist/overview
# User rc
# Date 1287147090 14400
# Node ID d4b85e30e56d605edc2236ccba5cde41bda1510a
# Parent fb2a31820ccff6f02bb24a0632f214bfef0a8b0a
sample tracking
- create request search+select box bug fixed.
- sample datasets grid operations fixed
--- a/templates/requests/common/sample_datasets.mako
+++ b/templates/requests/common/sample_datasets.mako
@@ -1,5 +1,5 @@
<%def name="render_sample_datasets( sample )">
- ${len( sample.transferred_dataset_files )}/${len( sample.datasets )}
+ ${len( sample.transferred_dataset_files )} / ${len( sample.datasets )}
</%def>
${render_sample_datasets( sample )}
--- a/templates/requests/common/create_request.mako
+++ b/templates/requests/common/create_request.mako
@@ -21,7 +21,7 @@
%endif
<div class="toolForm">
- <div class="toolFormTitle">Create a new request</div>
+ <div class="toolFormTitle">Create a new sequencing request</div>
%if len( request_type_select_field.options ) == 1:
There are no sequencer configurations available for ${trans.user.email} to create sequencing requests.
%else:
--- a/templates/admin/requests/get_data.mako
+++ b/templates/admin/requests/get_data.mako
@@ -104,7 +104,9 @@
<option value="${f}">${f}</option>
%endfor
</select>
- <br/>
+ </div>
+ <div class="form-row">
+ <div id="file_details" class="toolParamHelp" style="clear: both;background-color:#FAFAFA;"></div></div><div class="form-row"><input type="submit" name="select_show_datasets_button" value="Select & show datasets"/>
--- a/lib/galaxy/web/controllers/requests_common.py
+++ b/lib/galaxy/web/controllers/requests_common.py
@@ -140,9 +140,20 @@ class RequestsCommon( BaseController, Us
request_type = None
# user_id will not be 'none' if an admin user is submitting this request on behalf of another user
# and they selected that user's id from the user_id SelectField.
+ user_id_encoded = True
user_id = params.get( 'user_id', 'none' )
if user_id != 'none':
- user = trans.sa_session.query( trans.model.User ).get( trans.security.decode_id( user_id ) )
+ try:
+ user = trans.sa_session.query( trans.model.User ).get( trans.security.decode_id( user_id ) )
+ except TypeError, e:
+ # We must have an email address rather than an encoded user id
+ # This is because the galaxy.base.js creates a search+select box
+ # when there are more than 20 items in a selectfield
+ user = trans.sa_session.query( trans.model.User ) \
+ .filter( trans.model.User.table.c.email==util.restore_text( user_id ) ) \
+ .first()
+ user_id_encoded = False
+
elif not is_admin:
user = trans.user
else:
@@ -152,6 +163,9 @@ class RequestsCommon( BaseController, Us
if is_admin and user_id == 'none':
message = 'Select the user on behalf of whom you are submitting this request.'
status = 'error'
+ elif user is None:
+ message = 'Invalid user ID (%s)' % str(user_id)
+ status = 'error'
elif not name:
message = 'Enter the name of the request.'
status = 'error'
@@ -170,10 +184,6 @@ class RequestsCommon( BaseController, Us
widgets = []
if request_type is not None or status == 'error':
# Either the user selected a request_type or an error exists on the form.
- if is_admin:
- widgets.append( dict( label='Select user',
- widget=self.__build_user_id_select_field( trans, selected_value=user_id ),
- helptext='Submit the request on behalf of the selected user (Required)'))
widgets.append( dict( label='Name of the Experiment',
widget=TextField( 'name', 40, util.restore_text( params.get( 'name', '' ) ) ),
helptext='(Required)') )
@@ -182,9 +192,20 @@ class RequestsCommon( BaseController, Us
helptext='(Optional)') )
if request_type is not None:
widgets += request_type.request_form.get_widgets( user, **kwd )
- # In case there is an error on the form, make sure to populate widget fields with anything the user
- # may have already entered.
- self.populate_widgets_from_kwd( trans, widgets, **kwd )
+ # In case there is an error on the form, make sure to populate widget fields with anything the user
+ # may have already entered.
+ self.populate_widgets_from_kwd( trans, widgets, **kwd )
+ if request_type is not None or status == 'error':
+ # Either the user selected a request_type or an error exists on the form.
+ if is_admin:
+ if not user_id_encoded:
+ selected_user_id = trans.security.encode_id( user.id )
+ else:
+ selected_user_id = user_id
+ user_widget = dict( label='Select user',
+ widget=self.__build_user_id_select_field( trans, selected_value=selected_user_id ),
+ helptext='Submit the request on behalf of the selected user (Required)')
+ widgets = [ user_widget ] + widgets
return trans.fill_template( '/requests/common/create_request.mako',
cntrller=cntrller,
request_type_select_field=request_type_select_field,
@@ -873,7 +894,7 @@ class RequestsCommon( BaseController, Us
# Build the library_select_field and folder_select_field for the new sample being added.
library_select_field, folder_select_field = self.__build_library_and_folder_select_fields( trans,
user=request.user,
- sample_index=sample_index,
+ sample_index=len( current_samples ),
libraries=libraries,
sample=None,
library_id=library_id,
--- a/lib/galaxy/web/controllers/requests_admin.py
+++ b/lib/galaxy/web/controllers/requests_admin.py
@@ -184,23 +184,6 @@ class RequestsAdmin( BaseController, Use
**kwd ) )
# Render the list view
return self.request_grid( trans, **kwd )
- @web.json
- def get_file_details( self, trans, id, folder_path ):
- def print_ticks( d ):
- # pexpect timeout method
- pass
- # Avoid caching
- trans.response.headers['Pragma'] = 'no-cache'
- trans.response.headers['Expires'] = '0'
- request = trans.sa_session.query( trans.model.Request ).get( int( id ) )
- datatx_info = request.type.datatx_info
- cmd = 'ssh %s@%s "ls -oghp \'%s\'"' % ( datatx_info['username'],
- datatx_info['host'],
- folder_path )
- output = pexpect.run( cmd,
- events={ '.ssword:*' : datatx_info[ 'password'] + '\r\n', pexpect.TIMEOUT : print_ticks },
- timeout=10 )
- return unicode( output.replace( '\n', '<br/>' ) )
@web.expose
@web.require_admin
def reject( self, trans, **kwd ):
@@ -244,11 +227,6 @@ class RequestsAdmin( BaseController, Use
params = util.Params( kwd )
message = util.restore_text( params.get( 'message', '' ) )
status = params.get( 'status', 'done' )
- sample_id = params.get( 'sample_id', None )
- try:
- sample = trans.sa_session.query( trans.model.Sample ).get( trans.security.decode_id ( sample_id ) )
- except:
- return invalid_id_redirect( trans, 'requests_admin', sample_id )
if 'operation' in kwd:
operation = kwd[ 'operation' ].lower()
sample_dataset_id = params.get( 'id', None )
@@ -268,7 +246,9 @@ class RequestsAdmin( BaseController, Use
not_deleted = []
for sample_dataset in selected_sample_datasets:
# Make sure the dataset has been transferred before deleting it.
- if sample_dataset in sample.untransferred_dataset_files:
+ if sample_dataset in sample_dataset.sample.untransferred_dataset_files:
+ # save the sample to which these datasets belong to
+ sample = sample_dataset.sample
trans.sa_session.delete( sample_dataset )
trans.sa_session.flush()
else:
@@ -279,7 +259,7 @@ class RequestsAdmin( BaseController, Use
message = message + ' %s could not be deleted because their transfer status is not "Not Started". ' % str( not_deleted )
return trans.response.send_redirect( web.url_for( controller='requests_admin',
action='manage_datasets',
- sample_id=sample_id,
+ sample_id=trans.security.encode_id( sample.id ),
status=status,
message=message ) )
elif operation == "rename":
@@ -288,7 +268,7 @@ class RequestsAdmin( BaseController, Use
# has not yet been transferred.
no_datasets_transferred = True
for selected_sample_dataset in selected_sample_datasets:
- if selected_sample_dataset in sample.untransferred_dataset_files:
+ if selected_sample_dataset in selected_sample_dataset.sample.untransferred_dataset_files:
no_datasets_transferred = False
break
if no_datasets_transferred:
@@ -296,15 +276,20 @@ class RequestsAdmin( BaseController, Use
message = 'A dataset can be renamed only if it is in the "Not Started" state.'
return trans.response.send_redirect( web.url_for( controller='requests_admin',
action='manage_datasets',
- sample_id=sample_id,
+ sample_id=trans.security.encode_id( selected_sample_datasets[0].sample.id ),
status=status,
message=message ) )
return trans.fill_template( '/admin/requests/rename_datasets.mako',
- sample=sample,
+ sample=selected_sample_datasets[0].sample,
id_list=id_list )
elif operation == "start transfer":
- self.__start_datatx( trans, sample, selected_sample_datasets )
+ self.__start_datatx( trans, selected_sample_datasets[0].sample, selected_sample_datasets )
# Render the grid view
+ sample_id = params.get( 'sample_id', None )
+ try:
+ sample = trans.sa_session.query( trans.model.Sample ).get( trans.security.decode_id ( sample_id ) )
+ except:
+ return invalid_id_redirect( trans, 'requests_admin', sample_id )
request_id = trans.security.encode_id( sample.request.id )
library_id = trans.security.encode_id( sample.library.id )
self.datatx_grid.title = 'Datasets of sample "%s"' % sample.name
@@ -395,6 +380,10 @@ class RequestsAdmin( BaseController, Use
if folder_path[-1] == os.sep:
folder_path = os.path.dirname( folder_path[:-1] )
folder_path = self.__check_path( folder_path )
+ elif params.get( 'open_folder', False ):
+ if len(selected_files) == 1:
+ folder_path = os.path.join(folder_path, selected_files[0])
+ folder_path = self.__check_path( folder_path )
elif params.get( 'select_show_datasets_button', False ) or params.get( 'select_more_button', False ):
# get the sample these datasets are associated with
try:
@@ -443,8 +432,26 @@ class RequestsAdmin( BaseController, Use
status=status,
message=message )
@web.json
+ def get_file_details( self, trans, id, folder_path ):
+ def print_ticks( d ):
+ # pexpect timeout method
+ pass
+ # Avoid caching
+ trans.response.headers['Pragma'] = 'no-cache'
+ trans.response.headers['Expires'] = '0'
+ request = trans.sa_session.query( trans.model.Request ).get( int( id ) )
+ datatx_info = request.type.datatx_info
+ cmd = 'ssh %s@%s "ls -oghp \'%s\'"' % ( datatx_info['username'],
+ datatx_info['host'],
+ folder_path )
+ output = pexpect.run( cmd,
+ events={ '.ssword:*' : datatx_info[ 'password'] + '\r\n', pexpect.TIMEOUT : print_ticks },
+ timeout=10 )
+ return unicode( output.replace( '\n', '<br/>' ) )
+ @web.json
def open_folder( self, trans, id, folder_path ):
def print_ticks( d ):
+ # pexpect timeout method
pass
# Avoid caching
trans.response.headers['Pragma'] = 'no-cache'
--- a/lib/galaxy/web/base/controller.py
+++ b/lib/galaxy/web/base/controller.py
@@ -340,8 +340,7 @@ class UsesFormDefinitionWidgets:
widget_dict[ 'widget' ] = widget
else:
# An existing address object was selected
- address_obj = trans.sa_session.query( trans.app.model.UserAddress ).get( int( value ) )
- widget_dict[ 'widget' ] = address_obj
+ widget_dict[ 'widget' ] = widget
# Populate the AddressField params with the form field contents
widget_params_dict = {}
for field_name, label, help_text in widget.fields():
1
0
galaxy-dist commit 1f4d6b25a84e: Fix for Integer/FloatToolParameter.get_html_field() when 'value' is provided as an integer/float.
by commits-noreply@bitbucket.org 20 Nov '10
by commits-noreply@bitbucket.org 20 Nov '10
20 Nov '10
# HG changeset patch -- Bitbucket.org
# Project galaxy-dist
# URL http://bitbucket.org/galaxy/galaxy-dist/overview
# User Dan Blankenberg <dan(a)bx.psu.edu>
# Date 1287167414 14400
# Node ID 1f4d6b25a84e785c3feee1733a19ac10877a985b
# Parent 74fa7c7c0db8ed06aeda6948d286432b61e7feb0
Fix for Integer/FloatToolParameter.get_html_field() when 'value' is provided as an integer/float.
Fixes an issue seen when saving workflows: If an integer or float tool parameter is changed to a value of 0 or 0.0 and saved, the form field would be redisplayed using the default tool value; and not the value that is now saved in the database.
--- a/lib/galaxy/tools/parameters/basic.py
+++ b/lib/galaxy/tools/parameters/basic.py
@@ -197,6 +197,10 @@ class IntegerToolParameter( TextToolPara
raise ValueError( "An integer is required" )
elif self.value is None:
raise ValueError( "The settings for this field require a 'value' setting and optionally a default value which must be an integer" )
+ def get_html_field( self, trans=None, value=None, other_values={} ):
+ if isinstance( value, int ):
+ value = str( value )
+ return super( IntegerToolParameter, self ).get_html_field( trans=trans, value=value, other_values=other_values )
def from_html( self, value, trans=None, other_values={} ):
try:
return int( value )
@@ -235,6 +239,10 @@ class FloatToolParameter( TextToolParame
raise ValueError( "A real number is required" )
elif self.value is None:
raise ValueError( "The settings for this field require a 'value' setting and optionally a default value which must be a real number" )
+ def get_html_field( self, trans=None, value=None, other_values={} ):
+ if isinstance( value, float ):
+ value = str( value )
+ return super( FloatToolParameter, self ).get_html_field( trans=trans, value=value, other_values=other_values )
def from_html( self, value, trans=None, other_values={} ):
try:
return float( value )
1
0
# HG changeset patch -- Bitbucket.org
# Project galaxy-dist
# URL http://bitbucket.org/galaxy/galaxy-dist/overview
# User Kanwei Li <kanwei(a)gmail.com>
# Date 1287167075 14400
# Node ID 74fa7c7c0db8ed06aeda6948d286432b61e7feb0
# Parent 03b74e3675f0344005ad491f74d2fb0aa56cb010
trackster:
- New histogram mode for LineTrack that's used by default.
- Refactored LineTrack drawing code
- Can change draw color of LineTrack
- summary_tree now shows maximum y-axis value
- When editing track config, "Enter" and "Esc" keys submit and cancel the changes, respectively
--- a/static/scripts/trackster.js
+++ b/static/scripts/trackster.js
@@ -456,7 +456,7 @@ var Track = function (name, view, parent
};
$.extend( Track.prototype, {
init_global: function () {
- this.container_div = $("<div />").addClass('track')
+ this.container_div = $("<div />").addClass('track').css("position", "relative");
if (!this.hidden) {
this.header_div = $("<div class='track-header' />").appendTo(this.container_div);
if (this.view.editor) { this.drag_div = $("<div class='draghandle' />").appendTo(this.header_div); }
@@ -561,9 +561,17 @@ var TiledTrack = function() {
}
};
track_dropdown["Edit configuration"] = function() {
- var cancel_fn = function() { hide_modal(); };
- var ok_fn = function() { track.update_options(track.track_id); hide_modal(); };
+ var cancel_fn = function() { hide_modal(); $(window).unbind("keypress.check_enter_esc"); },
+ ok_fn = function() { track.update_options(track.track_id); hide_modal(); $(window).unbind("keypress.check_enter_esc"); },
+ check_enter_esc = function(e) {
+ if ((e.keyCode || e.which) === 27) { // Escape key
+ cancel_fn();
+ } else if ((e.keyCode || e.which) === 13) { // Enter key
+ ok_fn();
+ }
+ };
+ $(window).bind("keypress.check_enter_esc", check_enter_esc);
show_modal("Configure Track", track.gen_options(track.track_id), {
"Cancel": cancel_fn,
"OK": ok_fn
@@ -771,8 +779,8 @@ var ReferenceTrack = function (view) {
var LineTrack = function ( name, view, dataset_id, prefs ) {
this.track_type = "LineTrack";
- this.display_modes = ["Line", "Filled", "Intensity"];
- this.mode = "Line";
+ this.display_modes = ["Histogram", "Line", "Filled", "Intensity"];
+ this.mode = "Histogram";
Track.call( this, name, view, view.viewport_container );
TiledTrack.call( this );
@@ -780,7 +788,7 @@ var LineTrack = function ( name, view, d
this.dataset_id = dataset_id;
this.data_cache = new Cache(CACHED_DATA);
this.tile_cache = new Cache(CACHED_TILES_LINE);
- this.prefs = { 'min_value': undefined, 'max_value': undefined, 'mode': 'Line' };
+ this.prefs = { 'color': 'black', 'min_value': undefined, 'max_value': undefined, 'mode': this.mode };
if (prefs.min_value !== undefined) { this.prefs.min_value = prefs.min_value; }
if (prefs.max_value !== undefined) { this.prefs.max_value = prefs.max_value; }
};
@@ -806,10 +814,7 @@ var LineTrack = function ( name, view, d
track.total_frequency = data.total_frequency;
// Draw y-axis labels if necessary
- $('#linetrack_' + track_id + '_minval').remove();
- $('#linetrack_' + track_id + '_maxval').remove();
-
- track.container_div.css("position", "relative");
+ track.container_div.find(".yaxislabel").remove();
var min_label = $("<div />").addClass('yaxislabel').attr("id", 'linetrack_' + track_id + '_minval').text(round_1000(track.prefs.min_value));
var max_label = $("<div />").addClass('yaxislabel').attr("id", 'linetrack_' + track_id + '_maxval').text(round_1000(track.prefs.max_value));
@@ -886,7 +891,7 @@ var LineTrack = function ( name, view, d
mode = this.mode;
ctx.beginPath();
-
+ ctx.fillStyle = this.prefs.color;
// for intensity, calculate delta x in pixels to for width of box
if (data.length > 1) {
var delta_x_px = Math.ceil((data[1][0] - data[0][0]) * w_scale);
@@ -896,51 +901,42 @@ var LineTrack = function ( name, view, d
var x_scaled, y;
- for ( var i = 0; i < data.length; i++ ) {
- x_scaled = (data[i][0] - tile_low) * w_scale;
+ for (var i = 0, len = data.length; i < len; i++) {
+ x_scaled = Math.round((data[i][0] - tile_low) * w_scale);
y = data[i][1];
+ if (y === null) {
+ if (in_path && mode === "Filled") {
+ ctx.lineTo(x_scaled, height_px);
+ }
+ in_path = false;
+ continue;
+ }
+ if (y < min_value) {
+ y = min_value;
+ } else if (y > max_value) {
+ y = max_value;
+ }
- if ( mode == "Intensity" ) {
- // DRAW INTENSITY
- if (y === null) {
- continue;
- }
- if (y <= min_value) {
- y = min_value;
- } else if (y >= max_value) {
- y = max_value;
- }
+ if (mode === "Histogram") {
+ y = Math.round( height_px - (y - min_value) / vertical_range * height_px );
+ ctx.fillRect(x_scaled, y, delta_x_px, height_px - y);
+ } else if (mode === "Intensity" ) {
y = 255 - Math.floor( (y - min_value) / vertical_range * 255 );
ctx.fillStyle = "rgb(" +y+ "," +y+ "," +y+ ")";
- ctx.fillRect(x_scaled, 0, delta_x_px, this.height_px);
- }
- else {
- // Missing data causes us to stop drawing
- if (y === null) {
- if (in_path && mode === "Filled") {
- ctx.lineTo(x_scaled, height_px);
- }
- in_path = false;
- continue;
+ ctx.fillRect(x_scaled, 0, delta_x_px, height_px);
+ } else {
+ // console.log(y, this.min_value, this.vertical_range, (y - this.min_value) / this.vertical_range * this.height_px);
+ y = Math.round( height_px - (y - min_value) / vertical_range * height_px );
+ // console.log(canvas.get(0).height, canvas.get(0).width);
+ if (in_path) {
+ ctx.lineTo(x_scaled, y);
} else {
- // console.log(y, this.min_value, this.vertical_range, (y - this.min_value) / this.vertical_range * this.height_px);
- if (y <= min_value) {
- y = min_value;
- } else if (y >= max_value) {
- y = max_value;
- }
- y = Math.round( height_px - (y - min_value) / vertical_range * height_px );
- // console.log(canvas.get(0).height, canvas.get(0).width);
- if (in_path) {
+ in_path = true;
+ if (mode === "Filled") {
+ ctx.moveTo(x_scaled, height_px);
ctx.lineTo(x_scaled, y);
} else {
- in_path = true;
- if (mode === "Filled") {
- ctx.moveTo(x_scaled, height_px);
- ctx.lineTo(x_scaled, y);
- } else {
- ctx.moveTo(x_scaled, y);
- }
+ ctx.moveTo(x_scaled, y);
}
}
}
@@ -958,7 +954,10 @@ var LineTrack = function ( name, view, d
}, gen_options: function(track_id) {
var container = $("<div />").addClass("form-row");
- var minval = 'track_' + track_id + '_minval',
+ var color = 'track_' + track_id + '_color',
+ color_label = $('<label />').attr("for", color).text("Color:"),
+ color_input = $('<input />').attr("id", color).attr("name", color).val(this.prefs.color),
+ minval = 'track_' + track_id + '_minval',
min_label = $('<label></label>').attr("for", minval).text("Min value:"),
min_val = (this.prefs.min_value === undefined ? "" : this.prefs.min_value),
min_input = $('<input></input>').attr("id", minval).val(min_val),
@@ -967,13 +966,16 @@ var LineTrack = function ( name, view, d
max_val = (this.prefs.max_value === undefined ? "" : this.prefs.max_value),
max_input = $('<input></input>').attr("id", maxval).val(max_val);
- return container.append(min_label).append(min_input).append(max_label).append(max_input);
+ return container.append(min_label).append(min_input).append(max_label)
+ .append(max_input).append(color_label).append(color_input);
}, update_options: function(track_id) {
var min_value = $('#track_' + track_id + '_minval').val(),
max_value = $('#track_' + track_id + '_maxval').val();
- if ( min_value !== this.prefs.min_value || max_value !== this.prefs.max_value ) {
+ color = $('#track_' + track_id + '_color').val();
+ if ( min_value !== this.prefs.min_value || max_value !== this.prefs.max_value || color !== this.prefs.color ) {
this.prefs.min_value = parseFloat(min_value);
this.prefs.max_value = parseFloat(max_value);
+ this.prefs.color = color;
this.vertical_range = this.prefs.max_value - this.prefs.min_value;
// Update the y-axis
$('#linetrack_' + track_id + '_minval').text(this.prefs.min_value);
@@ -1199,12 +1201,18 @@ var FeatureTrack = function ( name, view
ctx.fillStyle = block_color;
ctx.font = this.default_font;
ctx.textAlign = "right";
+ this.container_div.find(".yaxislabel").remove();
- if (result.dataset_type == "summary_tree") {
+ if (result.dataset_type == "summary_tree") {
var points = result.data,
max = result.max,
avg = result.avg,
delta_x_px = Math.ceil(result.delta * w_scale);
+
+ var max_label = $("<div />").addClass('yaxislabel').text(max);
+
+ max_label.css({ position: "absolute", top: "22px", left: "10px" });
+ max_label.prependTo(this.container_div);
for ( var i = 0, len = points.length; i < len; i++ ) {
var x = Math.floor( (points[i][0] - tile_low) * w_scale );
--- a/static/june_2007_style/blue/trackster.css
+++ b/static/june_2007_style/blue/trackster.css
@@ -16,7 +16,7 @@
.overview-box{cursor:pointer;opacity:0.5;bottom:0px;z-index:100;position:absolute;margin-top:0px;height:14px;background:#484848 url(../images/visualization/draggable_horizontal.png) center center no-repeat;border-style:solid;border-color:#484848;border-width:0px 1px;-moz-border-radius:3px;border-radius:3px;}
.overview-box:hover{background-color:#838383;border-color:#838383;}
.viewport-canvas{width:100%;height:100px;}
-.yaxislabel{color:#777;}
+.yaxislabel{color:#777;z-index:100;}
.line-track .track-content{border-top:1px solid #ddd;border-bottom:1px solid #ddd;}
.track{background:white;margin-bottom:1px;}
.track-header{text-align:left;padding:4px 0px;color:#666;}
--- a/static/june_2007_style/trackster.css.tmpl
+++ b/static/june_2007_style/trackster.css.tmpl
@@ -116,6 +116,7 @@
.yaxislabel {
color: #777;
+ z-index: 100;
}
/* Line track needs borders to show range */
.line-track .track-content {
--- a/static/scripts/packed/trackster.js
+++ b/static/scripts/packed/trackster.js
@@ -1,1 +1,1 @@
-var DENSITY=200,FEATURE_LEVELS=10,MAX_FEATURE_DEPTH=100,DATA_ERROR="There was an error in indexing this dataset. ",DATA_NOCONVERTER="A converter for this dataset is not installed. Please check your datatypes_conf.xml file.",DATA_NONE="No data for this chrom/contig.",DATA_PENDING="Currently indexing... please wait",DATA_LOADING="Loading data...",CACHED_TILES_FEATURE=10,CACHED_TILES_LINE=30,CACHED_DATA=5,CONTEXT=$("<canvas></canvas>").get(0).getContext("2d"),PX_PER_CHAR=CONTEXT.measureText("A").width,RIGHT_STRAND,LEFT_STRAND;var right_img=new Image();right_img.src=image_path+"/visualization/strand_right.png";right_img.onload=function(){RIGHT_STRAND=CONTEXT.createPattern(right_img,"repeat")};var left_img=new Image();left_img.src=image_path+"/visualization/strand_left.png";left_img.onload=function(){LEFT_STRAND=CONTEXT.createPattern(left_img,"repeat")};var right_img_inv=new Image();right_img_inv.src=image_path+"/visualization/strand_right_inv.png";right_img_inv.onload=function()
{RIGHT_STRAND_INV=CONTEXT.createPattern(right_img_inv,"repeat")};var left_img_inv=new Image();left_img_inv.src=image_path+"/visualization/strand_left_inv.png";left_img_inv.onload=function(){LEFT_STRAND_INV=CONTEXT.createPattern(left_img_inv,"repeat")};function round_1000(a){return Math.round(a*1000)/1000}var Cache=function(a){this.num_elements=a;this.clear()};$.extend(Cache.prototype,{get:function(b){var a=this.key_ary.indexOf(b);if(a!=-1){this.key_ary.splice(a,1);this.key_ary.push(b)}return this.obj_cache[b]},set:function(b,c){if(!this.obj_cache[b]){if(this.key_ary.length>=this.num_elements){var a=this.key_ary.shift();delete this.obj_cache[a]}this.key_ary.push(b)}this.obj_cache[b]=c;return c},clear:function(){this.obj_cache={};this.key_ary=[]}});var View=function(a,c,e,d,b){this.container=a;this.vis_id=d;this.dbkey=b;this.title=e;this.chrom=c;this.tracks=[];this.label_tracks=[];this.max_low=0;this.max_high=0;this.num_tracks=0;this.track_id_counter=0;this.zoom_factor=3;this.
min_separation=30;this.has_changes=false;this.init();this.reset()};$.extend(View.prototype,{init:function(){var c=this.container,a=this;this.top_labeltrack=$("<div/>").addClass("top-labeltrack").appendTo(c);this.content_div=$("<div/>").addClass("content").css("position","relative").appendTo(c);this.viewport_container=$("<div/>").addClass("viewport-container").addClass("viewport-container").appendTo(this.content_div);this.intro_div=$("<div/>").addClass("intro").text("Select a chrom from the dropdown below").hide();this.nav_container=$("<div/>").addClass("nav-container").appendTo(c);this.nav_labeltrack=$("<div/>").addClass("nav-labeltrack").appendTo(this.nav_container);this.nav=$("<div/>").addClass("nav").appendTo(this.nav_container);this.overview=$("<div/>").addClass("overview").appendTo(this.nav);this.overview_viewport=$("<div/>").addClass("overview-viewport").appendTo(this.overview);this.overview_close=$("<a href='javascript:void(0);'>Close Overview</a>").addClass("overview
-close").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_form=$("<form/>").attr("action",function(){void (0)}).appendTo(this.nav_controls);this.chrom_select=$("<select/>").attr({name:"chrom"}).css("width","15em").addClass("no-autocomplete").append("<option value=''>Loading</option>").appendTo(this.chrom_form);var b=function(d){if(d.type==="focusout"||(d.keyCode||d.which)===13||(d.keyCode||d.which)===27){if((d.keyCode||d.which)!==27){a.go_to($(this).val())}$(this).hide();a.location_span.show();a.chrom_select.show();return false}};this.nav_input=$("<inp
ut/>").addClass("nav-input").hide().bind("keypress focusout",b).appendTo(this.chrom_form);this.location_span=$("<span/>").addClass("location").appendTo(this.chrom_form);this.location_span.bind("click",function(){a.location_span.hide();a.chrom_select.hide();a.nav_input.css("display","inline-block");a.nav_input.select();a.nav_input.focus()});if(this.vis_id!==undefined){this.hidden_input=$("<input/>").attr("type","hidden").val(this.vis_id).appendTo(this.chrom_form)}this.zo_link=$("<a/>").click(function(){a.zoom_out();a.redraw()}).html('<img src="'+image_path+'/fugue/magnifier-zoom-out.png" />').appendTo(this.chrom_form);this.zi_link=$("<a/>").click(function(){a.zoom_in();a.redraw()}).html('<img src="'+image_path+'/fugue/magnifier-zoom.png" />').appendTo(this.chrom_form);$.ajax({url:chrom_url,data:(this.vis_id!==undefined?{vis_id:this.vis_id}:{dbkey:this.dbkey}),dataType:"json",success:function(d){if(d.reference){a.add_label_track(new ReferenceTrack(a))}a.chrom_data=d.chrom_info
;var f='<option value="">Select Chrom/Contig</option>';for(i in a.chrom_data){var e=a.chrom_data[i]["chrom"];f+='<option value="'+e+'">'+e+"</option>"}a.chrom_select.html(f);a.intro_div.show();a.chrom_select.bind("change",function(){a.change_chrom(a.chrom_select.val())})},error:function(){alert("Could not load chroms for this dbkey:",a.dbkey)}});this.content_div.bind("dblclick",function(d){a.zoom_in(d.pageX,this.viewport_container)});this.overview_box.bind("dragstart",function(d){this.current_x=d.offsetX}).bind("drag",function(d){var g=d.offsetX-this.current_x;this.current_x=d.offsetX;var f=Math.round(g/a.viewport_container.width()*(a.max_high-a.max_low));a.move_delta(-f)});this.overview_close.bind("click",function(){for(var d in a.tracks){a.tracks[d].is_overview=false}$(this).siblings().filter("canvas").remove();$(this).parent().css("height",a.overview_box.height());a.overview_highlight.hide();$(this).hide()});this.viewport_container.bind("dragstart",function(d){this.origin
al_low=a.low;this.current_height=d.clientY;this.current_x=d.offsetX;this.enable_pan=(d.clientX<a.viewport_container.width()-16)?true:false}).bind("drag",function(g){if(!this.enable_pan||this.in_reordering){return}var d=$(this);var j=g.offsetX-this.current_x;var f=d.scrollTop()-(g.clientY-this.current_height);d.scrollTop(f);this.current_height=g.clientY;this.current_x=g.offsetX;var h=Math.round(j/a.viewport_container.width()*(a.high-a.low));a.move_delta(h)});this.top_labeltrack.bind("dragstart",function(d){this.drag_origin_x=d.clientX;this.drag_origin_pos=d.clientX/a.viewport_container.width()*(a.high-a.low)+a.low;this.drag_div=$("<div />").css({height:a.content_div.height()+30,top:"0px",position:"absolute","background-color":"#cfc",border:"1px solid #6a6",opacity:0.5,"z-index":1000}).appendTo($(this))}).bind("drag",function(j){var f=Math.min(j.clientX,this.drag_origin_x)-a.container.offset().left,d=Math.max(j.clientX,this.drag_origin_x)-a.container.offset().left,h=(a.high-a.
low),g=a.viewport_container.width();a.update_location(Math.round(f/g*h)+a.low,Math.round(d/g*h)+a.low);this.drag_div.css({left:f+"px",width:(d-f)+"px"})}).bind("dragend",function(k){var f=Math.min(k.clientX,this.drag_origin_x),d=Math.max(k.clientX,this.drag_origin_x),h=(a.high-a.low),g=a.viewport_container.width(),j=a.low;a.low=Math.round(f/g*h)+j;a.high=Math.round(d/g*h)+j;this.drag_div.remove();a.redraw()});this.add_label_track(new LabelTrack(this,this.top_labeltrack));this.add_label_track(new LabelTrack(this,this.nav_labeltrack))},update_location:function(a,b){this.location_span.text(commatize(a)+" - "+commatize(b));this.nav_input.val(this.chrom+":"+commatize(a)+"-"+commatize(b))},change_chrom:function(d,a,f){var c=this;var e=$.grep(c.chrom_data,function(h,j){return h.chrom===d})[0];if(e===undefined){return}if(d!==c.chrom){c.chrom=d;if(c.chrom===""){c.intro_div.show()}else{c.intro_div.hide()}c.chrom_select.val(c.chrom);c.max_high=e.len;c.reset();c.redraw(true);for(var g i
n c.tracks){var b=c.tracks[g];if(b.init){b.init()}}}if(a!==undefined&&f!==undefined){c.low=Math.max(a,0);c.high=Math.min(f,c.max_high)}c.reset_overview();c.redraw()},go_to:function(f){var k=this,b=f.split(":"),h=b[0],j=b[1];if(j!==undefined){try{var g=j.split("-"),a=parseInt(g[0].replace(/,/g,"")),d=parseInt(g[1].replace(/,/g,""))}catch(c){return false}}k.change_chrom(h,a,d)},move_delta:function(c){var a=this;var b=a.high-a.low;if(a.low-c<a.max_low){a.low=a.max_low;a.high=a.max_low+b}else{if(a.high-c>a.max_high){a.high=a.max_high;a.low=a.max_high-b}else{a.high-=c;a.low-=c}}a.redraw()},add_track:function(a){a.view=this;a.track_id=this.track_id_counter;this.tracks.push(a);if(a.init){a.init()}a.container_div.attr("id","track_"+a.track_id);this.track_id_counter+=1;this.num_tracks+=1},add_label_track:function(a){a.view=this;this.label_tracks.push(a)},remove_track:function(a){this.has_changes=true;a.container_div.fadeOut("slow",function(){$(this).remove()});delete this.tracks[this
.tracks.indexOf(a)];this.num_tracks-=1},reset:function(){this.low=this.max_low;this.high=this.max_high;this.viewport_container.find(".yaxislabel").remove()},redraw:function(h){var g=this.high-this.low,f=this.low,b=this.high;if(f<this.max_low){f=this.max_low}if(b>this.max_high){b=this.max_high}if(this.high!==0&&g<this.min_separation){b=f+this.min_separation}this.low=Math.floor(f);this.high=Math.ceil(b);this.resolution=Math.pow(10,Math.ceil(Math.log((this.high-this.low)/200)/Math.LN10));this.zoom_res=Math.pow(FEATURE_LEVELS,Math.max(0,Math.ceil(Math.log(this.resolution,FEATURE_LEVELS)/Math.log(FEATURE_LEVELS))));var a=this.low/(this.max_high-this.max_low)*this.overview_viewport.width();var e=(this.high-this.low)/(this.max_high-this.max_low)*this.overview_viewport.width();var j=13;this.overview_box.css({left:a,width:Math.max(j,e)}).show();if(e<j){this.overview_box.css("left",a-(j-e)/2)}if(this.overview_highlight){this.overview_highlight.css({left:a,width:e})}this.update_locatio
n(this.low,this.high);if(!h){for(var c=0,d=this.tracks.length;c<d;c++){if(this.tracks[c]&&this.tracks[c].enabled){this.tracks[c].draw()}}for(var c=0,d=this.label_tracks.length;c<d;c++){this.label_tracks[c].draw()}}},zoom_in:function(b,c){if(this.max_high===0||this.high-this.low<this.min_separation){return}var d=this.high-this.low,e=d/2+this.low,a=(d/this.zoom_factor)/2;if(b){e=b/this.viewport_container.width()*(this.high-this.low)+this.low}this.low=Math.round(e-a);this.high=Math.round(e+a);this.redraw()},zoom_out:function(){if(this.max_high===0){return}var b=this.high-this.low,c=b/2+this.low,a=(b*this.zoom_factor)/2;this.low=Math.round(c-a);this.high=Math.round(c+a);this.redraw()},reset_overview:function(){this.overview_viewport.find("canvas").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()}});var Track=function(b,a,c){this.name=b;this.parent_
element=c;this.view=a;this.init_global()};$.extend(Track.prototype,{init_global:function(){this.container_div=$("<div />").addClass("track");if(!this.hidden){this.header_div=$("<div class='track-header' />").appendTo(this.container_div);if(this.view.editor){this.drag_div=$("<div class='draghandle' />").appendTo(this.header_div)}this.name_div=$("<div class='menubutton popup' />").appendTo(this.header_div);this.name_div.text(this.name)}this.content_div=$("<div class='track-content'>").appendTo(this.container_div);this.parent_element.append(this.container_div)},init_each:function(c,b){var a=this;a.enabled=false;a.data_queue={};a.tile_cache.clear();a.data_cache.clear();a.initial_canvas=undefined;a.content_div.css("height","auto");if(!a.content_div.text()){a.content_div.text(DATA_LOADING)}a.container_div.removeClass("nodata error pending");if(a.view.chrom){$.getJSON(data_url,c,function(d){if(!d||d==="error"||d.kind==="error"){a.container_div.addClass("error");a.content_div.text(D
ATA_ERROR);if(d.message){var f=a.view.tracks.indexOf(a);var e=$("<a href='javascript:void(0);'></a>").attr("id",f+"_error");e.text("Click to view error");$("#"+f+"_error").live("click",function(){show_modal("Trackster Error","<pre>"+d.message+"</pre>",{Close:hide_modal})});a.content_div.append(e)}}else{if(d==="no converter"){a.container_div.addClass("error");a.content_div.text(DATA_NOCONVERTER)}else{if(d.data!==undefined&&(d.data===null||d.data.length===0)){a.container_div.addClass("nodata");a.content_div.text(DATA_NONE)}else{if(d==="pending"){a.container_div.addClass("pending");a.content_div.text(DATA_PENDING);setTimeout(function(){a.init()},5000)}else{a.content_div.text("");a.content_div.css("height",a.height_px+"px");a.enabled=true;b(d);a.draw()}}}}})}else{a.container_div.addClass("nodata");a.content_div.text(DATA_NONE)}}});var TiledTrack=function(){var d=this,c=d.view;if(d.hidden){return}if(d.display_modes!==undefined){if(d.mode_div===undefined){d.mode_div=$("<div class=
'right-float menubutton popup' />").appendTo(d.header_div);var h=d.display_modes[0];d.mode=h;d.mode_div.text(h);var a=function(j){d.mode_div.text(j);d.mode=j;d.tile_cache.clear();d.draw()};var f={};for(var e in d.display_modes){var g=d.display_modes[e];f[g]=function(j){return function(){a(j)}}(g)}make_popupmenu(d.mode_div,f)}else{d.mode_div.hide()}}var b={};b["Set as overview"]=function(){c.overview_viewport.find("canvas").remove();d.is_overview=true;d.set_overview();for(var j in c.tracks){if(c.tracks[j]!==d){c.tracks[j].is_overview=false}}};b["Edit configuration"]=function(){var k=function(){hide_modal()};var j=function(){d.update_options(d.track_id);hide_modal()};show_modal("Configure Track",d.gen_options(d.track_id),{Cancel:k,OK:j})};b.Remove=function(){c.remove_track(d);if(c.num_tracks===0){$("#no-tracks").show()}};make_popupmenu(d.name_div,b)};$.extend(TiledTrack.prototype,Track.prototype,{draw:function(){var j=this.view.low,e=this.view.high,f=e-j,d=this.view.resolution
;var l=$("<div style='position: relative;'></div>"),m=this.content_div.width()/f,h;this.content_div.children(":first").remove();this.content_div.append(l),this.max_height=0;var a=Math.floor(j/d/DENSITY);while((a*DENSITY*d)<e){var k=this.content_div.width()+"_"+m+"_"+a;var c=this.tile_cache.get(k);if(c){var g=a*DENSITY*d;var b=(g-j)*m;if(this.left_offset){b-=this.left_offset}c.css({left:b});l.append(c);this.max_height=Math.max(this.max_height,c.height());this.content_div.css("height",this.max_height+"px")}else{this.delayed_draw(this,k,j,e,a,d,l,m)}a+=1}},delayed_draw:function(c,e,a,f,b,d,g,h){setTimeout(function(){if(!(a>c.view.high||f<c.view.low)){tile_element=c.draw_tile(d,b,g,h);if(tile_element){if(!c.initial_canvas){c.initial_canvas=$(tile_element).clone();var l=tile_element.get(0).getContext("2d");var j=c.initial_canvas.get(0).getContext("2d");var k=l.getImageData(0,0,l.canvas.width,l.canvas.height);j.putImageData(k,0,0);c.set_overview()}c.tile_cache.set(e,tile_element);
c.max_height=Math.max(c.max_height,tile_element.height());c.content_div.css("height",c.max_height+"px")}}},50)},set_overview:function(){var a=this.view;if(this.initial_canvas&&this.is_overview){a.overview_close.show();a.overview_viewport.append(this.initial_canvas);a.overview_highlight.show().height(this.initial_canvas.height());a.overview_viewport.height(this.initial_canvas.height()+a.overview_box.height())}$(window).trigger("resize")}});var LabelTrack=function(a,b){this.track_type="LabelTrack";this.hidden=true;Track.call(this,null,a,b);this.container_div.addClass("label-track")};$.extend(LabelTrack.prototype,Track.prototype,{draw:function(){var c=this.view,d=c.high-c.low,g=Math.floor(Math.pow(10,Math.floor(Math.log(d)/Math.log(10)))),a=Math.floor(c.low/g)*g,e=this.content_div.width(),b=$("<div style='position: relative; height: 1.3em;'></div>");while(a<c.high){var f=(a-c.low)/d*e;b.append($("<div class='label'>"+commatize(a)+"</div>").css({position:"absolute",left:f-1}));a
+=g}this.content_div.children(":first").remove();this.content_div.append(b)}});var ReferenceTrack=function(a){this.track_type="ReferenceTrack";this.hidden=true;Track.call(this,null,a,a.top_labeltrack);TiledTrack.call(this);this.left_offset=200;this.height_px=12;this.container_div.addClass("reference-track");this.dummy_canvas=$("<canvas></canvas>").get(0).getContext("2d");this.data_queue={};this.data_cache=new Cache(CACHED_DATA);this.tile_cache=new Cache(CACHED_TILES_LINE)};$.extend(ReferenceTrack.prototype,TiledTrack.prototype,{get_data:function(d,b){var c=this,a=b*DENSITY*d,f=(b+1)*DENSITY*d,e=d+"_"+b;if(!c.data_queue[e]){c.data_queue[e]=true;$.ajax({url:reference_url,dataType:"json",data:{chrom:this.view.chrom,low:a,high:f,dbkey:this.view.dbkey},success:function(g){c.data_cache.set(e,g);delete c.data_queue[e];c.draw()},error:function(h,g,j){console.log(h,g,j)}})}},draw_tile:function(f,b,l,p){var g=b*DENSITY*f,d=DENSITY*f,e=$("<canvas class='tile'></canvas>"),o=e.get(0).get
Context("2d"),k=f+"_"+b;if(p>PX_PER_CHAR){if(this.data_cache.get(k)===undefined){this.get_data(f,b);return}var n=this.data_cache.get(k);if(n===null){this.content_div.css("height","0px");return}e.get(0).width=Math.ceil(d*p+this.left_offset);e.get(0).height=this.height_px;e.css({position:"absolute",top:0,left:(g-this.view.low)*p-this.left_offset});for(var h=0,m=n.length;h<m;h++){var a=Math.round(h*p),j=Math.round(p/2);o.fillText(n[h],a+this.left_offset+j,10)}l.append(e);return e}this.content_div.css("height","0px")}});var LineTrack=function(d,b,a,c){this.track_type="LineTrack";this.display_modes=["Line","Filled","Intensity"];this.mode="Line";Track.call(this,d,b,b.viewport_container);TiledTrack.call(this);this.height_px=80;this.dataset_id=a;this.data_cache=new Cache(CACHED_DATA);this.tile_cache=new Cache(CACHED_TILES_LINE);this.prefs={min_value:undefined,max_value:undefined,mode:"Line"};if(c.min_value!==undefined){this.prefs.min_value=c.min_value}if(c.max_value!==undefined){thi
s.prefs.max_value=c.max_value}};$.extend(LineTrack.prototype,TiledTrack.prototype,{init:function(){var a=this,b=a.view.tracks.indexOf(a);a.vertical_range=undefined;this.init_each({stats:true,chrom:a.view.chrom,low:null,high:null,dataset_id:a.dataset_id},function(c){a.container_div.addClass("line-track");data=c.data;if(isNaN(parseFloat(a.prefs.min_value))||isNaN(parseFloat(a.prefs.max_value))){a.prefs.min_value=data.min;a.prefs.max_value=data.max;$("#track_"+b+"_minval").val(a.prefs.min_value);$("#track_"+b+"_maxval").val(a.prefs.max_value)}a.vertical_range=a.prefs.max_value-a.prefs.min_value;a.total_frequency=data.total_frequency;$("#linetrack_"+b+"_minval").remove();$("#linetrack_"+b+"_maxval").remove();a.container_div.css("position","relative");var e=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+b+"_minval").text(round_1000(a.prefs.min_value));var d=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+b+"_maxval").text(round_1000(a.prefs.max_value));d.cs
s({position:"absolute",top:"22px",left:"10px"});d.prependTo(a.container_div);e.css({position:"absolute",top:a.height_px+11+"px",left:"10px"});e.prependTo(a.container_div)})},get_data:function(d,b){var c=this,a=b*DENSITY*d,f=(b+1)*DENSITY*d,e=d+"_"+b;if(!c.data_queue[e]){c.data_queue[e]=true;$.ajax({url:data_url,dataType:"json",data:{chrom:this.view.chrom,low:a,high:f,dataset_id:this.dataset_id,resolution:this.view.resolution},success:function(g){data=g.data;c.data_cache.set(e,data);delete c.data_queue[e];c.draw()},error:function(h,g,j){console.log(h,g,j)}})}},draw_tile:function(p,r,c,e){if(this.vertical_range===undefined){return}var s=r*DENSITY*p,a=DENSITY*p,b=$("<canvas class='tile'></canvas>"),v=p+"_"+r;if(this.data_cache.get(v)===undefined){this.get_data(p,r);return}var j=this.data_cache.get(v);if(j===null){return}b.css({position:"absolute",top:0,left:(s-this.view.low)*e});b.get(0).width=Math.ceil(a*e);b.get(0).height=this.height_px;var o=b.get(0).getContext("2d"),k=false
,l=this.prefs.min_value,g=this.prefs.max_value,n=this.vertical_range,t=this.total_frequency,d=this.height_px,m=this.mode;o.beginPath();if(data.length>1){var f=Math.ceil((data[1][0]-data[0][0])*e)}else{var f=10}var u,h;for(var q=0;q<data.length;q++){u=(data[q][0]-s)*e;h=data[q][1];if(m=="Intensity"){if(h===null){continue}if(h<=l){h=l}else{if(h>=g){h=g}}h=255-Math.floor((h-l)/n*255);o.fillStyle="rgb("+h+","+h+","+h+")";o.fillRect(u,0,f,this.height_px)}else{if(h===null){if(k&&m==="Filled"){o.lineTo(u,d)}k=false;continue}else{if(h<=l){h=l}else{if(h>=g){h=g}}h=Math.round(d-(h-l)/n*d);if(k){o.lineTo(u,h)}else{k=true;if(m==="Filled"){o.moveTo(u,d);o.lineTo(u,h)}else{o.moveTo(u,h)}}}}}if(m==="Filled"){if(k){o.lineTo(u,d)}o.fill()}else{o.stroke()}c.append(b);return b},gen_options:function(k){var a=$("<div />").addClass("form-row");var e="track_"+k+"_minval",h=$("<label></label>").attr("for",e).text("Min value:"),b=(this.prefs.min_value===undefined?"":this.prefs.min_value),j=$("<input
></input>").attr("id",e).val(b),g="track_"+k+"_maxval",d=$("<label></label>").attr("for",g).text("Max value:"),f=(this.prefs.max_value===undefined?"":this.prefs.max_value),c=$("<input></input>").attr("id",g).val(f);return a.append(h).append(j).append(d).append(c)},update_options:function(c){var a=$("#track_"+c+"_minval").val(),b=$("#track_"+c+"_maxval").val();if(a!==this.prefs.min_value||b!==this.prefs.max_value){this.prefs.min_value=parseFloat(a);this.prefs.max_value=parseFloat(b);this.vertical_range=this.prefs.max_value-this.prefs.min_value;$("#linetrack_"+c+"_minval").text(this.prefs.min_value);$("#linetrack_"+c+"_maxval").text(this.prefs.max_value);this.tile_cache.clear();this.draw()}}});var FeatureTrack=function(d,b,a,c){this.track_type="FeatureTrack";this.display_modes=["Auto","Dense","Squish","Pack"];Track.call(this,d,b,b.viewport_container);TiledTrack.call(this);this.height_px=0;this.container_div.addClass("feature-track");this.dataset_id=a;this.zo_slots={};this.show
_labels_scale=0.001;this.showing_details=false;this.vertical_detail_px=10;this.vertical_nodetail_px=2;this.summary_draw_height=30;this.default_font="9px Monaco, Lucida Console, monospace";this.inc_slots={};this.data_queue={};this.s_e_by_tile={};this.tile_cache=new Cache(CACHED_TILES_FEATURE);this.data_cache=new Cache(20);this.left_offset=200;this.prefs={block_color:"black",label_color:"black",show_counts:true};if(c.block_color!==undefined){this.prefs.block_color=c.block_color}if(c.label_color!==undefined){this.prefs.label_color=c.label_color}if(c.show_counts!==undefined){this.prefs.show_counts=c.show_counts}};$.extend(FeatureTrack.prototype,TiledTrack.prototype,{init:function(){var a=this,b="initial";this.init_each({low:a.view.max_low,high:a.view.max_high,dataset_id:a.dataset_id,chrom:a.view.chrom,resolution:this.view.resolution,mode:a.mode},function(c){a.mode_div.show();a.data_cache.set(b,c);a.draw()})},get_data:function(a,d){var b=this,c=a+"_"+d;if(!b.data_queue[c]){b.data
_queue[c]=true;$.getJSON(data_url,{chrom:b.view.chrom,low:a,high:d,dataset_id:b.dataset_id,resolution:this.view.resolution,mode:this.mode},function(e){b.data_cache.set(c,e);delete b.data_queue[c];b.draw()})}},incremental_slots:function(a,h,c,r){if(!this.inc_slots[a]){this.inc_slots[a]={};this.inc_slots[a].w_scale=a;this.inc_slots[a].mode=r;this.s_e_by_tile[a]={}}var n=this.inc_slots[a].w_scale,z=[],l=0,b=$("<canvas></canvas>").get(0).getContext("2d"),o=this.view.max_low;var B=[];if(this.inc_slots[a].mode!==r){delete this.inc_slots[a];this.inc_slots[a]={mode:r,w_scale:n};delete this.s_e_by_tile[a];this.s_e_by_tile[a]={}}for(var w=0,x=h.length;w<x;w++){var g=h[w],m=g[0];if(this.inc_slots[a][m]!==undefined){l=Math.max(l,this.inc_slots[a][m]);B.push(this.inc_slots[a][m])}else{z.push(w)}}for(var w=0,x=z.length;w<x;w++){var g=h[z[w]],m=g[0],s=g[1],d=g[2],q=g[3],e=Math.floor((s-o)*n),f=Math.ceil((d-o)*n);if(q!==undefined&&!c){var t=b.measureText(q).width;if(e-t<0){f+=t}else{e-=t}}v
ar v=0;while(true){var p=true;if(this.s_e_by_tile[a][v]!==undefined){for(var u=0,A=this.s_e_by_tile[a][v].length;u<A;u++){var y=this.s_e_by_tile[a][v][u];if(f>y[0]&&e<y[1]){p=false;break}}}if(p){if(this.s_e_by_tile[a][v]===undefined){this.s_e_by_tile[a][v]=[]}this.s_e_by_tile[a][v].push([e,f]);this.inc_slots[a][m]=v;l=Math.max(l,v);break}v++}}return l},rect_or_text:function(n,o,f,m,b,d,k,e,h){n.textAlign="center";var j=Math.round(o/2);if((this.mode==="Pack"||this.mode==="Auto")&&d!==undefined&&o>PX_PER_CHAR){n.fillStyle=this.prefs.block_color;n.fillRect(k,h+1,e,9);n.fillStyle="#eee";for(var g=0,l=d.length;g<l;g++){if(b+g>=f&&b+g<=m){var a=Math.floor(Math.max(0,(b+g-f)*o));n.fillText(d[g],a+this.left_offset+j,h+9)}}}else{n.fillStyle=this.prefs.block_color;n.fillRect(k,h+4,e,3)}},draw_tile:function(ac,n,q,ap){var L=n*DENSITY*ac,ah=(n+1)*DENSITY*ac,K=ah-L;var aj=(!this.initial_canvas?"initial":L+"_"+ah);var G=this.data_cache.get(aj);var e;if(G===undefined||(this.mode!=="Auto"&&
G.dataset_type==="summary_tree")){this.data_queue[[L,ah]]=true;this.get_data(L,ah);return}var a=Math.ceil(K*ap),Q=$("<canvas class='tile'></canvas>"),ae=this.prefs.label_color,h=this.prefs.block_color,p=this.mode,v=25,aa=(p==="Squish")||(p==="Dense")&&(p!=="Pack")||(p==="Auto"&&(G.extra_info==="no_detail")),U=this.left_offset,ao,B,aq;if(G.dataset_type==="summary_tree"){B=this.summary_draw_height}else{if(p==="Dense"){B=v;aq=10}else{aq=(aa?this.vertical_nodetail_px:this.vertical_detail_px);var w=(ap<0.0001?1/view.zoom_res:ap);B=this.incremental_slots(w,G.data,aa,p)*aq+v;ao=this.inc_slots[w]}}Q.css({position:"absolute",top:0,left:(L-this.view.low)*ap-U});Q.get(0).width=a+U;Q.get(0).height=B;q.parent().css("height",Math.max(this.height_px,B)+"px");var H=Q.get(0).getContext("2d");H.fillStyle=h;H.font=this.default_font;H.textAlign="right";if(G.dataset_type=="summary_tree"){var W=G.data,J=G.max,o=G.avg,b=Math.ceil(G.delta*ap);for(var al=0,F=W.length;al<F;al++){var Y=Math.floor((W[a
l][0]-L)*ap);var X=W[al][1];if(!X){continue}var ai=X/J*this.summary_draw_height;H.fillStyle="black";H.fillRect(Y+U,this.summary_draw_height-ai,b,ai);if(this.prefs.show_counts&&H.measureText(X).width<b){H.fillStyle="#bbb";H.textAlign="center";H.fillText(X,Y+U+(b/2),this.summary_draw_height-5)}}e="Summary";q.append(Q);return Q}if(G.message){Q.css({border:"solid red","border-width":"2px 2px 2px 0px"});H.fillStyle="red";H.textAlign="left";H.fillText(G.message,100+U,aq)}var an=G.data;var ak=0;for(var al=0,F=an.length;al<F;al++){var R=an[al],P=R[0],am=R[1],Z=R[2],M=R[3];if(am<=ah&&Z>=L){var ab=Math.floor(Math.max(0,(am-L)*ap)),I=Math.ceil(Math.min(a,Math.max(0,(Z-L)*ap))),V=(p==="Dense"?1:(1+ao[P]))*aq;if(G.dataset_type==="bai"){var t=R[4];H.fillStyle=h;if(R[5] instanceof Array){var C=Math.floor(Math.max(0,(R[5][0]-L)*ap)),O=Math.ceil(Math.min(a,Math.max(0,(R[5][1]-L)*ap))),A=Math.floor(Math.max(0,(R[6][0]-L)*ap)),u=Math.ceil(Math.min(a,Math.max(0,(R[6][1]-L)*ap)));if(R[5][1]>=L&&
R[5][0]<=ah){this.rect_or_text(H,ap,L,ah,R[5][0],R[5][2],C+U,O-C,V)}if(R[6][1]>=L&&R[6][0]<=ah){this.rect_or_text(H,ap,L,ah,R[6][0],R[6][2],A+U,u-A,V)}if(A>O){H.fillStyle="#999";H.fillRect(O+U,V+5,A-O,1)}}else{H.fillStyle=h;this.rect_or_text(H,ap,L,ah,am,M,ab+U,I-ab,V)}if(p!=="Dense"&&!aa&&am>L){H.fillStyle=this.prefs.label_color;if(n===0&&ab-H.measureText(M).width<0){H.textAlign="left";H.fillText(P,I+2+U,V+8)}else{H.textAlign="right";H.fillText(P,ab-2+U,V+8)}H.fillStyle=h}}else{if(G.dataset_type==="interval_index"){if(aa){H.fillStyle=h;H.fillRect(ab+U,V+5,I-ab,1)}else{var E=R[4],T=R[5],ad=R[6],g=R[7];var D,af,N=null,ar=null;if(T&&ad){N=Math.floor(Math.max(0,(T-L)*ap));ar=Math.ceil(Math.min(a,Math.max(0,(ad-L)*ap)))}if(p!=="Dense"&&M!==undefined&&am>L){H.fillStyle=ae;if(n===0&&ab-H.measureText(M).width<0){H.textAlign="left";H.fillText(M,I+2+U,V+8)}else{H.textAlign="right";H.fillText(M,ab-2+U,V+8)}H.fillStyle=h}if(g){if(E){if(E=="+"){H.fillStyle=RIGHT_STRAND}else{if(E=="-"){H
.fillStyle=LEFT_STRAND}}H.fillRect(ab+U,V,I-ab,10);H.fillStyle=h}for(var aj=0,f=g.length;aj<f;aj++){var s=g[aj],d=Math.floor(Math.max(0,(s[0]-L)*ap)),S=Math.ceil(Math.min(a,Math.max((s[1]-L)*ap)));if(d>S){continue}D=5;af=3;H.fillRect(d+U,V+af,S-d,D);if(N!==undefined&&!(d>ar||S<N)){D=9;af=1;var ag=Math.max(d,N),z=Math.min(S,ar);H.fillRect(ag+U,V+af,z-ag,D)}}}else{D=9;af=1;H.fillRect(ab+U,V+af,I-ab,D);if(R.strand){if(R.strand=="+"){H.fillStyle=RIGHT_STRAND_INV}else{if(R.strand=="-"){H.fillStyle=LEFT_STRAND_INV}}H.fillRect(ab+U,V,I-ab,10);H.fillStyle=h}}}}else{if(G.dataset_type==="vcf"){if(aa){H.fillStyle=h;H.fillRect(ab+U,V+5,I-ab,1)}else{var r=R[4],m=R[5],c=R[6];D=9;af=1;H.fillRect(ab+U,V,I-ab,D);if(p!=="Dense"&&M!==undefined&&am>L){H.fillStyle=ae;if(n===0&&ab-H.measureText(M).width<0){H.textAlign="left";H.fillText(M,I+2+U,V+8)}else{H.textAlign="right";H.fillText(M,ab-2+U,V+8)}H.fillStyle=h}var l=r+" / "+m;if(am>L&&H.measureText(l).width<(I-ab)){H.fillStyle="white";H.textAlig
n="center";H.fillText(l,U+ab+(I-ab)/2,V+8);H.fillStyle=h}}}}}ak++}}q.append(Q);return Q},gen_options:function(j){var a=$("<div />").addClass("form-row");var e="track_"+j+"_block_color",l=$("<label />").attr("for",e).text("Block color:"),m=$("<input />").attr("id",e).attr("name",e).val(this.prefs.block_color),k="track_"+j+"_label_color",g=$("<label />").attr("for",k).text("Text color:"),h=$("<input />").attr("id",k).attr("name",k).val(this.prefs.label_color),f="track_"+j+"_show_count",c=$("<label />").attr("for",f).text("Show summary counts"),b=$('<input type="checkbox" style="float:left;"></input>').attr("id",f).attr("name",f).attr("checked",this.prefs.show_counts),d=$("<div />").append(b).append(c);return a.append(l).append(m).append(g).append(h).append(d)},update_options:function(e){var b=$("#track_"+e+"_block_color").val(),d=$("#track_"+e+"_label_color").val(),c=$("#track_"+e+"_mode option:selected").val(),a=$("#track_"+e+"_show_count").attr("checked");if(b!==this.prefs.b
lock_color||d!==this.prefs.label_color||a!==this.prefs.show_counts){this.prefs.block_color=b;this.prefs.label_color=d;this.prefs.show_counts=a;this.tile_cache.clear();this.draw()}}});var ReadTrack=function(d,b,a,c){FeatureTrack.call(this,d,b,a,c);this.track_type="ReadTrack";this.vertical_detail_px=10;this.vertical_nodetail_px=5};$.extend(ReadTrack.prototype,TiledTrack.prototype,FeatureTrack.prototype,{});
+var DENSITY=200,FEATURE_LEVELS=10,MAX_FEATURE_DEPTH=100,DATA_ERROR="There was an error in indexing this dataset. ",DATA_NOCONVERTER="A converter for this dataset is not installed. Please check your datatypes_conf.xml file.",DATA_NONE="No data for this chrom/contig.",DATA_PENDING="Currently indexing... please wait",DATA_LOADING="Loading data...",CACHED_TILES_FEATURE=10,CACHED_TILES_LINE=30,CACHED_DATA=5,CONTEXT=$("<canvas></canvas>").get(0).getContext("2d"),PX_PER_CHAR=CONTEXT.measureText("A").width,RIGHT_STRAND,LEFT_STRAND;var right_img=new Image();right_img.src=image_path+"/visualization/strand_right.png";right_img.onload=function(){RIGHT_STRAND=CONTEXT.createPattern(right_img,"repeat")};var left_img=new Image();left_img.src=image_path+"/visualization/strand_left.png";left_img.onload=function(){LEFT_STRAND=CONTEXT.createPattern(left_img,"repeat")};var right_img_inv=new Image();right_img_inv.src=image_path+"/visualization/strand_right_inv.png";right_img_inv.onload=function()
{RIGHT_STRAND_INV=CONTEXT.createPattern(right_img_inv,"repeat")};var left_img_inv=new Image();left_img_inv.src=image_path+"/visualization/strand_left_inv.png";left_img_inv.onload=function(){LEFT_STRAND_INV=CONTEXT.createPattern(left_img_inv,"repeat")};function round_1000(a){return Math.round(a*1000)/1000}var Cache=function(a){this.num_elements=a;this.clear()};$.extend(Cache.prototype,{get:function(b){var a=this.key_ary.indexOf(b);if(a!=-1){this.key_ary.splice(a,1);this.key_ary.push(b)}return this.obj_cache[b]},set:function(b,c){if(!this.obj_cache[b]){if(this.key_ary.length>=this.num_elements){var a=this.key_ary.shift();delete this.obj_cache[a]}this.key_ary.push(b)}this.obj_cache[b]=c;return c},clear:function(){this.obj_cache={};this.key_ary=[]}});var View=function(a,c,e,d,b){this.container=a;this.vis_id=d;this.dbkey=b;this.title=e;this.chrom=c;this.tracks=[];this.label_tracks=[];this.max_low=0;this.max_high=0;this.num_tracks=0;this.track_id_counter=0;this.zoom_factor=3;this.
min_separation=30;this.has_changes=false;this.init();this.reset()};$.extend(View.prototype,{init:function(){var c=this.container,a=this;this.top_labeltrack=$("<div/>").addClass("top-labeltrack").appendTo(c);this.content_div=$("<div/>").addClass("content").css("position","relative").appendTo(c);this.viewport_container=$("<div/>").addClass("viewport-container").addClass("viewport-container").appendTo(this.content_div);this.intro_div=$("<div/>").addClass("intro").text("Select a chrom from the dropdown below").hide();this.nav_container=$("<div/>").addClass("nav-container").appendTo(c);this.nav_labeltrack=$("<div/>").addClass("nav-labeltrack").appendTo(this.nav_container);this.nav=$("<div/>").addClass("nav").appendTo(this.nav_container);this.overview=$("<div/>").addClass("overview").appendTo(this.nav);this.overview_viewport=$("<div/>").addClass("overview-viewport").appendTo(this.overview);this.overview_close=$("<a href='javascript:void(0);'>Close Overview</a>").addClass("overview
-close").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_form=$("<form/>").attr("action",function(){void (0)}).appendTo(this.nav_controls);this.chrom_select=$("<select/>").attr({name:"chrom"}).css("width","15em").addClass("no-autocomplete").append("<option value=''>Loading</option>").appendTo(this.chrom_form);var b=function(d){if(d.type==="focusout"||(d.keyCode||d.which)===13||(d.keyCode||d.which)===27){if((d.keyCode||d.which)!==27){a.go_to($(this).val())}$(this).hide();a.location_span.show();a.chrom_select.show();return false}};this.nav_input=$("<inp
ut/>").addClass("nav-input").hide().bind("keypress focusout",b).appendTo(this.chrom_form);this.location_span=$("<span/>").addClass("location").appendTo(this.chrom_form);this.location_span.bind("click",function(){a.location_span.hide();a.chrom_select.hide();a.nav_input.css("display","inline-block");a.nav_input.select();a.nav_input.focus()});if(this.vis_id!==undefined){this.hidden_input=$("<input/>").attr("type","hidden").val(this.vis_id).appendTo(this.chrom_form)}this.zo_link=$("<a/>").click(function(){a.zoom_out();a.redraw()}).html('<img src="'+image_path+'/fugue/magnifier-zoom-out.png" />').appendTo(this.chrom_form);this.zi_link=$("<a/>").click(function(){a.zoom_in();a.redraw()}).html('<img src="'+image_path+'/fugue/magnifier-zoom.png" />').appendTo(this.chrom_form);$.ajax({url:chrom_url,data:(this.vis_id!==undefined?{vis_id:this.vis_id}:{dbkey:this.dbkey}),dataType:"json",success:function(d){if(d.reference){a.add_label_track(new ReferenceTrack(a))}a.chrom_data=d.chrom_info
;var f='<option value="">Select Chrom/Contig</option>';for(i in a.chrom_data){var e=a.chrom_data[i]["chrom"];f+='<option value="'+e+'">'+e+"</option>"}a.chrom_select.html(f);a.intro_div.show();a.chrom_select.bind("change",function(){a.change_chrom(a.chrom_select.val())})},error:function(){alert("Could not load chroms for this dbkey:",a.dbkey)}});this.content_div.bind("dblclick",function(d){a.zoom_in(d.pageX,this.viewport_container)});this.overview_box.bind("dragstart",function(d){this.current_x=d.offsetX}).bind("drag",function(d){var g=d.offsetX-this.current_x;this.current_x=d.offsetX;var f=Math.round(g/a.viewport_container.width()*(a.max_high-a.max_low));a.move_delta(-f)});this.overview_close.bind("click",function(){for(var d in a.tracks){a.tracks[d].is_overview=false}$(this).siblings().filter("canvas").remove();$(this).parent().css("height",a.overview_box.height());a.overview_highlight.hide();$(this).hide()});this.viewport_container.bind("dragstart",function(d){this.origin
al_low=a.low;this.current_height=d.clientY;this.current_x=d.offsetX;this.enable_pan=(d.clientX<a.viewport_container.width()-16)?true:false}).bind("drag",function(g){if(!this.enable_pan||this.in_reordering){return}var d=$(this);var j=g.offsetX-this.current_x;var f=d.scrollTop()-(g.clientY-this.current_height);d.scrollTop(f);this.current_height=g.clientY;this.current_x=g.offsetX;var h=Math.round(j/a.viewport_container.width()*(a.high-a.low));a.move_delta(h)});this.top_labeltrack.bind("dragstart",function(d){this.drag_origin_x=d.clientX;this.drag_origin_pos=d.clientX/a.viewport_container.width()*(a.high-a.low)+a.low;this.drag_div=$("<div />").css({height:a.content_div.height()+30,top:"0px",position:"absolute","background-color":"#cfc",border:"1px solid #6a6",opacity:0.5,"z-index":1000}).appendTo($(this))}).bind("drag",function(j){var f=Math.min(j.clientX,this.drag_origin_x)-a.container.offset().left,d=Math.max(j.clientX,this.drag_origin_x)-a.container.offset().left,h=(a.high-a.
low),g=a.viewport_container.width();a.update_location(Math.round(f/g*h)+a.low,Math.round(d/g*h)+a.low);this.drag_div.css({left:f+"px",width:(d-f)+"px"})}).bind("dragend",function(k){var f=Math.min(k.clientX,this.drag_origin_x),d=Math.max(k.clientX,this.drag_origin_x),h=(a.high-a.low),g=a.viewport_container.width(),j=a.low;a.low=Math.round(f/g*h)+j;a.high=Math.round(d/g*h)+j;this.drag_div.remove();a.redraw()});this.add_label_track(new LabelTrack(this,this.top_labeltrack));this.add_label_track(new LabelTrack(this,this.nav_labeltrack))},update_location:function(a,b){this.location_span.text(commatize(a)+" - "+commatize(b));this.nav_input.val(this.chrom+":"+commatize(a)+"-"+commatize(b))},change_chrom:function(d,a,f){var c=this;var e=$.grep(c.chrom_data,function(h,j){return h.chrom===d})[0];if(e===undefined){return}if(d!==c.chrom){c.chrom=d;if(c.chrom===""){c.intro_div.show()}else{c.intro_div.hide()}c.chrom_select.val(c.chrom);c.max_high=e.len;c.reset();c.redraw(true);for(var g i
n c.tracks){var b=c.tracks[g];if(b.init){b.init()}}}if(a!==undefined&&f!==undefined){c.low=Math.max(a,0);c.high=Math.min(f,c.max_high)}c.reset_overview();c.redraw()},go_to:function(f){var k=this,b=f.split(":"),h=b[0],j=b[1];if(j!==undefined){try{var g=j.split("-"),a=parseInt(g[0].replace(/,/g,"")),d=parseInt(g[1].replace(/,/g,""))}catch(c){return false}}k.change_chrom(h,a,d)},move_delta:function(c){var a=this;var b=a.high-a.low;if(a.low-c<a.max_low){a.low=a.max_low;a.high=a.max_low+b}else{if(a.high-c>a.max_high){a.high=a.max_high;a.low=a.max_high-b}else{a.high-=c;a.low-=c}}a.redraw()},add_track:function(a){a.view=this;a.track_id=this.track_id_counter;this.tracks.push(a);if(a.init){a.init()}a.container_div.attr("id","track_"+a.track_id);this.track_id_counter+=1;this.num_tracks+=1},add_label_track:function(a){a.view=this;this.label_tracks.push(a)},remove_track:function(a){this.has_changes=true;a.container_div.fadeOut("slow",function(){$(this).remove()});delete this.tracks[this
.tracks.indexOf(a)];this.num_tracks-=1},reset:function(){this.low=this.max_low;this.high=this.max_high;this.viewport_container.find(".yaxislabel").remove()},redraw:function(h){var g=this.high-this.low,f=this.low,b=this.high;if(f<this.max_low){f=this.max_low}if(b>this.max_high){b=this.max_high}if(this.high!==0&&g<this.min_separation){b=f+this.min_separation}this.low=Math.floor(f);this.high=Math.ceil(b);this.resolution=Math.pow(10,Math.ceil(Math.log((this.high-this.low)/200)/Math.LN10));this.zoom_res=Math.pow(FEATURE_LEVELS,Math.max(0,Math.ceil(Math.log(this.resolution,FEATURE_LEVELS)/Math.log(FEATURE_LEVELS))));var a=this.low/(this.max_high-this.max_low)*this.overview_viewport.width();var e=(this.high-this.low)/(this.max_high-this.max_low)*this.overview_viewport.width();var j=13;this.overview_box.css({left:a,width:Math.max(j,e)}).show();if(e<j){this.overview_box.css("left",a-(j-e)/2)}if(this.overview_highlight){this.overview_highlight.css({left:a,width:e})}this.update_locatio
n(this.low,this.high);if(!h){for(var c=0,d=this.tracks.length;c<d;c++){if(this.tracks[c]&&this.tracks[c].enabled){this.tracks[c].draw()}}for(var c=0,d=this.label_tracks.length;c<d;c++){this.label_tracks[c].draw()}}},zoom_in:function(b,c){if(this.max_high===0||this.high-this.low<this.min_separation){return}var d=this.high-this.low,e=d/2+this.low,a=(d/this.zoom_factor)/2;if(b){e=b/this.viewport_container.width()*(this.high-this.low)+this.low}this.low=Math.round(e-a);this.high=Math.round(e+a);this.redraw()},zoom_out:function(){if(this.max_high===0){return}var b=this.high-this.low,c=b/2+this.low,a=(b*this.zoom_factor)/2;this.low=Math.round(c-a);this.high=Math.round(c+a);this.redraw()},reset_overview:function(){this.overview_viewport.find("canvas").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()}});var Track=function(b,a,c){this.name=b;this.parent_
element=c;this.view=a;this.init_global()};$.extend(Track.prototype,{init_global:function(){this.container_div=$("<div />").addClass("track").css("position","relative");if(!this.hidden){this.header_div=$("<div class='track-header' />").appendTo(this.container_div);if(this.view.editor){this.drag_div=$("<div class='draghandle' />").appendTo(this.header_div)}this.name_div=$("<div class='menubutton popup' />").appendTo(this.header_div);this.name_div.text(this.name)}this.content_div=$("<div class='track-content'>").appendTo(this.container_div);this.parent_element.append(this.container_div)},init_each:function(c,b){var a=this;a.enabled=false;a.data_queue={};a.tile_cache.clear();a.data_cache.clear();a.initial_canvas=undefined;a.content_div.css("height","auto");if(!a.content_div.text()){a.content_div.text(DATA_LOADING)}a.container_div.removeClass("nodata error pending");if(a.view.chrom){$.getJSON(data_url,c,function(d){if(!d||d==="error"||d.kind==="error"){a.container_div.addClass("e
rror");a.content_div.text(DATA_ERROR);if(d.message){var f=a.view.tracks.indexOf(a);var e=$("<a href='javascript:void(0);'></a>").attr("id",f+"_error");e.text("Click to view error");$("#"+f+"_error").live("click",function(){show_modal("Trackster Error","<pre>"+d.message+"</pre>",{Close:hide_modal})});a.content_div.append(e)}}else{if(d==="no converter"){a.container_div.addClass("error");a.content_div.text(DATA_NOCONVERTER)}else{if(d.data!==undefined&&(d.data===null||d.data.length===0)){a.container_div.addClass("nodata");a.content_div.text(DATA_NONE)}else{if(d==="pending"){a.container_div.addClass("pending");a.content_div.text(DATA_PENDING);setTimeout(function(){a.init()},5000)}else{a.content_div.text("");a.content_div.css("height",a.height_px+"px");a.enabled=true;b(d);a.draw()}}}}})}else{a.container_div.addClass("nodata");a.content_div.text(DATA_NONE)}}});var TiledTrack=function(){var d=this,c=d.view;if(d.hidden){return}if(d.display_modes!==undefined){if(d.mode_div===undefined
){d.mode_div=$("<div class='right-float menubutton popup' />").appendTo(d.header_div);var h=d.display_modes[0];d.mode=h;d.mode_div.text(h);var a=function(j){d.mode_div.text(j);d.mode=j;d.tile_cache.clear();d.draw()};var f={};for(var e in d.display_modes){var g=d.display_modes[e];f[g]=function(j){return function(){a(j)}}(g)}make_popupmenu(d.mode_div,f)}else{d.mode_div.hide()}}var b={};b["Set as overview"]=function(){c.overview_viewport.find("canvas").remove();d.is_overview=true;d.set_overview();for(var j in c.tracks){if(c.tracks[j]!==d){c.tracks[j].is_overview=false}}};b["Edit configuration"]=function(){var l=function(){hide_modal();$(window).unbind("keypress.check_enter_esc")},j=function(){d.update_options(d.track_id);hide_modal();$(window).unbind("keypress.check_enter_esc")},k=function(m){if((m.keyCode||m.which)===27){l()}else{if((m.keyCode||m.which)===13){j()}}};$(window).bind("keypress.check_enter_esc",k);show_modal("Configure Track",d.gen_options(d.track_id),{Cancel:l,OK
:j})};b.Remove=function(){c.remove_track(d);if(c.num_tracks===0){$("#no-tracks").show()}};make_popupmenu(d.name_div,b)};$.extend(TiledTrack.prototype,Track.prototype,{draw:function(){var j=this.view.low,e=this.view.high,f=e-j,d=this.view.resolution;var l=$("<div style='position: relative;'></div>"),m=this.content_div.width()/f,h;this.content_div.children(":first").remove();this.content_div.append(l),this.max_height=0;var a=Math.floor(j/d/DENSITY);while((a*DENSITY*d)<e){var k=this.content_div.width()+"_"+m+"_"+a;var c=this.tile_cache.get(k);if(c){var g=a*DENSITY*d;var b=(g-j)*m;if(this.left_offset){b-=this.left_offset}c.css({left:b});l.append(c);this.max_height=Math.max(this.max_height,c.height());this.content_div.css("height",this.max_height+"px")}else{this.delayed_draw(this,k,j,e,a,d,l,m)}a+=1}},delayed_draw:function(c,e,a,f,b,d,g,h){setTimeout(function(){if(!(a>c.view.high||f<c.view.low)){tile_element=c.draw_tile(d,b,g,h);if(tile_element){if(!c.initial_canvas){c.initial_ca
nvas=$(tile_element).clone();var l=tile_element.get(0).getContext("2d");var j=c.initial_canvas.get(0).getContext("2d");var k=l.getImageData(0,0,l.canvas.width,l.canvas.height);j.putImageData(k,0,0);c.set_overview()}c.tile_cache.set(e,tile_element);c.max_height=Math.max(c.max_height,tile_element.height());c.content_div.css("height",c.max_height+"px")}}},50)},set_overview:function(){var a=this.view;if(this.initial_canvas&&this.is_overview){a.overview_close.show();a.overview_viewport.append(this.initial_canvas);a.overview_highlight.show().height(this.initial_canvas.height());a.overview_viewport.height(this.initial_canvas.height()+a.overview_box.height())}$(window).trigger("resize")}});var LabelTrack=function(a,b){this.track_type="LabelTrack";this.hidden=true;Track.call(this,null,a,b);this.container_div.addClass("label-track")};$.extend(LabelTrack.prototype,Track.prototype,{draw:function(){var c=this.view,d=c.high-c.low,g=Math.floor(Math.pow(10,Math.floor(Math.log(d)/Math.log(10
)))),a=Math.floor(c.low/g)*g,e=this.content_div.width(),b=$("<div style='position: relative; height: 1.3em;'></div>");while(a<c.high){var f=(a-c.low)/d*e;b.append($("<div class='label'>"+commatize(a)+"</div>").css({position:"absolute",left:f-1}));a+=g}this.content_div.children(":first").remove();this.content_div.append(b)}});var ReferenceTrack=function(a){this.track_type="ReferenceTrack";this.hidden=true;Track.call(this,null,a,a.top_labeltrack);TiledTrack.call(this);this.left_offset=200;this.height_px=12;this.container_div.addClass("reference-track");this.dummy_canvas=$("<canvas></canvas>").get(0).getContext("2d");this.data_queue={};this.data_cache=new Cache(CACHED_DATA);this.tile_cache=new Cache(CACHED_TILES_LINE)};$.extend(ReferenceTrack.prototype,TiledTrack.prototype,{get_data:function(d,b){var c=this,a=b*DENSITY*d,f=(b+1)*DENSITY*d,e=d+"_"+b;if(!c.data_queue[e]){c.data_queue[e]=true;$.ajax({url:reference_url,dataType:"json",data:{chrom:this.view.chrom,low:a,high:f,dbkey:
this.view.dbkey},success:function(g){c.data_cache.set(e,g);delete c.data_queue[e];c.draw()},error:function(h,g,j){console.log(h,g,j)}})}},draw_tile:function(f,b,l,p){var g=b*DENSITY*f,d=DENSITY*f,e=$("<canvas class='tile'></canvas>"),o=e.get(0).getContext("2d"),k=f+"_"+b;if(p>PX_PER_CHAR){if(this.data_cache.get(k)===undefined){this.get_data(f,b);return}var n=this.data_cache.get(k);if(n===null){this.content_div.css("height","0px");return}e.get(0).width=Math.ceil(d*p+this.left_offset);e.get(0).height=this.height_px;e.css({position:"absolute",top:0,left:(g-this.view.low)*p-this.left_offset});for(var h=0,m=n.length;h<m;h++){var a=Math.round(h*p),j=Math.round(p/2);o.fillText(n[h],a+this.left_offset+j,10)}l.append(e);return e}this.content_div.css("height","0px")}});var LineTrack=function(d,b,a,c){this.track_type="LineTrack";this.display_modes=["Histogram","Line","Filled","Intensity"];this.mode="Histogram";Track.call(this,d,b,b.viewport_container);TiledTrack.call(this);this.height_
px=80;this.dataset_id=a;this.data_cache=new Cache(CACHED_DATA);this.tile_cache=new Cache(CACHED_TILES_LINE);this.prefs={color:"black",min_value:undefined,max_value:undefined,mode:this.mode};if(c.min_value!==undefined){this.prefs.min_value=c.min_value}if(c.max_value!==undefined){this.prefs.max_value=c.max_value}};$.extend(LineTrack.prototype,TiledTrack.prototype,{init:function(){var a=this,b=a.view.tracks.indexOf(a);a.vertical_range=undefined;this.init_each({stats:true,chrom:a.view.chrom,low:null,high:null,dataset_id:a.dataset_id},function(c){a.container_div.addClass("line-track");data=c.data;if(isNaN(parseFloat(a.prefs.min_value))||isNaN(parseFloat(a.prefs.max_value))){a.prefs.min_value=data.min;a.prefs.max_value=data.max;$("#track_"+b+"_minval").val(a.prefs.min_value);$("#track_"+b+"_maxval").val(a.prefs.max_value)}a.vertical_range=a.prefs.max_value-a.prefs.min_value;a.total_frequency=data.total_frequency;a.container_div.find(".yaxislabel").remove();var e=$("<div />").addCl
ass("yaxislabel").attr("id","linetrack_"+b+"_minval").text(round_1000(a.prefs.min_value));var d=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+b+"_maxval").text(round_1000(a.prefs.max_value));d.css({position:"absolute",top:"22px",left:"10px"});d.prependTo(a.container_div);e.css({position:"absolute",top:a.height_px+11+"px",left:"10px"});e.prependTo(a.container_div)})},get_data:function(d,b){var c=this,a=b*DENSITY*d,f=(b+1)*DENSITY*d,e=d+"_"+b;if(!c.data_queue[e]){c.data_queue[e]=true;$.ajax({url:data_url,dataType:"json",data:{chrom:this.view.chrom,low:a,high:f,dataset_id:this.dataset_id,resolution:this.view.resolution},success:function(g){data=g.data;c.data_cache.set(e,data);delete c.data_queue[e];c.draw()},error:function(h,g,j){console.log(h,g,j)}})}},draw_tile:function(p,s,c,e){if(this.vertical_range===undefined){return}var t=s*DENSITY*p,a=DENSITY*p,b=$("<canvas class='tile'></canvas>"),w=p+"_"+s;if(this.data_cache.get(w)===undefined){this.get_data(p,s);return}v
ar j=this.data_cache.get(w);if(j===null){return}b.css({position:"absolute",top:0,left:(t-this.view.low)*e});b.get(0).width=Math.ceil(a*e);b.get(0).height=this.height_px;var o=b.get(0).getContext("2d"),k=false,l=this.prefs.min_value,g=this.prefs.max_value,n=this.vertical_range,u=this.total_frequency,d=this.height_px,m=this.mode;o.beginPath();o.fillStyle=this.prefs.color;if(data.length>1){var f=Math.ceil((data[1][0]-data[0][0])*e)}else{var f=10}var v,h;for(var q=0,r=data.length;q<r;q++){v=Math.round((data[q][0]-t)*e);h=data[q][1];if(h===null){if(k&&m==="Filled"){o.lineTo(v,d)}k=false;continue}if(h<l){h=l}else{if(h>g){h=g}}if(m==="Histogram"){h=Math.round(d-(h-l)/n*d);o.fillRect(v,h,f,d-h)}else{if(m==="Intensity"){h=255-Math.floor((h-l)/n*255);o.fillStyle="rgb("+h+","+h+","+h+")";o.fillRect(v,0,f,d)}else{h=Math.round(d-(h-l)/n*d);if(k){o.lineTo(v,h)}else{k=true;if(m==="Filled"){o.moveTo(v,d);o.lineTo(v,h)}else{o.moveTo(v,h)}}}}}if(m==="Filled"){if(k){o.lineTo(v,d)}o.fill()}else
{o.stroke()}c.append(b);return b},gen_options:function(n){var a=$("<div />").addClass("form-row");var e="track_"+n+"_color",b=$("<label />").attr("for",e).text("Color:"),c=$("<input />").attr("id",e).attr("name",e).val(this.prefs.color),h="track_"+n+"_minval",m=$("<label></label>").attr("for",h).text("Min value:"),d=(this.prefs.min_value===undefined?"":this.prefs.min_value),l=$("<input></input>").attr("id",h).val(d),k="track_"+n+"_maxval",g=$("<label></label>").attr("for",k).text("Max value:"),j=(this.prefs.max_value===undefined?"":this.prefs.max_value),f=$("<input></input>").attr("id",k).val(j);return a.append(m).append(l).append(g).append(f).append(b).append(c)},update_options:function(c){var a=$("#track_"+c+"_minval").val(),b=$("#track_"+c+"_maxval").val();color=$("#track_"+c+"_color").val();if(a!==this.prefs.min_value||b!==this.prefs.max_value||color!==this.prefs.color){this.prefs.min_value=parseFloat(a);this.prefs.max_value=parseFloat(b);this.prefs.color=color;this.vert
ical_range=this.prefs.max_value-this.prefs.min_value;$("#linetrack_"+c+"_minval").text(this.prefs.min_value);$("#linetrack_"+c+"_maxval").text(this.prefs.max_value);this.tile_cache.clear();this.draw()}}});var FeatureTrack=function(d,b,a,c){this.track_type="FeatureTrack";this.display_modes=["Auto","Dense","Squish","Pack"];Track.call(this,d,b,b.viewport_container);TiledTrack.call(this);this.height_px=0;this.container_div.addClass("feature-track");this.dataset_id=a;this.zo_slots={};this.show_labels_scale=0.001;this.showing_details=false;this.vertical_detail_px=10;this.vertical_nodetail_px=2;this.summary_draw_height=30;this.default_font="9px Monaco, Lucida Console, monospace";this.inc_slots={};this.data_queue={};this.s_e_by_tile={};this.tile_cache=new Cache(CACHED_TILES_FEATURE);this.data_cache=new Cache(20);this.left_offset=200;this.prefs={block_color:"black",label_color:"black",show_counts:true};if(c.block_color!==undefined){this.prefs.block_color=c.block_color}if(c.label_colo
r!==undefined){this.prefs.label_color=c.label_color}if(c.show_counts!==undefined){this.prefs.show_counts=c.show_counts}};$.extend(FeatureTrack.prototype,TiledTrack.prototype,{init:function(){var a=this,b="initial";this.init_each({low:a.view.max_low,high:a.view.max_high,dataset_id:a.dataset_id,chrom:a.view.chrom,resolution:this.view.resolution,mode:a.mode},function(c){a.mode_div.show();a.data_cache.set(b,c);a.draw()})},get_data:function(a,d){var b=this,c=a+"_"+d;if(!b.data_queue[c]){b.data_queue[c]=true;$.getJSON(data_url,{chrom:b.view.chrom,low:a,high:d,dataset_id:b.dataset_id,resolution:this.view.resolution,mode:this.mode},function(e){b.data_cache.set(c,e);delete b.data_queue[c];b.draw()})}},incremental_slots:function(a,h,c,r){if(!this.inc_slots[a]){this.inc_slots[a]={};this.inc_slots[a].w_scale=a;this.inc_slots[a].mode=r;this.s_e_by_tile[a]={}}var n=this.inc_slots[a].w_scale,z=[],l=0,b=$("<canvas></canvas>").get(0).getContext("2d"),o=this.view.max_low;var B=[];if(this.inc_
slots[a].mode!==r){delete this.inc_slots[a];this.inc_slots[a]={mode:r,w_scale:n};delete this.s_e_by_tile[a];this.s_e_by_tile[a]={}}for(var w=0,x=h.length;w<x;w++){var g=h[w],m=g[0];if(this.inc_slots[a][m]!==undefined){l=Math.max(l,this.inc_slots[a][m]);B.push(this.inc_slots[a][m])}else{z.push(w)}}for(var w=0,x=z.length;w<x;w++){var g=h[z[w]],m=g[0],s=g[1],d=g[2],q=g[3],e=Math.floor((s-o)*n),f=Math.ceil((d-o)*n);if(q!==undefined&&!c){var t=b.measureText(q).width;if(e-t<0){f+=t}else{e-=t}}var v=0;while(true){var p=true;if(this.s_e_by_tile[a][v]!==undefined){for(var u=0,A=this.s_e_by_tile[a][v].length;u<A;u++){var y=this.s_e_by_tile[a][v][u];if(f>y[0]&&e<y[1]){p=false;break}}}if(p){if(this.s_e_by_tile[a][v]===undefined){this.s_e_by_tile[a][v]=[]}this.s_e_by_tile[a][v].push([e,f]);this.inc_slots[a][m]=v;l=Math.max(l,v);break}v++}}return l},rect_or_text:function(n,o,f,m,b,d,k,e,h){n.textAlign="center";var j=Math.round(o/2);if((this.mode==="Pack"||this.mode==="Auto")&&d!==undefine
d&&o>PX_PER_CHAR){n.fillStyle=this.prefs.block_color;n.fillRect(k,h+1,e,9);n.fillStyle="#eee";for(var g=0,l=d.length;g<l;g++){if(b+g>=f&&b+g<=m){var a=Math.floor(Math.max(0,(b+g-f)*o));n.fillText(d[g],a+this.left_offset+j,h+9)}}}else{n.fillStyle=this.prefs.block_color;n.fillRect(k,h+4,e,3)}},draw_tile:function(ad,n,r,aq){var M=n*DENSITY*ad,ai=(n+1)*DENSITY*ad,L=ai-M;var ak=(!this.initial_canvas?"initial":M+"_"+ai);var H=this.data_cache.get(ak);var e;if(H===undefined||(this.mode!=="Auto"&&H.dataset_type==="summary_tree")){this.data_queue[[M,ai]]=true;this.get_data(M,ai);return}var a=Math.ceil(L*aq),R=$("<canvas class='tile'></canvas>"),af=this.prefs.label_color,h=this.prefs.block_color,q=this.mode,w=25,ab=(q==="Squish")||(q==="Dense")&&(q!=="Pack")||(q==="Auto"&&(H.extra_info==="no_detail")),V=this.left_offset,ap,C,ar;if(H.dataset_type==="summary_tree"){C=this.summary_draw_height}else{if(q==="Dense"){C=w;ar=10}else{ar=(ab?this.vertical_nodetail_px:this.vertical_detail_px);var
z=(aq<0.0001?1/view.zoom_res:aq);C=this.incremental_slots(z,H.data,ab,q)*ar+w;ap=this.inc_slots[z]}}R.css({position:"absolute",top:0,left:(M-this.view.low)*aq-V});R.get(0).width=a+V;R.get(0).height=C;r.parent().css("height",Math.max(this.height_px,C)+"px");var I=R.get(0).getContext("2d");I.fillStyle=h;I.font=this.default_font;I.textAlign="right";this.container_div.find(".yaxislabel").remove();if(H.dataset_type=="summary_tree"){var X=H.data,K=H.max,p=H.avg,b=Math.ceil(H.delta*aq);var o=$("<div />").addClass("yaxislabel").text(K);o.css({position:"absolute",top:"22px",left:"10px"});o.prependTo(this.container_div);for(var am=0,G=X.length;am<G;am++){var Z=Math.floor((X[am][0]-M)*aq);var Y=X[am][1];if(!Y){continue}var aj=Y/K*this.summary_draw_height;I.fillStyle="black";I.fillRect(Z+V,this.summary_draw_height-aj,b,aj);if(this.prefs.show_counts&&I.measureText(Y).width<b){I.fillStyle="#bbb";I.textAlign="center";I.fillText(Y,Z+V+(b/2),this.summary_draw_height-5)}}e="Summary";r.append
(R);return R}if(H.message){R.css({border:"solid red","border-width":"2px 2px 2px 0px"});I.fillStyle="red";I.textAlign="left";I.fillText(H.message,100+V,ar)}var ao=H.data;var al=0;for(var am=0,G=ao.length;am<G;am++){var S=ao[am],Q=S[0],an=S[1],aa=S[2],N=S[3];if(an<=ai&&aa>=M){var ac=Math.floor(Math.max(0,(an-M)*aq)),J=Math.ceil(Math.min(a,Math.max(0,(aa-M)*aq))),W=(q==="Dense"?1:(1+ap[Q]))*ar;if(H.dataset_type==="bai"){var u=S[4];I.fillStyle=h;if(S[5] instanceof Array){var D=Math.floor(Math.max(0,(S[5][0]-M)*aq)),P=Math.ceil(Math.min(a,Math.max(0,(S[5][1]-M)*aq))),B=Math.floor(Math.max(0,(S[6][0]-M)*aq)),v=Math.ceil(Math.min(a,Math.max(0,(S[6][1]-M)*aq)));if(S[5][1]>=M&&S[5][0]<=ai){this.rect_or_text(I,aq,M,ai,S[5][0],S[5][2],D+V,P-D,W)}if(S[6][1]>=M&&S[6][0]<=ai){this.rect_or_text(I,aq,M,ai,S[6][0],S[6][2],B+V,v-B,W)}if(B>P){I.fillStyle="#999";I.fillRect(P+V,W+5,B-P,1)}}else{I.fillStyle=h;this.rect_or_text(I,aq,M,ai,an,N,ac+V,J-ac,W)}if(q!=="Dense"&&!ab&&an>M){I.fillStyle=th
is.prefs.label_color;if(n===0&&ac-I.measureText(N).width<0){I.textAlign="left";I.fillText(Q,J+2+V,W+8)}else{I.textAlign="right";I.fillText(Q,ac-2+V,W+8)}I.fillStyle=h}}else{if(H.dataset_type==="interval_index"){if(ab){I.fillStyle=h;I.fillRect(ac+V,W+5,J-ac,1)}else{var F=S[4],U=S[5],ae=S[6],g=S[7];var E,ag,O=null,at=null;if(U&&ae){O=Math.floor(Math.max(0,(U-M)*aq));at=Math.ceil(Math.min(a,Math.max(0,(ae-M)*aq)))}if(q!=="Dense"&&N!==undefined&&an>M){I.fillStyle=af;if(n===0&&ac-I.measureText(N).width<0){I.textAlign="left";I.fillText(N,J+2+V,W+8)}else{I.textAlign="right";I.fillText(N,ac-2+V,W+8)}I.fillStyle=h}if(g){if(F){if(F=="+"){I.fillStyle=RIGHT_STRAND}else{if(F=="-"){I.fillStyle=LEFT_STRAND}}I.fillRect(ac+V,W,J-ac,10);I.fillStyle=h}for(var ak=0,f=g.length;ak<f;ak++){var t=g[ak],d=Math.floor(Math.max(0,(t[0]-M)*aq)),T=Math.ceil(Math.min(a,Math.max((t[1]-M)*aq)));if(d>T){continue}E=5;ag=3;I.fillRect(d+V,W+ag,T-d,E);if(O!==undefined&&!(d>at||T<O)){E=9;ag=1;var ah=Math.max(d,O)
,A=Math.min(T,at);I.fillRect(ah+V,W+ag,A-ah,E)}}}else{E=9;ag=1;I.fillRect(ac+V,W+ag,J-ac,E);if(S.strand){if(S.strand=="+"){I.fillStyle=RIGHT_STRAND_INV}else{if(S.strand=="-"){I.fillStyle=LEFT_STRAND_INV}}I.fillRect(ac+V,W,J-ac,10);I.fillStyle=h}}}}else{if(H.dataset_type==="vcf"){if(ab){I.fillStyle=h;I.fillRect(ac+V,W+5,J-ac,1)}else{var s=S[4],m=S[5],c=S[6];E=9;ag=1;I.fillRect(ac+V,W,J-ac,E);if(q!=="Dense"&&N!==undefined&&an>M){I.fillStyle=af;if(n===0&&ac-I.measureText(N).width<0){I.textAlign="left";I.fillText(N,J+2+V,W+8)}else{I.textAlign="right";I.fillText(N,ac-2+V,W+8)}I.fillStyle=h}var l=s+" / "+m;if(an>M&&I.measureText(l).width<(J-ac)){I.fillStyle="white";I.textAlign="center";I.fillText(l,V+ac+(J-ac)/2,W+8);I.fillStyle=h}}}}}al++}}r.append(R);return R},gen_options:function(j){var a=$("<div />").addClass("form-row");var e="track_"+j+"_block_color",l=$("<label />").attr("for",e).text("Block color:"),m=$("<input />").attr("id",e).attr("name",e).val(this.prefs.block_color),k
="track_"+j+"_label_color",g=$("<label />").attr("for",k).text("Text color:"),h=$("<input />").attr("id",k).attr("name",k).val(this.prefs.label_color),f="track_"+j+"_show_count",c=$("<label />").attr("for",f).text("Show summary counts"),b=$('<input type="checkbox" style="float:left;"></input>').attr("id",f).attr("name",f).attr("checked",this.prefs.show_counts),d=$("<div />").append(b).append(c);return a.append(l).append(m).append(g).append(h).append(d)},update_options:function(e){var b=$("#track_"+e+"_block_color").val(),d=$("#track_"+e+"_label_color").val(),c=$("#track_"+e+"_mode option:selected").val(),a=$("#track_"+e+"_show_count").attr("checked");if(b!==this.prefs.block_color||d!==this.prefs.label_color||a!==this.prefs.show_counts){this.prefs.block_color=b;this.prefs.label_color=d;this.prefs.show_counts=a;this.tile_cache.clear();this.draw()}}});var ReadTrack=function(d,b,a,c){FeatureTrack.call(this,d,b,a,c);this.track_type="ReadTrack";this.vertical_detail_px=10;this.vert
ical_nodetail_px=5};$.extend(ReadTrack.prototype,TiledTrack.prototype,FeatureTrack.prototype,{});
1
0
galaxy-dist commit 7c80b7c2aa6a: Add descriptive labels to output dataset names for MACS peakcalling tool.
by commits-noreply@bitbucket.org 20 Nov '10
by commits-noreply@bitbucket.org 20 Nov '10
20 Nov '10
# HG changeset patch -- Bitbucket.org
# Project galaxy-dist
# URL http://bitbucket.org/galaxy/galaxy-dist/overview
# User Dan Blankenberg <dan(a)bx.psu.edu>
# Date 1287508435 14400
# Node ID 7c80b7c2aa6aef5fba1b3a08e6426f5c84a125b4
# Parent 9c80bcb0bfa49d553428aca22043a8a68f773c65
Add descriptive labels to output dataset names for MACS peakcalling tool.
--- a/tools/peak_calling/macs_wrapper.xml
+++ b/tools/peak_calling/macs_wrapper.xml
@@ -74,22 +74,22 @@
<param name="futurefdr" label="Perform the new peak detection method (futurefdr)" type="boolean" truevalue="--futurefdr" falsevalue="" checked="False" help="The default method only consider the peak location, 1k, 5k, and 10k regions in the control data; whereas the new future method also consider the 5k, 10k regions in treatment data to calculate local bias."/></inputs><outputs>
- <data name="output_bed_file" format="bed"/>
- <data name="output_xls_to_interval_peaks_file" format="interval">
+ <data name="output_bed_file" format="bed" label="${tool.name} on ${on_string} (peaks: bed)"/>
+ <data name="output_xls_to_interval_peaks_file" format="interval" label="${tool.name} on ${on_string} (peaks: interval)"><filter>xls_to_interval is True</filter></data>
- <data name="output_xls_to_interval_negative_peaks_file" format="interval">
+ <data name="output_xls_to_interval_negative_peaks_file" format="interval" label="${tool.name} on ${on_string} (negative peaks: interval)"><filter>xls_to_interval is True</filter><filter>input_type['input_control_file1'] is not None</filter></data>
- <data name="output_treatment_wig_file" format="wig">
+ <data name="output_treatment_wig_file" format="wig" label="${tool.name} on ${on_string} (treatment: wig)"><filter>wig_type['wig_type_selector']=='wig'</filter></data>
- <data name="output_control_wig_file" format="wig">
+ <data name="output_control_wig_file" format="wig" label="${tool.name} on ${on_string} (control: wig)"><filter>wig_type['wig_type_selector'] == 'wig'</filter><filter>input_type['input_control_file1'] is not None</filter></data>
- <data name="output_extra_files" format="html"/>
+ <data name="output_extra_files" format="html" label="${tool.name} on ${on_string} (html report)"/></outputs><configfiles><configfile name="options_file"><%
1
0
galaxy-dist commit 9c80bcb0bfa4: Fix for viewing a form definition.
by commits-noreply@bitbucket.org 20 Nov '10
by commits-noreply@bitbucket.org 20 Nov '10
20 Nov '10
# HG changeset patch -- Bitbucket.org
# Project galaxy-dist
# URL http://bitbucket.org/galaxy/galaxy-dist/overview
# User rc
# Date 1287424478 14400
# Node ID 9c80bcb0bfa49d553428aca22043a8a68f773c65
# Parent 98739e24554c777400732e8a2d8f6c18b2b8768a
Fix for viewing a form definition.
--- a/lib/galaxy/web/controllers/forms.py
+++ b/lib/galaxy/web/controllers/forms.py
@@ -104,7 +104,7 @@ class Forms( BaseController ):
message='Invalid form',
status='error' ) )
return trans.fill_template( '/admin/forms/show_form_read_only.mako',
- form=fdc.latest_form )
+ form_definition=fdc.latest_form )
def __form_types_widget(self, trans, selected='none'):
form_type_selectbox = SelectField( 'form_type_selectbox' )
if selected == 'none':
1
0
galaxy-dist commit d8da4f7bb0f5: Add -ungapped for blastn and blastx (having trouble with blastp and tblastn, not in tblastx)
by commits-noreply@bitbucket.org 20 Nov '10
by commits-noreply@bitbucket.org 20 Nov '10
20 Nov '10
# HG changeset patch -- Bitbucket.org
# Project galaxy-dist
# URL http://bitbucket.org/galaxy/galaxy-dist/overview
# User peterjc <p.j.a.cock(a)googlemail.com>
# Date 1286554738 -3600
# Node ID d8da4f7bb0f5e1d43b371e4e52fb688ad816e5bf
# Parent 8979b429d7691f4121afb368a05e6b9d0ea40706
Add -ungapped for blastn and blastx (having trouble with blastp and tblastn, not in tblastx)
--- a/tools/ncbi_blast_plus/ncbi_blastn_wrapper.xml
+++ b/tools/ncbi_blast_plus/ncbi_blastn_wrapper.xml
@@ -25,6 +25,7 @@ blastn
#if (str($adv_opts.word_size) and int(str($adv_opts.word_size)) > 0):
-word_size $adv_opts.word_size
#end if
+$adv_opts.ungapped
</command><inputs><param name="query" type="data" format="fasta" label="Nucleotide query sequence(s)"/>
@@ -76,6 +77,7 @@ blastn
<param name="strand" type="hidden" value="" /><param name="max_hits" type="hidden" value="" /><param name="word_size" type="hidden" value="" />
+ <param name="ungapped" type="hidden" value="" /></when><when value="advanced"><!-- Could use a select (yes, no, other) where other allows setting 'level window linker' -->
@@ -93,6 +95,7 @@ blastn
<param name="word_size" type="integer" value="0" label="Word size for wordfinder algorithm" help="Use zero for default, otherwise minimum 4."><validator type="in_range" min="0" /></param>
+ <param name="ungapped" type="boolean" label="Perform ungapped alignment only?" truevalue="-ungapped" falsevalue="" checked="false" /></when></conditional></inputs>
--- a/tools/ncbi_blast_plus/ncbi_blastp_wrapper.xml
+++ b/tools/ncbi_blast_plus/ncbi_blastp_wrapper.xml
@@ -25,6 +25,8 @@ blastp
#if (str($adv_opts.word_size) and int(str($adv_opts.word_size)) > 0):
-word_size $adv_opts.word_size
#end if
+##Ungapped disabled for now - see comments below
+##$adv_opts.ungapped
</command><inputs><param name="query" type="data" format="fasta" label="Protein query sequence(s)"/>
@@ -70,6 +72,10 @@ blastp
<param name="matrix" type="hidden" value="" /><param name="max_hits" type="hidden" value="" /><param name="word_size" type="hidden" value="" />
+ <!--
+ Ungapped disabled for now, see comments below
+ <param name="ungapped" type="hidden" value="" />
+ --></when><when value="advanced"><!-- Could use a select (yes, no, other) where other allows setting 'window locut hicut' -->
@@ -92,6 +98,12 @@ blastp
<param name="word_size" type="integer" value="0" label="Word size for wordfinder algorithm" help="Use zero for default, otherwise minimum 2."><validator type="in_range" min="0" /></param>
+ <!--
+ Can't use '-ungapped' on its own, error back is:
+ Composition-adjusted searched are not supported with an ungapped search, please add -comp_based_stats F or do a gapped search
+ Tried using '-ungapped -comp_based_stats F' and blastp crashed with 'Attempt to access NULL pointer.'
+ <param name="ungapped" type="boolean" label="Perform ungapped alignment only?" truevalue="-ungapped -comp_based_stats F" falsevalue="" checked="false" />
+ --></when></conditional></inputs>
--- a/tools/ncbi_blast_plus/ncbi_blastx_wrapper.xml
+++ b/tools/ncbi_blast_plus/ncbi_blastx_wrapper.xml
@@ -25,6 +25,7 @@ blastx
#if (str($adv_opts.word_size) and int(str($adv_opts.word_size)) > 0):
-word_size $adv_opts.word_size
#end if
+$adv_opts.ungapped
</command><inputs><param name="query" type="data" format="fasta" label="Nucleotide query sequence(s)"/>
@@ -67,6 +68,7 @@ blastx
<param name="matrix" type="hidden" value="" /><param name="max_hits" type="hidden" value="" /><param name="word_size" type="hidden" value="" />
+ <param name="ungapped" type="hidden" value="" /></when><when value="advanced"><!-- Could use a select (yes, no, other) where other allows setting 'window locut hicut' -->
@@ -94,6 +96,7 @@ blastx
<param name="word_size" type="integer" value="0" label="Word size for wordfinder algorithm" help="Use zero for default, otherwise minimum 2."><validator type="in_range" min="0" /></param>
+ <param name="ungapped" type="boolean" label="Perform ungapped alignment only?" truevalue="-ungapped" falsevalue="" checked="false" /></when></conditional></inputs>
--- a/tools/ncbi_blast_plus/ncbi_tblastn_wrapper.xml
+++ b/tools/ncbi_blast_plus/ncbi_tblastn_wrapper.xml
@@ -24,6 +24,8 @@ tblastn
#if (str($adv_opts.word_size) and int(str($adv_opts.word_size)) > 0):
-word_size $adv_opts.word_size
#end if
+##Ungapped disabled for now - see comments below
+##$adv_opts.ungapped
</command><inputs><param name="query" type="data" format="fasta" label="Protein query sequence(s)"/>
@@ -65,6 +67,10 @@ tblastn
<param name="matrix" type="hidden" value="" /><param name="max_hits" type="hidden" value="" /><param name="word_size" type="hidden" value="" />
+ <!--
+ Ungapped disabled for now, see comments below
+ <param name="ungapped" type="hidden" value="" />
+ --></when><when value="advanced"><!-- Could use a select (yes, no, other) where other allows setting 'window locut hicut' -->
@@ -87,6 +93,12 @@ tblastn
<param name="word_size" type="integer" value="0" label="Word size for wordfinder algorithm" help="Use zero for default, otherwise minimum 2."><validator type="in_range" min="0" /></param>
+ <!--
+ Can't use '-ungapped' on its own, error back is:
+ Composition-adjusted searched are not supported with an ungapped search, please add -comp_based_stats F or do a gapped search
+ Tried using '-ungapped -comp_based_stats F' and tblastn crashed with 'Attempt to access NULL pointer.'
+ <param name="ungapped" type="boolean" label="Perform ungapped alignment only?" truevalue="-ungapped -comp_based_stats F" falsevalue="" checked="false" />
+ --></when></conditional></inputs>
1
0