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
March 2011
- 1 participants
- 141 discussions
2 new changesets in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/c25c8055e608/
changeset: r5274:c25c8055e608
user: fubar
date: 2011-03-25 18:12:21
summary: Revised rgenetics tools to remove post job hooks
affected #: 35 files (21.8 KB)
--- a/test-data/rgCaCotest1_CaCo_topTable.gff Thu Mar 24 20:29:40 2011 -0400
+++ b/test-data/rgCaCotest1_CaCo_topTable.gff Fri Mar 25 13:12:21 2011 -0400
@@ -1,26 +1,26 @@
-track name=rgGLM_TopTable description="rgCaCotest1" visibility=2 useScore=1 color=0,60,120
-chr22 rgGLM variation 21784622 21784822 0 . . rs2283802 logp=-0.00
-chr22 rgGLM variation 21785266 21785466 42 . . rs2267000 logp=0.05
-chr22 rgGLM variation 21794654 21794854 249 . . rs16997606 logp=0.29
-chr22 rgGLM variation 21794710 21794910 493 . . rs4820537 logp=0.58
-chr22 rgGLM variation 21797704 21797904 237 . . rs3788347 logp=0.28
-chr22 rgGLM variation 21799818 21800018 61 . . rs756632 logp=0.07
-chr22 rgGLM variation 21807870 21808070 153 . . rs4820539 logp=0.18
-chr22 rgGLM variation 21820235 21820435 44 . . rs2283804 logp=0.05
-chr22 rgGLM variation 21820890 21821090 44 . . rs2267006 logp=0.05
-chr22 rgGLM variation 21820900 21821100 184 . . rs4822363 logp=0.22
-chr22 rgGLM variation 21827574 21827774 317 . . rs5751592 logp=0.37
-chr22 rgGLM variation 21832608 21832808 0 . . rs5759608 logp=-0.00
-chr22 rgGLM variation 21833070 21833270 0 . . rs5759612 logp=-0.00
-chr22 rgGLM variation 21860068 21860268 0 . . rs2267009 logp=-0.00
-chr22 rgGLM variation 21864266 21864466 117 . . rs2267010 logp=0.14
-chr22 rgGLM variation 21868598 21868798 571 . . rs5759636 logp=0.67
-chr22 rgGLM variation 21871388 21871588 0 . . rs2071436 logp=-0.00
-chr22 rgGLM variation 21875779 21875979 249 . . rs2267013 logp=0.29
-chr22 rgGLM variation 21889706 21889906 378 . . rs6003566 logp=0.44
-chr22 rgGLM variation 21892791 21892991 249 . . rs2256725 logp=0.29
-chr22 rgGLM variation 21892825 21893025 193 . . rs12160770 logp=0.23
-chr22 rgGLM variation 21895919 21896119 42 . . rs5751611 logp=0.05
-chr22 rgGLM variation 21898758 21898958 40 . . rs762601 logp=0.05
-chr22 rgGLM variation 21898963 21899163 40 . . rs2156921 logp=0.05
-chr22 rgGLM variation 21905542 21905742 40 . . rs4822375 logp=0.05
+track name=rgCaCo_TopTable description="rgCaCotest1" visibility=2 useScore=1 color=0,60,120
+chr22 rgCaCo variation 21784622 21784822 0 . . rs2283802 logp=-0.00
+chr22 rgCaCo variation 21785266 21785466 42 . . rs2267000 logp=0.05
+chr22 rgCaCo variation 21794654 21794854 249 . . rs16997606 logp=0.29
+chr22 rgCaCo variation 21794710 21794910 493 . . rs4820537 logp=0.58
+chr22 rgCaCo variation 21797704 21797904 237 . . rs3788347 logp=0.28
+chr22 rgCaCo variation 21799818 21800018 61 . . rs756632 logp=0.07
+chr22 rgCaCo variation 21807870 21808070 153 . . rs4820539 logp=0.18
+chr22 rgCaCo variation 21820235 21820435 44 . . rs2283804 logp=0.05
+chr22 rgCaCo variation 21820890 21821090 44 . . rs2267006 logp=0.05
+chr22 rgCaCo variation 21820900 21821100 184 . . rs4822363 logp=0.22
+chr22 rgCaCo variation 21827574 21827774 317 . . rs5751592 logp=0.37
+chr22 rgCaCo variation 21832608 21832808 0 . . rs5759608 logp=-0.00
+chr22 rgCaCo variation 21833070 21833270 0 . . rs5759612 logp=-0.00
+chr22 rgCaCo variation 21860068 21860268 0 . . rs2267009 logp=-0.00
+chr22 rgCaCo variation 21864266 21864466 117 . . rs2267010 logp=0.14
+chr22 rgCaCo variation 21868598 21868798 571 . . rs5759636 logp=0.67
+chr22 rgCaCo variation 21871388 21871588 0 . . rs2071436 logp=-0.00
+chr22 rgCaCo variation 21875779 21875979 249 . . rs2267013 logp=0.29
+chr22 rgCaCo variation 21889706 21889906 378 . . rs6003566 logp=0.44
+chr22 rgCaCo variation 21892791 21892991 249 . . rs2256725 logp=0.29
+chr22 rgCaCo variation 21892825 21893025 193 . . rs12160770 logp=0.23
+chr22 rgCaCo variation 21895919 21896119 42 . . rs5751611 logp=0.05
+chr22 rgCaCo variation 21898758 21898958 40 . . rs762601 logp=0.05
+chr22 rgCaCo variation 21898963 21899163 40 . . rs2156921 logp=0.05
+chr22 rgCaCo variation 21905542 21905742 40 . . rs4822375 logp=0.05
--- a/test-data/rgTDTtest1_TDT_topTable.gff Thu Mar 24 20:29:40 2011 -0400
+++ b/test-data/rgTDTtest1_TDT_topTable.gff Fri Mar 25 13:12:21 2011 -0400
@@ -1,25 +1,25 @@
track name=rgTDT_Top_Table description="rgTDTtest1" visibility=2 useScore=1 color=0,60,120
-chr22 rgGLM variation 21784622 21784822 0 . . rs2283802 logp=-0.00
-chr22 rgGLM variation 21785266 21785466 120 . . rs2267000 logp=0.13
-chr22 rgGLM variation 21794654 21794854 0 . . rs16997606 logp=-0.00
-chr22 rgGLM variation 21794710 21794910 457 . . rs4820537 logp=0.50
-chr22 rgGLM variation 21797704 21797904 120 . . rs3788347 logp=0.13
-chr22 rgGLM variation 21799818 21800018 228 . . rs756632 logp=0.25
-chr22 rgGLM variation 21807870 21808070 120 . . rs4820539 logp=0.13
-chr22 rgGLM variation 21820235 21820435 292 . . rs2283804 logp=0.32
-chr22 rgGLM variation 21820890 21821090 292 . . rs2267006 logp=0.32
-chr22 rgGLM variation 21820900 21821100 0 . . rs4822363 logp=-0.00
-chr22 rgGLM variation 21827574 21827774 541 . . rs5751592 logp=0.59
-chr22 rgGLM variation 21832608 21832808 400 . . rs5759608 logp=0.44
-chr22 rgGLM variation 21833070 21833270 400 . . rs5759612 logp=0.44
-chr22 rgGLM variation 21860068 21860268 0 . . rs2267009 logp=-0.00
-chr22 rgGLM variation 21864266 21864466 0 . . rs2267010 logp=-0.00
-chr22 rgGLM variation 21868598 21868798 457 . . rs5759636 logp=0.50
-chr22 rgGLM variation 21871388 21871588 0 . . rs2071436 logp=-0.00
-chr22 rgGLM variation 21875779 21875979 457 . . rs2267013 logp=0.50
-chr22 rgGLM variation 21889706 21889906 168 . . rs6003566 logp=0.18
-chr22 rgGLM variation 21892791 21892991 457 . . rs2256725 logp=0.50
-chr22 rgGLM variation 21895919 21896119 359 . . rs5751611 logp=0.39
-chr22 rgGLM variation 21898758 21898958 400 . . rs762601 logp=0.44
-chr22 rgGLM variation 21898963 21899163 400 . . rs2156921 logp=0.44
-chr22 rgGLM variation 21905542 21905742 400 . . rs4822375 logp=0.44
+chr22 rgTDT variation 21784622 21784822 0 . . rs2283802 logp=-0.00
+chr22 rgTDT variation 21785266 21785466 120 . . rs2267000 logp=0.13
+chr22 rgTDT variation 21794654 21794854 0 . . rs16997606 logp=-0.00
+chr22 rgTDT variation 21794710 21794910 457 . . rs4820537 logp=0.50
+chr22 rgTDT variation 21797704 21797904 120 . . rs3788347 logp=0.13
+chr22 rgTDT variation 21799818 21800018 228 . . rs756632 logp=0.25
+chr22 rgTDT variation 21807870 21808070 120 . . rs4820539 logp=0.13
+chr22 rgTDT variation 21820235 21820435 292 . . rs2283804 logp=0.32
+chr22 rgTDT variation 21820890 21821090 292 . . rs2267006 logp=0.32
+chr22 rgTDT variation 21820900 21821100 0 . . rs4822363 logp=-0.00
+chr22 rgTDT variation 21827574 21827774 541 . . rs5751592 logp=0.59
+chr22 rgTDT variation 21832608 21832808 400 . . rs5759608 logp=0.44
+chr22 rgTDT variation 21833070 21833270 400 . . rs5759612 logp=0.44
+chr22 rgTDT variation 21860068 21860268 0 . . rs2267009 logp=-0.00
+chr22 rgTDT variation 21864266 21864466 0 . . rs2267010 logp=-0.00
+chr22 rgTDT variation 21868598 21868798 457 . . rs5759636 logp=0.50
+chr22 rgTDT variation 21871388 21871588 0 . . rs2071436 logp=-0.00
+chr22 rgTDT variation 21875779 21875979 457 . . rs2267013 logp=0.50
+chr22 rgTDT variation 21889706 21889906 168 . . rs6003566 logp=0.18
+chr22 rgTDT variation 21892791 21892991 457 . . rs2256725 logp=0.50
+chr22 rgTDT variation 21895919 21896119 359 . . rs5751611 logp=0.39
+chr22 rgTDT variation 21898758 21898958 400 . . rs762601 logp=0.44
+chr22 rgTDT variation 21898963 21899163 400 . . rs2156921 logp=0.44
+chr22 rgTDT variation 21905542 21905742 400 . . rs4822375 logp=0.44
--- a/tools/rgenetics/rgCaCo.py Thu Mar 24 20:29:40 2011 -0400
+++ b/tools/rgenetics/rgCaCo.py Fri Mar 25 13:12:21 2011 -0400
@@ -20,7 +20,6 @@
import sys,math,shutil,subprocess,os,time,tempfile,string
from os.path import abspath
from rgutils import timenow, plinke
-
imagedir = '/static/rg' # if needed for images
myversion = 'V000.1 April 2007'
verbose = False
@@ -82,7 +81,7 @@
outres = [] # need to resort into chrom offset order
for i,lrow in enumerate(resfl):
chrom,snp,offset,p, = [lrow[x] for x in wewant]
- gff = ('chr%s' % chrom,'rgGLM','variation','%d' % (int(offset)-halfwidth),
+ gff = ('chr%s' % chrom,'rgCaCo','variation','%d' % (int(offset)-halfwidth),
'%d' % (int(offset)+halfwidth),p,'.','.','%s logp=%1.2f' % (snp,pvals[i]))
outres.append(gff)
outres = [(x[0],int(x[3]),x) for x in outres] # decorate
@@ -94,7 +93,6 @@
outf.close()
-
def plink_assocToGG(plinkout="hm",tag='test'):
""" plink --assoc output looks like this
# CHR SNP A1 F_A F_U A2 CHISQ P OR
@@ -170,14 +168,8 @@
else:
headl = headl.split()
delim = None
- chrpos = headl.index('CHR')
- rspos = headl.index('SNP')
- testpos = headl.index('TEST')
- naffpos = headl.index('AFF')
- nuaffpos = headl.index('UNAFF')
- chisqpos = headl.index('CHISQ')
- ppos = headl.index('P')
- wewant = [chrpos,rspos,testpos,naffpos,nuaffpos,chisqpos,ppos]
+ whatwewant = ['CHR','SNP','TEST','AFF','UNAFF','CHISQ','P']
+ wewant = [headl.index(x) for x in whatwewant]
llen = len(headl)
lnum = anum = 0
lastsnp = None # so we know when to write out a gg line
@@ -273,7 +265,7 @@
retval = p.wait()
resf = '%s.model' % tname # plink output is here we hope
xformModel(bfname,resf,outfname,name,amapf,flog) # leaves the desired summary file
- makeGFF(resf=outfname,outfname=gffout,logf=flog,twd=twd,name='rgGLM_TopTable',description=name,topn=topn)
+ makeGFF(resf=outfname,outfname=gffout,logf=flog,twd=twd,name='rgCaCo_TopTable',description=name,topn=topn)
flog.write('\n'.join(logme))
flog.close() # close the log used
#shutil.copytree(twd,logoutdir)
--- a/tools/rgenetics/rgCaCo.xml Thu Mar 24 20:29:40 2011 -0400
+++ b/tools/rgenetics/rgCaCo.xml Fri Mar 25 13:12:21 2011 -0400
@@ -1,25 +1,19 @@
<tool id="rgCaCo1" name="Case Control:">
- <code file="listFiles.py"/>
- <code file="rgCaCo_code.py"/>
-
<description>for unrelated subjects</description>
-
<command interpreter="python">
- rgCaCo.py '$i.extra_files_path/$i.metadata.base_name' "$name"
- '$out_file1' '$logf' '$logf.files_path' '$gffout'
+ rgCaCo.py '$i.extra_files_path/$i.metadata.base_name' "$title" '$out_file1' '$logf' '$logf.files_path' '$gffout'
</command>
-
<inputs><param name="i" type="data" label="RGenetics genotype data from your current history"
format="pbed" />
- <param name='name' type='text' size="132" value='CaseControl' label="Title for this job"/>
+ <param name='title' type='text' size="132" value='CaseControl' label="Title for this job"/></inputs><outputs>
- <data format="tabular" name="out_file1" />
- <data format="txt" name="logf" />
- <data format="gff" name="gffout" />
+ <data format="tabular" name="out_file1" label="${title}_rgCaCo.xls" />
+ <data format="txt" name="logf" label="${title}_rgCaCo.log"/>
+ <data format="gff" name="gffout" label="${title}_rgCaCoTop.gff" /></outputs><tests><test>
@@ -30,7 +24,7 @@
<composite_data value='tinywga.fam' /><edit_attributes type='name' value='tinywga' /></param>
- <param name='name' value='rgCaCotest1' />
+ <param name='title' value='rgCaCotest1' /><output name='out_file1' file='rgCaCotest1_CaCo.xls' ftype='tabular' compare='diff' /><output name='logf' file='rgCaCotest1_CaCo_log.txt' ftype='txt' compare='diff' lines_diff='20' /><output name='gffout' file='rgCaCotest1_CaCo_topTable.gff' ftype='gff' compare='diff' />
@@ -79,24 +73,31 @@
spreadsheet data, choose the .xls tab delimited format. It's not a stupid binary excel file. Just a plain old tab delimited
one with a header. Fortunately excel is dumb enough to open these without much protest.
+
-----
+.. class:: infomark
+
**Attribution**
-When you click 'execute', this Galaxy tool will run Plink (from Shaun Purcell) for you (which is GPL, so this must be too I guess) for calculations. For full Plink
-attribution, source code and documentation, please see http://pngu.mgh.harvard.edu/~purcell/plink/
+This Galaxy tool relies on Plink (see Plinksrc_) to test Casae Control association models.
-The Plink output files will be adjusted into UCSC compatible tracks - gg or wig, or else as tab delimited
-for you spreadsheet junkies out there. Python is used for all glue and data format yoga.
-Originally designed and written for the Rgenetics Galaxy tools by
-ross lazarus (ross spot lazarus ate gmail spot com), who didn't write
-either Galaxy or Plink but wishes he had.
+So, we rely on the author (Shaun Purcell) for the documentation you need specific to those settings - they are very nicely documented - see
+DOC_
-copyright Ross Lazarus 2007
-Licensed under the terms of the LGPL as documented http://www.gnu.org/licenses/lgpl.html
-but is about as useful as a chocolate teapot without Plink which is GPL.
+Tool and Galaxy datatypes originally designed and written for the Rgenetics
+series of whole genome scale statistical genetics tools by ross lazarus (ross.lazarus(a)gmail.com)
+
+Copyright Ross Lazarus March 2007
+This Galaxy wrapper is released licensed under the LGPL_ but is about as useful as a chocolate teapot without Plink which is GPL.
I'm no lawyer, but it looks like you got GPL if you use this software. Good luck.
+.. _Plinksrc: http://pngu.mgh.harvard.edu/~purcell/plink/
+
+.. _LGPL: http://www.gnu.org/copyleft/lesser.html
+
+.. _DOC: http://pngu.mgh.harvard.edu/~purcell/plink/anal.shtml#cc
+
</help></tool>
--- a/tools/rgenetics/rgCaCo_code.py Thu Mar 24 20:29:40 2011 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-# for caco
-# called as plinkCaCo.py $i $name $test $outformat $out_file1 $logf $map
-from galaxy import datatypes
-import time,string,sys
-
-def timenow():
- """return current time as a string
- """
- return time.strftime('%d/%m/%Y %H:%M:%S', time.localtime(time.time()))
-
-def exec_after_process(app, inp_data, out_data, param_dict, tool, stdout, stderr):
- """Sets the name of the data"""
- job_name = param_dict.get( 'name', 'RgCaCo' ).encode()
- killme = string.punctuation + string.whitespace
- trantab = string.maketrans(killme,'_'*len(killme))
- title = job_name.translate(trantab)
- indatname = inp_data['i'].name
- outxls = ['tabular','%s_CaCo.xls' % job_name]
- logtxt = ['txt','%s_CaCo_log.txt' % job_name]
- ggout = ['gff','%s_CaCo_topTable.gff' % job_name]
- lookup={}
- lookup['out_file1'] = outxls
- lookup['logf'] = logtxt
- lookup['gffout'] = ggout
- info = '%s rgCaCo from %s at %s' % (job_name,indatname,timenow())
- for name in lookup.keys():
- data = out_data[name]
- data_type,newname = lookup[name]
- data.name = newname
- data.info = info
- out_data[name] = data
- app.model.context.flush()
-
-
-def get_test_opts():
- """return test options"""
- dat = [('Armitage test for trend chisq. Does NOT assume HWE!','TREND',True),
- ('Allelic (A vs a) chisq. assumes HWE','ALLELIC',False),
- ('Genotype (AA vs Aa vs aa)chisq. assumes HWE','GENO',False),
- ('Dominant model (AA/Aa vs aa) chisq. assumesWE','DOM',False),
- ('Recessive (AA vs Aa/aa) chisq. assumes HWE','REC',False)]
- dat.reverse()
- return dat
-
-
--- a/tools/rgenetics/rgClean.xml Thu Mar 24 20:29:40 2011 -0400
+++ b/tools/rgenetics/rgClean.xml Fri Mar 25 13:12:21 2011 -0400
@@ -1,6 +1,4 @@
<tool id="rgClean1" name="Clean genotypes:">
- <code file="rgClean_code.py"/>
-
<description>filter markers, subjects</description><command interpreter="python">
@@ -47,7 +45,7 @@
</inputs><outputs>
- <data format="pbed" name="out_file1" metadata_source="input_file" />
+ <data format="pbed" name="out_file1" metadata_source="input_file" label="${title}_rgClean.pbed" /></outputs><tests>
--- a/tools/rgenetics/rgClean_code.py Thu Mar 24 20:29:40 2011 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-from galaxy import app
-import os, string, time
-
-def timenow():
- """return current time as a string
- """
- return time.strftime('%d/%m/%Y %H:%M:%S', time.localtime(time.time()))
-
-
-
-def exec_after_process(app, inp_data, out_data, param_dict, tool, stdout, stderr):
- name,data = out_data.items()[0]
- basename = param_dict['title']
- basename = basename.encode()
- killme = string.punctuation + string.whitespace
- trantab = string.maketrans(killme,'_'*len(killme))
- title = basename.translate(trantab)
- info = '%s filtered by rgClean.py at %s' % (title,timenow())
- data.change_datatype('pbed')
- #data.file_name = data.file_name
- data.metadata.base_name = title
- data.name = '%s.pbed' % title
- data.info = info
- data.readonly = True
- app.model.context.flush()
-
-
-
--- a/tools/rgenetics/rgEigPCA.xml Thu Mar 24 20:29:40 2011 -0400
+++ b/tools/rgenetics/rgEigPCA.xml Fri Mar 25 13:12:21 2011 -0400
@@ -1,5 +1,4 @@
<tool id="rgEigPCA1" name="Eigensoft:">
- <code file="rgEigPCA_code.py"/><description>PCA Ancestry using SNP</description><command interpreter="python">
@@ -27,12 +26,10 @@
</inputs><outputs>
- <data name="out_file1" format="html" />
- <data name="pca" format="txt" />
+ <data name="out_file1" format="html" label="${title}_rgEig.html"/>
+ <data name="pca" format="txt" label="${title}_rgEig.txt"/></outputs>
-<!-- python $TOOLPATH/$TOOL.py "$INPATH/tinywga" "$NPRE" ${OUTPATH}/${NPRE}.html $OUTPATH 4 2 2 2 $OUTPATH/pca.out $BINPATH -->
-
<tests><test><param name='i' value='tinywga' ftype='ldindep' >
@@ -59,17 +56,45 @@
**Syntax**
-- **Genotype data** is the input genotype file chosen from available library files.
-- **Title** is used to name the output files
-- **Tuning parameters** documented in the Eigensoft documentation - see below
+- **Genotype data** is an input genotype dataset in Plink lped (http://pngu.mgh.harvard.edu/~purcell/plink/data.shtml) format. See below for notes
+- **Title** is used to name the output files so you can remember what the outputs are for
+- **Tuning parameters** are documented in the Eigensoft (http://genepath.med.harvard.edu/~reich/Software.htm) documentation - see below
-(Note that you may need to convert an existing genotype file into that format to use this tool)
-----
**Summary**
+Eigensoft requires ld-reduced genotype data.
+Galaxy has an automatic converter for genotype data in Plink linkage pedigree (lped) format.
+For details of this generic genotype format, please see the Plink documentation at
+http://pngu.mgh.harvard.edu/~purcell/plink/data.shtml
+
+Reading that documentation, you'll see that the linkage pedigree format is really two related files with the same
+file base name - a map and ped file - eg 'mygeno.ped' and 'mygeno.map'.
+The map file has the chromosome, offset, genetic offset and snp name corresponding to each
+genotype stored as separate alleles in the ped file. The ped file has family id, individual id, father id (or 0), mother id
+(or 0), gender (1=male, 2=female, 0=unknown) and affection (1=unaffected, 2=affected, 0=unknown),
+then two separate allele columns for each genotype.
+
+Once you have your data in the right format, you can upload those into your Galaxy history using the "upload" tool.
+
+To upload your lped data in the upload tool, choose 'lped' as the 'file format'. The tool form will change to
+allow you to navigate to and select each member of the pair of ped and map files stored on your local computer
+(or available at a public URL for Galaxy to grab).
+Give the dataset a meaningful name (replace rgeneticsData with something more useful!) and click execute.
+
+When the upload is done, your new lped format dataset will appear in your history and then,
+when you choose the ancestry tool, that history dataset will be available as input.
+
+**Warning for the Impatient**
+
+When you execute the tool, it will look like it has not started running for a while as the automatic converter
+reduces the amount of LD - otherwise eigenstrat gives biased results.
+
+
**Attribution**
+
This tool runs and relies on the work of many others, including the
maintainers of the Eigensoft program, and the R and
Bioconductor projects. For full attribution, source code and documentation, please see
@@ -84,7 +109,7 @@
Licensed under the terms of the LGPL as documented http://www.gnu.org/licenses/lgpl.html
but is about as useful as a sponge boat without EIGENSOFT pca code.
-**README from eigensoft2**
+**README from eigensoft2 distribution at http://genepath.med.harvard.edu/~reich/Software.htm**
[rerla@beast eigensoft2]$ cat README
EIGENSOFT version 2.0, January 2008 (for Linux only)
--- a/tools/rgenetics/rgEigPCA_code.py Thu Mar 24 20:29:40 2011 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-from galaxy import datatypes,model
-import sys,time,string,shutil,os
-
-def timenow():
- """return current time as a string
- """
- return time.strftime('%d/%m/%Y %H:%M:%S', time.localtime(time.time()))
-
-def exec_after_process(app, inp_data, out_data, param_dict, tool, stdout, stderr):
- """Sets the name of the html output file
- if we created a set of ldreduced files, we need to move them into the input files_path
- so it doesn't need to be done again
- """
- indat = inp_data['i']
- indatname = indat.name
- base_name = indat.metadata.base_name
- todir = indat.extra_files_path # where the ldreduced stuff should be
- job_name = param_dict.get( 'title', 'Eigenstrat run' )
- job_name = job_name.encode()
- killme = string.punctuation + string.whitespace
- trantab = string.maketrans(killme,'_'*len(killme))
- job_name = job_name.translate(trantab)
- info = '%s rgEigPCA2 on %s at %s' % (job_name,indatname,timenow())
- exts = ['html','txt']
- for i,ofname in enumerate(['out_file1','pca']):
- data = out_data[ofname]
- ext = exts[i]
- newname = '%s.%s' % (job_name,ext)
- data.name = newname
- data.info = info
- out_data[ofname] = data
- if i == 0:
- fromdir = data.extra_files_path
- ldfname = '%s_INDEP_THIN' % base_name # we store ld reduced and thinned data
- ldout = os.path.join(todir,ldfname)
- ldin = os.path.join(fromdir,ldfname)
- if os.path.exists('%s.bed' % ldin) and not os.path.exists('%s.bed' % ldout): # copy ldreduced to input for next time
- for ext in ['bim','bed','fam']:
- src = '%s.%s' % (ldin,ext)
- dest = '%s.%s' % (ldout,ext)
- shutil.copy(src,dest)
- app.model.context.flush()
--- a/tools/rgenetics/rgGLM.py Thu Mar 24 20:29:40 2011 -0400
+++ b/tools/rgenetics/rgGLM.py Fri Mar 25 13:12:21 2011 -0400
@@ -95,6 +95,7 @@
outf.close()
+
def xformQassoc(resf='',outfname='',logf=None,twd='.'):
""" plink.assoc.linear to gg file
from the docs
--- a/tools/rgenetics/rgGLM.xml Thu Mar 24 20:29:40 2011 -0400
+++ b/tools/rgenetics/rgGLM.xml Fri Mar 25 13:12:21 2011 -0400
@@ -1,18 +1,15 @@
<tool id="rgGLM1" name="Linear Models:" version="0.2">
- <code file="listFiles.py"/>
+ <description>for genotype data</description><code file="rgGLM_code.py"/>
-
- <description>for genotype data</description>
-
<command interpreter="python">
rgGLM.py '$i.extra_files_path/$i.metadata.base_name' '$phef.extra_files_path/$phef.metadata.base_name'
- "$title1" '$predvar' '$covar' '$out_file1' '$logf' '$i.metadata.base_name'
+ "$title" '$predvar' '$covar' '$out_file1' '$logf' '$i.metadata.base_name'
'$inter' '$cond' '$gender' '$mind' '$geno' '$maf' '$logistic' '$gffout'
</command><inputs><page>
- <param name='title1' label='Title for outputs' type='text' value='GLM' size="80" />
+ <param name='title' label='Title for outputs' type='text' value='GLM' size="80" /><param name="i" type="data" format="pbed" label="Genotype file" size="80" /><param name="phef" type="data" format="pphe" label="Phenotype file" size="80"
help="Dependent variable and covariates will be chosen from this file on the next page"/>
@@ -41,9 +38,9 @@
</inputs><outputs>
- <data format="tabular" name="out_file1" />
- <data format="txt" name="logf" />
- <data format="gff" name="gffout" />
+ <data format="tabular" name="out_file1" label="${title}_rgGLM.xls"/>
+ <data format="txt" name="logf" label="${title}_rgGLMlog.txt" />
+ <data format="gff" name="gffout" label="${title}_rgGLM.gff"/></outputs><tests><test>
@@ -59,7 +56,7 @@
<composite_data value='tinywga.pphe' /><edit_attributes type='name' value='tinywga' /></param>
- <param name='title1' value='rgGLMtest1' />
+ <param name='title' value='rgGLMtest1' /><param name='predvar' value='c1' /><param name='covar' value='None' /><param name='inter' value='0' />
@@ -124,18 +121,26 @@
**Attribution**
-This tool allows you to control settings for models using Plink linear models. So, we rely on the author (Shaun Purcell)
-for the documentation you need specific to those settings - they are very nicely documented at
-http://pngu.mgh.harvard.edu/~purcell/plink/anal.shtml#glm
+This Galaxy tool relies on Plink (see Plinksrc_) to test GLM models.
+
+So, we rely on the author (Shaun Purcell) for the documentation you need specific to those settings - they are very nicely documented - see
+DOC_
Tool and Galaxy datatypes originally designed and written for the Rgenetics
series of whole genome scale statistical genetics tools by ross lazarus (ross.lazarus(a)gmail.com)
-supported by NIH grant
-Shaun Purcell created and maintains Plink
-Please acknowledge your use of this tool, Galaxy and Plink in your publications and let
-us know so we can keep track. These tools all rely on highly competitive grant funding
-so your letting us know about publications is important to our ongoing support.
+Copyright Ross Lazarus March 2007
+This Galaxy wrapper is released licensed under the LGPL_ but is about as useful as a chocolate teapot without Plink which is GPL.
+
+I'm no lawyer, but it looks like you got GPL if you use this software. Good luck.
+
+.. _Plinksrc: http://pngu.mgh.harvard.edu/~purcell/plink/
+
+.. _LGPL: http://www.gnu.org/copyleft/lesser.html
+
+.. _DOC: http://pngu.mgh.harvard.edu/~purcell/plink/anal.shtml#glm
+
</help></tool>
+
--- a/tools/rgenetics/rgGLM_code.py Thu Mar 24 20:29:40 2011 -0400
+++ b/tools/rgenetics/rgGLM_code.py Fri Mar 25 13:12:21 2011 -0400
@@ -2,17 +2,6 @@
import os,string,time
from galaxy import datatypes
-def timenow():
- """return current time as a string
- """
- return time.strftime('%d/%m/%Y %H:%M:%S', time.localtime(time.time()))
-
-def get_out_formats():
- """return options for formats"""
- dat = [['ucsc track','wig'],['ucsc genome graphs','gg'],['tab delimited','xls']]
- dat = [(x[0],x[1],False) for x in dat]
- dat.reverse()
- return dat
def get_phecols(phef='',selectOne=0):
"""return column names """
@@ -32,28 +21,3 @@
res = [('None','no phenotype columns found',False),]
return res
-
-def exec_after_process(app, inp_data, out_data, param_dict, tool, stdout, stderr):
- """Sets the name of the data"""
- killme=string.punctuation+string.whitespace
- trantab = string.maketrans(killme,'_'*len(killme))
- job_name = param_dict.get( 'title1', 'GLM' )
- job_name = job_name.encode().translate(trantab)
- outxls = ['tabular','%s_GLM.xls' % job_name]
- logtxt = ['txt','%s_GLM_log.txt' % job_name]
- ggout = ['gg','%s_GLM_topTable.gff' % job_name]
- lookup={}
- lookup['out_file1'] = outxls
- lookup['logf'] = logtxt
- lookup['gffout'] = ggout
- info = '%s GLM output by rgGLM created at %s' % (job_name,timenow())
- for name in lookup.keys():
- data = out_data[name]
- data_type,newname = lookup.get(name,(None,None))
- if data_type <> None:
- data.name = newname
- data.info = info
- out_data[name] = data
- else:
- print >> stdout,'no output matching %s in exec after hook for rgGLM' % name
- app.model.context.flush()
--- a/tools/rgenetics/rgGRR.xml Thu Mar 24 20:29:40 2011 -0400
+++ b/tools/rgenetics/rgGRR.xml Fri Mar 25 13:12:21 2011 -0400
@@ -1,20 +1,19 @@
<tool id="rgGRR1" name="GRR:">
- <code file="rgGRR_code.py"/><description>Pairwise Allele Sharing</description><command interpreter="python">
rgGRR.py $i.extra_files_path/$i.metadata.base_name "$i.metadata.base_name"
- '$out_file1' '$out_file1.files_path' "$title1" '$n' '$Z'
+ '$out_file1' '$out_file1.files_path' "$title" '$n' '$Z'
</command><inputs><param name="i" type="data" label="Genotype data file from your current history"
format="ldindep" />
- <param name='title1' type='text' size="80" value='rgGRR' label="Title for this job"/>
+ <param name='title' type='text' size="80" value='rgGRR' label="Title for this job"/><param name="n" type="integer" label="N snps to use (0=all)" value="5000" /><param name="Z" type="float" label="Z score cutoff for outliers (eg 2)" value="6"
help="2 works but for very large numbers of pairs, you might want to see less than 5%" /></inputs><outputs>
- <data format="html" name="out_file1" />
+ <data format="html" name="out_file1" label="${title}_rgGRR.html"/></outputs><tests>
@@ -26,7 +25,7 @@
<composite_data value='tinywga.fam' /><edit_attributes type='name' value='tinywga' /></param>
- <param name='title1' value='rgGRRtest1' />
+ <param name='title' value='rgGRRtest1' /><param name='n' value='100' /><param name='Z' value='6' /><param name='force' value='true' />
--- a/tools/rgenetics/rgGRR_code.py Thu Mar 24 20:29:40 2011 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-from galaxy import datatypes,model
-import sys,time,string,os,shutil
-
-def timenow():
- """return current time as a string
- """
- return time.strftime('%d/%m/%Y %H:%M:%S', time.localtime(time.time()))
-
-def exec_after_process(app, inp_data, out_data, param_dict, tool, stdout, stderr):
- """Sets the name of the html output file
- """
- killme = string.punctuation + string.whitespace
- trantab = string.maketrans(killme,'_'*len(killme))
- job_name = param_dict.get( 'title1', 'rgGRR' )
- job_name = job_name.encode()
- newname = '%s.html' % job_name.translate(trantab)
- indatname = inp_data['i'].name
- info = '%s Mean allele sharing on %s at %s' % (job_name,indatname,timenow())
- ofname = 'out_file1'
- data = out_data[ofname]
- data.name = newname
- data.info = info
- out_data[ofname] = data
- fromdir = data.extra_files_path
- indat = inp_data['i']
- indatname = indat.name
- base_name = indat.metadata.base_name
- todir = indat.extra_files_path # where the ldreduced stuff should be
- ldfname = '%s_INDEP_THIN' % base_name # we store ld reduced and thinned data
- ldout = os.path.join(todir,ldfname)
- ldin = os.path.join(fromdir,ldfname)
- if os.path.exists('%s.bed' % ldin) and not os.path.exists('%s.bed' % ldout): # copy ldreduced to input for next time
- for ext in ['bim','bed','fam']:
- src = '%s.%s' % (ldin,ext)
- dest = '%s.%s' % (ldout,ext)
- shutil.copy(src,dest)
- app.model.context.flush()
--- a/tools/rgenetics/rgGTOOL.xml Thu Mar 24 20:29:40 2011 -0400
+++ b/tools/rgenetics/rgGTOOL.xml Fri Mar 25 13:12:21 2011 -0400
@@ -1,6 +1,5 @@
<tool id="rgGTOOL1" name="Converter">
- <code file="listFiles.py"/>
- <code file="rgGTOOL_code.py"/>
+
<description>from linkage format to SNPTEST Marchini files</description>
--- a/tools/rgenetics/rgGTOOL_code.py Thu Mar 24 20:29:40 2011 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-# for GTOOL linkage ped to marchini snptest format
-from galaxy import datatypes
-
-
-def exec_before_job(app, inp_data, out_data, param_dict, tool=None):
- """Sets the name of the data"""
- job_name = param_dict.get( 'o', 'Marchini' )
- log = ['txt','%s_rgGTOOL_report.log' % job_name,'txt']
- lookup={}
- lookup['logf'] = log
- for name in lookup.keys():
- data = out_data[name]
- data_type,newname,ext = lookup[name]
- data = app.datatypes_registry.change_datatype(data, data_type)
- data.name = newname
- out_data[name] = data
-
-
-
--- a/tools/rgenetics/rgHaploView.py Thu Mar 24 20:29:40 2011 -0400
+++ b/tools/rgenetics/rgHaploView.py Fri Mar 25 13:12:21 2011 -0400
@@ -105,15 +105,8 @@
self.lf = file(self.log_file,'w')
s = 'PATH=%s\n' % os.environ.get('PATH','?')
self.lf.write(s)
-
- def setupRegions(self):
- """
- """
- chromosome = ''
- spos = epos = -9
- rslist = []
- rsdict = {}
+ def getRs(self):
if self.region > '':
useRs = []
useRsdict={}
@@ -138,6 +131,20 @@
else:
useRs = self.orslist.split() # galaxy replaces newlines with XX - go figure
useRsdict = dict(zip(useRs,useRs))
+ return useRs, useRsdict
+
+
+ def setupRegions(self):
+ """
+ This turns out to be complex because we allow the user
+ flexibility - paste a list of rs or give a region.
+ In most cases, some subset has to be generated correctly before running Haploview
+ """
+ chromosome = ''
+ spos = epos = -9
+ rslist = []
+ rsdict = {}
+ useRs,useRsdict = self.getRs()
self.useTemp = False
try:
dfile = open(self.DATA_FILE, 'r')
@@ -284,7 +291,60 @@
self.lf.write(s)
print >> sys.stdout,s
sys.exit(1)
-
+
+ def run(self,vcl):
+ """
+ """
+ p=subprocess.Popen(vcl,shell=True,cwd=self.outfpath,stderr=self.lf,stdout=self.lf)
+ retval = p.wait()
+ self.lf.write('## executing %s returned %d\n' % (vcl,retval))
+
+ def plotHmPanels(self,ste):
+ """
+ """
+ sp = '%d' % (self.spos/1000.) # hapmap wants kb
+ ep = '%d' % (self.epos/1000.)
+ fnum=0
+ for panel in self.hmpanels:
+ if panel > '' and panel.lower() <> 'none': # in case someone checks that option too :)
+ ptran = panel.strip()
+ ptran = ptran.replace('+','_')
+ fnum += 1 # preserve an order or else we get sorted
+ vcl = [javabin,'-jar',self.hvbin,'-n','-memory','%d' % self.memSize,
+ '-chromosome',self.chromosome, '-panel',panel.strip(),
+ '-hapmapDownload','-startpos',sp,'-endpos',ep,
+ '-ldcolorscheme',self.ldType]
+ if self.minMaf:
+ vcl += ['-minMaf','%f' % self.minMaf]
+ if self.maxDist:
+ vcl += ['-maxDistance',self.maxDist]
+ if self.hiRes:
+ vcl.append('-png')
+ else:
+ vcl.append('-compressedpng')
+ if self.infotrack:
+ vcl.append('-infoTrack')
+ p=subprocess.Popen(' '.join(vcl),shell=True,cwd=self.outfpath,stderr=ste,stdout=self.lf)
+ retval = p.wait()
+ inpng = 'Chromosome%s%s.LD.PNG' % (self.chromosome,panel)
+ inpng = inpng.replace(' ','') # mysterious spaces!
+ outpng = '%d_HapMap_%s_%s.png' % (fnum,ptran,self.chromosome)
+ # hack for stupid chb+jpt
+ outpng = outpng.replace(' ','')
+ tmppng = '%s.tmp.png' % self.title
+ tmppng = tmppng.replace(' ','')
+ outpng = os.path.split(outpng)[-1]
+ vcl = [self.convert, '-resize 800x400!', inpng, tmppng]
+ self.run(' '.join(vcl))
+ s = "text 10,300 'HapMap %s'" % ptran.strip()
+ vcl = [self.convert, '-pointsize 25','-fill maroon',
+ '-draw "%s"' % s, tmppng, outpng]
+ self.run(' '.join(vcl))
+ try:
+ os.remove(os.path.join(self.outfpath,tmppng))
+ except:
+ pass
+
def doPlots(self):
"""
"""
@@ -308,15 +368,9 @@
vcl += ['-chromosome',self.chromosome]
if self.infotrack:
vcl.append('-infoTrack')
- p=subprocess.Popen(' '.join(vcl),shell=True,cwd=self.outfpath,stderr=ste,stdout=self.lf)
- retval = p.wait()
- s = '## executing %s returned %d\n' % (' '.join(vcl),retval)
- self.lf.write(s)
+ self.run(' '.join(vcl))
vcl = [self.mogrify, '-resize 800x400!', '*.PNG']
- p=subprocess.Popen(' '.join(vcl),shell=True,cwd=self.outfpath,stderr=self.lf,stdout=self.lf)
- retval = p.wait()
- s = '## executing %s returned %d\n' % (' '.join(vcl),retval)
- self.lf.write(s)
+ self.run(' '.join(vcl))
inpng = '%s.LD.PNG' % DATA_FILE # stupid but necessary - can't control haploview name mangle
inpng = inpng.replace(' ','')
inpng = os.path.split(inpng)[-1]
@@ -326,89 +380,29 @@
outpng = outpng.replace(' ','')
outpng = os.path.split(outpng)[-1]
vcl = [self.convert, '-resize 800x400!', inpng, tmppng]
- p=subprocess.Popen(' '.join(vcl),shell=True,cwd=self.outfpath,stderr=self.lf,stdout=self.lf)
- retval = p.wait()
- s = '## executing %s returned %d\n' % (' '.join(vcl),retval)
- self.lf.write(s)
+ self.run(' '.join(vcl))
s = "text 10,300 '%s'" % self.title[:40]
vcl = [self.convert, '-pointsize 25','-fill maroon',
'-draw "%s"' % s, tmppng, outpng]
- p=subprocess.Popen(' '.join(vcl),shell=True,cwd=self.outfpath,stderr=self.lf,stdout=self.lf)
- retval = p.wait()
- s = '## executing %s returned %d\n' % (' '.join(vcl),retval)
- self.lf.write(s)
+ self.run(' '.join(vcl))
try:
os.remove(os.path.join(self.outfpath,tmppng))
except:
pass # label all the plots then delete all the .PNG files before munging
fnum=1
if self.hmpanels:
- sp = '%d' % (self.spos/1000.) # hapmap wants kb
- ep = '%d' % (self.epos/1000.)
- for panel in self.hmpanels:
- if panel > '' and panel.lower() <> 'none': # in case someone checks that option too :)
- ptran = panel.strip()
- ptran = ptran.replace('+','_')
- fnum += 1 # preserve an order or else we get sorted
- vcl = [javabin,'-jar',self.hvbin,'-n','-memory','%d' % self.memSize,
- '-chromosome',self.chromosome, '-panel',panel.strip(),
- '-hapmapDownload','-startpos',sp,'-endpos',ep,
- '-ldcolorscheme',self.ldType]
- if self.minMaf:
- vcl += ['-minMaf','%f' % self.minMaf]
- if self.maxDist:
- vcl += ['-maxDistance',self.maxDist]
- if self.hiRes:
- vcl.append('-png')
- else:
- vcl.append('-compressedpng')
- if self.infotrack:
- vcl.append('-infoTrack')
- p=subprocess.Popen(' '.join(vcl),shell=True,cwd=self.outfpath,stderr=ste,stdout=self.lf)
- retval = p.wait()
- inpng = 'Chromosome%s%s.LD.PNG' % (self.chromosome,panel)
- inpng = inpng.replace(' ','') # mysterious spaces!
- outpng = '%d_HapMap_%s_%s.png' % (fnum,ptran,self.chromosome)
- # hack for stupid chb+jpt
- outpng = outpng.replace(' ','')
- tmppng = '%s.tmp.png' % self.title
- tmppng = tmppng.replace(' ','')
- outpng = os.path.split(outpng)[-1]
- vcl = [self.convert, '-resize 800x400!', inpng, tmppng]
- p=subprocess.Popen(' '.join(vcl),shell=True,cwd=self.outfpath,stderr=self.lf,stdout=self.lf)
- retval = p.wait()
- s = '## executing %s returned %d\n' % (' '.join(vcl),retval)
- self.lf.write(s)
- s = "text 10,300 'HapMap %s'" % ptran.strip()
- vcl = [self.convert, '-pointsize 25','-fill maroon',
- '-draw "%s"' % s, tmppng, outpng]
- p=subprocess.Popen(' '.join(vcl),shell=True,cwd=self.outfpath,stderr=self.lf,stdout=self.lf)
- retval = p.wait()
- s = '## executing %s returned %d\n' % (' '.join(vcl),retval)
- self.lf.write(s)
- try:
- os.remove(os.path.join(self.outfpath,tmppng))
- except:
- pass
+ self.plotHmPanels(ste)
nimages = len(glob.glob(os.path.join(self.outfpath,'*.png'))) # rely on HaploView shouting - PNG @!
self.lf.write('### nimages=%d\n' % nimages)
if nimages > 0: # haploview may fail?
vcl = '%s -format pdf -resize 800x400! *.png' % self.mogrify
- p=subprocess.Popen(vcl,shell=True,cwd=self.outfpath,stderr=self.lf,stdout=self.lf)
- retval = p.wait()
- self.lf.write('## executing %s returned %d\n' % (vcl,retval))
+ self.run(vcl)
vcl = '%s *.pdf --fitpaper true --outfile alljoin.pdf' % self.pdfjoin
- p=subprocess.Popen(vcl,shell=True,cwd=self.outfpath,stderr=self.lf,stdout=self.lf)
- retval = p.wait()
- self.lf.write('## executing %s returned %d\n' % (vcl,retval))
+ self.run(vcl)
vcl = '%s alljoin.pdf --nup 1x%d --outfile allnup.pdf' % (self.pdfnup,nimages)
- p=subprocess.Popen(vcl,shell=True,cwd=self.outfpath,stderr=self.lf,stdout=self.lf)
- retval = p.wait()
- self.lf.write('## executing %s returned %d\n' % (vcl,retval))
+ self.run(vcl)
vcl = '%s -resize x300 allnup.pdf allnup.png' % (self.convert)
- p=subprocess.Popen(vcl,shell=True,cwd=self.outfpath,stderr=self.lf,stdout=self.lf)
- retval = p.wait()
- self.lf.write('## executing %s returned %d\n' % (vcl,retval))
+ self.run(vcl)
ste.close() # temp file used to catch haploview blather
hblather = open(blog,'r').readlines() # to catch the blather
os.unlink(blog)
@@ -417,6 +411,10 @@
self.lf.write(''.join(hblather))
self.lf.write('\n')
self.lf.close()
+
+ def writeHtml(self):
+ """
+ """
flist = glob.glob(os.path.join(self.outfpath, '*'))
flist.sort()
ts = '!"#$%&\'()*+,-/:;<=>?@[\\]^_`{|}~' + string.whitespace
@@ -509,6 +507,7 @@
sys.exit(1)
ld = ldPlot(argv = sys.argv)
ld.doPlots()
+ ld.writeHtml()
--- a/tools/rgenetics/rgHaploView_code.py Thu Mar 24 20:29:40 2011 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-from galaxy import app
-import galaxy.util,string,os,glob,time
-
-librepos = '/usr/local/galaxy/data/rg/library'
-myrepos = '/home/rerla/galaxy'
-
-
-#Provides Upload tool with access to list of available builds
-
-builds = []
-#Read build names and keys from galaxy.util
-for dbkey, build_name in galaxy.util.dbnames:
- builds.append((build_name,dbkey,False))
-
-def timenow():
- """return current time as a string
- """
- return time.strftime('%d/%m/%Y %H:%M:%S', time.localtime(time.time()))
-
-#Return available builds
-def get_available_builds(defval='hg18'):
- for i,x in enumerate(builds):
- if x[1] == defval:
- x = list(x)
- x[2] = True
- builds[i] = tuple(x)
- return builds
-
-#return available datasets for build
-def get_available_data( file_type_dir, build='hg18' ):
- #we need to allow switching of builds, and properly set in post run hook
- import_files = [('Use the History file chosen below','',True),]
- flist = glob.glob(os.path.join(librepos,file_type_dir,'*.ped'))
- maplist = glob.glob(os.path.join(librepos,file_type_dir,'*.map'))
- maplist = [os.path.splitext(x)[0] for x in maplist] # get unique filenames
- mapdict = dict(zip(maplist,maplist))
- flist = [os.path.splitext(x)[0] for x in flist] # get unique filenames
- flist = list(set(flist)) # remove dupes
- flist = [x for x in flist if mapdict.get(x,None)]
- flist.sort()
- for i, data in enumerate( flist ):
- #import_files.append( (os.path.split(data)[-1], os.path.split(data)[-1], False) )
- import_files.append((data,data, False) )
- if len(import_files) < 1:
- import_files = [('No %s data available - please choose a History file below'
- % file_type_dir,'',True),]
- return import_files
-
-def get_available_outexts(uid):
- userId = uid
- print 'userId=',userId
- flib = os.path.join(librepos,userId,'fped')
- plib = os.path.join(librepos,userId,'lped')
- e = [('Fbat style (header row has marker names)',flib,False),('Linkage style (separate .map file)',plib,True)]
- return e
-
-def getcols(fname="/usr/local/galaxy/data/camp2007/camp2007.xls"):
- """return column names other than chr offset as a select list"""
- head = open(fname,'r').next()
- c = head.strip().split()
- res = [(cname,'%d' % n,False) for n,cname in enumerate(c)]
- for i in range(4):
- x,y,z = res[i]
- res[i] = (x,y,True) # set first couple as selected
- return res
-
-
-def exec_after_process(app, inp_data, out_data, param_dict, tool, stdout, stderr):
- """Sets the name of the html output file - that's all we need
- for a html file result set
- """
- ts = '%s%s' % (string.punctuation,string.whitespace)
- ptran = string.maketrans(ts,'_'*len(ts))
- job_name = param_dict.get( 'title', 'LD_Plot' )
- job_name = job_name.encode().translate(ptran)
- ofname = 'out_file1'
- data = out_data[ofname]
- newname = job_name
- data.name = '%s.html' % newname
- info = '%s created by rgHaploView at %s' % (job_name,timenow())
- out_data[ofname] = data
- app.model.context.flush()
-
-
--- a/tools/rgenetics/rgLDIndep_code.py Thu Mar 24 20:29:40 2011 -0400
+++ b/tools/rgenetics/rgLDIndep_code.py Fri Mar 25 13:12:21 2011 -0400
@@ -15,7 +15,7 @@
trantab = string.maketrans(killme,'_'*len(killme))
title = basename.encode().translate(trantab)
info = '%s filtered by rgLDIndep.py at %s' % (title,timenow())
- #data.file_name = data.file_name
+ data.file_name = data.file_name
data.metadata.base_name = title
data.name = '%s.pbed' % title
data.info = info
--- a/tools/rgenetics/rgManQQ.xml Thu Mar 24 20:29:40 2011 -0400
+++ b/tools/rgenetics/rgManQQ.xml Fri Mar 25 13:12:21 2011 -0400
@@ -44,9 +44,9 @@
<param name='grey' value='0' /><output name='out_html' file='rgtestouts/rgManQQ/rgManQQtest1.html' ftype='html' lines_diff='60'><extra_files type="file" name='Allelep_manhattan.png' value='rgtestouts/rgManQQ/Allelep_manhattan.png' compare="sim_size"
- delta = "10000"/>
+ delta = "20000"/><extra_files type="file" name='Allelep_qqplot.png' value='rgtestouts/rgManQQ/Allelep_qqplot.png' compare="sim_size"
- delta = "10000" />
+ delta = "20000" /><extra_files type="file" name='rgManQQtest1.R' value='rgtestouts/rgManQQ/rgManQQtest1.R' compare="diff" lines_diff="160"/></output></test>
--- a/tools/rgenetics/rgPedSub.xml Thu Mar 24 20:29:40 2011 -0400
+++ b/tools/rgenetics/rgPedSub.xml Fri Mar 25 13:12:21 2011 -0400
@@ -1,5 +1,4 @@
<tool id="rgPedSub1" name="Subset markers:">
- <code file="rgPedSub_code.py"/><description>region or rs list</description>
@@ -44,7 +43,7 @@
</inputs><outputs>
- <data format="lped" name="output1" metadata_source="input1"/>
+ <data format="lped" name="output1" metadata_source="input1" label="${title}.lped"/></outputs><configfiles>
--- a/tools/rgenetics/rgPedSub_code.py Thu Mar 24 20:29:40 2011 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-from galaxy import app
-import galaxy.util,string,os,glob,time
-
-#Provides Upload tool with access to list of available builds
-
-builds = []
-#Read build names and keys from galaxy.util
-for dbkey, build_name in galaxy.util.dbnames:
- builds.append((build_name,dbkey,False))
-
-def timenow():
- """return current time as a string
- """
- return time.strftime('%d/%m/%Y %H:%M:%S', time.localtime(time.time()))
-
-
-#Return available builds
-def get_available_builds(defval='hg18'):
- for i,x in enumerate(builds):
- if x[1] == defval:
- x = list(x)
- x[2] = True
- builds[i] = tuple(x)
- return builds
-
-#return available datasets for build
-def get_available_data( file_type_dir, build='hg18' ):
- #we need to allow switching of builds, and properly set in post run hook
- import_files = [] # [('Use the History file chosen below','',False),]
- flist = glob.glob(os.path.join(librepos,file_type_dir,'*.ped'))
- flist = [os.path.splitext(x)[0] for x in flist] # get unique filenames
- flist = list(set(flist)) # remove dupes
- flist.sort()
- for i, data in enumerate( flist ):
- #import_files.append( (os.path.split(data)[-1], os.path.split(data)[-1], False) )
- import_files.append((os.path.split(data)[-1],data, False) )
- if len(import_files) < 1:
- import_files.append(('No %s data available - please choose a History file instead'
- % file_type_dir,'',True))
- return import_files
-
-def get_available_outexts(uid):
- userId = uid
- print 'userId=',userId
- flib = os.path.join(librepos,userId,'fped')
- plib = os.path.join(librepos,userId,'lped')
- e = [('Fbat style (header row has marker names)',flib,False),('Linkage style (separate .map file)',plib,True)]
- return e
-
-def getcols(fname="/usr/local/galaxy/data/camp2007/camp2007.xls"):
- """return column names other than chr offset as a select list"""
- head = open(fname,'r').next()
- c = head.strip().split()
- res = [(cname,'%d' % n,False) for n,cname in enumerate(c)]
- for i in range(4):
- x,y,z = res[i]
- res[i] = (x,y,True) # set first couple as selected
- return res
-
-
-def exec_after_process(app, inp_data, out_data, param_dict, tool, stdout, stderr):
- """from rgConvert_code
- """
- name,data = out_data.items()[0]
- iname,idata = inp_data.items()[0]
- basename = idata.metadata.base_name
- title = param_dict.get( 'title', 'Lped Subset' )
- title = title.encode() # make str - unicode is evil here
- killme = string.punctuation + string.whitespace
- trantab = string.maketrans(killme,'_'*len(killme))
- title = title.translate(trantab)
- info = '%s filtered by rgPedSub.py at %s' % (title,timenow())
- #data.file_name = data.file_name
- data.metadata.base_name = basename
- data.name = '%s.lped' % title
- data.info = info
- app.model.context.flush()
-
--- a/tools/rgenetics/rgQC.xml Thu Mar 24 20:29:40 2011 -0400
+++ b/tools/rgenetics/rgQC.xml Fri Mar 25 13:12:21 2011 -0400
@@ -1,21 +1,20 @@
<tool id="rgQC1" name="QC reports:">
- <code file="rgQC_code.py"/><description>Marker and Subject measures</description><command interpreter="python">
- rgQC.py -i '$input_file.extra_files_path/$input_file.metadata.base_name' -o "$out_prefix"
+ rgQC.py -i '$input_file.extra_files_path/$input_file.metadata.base_name' -o "$title"
-s '$html_file' -p '$html_file.files_path'
</command><inputs><param name="input_file" type="data" label="RGenetics genotype file in compressed Plink format"
size="80" format="pbed" />
- <param name="out_prefix" size="80" type="text" value="RgQC report" label="Descriptive report title"/>
+ <param name="title" size="80" type="text" value="RgQC report" label="Descriptive report title"/></inputs><outputs>
- <data format="html" name="html_file" metadata_source="input_file"/>
+ <data format="html" name="html_file" metadata_source="input_file" label="${title}.html"/></outputs><tests>
@@ -27,9 +26,9 @@
<composite_data value='tinywga.fam' /><edit_attributes type='name' value='tinywga' /></param>
- <param name='out_prefix' value='rgQCtest1' />
- <output name='html_file' file='rgtestouts/rgQC/rgQCtest1.html' ftype='html' lines_diff='280'>
- <extra_files type="file" name='tinywga_All_Paged.pdf' value="rgtestouts/rgQC/tinywga_All_Paged.pdf" compare="sim_size" delta = "5000"/>
+ <param name='title' value='rgQCtest1' />
+ <output name='html_file' file='rgtestouts/rgQC/rgQCtest1.html' ftype='html' lines_diff='300'>
+ <extra_files type="file" name='tinywga_All_Paged.pdf' value="rgtestouts/rgQC/tinywga_All_Paged.pdf" compare="sim_size" delta = "100000"/><extra_files type="file" name='tinywga.log' value="rgtestouts/rgQC/tinywga.log" compare="diff" lines_diff="15"/><extra_files type="file" name='tinywga.frq' value="rgtestouts/rgQC/tinywga.frq" compare="diff" /><extra_files type="file" name='tinywga.het' value="rgtestouts/rgQC/tinywga.het" compare="diff" lines_diff="90"/>
@@ -38,7 +37,7 @@
<extra_files type="file" name='tinywga.imiss' value="rgtestouts/rgQC/tinywga.imiss" compare="diff" /><extra_files type="file" name='tinywga.lmendel' value="rgtestouts/rgQC/tinywga.lmendel" compare="diff" /><extra_files type="file" name='tinywga.lmiss' value="rgtestouts/rgQC/tinywga.lmiss" compare="diff" />
- <extra_files type="file" name='tinywga_All_3x3.pdf' value="rgtestouts/rgQC/tinywga_All_3x3.pdf" compare="sim_size" delta="5000"/>
+ <extra_files type="file" name='tinywga_All_3x3.pdf' value="rgtestouts/rgQC/tinywga_All_3x3.pdf" compare="sim_size" delta="100000"/><extra_files type="file" name='ldp_tinywga.bed' value="rgtestouts/rgQC/ldp_tinywga.bed" compare="diff" lines_diff="10" /><extra_files type="file" name='ldp_tinywga.bim' value="rgtestouts/rgQC/ldp_tinywga.bim" compare="sim_size" delta="1000" /><extra_files type="file" name='ldp_tinywga.fam' value="rgtestouts/rgQC/ldp_tinywga.fam" compare="diff" />
@@ -46,9 +45,9 @@
<extra_files type="file" name='Ranked_Marker_HWE.xls' value="rgtestouts/rgQC/Ranked_Marker_HWE.xls" compare="diff" /><extra_files type="file" name='Ranked_Marker_MAF.xls' value="rgtestouts/rgQC/Ranked_Marker_MAF.xls" compare="diff" /><extra_files type="file" name='Ranked_Marker_Missing_Genotype.xls' value="rgtestouts/rgQC/Ranked_Marker_Missing_Genotype.xls" compare="diff" lines_diff="5"/>
- <extra_files type="file" name='Ranked_Subject_Missing_Genotype.xls' value="rgtestouts/rgQC/Ranked_Subject_Missing_Genotype.xls" compare="diff" lines_diff="10"/>
+ <extra_files type="file" name='Ranked_Subject_Missing_Genotype.xls' value="rgtestouts/rgQC/Ranked_Subject_Missing_Genotype.xls" compare="diff" lines_diff="40"/><extra_files type="file" name='tinywga_fracmiss_cum.jpg' value="rgtestouts/rgQC/tinywga_fracmiss_cum.jpg" compare="sim_size" delta = "20000"/>
- <extra_files type="file" name='tinywga_fracmiss_cum.pdf' value="rgtestouts/rgQC/tinywga_fracmiss_cum.pdf" compare="sim_size" delta = "1000"/>
+ <extra_files type="file" name='tinywga_fracmiss_cum.pdf' value="rgtestouts/rgQC/tinywga_fracmiss_cum.pdf" compare="sim_size" delta = "100000"/></output></test></tests>
--- a/tools/rgenetics/rgQC_code.py Thu Mar 24 20:29:40 2011 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-"""
-# after running the qc, need to rename various output files
- <data format="html" name="html_file" />
- <data format="txt" name="log_file" parent="html_file" />
- <data format="tabular" name="marker_file" parent="html_file" />
- <data format="tabular" name="subject_file" parent="html_file" />
- <data format="tabular" name="freq_file" parent="html_file" />
- </outputs>
-"""
-from galaxy import datatypes,model
-import sys,time
-
-def timenow():
- """return current time as a string
- """
- return time.strftime('%d/%m/%Y %H:%M:%S', time.localtime(time.time()))
-
-
-def exec_after_process(app, inp_data, out_data, param_dict, tool, stdout, stderr):
- """Change data file names
-
- """
- job_name = param_dict.get( 'out_prefix', 'rgQCdefault' )
- html = ['html','%s.html' % job_name]
- lookup={}
- lookup['html_file'] = html
- info = '%s QC report by rgQC at %s' % (job_name,timenow())
- for aname in lookup.keys():
- data = out_data[aname]
- data_type,newname = lookup[aname]
- data = app.datatypes_registry.change_datatype(data, data_type)
- data.name = newname
- data.info = info
- out_data[aname] = data
- app.model.context.flush()
-
-
-
--- a/tools/rgenetics/rgQQ.xml Thu Mar 24 20:29:40 2011 -0400
+++ b/tools/rgenetics/rgQQ.xml Fri Mar 25 13:12:21 2011 -0400
@@ -4,14 +4,14 @@
<description>for p values from an analysis </description><command interpreter="python">
- rgQQ.py "$input1" "$name" "$sample" "$cols" "$allqq" "$height" "$width" "$logtrans" "$allqq.id" "$__new_file_path__"
+ rgQQ.py "$input1" "$title" "$sample" "$cols" "$allqq" "$height" "$width" "$logtrans" "$allqq.id" "$__new_file_path__"
</command><inputs><page><param name="input1" type="data" label="Choose the History dataset containing p values to QQ plot"
size="80" format="tabular" help="Dataset missing? See Tip below" />
- <param name="name" type="text" size="80" label = "Descriptive title for QQ plot" value="QQ" />
+ <param name="title" type="text" size="80" label = "Descriptive title for QQ plot" value="QQ" /><param name="logtrans" type="boolean" label = "Use a log scale - recommended for p values in range 0-1.0"
truevalue="true" falsevalue="false"/>
@@ -28,13 +28,13 @@
</inputs><outputs>
- <data format="pdf" name="allqq" />
+ <data format="pdf" name="allqq" label="${title}.html"/></outputs><tests><test><param name='input1' value='tinywga.pphe' />
- <param name='name' value="rgQQtest1" />
+ <param name='title' value="rgQQtest1" /><param name='logtrans' value="false" /><param name='sample' value='1.0' /><param name='height' value='8' />
--- a/tools/rgenetics/rgQQ_code.py Thu Mar 24 20:29:40 2011 -0400
+++ b/tools/rgenetics/rgQQ_code.py Fri Mar 25 13:12:21 2011 -0400
@@ -48,25 +48,3 @@
else:
columns = [('?','?',False),]
return columns
-
-
-def exec_after_process(app, inp_data, out_data, param_dict, tool, stdout, stderr):
- """Sets the name of the data
- <outputs>
- <data format="pdf" name="allqq" />
- <data format="pdf" name="lowqq" parent="allqq"/>
- </outputs>
- """
- job_name = param_dict.get( 'name', 'My rgQQplot' )
- killme = string.punctuation + string.whitespace
- trantab = string.maketrans(killme,'_'*len(killme))
- newname = '%s.pdf' % job_name.translate(trantab)
- lookup={}
- lookup['allqq'] = newname
- for aname in lookup.keys():
- data = out_data[aname]
- newname = lookup[aname]
- data.name = newname
- out_data[aname] = data
- app.model.context.flush()
-
--- a/tools/rgenetics/rgRegion.xml Thu Mar 24 20:29:40 2011 -0400
+++ b/tools/rgenetics/rgRegion.xml Fri Mar 25 13:12:21 2011 -0400
@@ -1,24 +1,20 @@
<tool id="rgRegion" name="Subset:">
- <code file="rgRegion_code.py"/>
- <code file="listFiles.py"/>
-
<description>genotypes from genomic region</description><command interpreter="python">
- rgRegion.py $infile $r $tag $out_file1
+ rgRegion.py $infile $r $title $out_file1
</command><inputs><page><param name="infile" type="data" format="lped" label="Linkage ped genotype file name from current history" size="80"/>
+ <param name="title" type="text" size="80" label="Title for output files" optional="true"
+ help="Descriptive title for new genotype/map files" value="RGRegion" /><param name="r" type="text" label="Region" help="Cut and paste a UCSC browser region"
size="80" value="chr9:119,506,000-122,518,000"/><param name="rslist" type="text" area="true" label="List of rs numbers" help="Type (or cut and paste) a space or newline separated list of rs numbers"
size="5x20"/>
-
- <param name="tag" type="text" label="Output file name" value="My_favourite_region" size="80"/>
- <param name="outformat" type="select" label="Output file format" dynamic_options="get_rgRegionOutFormats()" size="80"/>
- <param name="dbkey" type="hidden" value="hg18" />
+ <param name="outformat" type="select" label="Output file format" dynamic_options="get_rgRegionOutFormats()" size="80"/></page>
@@ -26,7 +22,7 @@
</inputs><outputs>
- <data format="lped" name="out_file1" />
+ <data format="lped" name="out_file1" label="${title}.lped" metadata_source=infile /></outputs><help>
--- a/tools/rgenetics/rgRegion_code.py Thu Mar 24 20:29:40 2011 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-from galaxy import app
-import galaxy.util,string
-
-librepos = '/usr/local/galaxy/data/rg'
-myrepos = '/home/rerla/galaxy'
-marchinirepos = '/usr/local/galaxy/data/rg/snptest'
-
-#Provides Upload tool with access to list of available builds
-
-
-def get_rgRegionOutFormats():
- """return options for formats"""
- dat = [['ucsc track','wig',False],['Strict genome graphs (rs+floats)','gg',True],['tab delimited','xls',False]]
- dat = [(x[0],x[1],x[2]) for x in dat]
- return dat
-
-
-def get_phecols(phef):
- """return column names """
- head = open(phef,'r').next()
- c = head.strip().split()
- res = [(cname,cname,False) for cname in c]
- x,y,z = res[2] # 0,1 = fid,iid
- res[2] = (x,y,True) # set second selected
- return res
-
-
-def getAllcols(fname="/usr/local/galaxy/data/camp2007/camp2007.xls",outformat='gg'):
- """return column names other than chr offset as a select list"""
- head = open(fname,'r').next()
- c = head.strip().split()
- res = [(cname,'%d' % n,True) for n,cname in enumerate(c)]
-
- return res
-
-
-def exec_after_process(app, inp_data, out_data, param_dict, tool, stdout, stderr):
- """Sets the name of the data"""
- data_name = param_dict.get( 'tag', 'My region' )
- outformat = param_dict.get( 'outformat', 'gg' )
- outfile = param_dict.get( 'outfile1', 'lped' )
- for name, data in out_data.items():
- if name == 'tag':
- data = app.datatypes_registry.change_datatype(data, outformat)
- data.name = data_name
- out_data[name] = data
-
--- a/tools/rgenetics/rgTDT.py Thu Mar 24 20:29:40 2011 -0400
+++ b/tools/rgenetics/rgTDT.py Fri Mar 25 13:12:21 2011 -0400
@@ -26,6 +26,7 @@
verbose = False
+
def makeGFF(resf='',outfname='',logf=None,twd='.',name='track name',description='track description',topn=1000):
"""
score must be scaled to 0-1000
@@ -84,7 +85,7 @@
outres = [] # need to resort into chrom offset order
for i,lrow in enumerate(resfl):
chrom,snp,offset,p, = [lrow[x] for x in wewant]
- gff = ('chr%s' % chrom,'rgGLM','variation','%d' % (int(offset)-halfwidth),
+ gff = ('chr%s' % chrom,'rgTDT','variation','%d' % (int(offset)-halfwidth),
'%d' % (int(offset)+halfwidth),p,'.','.','%s logp=%1.2f' % (snp,pvals[i]))
outres.append(gff)
outres = [(x[0],int(x[3]),x) for x in outres] # decorate
--- a/tools/rgenetics/rgTDT.xml Thu Mar 24 20:29:40 2011 -0400
+++ b/tools/rgenetics/rgTDT.xml Fri Mar 25 13:12:21 2011 -0400
@@ -1,23 +1,21 @@
<tool id="rgTDT1" name="Transmission Distortion:">
- <code file="rgTDT_code.py"/>
-
<description>for family data</description><command interpreter="python">
- rgTDT.py -i '$i.extra_files_path/$i.metadata.base_name' -o '$title1'
+ rgTDT.py -i '$i.extra_files_path/$i.metadata.base_name' -o '$title'
-r '$out_file1' -l '$logf' -g '$gffout'
</command><inputs><param name="i" type="data" label="Genotypes for analysis from your current history datasets"
size="132" format="pbed" />
- <param name='title1' type='text' value='rgTDT' size="80"/>
+ <param name='title' type='text' value='rgTDT' label="Title for the output to remind you what you did" size="80"/></inputs><outputs>
- <data format="tabular" name="out_file1" />
- <data format="gff" name="gffout" />
- <data format="txt" name="logf" />
+ <data format="tabular" name="out_file1" label="${title}_rgTDT.xls"/>
+ <data format="gff" name="gffout" label="${title}_rgTDT.gff"/>
+ <data format="txt" name="logf" label="${title}_rgTDTlog.txt"/></outputs><tests>
@@ -29,7 +27,7 @@
<composite_data value='tinywga.fam' /><edit_attributes type='name' value='tinywga' /></param>
- <param name='title1' value='rgTDTtest1' />
+ <param name='title' value='rgTDTtest1' /><output name='out_file1' file='rgTDTtest1_TDT.xls' ftype='tabular' compare="diff"/><output name='gffout' file='rgTDTtest1_TDT_topTable.gff' ftype='gff' compare="diff" /><output name='logf' file='rgTDTtest1_TDT_log.txt' ftype='txt' lines_diff='79'/>
@@ -81,5 +79,30 @@
one with a header. Fortunately excel is dumb enough to open these without much protest.
+----
+
+.. class:: infomark
+
+**Attribution**
+
+This Galaxy tool relies on Plink (see Plinksrc_) to test TDT models.
+
+So, we rely on the author (Shaun Purcell) for the documentation you need specific to those settings - they are very nicely documented - see
+DOC_
+
+Tool and Galaxy datatypes originally designed and written for the Rgenetics
+series of whole genome scale statistical genetics tools by ross lazarus (ross.lazarus(a)gmail.com)
+
+Copyright Ross Lazarus March 2007
+This Galaxy wrapper is released licensed under the LGPL_ but is about as useful as a chocolate teapot without Plink which is GPL.
+
+I'm no lawyer, but it looks like you got GPL if you use this software. Good luck.
+
+.. _Plinksrc: http://pngu.mgh.harvard.edu/~purcell/plink/
+
+.. _LGPL: http://www.gnu.org/copyleft/lesser.html
+
+.. _DOC: http://pngu.mgh.harvard.edu/~purcell/plink/anal.shtml#tdt
+
</help></tool>
--- a/tools/rgenetics/rgTDT_code.py Thu Mar 24 20:29:40 2011 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-# before running the qc, need to rename various output files
-import time,string
-
-def timenow():
- """return current time as a string
- """
- return time.strftime('%d/%m/%Y %H:%M:%S', time.localtime(time.time()))
-
-def get_out_formats():
- """return options for formats"""
- dat = [['ucsc genome graphs','gg',True],['ucsc track','wig',False],['tab delimited','xls',False]]
- dat = [(x[0],x[1],x[2]) for x in dat]
- return dat
-
-
-def exec_after_process(app, inp_data, out_data, param_dict, tool, stdout, stderr):
- """Sets the name of the data
- <command interpreter="python2.4">
- rgTDT.py -i $i.extra_files_path/$i.metadata.base_name -o $title -f $outformat -r $out_file1 -l $logf
- </command>
-
- """
- dbk = param_dict.get('dbkey','hg18')
- job_name = param_dict.get( 'title1', 'rgTDTtest1' )
- killme=string.punctuation+string.whitespace
- trantab = string.maketrans(killme,'_'*len(killme))
- job_name = job_name.encode().translate(trantab)
- outxls = ['tabular','%s_TDT.xls' % job_name]
- logtxt = ['txt','%s_TDT_log.txt' % job_name]
- ggout = ['gg','%s_TDT_topTable.gff' % job_name]
- lookup={}
- lookup['out_file1'] = outxls
- lookup['logf'] = logtxt
- lookup['gffout'] = ggout
- info = 'rgTDT run at %s' % timenow()
- for name in lookup.keys():
- data = out_data[name]
- data_type,newname = lookup[name]
- data.name = newname
- data.info = info
- data.dbkey = dbk
- out_data[name] = data
- app.model.context.flush()
--- a/tools/rgenetics/rgfakePed.xml Thu Mar 24 20:29:40 2011 -0400
+++ b/tools/rgenetics/rgfakePed.xml Fri Mar 25 13:12:21 2011 -0400
@@ -1,14 +1,13 @@
<tool id="rgfakePed1" name="Null genotypes"><description>for testing</description>
- <code file="rgfakePed_code.py"/>
- <command interpreter="python">rgfakePed.py --title '$title1'
+ <command interpreter="python">rgfakePed.py --title '$title'
-o '$out_file1' -p '$out_file1.files_path' -c '$ncases' -n '$ntotal'
-s '$nsnp' -w '$lowmaf' -v '$missingValue' -l '$outFormat'
-d '$mafdist' -m '$missingRate' -M '$mendelRate' </command><inputs><page>
- <param name="title1"
+ <param name="title"
type="text"
help="Name for outputs from this job"
label="Descriptive short name"/>
@@ -60,11 +59,11 @@
</inputs><outputs>
- <data format="lped" name="out_file1" />
+ <data format="lped" name="out_file1" label="${title}.lped" /></outputs><tests><test>
- <param name='title1' value='rgfakePedtest1' />
+ <param name='title' value='rgfakePedtest1' /><param name="ntotal" value="40" /><param name="ncases" value="20" /><param name="nsnp" value="10" />
--- a/tools/rgenetics/rgfakePed_code.py Thu Mar 24 20:29:40 2011 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-import os, string, time
-from galaxy import datatypes
-from galaxy import app
-import galaxy.util
-
-#Provides Upload tool with access to list of available builds
-repospath = '/usr/local/galaxy/data/rg'
-builds = []
-#Read build names and keys from galaxy.util
-for dbkey, build_name in galaxy.util.dbnames:
- builds.append((build_name,dbkey,False))
-
-def timenow():
- """return current time as a string
- """
- return time.strftime('%d/%m/%Y %H:%M:%S', time.localtime(time.time()))
-
-#Return available builds
-def get_available_builds(defval='hg18'):
- for i,x in enumerate(builds):
- if x[1] == defval:
- x = list(x)
- x[2] = True
- builds[i] = tuple(x)
- return builds
-
-# Create link to files here
-def exec_after_process(app, inp_data, out_data, param_dict, tool, stdout, stderr):
- base_name = param_dict.get( 'title1', 'Null_Genotypes' )
- base_name = base_name.encode()
- outFormat = param_dict.get('outFormat','P')
- s = string.whitespace + string.punctuation
- ptran = string.maketrans(s,'_'*len(s))
- base_name = base_name.translate(ptran)
- pname = "out_file1"
- lookup = {'L':('linkped','lped'),'F':('FBAT','fped')}
- # /usr/local/galaxy/data/rg/1/lped/
- info = 'Null phenotypes created by rgfakePhe at %s' % timenow()
- data = out_data[pname]
- ftype,pext = lookup[outFormat]
- data.name = '%s.%s' % (base_name,pext) # that's how they've been named in rgfakePhe.py
- data.change_datatype(pext)
- #data.file_name = data.file_name
- data.metadata.base_name = base_name
- data.readonly = True
- out_data[pname] = data
- app.model.context.flush()
-
-
-
-
-
-
--- a/tools/rgenetics/rgfakePhe_code.py Thu Mar 24 20:29:40 2011 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-# before running the qc, need to rename various output files
-import os, string, time
-from galaxy import datatypes
-from galaxy import app
-import galaxy.util
-
-#Provides Upload tool with access to list of available builds
-repospath = '/usr/local/galaxy/data/rg'
-builds = []
-#Read build names and keys from galaxy.util
-for dbkey, build_name in galaxy.util.dbnames:
- builds.append((build_name,dbkey,False))
-
-def timenow():
- """return current time as a string
- """
- return time.strftime('%d/%m/%Y %H:%M:%S', time.localtime(time.time()))
-
-#Return available builds
-def get_available_builds(defval='hg18'):
- for i,x in enumerate(builds):
- if x[1] == defval:
- x = list(x)
- x[2] = True
- builds[i] = tuple(x)
- return builds
-
-# Create link to files here
-def exec_after_process(app, inp_data, out_data, param_dict, tool, stdout, stderr):
- base_name = param_dict.get( 'title1', 'Null_Phenotype' )
- base_name = base_name.encode()
- info = 'Null phenotypes created by rgfakePhe at %s' % timenow()
- s = string.whitespace + string.punctuation
- ptran = string.maketrans(s,'_'*len(s))
- base_name = base_name.translate(ptran)
- data = out_data['ppheout']
- data.name = '%s.phe' % (base_name) # that's how they've been named in rgfakePhe.py
- #data.file_name = data.file_name
- data.metadata.base_name = base_name
- out_data['pheout'] = data
- app.model.context.flush()
-
-
-
-
-
--- a/tools/rgenetics/rgutils.py Thu Mar 24 20:29:40 2011 -0400
+++ b/tools/rgenetics/rgutils.py Fri Mar 25 13:12:21 2011 -0400
@@ -5,6 +5,7 @@
#
import subprocess, os, sys, time, tempfile,string,plinkbinJZ
+import datetime
galhtmlprefix = """<?xml version="1.0" encoding="utf-8" ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@@ -30,6 +31,9 @@
"""
return time.strftime('%d/%m/%Y %H:%M:%S', time.localtime(time.time()))
+def timestamp():
+ return datetime.datetime.now().strftime('%Y%m%d%H%M%S')
+
def fail( message ):
print >> sys.stderr, message
return -1
@@ -41,6 +45,401 @@
return os.path.join(path, program)
return None
+def makeGFF(resf='',outfname='',logf=None,twd='.',name='track name',description='track description',topn=1000,pname='LOG10ARMITAGEP',rgname='rgGLM'):
+ """
+ score must be scaled to 0-1000
+
+ Want to make some wig tracks from each analysis
+ Best n -log10(p). Make top hit the window.
+ we use our tab output which has
+ rs chrom offset ADD_stat ADD_p ADD_log10p
+ rs3094315 1 792429 1.151 0.2528 0.597223
+
+ """
+
+ def is_number(s):
+ try:
+ float(s)
+ return True
+ except ValueError:
+ return False
+ header = 'track name=%s description="%s" visibility=2 useScore=1 color=0,60,120\n' % (name,description)
+ column_names = [ 'Seqname', 'Source', 'Feature', 'Start', 'End', 'Score', 'Strand', 'Frame', 'Group' ]
+ halfwidth=100
+ resfpath = os.path.join(twd,resf)
+ resf = open(resfpath,'r')
+ resfl = resf.readlines() # dumb but convenient for millions of rows
+ resfl = [x.split() for x in resfl]
+ headl = resfl[0]
+ resfl = resfl[1:]
+ headl = [x.strip().upper() for x in headl]
+ headIndex = dict(zip(headl,range(0,len(headl))))
+ chrpos = headIndex.get('CHROM',None)
+ rspos = headIndex.get('RS',None)
+ offspos = headIndex.get('OFFSET',None)
+ ppos = headIndex.get(pname,None)
+ wewant = [chrpos,rspos,offspos,ppos]
+ if None in wewant: # missing something
+ logf.write('### Error missing a required header in makeGFF - headIndex=%s, wewant=%s\n' % (headIndex,wewant))
+ return
+ resfl = [x for x in resfl if x[ppos] > '']
+ resfl = [(float(x[ppos]),x) for x in resfl] # decorate
+ resfl.sort()
+ resfl.reverse() # using -log10 so larger is better
+ resfl = resfl[:topn] # truncate
+ pvals = [x[0] for x in resfl] # need to scale
+ resfl = [x[1] for x in resfl] # drop decoration
+ if len(pvals) == 0:
+ logf.write('### no pvalues found in resfl - %s' % (resfl[:3]))
+ sys.exit(1)
+ maxp = max(pvals) # need to scale
+ minp = min(pvals)
+ prange = abs(maxp-minp) + 0.5 # fudge
+ scalefact = 1000.0/prange
+ logf.write('###maxp=%f,minp=%f,prange=%f,scalefact=%f\n' % (maxp,minp,prange,scalefact))
+ for i,row in enumerate(resfl):
+ row[ppos] = '%d' % (int(scalefact*pvals[i]))
+ resfl[i] = row # replace
+ outf = file(outfname,'w')
+ outf.write(header)
+ outres = [] # need to resort into chrom offset order
+ for i,lrow in enumerate(resfl):
+ chrom,snp,offset,p, = [lrow[x] for x in wewant]
+ gff = ('chr%s' % chrom,rgname,'variation','%d' % (int(offset)-halfwidth),
+ '%d' % (int(offset)+halfwidth),p,'.','.','%s logp=%1.2f' % (snp,pvals[i]))
+ outres.append(gff)
+ outres = [(x[0],int(x[3]),x) for x in outres] # decorate
+ outres.sort() # into chrom offset
+ outres=[x[2] for x in outres] # undecorate
+ outres = ['\t'.join(x) for x in outres]
+ outf.write('\n'.join(outres))
+ outf.write('\n')
+ outf.close()
+
+
+def bedToPicInterval(infile=None):
+ """
+ Picard tools requiring targets want
+ a sam style header which incidentally, MUST be sorted in natural order - not lexicographic order:
+
+ @SQ SN:chrM LN:16571
+ @SQ SN:chr1 LN:247249719
+ @SQ SN:chr2 LN:242951149
+ @SQ SN:chr3 LN:199501827
+ @SQ SN:chr4 LN:191273063
+ added to the start of what looks like a bed style file
+ chr1 67052400 67052451 - CCDS635.1_cds_0_0_chr1_67052401_r
+ chr1 67060631 67060788 - CCDS635.1_cds_1_0_chr1_67060632_r
+ chr1 67065090 67065317 - CCDS635.1_cds_2_0_chr1_67065091_r
+ chr1 67066082 67066181 - CCDS635.1_cds_3_0_chr1_67066083_r
+
+ see http://genome.ucsc.edu/FAQ/FAQtracks.html#tracks1
+ we need to add 1 to start coordinates on the way through - but length calculations are easier
+ """
+ # bedToPicard.py
+ # ross lazarus October 2010
+ # LGPL
+ # for Rgenetics
+
+ def getFlen(bedfname=None):
+ """
+ find all features in a BED file and sum their lengths
+ """
+ features = {}
+ try:
+ infile = open(bedfname,'r')
+ except:
+ print '###ERROR: getFlen unable to open bedfile %s' % bedfname
+ sys.exit(1)
+ for i,row in enumerate(infile):
+ if row[0] == '@': # shouldn't happen given a bed file!
+ print 'row %d=%s - should NOT start with @!' % (i,row)
+ sys.exit(1)
+ row = row.strip()
+ if len(row) > 0:
+ srow = row.split('\t')
+ f = srow[0]
+ spos = srow[1] # zero based from UCSC so no need to add 1 - eg 0-100 is 100 bases numbered 0-99 (!)
+ epos = srow[2] # see http://genome.ucsc.edu/FAQ/FAQtracks.html#tracks1
+ flen = int(epos) - int(spos)
+ features.setdefault(f,0)
+ features[f] += flen
+ infile.close()
+ return features
+
+ def keynat(string):
+ '''
+ borrowed from http://code.activestate.com/recipes/285264-natural-string-sorting/
+ A natural sort helper function for sort() and sorted()
+ without using regular expressions or exceptions.
+
+ >>> items = ('Z', 'a', '10th', '1st', '9')
+ >>> sorted(items)
+ ['10th', '1st', '9', 'Z', 'a']
+ >>> sorted(items, key=keynat)
+ ['1st', '9', '10th', 'a', 'Z']
+ '''
+ it = type(1)
+ r = []
+ for c in string:
+ if c.isdigit():
+ d = int(c)
+ if r and type( r[-1] ) == it:
+ r[-1] = r[-1] * 10 + d
+ else:
+ r.append(d)
+ else:
+ r.append(c.lower())
+ return r
+
+ def writePic(outfname=None,bedfname=None):
+ """
+ collect header info and rewrite bed with header for picard
+ """
+ featlen = getFlen(bedfname=bedfname)
+ try:
+ outf = open(outfname,'w')
+ except:
+ print '###ERROR: writePic unable to open output picard file %s' % outfname
+ sys.exit(1)
+ infile = open(bedfname,'r') # already tested in getFlen
+ k = featlen.keys()
+ fk = sorted(k, key=keynat)
+ header = ['@SQ\tSN:%s\tLN:%d' % (x,featlen[x]) for x in fk]
+ outf.write('\n'.join(header))
+ outf.write('\n')
+ for row in infile:
+ row = row.strip()
+ if len(row) > 0: # convert zero based start coordinate to 1 based
+ srow = row.split('\t')
+ srow[1] = '%d' % (int(srow[1])+1) # see http://genome.ucsc.edu/FAQ/FAQtracks.html#tracks1
+ outf.write('\t'.join(srow))
+ outf.write('\n')
+ outf.close()
+ infile.close()
+
+
+
+ # bedToPicInterval starts here
+ fd,outf = tempfile.mkstemp(prefix='rgPicardHsMetrics')
+ writePic(outfname=outf,bedfname=infile)
+ return outf
+
+
+def getFileString(fpath, outpath):
+ """
+ format a nice file size string
+ """
+ size = ''
+ fp = os.path.join(outpath, fpath)
+ s = '? ?'
+ if os.path.isfile(fp):
+ n = float(os.path.getsize(fp))
+ if n > 2**20:
+ size = ' (%1.1f MB)' % (n/2**20)
+ elif n > 2**10:
+ size = ' (%1.1f KB)' % (n/2**10)
+ elif n > 0:
+ size = ' (%d B)' % (int(n))
+ s = '%s %s' % (fpath, size)
+ return s
+
+
+def fixPicardOutputs(tempout=None,output_dir=None,log_file=None,html_output=None,progname=None,cl=[],transpose=True):
+ """
+ picard produces long hard to read tab header files
+ make them available but present them transposed for readability
+ """
+ rstyle="""<style type="text/css">
+ tr.d0 td {background-color: oldlace; color: black;}
+ tr.d1 td {background-color: aliceblue; color: black;}
+ </style>"""
+ cruft = []
+ dat = []
+ try:
+ r = open(tempout,'r').readlines()
+ except:
+ r = []
+ for row in r:
+ if row.strip() > '':
+ srow = row.split('\t')
+ if row[0] == '#':
+ cruft.append(row.strip()) # want strings
+ else:
+ dat.append(srow) # want lists
+
+ res = [rstyle,]
+ res.append(galhtmlprefix % progname)
+ res.append(galhtmlattr % (progname,timenow()))
+ flist = os.listdir(output_dir)
+ pdflist = [x for x in flist if os.path.splitext(x)[-1].lower() == '.pdf']
+ if len(pdflist) > 0: # assumes all pdfs come with thumbnail .jpgs
+ for p in pdflist:
+ imghref = '%s.jpg' % os.path.splitext(p)[0] # removes .pdf
+ res.append('<table cellpadding="10"><tr><td>\n')
+ res.append('<a href="%s"><img src="%s" alt="Click thumbnail to download %s" hspace="10" align="middle"></a>\n' % (p,imghref,p))
+ res.append('</tr></td></table>\n')
+ res.append('<b>Your job produced the following output files.</b><hr/>\n')
+ res.append('<table>\n')
+ for i,f in enumerate(flist):
+ fn = os.path.split(f)[-1]
+ res.append('<tr><td><a href="%s">%s</a></td></tr>\n' % (fn,fn))
+ res.append('</table><p/>\n')
+ if len(cruft) + len(dat) > 0:
+ res.append('<b>Picard on line resources</b><ul>\n')
+ res.append('<li><a href="http://picard.sourceforge.net/index.shtml">Click here for Picard Documentation</a></li>\n')
+ res.append('<li><a href="http://picard.sourceforge.net/picard-metric-definitions.shtml">Click here for Picard Metrics definitions</a></li></ul><hr/>\n')
+ if transpose:
+ res.append('<b>Picard output (transposed for readability)</b><hr/>\n')
+ else:
+ res.append('<b>Picard output</b><hr/>\n')
+ res.append('<table cellpadding="3" >\n')
+ if len(cruft) > 0:
+ cres = ['<tr class="d%d"><td>%s</td></tr>' % (i % 2,x) for i,x in enumerate(cruft)]
+ res += cres
+ if len(dat) > 0:
+ maxrows = 100
+ if transpose:
+ tdat = map(None,*dat) # transpose an arbitrary list of lists
+ missing = len(tdat) - maxrows
+ tdat = ['<tr class="d%d"><td>%s</td><td>%s</td></tr>\n' % ((i+len(cruft)) % 2,x[0],x[1]) for i,x in enumerate(tdat) if i < maxrows]
+ if len(tdat) > maxrows:
+ tdat.append('<tr><td colspan="2">...WARNING: %d rows deleted for sanity...see raw files for all rows</td></tr>' % missing)
+ else:
+ tdat = ['<tr class="d%d"><td>%s</td></tr>\n' % ((i+len(cruft)) % 2,x) for i,x in enumerate(dat) if i < maxrows]
+ if len(dat) > maxrows:
+ missing = len(dat) - maxrows
+ tdat.append('<tr><td>...WARNING: %d rows deleted for sanity...see raw files for all rows</td></tr>' % missing)
+ res += tdat
+ res.append('</table>\n')
+ else:
+ res.append('<b>No Picard output found - please consult the Picard log above for an explanation</b>')
+ l = open(log_file,'r').readlines()
+ if len(l) > 0:
+ res.append('<b>Picard log</b><hr/>\n')
+ rlog = ['<pre>',]
+ rlog += l
+ rlog.append('</pre>')
+ res += rlog
+ else:
+ res.append("Odd, Picard left no log file %s - must have really barfed badly?" % log_file)
+ res.append('<hr/>The freely available <a href="http://picard.sourceforge.net/command-line-overview.shtml">Picard software</a> \n')
+ res.append( 'generated all outputs reported here, using this command line:<br/>\n<pre>%s</pre>\n' % ''.join(cl))
+ res.append(galhtmlpostfix)
+ outf = open(html_output,'w')
+ outf.write(''.join(res))
+ outf.write('\n')
+ outf.close()
+
+def keynat(string):
+ '''
+ borrowed from http://code.activestate.com/recipes/285264-natural-string-sorting/
+ A natural sort helper function for sort() and sorted()
+ without using regular expressions or exceptions.
+
+ >>> items = ('Z', 'a', '10th', '1st', '9')
+ >>> sorted(items)
+ ['10th', '1st', '9', 'Z', 'a']
+ >>> sorted(items, key=keynat)
+ ['1st', '9', '10th', 'a', 'Z']
+ '''
+ it = type(1)
+ r = []
+ for c in string:
+ if c.isdigit():
+ d = int(c)
+ if r and type( r[-1] ) == it:
+ r[-1] = r[-1] * 10 + d
+ else:
+ r.append(d)
+ else:
+ r.append(c.lower())
+ return r
+
+def getFlen(bedfname=None):
+ """
+ find all features in a BED file and sum their lengths
+ """
+ features = {}
+ otherHeaders = []
+ try:
+ infile = open(bedfname,'r')
+ except:
+ print '###ERROR: getFlen unable to open bedfile %s' % bedfname
+ sys.exit(1)
+ for i,row in enumerate(infile):
+ if row.startswith('@'): # add to headers if not @SQ
+ if not row.startswith('@SQ'):
+ otherHeaders.append(row)
+ else:
+ row = row.strip()
+ if row.startswith('#') or row.lower().startswith('browser') or row.lower().startswith('track'):
+ continue # ignore headers
+ srow = row.split('\t')
+ if len(srow) > 3:
+ srow = row.split('\t')
+ f = srow[0]
+ spos = srow[1] # zero based from UCSC so no need to add 1 - eg 0-100 is 100 bases numbered 0-99 (!)
+ epos = srow[2] # see http://genome.ucsc.edu/FAQ/FAQtracks.html#tracks1
+ flen = int(epos) - int(spos)
+ features.setdefault(f,0)
+ features[f] += flen
+ infile.close()
+ fk = features.keys()
+ fk = sorted(fk, key=keynat)
+ return features,fk,otherHeaders
+
+def bedToPicInterval(infile=None,outfile=None):
+ """
+ Picard tools requiring targets want
+ a sam style header which incidentally, MUST be sorted in natural order - not lexicographic order:
+
+ @SQ SN:chrM LN:16571
+ @SQ SN:chr1 LN:247249719
+ @SQ SN:chr2 LN:242951149
+ @SQ SN:chr3 LN:199501827
+ @SQ SN:chr4 LN:191273063
+ added to the start of what looks like a bed style file
+ chr1 67052400 67052451 - CCDS635.1_cds_0_0_chr1_67052401_r
+ chr1 67060631 67060788 - CCDS635.1_cds_1_0_chr1_67060632_r
+ chr1 67065090 67065317 - CCDS635.1_cds_2_0_chr1_67065091_r
+ chr1 67066082 67066181 - CCDS635.1_cds_3_0_chr1_67066083_r
+
+ see http://genome.ucsc.edu/FAQ/FAQtracks.html#tracks1
+ we need to add 1 to start coordinates on the way through - but length calculations are easier
+ """
+ # bedToPicard.py
+ # ross lazarus October 2010
+ # LGPL
+ # for Rgenetics
+ """
+ collect header info and rewrite bed with header for picard
+ """
+ featlen,fk,otherHeaders = getFlen(bedfname=infile)
+ try:
+ outf = open(outfile,'w')
+ except:
+ print '###ERROR: writePic unable to open output picard file %s' % outfile
+ sys.exit(1)
+ inf = open(infile,'r') # already tested in getFlen
+ header = ['@SQ\tSN:%s\tLN:%d' % (x,featlen[x]) for x in fk]
+ if len(otherHeaders) > 0:
+ header += otherHeaders
+ outf.write('\n'.join(header))
+ outf.write('\n')
+ for row in inf:
+ row = row.strip()
+ if len(row) > 0: # convert zero based start coordinate to 1 based
+ if row.startswith('@'):
+ continue
+ else:
+ srow = row.split('\t')
+ srow[1] = '%d' % (int(srow[1])+1) # see http://genome.ucsc.edu/FAQ/FAQtracks.html#tracks1
+ outf.write('\t'.join(srow))
+ outf.write('\n')
+ outf.close()
+ inf.close()
+
def oRRun(rcmd=[],outdir=None,title='myR',rexe='R'):
"""
@@ -201,9 +600,12 @@
The fine Plink docs at http://pngu.mgh.harvard.edu/~purcell/plink/summary.shtml#prune
reproduced below
-Sometimes it is useful to generate a pruned subset of SNPs that are in approximate linkage equilibrium with each other. This can be achieved via two commands: --indep which prunes based on the variance inflation factor (VIF), which recursively removes SNPs within a sliding window; second, --indep-pairwise which is similar, except it is based only on pairwise genotypic correlation.
+Sometimes it is useful to generate a pruned subset of SNPs that are in approximate linkage equilibrium with each other. This can be achieved via two commands:
+--indep which prunes based on the variance inflation factor (VIF), which recursively removes SNPs within a sliding window; second, --indep-pairwise which is
+similar, except it is based only on pairwise genotypic correlation.
-Hint The output of either of these commands is two lists of SNPs: those that are pruned out and those that are not. A separate command using the --extract or --exclude option is necessary to actually perform the pruning.
+Hint The output of either of these commands is two lists of SNPs: those that are pruned out and those that are not. A separate command using the --extract or
+--exclude option is necessary to actually perform the pruning.
The VIF pruning routine is performed:
plink --file data --indep 50 5 2
@@ -217,16 +619,23 @@
a --extract or --exclude command.
The parameters for --indep are: window size in SNPs (e.g. 50), the number of SNPs to shift the
-window at each step (e.g. 5), the VIF threshold. The VIF is 1/(1-R^2) where R^2 is the multiple correlation coefficient for a SNP being regressed on all other SNPs simultaneously. That is, this considers the correlations between SNPs but also between linear combinations of SNPs. A VIF of 10 is often taken to represent near collinearity problems in standard multiple regression analyses (i.e. implies R^2 of 0.9). A VIF of 1 would imply that the SNP is completely independent of all other SNPs. Practically, values between 1.5 and 2 should probably be used; particularly in small samples, if this threshold is too low and/or the window size is too large, too many SNPs may be removed.
+window at each step (e.g. 5), the VIF threshold. The VIF is 1/(1-R^2) where R^2 is the multiple correlation coefficient for a SNP being regressed on all other
+SNPs simultaneously. That is, this considers the correlations between SNPs but also between linear combinations of SNPs. A VIF of 10 is often taken to represent
+near collinearity problems in standard multiple regression analyses (i.e. implies R^2 of 0.9). A VIF of 1 would imply that the SNP is completely independent of
+all other SNPs. Practically, values between 1.5 and 2 should probably be used; particularly in small samples, if this threshold is too low and/or the window
+size is too large, too many SNPs may be removed.
The second procedure is performed:
plink --file data --indep-pairwise 50 5 0.5
This generates the same output files as the first version; the only difference is that a
-simple pairwise threshold is used. The first two parameters (50 and 5) are the same as above (window size and step); the third parameter represents the r^2 threshold. Note: this represents the pairwise SNP-SNP metric now, not the multiple correlation coefficient; also note, this is based on the genotypic correlation, i.e. it does not involve phasing.
+simple pairwise threshold is used. The first two parameters (50 and 5) are the same as above (window size and step); the third parameter represents the r^2
+threshold. Note: this represents the pairwise SNP-SNP metric now, not the multiple correlation coefficient; also note, this is based on the genotypic
+correlation, i.e. it does not involve phasing.
To give a concrete example: the command above that specifies 50 5 0.5 would a) consider a
-window of 50 SNPs, b) calculate LD between each pair of SNPs in the window, b) remove one of a pair of SNPs if the LD is greater than 0.5, c) shift the window 5 SNPs forward and repeat the procedure.
+window of 50 SNPs, b) calculate LD between each pair of SNPs in the window, b) remove one of a pair of SNPs if the LD is greater than 0.5, c) shift the window 5
+SNPs forward and repeat the procedure.
To make a new, pruned file, then use something like (in this example, we also convert the
standard PED fileset to a binary one):
@@ -276,3 +685,4 @@
mfile.close()
return markers,snpcols,rslist,rsdict
+
http://bitbucket.org/galaxy/galaxy-central/changeset/a892beeb00b4/
changeset: r5275:a892beeb00b4
user: fubar
date: 2011-03-25 18:21:13
summary: Remove bogus makeGFF from rgutils
affected #: 1 file (2.9 KB)
--- a/tools/rgenetics/rgutils.py Fri Mar 25 13:12:21 2011 -0400
+++ b/tools/rgenetics/rgutils.py Fri Mar 25 13:21:13 2011 -0400
@@ -45,77 +45,6 @@
return os.path.join(path, program)
return None
-def makeGFF(resf='',outfname='',logf=None,twd='.',name='track name',description='track description',topn=1000,pname='LOG10ARMITAGEP',rgname='rgGLM'):
- """
- score must be scaled to 0-1000
-
- Want to make some wig tracks from each analysis
- Best n -log10(p). Make top hit the window.
- we use our tab output which has
- rs chrom offset ADD_stat ADD_p ADD_log10p
- rs3094315 1 792429 1.151 0.2528 0.597223
-
- """
-
- def is_number(s):
- try:
- float(s)
- return True
- except ValueError:
- return False
- header = 'track name=%s description="%s" visibility=2 useScore=1 color=0,60,120\n' % (name,description)
- column_names = [ 'Seqname', 'Source', 'Feature', 'Start', 'End', 'Score', 'Strand', 'Frame', 'Group' ]
- halfwidth=100
- resfpath = os.path.join(twd,resf)
- resf = open(resfpath,'r')
- resfl = resf.readlines() # dumb but convenient for millions of rows
- resfl = [x.split() for x in resfl]
- headl = resfl[0]
- resfl = resfl[1:]
- headl = [x.strip().upper() for x in headl]
- headIndex = dict(zip(headl,range(0,len(headl))))
- chrpos = headIndex.get('CHROM',None)
- rspos = headIndex.get('RS',None)
- offspos = headIndex.get('OFFSET',None)
- ppos = headIndex.get(pname,None)
- wewant = [chrpos,rspos,offspos,ppos]
- if None in wewant: # missing something
- logf.write('### Error missing a required header in makeGFF - headIndex=%s, wewant=%s\n' % (headIndex,wewant))
- return
- resfl = [x for x in resfl if x[ppos] > '']
- resfl = [(float(x[ppos]),x) for x in resfl] # decorate
- resfl.sort()
- resfl.reverse() # using -log10 so larger is better
- resfl = resfl[:topn] # truncate
- pvals = [x[0] for x in resfl] # need to scale
- resfl = [x[1] for x in resfl] # drop decoration
- if len(pvals) == 0:
- logf.write('### no pvalues found in resfl - %s' % (resfl[:3]))
- sys.exit(1)
- maxp = max(pvals) # need to scale
- minp = min(pvals)
- prange = abs(maxp-minp) + 0.5 # fudge
- scalefact = 1000.0/prange
- logf.write('###maxp=%f,minp=%f,prange=%f,scalefact=%f\n' % (maxp,minp,prange,scalefact))
- for i,row in enumerate(resfl):
- row[ppos] = '%d' % (int(scalefact*pvals[i]))
- resfl[i] = row # replace
- outf = file(outfname,'w')
- outf.write(header)
- outres = [] # need to resort into chrom offset order
- for i,lrow in enumerate(resfl):
- chrom,snp,offset,p, = [lrow[x] for x in wewant]
- gff = ('chr%s' % chrom,rgname,'variation','%d' % (int(offset)-halfwidth),
- '%d' % (int(offset)+halfwidth),p,'.','.','%s logp=%1.2f' % (snp,pvals[i]))
- outres.append(gff)
- outres = [(x[0],int(x[3]),x) for x in outres] # decorate
- outres.sort() # into chrom offset
- outres=[x[2] for x in outres] # undecorate
- outres = ['\t'.join(x) for x in outres]
- outf.write('\n'.join(outres))
- outf.write('\n')
- outf.close()
-
def bedToPicInterval(infile=None):
"""
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/galaxy-central: jgoecks: Add selected attribute to default value for Tophat coverage search.
by Bitbucket 24 Mar '11
by Bitbucket 24 Mar '11
24 Mar '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/8edb38ab1afb/
changeset: r5273:8edb38ab1afb
user: jgoecks
date: 2011-03-25 01:29:40
summary: Add selected attribute to default value for Tophat coverage search.
affected #: 1 file (32 bytes)
--- a/tools/ngs_rna/tophat_wrapper.xml Thu Mar 24 18:26:29 2011 -0400
+++ b/tools/ngs_rna/tophat_wrapper.xml Thu Mar 24 20:29:40 2011 -0400
@@ -251,7 +251,7 @@
<!-- Coverage search. --><conditional name="coverage_search"><param name="use_search" type="select" label="Use Coverage Search">
- <option value="Yes">Yes</option>
+ <option selected="true" value="Yes">Yes</option><option value="No">No</option></param><when value="Yes">
@@ -357,7 +357,7 @@
<!-- Coverage search. --><conditional name="coverage_search"><param name="use_search" type="select" label="Use Coverage Search">
- <option value="Yes">Yes</option>
+ <option selected="true" value="Yes">Yes</option><option value="No">No</option></param><when value="Yes">
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/f2f29d55493e/
changeset: r5272:f2f29d55493e
user: kanwei
date: 2011-03-24 23:26:29
summary: UI Tweaks and fixes:
- View details icon no longer tooltip; it now links to a page
- Restore folder icon to data libraries
- Make popupmenu link boxes smaller so that link clickthroughs don't activate popup as easily
- Make popupmenu initial position lower after click
affected #: 9 files (254 bytes)
--- a/static/june_2007_style/base.css.tmpl Thu Mar 24 17:36:06 2011 -0400
+++ b/static/june_2007_style/base.css.tmpl Thu Mar 24 18:26:29 2011 -0400
@@ -326,40 +326,40 @@
}
table.simple {
- font-size: 12px;
- background: #fff;
- margin: 1em;
- border-collapse: collapse;
- text-align: left;
+ font-size: 12px;
+ background: #fff;
+ margin: 1em;
+ border-collapse: collapse;
+ text-align: left;
}
table.simple th {
- font-size: 14px;
- font-weight: normal;
- padding: 10px 8px;
- border-bottom: 2px solid #333;
+ font-size: 14px;
+ font-weight: normal;
+ padding: 10px 8px;
+ border-bottom: 2px solid #333;
}
table.simple td {
- padding: 10px 8px 0px 8px;
+ padding: 10px 8px 0px 8px;
}
table.simple tbody tr:hover td {
- color: #333;
+ color: #333;
}
table.tabletip {
width: 100%;
- border-collapse: collapse;
- text-align: left;
+ border-collapse: collapse;
+ text-align: left;
}
table.tabletip th {
white-space: nowrap;
- border-bottom: 1px solid #444;
- padding-right: 3px;
+ border-bottom: 1px solid #444;
+ padding-right: 3px;
}
table.tabletip td {
- border-bottom: 1px solid #444;
+ border-bottom: 1px solid #ddd;
}
table.tabletip tbody tr:hover td {
- background-color: #111;
+ background-color: #eee;
}
table.colored {
@@ -576,12 +576,12 @@
.unselectable;
border: solid transparent 1px;
- -moz-border-radius: 0.5em;
- -webkit-border-radius: 0.5em;
- border-radius: 0.5em;
+ -moz-border-radius: 0.25em;
+ -webkit-border-radius: 0.25em;
+ border-radius: 0.25em;
- padding: 3px 0.5em;
- margin: -3px -0.5em;
+ padding: 1px 0.25em;
+ margin: -1px -0.25em;
.label {
position: relative;
@@ -598,7 +598,7 @@
padding-right: 20px;
background-image: url(../images/dropdownarrow.png);
background-repeat: no-repeat;
- background-position: right 8px;
+ background-position: right 7px;
}
.menubutton:hover {
@@ -615,7 +615,7 @@
}
.menubutton.popup.split:hover {
- background: url(../images/ddarrowsplit.png) no-repeat right -38px;
+ background: url(../images/ddarrowsplit.png) no-repeat right -39px;
}
## Popup menu styles
--- a/static/june_2007_style/blue/base.css Thu Mar 24 17:36:06 2011 -0400
+++ b/static/june_2007_style/blue/base.css Thu Mar 24 18:26:29 2011 -0400
@@ -64,8 +64,8 @@
table.simple tbody tr:hover td{color:#333;}
table.tabletip{width:100%;border-collapse:collapse;text-align:left;}
table.tabletip th{white-space:nowrap;border-bottom:1px solid #444;padding-right:3px;}
-table.tabletip td{border-bottom:1px solid #444;}
-table.tabletip tbody tr:hover td{background-color:#111;}
+table.tabletip td{border-bottom:1px solid #ddd;}
+table.tabletip tbody tr:hover td{background-color:#eee;}
table.colored{border-top:solid #d8b365 1px;border-bottom:solid #d8b365 1px;}
table.colored td,table.colored th{text-align:left;padding:5px;}
table.colored tr.header{background:#ebd9b2;background-image:url(form_title_bg.png);background-repeat:repeat-x;background-position:top;border-bottom:solid #d8b365 1px;font-weight:bold;}
@@ -103,13 +103,13 @@
.action-button > *{vertical-align:middle;}
.action-button:hover{color:black;background:#dddddd;}
.action-button:active{color:white;background:#aaaaaa;}
-.menubutton{display:inline-block;cursor:pointer;position:relative;user-select:none;-moz-user-select:none;-webkit-user-select:none;border:solid transparent 1px;-moz-border-radius:0.5em;-webkit-border-radius:0.5em;border-radius:0.5em;padding:3px 0.5em;margin:-3px -0.5em;}
+.menubutton{display:inline-block;cursor:pointer;position:relative;user-select:none;-moz-user-select:none;-webkit-user-select:none;border:solid transparent 1px;-moz-border-radius:0.25em;-webkit-border-radius:0.25em;border-radius:0.25em;padding:1px 0.25em;margin:-1px -0.25em;}
.menubutton .label{position:relative;display:block;border-right:none;}
.menubutton.action-button{border-color:#aaaaaa;}
-.menubutton.popup,.action-button.popup{padding-right:20px;background-image:url(../images/dropdownarrow.png);background-repeat:no-repeat;background-position:right 8px;}
+.menubutton.popup,.action-button.popup{padding-right:20px;background-image:url(../images/dropdownarrow.png);background-repeat:no-repeat;background-position:right 7px;}
.menubutton:hover{border-color:#aaaaaa;}
.menubutton.popup.split{padding-right:2em;}
-.menubutton.popup.split:hover{background:url(../images/ddarrowsplit.png) no-repeat right -38px;}
+.menubutton.popup.split:hover{background:url(../images/ddarrowsplit.png) no-repeat right -39px;}
.overlay-border{position:absolute;top:0;left:0;height:100%;width:100%;padding:1em;margin:-1em;background-color:rgba(0,0,0,0.5);-moz-border-radius:1em;-webkit-border-radius:1em;z-index:-1;}
div.popmenu-wrapper{position:absolute;top:100%;z-index:20000;}
div.popmenu-wrapper ul{display:block;margin:0;padding:0;background:white;color:#333;font-weight:bold;font-style:normal;white-space:nowrap;border:solid #aaaaaa 1px;padding:3px 0;-moz-border-radius:0.5em;-webkit-border-radius:0.5em;border-radius:0.5em;user-select:none;-moz-user-select:none;-webkit-user-select:none;}
--- a/static/june_2007_style/blue/library.css Thu Mar 24 17:36:06 2011 -0400
+++ b/static/june_2007_style/blue/library.css Thu Mar 24 18:26:29 2011 -0400
@@ -11,9 +11,9 @@
.libraryTitle th{text-align:left;}
pre.peek{background:white;color:black;width:100%;overflow:auto;}
pre.peek th{color:white;background:#023858;}
-span.expandLink{padding-left:20px;display:inline-block;vertical-align:middle;background:url(../images/silk/resultset_next.png) no-repeat;}
+span.expandLink{padding-left:12px;display:inline-block;vertical-align:middle;background:url(../images/silk/resultset_next.png) no-repeat;}
.folderRow.expanded span.expandLink{background:url(../images/silk/resultset_bottom.png) no-repeat;}
-.folderRow span.rowIcon{float:left;width:16px;height:16px;display:inline-block;vertical-align:middle;background:url(../images/silk/folder.png);}
+.folderRow span.rowIcon{float:left;margin-right:5px;width:16px;height:16px;display:inline-block;vertical-align:middle;background:url(../images/silk/folder.png);}
.libraryItem-error{margin-right:2px;padding:0 2px 0 2px;border:1px solid #AA6666;background:#FFCCCC;}
.libraryItem-queued{margin-right:2px;padding:0 2px 0 2px;border:1px solid #888888;background:#EEEEEE;}
.libraryItem-running{margin-right:2px;padding:0 2px 0 2px;border:1px solid #AAAA66;background:#FFFFCC;}
--- a/static/june_2007_style/library.css.tmpl Thu Mar 24 17:36:06 2011 -0400
+++ b/static/june_2007_style/library.css.tmpl Thu Mar 24 18:26:29 2011 -0400
@@ -31,14 +31,12 @@
}
input.datasetCheckbox,
-li, ul
-{
+li, ul {
padding: 0;
margin: 0;
}
-.rowTitle
-{
+.rowTitle {
padding: 2px;
}
@@ -50,22 +48,20 @@
text-align: left;
}
-pre.peek
-{
+pre.peek {
background: white;
color: black;
width: 100%;
overflow: auto;
}
-pre.peek th
-{
+pre.peek th {
color: white;
background: $peek_table_header;
}
span.expandLink {
- padding-left: 20px;
+ padding-left: 12px;
display: inline-block;
vertical-align: middle;
background: url(../images/silk/resultset_next.png) no-repeat;
@@ -77,6 +73,7 @@
.folderRow span.rowIcon {
float: left;
+ margin-right: 5px;
width: 16px;
height: 16px;
display: inline-block;
--- a/static/scripts/galaxy.base.js Thu Mar 24 17:36:06 2011 -0400
+++ b/static/scripts/galaxy.base.js Thu Mar 24 18:26:29 2011 -0400
@@ -77,7 +77,7 @@
x = Math.max( x, $(document).scrollLeft() + 20 );
wrapper.css( {
- top: e.pageY - 5,
+ top: e.pageY - 15,
left: x
} );
}, 10);
--- a/static/scripts/packed/galaxy.base.js Thu Mar 24 17:36:06 2011 -0400
+++ b/static/scripts/packed/galaxy.base.js Thu Mar 24 18:26:29 2011 -0400
@@ -1,1 +1,1 @@
-if(!Array.indexOf){Array.prototype.indexOf=function(c){for(var b=0,a=this.length;b<a;b++){if(this[b]==c){return b}}return -1}}function obj_length(c){if(c.length!==undefined){return c.length}var b=0;for(var a in c){b++}return b}$.fn.makeAbsolute=function(a){return this.each(function(){var b=$(this);var c=b.position();b.css({position:"absolute",marginLeft:0,marginTop:0,top:c.top,left:c.left,right:$(window).width()-(c.left+b.width())});if(a){b.remove().appendTo("body")}})};function make_popupmenu(b,c){var a=(b.data("menu_options"));b.data("menu_options",c);if(a){return}b.bind("click.show_popup",function(d){$(".popmenu-wrapper").remove();setTimeout(function(){var g=$("<ul id='"+b.attr("id")+"-menu'></ul>");var f=b.data("menu_options");if(obj_length(f)<=0){$("<li>No Options.</li>").appendTo(g)}$.each(f,function(j,i){if(i){$("<li/>").html(j).click(i).appendTo(g)}else{$("<li class='head'/>").html(j).appendTo(g)}});var h=$("<div class='popmenu-wrapper' style='position: absolute;left: 0; top: -1000;'>");h.append(g).append("<div class='overlay-border'>").appendTo("body");var e=d.pageX-h.width()/2;e=Math.min(e,$(document).scrollLeft()+$(window).width()-$(h).width()-20);e=Math.max(e,$(document).scrollLeft()+20);h.css({top:d.pageY-5,left:e})},10);setTimeout(function(){var f=function(h){$(h).bind("click.close_popup",function(){$(".popmenu-wrapper").remove();h.unbind("click.close_popup")})};f($(window.document));f($(window.top.document));for(var e=window.top.frames.length;e--;){var g=$(window.top.frames[e].document);f(g)}},50);return false})}function make_popup_menus(){jQuery("div[popupmenu]").each(function(){var a={};var c=$(this);c.find("a").each(function(){var f=$(this),h=f.get(0);var d=h.getAttribute("confirm"),e=h.getAttribute("href"),g=h.getAttribute("target");if(!e){a[f.text()]=null}else{a[f.text()]=function(){if(!d||confirm(d)){var i;if(g=="_parent"){window.parent.location=e}else{if(g=="_top"){window.top.location=e}else{if(g=="demo"){if(i==undefined||i.closed){i=window.open(e,g);i.creator=self}}else{window.location=e}}}}}}});var b=$("#"+c.attr("popupmenu"));b.find("a").bind("click",function(d){d.stopPropagation();return true});make_popupmenu(b,a);b.addClass("popup");c.remove()})}function naturalSort(j,h){var p=/(-?[0-9\.]+)/g,k=j.toString().toLowerCase()||"",g=h.toString().toLowerCase()||"",l=String.fromCharCode(0),n=k.replace(p,l+"$1"+l).split(l),e=g.replace(p,l+"$1"+l).split(l),d=(new Date(k)).getTime(),o=d?(new Date(g)).getTime():null;if(o){if(d<o){return -1}else{if(d>o){return 1}}}var m,f;for(var i=0,c=Math.max(n.length,e.length);i<c;i++){m=parseFloat(n[i])||n[i];f=parseFloat(e[i])||e[i];if(m<f){return -1}else{if(m>f){return 1}}}return 0}function replace_big_select_inputs(a,b){if(!jQuery().autocomplete){return}if(a===undefined){a=20}if(b===undefined){b=3000}$("select").each(function(){var d=$(this);var g=d.find("option").length;if((g<a)||(g>b)){return}if(d.attr("multiple")===true){return}if(d.hasClass("no-autocomplete")){return}var m=d.attr("value");var c=$("<input type='text' class='text-and-autocomplete-select'></input>");c.attr("size",40);c.attr("name",d.attr("name"));c.attr("id",d.attr("id"));c.click(function(){var n=$(this).val();$(this).val("Loading...");$(this).showAllInCache();$(this).val(n);$(this).select()});var e=[];var i={};d.children("option").each(function(){var o=$(this).text();var n=$(this).attr("value");e.push(o);i[o]=n;i[n]=n;if(n==m){c.attr("value",o)}});if(m===""||m==="?"){c.attr("value","Click to Search or Select")}if(d.attr("name")=="dbkey"){e=e.sort(naturalSort)}var f={selectFirst:false,autoFill:false,mustMatch:false,matchContains:true,max:b,minChars:0,hideForLessThanMinChars:false};c.autocomplete(e,f);d.replaceWith(c);var k=function(){var o=c.attr("value");var n=i[o];if(n!==null&&n!==undefined){c.attr("value",n)}else{if(m!==""){c.attr("value",m)}else{c.attr("value","?")}}};c.parents("form").submit(function(){k()});$(document).bind("convert_to_values",function(){k()});if(d.attr("refresh_on_change")=="true"){var h=d.attr("refresh_on_change_values"),l=d.attr("last_selected_value");if(h!==undefined){h=h.split(",")}var j=function(){var n=i[c.attr("value")];if(l!==n&&n!==null&&n!==undefined){if(h!==undefined&&$.inArray(n,h)===-1&&$.inArray(l,h)===-1){return}c.attr("value",n);$(window).trigger("refresh_on_change");c.parents("form").submit()}};c.bind("result",j);c.keyup(function(n){if(n.keyCode===13){j()}});c.keydown(function(n){if(n.keyCode===13){return false}})}})}function async_save_text(d,f,e,a,c,h,i,g,b){if(c===undefined){c=30}if(i===undefined){i=4}$("#"+d).live("click",function(){if($("#renaming-active").length>0){return}var l=$("#"+f),k=l.text(),j;if(h){j=$("<textarea></textarea>").attr({rows:i,cols:c}).text($.trim(k))}else{j=$("<input type='text'></input>").attr({value:$.trim(k),size:c})}j.attr("id","renaming-active");j.blur(function(){$(this).remove();l.show();if(b){b(j)}});j.keyup(function(n){if(n.keyCode===27){$(this).trigger("blur")}else{if(n.keyCode===13){var m={};m[a]=$(this).val();$(this).trigger("blur");$.ajax({url:e,data:m,error:function(){alert("Text editing for elt "+f+" failed")},success:function(o){if(o!==""){l.text(o)}else{l.html("<em>None</em>")}if(b){b(j)}}})}}});if(g){g(j)}l.hide();j.insertAfter(l);j.focus();j.select();return})}function init_history_items(d,a,c){var b=function(){try{var e=$.jStorage.get("history_expand_state");if(e){for(var g in e){$("#"+g+" div.historyItemBody").show()}}}catch(f){$.jStorage.deleteKey("history_expand_state")}if($.browser.mozilla){$("div.historyItemBody").each(function(){if(!$(this).is(":visible")){$(this).find("pre.peek").css("overflow","hidden")}})}d.each(function(){var j=this.id,h=$(this).children("div.historyItemBody"),i=h.find("pre.peek");$(this).find(".historyItemTitleBar > .historyItemTitle").wrap("<a href='javascript:void(0);'></a>").click(function(){var k;if(h.is(":visible")){if($.browser.mozilla){i.css("overflow","hidden")}h.slideUp("fast");if(!c){k=$.jStorage.get("history_expand_state");if(k){delete k[j];$.jStorage.set("history_expand_state",k)}}}else{h.slideDown("fast",function(){if($.browser.mozilla){i.css("overflow","auto")}});if(!c){k=$.jStorage.get("history_expand_state");if(!k){k={}}k[j]=true;$.jStorage.set("history_expand_state",k)}}return false})});$("#top-links > a.toggle").click(function(){var h=$.jStorage.get("history_expand_state");if(!h){h={}}$("div.historyItemBody:visible").each(function(){if($.browser.mozilla){$(this).find("pre.peek").css("overflow","hidden")}$(this).slideUp("fast");if(h){delete h[$(this).parent().attr("id")]}});$.jStorage.set("history_expand_state",h)}).show()};b()}function commatize(b){b+="";var a=/(\d+)(\d{3})/;while(a.test(b)){b=b.replace(a,"$1,$2")}return b}function reset_tool_search(a){var c=$("#galaxy_tools").contents();if(c.length===0){c=$(document)}$(this).removeClass("search_active");c.find(".toolTitle").removeClass("search_match");c.find(".toolSectionBody").hide();c.find(".toolTitle").show();c.find(".toolPanelLabel").show();c.find(".toolSectionWrapper").each(function(){if($(this).attr("id")!="recently_used_wrapper"){$(this).show()}else{if($(this).hasClass("user_pref_visible")){$(this).show()}}});c.find("#search-no-results").hide();c.find("#search-spinner").hide();if(a){var b=c.find("#tool-search-query");b.val("search tools");b.css("font-style","italic")}}var GalaxyAsync=function(a){this.url_dict={};this.log_action=(a===undefined?false:a)};GalaxyAsync.prototype.set_func_url=function(a,b){this.url_dict[a]=b};GalaxyAsync.prototype.set_user_pref=function(a,b){var c=this.url_dict[arguments.callee];if(c===undefined){return false}$.ajax({url:c,data:{pref_name:a,pref_value:b},error:function(){return false},success:function(){return true}})};GalaxyAsync.prototype.log_user_action=function(c,b,d){if(!this.log_action){return}var a=this.url_dict[arguments.callee];if(a===undefined){return false}$.ajax({url:a,data:{action:c,context:b,params:d},error:function(){return false},success:function(){return true}})};$(document).ready(function(){$("select[refresh_on_change='true']").change(function(){var a=$(this),e=a.val(),d=false,c=a.attr("refresh_on_change_values");if(c){c=c.split(",");var b=a.attr("last_selected_value");if($.inArray(e,c)===-1&&$.inArray(b,c)===-1){return}}$(window).trigger("refresh_on_change");$(document).trigger("convert_to_values");a.get(0).form.submit()});$("a[confirm]").click(function(){return confirm($(this).attr("confirm"))});if($.fn.tipsy){$(".tooltip").tipsy({gravity:"s"})}make_popup_menus();replace_big_select_inputs(20,1500);$("a").click(function(){var b=$(this);var c=(parent.frames&&parent.frames.galaxy_main);if((b.attr("target")=="galaxy_main")&&(!c)){var a=b.attr("href");if(a.indexOf("?")==-1){a+="?"}else{a+="&"}a+="use_panels=True";b.attr("href",a);b.attr("target","_self")}return b})});
\ No newline at end of file
+if(!Array.indexOf){Array.prototype.indexOf=function(c){for(var b=0,a=this.length;b<a;b++){if(this[b]==c){return b}}return -1}}function obj_length(c){if(c.length!==undefined){return c.length}var b=0;for(var a in c){b++}return b}$.fn.makeAbsolute=function(a){return this.each(function(){var b=$(this);var c=b.position();b.css({position:"absolute",marginLeft:0,marginTop:0,top:c.top,left:c.left,right:$(window).width()-(c.left+b.width())});if(a){b.remove().appendTo("body")}})};function make_popupmenu(b,c){var a=(b.data("menu_options"));b.data("menu_options",c);if(a){return}b.bind("click.show_popup",function(d){$(".popmenu-wrapper").remove();setTimeout(function(){var g=$("<ul id='"+b.attr("id")+"-menu'></ul>");var f=b.data("menu_options");if(obj_length(f)<=0){$("<li>No Options.</li>").appendTo(g)}$.each(f,function(j,i){if(i){$("<li/>").html(j).click(i).appendTo(g)}else{$("<li class='head'/>").html(j).appendTo(g)}});var h=$("<div class='popmenu-wrapper' style='position: absolute;left: 0; top: -1000;'>");h.append(g).append("<div class='overlay-border'>").appendTo("body");var e=d.pageX-h.width()/2;e=Math.min(e,$(document).scrollLeft()+$(window).width()-$(h).width()-20);e=Math.max(e,$(document).scrollLeft()+20);h.css({top:d.pageY-15,left:e})},10);setTimeout(function(){var f=function(h){$(h).bind("click.close_popup",function(){$(".popmenu-wrapper").remove();h.unbind("click.close_popup")})};f($(window.document));f($(window.top.document));for(var e=window.top.frames.length;e--;){var g=$(window.top.frames[e].document);f(g)}},50);return false})}function make_popup_menus(){jQuery("div[popupmenu]").each(function(){var a={};var c=$(this);c.find("a").each(function(){var f=$(this),h=f.get(0);var d=h.getAttribute("confirm"),e=h.getAttribute("href"),g=h.getAttribute("target");if(!e){a[f.text()]=null}else{a[f.text()]=function(){if(!d||confirm(d)){var i;if(g=="_parent"){window.parent.location=e}else{if(g=="_top"){window.top.location=e}else{if(g=="demo"){if(i==undefined||i.closed){i=window.open(e,g);i.creator=self}}else{window.location=e}}}}}}});var b=$("#"+c.attr("popupmenu"));b.find("a").bind("click",function(d){d.stopPropagation();return true});make_popupmenu(b,a);b.addClass("popup");c.remove()})}function naturalSort(j,h){var p=/(-?[0-9\.]+)/g,k=j.toString().toLowerCase()||"",g=h.toString().toLowerCase()||"",l=String.fromCharCode(0),n=k.replace(p,l+"$1"+l).split(l),e=g.replace(p,l+"$1"+l).split(l),d=(new Date(k)).getTime(),o=d?(new Date(g)).getTime():null;if(o){if(d<o){return -1}else{if(d>o){return 1}}}var m,f;for(var i=0,c=Math.max(n.length,e.length);i<c;i++){m=parseFloat(n[i])||n[i];f=parseFloat(e[i])||e[i];if(m<f){return -1}else{if(m>f){return 1}}}return 0}function replace_big_select_inputs(a,b){if(!jQuery().autocomplete){return}if(a===undefined){a=20}if(b===undefined){b=3000}$("select").each(function(){var d=$(this);var g=d.find("option").length;if((g<a)||(g>b)){return}if(d.attr("multiple")===true){return}if(d.hasClass("no-autocomplete")){return}var m=d.attr("value");var c=$("<input type='text' class='text-and-autocomplete-select'></input>");c.attr("size",40);c.attr("name",d.attr("name"));c.attr("id",d.attr("id"));c.click(function(){var n=$(this).val();$(this).val("Loading...");$(this).showAllInCache();$(this).val(n);$(this).select()});var e=[];var i={};d.children("option").each(function(){var o=$(this).text();var n=$(this).attr("value");e.push(o);i[o]=n;i[n]=n;if(n==m){c.attr("value",o)}});if(m===""||m==="?"){c.attr("value","Click to Search or Select")}if(d.attr("name")=="dbkey"){e=e.sort(naturalSort)}var f={selectFirst:false,autoFill:false,mustMatch:false,matchContains:true,max:b,minChars:0,hideForLessThanMinChars:false};c.autocomplete(e,f);d.replaceWith(c);var k=function(){var o=c.attr("value");var n=i[o];if(n!==null&&n!==undefined){c.attr("value",n)}else{if(m!==""){c.attr("value",m)}else{c.attr("value","?")}}};c.parents("form").submit(function(){k()});$(document).bind("convert_to_values",function(){k()});if(d.attr("refresh_on_change")=="true"){var h=d.attr("refresh_on_change_values"),l=d.attr("last_selected_value");if(h!==undefined){h=h.split(",")}var j=function(){var n=i[c.attr("value")];if(l!==n&&n!==null&&n!==undefined){if(h!==undefined&&$.inArray(n,h)===-1&&$.inArray(l,h)===-1){return}c.attr("value",n);$(window).trigger("refresh_on_change");c.parents("form").submit()}};c.bind("result",j);c.keyup(function(n){if(n.keyCode===13){j()}});c.keydown(function(n){if(n.keyCode===13){return false}})}})}function async_save_text(d,f,e,a,c,h,i,g,b){if(c===undefined){c=30}if(i===undefined){i=4}$("#"+d).live("click",function(){if($("#renaming-active").length>0){return}var l=$("#"+f),k=l.text(),j;if(h){j=$("<textarea></textarea>").attr({rows:i,cols:c}).text($.trim(k))}else{j=$("<input type='text'></input>").attr({value:$.trim(k),size:c})}j.attr("id","renaming-active");j.blur(function(){$(this).remove();l.show();if(b){b(j)}});j.keyup(function(n){if(n.keyCode===27){$(this).trigger("blur")}else{if(n.keyCode===13){var m={};m[a]=$(this).val();$(this).trigger("blur");$.ajax({url:e,data:m,error:function(){alert("Text editing for elt "+f+" failed")},success:function(o){if(o!==""){l.text(o)}else{l.html("<em>None</em>")}if(b){b(j)}}})}}});if(g){g(j)}l.hide();j.insertAfter(l);j.focus();j.select();return})}function init_history_items(d,a,c){var b=function(){try{var e=$.jStorage.get("history_expand_state");if(e){for(var g in e){$("#"+g+" div.historyItemBody").show()}}}catch(f){$.jStorage.deleteKey("history_expand_state")}if($.browser.mozilla){$("div.historyItemBody").each(function(){if(!$(this).is(":visible")){$(this).find("pre.peek").css("overflow","hidden")}})}d.each(function(){var j=this.id,h=$(this).children("div.historyItemBody"),i=h.find("pre.peek");$(this).find(".historyItemTitleBar > .historyItemTitle").wrap("<a href='javascript:void(0);'></a>").click(function(){var k;if(h.is(":visible")){if($.browser.mozilla){i.css("overflow","hidden")}h.slideUp("fast");if(!c){k=$.jStorage.get("history_expand_state");if(k){delete k[j];$.jStorage.set("history_expand_state",k)}}}else{h.slideDown("fast",function(){if($.browser.mozilla){i.css("overflow","auto")}});if(!c){k=$.jStorage.get("history_expand_state");if(!k){k={}}k[j]=true;$.jStorage.set("history_expand_state",k)}}return false})});$("#top-links > a.toggle").click(function(){var h=$.jStorage.get("history_expand_state");if(!h){h={}}$("div.historyItemBody:visible").each(function(){if($.browser.mozilla){$(this).find("pre.peek").css("overflow","hidden")}$(this).slideUp("fast");if(h){delete h[$(this).parent().attr("id")]}});$.jStorage.set("history_expand_state",h)}).show()};b()}function commatize(b){b+="";var a=/(\d+)(\d{3})/;while(a.test(b)){b=b.replace(a,"$1,$2")}return b}function reset_tool_search(a){var c=$("#galaxy_tools").contents();if(c.length===0){c=$(document)}$(this).removeClass("search_active");c.find(".toolTitle").removeClass("search_match");c.find(".toolSectionBody").hide();c.find(".toolTitle").show();c.find(".toolPanelLabel").show();c.find(".toolSectionWrapper").each(function(){if($(this).attr("id")!="recently_used_wrapper"){$(this).show()}else{if($(this).hasClass("user_pref_visible")){$(this).show()}}});c.find("#search-no-results").hide();c.find("#search-spinner").hide();if(a){var b=c.find("#tool-search-query");b.val("search tools");b.css("font-style","italic")}}var GalaxyAsync=function(a){this.url_dict={};this.log_action=(a===undefined?false:a)};GalaxyAsync.prototype.set_func_url=function(a,b){this.url_dict[a]=b};GalaxyAsync.prototype.set_user_pref=function(a,b){var c=this.url_dict[arguments.callee];if(c===undefined){return false}$.ajax({url:c,data:{pref_name:a,pref_value:b},error:function(){return false},success:function(){return true}})};GalaxyAsync.prototype.log_user_action=function(c,b,d){if(!this.log_action){return}var a=this.url_dict[arguments.callee];if(a===undefined){return false}$.ajax({url:a,data:{action:c,context:b,params:d},error:function(){return false},success:function(){return true}})};$(document).ready(function(){$("select[refresh_on_change='true']").change(function(){var a=$(this),e=a.val(),d=false,c=a.attr("refresh_on_change_values");if(c){c=c.split(",");var b=a.attr("last_selected_value");if($.inArray(e,c)===-1&&$.inArray(b,c)===-1){return}}$(window).trigger("refresh_on_change");$(document).trigger("convert_to_values");a.get(0).form.submit()});$("a[confirm]").click(function(){return confirm($(this).attr("confirm"))});if($.fn.tipsy){$(".tooltip").tipsy({gravity:"s"})}make_popup_menus();replace_big_select_inputs(20,1500);$("a").click(function(){var b=$(this);var c=(parent.frames&&parent.frames.galaxy_main);if((b.attr("target")=="galaxy_main")&&(!c)){var a=b.attr("href");if(a.indexOf("?")==-1){a+="?"}else{a+="&"}a+="use_panels=True";b.attr("href",a);b.attr("target","_self")}return b})});
\ No newline at end of file
--- a/templates/library/common/browse_library.mako Thu Mar 24 17:36:06 2011 -0400
+++ b/templates/library/common/browse_library.mako Thu Mar 24 18:26:29 2011 -0400
@@ -361,6 +361,7 @@
<span class="expandLink folder-${encoded_id}-click"><div style="float: left; margin-left: 2px;" class="menubutton split popup" id="folder_img-${folder.id}-popup"><a class="folder-${encoded_id}-click" href="javascript:void(0);">
+ <span class="rowIcon"></span>
%if folder.deleted:
<div class="libraryItem-error">${folder.name}</div>
%else:
--- a/templates/root/history.mako Thu Mar 24 17:36:06 2011 -0400
+++ b/templates/root/history.mako Thu Mar 24 18:26:29 2011 -0400
@@ -75,8 +75,8 @@
});
});
- // Show details icon
- $(this).find("a.show-details").bind("mouseenter.load-detail", function(e) {
+ // Show details icon -- Disabled since it often gets stuck, etc
+ /* $(this).find("a.show-details").bind("mouseenter.load-detail", function(e) {
var anchor = $(this);
$.get($(this).attr("href"), function(data) {
anchor.attr("title", data);
@@ -86,8 +86,10 @@
});
return false;
});
+
// Disable clickthrough
$(this).find("a.show-details").bind("click", function() { return false; });
+ */
// Tag handling.
$(this).find("a.icon-button.tags").each( function() {
--- a/templates/show_params.mako Thu Mar 24 17:36:06 2011 -0400
+++ b/templates/show_params.mako Thu Mar 24 18:26:29 2011 -0400
@@ -1,3 +1,4 @@
+<%inherit file="/base.mako"/><% from galaxy.util import nice_size %><%def name="inputs_recursive( input_params, param_values, depth=1 )">
@@ -27,12 +28,12 @@
<tr><th colspan="2" style="font-size: 120%;">${tool.name}</th></tr></thead><tbody>
- <tr><th>Created:</th><td>${history.create_time.strftime("%b %d, %Y")}</td></tr>
- <tr><th>Modified:</th><td>${history.update_time.strftime("%b %d, %Y")}</td></tr>
-## <tr><th>Copied from another history?</td><td>${hda.source_library_dataset}</td></tr>
- <tr><th>Filesize:</th><td>${nice_size(hda.dataset.file_size)}</td></tr>
- <tr><th>Dbkey:</th><td>${hda.dbkey}</td></tr>
- <tr><th>Format:</th><td>${hda.ext}</td></tr>
+ <tr><td>Created:</th><td>${history.create_time.strftime("%b %d, %Y")}</td></tr>
+ <tr><td>Modified:</th><td>${history.update_time.strftime("%b %d, %Y")}</td></tr>
+## <tr><td>Copied from another history?</td><td>${hda.source_library_dataset}</td></tr>
+ <tr><td>Filesize:</th><td>${nice_size(hda.dataset.file_size)}</td></tr>
+ <tr><td>Dbkey:</th><td>${hda.dbkey}</td></tr>
+ <tr><td>Format:</th><td>${hda.ext}</td></tr></table><br /><table class="tabletip">
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/galaxy-central: jgoecks: Change default value for Tophat coverage search to true.
by Bitbucket 24 Mar '11
by Bitbucket 24 Mar '11
24 Mar '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/0af3b79ea5ea/
changeset: r5271:0af3b79ea5ea
user: jgoecks
date: 2011-03-24 22:36:06
summary: Change default value for Tophat coverage search to true.
affected #: 1 file (8 bytes)
--- a/tools/ngs_rna/tophat_wrapper.xml Thu Mar 24 17:12:16 2011 -0400
+++ b/tools/ngs_rna/tophat_wrapper.xml Thu Mar 24 17:36:06 2011 -0400
@@ -251,8 +251,8 @@
<!-- Coverage search. --><conditional name="coverage_search"><param name="use_search" type="select" label="Use Coverage Search">
- <option value="No">No</option>
- <option value="Yes">Yes</option>
+ <option value="Yes">Yes</option>
+ <option value="No">No</option></param><when value="Yes"><param name="min_coverage_intron" type="integer" value="50" label="Minimum intron length that may be found during coverage search" />
@@ -357,8 +357,8 @@
<!-- Coverage search. --><conditional name="coverage_search"><param name="use_search" type="select" label="Use Coverage Search">
- <option value="No">No</option>
- <option value="Yes">Yes</option>
+ <option value="Yes">Yes</option>
+ <option value="No">No</option></param><when value="Yes"><param name="min_coverage_intron" type="integer" value="50" label="Minimum intron length that may be found during coverage search" />
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/galaxy-central: jgoecks: Trackster: put show_insertions and show_differences in track config and fix show_differences, which was broken in previous trackster commit.
by Bitbucket 24 Mar '11
by Bitbucket 24 Mar '11
24 Mar '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/120565d36127/
changeset: r5270:120565d36127
user: jgoecks
date: 2011-03-24 22:12:16
summary: Trackster: put show_insertions and show_differences in track config and fix show_differences, which was broken in previous trackster commit.
affected #: 2 files (961 bytes)
--- a/static/scripts/packed/trackster.js Thu Mar 24 15:05:28 2011 -0400
+++ b/static/scripts/packed/trackster.js Thu Mar 24 17:12:16 2011 -0400
@@ -1,1 +1,1 @@
-CanvasRenderingContext2D.prototype.dashedLine=function(c,j,b,h,f){if(f===undefined){f=4}var e=b-c;var d=h-j;var g=Math.floor(Math.sqrt(e*e+d*d)/f);var l=e/g;var k=d/g;var a;for(a=0;a<g;a++,c+=l,j+=k){if(a%2!==0){continue}this.fillRect(c,j,f,1)}};CanvasRenderingContext2D.prototype.drawDownwardEquilateralTriangle=function(b,a,e){var d=b-e/2,c=b+e/2,f=a-Math.sqrt(e*3/2);this.beginPath();this.moveTo(d,f);this.lineTo(c,f);this.lineTo(b,a);this.lineTo(d,f);this.strokeStyle=this.fillStyle;this.fill();this.stroke();this.closePath()};function sortable(a,b){a.bind("drag",{handle:b,relative:true},function(h,j){var g=$(this).parent();var f=g.children();var c;for(c=0;c<f.length;c++){if(j.offsetY<$(f.get(c)).position().top){break}}if(c===f.length){if(this!==f.get(c-1)){g.append(this)}}else{if(this!==f.get(c)){$(this).insertBefore(f.get(c))}}})}var NO_OVERLAP=1001,CONTAINS=1002,OVERLAP_START=1003,OVERLAP_END=1004,CONTAINED_BY=1005;function compute_overlap(e,b){var g=e[0],f=e[1],d=b[0],c=b[1],a;if(g<d){if(f<d){a=NO_OVERLAP}else{if(f<=c){a=OVERLAP_START}else{a=CONTAINS}}}else{if(g>c){a=NO_OVERLAP}else{if(f<=c){a=CONTAINED_BY}else{a=OVERLAP_END}}}return a}function is_overlap(b,a){return(compute_overlap(b,a)!==NO_OVERLAP)}var DENSE_TRACK_HEIGHT=10,NO_DETAIL_TRACK_HEIGHT=3,SQUISH_TRACK_HEIGHT=5,PACK_TRACK_HEIGHT=10,NO_DETAIL_FEATURE_HEIGHT=1,DENSE_FEATURE_HEIGHT=1,SQUISH_FEATURE_HEIGHT=3,PACK_FEATURE_HEIGHT=9,ERROR_PADDING=10,LABEL_SPACING=2,PACK_SPACING=5,MIN_SQUISH_VIEW_WIDTH=12000,DEFAULT_FONT="9px Monaco, Lucida Console, monospace",DENSITY=200,FEATURE_LEVELS=10,MAX_FEATURE_DEPTH=100,DEFAULT_DATA_QUERY_WAIT=5000,MAX_CHROMS_SELECTABLE=100,CONNECTOR_COLOR="#ccc",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_CANNOT_RUN_TOOL="Tool cannot be rerun: ",DATA_LOADING="Loading data...",DATA_OK="Ready for display",CACHED_TILES_FEATURE=10,CACHED_TILES_LINE=5,CACHED_DATA=5,DUMMY_CANVAS=document.createElement("canvas"),RIGHT_STRAND,LEFT_STRAND;if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(DUMMY_CANVAS)}var CONTEXT=DUMMY_CANVAS.getContext("2d");CONTEXT.font=DEFAULT_FONT;var CHAR_WIDTH_PX=CONTEXT.measureText("A").width,CHAR_HEIGHT_PX=9;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.move_key_to_end(b,a)}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},move_key_to_end:function(b,a){this.key_ary.splice(a,1);this.key_ary.push(b)},clear:function(){this.obj_cache={};this.key_ary=[]},size:function(){return this.key_ary.length}});var DataManager=function(b,a){Cache.call(this,b);this.track=a};$.extend(DataManager.prototype,Cache.prototype,{load_data:function(d,a,f,h,b,e){var g={chrom:d,low:a,high:f,mode:h,resolution:b,dataset_id:this.track.dataset_id,hda_ldda:this.track.hda_ldda};$.extend(g,e);var c=this;return $.getJSON(this.track.data_url,g,function(j){c.set_data(a,f,h,j)})},get_data:function(j,k,c,h,b,f){var l=this.get(this.gen_key(k,c,h));if(l){return l}var m,g,a,e,h,l;for(var d=0;d<this.key_ary.length;d++){m=this.key_ary[d];g=this.split_key(m);a=g[0];e=g[1];if(k>=a&&c<=e){l=this.obj_cache[m];if(l.dataset_type!=="summary_tree"&&l.extra_info!=="no_detail"){this.move_key_to_end(m,d);return l}}}return this.load_data(j,k,c,h,b,f)},set_data:function(b,c,d,a){return this.set(this.gen_key(b,c,d),a)},gen_key:function(a,c,d){var b=a+"_"+c+"_"+d;return b},split_key:function(a){return a.split("_")}});var View=function(a,d,c,b,e){this.container=a;this.chrom=null;this.vis_id=c;this.dbkey=b;this.title=d;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(e);this.reset()};$.extend(View.prototype,{init:function(d){var c=this.container,a=this;this.top_container=$("<div/>").addClass("top-container").appendTo(c);this.content_div=$("<div/>").addClass("content").css("position","relative").appendTo(c);this.bottom_container=$("<div/>").addClass("bottom-container").appendTo(c);this.top_labeltrack=$("<div/>").addClass("top-labeltrack").appendTo(this.top_container);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_labeltrack=$("<div/>").addClass("nav-labeltrack").appendTo(this.bottom_container);this.nav_container=$("<div/>").addClass("nav-container").prependTo(this.top_container);this.nav=$("<div/>").addClass("nav").appendTo(this.nav_container);this.overview=$("<div/>").addClass("overview").appendTo(this.bottom_container);this.overview_viewport=$("<div/>").addClass("overview-viewport").appendTo(this.overview);this.overview_close=$("<a 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_select=$("<select/>").attr({name:"chrom"}).css("width","15em").addClass("no-autocomplete").append("<option value=''>Loading</option>").appendTo(this.nav_controls);var b=function(f){if(f.type==="focusout"||(f.keyCode||f.which)===13||(f.keyCode||f.which)===27){if((f.keyCode||f.which)!==27){a.go_to($(this).val())}$(this).hide();$(this).val("");a.location_span.show();a.chrom_select.show()}};this.nav_input=$("<input/>").addClass("nav-input").hide().bind("keyup focusout",b).appendTo(this.nav_controls);this.location_span=$("<span/>").addClass("location").appendTo(this.nav_controls);this.location_span.bind("click",function(){a.location_span.hide();a.chrom_select.hide();a.nav_input.val(a.chrom+":"+a.low+"-"+a.high);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.nav_controls)}this.zo_link=$("<a id='zoom-out' />").click(function(){a.zoom_out();a.redraw()}).appendTo(this.nav_controls);this.zi_link=$("<a id='zoom-in' />").click(function(){a.zoom_in();a.redraw()}).appendTo(this.nav_controls);this.load_chroms({low:0},d);this.chrom_select.bind("change",function(){a.change_chrom(a.chrom_select.val())});this.intro_div.show();this.content_div.bind("click",function(f){$(this).find("input").trigger("blur")});this.content_div.bind("dblclick",function(f){a.zoom_in(f.pageX,this.viewport_container)});this.overview_box.bind("dragstart",function(f,g){this.current_x=g.offsetX}).bind("drag",function(f,h){var j=h.offsetX-this.current_x;this.current_x=h.offsetX;var g=Math.round(j/a.viewport_container.width()*(a.max_high-a.max_low));a.move_delta(-g)});this.overview_close.bind("click",function(){for(var f=0,e=a.tracks.length;f<e;f++){a.tracks[f].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("draginit",function(f,g){if(f.clientX>a.viewport_container.width()-16){return false}}).bind("dragstart",function(f,g){g.original_low=a.low;g.current_height=f.clientY;g.current_x=g.offsetX}).bind("drag",function(h,k){var f=$(this);var l=k.offsetX-k.current_x;var g=f.scrollTop()-(h.clientY-k.current_height);f.scrollTop(g);k.current_height=h.clientY;k.current_x=k.offsetX;var j=Math.round(l/a.viewport_container.width()*(a.high-a.low));a.move_delta(j)}).bind("mousewheel",function(h,k,g,f){if(g){var j=Math.round(-g/a.viewport_container.width()*(a.high-a.low));a.move_delta(j)}});this.top_labeltrack.bind("dragstart",function(f,g){return $("<div />").css({height:a.content_div.height()+a.top_labeltrack.height()+a.nav_labeltrack.height()+1,top:"0px",position:"absolute","background-color":"#ccf",opacity:0.5,"z-index":1000}).appendTo($(this))}).bind("drag",function(k,l){$(l.proxy).css({left:Math.min(k.pageX,l.startX),width:Math.abs(k.pageX-l.startX)});var g=Math.min(k.pageX,l.startX)-a.container.offset().left,f=Math.max(k.pageX,l.startX)-a.container.offset().left,j=(a.high-a.low),h=a.viewport_container.width();a.update_location(Math.round(g/h*j)+a.low,Math.round(f/h*j)+a.low)}).bind("dragend",function(l,m){var g=Math.min(l.pageX,m.startX),f=Math.max(l.pageX,m.startX),j=(a.high-a.low),h=a.viewport_container.width(),k=a.low;a.low=Math.round(g/h*j)+k;a.high=Math.round(f/h*j)+k;$(m.proxy).remove();a.redraw()});this.add_label_track(new LabelTrack(this,this.top_labeltrack));this.add_label_track(new LabelTrack(this,this.nav_labeltrack));$(window).bind("resize",function(){a.resize_window()});$(document).bind("redraw",function(){a.redraw()});this.reset();$(window).trigger("resize")},update_location:function(a,b){this.location_span.text(commatize(a)+" - "+commatize(b));this.nav_input.val(this.chrom+":"+commatize(a)+"-"+commatize(b))},load_chroms:function(b,c){b.num=MAX_CHROMS_SELECTABLE;$.extend(b,(this.vis_id!==undefined?{vis_id:this.vis_id}:{dbkey:this.dbkey}));var a=this;$.ajax({url:chrom_url,data:b,dataType:"json",success:function(e){if(e.chrom_info.length===0){alert("Invalid chromosome: "+b.chrom);return}if(e.reference){a.add_label_track(new ReferenceTrack(a))}a.chrom_data=e.chrom_info;var h='<option value="">Select Chrom/Contig</option>';for(var g=0,d=a.chrom_data.length;g<d;g++){var f=a.chrom_data[g].chrom;h+='<option value="'+f+'">'+f+"</option>"}if(e.prev_chroms){h+='<option value="previous">Previous '+MAX_CHROMS_SELECTABLE+"</option>"}if(e.next_chroms){h+='<option value="next">Next '+MAX_CHROMS_SELECTABLE+"</option>"}a.chrom_select.html(h);if(c){c()}a.chrom_start_index=e.start_index},error:function(){alert("Could not load chroms for this dbkey:",a.dbkey)}})},change_chrom:function(e,b,g){if(!e||e==="None"){return}var d=this;if(e==="previous"){d.load_chroms({low:this.chrom_start_index-MAX_CHROMS_SELECTABLE});return}if(e==="next"){d.load_chroms({low:this.chrom_start_index+MAX_CHROMS_SELECTABLE});return}var f=$.grep(d.chrom_data,function(j,k){return j.chrom===e})[0];if(f===undefined){d.load_chroms({chrom:e},function(){d.change_chrom(e,b,g)});return}else{if(e!==d.chrom){d.chrom=e;if(!d.chrom){d.intro_div.show()}else{d.intro_div.hide()}d.chrom_select.val(d.chrom);d.max_high=f.len-1;d.reset();d.redraw(true);for(var h=0,a=d.tracks.length;h<a;h++){var c=d.tracks[h];if(c.init){c.init()}}}if(b!==undefined&&g!==undefined){d.low=Math.max(b,0);d.high=Math.min(g,d.max_high)}d.reset_overview();d.redraw()}},go_to:function(f){var k=this,a,d,b=f.split(":"),h=b[0],j=b[1];if(j!==undefined){try{var g=j.split("-");a=parseInt(g[0].replace(/,/g,""),10);d=parseInt(g[1].replace(/,/g,""),10)}catch(c){return false}}k.change_chrom(h,a,d)},move_fraction:function(c){var a=this;var b=a.high-a.low;this.move_delta(c*b)},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);sortable(a.container_div,".draghandle");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())||0;var e=((this.high-this.low)/(this.max_high-this.max_low)*this.overview_viewport.width())||0;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_location(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(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()},resize_window:function(){this.viewport_container.height(this.container.height()-this.top_container.height()-this.bottom_container.height());this.nav_container.width(this.container.width());this.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 Tool=function(a,b){this.name=a;this.params=b};$.extend(Tool.prototype,{get_param_values_dict:function(){var b={};for(var a=0;a<this.params.length;a++){var c=this.params[a];b[c.name]=c.value}return b},get_param_values:function(){var b=[];for(var a=0;a<this.params.length;a++){b[a]=this.params[a].value}return b}});var NumberToolParameter=function(c,b,e,a,d){this.name=c;this.label=b;this.min=e;this.max=a;this.value=d};var get_tool_from_dict=function(f){if(obj_length(f)===0){return undefined}var b=f.name;var l=f.params;var c=Array();for(var e=0;e<l.length;e++){var g=l[e];var a=g.name,k=g.label,h=g.type,d=g.min,j=g.max,m=g.value;c[c.length]=new NumberToolParameter(a,k,d,j,m)}return new Tool(b,c)};var Filter=function(b,a,c){this.name=b;this.index=a;this.value=c};var NumberFilter=function(b,a){this.name=b;this.index=a;this.low=-Number.MAX_VALUE;this.high=Number.MAX_VALUE;this.slider_min=Number.MAX_VALUE;this.slider_max=-Number.MAX_VALUE;this.slider=null;this.slider_label=null};$.extend(NumberFilter.prototype,{applies_to:function(a){if(a.length>this.index){return true}return false},keep:function(a){if(!this.applies_to(a)){return true}return(a[this.index]>=this.low&&a[this.index]<=this.high)},update_attrs:function(b){var a=false;if(!this.applies_to(b)){return a}if(b[this.index]<this.slider_min){this.slider_min=b[this.index];a=true}if(b[this.index]>this.slider_max){this.slider_max=b[this.index];a=false}return a},update_ui_elt:function(){var b=this.slider.slider("option","min"),a=this.slider.slider("option","max");if(this.slider_min<b||this.slider_max>a){this.slider.slider("option","min",this.slider_min);this.slider.slider("option","max",this.slider_max);this.slider.slider("option","values",[this.slider_min,this.slider_max])}}});var get_filters_from_dict=function(a){var g=[];for(var d=0;d<a.length;d++){var f=a[d];var c=f.name,e=f.type,b=f.index;if(e==="int"||e==="float"){g[d]=new NumberFilter(c,b)}else{g[d]=new Filter(c,b,e)}}return g};var TrackConfig=function(a){this.track=a.track;this.params=a.params;this.values={};if(a.saved_values){this.restore_values(a.saved_values)}this.onchange=a.onchange};$.extend(TrackConfig.prototype,{restore_values:function(a){var b=this;$.each(this.params,function(c,d){if(a[d.key]!==undefined){b.values[d.key]=a[d.key]}else{b.values[d.key]=d.default_value}})},build_form:function(){var b=this;var a=$("<div />");$.each(this.params,function(f,d){if(!d.hidden){var c="param_"+f;var l=$("<div class='form-row' />").appendTo(a);l.append($("<label />").attr("for",c).text(d.label+":"));if(d.type==="bool"){l.append($('<input type="checkbox" />').attr("id",c).attr("name",c).attr("checked",b.values[d.key]))}else{if(d.type==="color"){var h=b.values[d.key];var g=$("<input />").attr("id",c).attr("name",c).val(h);var j=$("<div class='tipsy tipsy-north' style='position: absolute;' />").hide();var e=$("<div style='background-color: black; padding: 10px;'></div>").appendTo(j);var k=$("<div/>").appendTo(e).farbtastic({width:100,height:100,callback:g,color:h});$("<div />").append(g).append(j).appendTo(l).bind("click",function(m){j.css({left:$(this).position().left+($(g).width()/2)-60,top:$(this).position().top+$(this.height)}).show();$(document).bind("click.color-picker",function(){j.hide();$(document).unbind("click.color-picker")});m.stopPropagation()})}else{l.append($("<input />").attr("id",c).attr("name",c).val(b.values[d.key]))}}}});return a},update_from_form:function(a){var c=this;var b=false;$.each(this.params,function(d,f){if(!f.hidden){var g="param_"+d;var e=a.find("#"+g).val();if(f.type==="float"){e=parseFloat(e)}else{if(f.type==="int"){e=parseInt(e)}else{if(f.type==="bool"){e=a.find("#"+g).is(":checked")}}}if(e!==c.values[f.key]){c.values[f.key]=e;b=true}}});if(b){this.onchange()}}});var Track=function(b,a,e,c,d){this.name=b;this.view=a;this.parent_element=e;this.data_url=(c?c:default_data_url);this.data_url_extra_params={};this.data_query_wait=(d?d:DEFAULT_DATA_QUERY_WAIT);this.dataset_check_url=converted_datasets_state_url;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.name_div.attr("id",this.name.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9\-]/g,"").toLowerCase())}this.content_div=$("<div class='track-content'>").appendTo(this.container_div);this.parent_element.append(this.container_div)};$.extend(Track.prototype,{init:function(){var a=this;a.enabled=false;a.tile_cache.clear();a.data_cache.clear();a.initial_canvas=undefined;a.content_div.css("height","auto");a.container_div.removeClass("nodata error pending");if(!a.dataset_id){return}$.getJSON(converted_datasets_state_url,{hda_ldda:a.hda_ldda,dataset_id:a.dataset_id,chrom:a.view.chrom},function(b){if(!b||b==="error"||b.kind==="error"){a.container_div.addClass("error");a.content_div.text(DATA_ERROR);if(b.message){var d=a.view.tracks.indexOf(a);var c=$(" <a href='javascript:void(0);'></a>").text("View error").bind("click",function(){show_modal("Trackster Error","<pre>"+b.message+"</pre>",{Close:hide_modal})});a.content_div.append(c)}}else{if(b==="no converter"){a.container_div.addClass("error");a.content_div.text(DATA_NOCONVERTER)}else{if(b==="no data"||(b.data!==undefined&&(b.data===null||b.data.length===0))){a.container_div.addClass("nodata");a.content_div.text(DATA_NONE)}else{if(b==="pending"){a.container_div.addClass("pending");a.content_div.text(DATA_PENDING);setTimeout(function(){a.init()},a.data_query_wait)}else{if(b.status==="data"){if(b.valid_chroms){a.valid_chroms=b.valid_chroms;a.make_name_popup_menu()}a.content_div.text(DATA_OK);if(a.view.chrom){a.content_div.text("");a.content_div.css("height",a.height_px+"px");a.enabled=true;$.when(a.predraw_init()).done(function(){a.draw()})}}}}}}})},predraw_init:function(){},update_name:function(a){this.old_name=this.name;this.name=a;this.name_div.text(this.name)},revert_name:function(){this.name=this.old_name;this.name_div.text(this.name)}});var TiledTrack=function(b,j,n){var c=this,o=c.view;this.filters=(b!==undefined?get_filters_from_dict(b):[]);this.filters_available=false;this.filters_visible=false;this.tool=(j!==undefined?get_tool_from_dict(j):undefined);this.parent_track=n;this.child_tracks=[];if(c.hidden){return}if(this.parent_track){this.header_div.find(".draghandle").removeClass("draghandle").addClass("child-track-icon").addClass("icon-button");this.parent_element.addClass("child-track");this.tool=undefined}this.filters_div=$("<div/>").addClass("filters").hide();this.header_div.after(this.filters_div);this.filters_div.bind("drag",function(q){q.stopPropagation()}).bind("dblclick",function(q){q.stopPropagation()});$.each(this.filters,function(t,w){var u=$("<div/>").addClass("slider-row").appendTo(c.filters_div);var v=$("<div/>").addClass("slider-label").appendTo(u);var s=$("<span/>").addClass("name").appendTo(v);s.text(w.name+" ");var r=$("<span/>").addClass("values").appendTo(v);var q=$("<div/>").addClass("slider").appendTo(u);w.control_element=$("<div/>").attr("id",w.name+"-filter-control").appendTo(q);w.control_element.slider({range:true,min:Number.MAX_VALUE,max:-Number.MIN_VALUE,values:[0,0],slide:function(y,z){var x=z.values;r.text("["+x[0]+"-"+x[1]+"]");w.low=x[0];w.high=x[1];c.draw(true,true)},change:function(x,y){w.control_element.slider("option","slide").call(w.control_element,x,y)}});w.slider=w.control_element;w.slider_label=r;$("<div style='clear: both;'/>").appendTo(u)});if(this.tool){this.dynamic_tool_div=$("<div/>").addClass("dynamic-tool").hide();this.header_div.after(this.dynamic_tool_div);this.dynamic_tool_div.bind("drag",function(q){q.stopPropagation()}).bind("click",function(q){q.stopPropagation()}).bind("dblclick",function(q){q.stopPropagation()});var m=$("<div class='tool-name'>").appendTo(this.dynamic_tool_div).text(this.tool.name);var l=this.tool.params;var c=this;$.each(this.tool.params,function(x,s){var v=$("<div>").addClass("slider-row").appendTo(c.dynamic_tool_div);var u=$("<div>").addClass("slider-label").appendTo(v);var z=$("<span class='param-name'>").text(s.label+" ").appendTo(u);var t=$("<span/>").text(s.value);var w=$("<span class='param-value'>").appendTo(u).append("[").append(t).append("]");var y=$("<div/>").addClass("slider").appendTo(v);var q=$("<div id='"+s.name+"-param-control'>").appendTo(y);var r=(s.max<=1?0.01:(s.max<=1000?1:5));q.slider({min:s.min,max:s.max,step:r,value:s.value,slide:function(A,C){var B=C.value;s.value=B;if(0<B&&B<1){B=parseFloat(B).toFixed(2)}t.text(B)},change:function(A,B){s.value=B.value}});w.click(function(){var C=t,B=C.text(),A=(s.max<=1?4:s.max.length);C.text("");$("<input type='text'/>").attr("size",A).attr("maxlength",A).attr("value",B).appendTo(C).focus().select().click(function(D){D.stopPropagation()}).blur(function(){$(this).remove();C.text(B)}).keyup(function(F){if(F.keyCode===27){$(this).trigger("blur")}else{if(F.keyCode===13){var D=$(this),E=parseFloat(D.val());if(isNaN(E)||E>s.max||E<s.min){alert("Parameter value must be in the range ["+s.min+"-"+s.max+"]");return $(this)}C.text(E);q.slider("value",E);s.value=E}}})});$("<div style='clear: both;'/>").appendTo(v)});var p=$("<div>").addClass("slider-row").appendTo(this.dynamic_tool_div);var k=$("<input type='submit'>").attr("value","Run").appendTo(p);var c=this;k.click(function(){c.run_tool()})}c.child_tracks_container=$("<div/>").addClass("child-tracks-container").hide();c.container_div.append(c.child_tracks_container);if(c.display_modes!==undefined){if(c.mode_div===undefined){c.mode_div=$("<div class='right-float menubutton popup' />").appendTo(c.header_div);var e=(c.track_config&&c.track_config.values.mode?c.track_config.values.mode:c.display_modes[0]);c.mode=e;c.mode_div.text(e);var d=function(q){c.mode_div.text(q);c.mode=q;c.track_config.values.mode=q;c.tile_cache.clear();c.draw()};var a={};for(var f=0,h=c.display_modes.length;f<h;f++){var g=c.display_modes[f];a[g]=function(q){return function(){d(q)}}(g)}make_popupmenu(c.mode_div,a)}else{c.mode_div.hide()}}this.make_name_popup_menu()};$.extend(TiledTrack.prototype,Track.prototype,{make_name_popup_menu:function(){var b=this;var a={};a["Edit configuration"]=function(){var h=function(){hide_modal();$(window).unbind("keypress.check_enter_esc")},f=function(){b.track_config.update_from_form($(".dialog-box"));hide_modal();$(window).unbind("keypress.check_enter_esc")},g=function(j){if((j.keyCode||j.which)===27){h()}else{if((j.keyCode||j.which)===13){f()}}};$(window).bind("keypress.check_enter_esc",g);show_modal("Configure Track",b.track_config.build_form(),{Cancel:h,OK:f})};if(b.filters_available>0){var e=(b.filters_div.is(":visible")?"Hide filters":"Show filters");a[e]=function(){b.filters_visible=(b.filters_div.is(":visible"));b.filters_div.toggle();b.make_name_popup_menu()}}if(b.tool){var e=(b.dynamic_tool_div.is(":visible")?"Hide Tool":"Show Tool");a[e]=function(){if(!b.dynamic_tool_div.is(":visible")){b.update_name(b.name+b.tool_region_and_parameters_str())}else{menu_option_text="Show dynamic tool";b.revert_name()}b.dynamic_tool_div.toggle();b.make_name_popup_menu()}}if(b.track_type=="ReadTrack"){var e=(b.show_insertions?"Hide Insertions":"Show Insertions");a[e]=function(){b.show_insertions=!b.show_insertions;b.draw(true);b.make_name_popup_menu()}}if(b.valid_chroms){a["List chrom/contigs with data"]=function(){show_modal("Chrom/contigs with data","<p>"+b.valid_chroms.join("<br/>")+"</p>",{Close:function(){hide_modal()}})}}var c=view;var d=function(){$("#no-tracks").show()};if(this.parent_track){c=this.parent_track;d=function(){}}a.Remove=function(){c.remove_track(b);if(c.num_tracks===0){d()}};make_popupmenu(b.name_div,a)},draw:function(a,d){console.log(this.name,a,d);var s=this.view.low,g=this.view.high,j=g-s,l=this.view.container.width(),m=this.view.resolution;var e=$("<div style='position: relative;'></div>"),f=l/j;if(!d){this.content_div.children().remove()}this.content_div.append(e);this.max_height=0;var o=Math.floor(s/m/DENSITY);var c={};while((o*DENSITY*m)<g){var r=l+"_"+f+"_"+o;var h=this.tile_cache.get(r);var p=o*DENSITY*this.view.resolution;var b=p+DENSITY*this.view.resolution;if(!a&&h){this.show_tile(h,e,p,f)}else{this.delayed_draw(a,r,p,b,o,m,e,f,c)}o+=1}if(d){var k=this;var q=setInterval(function(){if(obj_length(c)===0){var v=k.content_div.children();var u=false;for(var w=v.length-1,t=0;w>=t;w--){var x=$(v[w]);if(u){x.remove()}else{if(x.children().length!==0){u=true}}}clearInterval(q)}},50)}for(var n=0;n<this.child_tracks.length;n++){this.child_tracks[n].draw(a,d)}},delayed_draw:function(b,j,g,l,c,e,k,m,f){var d=this;var h=function(u,n,p,o,s,t,q){returned_tile=d.draw_tile(n,p,o,s,t,q);var r=$("<div class='track-tile'>").prepend(returned_tile);tile_element=r;d.tile_cache.set(j,tile_element);d.show_tile(tile_element,s,g,t);delete f[u]};var a=setTimeout(function(){if(g<=d.view.high&&l>=d.view.low){var n=(b?undefined:d.tile_cache.get(j));if(n){d.show_tile(n,k,g,m);delete f[a]}else{$.when(d.data_cache.get_data(view.chrom,g,l,d.mode,e,d.data_url_extra_params)).then(function(){result=d.data_cache.get_data(view.chrom,g,l,d.mode,e,d.data_url_extra_params);if(view.reference_track&&m>CHAR_WIDTH_PX){$.when(view.reference_track.data_cache.get_data(view.chrom,g,l,d.mode,e,view.reference_track.data_url_extra_params)).then(function(){seq_data=view.reference_track.data_cache.get_data(view.chrom,g,l,d.mode,e,view.reference_track.data_url_extra_params);h(a,result,e,c,k,m,seq_data)})}else{h(a,result,e,c,k,m)}})}}},50);f[a]=true},show_tile:function(h,j,e,k){var a=this;var c=this.view.high-this.view.low,b=(e-this.view.low)*k;if(this.left_offset){b-=this.left_offset}h.css({position:"absolute",top:0,left:b,height:""});j.append(h);a.max_height=Math.max(a.max_height,h.height());a.content_div.css("height",a.max_height+"px");j.children().css("height",a.max_height+"px");if(a.hidden){return}for(var g=0;g<a.filters.length;g++){a.filters[g].update_ui_elt()}var d=false;if(a.example_feature){for(var g=0;g<a.filters.length;g++){if(a.filters[g].applies_to(a.example_feature)){d=true;break}}}if(a.filters_available!==d){a.filters_available=d;if(!a.filters_available){a.filters_div.hide()}a.make_name_popup_menu()}},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")},run_tool:function(){var b={dataset_id:this.original_dataset_id,chrom:this.view.chrom,low:this.view.low,high:this.view.high,tool_id:this.tool.name};$.extend(b,this.tool.get_param_values_dict());var d=this,c=b.tool_id+d.tool_region_and_parameters_str(b.chrom,b.low,b.high),e;if(d.track_type==="FeatureTrack"){e=new ToolDataFeatureTrack(c,view,d.hda_ldda,undefined,{},{},d)}this.add_track(e);e.content_div.text("Starting job.");view.has_changes=true;var a=function(){$.getJSON(run_tool_url,b,function(f){if(f==="no converter"){e.container_div.addClass("error");e.content_div.text(DATA_NOCONVERTER)}else{if(f.error){e.container_div.addClass("error");e.content_div.text(DATA_CANNOT_RUN_TOOL+f.message)}else{if(f==="pending"){e.container_div.addClass("pending");e.content_div.text("Converting input data so that it can be easily reused.");setTimeout(a,2000)}else{e.dataset_id=f.dataset_id;e.content_div.text("Running job.");e.init()}}}})};a()},tool_region_and_parameters_str:function(c,a,d){var b=this,e=(c!==undefined&&a!==undefined&&d!==undefined?c+":"+a+"-"+d:"all");return" - region=["+e+"], parameters=["+b.tool.get_param_values().join(", ")+"]"},add_track:function(a){a.track_id=this.track_id+"_"+this.child_tracks.length;a.container_div.attr("id","track_"+a.track_id);this.child_tracks_container.append(a.container_div);sortable(a.container_div,".child-track-icon");if(!$(this.child_tracks_container).is(":visible")){this.child_tracks_container.show()}this.child_tracks.push(a)},remove_track:function(a){a.container_div.fadeOut("slow",function(){$(this).remove()})}});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.view.container.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);a.reference_track=this;this.left_offset=200;this.height_px=12;this.font=DEFAULT_FONT;this.container_div.addClass("reference-track");this.content_div.css("background","none");this.content_div.css("min-height","0px");this.content_div.css("border","none");this.data_url=reference_url;this.data_url_extra_params={dbkey:a.dbkey};this.data_cache=new DataManager(CACHED_DATA,this);this.tile_cache=new Cache(CACHED_TILES_LINE)};$.extend(ReferenceTrack.prototype,TiledTrack.prototype,{draw_tile:function(m,g,b,j,n){var f=this,d=DENSITY*g;if(n>CHAR_WIDTH_PX){if(m===null){f.content_div.css("height","0px");return}var e=document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(e)}e=$(e);var l=e.get(0).getContext("2d");e.get(0).width=Math.ceil(d*n+f.left_offset);e.get(0).height=f.height_px;l.font=DEFAULT_FONT;l.textAlign="center";for(var h=0,k=m.length;h<k;h++){var a=Math.round(h*n);l.fillText(m[h],a+f.left_offset,10)}return e}this.content_div.css("height","0px")}});var LineTrack=function(e,c,f,a,d){var b=this;this.track_type="LineTrack";this.display_modes=["Histogram","Line","Filled","Intensity"];this.mode="Histogram";Track.call(this,e,c,c.viewport_container);TiledTrack.call(this);this.min_height_px=16;this.max_height_px=400;this.height_px=80;this.hda_ldda=f;this.dataset_id=a;this.original_dataset_id=a;this.data_cache=new DataManager(CACHED_DATA,this);this.tile_cache=new Cache(CACHED_TILES_LINE);this.track_config=new TrackConfig({track:this,params:[{key:"color",label:"Color",type:"color",default_value:"black"},{key:"min_value",label:"Min Value",type:"float",default_value:undefined},{key:"max_value",label:"Max Value",type:"float",default_value:undefined},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"height",type:"int",default_value:this.height_px,hidden:true}],saved_values:d,onchange:function(){b.vertical_range=b.prefs.max_value-b.prefs.min_value;$("#linetrack_"+b.track_id+"_minval").text(b.prefs.min_value);$("#linetrack_"+b.track_id+"_maxval").text(b.prefs.max_value);b.tile_cache.clear();b.draw()}});this.prefs=this.track_config.values;this.height_px=this.track_config.values.height;this.vertical_range=this.track_config.values.max_value-this.track_config.values.min_value;(function(g){var k=false;var j=false;var h=$("<div class='track-resize'>");$(g.container_div).hover(function(){k=true;h.show()},function(){k=false;if(!j){h.hide()}});h.hide().bind("dragstart",function(l,m){j=true;m.original_height=$(g.content_div).height()}).bind("drag",function(m,n){var l=Math.min(Math.max(n.original_height+n.deltaY,g.min_height_px),g.max_height_px);$(g.content_div).css("height",l);g.height_px=l;g.draw(true)}).bind("dragend",function(l,m){g.tile_cache.clear();j=false;if(!k){h.hide()}g.track_config.values.height=g.height_px}).appendTo(g.container_div)})(this)};$.extend(LineTrack.prototype,TiledTrack.prototype,{predraw_init:function(){var a=this,b=a.view.tracks.indexOf(a);a.vertical_range=undefined;return $.getJSON(a.data_url,{stats:true,chrom:a.view.chrom,low:null,high:null,hda_ldda:a.hda_ldda,dataset_id:a.dataset_id},function(c){a.container_div.addClass("line-track");var e=c.data;if(isNaN(parseFloat(a.prefs.min_value))||isNaN(parseFloat(a.prefs.max_value))){a.prefs.min_value=e.min;a.prefs.max_value=e.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=e.total_frequency;a.container_div.find(".yaxislabel").remove();var f=$("<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.css({position:"absolute",top:"24px",left:"10px"});d.prependTo(a.container_div);f.css({position:"absolute",bottom:"2px",left:"10px"});f.prependTo(a.container_div)})},draw_tile:function(j,q,t,c,e){if(this.vertical_range===undefined){return}var o=this,u=t*DENSITY*q,a=DENSITY*q,B=q+"_"+t,v={hda_ldda:this.hda_ldda,dataset_id:this.dataset_id,resolution:this.view.resolution};var b=document.createElement("canvas"),z=j.data;if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(b)}b=$(b);b.get(0).width=Math.ceil(a*e);b.get(0).height=o.height_px;var p=b.get(0).getContext("2d"),k=false,l=o.prefs.min_value,g=o.prefs.max_value,n=o.vertical_range,w=o.total_frequency,d=o.height_px,m=o.mode;var A=Math.round(d+l/n*d);p.beginPath();p.moveTo(0,A);p.lineTo(a*e,A);p.fillStyle="#aaa";p.stroke();p.beginPath();p.fillStyle=o.prefs.color;var x,h,f;if(z.length>1){f=Math.ceil((z[1][0]-z[0][0])*e)}else{f=10}for(var r=0,s=z.length;r<s;r++){x=Math.round((z[r][0]-u)*e);h=z[r][1];if(h===null){if(k&&m==="Filled"){p.lineTo(x,d)}k=false;continue}if(h<l){h=l}else{if(h>g){h=g}}if(m==="Histogram"){h=Math.round(h/n*d);p.fillRect(x,A,f,-h)}else{if(m==="Intensity"){h=255-Math.floor((h-l)/n*255);p.fillStyle="rgb("+h+","+h+","+h+")";p.fillRect(x,0,f,d)}else{h=Math.round(d-(h-l)/n*d);if(k){p.lineTo(x,h)}else{k=true;if(m==="Filled"){p.moveTo(x,d);p.lineTo(x,h)}else{p.moveTo(x,h)}}}}}if(m==="Filled"){if(k){p.lineTo(x,A);p.lineTo(0,A)}p.fill()}else{p.stroke()}return b}});var FeatureTrack=function(a,f,e,j,h,c,d,g){var b=this;this.track_type="FeatureTrack";this.display_modes=["Auto","Dense","Squish","Pack"];this.track_config=new TrackConfig({track:this,params:[{key:"block_color",label:"Block color",type:"color",default_value:"#444"},{key:"label_color",label:"Label color",type:"color",default_value:"black"},{key:"show_counts",label:"Show summary counts",type:"bool",default_value:true},{key:"mode",type:"string",default_value:this.mode,hidden:true},],saved_values:h,onchange:function(){b.tile_cache.clear();b.draw()}});this.prefs=this.track_config.values;Track.call(this,a,f,f.viewport_container);TiledTrack.call(this,c,d,g);this.height_px=0;this.container_div.addClass("feature-track");this.hda_ldda=e;this.dataset_id=j;this.original_dataset_id=j;this.zo_slots={};this.show_labels_scale=0.001;this.showing_details=false;this.summary_draw_height=30;this.default_font=DEFAULT_FONT;this.inc_slots={};this.start_end_dct={};this.tile_cache=new Cache(CACHED_TILES_FEATURE);this.data_cache=new DataManager(20,this);this.left_offset=200};$.extend(FeatureTrack.prototype,TiledTrack.prototype,{incremental_slots:function(a,h,p){var q=this.inc_slots[a];if(!q||(q.mode!==p)){q={};q.w_scale=a;q.mode=p;this.inc_slots[a]=q;this.start_end_dct[a]={}}var l=q.w_scale,w=[],x=[],j=0,n=this.view.max_low;for(var u=0,v=h.length;u<v;u++){var g=h[u],k=g[0];if(q[k]!==undefined){j=Math.max(j,q[k]);x.push(q[k])}else{w.push(u)}}var d=this.start_end_dct[a];var m=function(D,E){for(var C=0;C<=MAX_FEATURE_DEPTH;C++){var A=false,F=d[C];if(F!==undefined){for(var z=0,B=F.length;z<B;z++){var y=F[z];if(E>y[0]&&D<y[1]){A=true;break}}}if(!A){return C}}return -1};for(var u=0,v=w.length;u<v;u++){var g=h[w[u]],k=g[0],s=g[1],b=g[2],o=g[3],c=Math.floor((s-n)*l),f=Math.ceil((b-n)*l),t=CONTEXT.measureText(o).width,e;if(o!==undefined&&p==="Pack"){t+=(LABEL_SPACING+PACK_SPACING);if(c-t>=0){c-=t;e="left"}else{f+=t;e="right"}}var r=m(c,f);if(r>=0){if(d[r]===undefined){d[r]=[]}d[r].push([c,f]);q[k]=r;j=Math.max(j,r)}else{}}return j+1},draw_summary_tree:function(b,o,n,l,r,j,f,e){var c=j+LABEL_SPACING+CHAR_HEIGHT_PX;delta_x_px=Math.ceil(n*r);var h=$("<div />").addClass("yaxislabel");h.text(l);h.css({position:"absolute",top:"22px",left:"10px"});h.prependTo(this.container_div);var q=b.get(0).getContext("2d");for(var d=0,g=o.length;d<g;d++){var m=Math.floor((o[d][0]-f)*r);var k=o[d][1];if(!k){continue}var p=k/l*j;q.fillStyle="black";q.fillRect(m+e,c-p,delta_x_px,p);var a=4;if(this.prefs.show_counts&&(q.measureText(k).width+a)<delta_x_px){q.fillStyle="#666";q.textAlign="center";q.fillText(k,m+e+(delta_x_px/2),10)}}},draw_element:function(p,f,g,x,j,r,I,M,N,a,A){var u=x[0],K=x[1],C=x[2]-1,s=x[3],D=Math.floor(Math.max(0,(K-r)*M)),q=Math.ceil(Math.min(a,Math.max(0,(C-r)*M))),B=ERROR_PADDING+(g==="Dense"?0:(0+j))*N,o,G,t=null,O=null,d=this.prefs.block_color,F=this.prefs.label_color;if(g==="Dense"){p.fillStyle=d;p.fillRect(D+A,B,q-D,DENSE_FEATURE_HEIGHT)}else{if(g==="no_detail"){p.fillStyle=d;p.fillRect(D+A,B+5,q-D,DENSE_FEATURE_HEIGHT)}else{var n=x[5],z=x[6],E=x[7],e=x[8];if(z&&E){t=Math.floor(Math.max(0,(z-r)*M));O=Math.ceil(Math.min(a,Math.max(0,(E-r)*M)))}var L,v;if(g==="Squish"){L=1;v=SQUISH_FEATURE_HEIGHT}else{L=5;v=PACK_FEATURE_HEIGHT}if(!e){if(x.strand){if(x.strand==="+"){p.fillStyle=RIGHT_STRAND_INV}else{if(x.strand==="-"){p.fillStyle=LEFT_STRAND_INV}}}else{p.fillStyle=d}p.fillRect(D+A,B,q-D,v)}else{var m,w;if(g==="Squish"){p.fillStyle=CONNECTOR_COLOR;m=B+Math.floor(SQUISH_FEATURE_HEIGHT/2)+1;w=1}else{if(n){var m=B;var w=v;if(n==="+"){p.fillStyle=RIGHT_STRAND}else{if(n==="-"){p.fillStyle=LEFT_STRAND}}}else{p.fillStyle=CONNECTOR_COLOR;m+=(SQUISH_FEATURE_HEIGHT/2)+1;w=1}}p.fillRect(D+A,m,q-D,w);for(var J=0,c=e.length;J<c;J++){var h=e[J],b=Math.floor(Math.max(0,(h[0]-r)*M)),y=Math.ceil(Math.min(a,Math.max((h[1]-1-r)*M)));if(b>y){continue}p.fillStyle=d;p.fillRect(b+A,B+(v-L)/2+1,y-b,L);if(t!==undefined&&!(b>O||y<t)){var H=Math.max(b,t),l=Math.min(y,O);p.fillRect(H+A,B+1,l-H,v)}}}if(g==="Pack"&&K>r){p.fillStyle=F;if(f===0&&D-p.measureText(s).width<0){p.textAlign="left";p.fillText(s,q+A+LABEL_SPACING,B+8)}else{p.textAlign="right";p.fillText(s,D+A-LABEL_SPACING,B+8)}p.fillStyle=d}}}},get_y_scale:function(b){var a;if(b==="summary_tree"){}if(b==="Dense"){a=DENSE_TRACK_HEIGHT}else{if(b==="no_detail"){a=NO_DETAIL_TRACK_HEIGHT}else{if(b==="Squish"){a=SQUISH_TRACK_HEIGHT}else{a=PACK_TRACK_HEIGHT}}}return a},draw_tile:function(o,x,C,k,m,d){var t=this;var E=C*DENSITY*x,a=(C+1)*DENSITY*x,q=a-E,F={hda_ldda:t.hda_ldda,dataset_id:t.dataset_id,resolution:this.view.resolution,mode:this.mode};var v=Math.ceil(q*m),s=this.mode,H=25,g=this.left_offset,p,h;var c=document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(c)}c=$(c);if(s==="Auto"){if(o.dataset_type==="summary_tree"){s=o.dataset_type}else{if(o.extra_info==="no_detail"){s="no_detail"}else{var G=o.data;if((G.length&&G.length<4)||(this.view.high-this.view.low>MIN_SQUISH_VIEW_WIDTH)){s="Squish"}else{s="Pack"}}}}var y=this.get_y_scale(s);if(s==="summary_tree"){h=this.summary_draw_height}if(s==="Dense"){h=H}else{if(s==="no_detail"||s==="Squish"||s==="Pack"){h=this.incremental_slots(m,o.data,s)*y+H;p=this.inc_slots[m]}}c.get(0).width=v+g;c.get(0).height=h;if(o.dataset_type==="summary_tree"){c.get(0).height+=LABEL_SPACING+CHAR_HEIGHT_PX}k.parent().css("height",Math.max(this.height_px,h)+"px");var w=c.get(0).getContext("2d");w.fillStyle=this.prefs.block_color;w.font=this.default_font;w.textAlign="right";this.container_div.find(".yaxislabel").remove();if(s==="summary_tree"){this.draw_summary_tree(c,o.data,o.delta,o.max,m,h,E,g);return c}if(o.message){c.css({"border-top":"1px solid red"});w.fillStyle="red";w.textAlign="left";var r=w.textBaseline;w.textBaseline="top";w.fillText(o.message,g,0);w.textBaseline=r;if(!o.data){return c}}this.example_feature=(o.data.length?o.data[0]:undefined);var G=o.data;for(var z=0,B=G.length;z<B;z++){var j=G[z],l=j[0],u=j[1],b=j[2],e=(p&&p[l]!==undefined?p[l]:null);var A=false;var n;for(var D=0;D<this.filters.length;D++){n=this.filters[D];n.update_attrs(j);if(!n.keep(j)){A=true;break}}if(A){continue}if(is_overlap([u,b],[E,a])&&(s=="Dense"||e!==null)){this.draw_element(w,C,s,j,e,E,a,m,y,v,g,d)}}return c}});var VcfTrack=function(d,b,f,a,c,e){FeatureTrack.call(this,d,b,f,a,c,e);this.track_type="VcfTrack"};$.extend(VcfTrack.prototype,TiledTrack.prototype,FeatureTrack.prototype,{draw_element:function(u,p,j,e,x,c,m,v,s){var j=data[i],l=j[0],t=j[1],d=j[2]-1,o=j[3],g=Math.floor(Math.max(0,(t-x)*m)),k=Math.ceil(Math.min(s,Math.max(0,(d-x)*m))),f=ERROR_PADDING+(p==="Dense"?0:(0+e))*v,a,y,b=null,n=null;if(no_label){u.fillStyle=block_color;u.fillRect(g+left_offset,f+5,k-g,1)}else{var w=j[4],r=j[5],h=j[6];a=9;y=1;u.fillRect(g+left_offset,f,k-g,a);if(p!=="Dense"&&o!==undefined&&t>x){u.fillStyle=label_color;if(tile_index===0&&g-u.measureText(o).width<0){u.textAlign="left";u.fillText(o,k+2+left_offset,f+8)}else{u.textAlign="right";u.fillText(o,g-2+left_offset,f+8)}u.fillStyle=block_color}var q=w+" / "+r;if(t>x&&u.measureText(q).width<(k-g)){u.fillStyle="white";u.textAlign="center";u.fillText(q,left_offset+g+(k-g)/2,f+8);u.fillStyle=block_color}}}});var ReadTrack=function(d,b,f,a,c,e){FeatureTrack.call(this,d,b,f,a,c,e);this.track_type="ReadTrack";this.difference_mode=true;this.show_insertions=false;this.make_name_popup_menu()};$.extend(ReadTrack.prototype,TiledTrack.prototype,FeatureTrack.prototype,{get_y_scale:function(b){var a;if(b==="summary_tree"){}if(b==="Dense"){a=DENSE_TRACK_HEIGHT}else{if(b==="Squish"){a=SQUISH_TRACK_HEIGHT}else{a=PACK_TRACK_HEIGHT;if(this.show_insertions){a*=2}}}return a},draw_read:function(m,d,J,n,D,G,e,o,y,a){m.textAlign="center";var l=this,u=[n,D],C=0,z=0,f=0;var r=[];if((d==="Pack"||this.mode==="Auto")&&o!==undefined&&J>CHAR_WIDTH_PX){f=Math.ceil(CHAR_WIDTH_PX/2+1)}if(!e){e=[[0,o.length]]}for(var h=0,k=e.length;h<k;h++){var b=e[h],g="MIDNSHP=X"[b[0]],v=b[1];if(g==="H"||g==="S"){C-=v}var x=G+C,B=Math.floor(Math.max(0,(x-n)*J)),E=Math.floor(Math.max(0,(x+v-n)*J));switch(g){case"H":break;case"S":case"M":case"=":var p=compute_overlap([x,x+v],u);if(p!==NO_OVERLAP){var q=o.slice(z,z+v);if(f>0){m.fillStyle=this.prefs.block_color;m.fillRect(B+this.left_offset-f,y+1,E-B,9);m.fillStyle=CONNECTOR_COLOR;for(var I=0,j=q.length;I<j;I++){if(this.difference_mode&&a){var s=a[x-n+I];if(!s||s.toLowerCase()===q[I].toLowerCase()){continue}}if(x+I>=n&&x+I<=D){var A=Math.floor(Math.max(0,(x+I-n)*J));m.fillText(q[I],A+this.left_offset,y+9)}}}else{m.fillStyle=this.prefs.block_color;m.fillRect(B+this.left_offset,y+(this.mode!=="Dense"?4:5),E-B,(d!=="Dense"?SQUISH_FEATURE_HEIGHT:DENSE_FEATURE_HEIGHT))}}z+=v;C+=v;break;case"N":m.fillStyle=CONNECTOR_COLOR;m.fillRect(B+this.left_offset-f,y+5,E-B,1);C+=v;break;case"D":m.fillStyle="red";m.fillRect(B+this.left_offset-f,y+4,E-B,3);C+=v;break;case"P":break;case"I":var p=compute_overlap([x,x+v],u),K=this.left_offset+B-f;if(p!==NO_OVERLAP){var q=o.slice(z,z+v);if(this.show_insertions){var w=this.left_offset+B-(E-B)/2;if((d==="Pack"||this.mode==="Auto")&&o!==undefined&&J>CHAR_WIDTH_PX){m.fillStyle="yellow";m.fillRect(w-f,y-9,E-B,9);r[r.length]={type:"triangle",data:[K,y+4,5]};m.fillStyle=CONNECTOR_COLOR;switch(p){case (OVERLAP_START):q=q.slice(n-x);break;case (OVERLAP_END):q=q.slice(0,x-D);break;case (CONTAINED_BY):break;case (CONTAINS):q=q.slice(n-x,x-D);break}for(var I=0,j=q.length;I<j;I++){var A=Math.floor(Math.max(0,(x+I-n)*J));m.fillText(q[I],A+this.left_offset-(E-B)/2,y)}}else{m.fillStyle="yellow";m.fillRect(w,y+(this.mode!=="Dense"?2:5),E-B,(d!=="Dense"?SQUISH_FEATURE_HEIGHT:DENSE_FEATURE_HEIGHT))}}else{if((d==="Pack"||this.mode==="Auto")&&o!==undefined&&J>CHAR_WIDTH_PX){r[r.length]={type:"text",data:[q.length,K,y+9]}}else{}}}z+=v;break;case"X":z+=v;break}}m.fillStyle="yellow";var t,L,H;for(var F=0;F<r.length;F++){t=r[F];L=t.type;H=t.data;if(L==="text"){m.font="bold "+DEFAULT_FONT;m.fillText(H[0],H[1],H[2]);m.font=DEFAULT_FONT}else{if(L=="triangle"){m.drawDownwardEquilateralTriangle(H[0],H[1],H[2])}}}},draw_element:function(w,y,r,k,e,A,b,n,x,u,f,c){var m=k[0],v=k[1],d=k[2],o=k[3],h=Math.floor(Math.max(0,(v-A)*n)),j=Math.ceil(Math.min(u,Math.max(0,(d-A)*n))),g=(r==="Dense"?1:(1+e))*x,z=this.prefs.block_color,l=this.prefs.label_color;t=0;w.fillStyle=z;if(k[5] instanceof Array){var s=Math.floor(Math.max(0,(k[4][0]-A)*n)),q=Math.ceil(Math.min(u,Math.max(0,(k[4][1]-A)*n))),p=Math.floor(Math.max(0,(k[5][0]-A)*n)),a=Math.ceil(Math.min(u,Math.max(0,(k[5][1]-A)*n)));if(k[4][1]>=A&&k[4][0]<=b&&k[4][2]){this.draw_read(w,r,n,A,b,k[4][0],k[4][2],k[4][3],g,c)}if(k[5][1]>=A&&k[5][0]<=b&&k[5][2]){this.draw_read(w,r,n,A,b,k[5][0],k[5][2],k[5][3],g,c)}if(p>q){w.fillStyle=CONNECTOR_COLOR;w.dashedLine(q+f,g+5,f+p,g+5)}}else{w.fillStyle=z;this.draw_read(w,r,n,A,b,v,k[4],k[5],g,c)}if(r==="Pack"&&v>A){w.fillStyle=this.prefs.label_color;if((r==="Pack"||this.mode==="Auto")&&n>CHAR_WIDTH_PX){var t=Math.round(n/2)}if(y===0&&h-w.measureText(o).width<0){w.textAlign="left";w.fillText(o,j+f+LABEL_SPACING-t,g+8)}else{w.textAlign="right";w.fillText(o,h+f-LABEL_SPACING-t,g+8)}w.fillStyle=z}}});var ToolDataFeatureTrack=function(e,c,g,a,d,f,b){FeatureTrack.call(this,e,c,g,a,d,f,{},b);this.track_type="ToolDataFeatureTrack";this.data_url=raw_data_url;this.data_query_wait=1000;this.dataset_check_url=dataset_state_url};$.extend(ToolDataFeatureTrack.prototype,TiledTrack.prototype,FeatureTrack.prototype,{predraw_init:function(){var b=this;var a=function(){if(b.data_cache.size()===0){setTimeout(a,300)}else{b.data_url=default_data_url;b.data_query_wait=DEFAULT_DATA_QUERY_WAIT;b.dataset_state_url=converted_datasets_state_url;$.getJSON(b.dataset_state_url,{dataset_id:b.dataset_id,hda_ldda:b.hda_ldda},function(c){})}};a()}});
\ No newline at end of file
+CanvasRenderingContext2D.prototype.dashedLine=function(c,j,b,h,f){if(f===undefined){f=4}var e=b-c;var d=h-j;var g=Math.floor(Math.sqrt(e*e+d*d)/f);var l=e/g;var k=d/g;var a;for(a=0;a<g;a++,c+=l,j+=k){if(a%2!==0){continue}this.fillRect(c,j,f,1)}};CanvasRenderingContext2D.prototype.drawDownwardEquilateralTriangle=function(b,a,e){var d=b-e/2,c=b+e/2,f=a-Math.sqrt(e*3/2);this.beginPath();this.moveTo(d,f);this.lineTo(c,f);this.lineTo(b,a);this.lineTo(d,f);this.strokeStyle=this.fillStyle;this.fill();this.stroke();this.closePath()};function sortable(a,b){a.bind("drag",{handle:b,relative:true},function(h,j){var g=$(this).parent();var f=g.children();var c;for(c=0;c<f.length;c++){if(j.offsetY<$(f.get(c)).position().top){break}}if(c===f.length){if(this!==f.get(c-1)){g.append(this)}}else{if(this!==f.get(c)){$(this).insertBefore(f.get(c))}}})}var NO_OVERLAP=1001,CONTAINS=1002,OVERLAP_START=1003,OVERLAP_END=1004,CONTAINED_BY=1005;function compute_overlap(e,b){var g=e[0],f=e[1],d=b[0],c=b[1],a;if(g<d){if(f<d){a=NO_OVERLAP}else{if(f<=c){a=OVERLAP_START}else{a=CONTAINS}}}else{if(g>c){a=NO_OVERLAP}else{if(f<=c){a=CONTAINED_BY}else{a=OVERLAP_END}}}return a}function is_overlap(b,a){return(compute_overlap(b,a)!==NO_OVERLAP)}var DENSE_TRACK_HEIGHT=10,NO_DETAIL_TRACK_HEIGHT=3,SQUISH_TRACK_HEIGHT=5,PACK_TRACK_HEIGHT=10,NO_DETAIL_FEATURE_HEIGHT=1,DENSE_FEATURE_HEIGHT=1,SQUISH_FEATURE_HEIGHT=3,PACK_FEATURE_HEIGHT=9,ERROR_PADDING=10,LABEL_SPACING=2,PACK_SPACING=5,MIN_SQUISH_VIEW_WIDTH=12000,DEFAULT_FONT="9px Monaco, Lucida Console, monospace",DENSITY=200,FEATURE_LEVELS=10,MAX_FEATURE_DEPTH=100,DEFAULT_DATA_QUERY_WAIT=5000,MAX_CHROMS_SELECTABLE=100,CONNECTOR_COLOR="#ccc",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_CANNOT_RUN_TOOL="Tool cannot be rerun: ",DATA_LOADING="Loading data...",DATA_OK="Ready for display",CACHED_TILES_FEATURE=10,CACHED_TILES_LINE=5,CACHED_DATA=5,DUMMY_CANVAS=document.createElement("canvas"),RIGHT_STRAND,LEFT_STRAND;if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(DUMMY_CANVAS)}var CONTEXT=DUMMY_CANVAS.getContext("2d");CONTEXT.font=DEFAULT_FONT;var CHAR_WIDTH_PX=CONTEXT.measureText("A").width,CHAR_HEIGHT_PX=9;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.move_key_to_end(b,a)}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},move_key_to_end:function(b,a){this.key_ary.splice(a,1);this.key_ary.push(b)},clear:function(){this.obj_cache={};this.key_ary=[]},size:function(){return this.key_ary.length}});var DataManager=function(b,a,c){Cache.call(this,b);this.track=a;this.subset=(c!==undefined?c:true)};$.extend(DataManager.prototype,Cache.prototype,{load_data:function(d,a,f,h,b,e){var g={chrom:d,low:a,high:f,mode:h,resolution:b,dataset_id:this.track.dataset_id,hda_ldda:this.track.hda_ldda};$.extend(g,e);var c=this;return $.getJSON(this.track.data_url,g,function(j){c.set_data(a,f,h,j)})},get_data:function(j,k,c,h,b,f){var l=this.get(this.gen_key(k,c,h));if(l){return l}if(this.subset){var m,g,a,e,h,l;for(var d=0;d<this.key_ary.length;d++){m=this.key_ary[d];g=this.split_key(m);a=g[0];e=g[1];if(k>=a&&c<=e){l=this.obj_cache[m];if(l.dataset_type!=="summary_tree"&&l.extra_info!=="no_detail"){this.move_key_to_end(m,d);return l}}}}return this.load_data(j,k,c,h,b,f)},set_data:function(b,c,d,a){return this.set(this.gen_key(b,c,d),a)},gen_key:function(a,c,d){var b=a+"_"+c+"_"+d;return b},split_key:function(a){return a.split("_")}});var View=function(a,d,c,b,e){this.container=a;this.chrom=null;this.vis_id=c;this.dbkey=b;this.title=d;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(e);this.reset()};$.extend(View.prototype,{init:function(d){var c=this.container,a=this;this.top_container=$("<div/>").addClass("top-container").appendTo(c);this.content_div=$("<div/>").addClass("content").css("position","relative").appendTo(c);this.bottom_container=$("<div/>").addClass("bottom-container").appendTo(c);this.top_labeltrack=$("<div/>").addClass("top-labeltrack").appendTo(this.top_container);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_labeltrack=$("<div/>").addClass("nav-labeltrack").appendTo(this.bottom_container);this.nav_container=$("<div/>").addClass("nav-container").prependTo(this.top_container);this.nav=$("<div/>").addClass("nav").appendTo(this.nav_container);this.overview=$("<div/>").addClass("overview").appendTo(this.bottom_container);this.overview_viewport=$("<div/>").addClass("overview-viewport").appendTo(this.overview);this.overview_close=$("<a 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_select=$("<select/>").attr({name:"chrom"}).css("width","15em").addClass("no-autocomplete").append("<option value=''>Loading</option>").appendTo(this.nav_controls);var b=function(f){if(f.type==="focusout"||(f.keyCode||f.which)===13||(f.keyCode||f.which)===27){if((f.keyCode||f.which)!==27){a.go_to($(this).val())}$(this).hide();$(this).val("");a.location_span.show();a.chrom_select.show()}};this.nav_input=$("<input/>").addClass("nav-input").hide().bind("keyup focusout",b).appendTo(this.nav_controls);this.location_span=$("<span/>").addClass("location").appendTo(this.nav_controls);this.location_span.bind("click",function(){a.location_span.hide();a.chrom_select.hide();a.nav_input.val(a.chrom+":"+a.low+"-"+a.high);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.nav_controls)}this.zo_link=$("<a id='zoom-out' />").click(function(){a.zoom_out();a.redraw()}).appendTo(this.nav_controls);this.zi_link=$("<a id='zoom-in' />").click(function(){a.zoom_in();a.redraw()}).appendTo(this.nav_controls);this.load_chroms({low:0},d);this.chrom_select.bind("change",function(){a.change_chrom(a.chrom_select.val())});this.intro_div.show();this.content_div.bind("click",function(f){$(this).find("input").trigger("blur")});this.content_div.bind("dblclick",function(f){a.zoom_in(f.pageX,this.viewport_container)});this.overview_box.bind("dragstart",function(f,g){this.current_x=g.offsetX}).bind("drag",function(f,h){var j=h.offsetX-this.current_x;this.current_x=h.offsetX;var g=Math.round(j/a.viewport_container.width()*(a.max_high-a.max_low));a.move_delta(-g)});this.overview_close.bind("click",function(){for(var f=0,e=a.tracks.length;f<e;f++){a.tracks[f].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("draginit",function(f,g){if(f.clientX>a.viewport_container.width()-16){return false}}).bind("dragstart",function(f,g){g.original_low=a.low;g.current_height=f.clientY;g.current_x=g.offsetX}).bind("drag",function(h,k){var f=$(this);var l=k.offsetX-k.current_x;var g=f.scrollTop()-(h.clientY-k.current_height);f.scrollTop(g);k.current_height=h.clientY;k.current_x=k.offsetX;var j=Math.round(l/a.viewport_container.width()*(a.high-a.low));a.move_delta(j)}).bind("mousewheel",function(h,k,g,f){if(g){var j=Math.round(-g/a.viewport_container.width()*(a.high-a.low));a.move_delta(j)}});this.top_labeltrack.bind("dragstart",function(f,g){return $("<div />").css({height:a.content_div.height()+a.top_labeltrack.height()+a.nav_labeltrack.height()+1,top:"0px",position:"absolute","background-color":"#ccf",opacity:0.5,"z-index":1000}).appendTo($(this))}).bind("drag",function(k,l){$(l.proxy).css({left:Math.min(k.pageX,l.startX),width:Math.abs(k.pageX-l.startX)});var g=Math.min(k.pageX,l.startX)-a.container.offset().left,f=Math.max(k.pageX,l.startX)-a.container.offset().left,j=(a.high-a.low),h=a.viewport_container.width();a.update_location(Math.round(g/h*j)+a.low,Math.round(f/h*j)+a.low)}).bind("dragend",function(l,m){var g=Math.min(l.pageX,m.startX),f=Math.max(l.pageX,m.startX),j=(a.high-a.low),h=a.viewport_container.width(),k=a.low;a.low=Math.round(g/h*j)+k;a.high=Math.round(f/h*j)+k;$(m.proxy).remove();a.redraw()});this.add_label_track(new LabelTrack(this,this.top_labeltrack));this.add_label_track(new LabelTrack(this,this.nav_labeltrack));$(window).bind("resize",function(){a.resize_window()});$(document).bind("redraw",function(){a.redraw()});this.reset();$(window).trigger("resize")},update_location:function(a,b){this.location_span.text(commatize(a)+" - "+commatize(b));this.nav_input.val(this.chrom+":"+commatize(a)+"-"+commatize(b))},load_chroms:function(b,c){b.num=MAX_CHROMS_SELECTABLE;$.extend(b,(this.vis_id!==undefined?{vis_id:this.vis_id}:{dbkey:this.dbkey}));var a=this;$.ajax({url:chrom_url,data:b,dataType:"json",success:function(e){if(e.chrom_info.length===0){alert("Invalid chromosome: "+b.chrom);return}if(e.reference){a.add_label_track(new ReferenceTrack(a))}a.chrom_data=e.chrom_info;var h='<option value="">Select Chrom/Contig</option>';for(var g=0,d=a.chrom_data.length;g<d;g++){var f=a.chrom_data[g].chrom;h+='<option value="'+f+'">'+f+"</option>"}if(e.prev_chroms){h+='<option value="previous">Previous '+MAX_CHROMS_SELECTABLE+"</option>"}if(e.next_chroms){h+='<option value="next">Next '+MAX_CHROMS_SELECTABLE+"</option>"}a.chrom_select.html(h);if(c){c()}a.chrom_start_index=e.start_index},error:function(){alert("Could not load chroms for this dbkey:",a.dbkey)}})},change_chrom:function(e,b,g){if(!e||e==="None"){return}var d=this;if(e==="previous"){d.load_chroms({low:this.chrom_start_index-MAX_CHROMS_SELECTABLE});return}if(e==="next"){d.load_chroms({low:this.chrom_start_index+MAX_CHROMS_SELECTABLE});return}var f=$.grep(d.chrom_data,function(j,k){return j.chrom===e})[0];if(f===undefined){d.load_chroms({chrom:e},function(){d.change_chrom(e,b,g)});return}else{if(e!==d.chrom){d.chrom=e;if(!d.chrom){d.intro_div.show()}else{d.intro_div.hide()}d.chrom_select.val(d.chrom);d.max_high=f.len-1;d.reset();d.redraw(true);for(var h=0,a=d.tracks.length;h<a;h++){var c=d.tracks[h];if(c.init){c.init()}}}if(b!==undefined&&g!==undefined){d.low=Math.max(b,0);d.high=Math.min(g,d.max_high)}d.reset_overview();d.redraw()}},go_to:function(f){var k=this,a,d,b=f.split(":"),h=b[0],j=b[1];if(j!==undefined){try{var g=j.split("-");a=parseInt(g[0].replace(/,/g,""),10);d=parseInt(g[1].replace(/,/g,""),10)}catch(c){return false}}k.change_chrom(h,a,d)},move_fraction:function(c){var a=this;var b=a.high-a.low;this.move_delta(c*b)},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);sortable(a.container_div,".draghandle");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())||0;var e=((this.high-this.low)/(this.max_high-this.max_low)*this.overview_viewport.width())||0;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_location(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(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()},resize_window:function(){this.viewport_container.height(this.container.height()-this.top_container.height()-this.bottom_container.height());this.nav_container.width(this.container.width());this.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 Tool=function(a,b){this.name=a;this.params=b};$.extend(Tool.prototype,{get_param_values_dict:function(){var b={};for(var a=0;a<this.params.length;a++){var c=this.params[a];b[c.name]=c.value}return b},get_param_values:function(){var b=[];for(var a=0;a<this.params.length;a++){b[a]=this.params[a].value}return b}});var NumberToolParameter=function(c,b,e,a,d){this.name=c;this.label=b;this.min=e;this.max=a;this.value=d};var get_tool_from_dict=function(f){if(obj_length(f)===0){return undefined}var b=f.name;var l=f.params;var c=Array();for(var e=0;e<l.length;e++){var g=l[e];var a=g.name,k=g.label,h=g.type,d=g.min,j=g.max,m=g.value;c[c.length]=new NumberToolParameter(a,k,d,j,m)}return new Tool(b,c)};var Filter=function(b,a,c){this.name=b;this.index=a;this.value=c};var NumberFilter=function(b,a){this.name=b;this.index=a;this.low=-Number.MAX_VALUE;this.high=Number.MAX_VALUE;this.slider_min=Number.MAX_VALUE;this.slider_max=-Number.MAX_VALUE;this.slider=null;this.slider_label=null};$.extend(NumberFilter.prototype,{applies_to:function(a){if(a.length>this.index){return true}return false},keep:function(a){if(!this.applies_to(a)){return true}return(a[this.index]>=this.low&&a[this.index]<=this.high)},update_attrs:function(b){var a=false;if(!this.applies_to(b)){return a}if(b[this.index]<this.slider_min){this.slider_min=b[this.index];a=true}if(b[this.index]>this.slider_max){this.slider_max=b[this.index];a=false}return a},update_ui_elt:function(){var b=this.slider.slider("option","min"),a=this.slider.slider("option","max");if(this.slider_min<b||this.slider_max>a){this.slider.slider("option","min",this.slider_min);this.slider.slider("option","max",this.slider_max);this.slider.slider("option","values",[this.slider_min,this.slider_max])}}});var get_filters_from_dict=function(a){var g=[];for(var d=0;d<a.length;d++){var f=a[d];var c=f.name,e=f.type,b=f.index;if(e==="int"||e==="float"){g[d]=new NumberFilter(c,b)}else{g[d]=new Filter(c,b,e)}}return g};var TrackConfig=function(a){this.track=a.track;this.params=a.params;this.values={};if(a.saved_values){this.restore_values(a.saved_values)}this.onchange=a.onchange};$.extend(TrackConfig.prototype,{restore_values:function(a){var b=this;$.each(this.params,function(c,d){if(a[d.key]!==undefined){b.values[d.key]=a[d.key]}else{b.values[d.key]=d.default_value}})},build_form:function(){var b=this;var a=$("<div />");$.each(this.params,function(f,d){if(!d.hidden){var c="param_"+f;var l=$("<div class='form-row' />").appendTo(a);l.append($("<label />").attr("for",c).text(d.label+":"));if(d.type==="bool"){l.append($('<input type="checkbox" />').attr("id",c).attr("name",c).attr("checked",b.values[d.key]))}else{if(d.type==="color"){var h=b.values[d.key];var g=$("<input />").attr("id",c).attr("name",c).val(h);var j=$("<div class='tipsy tipsy-north' style='position: absolute;' />").hide();var e=$("<div style='background-color: black; padding: 10px;'></div>").appendTo(j);var k=$("<div/>").appendTo(e).farbtastic({width:100,height:100,callback:g,color:h});$("<div />").append(g).append(j).appendTo(l).bind("click",function(m){j.css({left:$(this).position().left+($(g).width()/2)-60,top:$(this).position().top+$(this.height)}).show();$(document).bind("click.color-picker",function(){j.hide();$(document).unbind("click.color-picker")});m.stopPropagation()})}else{l.append($("<input />").attr("id",c).attr("name",c).val(b.values[d.key]))}}}});return a},update_from_form:function(a){var c=this;var b=false;$.each(this.params,function(d,f){if(!f.hidden){var g="param_"+d;var e=a.find("#"+g).val();if(f.type==="float"){e=parseFloat(e)}else{if(f.type==="int"){e=parseInt(e)}else{if(f.type==="bool"){e=a.find("#"+g).is(":checked")}}}if(e!==c.values[f.key]){c.values[f.key]=e;b=true}}});if(b){this.onchange()}}});var Track=function(b,a,e,c,d){this.name=b;this.view=a;this.parent_element=e;this.data_url=(c?c:default_data_url);this.data_url_extra_params={};this.data_query_wait=(d?d:DEFAULT_DATA_QUERY_WAIT);this.dataset_check_url=converted_datasets_state_url;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.name_div.attr("id",this.name.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9\-]/g,"").toLowerCase())}this.content_div=$("<div class='track-content'>").appendTo(this.container_div);this.parent_element.append(this.container_div)};$.extend(Track.prototype,{init:function(){var a=this;a.enabled=false;a.tile_cache.clear();a.data_cache.clear();a.initial_canvas=undefined;a.content_div.css("height","auto");a.container_div.removeClass("nodata error pending");if(!a.dataset_id){return}$.getJSON(converted_datasets_state_url,{hda_ldda:a.hda_ldda,dataset_id:a.dataset_id,chrom:a.view.chrom},function(b){if(!b||b==="error"||b.kind==="error"){a.container_div.addClass("error");a.content_div.text(DATA_ERROR);if(b.message){var d=a.view.tracks.indexOf(a);var c=$(" <a href='javascript:void(0);'></a>").text("View error").bind("click",function(){show_modal("Trackster Error","<pre>"+b.message+"</pre>",{Close:hide_modal})});a.content_div.append(c)}}else{if(b==="no converter"){a.container_div.addClass("error");a.content_div.text(DATA_NOCONVERTER)}else{if(b==="no data"||(b.data!==undefined&&(b.data===null||b.data.length===0))){a.container_div.addClass("nodata");a.content_div.text(DATA_NONE)}else{if(b==="pending"){a.container_div.addClass("pending");a.content_div.text(DATA_PENDING);setTimeout(function(){a.init()},a.data_query_wait)}else{if(b.status==="data"){if(b.valid_chroms){a.valid_chroms=b.valid_chroms;a.make_name_popup_menu()}a.content_div.text(DATA_OK);if(a.view.chrom){a.content_div.text("");a.content_div.css("height",a.height_px+"px");a.enabled=true;$.when(a.predraw_init()).done(function(){a.draw()})}}}}}}})},predraw_init:function(){},update_name:function(a){this.old_name=this.name;this.name=a;this.name_div.text(this.name)},revert_name:function(){this.name=this.old_name;this.name_div.text(this.name)}});var TiledTrack=function(b,j,n){var c=this,o=c.view;this.filters=(b!==undefined?get_filters_from_dict(b):[]);this.filters_available=false;this.filters_visible=false;this.tool=(j!==undefined?get_tool_from_dict(j):undefined);this.parent_track=n;this.child_tracks=[];if(c.hidden){return}if(this.parent_track){this.header_div.find(".draghandle").removeClass("draghandle").addClass("child-track-icon").addClass("icon-button");this.parent_element.addClass("child-track");this.tool=undefined}this.filters_div=$("<div/>").addClass("filters").hide();this.header_div.after(this.filters_div);this.filters_div.bind("drag",function(q){q.stopPropagation()}).bind("dblclick",function(q){q.stopPropagation()});$.each(this.filters,function(t,w){var u=$("<div/>").addClass("slider-row").appendTo(c.filters_div);var v=$("<div/>").addClass("slider-label").appendTo(u);var s=$("<span/>").addClass("name").appendTo(v);s.text(w.name+" ");var r=$("<span/>").addClass("values").appendTo(v);var q=$("<div/>").addClass("slider").appendTo(u);w.control_element=$("<div/>").attr("id",w.name+"-filter-control").appendTo(q);w.control_element.slider({range:true,min:Number.MAX_VALUE,max:-Number.MIN_VALUE,values:[0,0],slide:function(y,z){var x=z.values;r.text("["+x[0]+"-"+x[1]+"]");w.low=x[0];w.high=x[1];c.draw(true,true)},change:function(x,y){w.control_element.slider("option","slide").call(w.control_element,x,y)}});w.slider=w.control_element;w.slider_label=r;$("<div style='clear: both;'/>").appendTo(u)});if(this.tool){this.dynamic_tool_div=$("<div/>").addClass("dynamic-tool").hide();this.header_div.after(this.dynamic_tool_div);this.dynamic_tool_div.bind("drag",function(q){q.stopPropagation()}).bind("click",function(q){q.stopPropagation()}).bind("dblclick",function(q){q.stopPropagation()});var m=$("<div class='tool-name'>").appendTo(this.dynamic_tool_div).text(this.tool.name);var l=this.tool.params;var c=this;$.each(this.tool.params,function(x,s){var v=$("<div>").addClass("slider-row").appendTo(c.dynamic_tool_div);var u=$("<div>").addClass("slider-label").appendTo(v);var z=$("<span class='param-name'>").text(s.label+" ").appendTo(u);var t=$("<span/>").text(s.value);var w=$("<span class='param-value'>").appendTo(u).append("[").append(t).append("]");var y=$("<div/>").addClass("slider").appendTo(v);var q=$("<div id='"+s.name+"-param-control'>").appendTo(y);var r=(s.max<=1?0.01:(s.max<=1000?1:5));q.slider({min:s.min,max:s.max,step:r,value:s.value,slide:function(A,C){var B=C.value;s.value=B;if(0<B&&B<1){B=parseFloat(B).toFixed(2)}t.text(B)},change:function(A,B){s.value=B.value}});w.click(function(){var C=t,B=C.text(),A=(s.max<=1?4:s.max.length);C.text("");$("<input type='text'/>").attr("size",A).attr("maxlength",A).attr("value",B).appendTo(C).focus().select().click(function(D){D.stopPropagation()}).blur(function(){$(this).remove();C.text(B)}).keyup(function(F){if(F.keyCode===27){$(this).trigger("blur")}else{if(F.keyCode===13){var D=$(this),E=parseFloat(D.val());if(isNaN(E)||E>s.max||E<s.min){alert("Parameter value must be in the range ["+s.min+"-"+s.max+"]");return $(this)}C.text(E);q.slider("value",E);s.value=E}}})});$("<div style='clear: both;'/>").appendTo(v)});var p=$("<div>").addClass("slider-row").appendTo(this.dynamic_tool_div);var k=$("<input type='submit'>").attr("value","Run").appendTo(p);var c=this;k.click(function(){c.run_tool()})}c.child_tracks_container=$("<div/>").addClass("child-tracks-container").hide();c.container_div.append(c.child_tracks_container);if(c.display_modes!==undefined){if(c.mode_div===undefined){c.mode_div=$("<div class='right-float menubutton popup' />").appendTo(c.header_div);var e=(c.track_config&&c.track_config.values.mode?c.track_config.values.mode:c.display_modes[0]);c.mode=e;c.mode_div.text(e);var d=function(q){c.mode_div.text(q);c.mode=q;c.track_config.values.mode=q;c.tile_cache.clear();c.draw()};var a={};for(var f=0,h=c.display_modes.length;f<h;f++){var g=c.display_modes[f];a[g]=function(q){return function(){d(q)}}(g)}make_popupmenu(c.mode_div,a)}else{c.mode_div.hide()}}this.make_name_popup_menu()};$.extend(TiledTrack.prototype,Track.prototype,{make_name_popup_menu:function(){var b=this;var a={};a["Edit configuration"]=function(){var h=function(){hide_modal();$(window).unbind("keypress.check_enter_esc")},f=function(){b.track_config.update_from_form($(".dialog-box"));hide_modal();$(window).unbind("keypress.check_enter_esc")},g=function(j){if((j.keyCode||j.which)===27){h()}else{if((j.keyCode||j.which)===13){f()}}};$(window).bind("keypress.check_enter_esc",g);show_modal("Configure Track",b.track_config.build_form(),{Cancel:h,OK:f})};if(b.filters_available>0){var e=(b.filters_div.is(":visible")?"Hide filters":"Show filters");a[e]=function(){b.filters_visible=(b.filters_div.is(":visible"));b.filters_div.toggle();b.make_name_popup_menu()}}if(b.tool){var e=(b.dynamic_tool_div.is(":visible")?"Hide Tool":"Show Tool");a[e]=function(){if(!b.dynamic_tool_div.is(":visible")){b.update_name(b.name+b.tool_region_and_parameters_str())}else{menu_option_text="Show dynamic tool";b.revert_name()}b.dynamic_tool_div.toggle();b.make_name_popup_menu()}}if(b.valid_chroms){a["List chrom/contigs with data"]=function(){show_modal("Chrom/contigs with data","<p>"+b.valid_chroms.join("<br/>")+"</p>",{Close:function(){hide_modal()}})}}var c=view;var d=function(){$("#no-tracks").show()};if(this.parent_track){c=this.parent_track;d=function(){}}a.Remove=function(){c.remove_track(b);if(c.num_tracks===0){d()}};make_popupmenu(b.name_div,a)},draw:function(a,d){var s=this.view.low,g=this.view.high,j=g-s,l=this.view.container.width(),m=this.view.resolution;var e=$("<div style='position: relative;'></div>"),f=l/j;if(!d){this.content_div.children().remove()}this.content_div.append(e);this.max_height=0;var o=Math.floor(s/m/DENSITY);var c={};while((o*DENSITY*m)<g){var r=l+"_"+f+"_"+o;var h=this.tile_cache.get(r);var p=o*DENSITY*this.view.resolution;var b=p+DENSITY*this.view.resolution;if(!a&&h){this.show_tile(h,e,p,f)}else{this.delayed_draw(a,r,p,b,o,m,e,f,c)}o+=1}if(d){var k=this;var q=setInterval(function(){if(obj_length(c)===0){var v=k.content_div.children();var u=false;for(var w=v.length-1,t=0;w>=t;w--){var x=$(v[w]);if(u){x.remove()}else{if(x.children().length!==0){u=true}}}clearInterval(q)}},50)}for(var n=0;n<this.child_tracks.length;n++){this.child_tracks[n].draw(a,d)}},delayed_draw:function(b,j,g,l,c,e,k,m,f){var d=this;var h=function(u,n,p,o,s,t,q){returned_tile=d.draw_tile(n,p,o,s,t,q);var r=$("<div class='track-tile'>").prepend(returned_tile);tile_element=r;d.tile_cache.set(j,tile_element);d.show_tile(tile_element,s,g,t);delete f[u]};var a=setTimeout(function(){if(g<=d.view.high&&l>=d.view.low){var n=(b?undefined:d.tile_cache.get(j));if(n){d.show_tile(n,k,g,m);delete f[a]}else{$.when(d.data_cache.get_data(view.chrom,g,l,d.mode,e,d.data_url_extra_params)).then(function(){var o=d.data_cache.get_data(view.chrom,g,l,d.mode,e,d.data_url_extra_params);if(view.reference_track&&m>CHAR_WIDTH_PX){$.when(view.reference_track.data_cache.get_data(view.chrom,g,l,d.mode,e,view.reference_track.data_url_extra_params)).then(function(){var p=view.reference_track.data_cache.get_data(view.chrom,g,l,d.mode,e,view.reference_track.data_url_extra_params);h(a,o,e,c,k,m,p)})}else{h(a,o,e,c,k,m)}})}}},50);f[a]=true},show_tile:function(h,j,e,k){var a=this;var c=this.view.high-this.view.low,b=(e-this.view.low)*k;if(this.left_offset){b-=this.left_offset}h.css({position:"absolute",top:0,left:b,height:""});j.append(h);a.max_height=Math.max(a.max_height,h.height());a.content_div.css("height",a.max_height+"px");j.children().css("height",a.max_height+"px");if(a.hidden){return}for(var g=0;g<a.filters.length;g++){a.filters[g].update_ui_elt()}var d=false;if(a.example_feature){for(var g=0;g<a.filters.length;g++){if(a.filters[g].applies_to(a.example_feature)){d=true;break}}}if(a.filters_available!==d){a.filters_available=d;if(!a.filters_available){a.filters_div.hide()}a.make_name_popup_menu()}},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")},run_tool:function(){var b={dataset_id:this.original_dataset_id,chrom:this.view.chrom,low:this.view.low,high:this.view.high,tool_id:this.tool.name};$.extend(b,this.tool.get_param_values_dict());var d=this,c=b.tool_id+d.tool_region_and_parameters_str(b.chrom,b.low,b.high),e;if(d.track_type==="FeatureTrack"){e=new ToolDataFeatureTrack(c,view,d.hda_ldda,undefined,{},{},d)}this.add_track(e);e.content_div.text("Starting job.");view.has_changes=true;var a=function(){$.getJSON(run_tool_url,b,function(f){if(f==="no converter"){e.container_div.addClass("error");e.content_div.text(DATA_NOCONVERTER)}else{if(f.error){e.container_div.addClass("error");e.content_div.text(DATA_CANNOT_RUN_TOOL+f.message)}else{if(f==="pending"){e.container_div.addClass("pending");e.content_div.text("Converting input data so that it can be easily reused.");setTimeout(a,2000)}else{e.dataset_id=f.dataset_id;e.content_div.text("Running job.");e.init()}}}})};a()},tool_region_and_parameters_str:function(c,a,d){var b=this,e=(c!==undefined&&a!==undefined&&d!==undefined?c+":"+a+"-"+d:"all");return" - region=["+e+"], parameters=["+b.tool.get_param_values().join(", ")+"]"},add_track:function(a){a.track_id=this.track_id+"_"+this.child_tracks.length;a.container_div.attr("id","track_"+a.track_id);this.child_tracks_container.append(a.container_div);sortable(a.container_div,".child-track-icon");if(!$(this.child_tracks_container).is(":visible")){this.child_tracks_container.show()}this.child_tracks.push(a)},remove_track:function(a){a.container_div.fadeOut("slow",function(){$(this).remove()})}});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.view.container.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);a.reference_track=this;this.left_offset=200;this.height_px=12;this.font=DEFAULT_FONT;this.container_div.addClass("reference-track");this.content_div.css("background","none");this.content_div.css("min-height","0px");this.content_div.css("border","none");this.data_url=reference_url;this.data_url_extra_params={dbkey:a.dbkey};this.data_cache=new DataManager(CACHED_DATA,this,false);this.tile_cache=new Cache(CACHED_TILES_LINE)};$.extend(ReferenceTrack.prototype,TiledTrack.prototype,{draw_tile:function(m,g,b,j,n){var f=this,d=DENSITY*g;if(n>CHAR_WIDTH_PX){if(m===null){f.content_div.css("height","0px");return}var e=document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(e)}e=$(e);var l=e.get(0).getContext("2d");e.get(0).width=Math.ceil(d*n+f.left_offset);e.get(0).height=f.height_px;l.font=DEFAULT_FONT;l.textAlign="center";for(var h=0,k=m.length;h<k;h++){var a=Math.round(h*n);l.fillText(m[h],a+f.left_offset,10)}return e}this.content_div.css("height","0px")}});var LineTrack=function(e,c,f,a,d){var b=this;this.track_type="LineTrack";this.display_modes=["Histogram","Line","Filled","Intensity"];this.mode="Histogram";Track.call(this,e,c,c.viewport_container);TiledTrack.call(this);this.min_height_px=16;this.max_height_px=400;this.height_px=80;this.hda_ldda=f;this.dataset_id=a;this.original_dataset_id=a;this.data_cache=new DataManager(CACHED_DATA,this);this.tile_cache=new Cache(CACHED_TILES_LINE);this.track_config=new TrackConfig({track:this,params:[{key:"color",label:"Color",type:"color",default_value:"black"},{key:"min_value",label:"Min Value",type:"float",default_value:undefined},{key:"max_value",label:"Max Value",type:"float",default_value:undefined},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"height",type:"int",default_value:this.height_px,hidden:true}],saved_values:d,onchange:function(){b.vertical_range=b.prefs.max_value-b.prefs.min_value;$("#linetrack_"+b.track_id+"_minval").text(b.prefs.min_value);$("#linetrack_"+b.track_id+"_maxval").text(b.prefs.max_value);b.tile_cache.clear();b.draw()}});this.prefs=this.track_config.values;this.height_px=this.track_config.values.height;this.vertical_range=this.track_config.values.max_value-this.track_config.values.min_value;(function(g){var k=false;var j=false;var h=$("<div class='track-resize'>");$(g.container_div).hover(function(){k=true;h.show()},function(){k=false;if(!j){h.hide()}});h.hide().bind("dragstart",function(l,m){j=true;m.original_height=$(g.content_div).height()}).bind("drag",function(m,n){var l=Math.min(Math.max(n.original_height+n.deltaY,g.min_height_px),g.max_height_px);$(g.content_div).css("height",l);g.height_px=l;g.draw(true)}).bind("dragend",function(l,m){g.tile_cache.clear();j=false;if(!k){h.hide()}g.track_config.values.height=g.height_px}).appendTo(g.container_div)})(this)};$.extend(LineTrack.prototype,TiledTrack.prototype,{predraw_init:function(){var a=this,b=a.view.tracks.indexOf(a);a.vertical_range=undefined;return $.getJSON(a.data_url,{stats:true,chrom:a.view.chrom,low:null,high:null,hda_ldda:a.hda_ldda,dataset_id:a.dataset_id},function(c){a.container_div.addClass("line-track");var e=c.data;if(isNaN(parseFloat(a.prefs.min_value))||isNaN(parseFloat(a.prefs.max_value))){a.prefs.min_value=e.min;a.prefs.max_value=e.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=e.total_frequency;a.container_div.find(".yaxislabel").remove();var f=$("<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.css({position:"absolute",top:"24px",left:"10px"});d.prependTo(a.container_div);f.css({position:"absolute",bottom:"2px",left:"10px"});f.prependTo(a.container_div)})},draw_tile:function(j,q,t,c,e){if(this.vertical_range===undefined){return}var o=this,u=t*DENSITY*q,a=DENSITY*q,B=q+"_"+t,v={hda_ldda:this.hda_ldda,dataset_id:this.dataset_id,resolution:this.view.resolution};var b=document.createElement("canvas"),z=j.data;if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(b)}b=$(b);b.get(0).width=Math.ceil(a*e);b.get(0).height=o.height_px;var p=b.get(0).getContext("2d"),k=false,l=o.prefs.min_value,g=o.prefs.max_value,n=o.vertical_range,w=o.total_frequency,d=o.height_px,m=o.mode;var A=Math.round(d+l/n*d);p.beginPath();p.moveTo(0,A);p.lineTo(a*e,A);p.fillStyle="#aaa";p.stroke();p.beginPath();p.fillStyle=o.prefs.color;var x,h,f;if(z.length>1){f=Math.ceil((z[1][0]-z[0][0])*e)}else{f=10}for(var r=0,s=z.length;r<s;r++){x=Math.round((z[r][0]-u)*e);h=z[r][1];if(h===null){if(k&&m==="Filled"){p.lineTo(x,d)}k=false;continue}if(h<l){h=l}else{if(h>g){h=g}}if(m==="Histogram"){h=Math.round(h/n*d);p.fillRect(x,A,f,-h)}else{if(m==="Intensity"){h=255-Math.floor((h-l)/n*255);p.fillStyle="rgb("+h+","+h+","+h+")";p.fillRect(x,0,f,d)}else{h=Math.round(d-(h-l)/n*d);if(k){p.lineTo(x,h)}else{k=true;if(m==="Filled"){p.moveTo(x,d);p.lineTo(x,h)}else{p.moveTo(x,h)}}}}}if(m==="Filled"){if(k){p.lineTo(x,A);p.lineTo(0,A)}p.fill()}else{p.stroke()}return b}});var FeatureTrack=function(a,f,e,j,h,c,d,g){var b=this;this.track_type="FeatureTrack";this.display_modes=["Auto","Dense","Squish","Pack"];this.track_config=new TrackConfig({track:this,params:[{key:"block_color",label:"Block color",type:"color",default_value:"#444"},{key:"label_color",label:"Label color",type:"color",default_value:"black"},{key:"show_counts",label:"Show summary counts",type:"bool",default_value:true},{key:"mode",type:"string",default_value:this.mode,hidden:true},],saved_values:h,onchange:function(){b.tile_cache.clear();b.draw()}});this.prefs=this.track_config.values;Track.call(this,a,f,f.viewport_container);TiledTrack.call(this,c,d,g);this.height_px=0;this.container_div.addClass("feature-track");this.hda_ldda=e;this.dataset_id=j;this.original_dataset_id=j;this.zo_slots={};this.show_labels_scale=0.001;this.showing_details=false;this.summary_draw_height=30;this.default_font=DEFAULT_FONT;this.inc_slots={};this.start_end_dct={};this.tile_cache=new Cache(CACHED_TILES_FEATURE);this.data_cache=new DataManager(20,this);this.left_offset=200};$.extend(FeatureTrack.prototype,TiledTrack.prototype,{incremental_slots:function(a,h,p){var q=this.inc_slots[a];if(!q||(q.mode!==p)){q={};q.w_scale=a;q.mode=p;this.inc_slots[a]=q;this.start_end_dct[a]={}}var l=q.w_scale,w=[],x=[],j=0,n=this.view.max_low;for(var u=0,v=h.length;u<v;u++){var g=h[u],k=g[0];if(q[k]!==undefined){j=Math.max(j,q[k]);x.push(q[k])}else{w.push(u)}}var d=this.start_end_dct[a];var m=function(D,E){for(var C=0;C<=MAX_FEATURE_DEPTH;C++){var A=false,F=d[C];if(F!==undefined){for(var z=0,B=F.length;z<B;z++){var y=F[z];if(E>y[0]&&D<y[1]){A=true;break}}}if(!A){return C}}return -1};for(var u=0,v=w.length;u<v;u++){var g=h[w[u]],k=g[0],s=g[1],b=g[2],o=g[3],c=Math.floor((s-n)*l),f=Math.ceil((b-n)*l),t=CONTEXT.measureText(o).width,e;if(o!==undefined&&p==="Pack"){t+=(LABEL_SPACING+PACK_SPACING);if(c-t>=0){c-=t;e="left"}else{f+=t;e="right"}}var r=m(c,f);if(r>=0){if(d[r]===undefined){d[r]=[]}d[r].push([c,f]);q[k]=r;j=Math.max(j,r)}else{}}return j+1},draw_summary_tree:function(b,o,n,l,r,j,f,e){var c=j+LABEL_SPACING+CHAR_HEIGHT_PX;delta_x_px=Math.ceil(n*r);var h=$("<div />").addClass("yaxislabel");h.text(l);h.css({position:"absolute",top:"22px",left:"10px"});h.prependTo(this.container_div);var q=b.get(0).getContext("2d");for(var d=0,g=o.length;d<g;d++){var m=Math.floor((o[d][0]-f)*r);var k=o[d][1];if(!k){continue}var p=k/l*j;q.fillStyle="black";q.fillRect(m+e,c-p,delta_x_px,p);var a=4;if(this.prefs.show_counts&&(q.measureText(k).width+a)<delta_x_px){q.fillStyle="#666";q.textAlign="center";q.fillText(k,m+e+(delta_x_px/2),10)}}},draw_element:function(p,f,g,x,j,r,I,M,N,a,A){var u=x[0],K=x[1],C=x[2]-1,s=x[3],D=Math.floor(Math.max(0,(K-r)*M)),q=Math.ceil(Math.min(a,Math.max(0,(C-r)*M))),B=ERROR_PADDING+(g==="Dense"?0:(0+j))*N,o,G,t=null,O=null,d=this.prefs.block_color,F=this.prefs.label_color;if(g==="Dense"){p.fillStyle=d;p.fillRect(D+A,B,q-D,DENSE_FEATURE_HEIGHT)}else{if(g==="no_detail"){p.fillStyle=d;p.fillRect(D+A,B+5,q-D,DENSE_FEATURE_HEIGHT)}else{var n=x[5],z=x[6],E=x[7],e=x[8];if(z&&E){t=Math.floor(Math.max(0,(z-r)*M));O=Math.ceil(Math.min(a,Math.max(0,(E-r)*M)))}var L,v;if(g==="Squish"){L=1;v=SQUISH_FEATURE_HEIGHT}else{L=5;v=PACK_FEATURE_HEIGHT}if(!e){if(x.strand){if(x.strand==="+"){p.fillStyle=RIGHT_STRAND_INV}else{if(x.strand==="-"){p.fillStyle=LEFT_STRAND_INV}}}else{p.fillStyle=d}p.fillRect(D+A,B,q-D,v)}else{var m,w;if(g==="Squish"){p.fillStyle=CONNECTOR_COLOR;m=B+Math.floor(SQUISH_FEATURE_HEIGHT/2)+1;w=1}else{if(n){var m=B;var w=v;if(n==="+"){p.fillStyle=RIGHT_STRAND}else{if(n==="-"){p.fillStyle=LEFT_STRAND}}}else{p.fillStyle=CONNECTOR_COLOR;m+=(SQUISH_FEATURE_HEIGHT/2)+1;w=1}}p.fillRect(D+A,m,q-D,w);for(var J=0,c=e.length;J<c;J++){var h=e[J],b=Math.floor(Math.max(0,(h[0]-r)*M)),y=Math.ceil(Math.min(a,Math.max((h[1]-1-r)*M)));if(b>y){continue}p.fillStyle=d;p.fillRect(b+A,B+(v-L)/2+1,y-b,L);if(t!==undefined&&!(b>O||y<t)){var H=Math.max(b,t),l=Math.min(y,O);p.fillRect(H+A,B+1,l-H,v)}}}if(g==="Pack"&&K>r){p.fillStyle=F;if(f===0&&D-p.measureText(s).width<0){p.textAlign="left";p.fillText(s,q+A+LABEL_SPACING,B+8)}else{p.textAlign="right";p.fillText(s,D+A-LABEL_SPACING,B+8)}p.fillStyle=d}}}},get_y_scale:function(b){var a;if(b==="summary_tree"){}if(b==="Dense"){a=DENSE_TRACK_HEIGHT}else{if(b==="no_detail"){a=NO_DETAIL_TRACK_HEIGHT}else{if(b==="Squish"){a=SQUISH_TRACK_HEIGHT}else{a=PACK_TRACK_HEIGHT}}}return a},draw_tile:function(o,x,C,k,m,d){var t=this;var E=C*DENSITY*x,a=(C+1)*DENSITY*x,q=a-E,F={hda_ldda:t.hda_ldda,dataset_id:t.dataset_id,resolution:this.view.resolution,mode:this.mode};var v=Math.ceil(q*m),s=this.mode,H=25,g=this.left_offset,p,h;var c=document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(c)}c=$(c);if(s==="Auto"){if(o.dataset_type==="summary_tree"){s=o.dataset_type}else{if(o.extra_info==="no_detail"){s="no_detail"}else{var G=o.data;if((G.length&&G.length<4)||(this.view.high-this.view.low>MIN_SQUISH_VIEW_WIDTH)){s="Squish"}else{s="Pack"}}}}var y=this.get_y_scale(s);if(s==="summary_tree"){h=this.summary_draw_height}if(s==="Dense"){h=H}else{if(s==="no_detail"||s==="Squish"||s==="Pack"){h=this.incremental_slots(m,o.data,s)*y+H;p=this.inc_slots[m]}}c.get(0).width=v+g;c.get(0).height=h;if(o.dataset_type==="summary_tree"){c.get(0).height+=LABEL_SPACING+CHAR_HEIGHT_PX}k.parent().css("height",Math.max(this.height_px,h)+"px");var w=c.get(0).getContext("2d");w.fillStyle=this.prefs.block_color;w.font=this.default_font;w.textAlign="right";this.container_div.find(".yaxislabel").remove();if(s==="summary_tree"){this.draw_summary_tree(c,o.data,o.delta,o.max,m,h,E,g);return c}if(o.message){c.css({"border-top":"1px solid red"});w.fillStyle="red";w.textAlign="left";var r=w.textBaseline;w.textBaseline="top";w.fillText(o.message,g,0);w.textBaseline=r;if(!o.data){return c}}this.example_feature=(o.data.length?o.data[0]:undefined);var G=o.data;for(var z=0,B=G.length;z<B;z++){var j=G[z],l=j[0],u=j[1],b=j[2],e=(p&&p[l]!==undefined?p[l]:null);var A=false;var n;for(var D=0;D<this.filters.length;D++){n=this.filters[D];n.update_attrs(j);if(!n.keep(j)){A=true;break}}if(A){continue}if(is_overlap([u,b],[E,a])&&(s=="Dense"||e!==null)){this.draw_element(w,C,s,j,e,E,a,m,y,v,g,d)}}return c}});var VcfTrack=function(d,b,f,a,c,e){FeatureTrack.call(this,d,b,f,a,c,e);this.track_type="VcfTrack"};$.extend(VcfTrack.prototype,TiledTrack.prototype,FeatureTrack.prototype,{draw_element:function(u,p,j,e,x,c,m,v,s){var j=data[i],l=j[0],t=j[1],d=j[2]-1,o=j[3],g=Math.floor(Math.max(0,(t-x)*m)),k=Math.ceil(Math.min(s,Math.max(0,(d-x)*m))),f=ERROR_PADDING+(p==="Dense"?0:(0+e))*v,a,y,b=null,n=null;if(no_label){u.fillStyle=block_color;u.fillRect(g+left_offset,f+5,k-g,1)}else{var w=j[4],r=j[5],h=j[6];a=9;y=1;u.fillRect(g+left_offset,f,k-g,a);if(p!=="Dense"&&o!==undefined&&t>x){u.fillStyle=label_color;if(tile_index===0&&g-u.measureText(o).width<0){u.textAlign="left";u.fillText(o,k+2+left_offset,f+8)}else{u.textAlign="right";u.fillText(o,g-2+left_offset,f+8)}u.fillStyle=block_color}var q=w+" / "+r;if(t>x&&u.measureText(q).width<(k-g)){u.fillStyle="white";u.textAlign="center";u.fillText(q,left_offset+g+(k-g)/2,f+8);u.fillStyle=block_color}}}});var ReadTrack=function(d,b,f,a,c,e){FeatureTrack.call(this,d,b,f,a,c,e);this.track_config=new TrackConfig({track:this,params:[{key:"block_color",label:"Block color",type:"color",default_value:"#444"},{key:"label_color",label:"Label color",type:"color",default_value:"black"},{key:"show_insertions",label:"Show insertions",type:"bool",default_value:false},{key:"show_differences",label:"Show differences only",type:"bool",default_value:true},{key:"show_counts",label:"Show summary counts",type:"bool",default_value:true},{key:"mode",type:"string",default_value:this.mode,hidden:true},],saved_values:c,onchange:function(){this.track.tile_cache.clear();this.track.draw()}});this.prefs=this.track_config.values;this.track_type="ReadTrack";this.make_name_popup_menu()};$.extend(ReadTrack.prototype,TiledTrack.prototype,FeatureTrack.prototype,{get_y_scale:function(b){var a;if(b==="summary_tree"){}if(b==="Dense"){a=DENSE_TRACK_HEIGHT}else{if(b==="Squish"){a=SQUISH_TRACK_HEIGHT}else{a=PACK_TRACK_HEIGHT;if(this.track_config.values.show_insertions){a*=2}}}return a},draw_read:function(m,d,J,n,D,G,e,o,y,a){m.textAlign="center";var l=this,u=[n,D],C=0,z=0,f=0;var r=[];if((d==="Pack"||this.mode==="Auto")&&o!==undefined&&J>CHAR_WIDTH_PX){f=Math.round(J/2)}if(!e){e=[[0,o.length]]}for(var h=0,k=e.length;h<k;h++){var b=e[h],g="MIDNSHP=X"[b[0]],v=b[1];if(g==="H"||g==="S"){C-=v}var x=G+C,B=Math.floor(Math.max(0,(x-n)*J)),E=Math.floor(Math.max(0,(x+v-n)*J));switch(g){case"H":break;case"S":case"M":case"=":var p=compute_overlap([x,x+v],u);if(p!==NO_OVERLAP){var q=o.slice(z,z+v);if(f>0){m.fillStyle=this.prefs.block_color;m.fillRect(B+this.left_offset-f,y+1,E-B,9);m.fillStyle=CONNECTOR_COLOR;for(var I=0,j=q.length;I<j;I++){if(this.track_config.values.show_differences&&a){var s=a[x-n+I];if(!s||s.toLowerCase()===q[I].toLowerCase()){continue}}if(x+I>=n&&x+I<=D){var A=Math.floor(Math.max(0,(x+I-n)*J));m.fillText(q[I],A+this.left_offset,y+9)}}}else{m.fillStyle=this.prefs.block_color;m.fillRect(B+this.left_offset,y+(this.mode!=="Dense"?4:5),E-B,(d!=="Dense"?SQUISH_FEATURE_HEIGHT:DENSE_FEATURE_HEIGHT))}}z+=v;C+=v;break;case"N":m.fillStyle=CONNECTOR_COLOR;m.fillRect(B+this.left_offset-f,y+5,E-B,1);C+=v;break;case"D":m.fillStyle="red";m.fillRect(B+this.left_offset-f,y+4,E-B,3);C+=v;break;case"P":break;case"I":var p=compute_overlap([x,x+v],u),K=this.left_offset+B-f;if(p!==NO_OVERLAP){var q=o.slice(z,z+v);if(this.track_config.values.show_insertions){var w=this.left_offset+B-(E-B)/2;if((d==="Pack"||this.mode==="Auto")&&o!==undefined&&J>CHAR_WIDTH_PX){m.fillStyle="yellow";m.fillRect(w-f,y-9,E-B,9);r[r.length]={type:"triangle",data:[K,y+4,5]};m.fillStyle=CONNECTOR_COLOR;switch(p){case (OVERLAP_START):q=q.slice(n-x);break;case (OVERLAP_END):q=q.slice(0,x-D);break;case (CONTAINED_BY):break;case (CONTAINS):q=q.slice(n-x,x-D);break}for(var I=0,j=q.length;I<j;I++){var A=Math.floor(Math.max(0,(x+I-n)*J));m.fillText(q[I],A+this.left_offset-(E-B)/2,y)}}else{m.fillStyle="yellow";m.fillRect(w,y+(this.mode!=="Dense"?2:5),E-B,(d!=="Dense"?SQUISH_FEATURE_HEIGHT:DENSE_FEATURE_HEIGHT))}}else{if((d==="Pack"||this.mode==="Auto")&&o!==undefined&&J>CHAR_WIDTH_PX){r[r.length]={type:"text",data:[q.length,K,y+9]}}else{}}}z+=v;break;case"X":z+=v;break}}m.fillStyle="yellow";var t,L,H;for(var F=0;F<r.length;F++){t=r[F];L=t.type;H=t.data;if(L==="text"){m.font="bold "+DEFAULT_FONT;m.fillText(H[0],H[1],H[2]);m.font=DEFAULT_FONT}else{if(L=="triangle"){m.drawDownwardEquilateralTriangle(H[0],H[1],H[2])}}}},draw_element:function(w,y,r,k,e,A,b,n,x,u,f,c){var m=k[0],v=k[1],d=k[2],o=k[3],h=Math.floor(Math.max(0,(v-A)*n)),j=Math.ceil(Math.min(u,Math.max(0,(d-A)*n))),g=(r==="Dense"?1:(1+e))*x,z=this.prefs.block_color,l=this.prefs.label_color;t=0;w.fillStyle=z;if(k[5] instanceof Array){var s=Math.floor(Math.max(0,(k[4][0]-A)*n)),q=Math.ceil(Math.min(u,Math.max(0,(k[4][1]-A)*n))),p=Math.floor(Math.max(0,(k[5][0]-A)*n)),a=Math.ceil(Math.min(u,Math.max(0,(k[5][1]-A)*n)));if(k[4][1]>=A&&k[4][0]<=b&&k[4][2]){this.draw_read(w,r,n,A,b,k[4][0],k[4][2],k[4][3],g,c)}if(k[5][1]>=A&&k[5][0]<=b&&k[5][2]){this.draw_read(w,r,n,A,b,k[5][0],k[5][2],k[5][3],g,c)}if(p>q){w.fillStyle=CONNECTOR_COLOR;w.dashedLine(q+f,g+5,f+p,g+5)}}else{w.fillStyle=z;this.draw_read(w,r,n,A,b,v,k[4],k[5],g,c)}if(r==="Pack"&&v>A){w.fillStyle=this.prefs.label_color;if((r==="Pack"||this.mode==="Auto")&&n>CHAR_WIDTH_PX){var t=Math.round(n/2)}if(y===0&&h-w.measureText(o).width<0){w.textAlign="left";w.fillText(o,j+f+LABEL_SPACING-t,g+8)}else{w.textAlign="right";w.fillText(o,h+f-LABEL_SPACING-t,g+8)}w.fillStyle=z}}});var ToolDataFeatureTrack=function(e,c,g,a,d,f,b){FeatureTrack.call(this,e,c,g,a,d,f,{},b);this.track_type="ToolDataFeatureTrack";this.data_url=raw_data_url;this.data_query_wait=1000;this.dataset_check_url=dataset_state_url};$.extend(ToolDataFeatureTrack.prototype,TiledTrack.prototype,FeatureTrack.prototype,{predraw_init:function(){var b=this;var a=function(){if(b.data_cache.size()===0){setTimeout(a,300)}else{b.data_url=default_data_url;b.data_query_wait=DEFAULT_DATA_QUERY_WAIT;b.dataset_state_url=converted_datasets_state_url;$.getJSON(b.dataset_state_url,{dataset_id:b.dataset_id,hda_ldda:b.hda_ldda},function(c){})}};a()}});
\ No newline at end of file
--- a/static/scripts/trackster.js Thu Mar 24 15:05:28 2011 -0400
+++ b/static/scripts/trackster.js Thu Mar 24 17:12:16 2011 -0400
@@ -245,9 +245,10 @@
/**
* Data manager for a track.
*/
-var DataManager = function(num_elements, track) {
+var DataManager = function(num_elements, track, subset) {
Cache.call(this, num_elements);
this.track = track;
+ this.subset = (subset !== undefined ? subset : true);
};
$.extend(DataManager.prototype, Cache.prototype, {
/**
@@ -283,30 +284,33 @@
}
//
+ // If data supports subsetting:
// Look in cache for data that can be used. Data can be reused if it
// has the requested data and is not summary tree and has details.
// TODO: this logic could be improved if the visualization knew whether
// the data was "index" or "data." Also could slice the data so that
// only data points in request are returned.
//
- var key, split_key, entry_low, entry_high, mode, entry;
- for (var i = 0; i < this.key_ary.length; i++) {
- key = this.key_ary[i];
- split_key = this.split_key(key);
- entry_low = split_key[0];
- entry_high = split_key[1];
+ if (this.subset) {
+ var key, split_key, entry_low, entry_high, mode, entry;
+ for (var i = 0; i < this.key_ary.length; i++) {
+ key = this.key_ary[i];
+ split_key = this.split_key(key);
+ entry_low = split_key[0];
+ entry_high = split_key[1];
- if (low >= entry_low && high <= entry_high) {
- // This track has the range of data needed; check other attributes.
- entry = this.obj_cache[key];
- if (entry.dataset_type !== "summary_tree" && entry.extra_info !== "no_detail") {
- // Data is usable.
- this.move_key_to_end(key, i);
- return entry;
+ if (low >= entry_low && high <= entry_high) {
+ // This track has the range of data needed; check other attributes.
+ entry = this.obj_cache[key];
+ if (entry.dataset_type !== "summary_tree" && entry.extra_info !== "no_detail") {
+ // Data is usable.
+ this.move_key_to_end(key, i);
+ return entry;
+ }
}
}
}
-
+
//
// Load data from server.
//
@@ -1477,20 +1481,7 @@
track.make_name_popup_menu();
};
}
-
- //
- // For ReadTracks: show/hide insertions.
- //
- if (track.track_type == "ReadTrack") {
- // Show/hide insertions.
- var text = (track.show_insertions ? "Hide Insertions" : "Show Insertions");
- track_dropdown[text] = function() {
- track.show_insertions = !track.show_insertions;
- track.draw(true);
- track.make_name_popup_menu();
- };
- }
-
+
//
// List chrom/contigs with data option.
//
@@ -1526,7 +1517,6 @@
* tiles after drawing new tiles.
*/
draw: function(force, clear_after) {
- console.log(this.name, force, clear_after);
var low = this.view.low,
high = this.view.high,
range = high - low,
@@ -1643,16 +1633,16 @@
$.when(track.data_cache.get_data(view.chrom, tile_low, tile_high, track.mode,
resolution, track.data_url_extra_params)).then(function() {
// Data available for track.
- result = track.data_cache.get_data(view.chrom, tile_low, tile_high, track.mode,
- resolution, track.data_url_extra_params);
+ var result = track.data_cache.get_data(view.chrom, tile_low, tile_high, track.mode,
+ resolution, track.data_url_extra_params);
// If sequence data needed, get that and draw. Otherwise draw.
if (view.reference_track && w_scale > CHAR_WIDTH_PX) {
$.when(view.reference_track.data_cache.get_data(view.chrom, tile_low, tile_high,
track.mode, resolution,
view.reference_track.data_url_extra_params)).then(function() {
- seq_data = view.reference_track.data_cache.get_data(view.chrom, tile_low, tile_high,
- track.mode, resolution,
- view.reference_track.data_url_extra_params);
+ var seq_data = view.reference_track.data_cache.get_data(view.chrom, tile_low, tile_high,
+ track.mode, resolution,
+ view.reference_track.data_url_extra_params);
draw_and_show_tile(id, result, resolution, tile_index, parent_element, w_scale, seq_data);
});
}
@@ -1871,7 +1861,7 @@
this.content_div.css("border", "none");
this.data_url = reference_url;
this.data_url_extra_params = {dbkey: view.dbkey};
- this.data_cache = new DataManager(CACHED_DATA, this);
+ this.data_cache = new DataManager(CACHED_DATA, this, false);
this.tile_cache = new Cache(CACHED_TILES_LINE);
};
$.extend(ReferenceTrack.prototype, TiledTrack.prototype, {
@@ -2517,9 +2507,7 @@
* Draw FeatureTrack tile.
*/
draw_tile: function(result, resolution, tile_index, parent_element, w_scale, ref_seq) {
- // Fetch reference sequence data if it exists and we are displaying
var track = this;
-
var tile_low = tile_index * DENSITY * resolution,
tile_high = ( tile_index + 1 ) * DENSITY * resolution,
tile_span = tile_high - tile_low,
@@ -2736,9 +2724,26 @@
var ReadTrack = function (name, view, hda_ldda, dataset_id, prefs, filters) {
FeatureTrack.call(this, name, view, hda_ldda, dataset_id, prefs, filters);
+
+ this.track_config = new TrackConfig( {
+ track: this,
+ params: [
+ { key: 'block_color', label: 'Block color', type: 'color', default_value: '#444' },
+ { key: 'label_color', label: 'Label color', type: 'color', default_value: 'black' },
+ { key: 'show_insertions', label: 'Show insertions', type: 'bool', default_value: false },
+ { key: 'show_differences', label: 'Show differences only', type: 'bool', default_value: true },
+ { key: 'show_counts', label: 'Show summary counts', type: 'bool', default_value: true },
+ { key: 'mode', type: 'string', default_value: this.mode, hidden: true },
+ ],
+ saved_values: prefs,
+ onchange: function() {
+ this.track.tile_cache.clear();
+ this.track.draw();
+ }
+ });
+ this.prefs = this.track_config.values;
+
this.track_type = "ReadTrack";
- this.difference_mode = true;
- this.show_insertions = false;
this.make_name_popup_menu();
};
$.extend(ReadTrack.prototype, TiledTrack.prototype, FeatureTrack.prototype, {
@@ -2758,7 +2763,7 @@
}
else { // mode === "Pack"
y_scale = PACK_TRACK_HEIGHT;
- if (this.show_insertions) {
+ if (this.track_config.values.show_insertions) {
y_scale *= 2;
}
}
@@ -2781,7 +2786,7 @@
// Gap is needed so that read is offset and hence first base can be drawn on read.
// TODO-FIX: using this gap offsets reads so that their start is not visually in sync with other tracks.
if ((mode === "Pack" || this.mode === "Auto") && orig_seq !== undefined && w_scale > CHAR_WIDTH_PX) {
- gap = Math.ceil(CHAR_WIDTH_PX/2 + 1);
+ gap = Math.round(w_scale/2);
}
if (!cigar) {
// If no cigar string, then assume all matches
@@ -2819,7 +2824,7 @@
// TODO: this can be made much more efficient by computing the complete sequence
// to draw and then drawing it.
for (var c = 0, str_len = seq.length; c < str_len; c++) {
- if (this.difference_mode && ref_seq) {
+ if (this.track_config.values.show_differences && ref_seq) {
var ref_char = ref_seq[seq_start - tile_low + c];
if (!ref_char || ref_char.toLowerCase() === seq[c].toLowerCase()) {
continue;
@@ -2869,7 +2874,7 @@
var seq = orig_seq.slice(seq_offset, seq_offset + cig_len);
// Insertion point is between the sequence start and the previous base: (-gap) moves
// back from sequence start to insertion point.
- if (this.show_insertions) {
+ if (this.track_config.values.show_insertions) {
//
// Show inserted sequence above, centered on insertion point.
//
@@ -2955,7 +2960,6 @@
* Draw a complete read.
*/
draw_element: function(ctx, tile_index, mode, feature, slot, tile_low, tile_high, w_scale, y_scale, width, left_offset, ref_seq) {
-
// All features need a start, end, and vertical center.
var
feature_uid = feature[0],
@@ -3029,7 +3033,7 @@
this.dataset_check_url = dataset_state_url;
};
-$.extend( ToolDataFeatureTrack.prototype, TiledTrack.prototype, FeatureTrack.prototype, {
+$.extend(ToolDataFeatureTrack.prototype, TiledTrack.prototype, FeatureTrack.prototype, {
/**
* For this track type, the predraw init sets up postdraw init.
*/
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/e37ad896e5fd/
changeset: r5269:e37ad896e5fd
user: jgoecks
date: 2011-03-24 20:05:28
summary: Implement a data manager for trackster. Convert DataCache into a DataManager and use jQuery Deferred objects to move data management from the tile level to the track level. Implications of these changes include (a) callbacks are no longer needed when drawing tiles; (a) data is fetched before a tile is drawn; and (c) tile drawing is completely tracked so that actions can be taken after a track has been drawn.
affected #: 4 files (1.4 KB)
--- a/lib/galaxy/web/controllers/tracks.py Thu Mar 24 15:03:12 2011 -0400
+++ b/lib/galaxy/web/controllers/tracks.py Thu Mar 24 15:05:28 2011 -0400
@@ -741,9 +741,9 @@
#
try:
subset_job, subset_job_outputs = tool.execute( trans, incoming=tool_params, history=original_dataset.history )
- except e:
+ except Exception, e:
# Lots of things can go wrong when trying to execute tool.
- return to_json_string( { "error" : True, "message" : e.str() } )
+ return to_json_string( { "error" : True, "message" : e.__class__.__name__ + ": " + str(e) } )
for output in subset_job_outputs.values():
output.visible = False
trans.sa_session.flush()
@@ -760,12 +760,6 @@
return self.add_track_async( trans, output_dataset.id )
- @web.expose
- def woot( self, trans, ldda_id, target_type ):
- ldda = trans.sa_session.query( trans.app.model.LibraryDatasetDatasetAssociation ).get( trans.security.decode_id( ldda_id ) )
- converted_dataset = ldda.get_converted_dataset( trans, target_type )
- raise converted_dataset
-
#
# Helper methods.
#
--- a/static/scripts/packed/jquery.event.drag.js Thu Mar 24 15:03:12 2011 -0400
+++ b/static/scripts/packed/jquery.event.drag.js Thu Mar 24 15:05:28 2011 -0400
@@ -1,6 +1,6 @@
/*
- * jquery.event.drag - v 2.0.0
+ * jquery.event.drag - v 2.1.0
* Copyright (c) 2010 Three Dub Media - http://threedubmedia.com
* Open Source MIT License - http://threedubmedia.com/code/license
*/
-(function(d){d.fn.drag=function(i,e,h){var g=typeof i=="string"?i:"",f=d.isFunction(i)?i:d.isFunction(e)?e:null;if(g.indexOf("drag")!==0){g="drag"+g}h=(i==f?e:h)||{};return f?this.bind(g,h,f):this.trigger(g)};var b=d.event,a=b.special,c=a.drag={defaults:{which:1,distance:0,not:":input",handle:null,relative:false,drop:true,click:false},datakey:"dragdata",livekey:"livedrag",add:function(g){var f=d.data(this,c.datakey),e=g.data||{};f.related+=1;if(!f.live&&g.selector){f.live=true;b.add(this,"draginit."+c.livekey,c.delegate)}d.each(c.defaults,function(h,i){if(e[h]!==undefined){f[h]=e[h]}})},remove:function(){d.data(this,c.datakey).related-=1},setup:function(){if(d.data(this,c.datakey)){return}var e=d.extend({related:0},c.defaults);d.data(this,c.datakey,e);b.add(this,"mousedown",c.init,e);if(this.attachEvent){this.attachEvent("ondragstart",c.dontstart)}},teardown:function(){if(d.data(this,c.datakey).related){return}d.removeData(this,c.datakey);b.remove(this,"mousedown",c.init);b.remove(this,"draginit",c.delegate);c.textselect(true);if(this.detachEvent){this.detachEvent("ondragstart",c.dontstart)}},init:function(g){var e=g.data,f;if(e.which>0&&g.which!=e.which){return}if(d(g.target).is(e.not)){return}if(e.handle&&!d(g.target).closest(e.handle,g.currentTarget).length){return}e.propagates=1;e.interactions=[c.interaction(this,e)];e.target=g.target;e.pageX=g.pageX;e.pageY=g.pageY;e.dragging=null;f=c.hijack(g,"draginit",e);if(!e.propagates){return}f=c.flatten(f);if(f&&f.length){e.interactions=[];d.each(f,function(){e.interactions.push(c.interaction(this,e))})}e.propagates=e.interactions.length;if(e.drop!==false&&a.drop){a.drop.handler(g,e)}c.textselect(false);b.add(document,"mousemove mouseup",c.handler,e);return false},interaction:function(f,e){return{drag:f,callback:new c.callback(),droppable:[],offset:d(f)[e.relative?"position":"offset"]()||{top:0,left:0}}},handler:function(f){var e=f.data;switch(f.type){case !e.dragging&&"mousemove":if(Math.pow(f.pageX-e.pageX,2)+Math.pow(f.pageY-e.pageY,2)<Math.pow(e.distance,2)){break}f.target=e.target;c.hijack(f,"dragstart",e);if(e.propagates){e.dragging=true}case"mousemove":if(e.dragging){c.hijack(f,"drag",e);if(e.propagates){if(e.drop!==false&&a.drop){a.drop.handler(f,e)}break}f.type="mouseup"}case"mouseup":b.remove(document,"mousemove mouseup",c.handler);if(e.dragging){if(e.drop!==false&&a.drop){a.drop.handler(f,e)}c.hijack(f,"dragend",e)}else{c.hijack(f,"dragclickonly",e)}c.textselect(true);if(e.click===false&&e.dragging){jQuery.event.triggered=true;setTimeout(function(){jQuery.event.triggered=false},20);e.dragging=false}break}},delegate:function(g){var e=[],h,f=d.data(this,"events")||{};d.each(f.live||[],function(j,k){if(k.preType.indexOf("drag")!==0){return}h=d(g.target).closest(k.selector,g.currentTarget)[0];if(!h){return}b.add(h,k.origType+"."+c.livekey,k.origHandler,k.data);if(d.inArray(h,e)<0){e.push(h)}});if(!e.length){return false}return d(e).bind("dragend."+c.livekey,function(){b.remove(this,"."+c.livekey)})},hijack:function(f,m,p,n,h){if(!p){return}var o={event:f.originalEvent,type:f.type},k=m.indexOf("drop")?"drag":"drop",r,j=n||0,g,e,q,l=!isNaN(n)?n:p.interactions.length;f.type=m;f.originalEvent=null;p.results=[];do{if(g=p.interactions[j]){if(m!=="dragend"&&g.cancelled){continue}q=c.properties(f,p,g);g.results=[];d(h||g[k]||p.droppable).each(function(s,i){q.target=i;r=i?b.handle.call(i,f,q):null;if(r===false){if(k=="drag"){g.cancelled=true;p.propagates-=1}if(m=="drop"){g[k][s]=null}}else{if(m=="dropinit"){g.droppable.push(c.element(r)||i)}}if(m=="dragstart"){g.proxy=d(c.element(r)||g.drag)[0]}g.results.push(r);delete f.result;if(m!=="dropinit"){return r}});p.results[j]=c.flatten(g.results);if(m=="dropinit"){g.droppable=c.flatten(g.droppable)}if(m=="dragstart"&&!g.cancelled){q.update()}}}while(++j<l);f.type=o.type;f.originalEvent=o.event;return c.flatten(p.results)},properties:function(g,e,f){var h=f.callback;h.drag=f.drag;h.proxy=f.proxy||f.drag;h.startX=e.pageX;h.startY=e.pageY;h.deltaX=g.pageX-e.pageX;h.deltaY=g.pageY-e.pageY;h.originalX=f.offset.left;h.originalY=f.offset.top;h.offsetX=g.pageX-(e.pageX-h.originalX);h.offsetY=g.pageY-(e.pageY-h.originalY);h.drop=c.flatten((f.drop||[]).slice());h.available=c.flatten((f.droppable||[]).slice());return h},element:function(e){if(e&&(e.jquery||e.nodeType==1)){return e}},flatten:function(e){return d.map(e,function(f){return f&&f.jquery?d.makeArray(f):f&&f.length?c.flatten(f):f})},textselect:function(e){d(document)[e?"unbind":"bind"]("selectstart",c.dontstart).attr("unselectable",e?"off":"on").css("MozUserSelect",e?"":"none")},dontstart:function(){return false},callback:function(){}};c.callback.prototype={update:function(){if(a.drop&&this.available.length){d.each(this.available,function(e){a.drop.locate(this,e)})}}};a.draginit=a.dragstart=a.dragend=c})(jQuery);
\ No newline at end of file
+(function(d){d.fn.drag=function(j,f,i){var h=typeof j=="string"?j:"",g=d.isFunction(j)?j:d.isFunction(f)?f:null;if(h.indexOf("drag")!==0){h="drag"+h}i=(j==g?f:i)||{};return g?this.bind(h,i,g):this.trigger(h)};var b=d.event,a=b.special,c=a.drag={defaults:{which:1,distance:0,not:":input",handle:null,relative:false,drop:true,click:false},datakey:"dragdata",add:function(h){var g=d.data(this,c.datakey),f=h.data||{};g.related+=1;d.each(c.defaults,function(i,j){if(f[i]!==undefined){g[i]=f[i]}})},remove:function(){d.data(this,c.datakey).related-=1},setup:function(){if(d.data(this,c.datakey)){return}var f=d.extend({related:0},c.defaults);d.data(this,c.datakey,f);b.add(this,"touchstart mousedown",c.init,f);if(this.attachEvent){this.attachEvent("ondragstart",c.dontstart)}},teardown:function(){var f=d.data(this,c.datakey)||{};if(f.related){return}d.removeData(this,c.datakey);b.remove(this,"touchstart mousedown",c.init);c.textselect(true);if(this.detachEvent){this.detachEvent("ondragstart",c.dontstart)}},init:function(h){if(c.touched){return}var f=h.data,g;if(h.which!=0&&f.which>0&&h.which!=f.which){return}if(d(h.target).is(f.not)){return}if(f.handle&&!d(h.target).closest(f.handle,h.currentTarget).length){return}if(h.type=="touchstart"){c.touched=this;c.touchFix(h,f)}f.propagates=1;f.mousedown=this;f.interactions=[c.interaction(this,f)];f.target=h.target;f.pageX=h.pageX;f.pageY=h.pageY;f.dragging=null;g=c.hijack(h,"draginit",f);if(!f.propagates){return}g=c.flatten(g);if(g&&g.length){f.interactions=[];d.each(g,function(){f.interactions.push(c.interaction(this,f))})}f.propagates=f.interactions.length;if(f.drop!==false&&a.drop){a.drop.handler(h,f)}c.textselect(false);if(c.touched){b.add(c.touched,"touchmove touchend",c.handler,f)}else{b.add(document,"mousemove mouseup",c.handler,f)}if(!c.touched||f.live){return false}},touchFix:function(h,f){var j=h.originalEvent,g=0;if(j&&j.changedTouches){h.pageX=j.changedTouches[0].pageX;h.pageY=j.changedTouches[0].pageY}},interaction:function(g,f){var h=d(g)[f.relative?"position":"offset"]()||{top:0,left:0};return{drag:g,callback:new c.callback(),droppable:[],offset:h}},handler:function(g){var f=g.data;if(c.touched){c.touchFix(g,f)}switch(g.type){case !f.dragging&&"touchmove":g.preventDefault();case !f.dragging&&"mousemove":if(Math.pow(g.pageX-f.pageX,2)+Math.pow(g.pageY-f.pageY,2)<Math.pow(f.distance,2)){break}g.target=f.target;c.hijack(g,"dragstart",f);if(f.propagates){f.dragging=true}case"touchmove":g.preventDefault();case"mousemove":if(f.dragging){c.hijack(g,"drag",f);if(f.propagates){if(f.drop!==false&&a.drop){a.drop.handler(g,f)}break}g.type="mouseup"}case"touchend":case"mouseup":if(c.touched){b.remove(c.touched,"touchmove touchend",c.handler)}else{b.remove(document,"mousemove mouseup",c.handler)}if(f.dragging){if(f.drop!==false&&a.drop){a.drop.handler(g,f)}c.hijack(g,"dragend",f)}else{c.hijack(g,"dragclickonly",f)}c.textselect(true);if(f.click===false&&f.dragging){d.data(f.mousedown,"suppress.click",new Date().getTime()+5)}f.dragging=c.touched=false;break}},hijack:function(g,n,q,o,j){if(!q){return}var p={event:g.originalEvent,type:g.type},l=n.indexOf("drop")?"drag":"drop",s,k=o||0,h,f,r,m=!isNaN(o)?o:q.interactions.length;g.type=n;g.originalEvent=null;q.results=[];do{if(h=q.interactions[k]){if(n!=="dragend"&&h.cancelled){continue}r=c.properties(g,q,h);h.results=[];d(j||h[l]||q.droppable).each(function(t,i){r.target=i;s=i?b.handle.call(i,g,r):null;if(s===false){if(l=="drag"){h.cancelled=true;q.propagates-=1}if(n=="drop"){h[l][t]=null}}else{if(n=="dropinit"){h.droppable.push(c.element(s)||i)}}if(n=="dragstart"){h.proxy=d(c.element(s)||h.drag)[0]}h.results.push(s);delete g.result;if(n!=="dropinit"){return s}});q.results[k]=c.flatten(h.results);if(n=="dropinit"){h.droppable=c.flatten(h.droppable)}if(n=="dragstart"&&!h.cancelled){r.update()}}}while(++k<m);g.type=p.type;g.originalEvent=p.event;return c.flatten(q.results)},properties:function(h,f,g){var i=g.callback;i.drag=g.drag;i.proxy=g.proxy||g.drag;i.startX=f.pageX;i.startY=f.pageY;i.deltaX=h.pageX-f.pageX;i.deltaY=h.pageY-f.pageY;i.originalX=g.offset.left;i.originalY=g.offset.top;i.offsetX=i.originalX+i.deltaX;i.offsetY=i.originalY+i.deltaY;i.drop=c.flatten((g.drop||[]).slice());i.available=c.flatten((g.droppable||[]).slice());return i},element:function(f){if(f&&(f.jquery||f.nodeType==1)){return f}},flatten:function(f){return d.map(f,function(g){return g&&g.jquery?d.makeArray(g):g&&g.length?c.flatten(g):g})},textselect:function(f){d(document)[f?"unbind":"bind"]("selectstart",c.dontstart).css("MozUserSelect",f?"":"none");document.unselectable=f?"off":"on"},dontstart:function(){return false},callback:function(){}};c.callback.prototype={update:function(){if(a.drop&&this.available.length){d.each(this.available,function(f){a.drop.locate(this,f)})}}};var e=b.handle;b.handle=function(f){if(d.data(this,"suppress."+f.type)-new Date().getTime()>0){d.removeData(this,"suppress."+f.type);return}return e.apply(this,arguments)};a.draginit=a.dragstart=a.dragend=c})(jQuery);
\ No newline at end of file
--- a/static/scripts/packed/trackster.js Thu Mar 24 15:03:12 2011 -0400
+++ b/static/scripts/packed/trackster.js Thu Mar 24 15:05:28 2011 -0400
@@ -1,1 +1,1 @@
-CanvasRenderingContext2D.prototype.dashedLine=function(c,j,b,h,f){if(f===undefined){f=4}var e=b-c;var d=h-j;var g=Math.floor(Math.sqrt(e*e+d*d)/f);var l=e/g;var k=d/g;var a;for(a=0;a<g;a++,c+=l,j+=k){if(a%2!==0){continue}this.fillRect(c,j,f,1)}};CanvasRenderingContext2D.prototype.drawDownwardEquilateralTriangle=function(b,a,e){var d=b-e/2,c=b+e/2,f=a-Math.sqrt(e*3/2);this.beginPath();this.moveTo(d,f);this.lineTo(c,f);this.lineTo(b,a);this.lineTo(d,f);this.strokeStyle=this.fillStyle;this.fill();this.stroke();this.closePath()};function sortable(a,b){a.bind("drag",{handle:b,relative:true},function(h,j){var g=$(this).parent();var f=g.children();var c;for(c=0;c<f.length;c++){if(j.offsetY<$(f.get(c)).position().top){break}}if(c===f.length){if(this!==f.get(c-1)){g.append(this)}}else{if(this!==f.get(c)){$(this).insertBefore(f.get(c))}}})}var NO_OVERLAP=1001,CONTAINS=1002,OVERLAP_START=1003,OVERLAP_END=1004,CONTAINED_BY=1005;function compute_overlap(e,b){var g=e[0],f=e[1],d=b[0],c=b[1],a;if(g<d){if(f<d){a=NO_OVERLAP}else{if(f<=c){a=OVERLAP_START}else{a=CONTAINS}}}else{if(g>c){a=NO_OVERLAP}else{if(f<=c){a=CONTAINED_BY}else{a=OVERLAP_END}}}return a}function is_overlap(b,a){return(compute_overlap(b,a)!==NO_OVERLAP)}var DENSE_TRACK_HEIGHT=10,NO_DETAIL_TRACK_HEIGHT=3,SQUISH_TRACK_HEIGHT=5,PACK_TRACK_HEIGHT=10,NO_DETAIL_FEATURE_HEIGHT=1,DENSE_FEATURE_HEIGHT=1,SQUISH_FEATURE_HEIGHT=3,PACK_FEATURE_HEIGHT=9,ERROR_PADDING=10,LABEL_SPACING=2,PACK_SPACING=5,MIN_SQUISH_VIEW_WIDTH=12000,DEFAULT_FONT="9px Monaco, Lucida Console, monospace",DENSITY=200,FEATURE_LEVELS=10,MAX_FEATURE_DEPTH=100,DEFAULT_DATA_QUERY_WAIT=5000,MAX_CHROMS_SELECTABLE=100,CONNECTOR_COLOR="#ccc",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_CANNOT_RUN_TOOL="Tool cannot be rerun: ",DATA_LOADING="Loading data...",DATA_OK="Ready for display",CACHED_TILES_FEATURE=10,CACHED_TILES_LINE=5,CACHED_DATA=5,DUMMY_CANVAS=document.createElement("canvas"),RIGHT_STRAND,LEFT_STRAND;if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(DUMMY_CANVAS)}var CONTEXT=DUMMY_CANVAS.getContext("2d");CONTEXT.font=DEFAULT_FONT;var CHAR_WIDTH_PX=CONTEXT.measureText("A").width,CHAR_HEIGHT_PX=9;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.move_key_to_end(b,a)}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},move_key_to_end:function(b,a){this.key_ary.splice(a,1);this.key_ary.push(b)},clear:function(){this.obj_cache={};this.key_ary=[]},size:function(){return this.key_ary.length}});var DataCache=function(a){Cache.call(this,a)};$.extend(DataCache.prototype,Cache.prototype,{get_data:function(g,b,e){var h=this.get(this.gen_key(g,b,e));if(h){return h}var j,f,a,d,e,h;for(var c=0;c<this.key_ary.length;c++){j=this.key_ary[c];f=this.split_key(j);a=f[0];d=f[1];if(g>=a&&b<=d){h=this.obj_cache[j];if(h.dataset_type!=="summary_tree"&&h.extra_info!=="no_detail"){this.move_key_to_end(j,c);return h}}}return undefined},set_data:function(b,c,d,a){return this.set(this.gen_key(b,c,d),a)},gen_key:function(a,c,d){var b=a+"_"+c+"_"+d;return b},split_key:function(a){return a.split("_")}});var View=function(a,d,c,b,e){this.container=a;this.chrom=null;this.vis_id=c;this.dbkey=b;this.title=d;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(e);this.reset()};$.extend(View.prototype,{init:function(d){var c=this.container,a=this;this.top_container=$("<div/>").addClass("top-container").appendTo(c);this.content_div=$("<div/>").addClass("content").css("position","relative").appendTo(c);this.bottom_container=$("<div/>").addClass("bottom-container").appendTo(c);this.top_labeltrack=$("<div/>").addClass("top-labeltrack").appendTo(this.top_container);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_labeltrack=$("<div/>").addClass("nav-labeltrack").appendTo(this.bottom_container);this.nav_container=$("<div/>").addClass("nav-container").prependTo(this.top_container);this.nav=$("<div/>").addClass("nav").appendTo(this.nav_container);this.overview=$("<div/>").addClass("overview").appendTo(this.bottom_container);this.overview_viewport=$("<div/>").addClass("overview-viewport").appendTo(this.overview);this.overview_close=$("<a 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_select=$("<select/>").attr({name:"chrom"}).css("width","15em").addClass("no-autocomplete").append("<option value=''>Loading</option>").appendTo(this.nav_controls);var b=function(f){if(f.type==="focusout"||(f.keyCode||f.which)===13||(f.keyCode||f.which)===27){if((f.keyCode||f.which)!==27){a.go_to($(this).val())}$(this).hide();a.location_span.show();a.chrom_select.show();return false}};this.nav_input=$("<input/>").addClass("nav-input").hide().bind("keyup focusout",b).appendTo(this.nav_controls);this.location_span=$("<span/>").addClass("location").appendTo(this.nav_controls);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.nav_controls)}this.zo_link=$("<a id='zoom-out' />").click(function(){a.zoom_out();a.redraw()}).appendTo(this.nav_controls);this.zi_link=$("<a id='zoom-in' />").click(function(){a.zoom_in();a.redraw()}).appendTo(this.nav_controls);this.load_chroms({low:0},d);this.chrom_select.bind("change",function(){a.change_chrom(a.chrom_select.val())});this.intro_div.show();this.content_div.bind("click",function(f){$(this).find("input").trigger("blur")});this.content_div.bind("dblclick",function(f){a.zoom_in(f.pageX,this.viewport_container)});this.overview_box.bind("dragstart",function(f,g){this.current_x=g.offsetX}).bind("drag",function(f,h){var j=h.offsetX-this.current_x;this.current_x=h.offsetX;var g=Math.round(j/a.viewport_container.width()*(a.max_high-a.max_low));a.move_delta(-g)});this.overview_close.bind("click",function(){for(var f=0,e=a.tracks.length;f<e;f++){a.tracks[f].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("draginit",function(f,g){if(f.clientX>a.viewport_container.width()-16){return false}}).bind("dragstart",function(f,g){g.original_low=a.low;g.current_height=f.clientY;g.current_x=g.offsetX}).bind("drag",function(h,k){var f=$(this);var l=k.offsetX-k.current_x;var g=f.scrollTop()-(h.clientY-k.current_height);f.scrollTop(g);k.current_height=h.clientY;k.current_x=k.offsetX;var j=Math.round(l/a.viewport_container.width()*(a.high-a.low));a.move_delta(j)}).bind("mousewheel",function(h,k,g,f){if(g){var j=Math.round(-g/a.viewport_container.width()*(a.high-a.low));a.move_delta(j)}});this.top_labeltrack.bind("dragstart",function(f,g){return $("<div />").css({height:a.content_div.height()+a.top_labeltrack.height()+a.nav_labeltrack.height()+1,top:"0px",position:"absolute","background-color":"#ccf",opacity:0.5,"z-index":1000}).appendTo($(this))}).bind("drag",function(k,l){$(l.proxy).css({left:Math.min(k.pageX,l.startX),width:Math.abs(k.pageX-l.startX)});var g=Math.min(k.pageX,l.startX)-a.container.offset().left,f=Math.max(k.pageX,l.startX)-a.container.offset().left,j=(a.high-a.low),h=a.viewport_container.width();a.update_location(Math.round(g/h*j)+a.low,Math.round(f/h*j)+a.low)}).bind("dragend",function(l,m){var g=Math.min(l.pageX,m.startX),f=Math.max(l.pageX,m.startX),j=(a.high-a.low),h=a.viewport_container.width(),k=a.low;a.low=Math.round(g/h*j)+k;a.high=Math.round(f/h*j)+k;$(m.proxy).remove();a.redraw()});this.add_label_track(new LabelTrack(this,this.top_labeltrack));this.add_label_track(new LabelTrack(this,this.nav_labeltrack));$(window).bind("resize",function(){a.resize_window()});$(document).bind("redraw",function(){a.redraw()});this.reset();$(window).trigger("resize")},update_location:function(a,b){this.location_span.text(commatize(a)+" - "+commatize(b));this.nav_input.val(this.chrom+":"+commatize(a)+"-"+commatize(b))},load_chroms:function(b,c){b.num=MAX_CHROMS_SELECTABLE;$.extend(b,(this.vis_id!==undefined?{vis_id:this.vis_id}:{dbkey:this.dbkey}));var a=this;$.ajax({url:chrom_url,data:b,dataType:"json",success:function(e){if(e.reference){a.add_label_track(new ReferenceTrack(a))}a.chrom_data=e.chrom_info;var h='<option value="">Select Chrom/Contig</option>';for(var g=0,d=a.chrom_data.length;g<d;g++){var f=a.chrom_data[g].chrom;h+='<option value="'+f+'">'+f+"</option>"}if(e.prev_chroms){h+='<option value="previous">Previous '+MAX_CHROMS_SELECTABLE+"</option>"}if(e.next_chroms){h+='<option value="next">Next '+MAX_CHROMS_SELECTABLE+"</option>"}a.chrom_select.html(h);if(c){c()}a.chrom_start_index=e.start_index},error:function(){alert("Could not load chroms for this dbkey:",a.dbkey)}})},change_chrom:function(e,b,g){if(!e||e==="None"){return}var d=this;if(e==="previous"){d.load_chroms({low:this.chrom_start_index-MAX_CHROMS_SELECTABLE});return}if(e==="next"){d.load_chroms({low:this.chrom_start_index+MAX_CHROMS_SELECTABLE});return}var f=$.grep(d.chrom_data,function(j,k){return j.chrom===e})[0];if(f===undefined){d.load_chroms({chrom:e},function(){d.change_chrom(e,b,g)});return}else{if(e!==d.chrom){d.chrom=e;if(!d.chrom){d.intro_div.show()}else{d.intro_div.hide()}d.chrom_select.val(d.chrom);d.max_high=f.len-1;d.reset();d.redraw(true);for(var h=0,a=d.tracks.length;h<a;h++){var c=d.tracks[h];if(c.init){c.init()}}}if(b!==undefined&&g!==undefined){d.low=Math.max(b,0);d.high=Math.min(g,d.max_high)}d.reset_overview();d.redraw()}},go_to:function(f){var k=this,a,d,b=f.split(":"),h=b[0],j=b[1];if(j!==undefined){try{var g=j.split("-");a=parseInt(g[0].replace(/,/g,""),10);d=parseInt(g[1].replace(/,/g,""),10)}catch(c){return false}}k.change_chrom(h,a,d)},move_fraction:function(c){var a=this;var b=a.high-a.low;this.move_delta(c*b)},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);sortable(a.container_div,".draghandle");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())||0;var e=((this.high-this.low)/(this.max_high-this.max_low)*this.overview_viewport.width())||0;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_location(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(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()},resize_window:function(){this.viewport_container.height(this.container.height()-this.top_container.height()-this.bottom_container.height());this.nav_container.width(this.container.width());this.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 Tool=function(a,b){this.name=a;this.params=b};$.extend(Tool.prototype,{get_param_values_dict:function(){var b={};for(var a=0;a<this.params.length;a++){var c=this.params[a];b[c.name]=c.value}return b},get_param_values:function(){var b=[];for(var a=0;a<this.params.length;a++){b[a]=this.params[a].value}return b}});var NumberToolParameter=function(c,b,e,a,d){this.name=c;this.label=b;this.min=e;this.max=a;this.value=d};var get_tool_from_dict=function(f){if(obj_length(f)===0){return undefined}var b=f.name;var l=f.params;var c=Array();for(var e=0;e<l.length;e++){var g=l[e];var a=g.name,k=g.label,h=g.type,d=g.min,j=g.max,m=g.value;c[c.length]=new NumberToolParameter(a,k,d,j,m)}return new Tool(b,c)};var Filter=function(b,a,c){this.name=b;this.index=a;this.value=c};var NumberFilter=function(b,a){this.name=b;this.index=a;this.low=-Number.MAX_VALUE;this.high=Number.MAX_VALUE;this.slider_min=Number.MAX_VALUE;this.slider_max=-Number.MAX_VALUE;this.slider=null;this.slider_label=null};$.extend(NumberFilter.prototype,{applies_to:function(a){if(a.length>this.index){return true}return false},keep:function(a){if(!this.applies_to(a)){return true}return(a[this.index]>=this.low&&a[this.index]<=this.high)},update_attrs:function(b){var a=false;if(!this.applies_to(b)){return a}if(b[this.index]<this.slider_min){this.slider_min=b[this.index];a=true}if(b[this.index]>this.slider_max){this.slider_max=b[this.index];a=false}return a},update_ui_elt:function(){var b=this.slider.slider("option","min"),a=this.slider.slider("option","max");if(this.slider_min<b||this.slider_max>a){this.slider.slider("option","min",this.slider_min);this.slider.slider("option","max",this.slider_max);this.slider.slider("option","values",[this.slider_min,this.slider_max])}}});var get_filters_from_dict=function(a){var g=[];for(var d=0;d<a.length;d++){var f=a[d];var c=f.name,e=f.type,b=f.index;if(e==="int"||e==="float"){g[d]=new NumberFilter(c,b)}else{g[d]=new Filter(c,b,e)}}return g};var TrackConfig=function(a){this.track=a.track;this.params=a.params;this.values={};if(a.saved_values){this.restore_values(a.saved_values)}this.onchange=a.onchange};$.extend(TrackConfig.prototype,{restore_values:function(a){var b=this;$.each(this.params,function(c,d){if(a[d.key]!==undefined){b.values[d.key]=a[d.key]}else{b.values[d.key]=d.default_value}})},build_form:function(){var b=this;var a=$("<div />");$.each(this.params,function(f,d){if(!d.hidden){var c="param_"+f;var l=$("<div class='form-row' />").appendTo(a);l.append($("<label />").attr("for",c).text(d.label+":"));if(d.type==="bool"){l.append($('<input type="checkbox" />').attr("id",c).attr("name",c).attr("checked",b.values[d.key]))}else{if(d.type==="color"){var h=b.values[d.key];var g=$("<input />").attr("id",c).attr("name",c).val(h);var j=$("<div class='tipsy tipsy-north' style='position: absolute;' />").hide();var e=$("<div style='background-color: black; padding: 10px;'></div>").appendTo(j);var k=$("<div/>").appendTo(e).farbtastic({width:100,height:100,callback:g,color:h});$("<div />").append(g).append(j).appendTo(l).bind("click",function(m){j.css({left:$(this).position().left+($(g).width()/2)-60,top:$(this).position().top+$(this.height)}).show();$(document).bind("click.color-picker",function(){j.hide();$(document).unbind("click.color-picker")});m.stopPropagation()})}else{l.append($("<input />").attr("id",c).attr("name",c).val(b.values[d.key]))}}}});return a},update_from_form:function(a){var c=this;var b=false;$.each(this.params,function(d,f){if(!f.hidden){var g="param_"+d;var e=a.find("#"+g).val();if(f.type==="float"){e=parseFloat(e)}else{if(f.type==="int"){e=parseInt(e)}else{if(f.type==="bool"){e=a.find("#"+g).is(":checked")}}}if(e!==c.values[f.key]){c.values[f.key]=e;b=true}}});if(b){this.onchange()}}});var Track=function(b,a,e,c,d){this.name=b;this.view=a;this.parent_element=e;this.data_url=(c?c:default_data_url);this.data_query_wait=(d?d:DEFAULT_DATA_QUERY_WAIT);this.dataset_check_url=converted_datasets_state_url;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.name_div.attr("id",this.name.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9\-]/g,"").toLowerCase())}this.content_div=$("<div class='track-content'>").appendTo(this.container_div);this.parent_element.append(this.container_div)};$.extend(Track.prototype,{init:function(){var a=this;a.enabled=false;a.tile_cache.clear();a.data_cache.clear();a.initial_canvas=undefined;a.content_div.css("height","auto");a.container_div.removeClass("nodata error pending");if(!a.dataset_id){return}$.getJSON(converted_datasets_state_url,{hda_ldda:a.hda_ldda,dataset_id:a.dataset_id,chrom:a.view.chrom},function(b){if(!b||b==="error"||b.kind==="error"){a.container_div.addClass("error");a.content_div.text(DATA_ERROR);if(b.message){var d=a.view.tracks.indexOf(a);var c=$(" <a href='javascript:void(0);'></a>").text("View error").bind("click",function(){show_modal("Trackster Error","<pre>"+b.message+"</pre>",{Close:hide_modal})});a.content_div.append(c)}}else{if(b==="no converter"){a.container_div.addClass("error");a.content_div.text(DATA_NOCONVERTER)}else{if(b==="no data"||(b.data!==undefined&&(b.data===null||b.data.length===0))){a.container_div.addClass("nodata");a.content_div.text(DATA_NONE)}else{if(b==="pending"){a.container_div.addClass("pending");a.content_div.text(DATA_PENDING);setTimeout(function(){a.init()},a.data_query_wait)}else{if(b.status==="data"){if(b.valid_chroms){a.valid_chroms=b.valid_chroms;a.make_name_popup_menu()}a.content_div.text(DATA_OK);if(a.view.chrom){a.content_div.text("");a.content_div.css("height",a.height_px+"px");a.enabled=true;$.when(a.predraw_init()).done(function(){a.draw()})}}}}}}})},predraw_init:function(){},update_name:function(a){this.old_name=this.name;this.name=a;this.name_div.text(this.name)},revert_name:function(){this.name=this.old_name;this.name_div.text(this.name)}});var TiledTrack=function(b,j,n){var c=this,o=c.view;this.filters=(b!==undefined?get_filters_from_dict(b):[]);this.filters_available=false;this.filters_visible=false;this.tool=(j!==undefined?get_tool_from_dict(j):undefined);this.parent_track=n;this.child_tracks=[];if(c.hidden){return}if(this.parent_track){this.header_div.find(".draghandle").removeClass("draghandle").addClass("child-track-icon").addClass("icon-button");this.parent_element.addClass("child-track");this.tool=undefined}this.filters_div=$("<div/>").addClass("filters").hide();this.header_div.after(this.filters_div);this.filters_div.bind("drag",function(q){q.stopPropagation()}).bind("dblclick",function(q){q.stopPropagation()});$.each(this.filters,function(t,w){var u=$("<div/>").addClass("slider-row").appendTo(c.filters_div);var v=$("<div/>").addClass("slider-label").appendTo(u);var s=$("<span/>").addClass("name").appendTo(v);s.text(w.name+" ");var r=$("<span/>").addClass("values").appendTo(v);var q=$("<div/>").addClass("slider").appendTo(u);w.control_element=$("<div/>").attr("id",w.name+"-filter-control").appendTo(q);w.control_element.slider({range:true,min:Number.MAX_VALUE,max:-Number.MIN_VALUE,values:[0,0],slide:function(y,z){var x=z.values;r.text("["+x[0]+"-"+x[1]+"]");w.low=x[0];w.high=x[1];c.draw(true,true)},change:function(x,y){w.control_element.slider("option","slide").call(w.control_element,x,y)}});w.slider=w.control_element;w.slider_label=r;$("<div style='clear: both;'/>").appendTo(u)});if(this.tool){this.dynamic_tool_div=$("<div/>").addClass("dynamic-tool").hide();this.header_div.after(this.dynamic_tool_div);this.dynamic_tool_div.bind("drag",function(q){q.stopPropagation()}).bind("click",function(q){q.stopPropagation()}).bind("dblclick",function(q){q.stopPropagation()});var m=$("<div class='tool-name'>").appendTo(this.dynamic_tool_div).text(this.tool.name);var l=this.tool.params;var c=this;$.each(this.tool.params,function(x,s){var v=$("<div>").addClass("slider-row").appendTo(c.dynamic_tool_div);var u=$("<div>").addClass("slider-label").appendTo(v);var z=$("<span class='param-name'>").text(s.label+" ").appendTo(u);var t=$("<span/>").text(s.value);var w=$("<span class='param-value'>").appendTo(u).append("[").append(t).append("]");var y=$("<div/>").addClass("slider").appendTo(v);var q=$("<div id='"+s.name+"-param-control'>").appendTo(y);var r=(s.max<=1?0.01:(s.max<=1000?1:5));q.slider({min:s.min,max:s.max,step:r,value:s.value,slide:function(A,C){var B=C.value;s.value=B;if(0<B&&B<1){B=parseFloat(B).toFixed(2)}t.text(B)},change:function(A,B){s.value=B.value}});w.click(function(){var C=t,B=C.text(),A=(s.max<=1?4:s.max.length);C.text("");$("<input type='text'/>").attr("size",A).attr("maxlength",A).attr("value",B).appendTo(C).focus().select().click(function(D){D.stopPropagation()}).blur(function(){$(this).remove();C.text(B)}).keyup(function(F){if(F.keyCode===27){$(this).trigger("blur")}else{if(F.keyCode===13){var D=$(this),E=parseFloat(D.val());if(isNaN(E)||E>s.max||E<s.min){alert("Parameter value must be in the range ["+s.min+"-"+s.max+"]");return $(this)}C.text(E);q.slider("value",E);s.value=E}}})});$("<div style='clear: both;'/>").appendTo(v)});var p=$("<div>").addClass("slider-row").appendTo(this.dynamic_tool_div);var k=$("<input type='submit'>").attr("value","Run").appendTo(p);var c=this;k.click(function(){c.run_tool()})}c.child_tracks_container=$("<div/>").addClass("child-tracks-container").hide();c.container_div.append(c.child_tracks_container);if(c.display_modes!==undefined){if(c.mode_div===undefined){c.mode_div=$("<div class='right-float menubutton popup' />").appendTo(c.header_div);var e=(c.track_config&&c.track_config.values.mode?c.track_config.values.mode:c.display_modes[0]);c.mode=e;c.mode_div.text(e);var d=function(q){c.mode_div.text(q);c.mode=q;c.track_config.values.mode=q;c.tile_cache.clear();c.draw()};var a={};for(var f=0,h=c.display_modes.length;f<h;f++){var g=c.display_modes[f];a[g]=function(q){return function(){d(q)}}(g)}make_popupmenu(c.mode_div,a)}else{c.mode_div.hide()}}this.make_name_popup_menu()};$.extend(TiledTrack.prototype,Track.prototype,{make_name_popup_menu:function(){var b=this;var a={};a["Edit configuration"]=function(){var h=function(){hide_modal();$(window).unbind("keypress.check_enter_esc")},f=function(){b.track_config.update_from_form($(".dialog-box"));hide_modal();$(window).unbind("keypress.check_enter_esc")},g=function(j){if((j.keyCode||j.which)===27){h()}else{if((j.keyCode||j.which)===13){f()}}};$(window).bind("keypress.check_enter_esc",g);show_modal("Configure Track",b.track_config.build_form(),{Cancel:h,OK:f})};if(b.filters_available>0){var e=(b.filters_div.is(":visible")?"Hide filters":"Show filters");a[e]=function(){b.filters_visible=(b.filters_div.is(":visible"));b.filters_div.toggle();b.make_name_popup_menu()}}if(b.tool){var e=(b.dynamic_tool_div.is(":visible")?"Hide Tool":"Show Tool");a[e]=function(){if(!b.dynamic_tool_div.is(":visible")){b.update_name(b.name+b.tool_region_and_parameters_str())}else{menu_option_text="Show dynamic tool";b.revert_name()}b.dynamic_tool_div.toggle();b.make_name_popup_menu()}}if(b.track_type=="ReadTrack"){var e=(b.show_insertions?"Hide Insertions":"Show Insertions");a[e]=function(){b.show_insertions=!b.show_insertions;b.draw(true);b.make_name_popup_menu()}}if(b.valid_chroms){a["List chrom/contigs with data"]=function(){show_modal("Chrom/contigs with data","<p>"+b.valid_chroms.join("<br/>")+"</p>",{Close:function(){hide_modal()}})}}var c=view;var d=function(){$("#no-tracks").show()};if(this.parent_track){c=this.parent_track;d=function(){}}a.Remove=function(){c.remove_track(b);if(c.num_tracks===0){d()}};make_popupmenu(b.name_div,a)},tile_data:function(d,a,g,k,j){var b=this,h=a*DENSITY*d,f=(a+1)*DENSITY*d,e={chrom:this.view.chrom,low:h,high:f,dbkey:this.view.dbkey};if(j===undefined){j=d+"_"+a}var c=b.data_cache.get(j);if(c){return k(c)}$.extend(e,g);$.ajax({url:this.data_url,dataType:"json",data:e,success:function(l){b.data_cache.set(j,l);return k(l)},error:function(m,l,n){console.log(m,l,n)}})},draw:function(a,d){var s=this.view.low,g=this.view.high,j=g-s,l=this.view.container.width(),m=this.view.resolution;var e=$("<div style='position: relative;'></div>"),f=l/j;if(!d){this.content_div.children().remove()}this.content_div.append(e);this.max_height=0;var o=Math.floor(s/m/DENSITY);var c={};while((o*DENSITY*m)<g){var r=l+"_"+f+"_"+o;var h=this.tile_cache.get(r);var p=o*DENSITY*this.view.resolution;var b=p+DENSITY*this.view.resolution;if(!a&&h){this.show_tile(h,e,p,f)}else{this.delayed_draw(a,r,p,b,o,m,e,f,c)}o+=1}if(d){var k=this;var q=setInterval(function(){if(obj_length(c)===0){var v=k.content_div.children();var u=false;for(var w=v.length-1,t=0;w>=t;w--){var x=$(v[w]);if(u){x.remove()}else{if(x.children().length!==0){u=true}}}clearInterval(q)}},50)}for(var n=0;n<this.child_tracks.length;n++){this.child_tracks[n].draw(a,d)}},delayed_draw:function(b,j,h,l,c,e,k,m,f){var d=this;var g=function(n){d.tile_cache.set(j,n);d.show_tile(n,k,h,m)};var a=setTimeout(function(){if(h<=d.view.high&&l>=d.view.low){var n;if(!b){n=d.tile_cache.get(j)}if(!n){d.draw_tile(e,c,k,m,function(p){if(p){var o=$("<div class='track-tile'>").prepend(p);n=o}g(n)})}if(n){g(n)}}delete f[a]},50);f[a]=true},show_tile:function(h,j,e,k){var a=this;var c=this.view.high-this.view.low,b=(e-this.view.low)*k;if(this.left_offset){b-=this.left_offset}h.css({position:"absolute",top:0,left:b,height:""});j.append(h);a.max_height=Math.max(a.max_height,h.height());a.content_div.css("height",a.max_height+"px");j.children().css("height",a.max_height+"px");if(a.hidden){return}for(var g=0;g<a.filters.length;g++){a.filters[g].update_ui_elt()}var d=false;if(a.example_feature){for(var g=0;g<a.filters.length;g++){if(a.filters[g].applies_to(a.example_feature)){d=true;break}}}if(a.filters_available!==d){a.filters_available=d;if(!a.filters_available){a.filters_div.hide()}a.make_name_popup_menu()}},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")},run_tool:function(){var b={dataset_id:this.original_dataset_id,chrom:this.view.chrom,low:this.view.low,high:this.view.high,tool_id:this.tool.name};$.extend(b,this.tool.get_param_values_dict());var d=this,c=b.tool_id+d.tool_region_and_parameters_str(b.chrom,b.low,b.high),e;if(d.track_type==="FeatureTrack"){e=new ToolDataFeatureTrack(c,view,d.hda_ldda,undefined,{},{},d)}this.add_track(e);e.content_div.text("Starting job.");view.has_changes=true;var a=function(){$.getJSON(run_tool_url,b,function(f){if(f==="no converter"){e.container_div.addClass("error");e.content_div.text(DATA_NOCONVERTER)}else{if(f.error){e.container_div.addClass("error");e.content_div.text(DATA_CANNOT_RUN_TOOL+f.message)}else{if(f==="pending"){e.container_div.addClass("pending");e.content_div.text("Converting input data so that it can be easily reused.");setTimeout(a,2000)}else{e.dataset_id=f.dataset_id;e.content_div.text("Running job.");e.init()}}}})};a()},tool_region_and_parameters_str:function(c,a,d){var b=this,e=(c!==undefined&&a!==undefined&&d!==undefined?c+":"+a+"-"+d:"all");return" - region=["+e+"], parameters=["+b.tool.get_param_values().join(", ")+"]"},add_track:function(a){a.track_id=this.track_id+"_"+this.child_tracks.length;a.container_div.attr("id","track_"+a.track_id);this.child_tracks_container.append(a.container_div);sortable(a.container_div,".child-track-icon");if(!$(this.child_tracks_container).is(":visible")){this.child_tracks_container.show()}this.child_tracks.push(a)},remove_track:function(a){a.container_div.fadeOut("slow",function(){$(this).remove()})}});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.view.container.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);a.reference_track=this;this.left_offset=200;this.height_px=12;this.font=DEFAULT_FONT;this.container_div.addClass("reference-track");this.content_div.css("background","none");this.content_div.css("min-height","0px");this.content_div.css("border","none");this.data_url=reference_url;this.data_cache=new DataCache(CACHED_DATA);this.tile_cache=new Cache(CACHED_TILES_LINE)};$.extend(ReferenceTrack.prototype,TiledTrack.prototype,{draw_tile:function(c,b,e,g,f){var a=this,d=DENSITY*c;if(g>CHAR_WIDTH_PX){a.tile_data(c,b,{},function(j){if(j===null){a.content_div.css("height","0px");return}var k=document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(k)}k=$(k);var h=k.get(0).getContext("2d");k.get(0).width=Math.ceil(d*g+a.left_offset);k.get(0).height=a.height_px;h.font=DEFAULT_FONT;h.textAlign="center";for(var n=0,l=j.length;n<l;n++){var m=Math.round(n*g);h.fillText(j[n],m+a.left_offset,10)}return f(k)})}this.content_div.css("height","0px")}});var LineTrack=function(e,c,f,a,d){var b=this;this.track_type="LineTrack";this.display_modes=["Histogram","Line","Filled","Intensity"];this.mode="Histogram";Track.call(this,e,c,c.viewport_container);TiledTrack.call(this);this.min_height_px=16;this.max_height_px=400;this.height_px=80;this.hda_ldda=f;this.dataset_id=a;this.original_dataset_id=a;this.data_cache=new DataCache(CACHED_DATA);this.tile_cache=new Cache(CACHED_TILES_LINE);this.track_config=new TrackConfig({track:this,params:[{key:"color",label:"Color",type:"color",default_value:"black"},{key:"min_value",label:"Min Value",type:"float",default_value:undefined},{key:"max_value",label:"Max Value",type:"float",default_value:undefined},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"height",type:"int",default_value:this.height_px,hidden:true}],saved_values:d,onchange:function(){b.vertical_range=b.prefs.max_value-b.prefs.min_value;$("#linetrack_"+b.track_id+"_minval").text(b.prefs.min_value);$("#linetrack_"+b.track_id+"_maxval").text(b.prefs.max_value);b.tile_cache.clear();b.draw()}});this.prefs=this.track_config.values;this.height_px=this.track_config.values.height;this.vertical_range=this.track_config.values.max_value-this.track_config.values.min_value;(function(g){var k=false;var j=false;var h=$("<div class='track-resize'>");$(g.container_div).hover(function(){k=true;h.show()},function(){k=false;if(!j){h.hide()}});h.hide().bind("dragstart",function(l,m){j=true;m.original_height=$(g.content_div).height()}).bind("drag",function(m,n){var l=Math.min(Math.max(n.original_height+n.deltaY,g.min_height_px),g.max_height_px);$(g.content_div).css("height",l);g.height_px=l;g.draw(true)}).bind("dragend",function(l,m){g.tile_cache.clear();j=false;if(!k){h.hide()}g.track_config.values.height=g.height_px}).appendTo(g.container_div)})(this)};$.extend(LineTrack.prototype,TiledTrack.prototype,{predraw_init:function(){var a=this,b=a.view.tracks.indexOf(a);a.vertical_range=undefined;return $.getJSON(a.data_url,{stats:true,chrom:a.view.chrom,low:null,high:null,hda_ldda:a.hda_ldda,dataset_id:a.dataset_id},function(c){a.container_div.addClass("line-track");var e=c.data;if(isNaN(parseFloat(a.prefs.min_value))||isNaN(parseFloat(a.prefs.max_value))){a.prefs.min_value=e.min;a.prefs.max_value=e.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=e.total_frequency;a.container_div.find(".yaxislabel").remove();var f=$("<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.css({position:"absolute",top:"24px",left:"10px"});d.prependTo(a.container_div);f.css({position:"absolute",bottom:"2px",left:"10px"});f.prependTo(a.container_div)})},draw_tile:function(d,a,j,k,h){if(this.vertical_range===undefined){return}var c=this,f=a*DENSITY*d,b=DENSITY*d,g=d+"_"+a,e={hda_ldda:this.hda_ldda,dataset_id:this.dataset_id,resolution:this.view.resolution};this.tile_data(d,a,e,function(C){var l=document.createElement("canvas"),q=C.data;if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(l)}l=$(l);l.get(0).width=Math.ceil(b*k);l.get(0).height=c.height_px;var z=l.get(0).getContext("2d"),n=false,B=c.prefs.min_value,v=c.prefs.max_value,A=c.vertical_range,m=c.total_frequency,u=c.height_px,s=c.mode;var r=Math.round(u+B/A*u);z.beginPath();z.moveTo(0,r);z.lineTo(b*k,r);z.fillStyle="#aaa";z.stroke();z.beginPath();z.fillStyle=c.prefs.color;var p,w,x;if(q.length>1){x=Math.ceil((q[1][0]-q[0][0])*k)}else{x=10}for(var o=0,t=q.length;o<t;o++){p=Math.round((q[o][0]-f)*k);w=q[o][1];if(w===null){if(n&&s==="Filled"){z.lineTo(p,u)}n=false;continue}if(w<B){w=B}else{if(w>v){w=v}}if(s==="Histogram"){w=Math.round(w/A*u);z.fillRect(p,r,x,-w)}else{if(s==="Intensity"){w=255-Math.floor((w-B)/A*255);z.fillStyle="rgb("+w+","+w+","+w+")";z.fillRect(p,0,x,u)}else{w=Math.round(u-(w-B)/A*u);if(n){z.lineTo(p,w)}else{n=true;if(s==="Filled"){z.moveTo(p,u);z.lineTo(p,w)}else{z.moveTo(p,w)}}}}}if(s==="Filled"){if(n){z.lineTo(p,r);z.lineTo(0,r)}z.fill()}else{z.stroke()}h(l)})}});var FeatureTrack=function(a,f,e,j,h,c,d,g){var b=this;this.track_type="FeatureTrack";this.display_modes=["Auto","Dense","Squish","Pack"];this.track_config=new TrackConfig({track:this,params:[{key:"block_color",label:"Block color",type:"color",default_value:"#444"},{key:"label_color",label:"Label color",type:"color",default_value:"black"},{key:"show_counts",label:"Show summary counts",type:"bool",default_value:true},{key:"mode",type:"string",default_value:this.mode,hidden:true},],saved_values:h,onchange:function(){b.tile_cache.clear();b.draw()}});this.prefs=this.track_config.values;Track.call(this,a,f,f.viewport_container);TiledTrack.call(this,c,d,g);this.height_px=0;this.container_div.addClass("feature-track");this.hda_ldda=e;this.dataset_id=j;this.original_dataset_id=j;this.zo_slots={};this.show_labels_scale=0.001;this.showing_details=false;this.summary_draw_height=30;this.default_font=DEFAULT_FONT;this.inc_slots={};this.start_end_dct={};this.tile_cache=new Cache(CACHED_TILES_FEATURE);this.data_cache=new DataCache(20);this.left_offset=200};$.extend(FeatureTrack.prototype,TiledTrack.prototype,{incremental_slots:function(a,h,p){var q=this.inc_slots[a];if(!q||(q.mode!==p)){q={};q.w_scale=a;q.mode=p;this.inc_slots[a]=q;this.start_end_dct[a]={}}var l=q.w_scale,w=[],x=[],j=0,n=this.view.max_low;for(var u=0,v=h.length;u<v;u++){var g=h[u],k=g[0];if(q[k]!==undefined){j=Math.max(j,q[k]);x.push(q[k])}else{w.push(u)}}var d=this.start_end_dct[a];var m=function(D,E){for(var C=0;C<=MAX_FEATURE_DEPTH;C++){var A=false,F=d[C];if(F!==undefined){for(var z=0,B=F.length;z<B;z++){var y=F[z];if(E>y[0]&&D<y[1]){A=true;break}}}if(!A){return C}}return -1};for(var u=0,v=w.length;u<v;u++){var g=h[w[u]],k=g[0],s=g[1],b=g[2],o=g[3],c=Math.floor((s-n)*l),f=Math.ceil((b-n)*l),t=CONTEXT.measureText(o).width,e;if(o!==undefined&&p==="Pack"){t+=(LABEL_SPACING+PACK_SPACING);if(c-t>=0){c-=t;e="left"}else{f+=t;e="right"}}var r=m(c,f);if(r>=0){if(d[r]===undefined){d[r]=[]}d[r].push([c,f]);q[k]=r;j=Math.max(j,r)}else{}}return j+1},draw_summary_tree:function(b,o,n,l,r,j,f,e){var c=j+LABEL_SPACING+CHAR_HEIGHT_PX;delta_x_px=Math.ceil(n*r);var h=$("<div />").addClass("yaxislabel");h.text(l);h.css({position:"absolute",top:"22px",left:"10px"});h.prependTo(this.container_div);var q=b.get(0).getContext("2d");for(var d=0,g=o.length;d<g;d++){var m=Math.floor((o[d][0]-f)*r);var k=o[d][1];if(!k){continue}var p=k/l*j;q.fillStyle="black";q.fillRect(m+e,c-p,delta_x_px,p);var a=4;if(this.prefs.show_counts&&(q.measureText(k).width+a)<delta_x_px){q.fillStyle="#666";q.textAlign="center";q.fillText(k,m+e+(delta_x_px/2),10)}}},draw_element:function(p,f,g,x,j,r,I,M,N,a,A){var u=x[0],K=x[1],C=x[2],s=x[3],D=Math.floor(Math.max(0,(K-r)*M)),q=Math.ceil(Math.min(a,Math.max(0,(C-r)*M))),B=ERROR_PADDING+(g==="Dense"?0:(0+j))*N,o,G,t=null,O=null,d=this.prefs.block_color,F=this.prefs.label_color;if(g==="Dense"){p.fillStyle=d;p.fillRect(D+A,B,q-D,DENSE_FEATURE_HEIGHT)}else{if(g==="no_detail"){p.fillStyle=d;p.fillRect(D+A,B+5,q-D,DENSE_FEATURE_HEIGHT)}else{var n=x[5],z=x[6],E=x[7],e=x[8];if(z&&E){t=Math.floor(Math.max(0,(z-r)*M));O=Math.ceil(Math.min(a,Math.max(0,(E-r)*M)))}var L,v;if(g==="Squish"){L=1;v=SQUISH_FEATURE_HEIGHT}else{L=5;v=PACK_FEATURE_HEIGHT}if(!e){if(x.strand){if(x.strand==="+"){p.fillStyle=RIGHT_STRAND_INV}else{if(x.strand==="-"){p.fillStyle=LEFT_STRAND_INV}}}else{p.fillStyle=d}p.fillRect(D+A,B,q-D,v)}else{var m,w;if(g==="Squish"){p.fillStyle=CONNECTOR_COLOR;m=B+Math.floor(SQUISH_FEATURE_HEIGHT/2)+1;w=1}else{if(n){var m=B;var w=v;if(n==="+"){p.fillStyle=RIGHT_STRAND}else{if(n==="-"){p.fillStyle=LEFT_STRAND}}}else{p.fillStyle=CONNECTOR_COLOR;m+=(SQUISH_FEATURE_HEIGHT/2)+1;w=1}}p.fillRect(D+A,m,q-D,w);for(var J=0,c=e.length;J<c;J++){var h=e[J],b=Math.floor(Math.max(0,(h[0]-r)*M)),y=Math.ceil(Math.min(a,Math.max((h[1]-r)*M)));if(b>y){continue}p.fillStyle=d;p.fillRect(b+A,B+(v-L)/2+1,y-b,L);if(t!==undefined&&!(b>O||y<t)){var H=Math.max(b,t),l=Math.min(y,O-1);p.fillRect(H+A,B+1,l-H,v)}}}if(g==="Pack"&&K>r){p.fillStyle=F;if(f===0&&D-p.measureText(s).width<0){p.textAlign="left";p.fillText(s,q+A+LABEL_SPACING,B+8)}else{p.textAlign="right";p.fillText(s,D+A-LABEL_SPACING,B+8)}p.fillStyle=d}}}},get_y_scale:function(b){var a;if(b==="summary_tree"){}if(b==="Dense"){a=DENSE_TRACK_HEIGHT}else{if(b==="no_detail"){a=NO_DETAIL_TRACK_HEIGHT}else{if(b==="Squish"){a=SQUISH_TRACK_HEIGHT}else{a=PACK_TRACK_HEIGHT}}}return a},draw_tile:function(z,E,l,n,j,d,p){var v=this;if(v.view.reference_track&&n>CHAR_WIDTH_PX&&d===undefined){return v.view.reference_track.tile_data(z,E,{},function(f){v.draw_tile(z,E,l,n,j,f)})}var G=E*DENSITY*z,a=(E+1)*DENSITY*z,s=a-G,H={hda_ldda:v.hda_ldda,dataset_id:v.dataset_id,resolution:this.view.resolution,mode:this.mode};if(p===undefined){var q=this.data_cache.get_data(G,a,this.mode),J=z+"_"+E+"_"+this.mode;if(q===undefined){return v.tile_data(z,E,H,function(f){v.data_cache.set_data(G,a,this.mode,f);v.draw_tile(z,E,l,n,j,d,f)},J)}p=q}var x=Math.ceil(s*n),u=this.mode,K=25,g=this.left_offset,r,h;var c=document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(c)}c=$(c);if(u==="Auto"){if(p.dataset_type==="summary_tree"){u=p.dataset_type}else{if(p.extra_info==="no_detail"){u="no_detail"}else{var I=p.data;if((I.length&&I.length<4)||(this.view.high-this.view.low>MIN_SQUISH_VIEW_WIDTH)){u="Squish"}else{u="Pack"}}}}var A=this.get_y_scale(u);if(u==="summary_tree"){h=this.summary_draw_height}if(u==="Dense"){h=K}else{if(u==="no_detail"||u==="Squish"||u==="Pack"){h=this.incremental_slots(n,p.data,u)*A+K;r=this.inc_slots[n]}}c.get(0).width=x+g;c.get(0).height=h;if(p.dataset_type==="summary_tree"){c.get(0).height+=LABEL_SPACING+CHAR_HEIGHT_PX}l.parent().css("height",Math.max(this.height_px,h)+"px");var y=c.get(0).getContext("2d");y.fillStyle=this.prefs.block_color;y.font=this.default_font;y.textAlign="right";this.container_div.find(".yaxislabel").remove();if(u==="summary_tree"){this.draw_summary_tree(c,p.data,p.delta,p.max,n,h,G,g);return j(c)}if(p.message){c.css({"border-top":"1px solid red"});y.fillStyle="red";y.textAlign="left";var t=y.textBaseline;y.textBaseline="top";y.fillText(p.message,g,0);y.textBaseline=t;if(!p.data){return j(c)}}this.example_feature=(p.data.length?p.data[0]:undefined);var I=p.data;for(var B=0,D=I.length;B<D;B++){var k=I[B],m=k[0],w=k[1],b=k[2],e=(r&&r[m]!==undefined?r[m]:null);var C=false;var o;for(var F=0;F<this.filters.length;F++){o=this.filters[F];o.update_attrs(k);if(!o.keep(k)){C=true;break}}if(C){continue}if(is_overlap([w,b],[G,a])&&(u=="Dense"||e!==null)){this.draw_element(y,E,u,k,e,G,a,n,A,x,g,d)}}j(c)}});var VcfTrack=function(d,b,f,a,c,e){FeatureTrack.call(this,d,b,f,a,c,e);this.track_type="VcfTrack"};$.extend(VcfTrack.prototype,TiledTrack.prototype,FeatureTrack.prototype,{draw_element:function(u,p,j,e,x,c,m,v,s){var j=data[i],l=j[0],t=j[1],d=j[2]-1,o=j[3],g=Math.floor(Math.max(0,(t-x)*m)),k=Math.ceil(Math.min(s,Math.max(0,(d-x)*m))),f=ERROR_PADDING+(p==="Dense"?0:(0+e))*v,a,y,b=null,n=null;if(no_label){u.fillStyle=block_color;u.fillRect(g+left_offset,f+5,k-g,1)}else{var w=j[4],r=j[5],h=j[6];a=9;y=1;u.fillRect(g+left_offset,f,k-g,a);if(p!=="Dense"&&o!==undefined&&t>x){u.fillStyle=label_color;if(tile_index===0&&g-u.measureText(o).width<0){u.textAlign="left";u.fillText(o,k+2+left_offset,f+8)}else{u.textAlign="right";u.fillText(o,g-2+left_offset,f+8)}u.fillStyle=block_color}var q=w+" / "+r;if(t>x&&u.measureText(q).width<(k-g)){u.fillStyle="white";u.textAlign="center";u.fillText(q,left_offset+g+(k-g)/2,f+8);u.fillStyle=block_color}}}});var ReadTrack=function(d,b,f,a,c,e){FeatureTrack.call(this,d,b,f,a,c,e);this.track_type="ReadTrack";this.difference_mode=true;this.show_insertions=false;this.make_name_popup_menu()};$.extend(ReadTrack.prototype,TiledTrack.prototype,FeatureTrack.prototype,{get_y_scale:function(b){var a;if(b==="summary_tree"){}if(b==="Dense"){a=DENSE_TRACK_HEIGHT}else{if(b==="Squish"){a=SQUISH_TRACK_HEIGHT}else{a=PACK_TRACK_HEIGHT;if(this.show_insertions){a*=2}}}return a},draw_read:function(m,d,J,n,D,G,e,o,y,a){m.textAlign="center";var l=this,u=[n,D],C=0,z=0,f=0;var r=[];if((d==="Pack"||this.mode==="Auto")&&o!==undefined&&J>CHAR_WIDTH_PX){f=Math.round(J/2)}if(!e){e=[[0,o.length]]}for(var h=0,k=e.length;h<k;h++){var b=e[h],g="MIDNSHP=X"[b[0]],v=b[1];if(g==="H"||g==="S"){C-=v}var x=G+C,B=Math.floor(Math.max(0,(x-n)*J)),E=Math.floor(Math.max(0,(x+v-n)*J));switch(g){case"H":break;case"S":case"M":case"=":var p=compute_overlap([x,x+v],u);if(p!==NO_OVERLAP){var q=o.slice(z,z+v);if(f>0){m.fillStyle=this.prefs.block_color;m.fillRect(B+this.left_offset-f,y+1,E-B,9);m.fillStyle=CONNECTOR_COLOR;for(var I=0,j=q.length;I<j;I++){if(this.difference_mode&&a){var s=a[x-n+I];if(!s||s.toLowerCase()===q[I].toLowerCase()){continue}}if(x+I>=n&&x+I<=D){var A=Math.floor(Math.max(0,(x+I-n)*J));m.fillText(q[I],A+this.left_offset,y+9)}}}else{m.fillStyle=this.prefs.block_color;m.fillRect(B+this.left_offset,y+(this.mode!=="Dense"?4:5),E-B,(d!=="Dense"?SQUISH_FEATURE_HEIGHT:DENSE_FEATURE_HEIGHT))}}z+=v;C+=v;break;case"N":m.fillStyle=CONNECTOR_COLOR;m.fillRect(B+this.left_offset-f,y+5,E-B,1);C+=v;break;case"D":m.fillStyle="red";m.fillRect(B+this.left_offset-f,y+4,E-B,3);C+=v;break;case"P":break;case"I":var p=compute_overlap([x,x+v],u),K=this.left_offset+B-f;if(p!==NO_OVERLAP){var q=o.slice(z,z+v);if(this.show_insertions){var w=this.left_offset+B-(E-B)/2;if((d==="Pack"||this.mode==="Auto")&&o!==undefined&&J>CHAR_WIDTH_PX){m.fillStyle="yellow";m.fillRect(w-f,y-9,E-B,9);r[r.length]={type:"triangle",data:[K,y+4,5]};m.fillStyle=CONNECTOR_COLOR;switch(p){case (OVERLAP_START):q=q.slice(n-x);break;case (OVERLAP_END):q=q.slice(0,x-D);break;case (CONTAINED_BY):break;case (CONTAINS):q=q.slice(n-x,x-D);break}for(var I=0,j=q.length;I<j;I++){var A=Math.floor(Math.max(0,(x+I-n)*J));m.fillText(q[I],A+this.left_offset-(E-B)/2,y)}}else{m.fillStyle="yellow";m.fillRect(w,y+(this.mode!=="Dense"?2:5),E-B,(d!=="Dense"?SQUISH_FEATURE_HEIGHT:DENSE_FEATURE_HEIGHT))}}else{if((d==="Pack"||this.mode==="Auto")&&o!==undefined&&J>CHAR_WIDTH_PX){r[r.length]={type:"text",data:[q.length,K,y+9]}}else{}}}z+=v;break;case"X":z+=v;break}}m.fillStyle="yellow";var t,L,H;for(var F=0;F<r.length;F++){t=r[F];L=t.type;H=t.data;if(L==="text"){m.font="bold "+DEFAULT_FONT;m.fillText(H[0],H[1],H[2]);m.font=DEFAULT_FONT}else{if(L=="triangle"){m.drawDownwardEquilateralTriangle(H[0],H[1],H[2])}}}},draw_element:function(w,y,r,k,e,A,b,n,x,u,f,c){var m=k[0],v=k[1],d=k[2],o=k[3],h=Math.floor(Math.max(0,(v-A)*n)),j=Math.ceil(Math.min(u,Math.max(0,(d-A)*n))),g=(r==="Dense"?1:(1+e))*x,z=this.prefs.block_color,l=this.prefs.label_color;t=0;w.fillStyle=z;if(k[5] instanceof Array){var s=Math.floor(Math.max(0,(k[4][0]-A)*n)),q=Math.ceil(Math.min(u,Math.max(0,(k[4][1]-A)*n))),p=Math.floor(Math.max(0,(k[5][0]-A)*n)),a=Math.ceil(Math.min(u,Math.max(0,(k[5][1]-A)*n)));if(k[4][1]>=A&&k[4][0]<=b&&k[4][2]){this.draw_read(w,r,n,A,b,k[4][0],k[4][2],k[4][3],g,c)}if(k[5][1]>=A&&k[5][0]<=b&&k[5][2]){this.draw_read(w,r,n,A,b,k[5][0],k[5][2],k[5][3],g,c)}if(p>q){w.fillStyle=CONNECTOR_COLOR;w.dashedLine(q+f,g+5,f+p,g+5)}}else{w.fillStyle=z;this.draw_read(w,r,n,A,b,v,k[4],k[5],g,c)}if(r==="Pack"&&v>A){w.fillStyle=this.prefs.label_color;if((r==="Pack"||this.mode==="Auto")&&n>CHAR_WIDTH_PX){var t=Math.round(n/2)}if(y===0&&h-w.measureText(o).width<0){w.textAlign="left";w.fillText(o,j+f+LABEL_SPACING-t,g+8)}else{w.textAlign="right";w.fillText(o,h+f-LABEL_SPACING-t,g+8)}w.fillStyle=z}}});var ToolDataFeatureTrack=function(e,c,g,a,d,f,b){FeatureTrack.call(this,e,c,g,a,d,f,{},b);this.track_type="ToolDataFeatureTrack";this.data_url=raw_data_url;this.data_query_wait=1000;this.dataset_check_url=dataset_state_url};$.extend(ToolDataFeatureTrack.prototype,TiledTrack.prototype,FeatureTrack.prototype,{predraw_init:function(){var b=this;var a=function(){if(b.data_cache.size()===0){setTimeout(a,300)}else{b.data_url=default_data_url;b.data_query_wait=DEFAULT_DATA_QUERY_WAIT;b.dataset_state_url=converted_datasets_state_url;$.getJSON(b.dataset_state_url,{dataset_id:b.dataset_id,hda_ldda:b.hda_ldda},function(c){})}};a()}});
\ No newline at end of file
+CanvasRenderingContext2D.prototype.dashedLine=function(c,j,b,h,f){if(f===undefined){f=4}var e=b-c;var d=h-j;var g=Math.floor(Math.sqrt(e*e+d*d)/f);var l=e/g;var k=d/g;var a;for(a=0;a<g;a++,c+=l,j+=k){if(a%2!==0){continue}this.fillRect(c,j,f,1)}};CanvasRenderingContext2D.prototype.drawDownwardEquilateralTriangle=function(b,a,e){var d=b-e/2,c=b+e/2,f=a-Math.sqrt(e*3/2);this.beginPath();this.moveTo(d,f);this.lineTo(c,f);this.lineTo(b,a);this.lineTo(d,f);this.strokeStyle=this.fillStyle;this.fill();this.stroke();this.closePath()};function sortable(a,b){a.bind("drag",{handle:b,relative:true},function(h,j){var g=$(this).parent();var f=g.children();var c;for(c=0;c<f.length;c++){if(j.offsetY<$(f.get(c)).position().top){break}}if(c===f.length){if(this!==f.get(c-1)){g.append(this)}}else{if(this!==f.get(c)){$(this).insertBefore(f.get(c))}}})}var NO_OVERLAP=1001,CONTAINS=1002,OVERLAP_START=1003,OVERLAP_END=1004,CONTAINED_BY=1005;function compute_overlap(e,b){var g=e[0],f=e[1],d=b[0],c=b[1],a;if(g<d){if(f<d){a=NO_OVERLAP}else{if(f<=c){a=OVERLAP_START}else{a=CONTAINS}}}else{if(g>c){a=NO_OVERLAP}else{if(f<=c){a=CONTAINED_BY}else{a=OVERLAP_END}}}return a}function is_overlap(b,a){return(compute_overlap(b,a)!==NO_OVERLAP)}var DENSE_TRACK_HEIGHT=10,NO_DETAIL_TRACK_HEIGHT=3,SQUISH_TRACK_HEIGHT=5,PACK_TRACK_HEIGHT=10,NO_DETAIL_FEATURE_HEIGHT=1,DENSE_FEATURE_HEIGHT=1,SQUISH_FEATURE_HEIGHT=3,PACK_FEATURE_HEIGHT=9,ERROR_PADDING=10,LABEL_SPACING=2,PACK_SPACING=5,MIN_SQUISH_VIEW_WIDTH=12000,DEFAULT_FONT="9px Monaco, Lucida Console, monospace",DENSITY=200,FEATURE_LEVELS=10,MAX_FEATURE_DEPTH=100,DEFAULT_DATA_QUERY_WAIT=5000,MAX_CHROMS_SELECTABLE=100,CONNECTOR_COLOR="#ccc",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_CANNOT_RUN_TOOL="Tool cannot be rerun: ",DATA_LOADING="Loading data...",DATA_OK="Ready for display",CACHED_TILES_FEATURE=10,CACHED_TILES_LINE=5,CACHED_DATA=5,DUMMY_CANVAS=document.createElement("canvas"),RIGHT_STRAND,LEFT_STRAND;if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(DUMMY_CANVAS)}var CONTEXT=DUMMY_CANVAS.getContext("2d");CONTEXT.font=DEFAULT_FONT;var CHAR_WIDTH_PX=CONTEXT.measureText("A").width,CHAR_HEIGHT_PX=9;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.move_key_to_end(b,a)}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},move_key_to_end:function(b,a){this.key_ary.splice(a,1);this.key_ary.push(b)},clear:function(){this.obj_cache={};this.key_ary=[]},size:function(){return this.key_ary.length}});var DataManager=function(b,a){Cache.call(this,b);this.track=a};$.extend(DataManager.prototype,Cache.prototype,{load_data:function(d,a,f,h,b,e){var g={chrom:d,low:a,high:f,mode:h,resolution:b,dataset_id:this.track.dataset_id,hda_ldda:this.track.hda_ldda};$.extend(g,e);var c=this;return $.getJSON(this.track.data_url,g,function(j){c.set_data(a,f,h,j)})},get_data:function(j,k,c,h,b,f){var l=this.get(this.gen_key(k,c,h));if(l){return l}var m,g,a,e,h,l;for(var d=0;d<this.key_ary.length;d++){m=this.key_ary[d];g=this.split_key(m);a=g[0];e=g[1];if(k>=a&&c<=e){l=this.obj_cache[m];if(l.dataset_type!=="summary_tree"&&l.extra_info!=="no_detail"){this.move_key_to_end(m,d);return l}}}return this.load_data(j,k,c,h,b,f)},set_data:function(b,c,d,a){return this.set(this.gen_key(b,c,d),a)},gen_key:function(a,c,d){var b=a+"_"+c+"_"+d;return b},split_key:function(a){return a.split("_")}});var View=function(a,d,c,b,e){this.container=a;this.chrom=null;this.vis_id=c;this.dbkey=b;this.title=d;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(e);this.reset()};$.extend(View.prototype,{init:function(d){var c=this.container,a=this;this.top_container=$("<div/>").addClass("top-container").appendTo(c);this.content_div=$("<div/>").addClass("content").css("position","relative").appendTo(c);this.bottom_container=$("<div/>").addClass("bottom-container").appendTo(c);this.top_labeltrack=$("<div/>").addClass("top-labeltrack").appendTo(this.top_container);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_labeltrack=$("<div/>").addClass("nav-labeltrack").appendTo(this.bottom_container);this.nav_container=$("<div/>").addClass("nav-container").prependTo(this.top_container);this.nav=$("<div/>").addClass("nav").appendTo(this.nav_container);this.overview=$("<div/>").addClass("overview").appendTo(this.bottom_container);this.overview_viewport=$("<div/>").addClass("overview-viewport").appendTo(this.overview);this.overview_close=$("<a 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_select=$("<select/>").attr({name:"chrom"}).css("width","15em").addClass("no-autocomplete").append("<option value=''>Loading</option>").appendTo(this.nav_controls);var b=function(f){if(f.type==="focusout"||(f.keyCode||f.which)===13||(f.keyCode||f.which)===27){if((f.keyCode||f.which)!==27){a.go_to($(this).val())}$(this).hide();$(this).val("");a.location_span.show();a.chrom_select.show()}};this.nav_input=$("<input/>").addClass("nav-input").hide().bind("keyup focusout",b).appendTo(this.nav_controls);this.location_span=$("<span/>").addClass("location").appendTo(this.nav_controls);this.location_span.bind("click",function(){a.location_span.hide();a.chrom_select.hide();a.nav_input.val(a.chrom+":"+a.low+"-"+a.high);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.nav_controls)}this.zo_link=$("<a id='zoom-out' />").click(function(){a.zoom_out();a.redraw()}).appendTo(this.nav_controls);this.zi_link=$("<a id='zoom-in' />").click(function(){a.zoom_in();a.redraw()}).appendTo(this.nav_controls);this.load_chroms({low:0},d);this.chrom_select.bind("change",function(){a.change_chrom(a.chrom_select.val())});this.intro_div.show();this.content_div.bind("click",function(f){$(this).find("input").trigger("blur")});this.content_div.bind("dblclick",function(f){a.zoom_in(f.pageX,this.viewport_container)});this.overview_box.bind("dragstart",function(f,g){this.current_x=g.offsetX}).bind("drag",function(f,h){var j=h.offsetX-this.current_x;this.current_x=h.offsetX;var g=Math.round(j/a.viewport_container.width()*(a.max_high-a.max_low));a.move_delta(-g)});this.overview_close.bind("click",function(){for(var f=0,e=a.tracks.length;f<e;f++){a.tracks[f].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("draginit",function(f,g){if(f.clientX>a.viewport_container.width()-16){return false}}).bind("dragstart",function(f,g){g.original_low=a.low;g.current_height=f.clientY;g.current_x=g.offsetX}).bind("drag",function(h,k){var f=$(this);var l=k.offsetX-k.current_x;var g=f.scrollTop()-(h.clientY-k.current_height);f.scrollTop(g);k.current_height=h.clientY;k.current_x=k.offsetX;var j=Math.round(l/a.viewport_container.width()*(a.high-a.low));a.move_delta(j)}).bind("mousewheel",function(h,k,g,f){if(g){var j=Math.round(-g/a.viewport_container.width()*(a.high-a.low));a.move_delta(j)}});this.top_labeltrack.bind("dragstart",function(f,g){return $("<div />").css({height:a.content_div.height()+a.top_labeltrack.height()+a.nav_labeltrack.height()+1,top:"0px",position:"absolute","background-color":"#ccf",opacity:0.5,"z-index":1000}).appendTo($(this))}).bind("drag",function(k,l){$(l.proxy).css({left:Math.min(k.pageX,l.startX),width:Math.abs(k.pageX-l.startX)});var g=Math.min(k.pageX,l.startX)-a.container.offset().left,f=Math.max(k.pageX,l.startX)-a.container.offset().left,j=(a.high-a.low),h=a.viewport_container.width();a.update_location(Math.round(g/h*j)+a.low,Math.round(f/h*j)+a.low)}).bind("dragend",function(l,m){var g=Math.min(l.pageX,m.startX),f=Math.max(l.pageX,m.startX),j=(a.high-a.low),h=a.viewport_container.width(),k=a.low;a.low=Math.round(g/h*j)+k;a.high=Math.round(f/h*j)+k;$(m.proxy).remove();a.redraw()});this.add_label_track(new LabelTrack(this,this.top_labeltrack));this.add_label_track(new LabelTrack(this,this.nav_labeltrack));$(window).bind("resize",function(){a.resize_window()});$(document).bind("redraw",function(){a.redraw()});this.reset();$(window).trigger("resize")},update_location:function(a,b){this.location_span.text(commatize(a)+" - "+commatize(b));this.nav_input.val(this.chrom+":"+commatize(a)+"-"+commatize(b))},load_chroms:function(b,c){b.num=MAX_CHROMS_SELECTABLE;$.extend(b,(this.vis_id!==undefined?{vis_id:this.vis_id}:{dbkey:this.dbkey}));var a=this;$.ajax({url:chrom_url,data:b,dataType:"json",success:function(e){if(e.chrom_info.length===0){alert("Invalid chromosome: "+b.chrom);return}if(e.reference){a.add_label_track(new ReferenceTrack(a))}a.chrom_data=e.chrom_info;var h='<option value="">Select Chrom/Contig</option>';for(var g=0,d=a.chrom_data.length;g<d;g++){var f=a.chrom_data[g].chrom;h+='<option value="'+f+'">'+f+"</option>"}if(e.prev_chroms){h+='<option value="previous">Previous '+MAX_CHROMS_SELECTABLE+"</option>"}if(e.next_chroms){h+='<option value="next">Next '+MAX_CHROMS_SELECTABLE+"</option>"}a.chrom_select.html(h);if(c){c()}a.chrom_start_index=e.start_index},error:function(){alert("Could not load chroms for this dbkey:",a.dbkey)}})},change_chrom:function(e,b,g){if(!e||e==="None"){return}var d=this;if(e==="previous"){d.load_chroms({low:this.chrom_start_index-MAX_CHROMS_SELECTABLE});return}if(e==="next"){d.load_chroms({low:this.chrom_start_index+MAX_CHROMS_SELECTABLE});return}var f=$.grep(d.chrom_data,function(j,k){return j.chrom===e})[0];if(f===undefined){d.load_chroms({chrom:e},function(){d.change_chrom(e,b,g)});return}else{if(e!==d.chrom){d.chrom=e;if(!d.chrom){d.intro_div.show()}else{d.intro_div.hide()}d.chrom_select.val(d.chrom);d.max_high=f.len-1;d.reset();d.redraw(true);for(var h=0,a=d.tracks.length;h<a;h++){var c=d.tracks[h];if(c.init){c.init()}}}if(b!==undefined&&g!==undefined){d.low=Math.max(b,0);d.high=Math.min(g,d.max_high)}d.reset_overview();d.redraw()}},go_to:function(f){var k=this,a,d,b=f.split(":"),h=b[0],j=b[1];if(j!==undefined){try{var g=j.split("-");a=parseInt(g[0].replace(/,/g,""),10);d=parseInt(g[1].replace(/,/g,""),10)}catch(c){return false}}k.change_chrom(h,a,d)},move_fraction:function(c){var a=this;var b=a.high-a.low;this.move_delta(c*b)},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);sortable(a.container_div,".draghandle");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())||0;var e=((this.high-this.low)/(this.max_high-this.max_low)*this.overview_viewport.width())||0;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_location(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(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()},resize_window:function(){this.viewport_container.height(this.container.height()-this.top_container.height()-this.bottom_container.height());this.nav_container.width(this.container.width());this.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 Tool=function(a,b){this.name=a;this.params=b};$.extend(Tool.prototype,{get_param_values_dict:function(){var b={};for(var a=0;a<this.params.length;a++){var c=this.params[a];b[c.name]=c.value}return b},get_param_values:function(){var b=[];for(var a=0;a<this.params.length;a++){b[a]=this.params[a].value}return b}});var NumberToolParameter=function(c,b,e,a,d){this.name=c;this.label=b;this.min=e;this.max=a;this.value=d};var get_tool_from_dict=function(f){if(obj_length(f)===0){return undefined}var b=f.name;var l=f.params;var c=Array();for(var e=0;e<l.length;e++){var g=l[e];var a=g.name,k=g.label,h=g.type,d=g.min,j=g.max,m=g.value;c[c.length]=new NumberToolParameter(a,k,d,j,m)}return new Tool(b,c)};var Filter=function(b,a,c){this.name=b;this.index=a;this.value=c};var NumberFilter=function(b,a){this.name=b;this.index=a;this.low=-Number.MAX_VALUE;this.high=Number.MAX_VALUE;this.slider_min=Number.MAX_VALUE;this.slider_max=-Number.MAX_VALUE;this.slider=null;this.slider_label=null};$.extend(NumberFilter.prototype,{applies_to:function(a){if(a.length>this.index){return true}return false},keep:function(a){if(!this.applies_to(a)){return true}return(a[this.index]>=this.low&&a[this.index]<=this.high)},update_attrs:function(b){var a=false;if(!this.applies_to(b)){return a}if(b[this.index]<this.slider_min){this.slider_min=b[this.index];a=true}if(b[this.index]>this.slider_max){this.slider_max=b[this.index];a=false}return a},update_ui_elt:function(){var b=this.slider.slider("option","min"),a=this.slider.slider("option","max");if(this.slider_min<b||this.slider_max>a){this.slider.slider("option","min",this.slider_min);this.slider.slider("option","max",this.slider_max);this.slider.slider("option","values",[this.slider_min,this.slider_max])}}});var get_filters_from_dict=function(a){var g=[];for(var d=0;d<a.length;d++){var f=a[d];var c=f.name,e=f.type,b=f.index;if(e==="int"||e==="float"){g[d]=new NumberFilter(c,b)}else{g[d]=new Filter(c,b,e)}}return g};var TrackConfig=function(a){this.track=a.track;this.params=a.params;this.values={};if(a.saved_values){this.restore_values(a.saved_values)}this.onchange=a.onchange};$.extend(TrackConfig.prototype,{restore_values:function(a){var b=this;$.each(this.params,function(c,d){if(a[d.key]!==undefined){b.values[d.key]=a[d.key]}else{b.values[d.key]=d.default_value}})},build_form:function(){var b=this;var a=$("<div />");$.each(this.params,function(f,d){if(!d.hidden){var c="param_"+f;var l=$("<div class='form-row' />").appendTo(a);l.append($("<label />").attr("for",c).text(d.label+":"));if(d.type==="bool"){l.append($('<input type="checkbox" />').attr("id",c).attr("name",c).attr("checked",b.values[d.key]))}else{if(d.type==="color"){var h=b.values[d.key];var g=$("<input />").attr("id",c).attr("name",c).val(h);var j=$("<div class='tipsy tipsy-north' style='position: absolute;' />").hide();var e=$("<div style='background-color: black; padding: 10px;'></div>").appendTo(j);var k=$("<div/>").appendTo(e).farbtastic({width:100,height:100,callback:g,color:h});$("<div />").append(g).append(j).appendTo(l).bind("click",function(m){j.css({left:$(this).position().left+($(g).width()/2)-60,top:$(this).position().top+$(this.height)}).show();$(document).bind("click.color-picker",function(){j.hide();$(document).unbind("click.color-picker")});m.stopPropagation()})}else{l.append($("<input />").attr("id",c).attr("name",c).val(b.values[d.key]))}}}});return a},update_from_form:function(a){var c=this;var b=false;$.each(this.params,function(d,f){if(!f.hidden){var g="param_"+d;var e=a.find("#"+g).val();if(f.type==="float"){e=parseFloat(e)}else{if(f.type==="int"){e=parseInt(e)}else{if(f.type==="bool"){e=a.find("#"+g).is(":checked")}}}if(e!==c.values[f.key]){c.values[f.key]=e;b=true}}});if(b){this.onchange()}}});var Track=function(b,a,e,c,d){this.name=b;this.view=a;this.parent_element=e;this.data_url=(c?c:default_data_url);this.data_url_extra_params={};this.data_query_wait=(d?d:DEFAULT_DATA_QUERY_WAIT);this.dataset_check_url=converted_datasets_state_url;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.name_div.attr("id",this.name.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9\-]/g,"").toLowerCase())}this.content_div=$("<div class='track-content'>").appendTo(this.container_div);this.parent_element.append(this.container_div)};$.extend(Track.prototype,{init:function(){var a=this;a.enabled=false;a.tile_cache.clear();a.data_cache.clear();a.initial_canvas=undefined;a.content_div.css("height","auto");a.container_div.removeClass("nodata error pending");if(!a.dataset_id){return}$.getJSON(converted_datasets_state_url,{hda_ldda:a.hda_ldda,dataset_id:a.dataset_id,chrom:a.view.chrom},function(b){if(!b||b==="error"||b.kind==="error"){a.container_div.addClass("error");a.content_div.text(DATA_ERROR);if(b.message){var d=a.view.tracks.indexOf(a);var c=$(" <a href='javascript:void(0);'></a>").text("View error").bind("click",function(){show_modal("Trackster Error","<pre>"+b.message+"</pre>",{Close:hide_modal})});a.content_div.append(c)}}else{if(b==="no converter"){a.container_div.addClass("error");a.content_div.text(DATA_NOCONVERTER)}else{if(b==="no data"||(b.data!==undefined&&(b.data===null||b.data.length===0))){a.container_div.addClass("nodata");a.content_div.text(DATA_NONE)}else{if(b==="pending"){a.container_div.addClass("pending");a.content_div.text(DATA_PENDING);setTimeout(function(){a.init()},a.data_query_wait)}else{if(b.status==="data"){if(b.valid_chroms){a.valid_chroms=b.valid_chroms;a.make_name_popup_menu()}a.content_div.text(DATA_OK);if(a.view.chrom){a.content_div.text("");a.content_div.css("height",a.height_px+"px");a.enabled=true;$.when(a.predraw_init()).done(function(){a.draw()})}}}}}}})},predraw_init:function(){},update_name:function(a){this.old_name=this.name;this.name=a;this.name_div.text(this.name)},revert_name:function(){this.name=this.old_name;this.name_div.text(this.name)}});var TiledTrack=function(b,j,n){var c=this,o=c.view;this.filters=(b!==undefined?get_filters_from_dict(b):[]);this.filters_available=false;this.filters_visible=false;this.tool=(j!==undefined?get_tool_from_dict(j):undefined);this.parent_track=n;this.child_tracks=[];if(c.hidden){return}if(this.parent_track){this.header_div.find(".draghandle").removeClass("draghandle").addClass("child-track-icon").addClass("icon-button");this.parent_element.addClass("child-track");this.tool=undefined}this.filters_div=$("<div/>").addClass("filters").hide();this.header_div.after(this.filters_div);this.filters_div.bind("drag",function(q){q.stopPropagation()}).bind("dblclick",function(q){q.stopPropagation()});$.each(this.filters,function(t,w){var u=$("<div/>").addClass("slider-row").appendTo(c.filters_div);var v=$("<div/>").addClass("slider-label").appendTo(u);var s=$("<span/>").addClass("name").appendTo(v);s.text(w.name+" ");var r=$("<span/>").addClass("values").appendTo(v);var q=$("<div/>").addClass("slider").appendTo(u);w.control_element=$("<div/>").attr("id",w.name+"-filter-control").appendTo(q);w.control_element.slider({range:true,min:Number.MAX_VALUE,max:-Number.MIN_VALUE,values:[0,0],slide:function(y,z){var x=z.values;r.text("["+x[0]+"-"+x[1]+"]");w.low=x[0];w.high=x[1];c.draw(true,true)},change:function(x,y){w.control_element.slider("option","slide").call(w.control_element,x,y)}});w.slider=w.control_element;w.slider_label=r;$("<div style='clear: both;'/>").appendTo(u)});if(this.tool){this.dynamic_tool_div=$("<div/>").addClass("dynamic-tool").hide();this.header_div.after(this.dynamic_tool_div);this.dynamic_tool_div.bind("drag",function(q){q.stopPropagation()}).bind("click",function(q){q.stopPropagation()}).bind("dblclick",function(q){q.stopPropagation()});var m=$("<div class='tool-name'>").appendTo(this.dynamic_tool_div).text(this.tool.name);var l=this.tool.params;var c=this;$.each(this.tool.params,function(x,s){var v=$("<div>").addClass("slider-row").appendTo(c.dynamic_tool_div);var u=$("<div>").addClass("slider-label").appendTo(v);var z=$("<span class='param-name'>").text(s.label+" ").appendTo(u);var t=$("<span/>").text(s.value);var w=$("<span class='param-value'>").appendTo(u).append("[").append(t).append("]");var y=$("<div/>").addClass("slider").appendTo(v);var q=$("<div id='"+s.name+"-param-control'>").appendTo(y);var r=(s.max<=1?0.01:(s.max<=1000?1:5));q.slider({min:s.min,max:s.max,step:r,value:s.value,slide:function(A,C){var B=C.value;s.value=B;if(0<B&&B<1){B=parseFloat(B).toFixed(2)}t.text(B)},change:function(A,B){s.value=B.value}});w.click(function(){var C=t,B=C.text(),A=(s.max<=1?4:s.max.length);C.text("");$("<input type='text'/>").attr("size",A).attr("maxlength",A).attr("value",B).appendTo(C).focus().select().click(function(D){D.stopPropagation()}).blur(function(){$(this).remove();C.text(B)}).keyup(function(F){if(F.keyCode===27){$(this).trigger("blur")}else{if(F.keyCode===13){var D=$(this),E=parseFloat(D.val());if(isNaN(E)||E>s.max||E<s.min){alert("Parameter value must be in the range ["+s.min+"-"+s.max+"]");return $(this)}C.text(E);q.slider("value",E);s.value=E}}})});$("<div style='clear: both;'/>").appendTo(v)});var p=$("<div>").addClass("slider-row").appendTo(this.dynamic_tool_div);var k=$("<input type='submit'>").attr("value","Run").appendTo(p);var c=this;k.click(function(){c.run_tool()})}c.child_tracks_container=$("<div/>").addClass("child-tracks-container").hide();c.container_div.append(c.child_tracks_container);if(c.display_modes!==undefined){if(c.mode_div===undefined){c.mode_div=$("<div class='right-float menubutton popup' />").appendTo(c.header_div);var e=(c.track_config&&c.track_config.values.mode?c.track_config.values.mode:c.display_modes[0]);c.mode=e;c.mode_div.text(e);var d=function(q){c.mode_div.text(q);c.mode=q;c.track_config.values.mode=q;c.tile_cache.clear();c.draw()};var a={};for(var f=0,h=c.display_modes.length;f<h;f++){var g=c.display_modes[f];a[g]=function(q){return function(){d(q)}}(g)}make_popupmenu(c.mode_div,a)}else{c.mode_div.hide()}}this.make_name_popup_menu()};$.extend(TiledTrack.prototype,Track.prototype,{make_name_popup_menu:function(){var b=this;var a={};a["Edit configuration"]=function(){var h=function(){hide_modal();$(window).unbind("keypress.check_enter_esc")},f=function(){b.track_config.update_from_form($(".dialog-box"));hide_modal();$(window).unbind("keypress.check_enter_esc")},g=function(j){if((j.keyCode||j.which)===27){h()}else{if((j.keyCode||j.which)===13){f()}}};$(window).bind("keypress.check_enter_esc",g);show_modal("Configure Track",b.track_config.build_form(),{Cancel:h,OK:f})};if(b.filters_available>0){var e=(b.filters_div.is(":visible")?"Hide filters":"Show filters");a[e]=function(){b.filters_visible=(b.filters_div.is(":visible"));b.filters_div.toggle();b.make_name_popup_menu()}}if(b.tool){var e=(b.dynamic_tool_div.is(":visible")?"Hide Tool":"Show Tool");a[e]=function(){if(!b.dynamic_tool_div.is(":visible")){b.update_name(b.name+b.tool_region_and_parameters_str())}else{menu_option_text="Show dynamic tool";b.revert_name()}b.dynamic_tool_div.toggle();b.make_name_popup_menu()}}if(b.track_type=="ReadTrack"){var e=(b.show_insertions?"Hide Insertions":"Show Insertions");a[e]=function(){b.show_insertions=!b.show_insertions;b.draw(true);b.make_name_popup_menu()}}if(b.valid_chroms){a["List chrom/contigs with data"]=function(){show_modal("Chrom/contigs with data","<p>"+b.valid_chroms.join("<br/>")+"</p>",{Close:function(){hide_modal()}})}}var c=view;var d=function(){$("#no-tracks").show()};if(this.parent_track){c=this.parent_track;d=function(){}}a.Remove=function(){c.remove_track(b);if(c.num_tracks===0){d()}};make_popupmenu(b.name_div,a)},draw:function(a,d){console.log(this.name,a,d);var s=this.view.low,g=this.view.high,j=g-s,l=this.view.container.width(),m=this.view.resolution;var e=$("<div style='position: relative;'></div>"),f=l/j;if(!d){this.content_div.children().remove()}this.content_div.append(e);this.max_height=0;var o=Math.floor(s/m/DENSITY);var c={};while((o*DENSITY*m)<g){var r=l+"_"+f+"_"+o;var h=this.tile_cache.get(r);var p=o*DENSITY*this.view.resolution;var b=p+DENSITY*this.view.resolution;if(!a&&h){this.show_tile(h,e,p,f)}else{this.delayed_draw(a,r,p,b,o,m,e,f,c)}o+=1}if(d){var k=this;var q=setInterval(function(){if(obj_length(c)===0){var v=k.content_div.children();var u=false;for(var w=v.length-1,t=0;w>=t;w--){var x=$(v[w]);if(u){x.remove()}else{if(x.children().length!==0){u=true}}}clearInterval(q)}},50)}for(var n=0;n<this.child_tracks.length;n++){this.child_tracks[n].draw(a,d)}},delayed_draw:function(b,j,g,l,c,e,k,m,f){var d=this;var h=function(u,n,p,o,s,t,q){returned_tile=d.draw_tile(n,p,o,s,t,q);var r=$("<div class='track-tile'>").prepend(returned_tile);tile_element=r;d.tile_cache.set(j,tile_element);d.show_tile(tile_element,s,g,t);delete f[u]};var a=setTimeout(function(){if(g<=d.view.high&&l>=d.view.low){var n=(b?undefined:d.tile_cache.get(j));if(n){d.show_tile(n,k,g,m);delete f[a]}else{$.when(d.data_cache.get_data(view.chrom,g,l,d.mode,e,d.data_url_extra_params)).then(function(){result=d.data_cache.get_data(view.chrom,g,l,d.mode,e,d.data_url_extra_params);if(view.reference_track&&m>CHAR_WIDTH_PX){$.when(view.reference_track.data_cache.get_data(view.chrom,g,l,d.mode,e,view.reference_track.data_url_extra_params)).then(function(){seq_data=view.reference_track.data_cache.get_data(view.chrom,g,l,d.mode,e,view.reference_track.data_url_extra_params);h(a,result,e,c,k,m,seq_data)})}else{h(a,result,e,c,k,m)}})}}},50);f[a]=true},show_tile:function(h,j,e,k){var a=this;var c=this.view.high-this.view.low,b=(e-this.view.low)*k;if(this.left_offset){b-=this.left_offset}h.css({position:"absolute",top:0,left:b,height:""});j.append(h);a.max_height=Math.max(a.max_height,h.height());a.content_div.css("height",a.max_height+"px");j.children().css("height",a.max_height+"px");if(a.hidden){return}for(var g=0;g<a.filters.length;g++){a.filters[g].update_ui_elt()}var d=false;if(a.example_feature){for(var g=0;g<a.filters.length;g++){if(a.filters[g].applies_to(a.example_feature)){d=true;break}}}if(a.filters_available!==d){a.filters_available=d;if(!a.filters_available){a.filters_div.hide()}a.make_name_popup_menu()}},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")},run_tool:function(){var b={dataset_id:this.original_dataset_id,chrom:this.view.chrom,low:this.view.low,high:this.view.high,tool_id:this.tool.name};$.extend(b,this.tool.get_param_values_dict());var d=this,c=b.tool_id+d.tool_region_and_parameters_str(b.chrom,b.low,b.high),e;if(d.track_type==="FeatureTrack"){e=new ToolDataFeatureTrack(c,view,d.hda_ldda,undefined,{},{},d)}this.add_track(e);e.content_div.text("Starting job.");view.has_changes=true;var a=function(){$.getJSON(run_tool_url,b,function(f){if(f==="no converter"){e.container_div.addClass("error");e.content_div.text(DATA_NOCONVERTER)}else{if(f.error){e.container_div.addClass("error");e.content_div.text(DATA_CANNOT_RUN_TOOL+f.message)}else{if(f==="pending"){e.container_div.addClass("pending");e.content_div.text("Converting input data so that it can be easily reused.");setTimeout(a,2000)}else{e.dataset_id=f.dataset_id;e.content_div.text("Running job.");e.init()}}}})};a()},tool_region_and_parameters_str:function(c,a,d){var b=this,e=(c!==undefined&&a!==undefined&&d!==undefined?c+":"+a+"-"+d:"all");return" - region=["+e+"], parameters=["+b.tool.get_param_values().join(", ")+"]"},add_track:function(a){a.track_id=this.track_id+"_"+this.child_tracks.length;a.container_div.attr("id","track_"+a.track_id);this.child_tracks_container.append(a.container_div);sortable(a.container_div,".child-track-icon");if(!$(this.child_tracks_container).is(":visible")){this.child_tracks_container.show()}this.child_tracks.push(a)},remove_track:function(a){a.container_div.fadeOut("slow",function(){$(this).remove()})}});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.view.container.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);a.reference_track=this;this.left_offset=200;this.height_px=12;this.font=DEFAULT_FONT;this.container_div.addClass("reference-track");this.content_div.css("background","none");this.content_div.css("min-height","0px");this.content_div.css("border","none");this.data_url=reference_url;this.data_url_extra_params={dbkey:a.dbkey};this.data_cache=new DataManager(CACHED_DATA,this);this.tile_cache=new Cache(CACHED_TILES_LINE)};$.extend(ReferenceTrack.prototype,TiledTrack.prototype,{draw_tile:function(m,g,b,j,n){var f=this,d=DENSITY*g;if(n>CHAR_WIDTH_PX){if(m===null){f.content_div.css("height","0px");return}var e=document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(e)}e=$(e);var l=e.get(0).getContext("2d");e.get(0).width=Math.ceil(d*n+f.left_offset);e.get(0).height=f.height_px;l.font=DEFAULT_FONT;l.textAlign="center";for(var h=0,k=m.length;h<k;h++){var a=Math.round(h*n);l.fillText(m[h],a+f.left_offset,10)}return e}this.content_div.css("height","0px")}});var LineTrack=function(e,c,f,a,d){var b=this;this.track_type="LineTrack";this.display_modes=["Histogram","Line","Filled","Intensity"];this.mode="Histogram";Track.call(this,e,c,c.viewport_container);TiledTrack.call(this);this.min_height_px=16;this.max_height_px=400;this.height_px=80;this.hda_ldda=f;this.dataset_id=a;this.original_dataset_id=a;this.data_cache=new DataManager(CACHED_DATA,this);this.tile_cache=new Cache(CACHED_TILES_LINE);this.track_config=new TrackConfig({track:this,params:[{key:"color",label:"Color",type:"color",default_value:"black"},{key:"min_value",label:"Min Value",type:"float",default_value:undefined},{key:"max_value",label:"Max Value",type:"float",default_value:undefined},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"height",type:"int",default_value:this.height_px,hidden:true}],saved_values:d,onchange:function(){b.vertical_range=b.prefs.max_value-b.prefs.min_value;$("#linetrack_"+b.track_id+"_minval").text(b.prefs.min_value);$("#linetrack_"+b.track_id+"_maxval").text(b.prefs.max_value);b.tile_cache.clear();b.draw()}});this.prefs=this.track_config.values;this.height_px=this.track_config.values.height;this.vertical_range=this.track_config.values.max_value-this.track_config.values.min_value;(function(g){var k=false;var j=false;var h=$("<div class='track-resize'>");$(g.container_div).hover(function(){k=true;h.show()},function(){k=false;if(!j){h.hide()}});h.hide().bind("dragstart",function(l,m){j=true;m.original_height=$(g.content_div).height()}).bind("drag",function(m,n){var l=Math.min(Math.max(n.original_height+n.deltaY,g.min_height_px),g.max_height_px);$(g.content_div).css("height",l);g.height_px=l;g.draw(true)}).bind("dragend",function(l,m){g.tile_cache.clear();j=false;if(!k){h.hide()}g.track_config.values.height=g.height_px}).appendTo(g.container_div)})(this)};$.extend(LineTrack.prototype,TiledTrack.prototype,{predraw_init:function(){var a=this,b=a.view.tracks.indexOf(a);a.vertical_range=undefined;return $.getJSON(a.data_url,{stats:true,chrom:a.view.chrom,low:null,high:null,hda_ldda:a.hda_ldda,dataset_id:a.dataset_id},function(c){a.container_div.addClass("line-track");var e=c.data;if(isNaN(parseFloat(a.prefs.min_value))||isNaN(parseFloat(a.prefs.max_value))){a.prefs.min_value=e.min;a.prefs.max_value=e.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=e.total_frequency;a.container_div.find(".yaxislabel").remove();var f=$("<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.css({position:"absolute",top:"24px",left:"10px"});d.prependTo(a.container_div);f.css({position:"absolute",bottom:"2px",left:"10px"});f.prependTo(a.container_div)})},draw_tile:function(j,q,t,c,e){if(this.vertical_range===undefined){return}var o=this,u=t*DENSITY*q,a=DENSITY*q,B=q+"_"+t,v={hda_ldda:this.hda_ldda,dataset_id:this.dataset_id,resolution:this.view.resolution};var b=document.createElement("canvas"),z=j.data;if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(b)}b=$(b);b.get(0).width=Math.ceil(a*e);b.get(0).height=o.height_px;var p=b.get(0).getContext("2d"),k=false,l=o.prefs.min_value,g=o.prefs.max_value,n=o.vertical_range,w=o.total_frequency,d=o.height_px,m=o.mode;var A=Math.round(d+l/n*d);p.beginPath();p.moveTo(0,A);p.lineTo(a*e,A);p.fillStyle="#aaa";p.stroke();p.beginPath();p.fillStyle=o.prefs.color;var x,h,f;if(z.length>1){f=Math.ceil((z[1][0]-z[0][0])*e)}else{f=10}for(var r=0,s=z.length;r<s;r++){x=Math.round((z[r][0]-u)*e);h=z[r][1];if(h===null){if(k&&m==="Filled"){p.lineTo(x,d)}k=false;continue}if(h<l){h=l}else{if(h>g){h=g}}if(m==="Histogram"){h=Math.round(h/n*d);p.fillRect(x,A,f,-h)}else{if(m==="Intensity"){h=255-Math.floor((h-l)/n*255);p.fillStyle="rgb("+h+","+h+","+h+")";p.fillRect(x,0,f,d)}else{h=Math.round(d-(h-l)/n*d);if(k){p.lineTo(x,h)}else{k=true;if(m==="Filled"){p.moveTo(x,d);p.lineTo(x,h)}else{p.moveTo(x,h)}}}}}if(m==="Filled"){if(k){p.lineTo(x,A);p.lineTo(0,A)}p.fill()}else{p.stroke()}return b}});var FeatureTrack=function(a,f,e,j,h,c,d,g){var b=this;this.track_type="FeatureTrack";this.display_modes=["Auto","Dense","Squish","Pack"];this.track_config=new TrackConfig({track:this,params:[{key:"block_color",label:"Block color",type:"color",default_value:"#444"},{key:"label_color",label:"Label color",type:"color",default_value:"black"},{key:"show_counts",label:"Show summary counts",type:"bool",default_value:true},{key:"mode",type:"string",default_value:this.mode,hidden:true},],saved_values:h,onchange:function(){b.tile_cache.clear();b.draw()}});this.prefs=this.track_config.values;Track.call(this,a,f,f.viewport_container);TiledTrack.call(this,c,d,g);this.height_px=0;this.container_div.addClass("feature-track");this.hda_ldda=e;this.dataset_id=j;this.original_dataset_id=j;this.zo_slots={};this.show_labels_scale=0.001;this.showing_details=false;this.summary_draw_height=30;this.default_font=DEFAULT_FONT;this.inc_slots={};this.start_end_dct={};this.tile_cache=new Cache(CACHED_TILES_FEATURE);this.data_cache=new DataManager(20,this);this.left_offset=200};$.extend(FeatureTrack.prototype,TiledTrack.prototype,{incremental_slots:function(a,h,p){var q=this.inc_slots[a];if(!q||(q.mode!==p)){q={};q.w_scale=a;q.mode=p;this.inc_slots[a]=q;this.start_end_dct[a]={}}var l=q.w_scale,w=[],x=[],j=0,n=this.view.max_low;for(var u=0,v=h.length;u<v;u++){var g=h[u],k=g[0];if(q[k]!==undefined){j=Math.max(j,q[k]);x.push(q[k])}else{w.push(u)}}var d=this.start_end_dct[a];var m=function(D,E){for(var C=0;C<=MAX_FEATURE_DEPTH;C++){var A=false,F=d[C];if(F!==undefined){for(var z=0,B=F.length;z<B;z++){var y=F[z];if(E>y[0]&&D<y[1]){A=true;break}}}if(!A){return C}}return -1};for(var u=0,v=w.length;u<v;u++){var g=h[w[u]],k=g[0],s=g[1],b=g[2],o=g[3],c=Math.floor((s-n)*l),f=Math.ceil((b-n)*l),t=CONTEXT.measureText(o).width,e;if(o!==undefined&&p==="Pack"){t+=(LABEL_SPACING+PACK_SPACING);if(c-t>=0){c-=t;e="left"}else{f+=t;e="right"}}var r=m(c,f);if(r>=0){if(d[r]===undefined){d[r]=[]}d[r].push([c,f]);q[k]=r;j=Math.max(j,r)}else{}}return j+1},draw_summary_tree:function(b,o,n,l,r,j,f,e){var c=j+LABEL_SPACING+CHAR_HEIGHT_PX;delta_x_px=Math.ceil(n*r);var h=$("<div />").addClass("yaxislabel");h.text(l);h.css({position:"absolute",top:"22px",left:"10px"});h.prependTo(this.container_div);var q=b.get(0).getContext("2d");for(var d=0,g=o.length;d<g;d++){var m=Math.floor((o[d][0]-f)*r);var k=o[d][1];if(!k){continue}var p=k/l*j;q.fillStyle="black";q.fillRect(m+e,c-p,delta_x_px,p);var a=4;if(this.prefs.show_counts&&(q.measureText(k).width+a)<delta_x_px){q.fillStyle="#666";q.textAlign="center";q.fillText(k,m+e+(delta_x_px/2),10)}}},draw_element:function(p,f,g,x,j,r,I,M,N,a,A){var u=x[0],K=x[1],C=x[2]-1,s=x[3],D=Math.floor(Math.max(0,(K-r)*M)),q=Math.ceil(Math.min(a,Math.max(0,(C-r)*M))),B=ERROR_PADDING+(g==="Dense"?0:(0+j))*N,o,G,t=null,O=null,d=this.prefs.block_color,F=this.prefs.label_color;if(g==="Dense"){p.fillStyle=d;p.fillRect(D+A,B,q-D,DENSE_FEATURE_HEIGHT)}else{if(g==="no_detail"){p.fillStyle=d;p.fillRect(D+A,B+5,q-D,DENSE_FEATURE_HEIGHT)}else{var n=x[5],z=x[6],E=x[7],e=x[8];if(z&&E){t=Math.floor(Math.max(0,(z-r)*M));O=Math.ceil(Math.min(a,Math.max(0,(E-r)*M)))}var L,v;if(g==="Squish"){L=1;v=SQUISH_FEATURE_HEIGHT}else{L=5;v=PACK_FEATURE_HEIGHT}if(!e){if(x.strand){if(x.strand==="+"){p.fillStyle=RIGHT_STRAND_INV}else{if(x.strand==="-"){p.fillStyle=LEFT_STRAND_INV}}}else{p.fillStyle=d}p.fillRect(D+A,B,q-D,v)}else{var m,w;if(g==="Squish"){p.fillStyle=CONNECTOR_COLOR;m=B+Math.floor(SQUISH_FEATURE_HEIGHT/2)+1;w=1}else{if(n){var m=B;var w=v;if(n==="+"){p.fillStyle=RIGHT_STRAND}else{if(n==="-"){p.fillStyle=LEFT_STRAND}}}else{p.fillStyle=CONNECTOR_COLOR;m+=(SQUISH_FEATURE_HEIGHT/2)+1;w=1}}p.fillRect(D+A,m,q-D,w);for(var J=0,c=e.length;J<c;J++){var h=e[J],b=Math.floor(Math.max(0,(h[0]-r)*M)),y=Math.ceil(Math.min(a,Math.max((h[1]-1-r)*M)));if(b>y){continue}p.fillStyle=d;p.fillRect(b+A,B+(v-L)/2+1,y-b,L);if(t!==undefined&&!(b>O||y<t)){var H=Math.max(b,t),l=Math.min(y,O);p.fillRect(H+A,B+1,l-H,v)}}}if(g==="Pack"&&K>r){p.fillStyle=F;if(f===0&&D-p.measureText(s).width<0){p.textAlign="left";p.fillText(s,q+A+LABEL_SPACING,B+8)}else{p.textAlign="right";p.fillText(s,D+A-LABEL_SPACING,B+8)}p.fillStyle=d}}}},get_y_scale:function(b){var a;if(b==="summary_tree"){}if(b==="Dense"){a=DENSE_TRACK_HEIGHT}else{if(b==="no_detail"){a=NO_DETAIL_TRACK_HEIGHT}else{if(b==="Squish"){a=SQUISH_TRACK_HEIGHT}else{a=PACK_TRACK_HEIGHT}}}return a},draw_tile:function(o,x,C,k,m,d){var t=this;var E=C*DENSITY*x,a=(C+1)*DENSITY*x,q=a-E,F={hda_ldda:t.hda_ldda,dataset_id:t.dataset_id,resolution:this.view.resolution,mode:this.mode};var v=Math.ceil(q*m),s=this.mode,H=25,g=this.left_offset,p,h;var c=document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(c)}c=$(c);if(s==="Auto"){if(o.dataset_type==="summary_tree"){s=o.dataset_type}else{if(o.extra_info==="no_detail"){s="no_detail"}else{var G=o.data;if((G.length&&G.length<4)||(this.view.high-this.view.low>MIN_SQUISH_VIEW_WIDTH)){s="Squish"}else{s="Pack"}}}}var y=this.get_y_scale(s);if(s==="summary_tree"){h=this.summary_draw_height}if(s==="Dense"){h=H}else{if(s==="no_detail"||s==="Squish"||s==="Pack"){h=this.incremental_slots(m,o.data,s)*y+H;p=this.inc_slots[m]}}c.get(0).width=v+g;c.get(0).height=h;if(o.dataset_type==="summary_tree"){c.get(0).height+=LABEL_SPACING+CHAR_HEIGHT_PX}k.parent().css("height",Math.max(this.height_px,h)+"px");var w=c.get(0).getContext("2d");w.fillStyle=this.prefs.block_color;w.font=this.default_font;w.textAlign="right";this.container_div.find(".yaxislabel").remove();if(s==="summary_tree"){this.draw_summary_tree(c,o.data,o.delta,o.max,m,h,E,g);return c}if(o.message){c.css({"border-top":"1px solid red"});w.fillStyle="red";w.textAlign="left";var r=w.textBaseline;w.textBaseline="top";w.fillText(o.message,g,0);w.textBaseline=r;if(!o.data){return c}}this.example_feature=(o.data.length?o.data[0]:undefined);var G=o.data;for(var z=0,B=G.length;z<B;z++){var j=G[z],l=j[0],u=j[1],b=j[2],e=(p&&p[l]!==undefined?p[l]:null);var A=false;var n;for(var D=0;D<this.filters.length;D++){n=this.filters[D];n.update_attrs(j);if(!n.keep(j)){A=true;break}}if(A){continue}if(is_overlap([u,b],[E,a])&&(s=="Dense"||e!==null)){this.draw_element(w,C,s,j,e,E,a,m,y,v,g,d)}}return c}});var VcfTrack=function(d,b,f,a,c,e){FeatureTrack.call(this,d,b,f,a,c,e);this.track_type="VcfTrack"};$.extend(VcfTrack.prototype,TiledTrack.prototype,FeatureTrack.prototype,{draw_element:function(u,p,j,e,x,c,m,v,s){var j=data[i],l=j[0],t=j[1],d=j[2]-1,o=j[3],g=Math.floor(Math.max(0,(t-x)*m)),k=Math.ceil(Math.min(s,Math.max(0,(d-x)*m))),f=ERROR_PADDING+(p==="Dense"?0:(0+e))*v,a,y,b=null,n=null;if(no_label){u.fillStyle=block_color;u.fillRect(g+left_offset,f+5,k-g,1)}else{var w=j[4],r=j[5],h=j[6];a=9;y=1;u.fillRect(g+left_offset,f,k-g,a);if(p!=="Dense"&&o!==undefined&&t>x){u.fillStyle=label_color;if(tile_index===0&&g-u.measureText(o).width<0){u.textAlign="left";u.fillText(o,k+2+left_offset,f+8)}else{u.textAlign="right";u.fillText(o,g-2+left_offset,f+8)}u.fillStyle=block_color}var q=w+" / "+r;if(t>x&&u.measureText(q).width<(k-g)){u.fillStyle="white";u.textAlign="center";u.fillText(q,left_offset+g+(k-g)/2,f+8);u.fillStyle=block_color}}}});var ReadTrack=function(d,b,f,a,c,e){FeatureTrack.call(this,d,b,f,a,c,e);this.track_type="ReadTrack";this.difference_mode=true;this.show_insertions=false;this.make_name_popup_menu()};$.extend(ReadTrack.prototype,TiledTrack.prototype,FeatureTrack.prototype,{get_y_scale:function(b){var a;if(b==="summary_tree"){}if(b==="Dense"){a=DENSE_TRACK_HEIGHT}else{if(b==="Squish"){a=SQUISH_TRACK_HEIGHT}else{a=PACK_TRACK_HEIGHT;if(this.show_insertions){a*=2}}}return a},draw_read:function(m,d,J,n,D,G,e,o,y,a){m.textAlign="center";var l=this,u=[n,D],C=0,z=0,f=0;var r=[];if((d==="Pack"||this.mode==="Auto")&&o!==undefined&&J>CHAR_WIDTH_PX){f=Math.ceil(CHAR_WIDTH_PX/2+1)}if(!e){e=[[0,o.length]]}for(var h=0,k=e.length;h<k;h++){var b=e[h],g="MIDNSHP=X"[b[0]],v=b[1];if(g==="H"||g==="S"){C-=v}var x=G+C,B=Math.floor(Math.max(0,(x-n)*J)),E=Math.floor(Math.max(0,(x+v-n)*J));switch(g){case"H":break;case"S":case"M":case"=":var p=compute_overlap([x,x+v],u);if(p!==NO_OVERLAP){var q=o.slice(z,z+v);if(f>0){m.fillStyle=this.prefs.block_color;m.fillRect(B+this.left_offset-f,y+1,E-B,9);m.fillStyle=CONNECTOR_COLOR;for(var I=0,j=q.length;I<j;I++){if(this.difference_mode&&a){var s=a[x-n+I];if(!s||s.toLowerCase()===q[I].toLowerCase()){continue}}if(x+I>=n&&x+I<=D){var A=Math.floor(Math.max(0,(x+I-n)*J));m.fillText(q[I],A+this.left_offset,y+9)}}}else{m.fillStyle=this.prefs.block_color;m.fillRect(B+this.left_offset,y+(this.mode!=="Dense"?4:5),E-B,(d!=="Dense"?SQUISH_FEATURE_HEIGHT:DENSE_FEATURE_HEIGHT))}}z+=v;C+=v;break;case"N":m.fillStyle=CONNECTOR_COLOR;m.fillRect(B+this.left_offset-f,y+5,E-B,1);C+=v;break;case"D":m.fillStyle="red";m.fillRect(B+this.left_offset-f,y+4,E-B,3);C+=v;break;case"P":break;case"I":var p=compute_overlap([x,x+v],u),K=this.left_offset+B-f;if(p!==NO_OVERLAP){var q=o.slice(z,z+v);if(this.show_insertions){var w=this.left_offset+B-(E-B)/2;if((d==="Pack"||this.mode==="Auto")&&o!==undefined&&J>CHAR_WIDTH_PX){m.fillStyle="yellow";m.fillRect(w-f,y-9,E-B,9);r[r.length]={type:"triangle",data:[K,y+4,5]};m.fillStyle=CONNECTOR_COLOR;switch(p){case (OVERLAP_START):q=q.slice(n-x);break;case (OVERLAP_END):q=q.slice(0,x-D);break;case (CONTAINED_BY):break;case (CONTAINS):q=q.slice(n-x,x-D);break}for(var I=0,j=q.length;I<j;I++){var A=Math.floor(Math.max(0,(x+I-n)*J));m.fillText(q[I],A+this.left_offset-(E-B)/2,y)}}else{m.fillStyle="yellow";m.fillRect(w,y+(this.mode!=="Dense"?2:5),E-B,(d!=="Dense"?SQUISH_FEATURE_HEIGHT:DENSE_FEATURE_HEIGHT))}}else{if((d==="Pack"||this.mode==="Auto")&&o!==undefined&&J>CHAR_WIDTH_PX){r[r.length]={type:"text",data:[q.length,K,y+9]}}else{}}}z+=v;break;case"X":z+=v;break}}m.fillStyle="yellow";var t,L,H;for(var F=0;F<r.length;F++){t=r[F];L=t.type;H=t.data;if(L==="text"){m.font="bold "+DEFAULT_FONT;m.fillText(H[0],H[1],H[2]);m.font=DEFAULT_FONT}else{if(L=="triangle"){m.drawDownwardEquilateralTriangle(H[0],H[1],H[2])}}}},draw_element:function(w,y,r,k,e,A,b,n,x,u,f,c){var m=k[0],v=k[1],d=k[2],o=k[3],h=Math.floor(Math.max(0,(v-A)*n)),j=Math.ceil(Math.min(u,Math.max(0,(d-A)*n))),g=(r==="Dense"?1:(1+e))*x,z=this.prefs.block_color,l=this.prefs.label_color;t=0;w.fillStyle=z;if(k[5] instanceof Array){var s=Math.floor(Math.max(0,(k[4][0]-A)*n)),q=Math.ceil(Math.min(u,Math.max(0,(k[4][1]-A)*n))),p=Math.floor(Math.max(0,(k[5][0]-A)*n)),a=Math.ceil(Math.min(u,Math.max(0,(k[5][1]-A)*n)));if(k[4][1]>=A&&k[4][0]<=b&&k[4][2]){this.draw_read(w,r,n,A,b,k[4][0],k[4][2],k[4][3],g,c)}if(k[5][1]>=A&&k[5][0]<=b&&k[5][2]){this.draw_read(w,r,n,A,b,k[5][0],k[5][2],k[5][3],g,c)}if(p>q){w.fillStyle=CONNECTOR_COLOR;w.dashedLine(q+f,g+5,f+p,g+5)}}else{w.fillStyle=z;this.draw_read(w,r,n,A,b,v,k[4],k[5],g,c)}if(r==="Pack"&&v>A){w.fillStyle=this.prefs.label_color;if((r==="Pack"||this.mode==="Auto")&&n>CHAR_WIDTH_PX){var t=Math.round(n/2)}if(y===0&&h-w.measureText(o).width<0){w.textAlign="left";w.fillText(o,j+f+LABEL_SPACING-t,g+8)}else{w.textAlign="right";w.fillText(o,h+f-LABEL_SPACING-t,g+8)}w.fillStyle=z}}});var ToolDataFeatureTrack=function(e,c,g,a,d,f,b){FeatureTrack.call(this,e,c,g,a,d,f,{},b);this.track_type="ToolDataFeatureTrack";this.data_url=raw_data_url;this.data_query_wait=1000;this.dataset_check_url=dataset_state_url};$.extend(ToolDataFeatureTrack.prototype,TiledTrack.prototype,FeatureTrack.prototype,{predraw_init:function(){var b=this;var a=function(){if(b.data_cache.size()===0){setTimeout(a,300)}else{b.data_url=default_data_url;b.data_query_wait=DEFAULT_DATA_QUERY_WAIT;b.dataset_state_url=converted_datasets_state_url;$.getJSON(b.dataset_state_url,{dataset_id:b.dataset_id,hda_ldda:b.hda_ldda},function(c){})}};a()}});
\ No newline at end of file
--- a/static/scripts/trackster.js Thu Mar 24 15:03:12 2011 -0400
+++ b/static/scripts/trackster.js Thu Mar 24 15:05:28 2011 -0400
@@ -243,13 +243,30 @@
});
/**
- * Data-specific cache.
+ * Data manager for a track.
*/
-var DataCache = function(num_elements) {
- Cache.call(this, num_elements);
+var DataManager = function(num_elements, track) {
+ Cache.call(this, num_elements);
+ this.track = track;
};
-$.extend(DataCache.prototype, Cache.prototype, {
- get_data: function(low, high, mode) {
+$.extend(DataManager.prototype, Cache.prototype, {
+ /**
+ * Load data from server; returns AJAX object so that use of Deferred is possible.
+ */
+ load_data: function(chrom, low, high, mode, resolution, extra_params) {
+ var params = {"chrom": chrom, "low": low, "high": high, "mode": mode,
+ "resolution": resolution, "dataset_id" : this.track.dataset_id,
+ "hda_ldda": this.track.hda_ldda};
+ $.extend(params, extra_params);
+ var manager = this;
+ return $.getJSON(this.track.data_url, params, function (result) {
+ manager.set_data(low, high, mode, result);
+ });
+ },
+ /**
+ * Get data and do callback.
+ */
+ get_data: function(chrom, low, high, mode, resolution, extra_params) {
// Debugging:
//console.log("get_data", low, high, mode);
/*
@@ -259,7 +276,7 @@
}
*/
- // Look for key in cache and, if found, return it.
+ // Look for key in cache and, if found, do callback.
var entry = this.get(this.gen_key(low, high, mode));
if (entry) {
return entry;
@@ -290,18 +307,25 @@
}
}
- return undefined;
+ //
+ // Load data from server.
+ //
+ return this.load_data(chrom, low, high, mode, resolution, extra_params);
},
set_data: function(low, high, mode, result) {
//console.log("set_data", low, high, mode, result);
return this.set(this.gen_key(low, high, mode), result);
},
- // Generate key for cache.
+ /**
+ * Generate key for cache.
+ */
gen_key: function(low, high, mode) {
var key = low + "_" + high + "_" + mode;
return key;
},
- // Split key from cache into array with format [low, high, mode]
+ /**
+ * Split key from cache into array with format [low, high, mode]
+ */
split_key: function(key) {
return key.split("_");
}
@@ -1028,6 +1052,7 @@
this.view = view;
this.parent_element = parent_element;
this.data_url = (data_url ? data_url : default_data_url);
+ this.data_url_extra_params = {}
this.data_query_wait = (data_query_wait ? data_query_wait : DEFAULT_DATA_QUERY_WAIT);
this.dataset_check_url = converted_datasets_state_url;
@@ -1496,45 +1521,12 @@
make_popupmenu(track.name_div, track_dropdown);
},
- tile_data: function(resolution, tile_index, extra_params, callback, key) {
- var track = this,
- low = tile_index * DENSITY * resolution,
- high = ( tile_index + 1 ) * DENSITY * resolution,
- params = { "chrom": this.view.chrom, "low": low, "high": high, "dbkey": this.view.dbkey };
-
- if (key === undefined) {
- key = resolution + "_" + tile_index;
- }
- var cached = track.data_cache.get(key);
- if (cached) {
- return callback(cached);
- }
- $.extend(params, extra_params);
- $.ajax({ 'url': this.data_url, 'dataType': 'json', 'data': params,
- success: function (result) {
- track.data_cache.set(key, result);
- return callback(result);
- }, error: function(r, t, e) {
- console.log(r, t, e);
- }
- });
- },
/**
* Draw track. It is possible to force a redraw rather than use cached tiles and/or clear old
* tiles after drawing new tiles.
- *
- * NOTE/TODO: clear_after only works when no data needs to be loaded. Because tiles fetch their own
- * data and then draw themselves, there's no way to determine when all track tiles have been drawn
- * because a tile may be waiting on data or drawing itself and there is no way to track a tile's status
- * when it requests data and subsequently draws itself. Without the ability to determine when
- * a track has been drawn, clear_after may not clear old tiles because it may be called too soon and
- * miss old tiles that are being/will be drawn over.
- *
- * This problem can be fixed by either (a) fetching the data before drawing tiles so that tile drawing
- * status can be fully monitored; or (b) keeping a global dictionary of tiles being drawn and their
- * status. (a) is probably the better approach.
*/
draw: function(force, clear_after) {
+ console.log(this.name, force, clear_after);
var low = this.view.low,
high = this.view.high,
range = high - low,
@@ -1544,9 +1536,7 @@
var parent_element = $("<div style='position: relative;'></div>"),
w_scale = width / range;
- if (!clear_after) {
- this.content_div.children().remove();
- }
+ if (!clear_after) { this.content_div.children().remove(); }
this.content_div.append( parent_element );
this.max_height = 0;
// Index of first tile that overlaps visible region
@@ -1571,7 +1561,7 @@
}
//
- // Actions to take after new tiles have been loaded/drawn:
+ // Actions to take after tiles have been drawn:
// (1) remove old tile(s);
// (2) update filtering UI elements.
//
@@ -1612,44 +1602,66 @@
delayed_draw: function(force, key, tile_low, tile_high, tile_index, resolution, parent_element, w_scale, draw_tile_dict) {
var track = this;
// Put a 50ms delay on drawing so that if the user scrolls fast, we don't load extra data
- var draw_tile = function(tile_element) {
+ var draw_and_show_tile = function(id, result, resolution, tile_index, parent_element, w_scale, seq_data) {
+ returned_tile = track.draw_tile(result, resolution, tile_index, parent_element, w_scale, seq_data)
+
+ // Wrap element in div for background
+ var wrapper_element = $("<div class='track-tile'>").prepend(returned_tile);
+ tile_element = wrapper_element;
+
track.tile_cache.set(key, tile_element);
track.show_tile(tile_element, parent_element, tile_low, w_scale);
+
+ // TODO: this should go in a post-draw function.
+ // Store initial canvas in case we need to use it for overview
+ /* This is completely broken, just saves the first tile it sees
+ regardless of if it should be the overview
+ if (!track.initial_canvas && !window.G_vmlCanvasManager) {
+ track.initial_canvas = $(tile_element).clone();
+ var src_ctx = tile_element.get(0).getContext("2d");
+ var tgt_ctx = track.initial_canvas.get(0).getContext("2d");
+ var data = src_ctx.getImageData(0, 0, src_ctx.canvas.width, src_ctx.canvas.height);
+ tgt_ctx.putImageData(data, 0, 0);
+ track.set_overview();
+ }
+ */
+
+ delete draw_tile_dict[id];
};
var id = setTimeout(function() {
if (tile_low <= track.view.high && tile_high >= track.view.low) {
// Show/draw tile: check cache for tile; if tile not in cache, draw it.
- var tile_element;
- if (!force) {
- tile_element = track.tile_cache.get(key);
+ var tile_element = (force ? undefined : track.tile_cache.get(key));
+ if (tile_element) {
+ track.show_tile(tile_element, parent_element, tile_low, w_scale);
+ delete draw_tile_dict[id];
}
- if (!tile_element) {
- track.draw_tile(resolution, tile_index, parent_element, w_scale, function(returned_tile) {
- if ( returned_tile ) {
- // Wrap element in div for background
- var wrapper_element = $("<div class='track-tile'>").prepend( returned_tile );
- tile_element = wrapper_element;
+ else {
+ //
+ // Really draw tile: get data, seq data if available, and draw tile.
+ //
+ $.when(track.data_cache.get_data(view.chrom, tile_low, tile_high, track.mode,
+ resolution, track.data_url_extra_params)).then(function() {
+ // Data available for track.
+ result = track.data_cache.get_data(view.chrom, tile_low, tile_high, track.mode,
+ resolution, track.data_url_extra_params);
+ // If sequence data needed, get that and draw. Otherwise draw.
+ if (view.reference_track && w_scale > CHAR_WIDTH_PX) {
+ $.when(view.reference_track.data_cache.get_data(view.chrom, tile_low, tile_high,
+ track.mode, resolution,
+ view.reference_track.data_url_extra_params)).then(function() {
+ seq_data = view.reference_track.data_cache.get_data(view.chrom, tile_low, tile_high,
+ track.mode, resolution,
+ view.reference_track.data_url_extra_params);
+ draw_and_show_tile(id, result, resolution, tile_index, parent_element, w_scale, seq_data);
+ });
}
- draw_tile(tile_element);
- });
- }
- if (tile_element) {
- // Store initial canvas in case we need to use it for overview
- /* This is completely broken, just saves the first tile it sees
- regardless of if it should be the overview
- if (!track.initial_canvas && !window.G_vmlCanvasManager) {
- track.initial_canvas = $(tile_element).clone();
- var src_ctx = tile_element.get(0).getContext("2d");
- var tgt_ctx = track.initial_canvas.get(0).getContext("2d");
- var data = src_ctx.getImageData(0, 0, src_ctx.canvas.width, src_ctx.canvas.height);
- tgt_ctx.putImageData(data, 0, 0);
- track.set_overview();
- }
- */
- draw_tile(tile_element);
+ else {
+ draw_and_show_tile(id, result, resolution, tile_index, parent_element, w_scale);
+ }
+ });
}
}
- delete draw_tile_dict[id];
}, 50);
draw_tile_dict[id] = true;
},
@@ -1846,8 +1858,8 @@
var ReferenceTrack = function (view) {
this.track_type = "ReferenceTrack";
this.hidden = true;
- Track.call( this, null, view, view.top_labeltrack );
- TiledTrack.call( this );
+ Track.call(this, null, view, view.top_labeltrack);
+ TiledTrack.call(this);
view.reference_track = this;
this.left_offset = 200;
@@ -1858,42 +1870,43 @@
this.content_div.css("min-height", "0px");
this.content_div.css("border", "none");
this.data_url = reference_url;
- this.data_cache = new DataCache(CACHED_DATA);
+ this.data_url_extra_params = {dbkey: view.dbkey};
+ this.data_cache = new DataManager(CACHED_DATA, this);
this.tile_cache = new Cache(CACHED_TILES_LINE);
};
-$.extend( ReferenceTrack.prototype, TiledTrack.prototype, {
- draw_tile: function( resolution, tile_index, parent_element, w_scale, callback ) {
+$.extend(ReferenceTrack.prototype, TiledTrack.prototype, {
+ /**
+ * Draw ReferenceTrack tile.
+ */
+ draw_tile: function(seq, resolution, tile_index, parent_element, w_scale) {
var track = this,
tile_length = DENSITY * resolution;
if (w_scale > CHAR_WIDTH_PX) {
- track.tile_data(resolution, tile_index, {}, function(seq) {
- if (seq === null) {
- track.content_div.css("height", "0px");
- return;
- }
- var canvas = document.createElement("canvas");
- if (window.G_vmlCanvasManager) { G_vmlCanvasManager.initElement(canvas); } // EXCANVAS HACK
- canvas = $(canvas);
+ if (seq === null) {
+ track.content_div.css("height", "0px");
+ return;
+ }
+ var canvas = document.createElement("canvas");
+ if (window.G_vmlCanvasManager) { G_vmlCanvasManager.initElement(canvas); } // EXCANVAS HACK
+ canvas = $(canvas);
- var ctx = canvas.get(0).getContext("2d");
- canvas.get(0).width = Math.ceil( tile_length * w_scale + track.left_offset);
- canvas.get(0).height = track.height_px;
- ctx.font = DEFAULT_FONT;
- ctx.textAlign = "center";
- for (var c = 0, str_len = seq.length; c < str_len; c++) {
- var c_start = Math.round(c * w_scale);
- ctx.fillText(seq[c], c_start + track.left_offset, 10);
- }
- // parent_element.append(canvas);
- return callback(canvas);
- });
+ var ctx = canvas.get(0).getContext("2d");
+ canvas.get(0).width = Math.ceil( tile_length * w_scale + track.left_offset);
+ canvas.get(0).height = track.height_px;
+ ctx.font = DEFAULT_FONT;
+ ctx.textAlign = "center";
+ for (var c = 0, str_len = seq.length; c < str_len; c++) {
+ var c_start = Math.round(c * w_scale);
+ ctx.fillText(seq[c], c_start + track.left_offset, 10);
+ }
+ return canvas;
}
this.content_div.css("height", "0px");
}
});
-var LineTrack = function ( name, view, hda_ldda, dataset_id, prefs ) {
+var LineTrack = function (name, view, hda_ldda, dataset_id, prefs) {
var track = this;
this.track_type = "LineTrack";
this.display_modes = ["Histogram", "Line", "Filled", "Intensity"];
@@ -1907,7 +1920,7 @@
this.hda_ldda = hda_ldda;
this.dataset_id = dataset_id;
this.original_dataset_id = dataset_id;
- this.data_cache = new DataCache(CACHED_DATA);
+ this.data_cache = new DataManager(CACHED_DATA, this);
this.tile_cache = new Cache(CACHED_TILES_LINE);
// Define track configuration
@@ -1968,7 +1981,7 @@
}).appendTo( track.container_div );
})(this);
};
-$.extend( LineTrack.prototype, TiledTrack.prototype, {
+$.extend(LineTrack.prototype, TiledTrack.prototype, {
predraw_init: function() {
var track = this,
track_id = track.view.tracks.indexOf(track);
@@ -2001,7 +2014,10 @@
min_label.prependTo(track.container_div);
});
},
- draw_tile: function( resolution, tile_index, parent_element, w_scale, callback ) {
+ /**
+ * Draw LineTrack tile.
+ */
+ draw_tile: function(result, resolution, tile_index, parent_element, w_scale) {
if (this.vertical_range === undefined) {
return;
}
@@ -2012,94 +2028,93 @@
key = resolution + "_" + tile_index,
params = { hda_ldda: this.hda_ldda, dataset_id: this.dataset_id, resolution: this.view.resolution };
- this.tile_data(resolution, tile_index, params, function(result) {
- var canvas = document.createElement("canvas"),
- data = result.data;
- if (window.G_vmlCanvasManager) { G_vmlCanvasManager.initElement(canvas); } // EXCANVAS HACK
- canvas = $(canvas);
- canvas.get(0).width = Math.ceil( tile_length * w_scale );
- canvas.get(0).height = track.height_px;
- var ctx = canvas.get(0).getContext("2d"),
- in_path = false,
- min_value = track.prefs.min_value,
- max_value = track.prefs.max_value,
- vertical_range = track.vertical_range,
- total_frequency = track.total_frequency,
- height_px = track.height_px,
- mode = track.mode;
+ var canvas = document.createElement("canvas"),
+ data = result.data;
+ if (window.G_vmlCanvasManager) { G_vmlCanvasManager.initElement(canvas); } // EXCANVAS HACK
+ canvas = $(canvas);
+
+ canvas.get(0).width = Math.ceil( tile_length * w_scale );
+ canvas.get(0).height = track.height_px;
+ var ctx = canvas.get(0).getContext("2d"),
+ in_path = false,
+ min_value = track.prefs.min_value,
+ max_value = track.prefs.max_value,
+ vertical_range = track.vertical_range,
+ total_frequency = track.total_frequency,
+ height_px = track.height_px,
+ mode = track.mode;
- // Pixel position of 0 on the y axis
- var y_zero = Math.round( height_px + min_value / vertical_range * height_px );
+ // Pixel position of 0 on the y axis
+ var y_zero = Math.round( height_px + min_value / vertical_range * height_px );
- // Line at 0.0
- ctx.beginPath();
- ctx.moveTo( 0, y_zero );
- ctx.lineTo( tile_length * w_scale, y_zero );
- // ctx.lineWidth = 0.5;
- ctx.fillStyle = "#aaa";
- ctx.stroke();
-
- ctx.beginPath();
- ctx.fillStyle = track.prefs.color;
- var x_scaled, y, delta_x_px;
- if (data.length > 1) {
- delta_x_px = Math.ceil((data[1][0] - data[0][0]) * w_scale);
+ // Line at 0.0
+ ctx.beginPath();
+ ctx.moveTo( 0, y_zero );
+ ctx.lineTo( tile_length * w_scale, y_zero );
+ // ctx.lineWidth = 0.5;
+ ctx.fillStyle = "#aaa";
+ ctx.stroke();
+
+ ctx.beginPath();
+ ctx.fillStyle = track.prefs.color;
+ var x_scaled, y, delta_x_px;
+ if (data.length > 1) {
+ delta_x_px = Math.ceil((data[1][0] - data[0][0]) * w_scale);
+ } else {
+ delta_x_px = 10;
+ }
+ 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 === "Histogram") {
+ // y becomes the bar height in pixels, which is the negated for canvas coords
+ y = Math.round( y / vertical_range * height_px );
+ ctx.fillRect(x_scaled, y_zero, delta_x_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, height_px);
} else {
- delta_x_px = 10;
- }
- 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 === "Histogram") {
- // y becomes the bar height in pixels, which is the negated for canvas coords
- y = Math.round( y / vertical_range * height_px );
- ctx.fillRect(x_scaled, y_zero, delta_x_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, height_px);
+ // console.log(y, track.min_value, track.vertical_range, (y - track.min_value) / track.vertical_range * track.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, track.min_value, track.vertical_range, (y - track.min_value) / track.vertical_range * track.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) {
+ 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);
}
}
}
- if (mode === "Filled") {
- if (in_path) {
- ctx.lineTo( x_scaled, y_zero );
- ctx.lineTo( 0, y_zero );
- }
- ctx.fill();
- } else {
- ctx.stroke();
+ }
+ if (mode === "Filled") {
+ if (in_path) {
+ ctx.lineTo( x_scaled, y_zero );
+ ctx.lineTo( 0, y_zero );
}
- callback(canvas);
- });
+ ctx.fill();
+ } else {
+ ctx.stroke();
+ }
+ return canvas;
}
});
@@ -2147,10 +2162,10 @@
this.inc_slots = {};
this.start_end_dct = {};
this.tile_cache = new Cache(CACHED_TILES_FEATURE);
- this.data_cache = new DataCache(20);
+ this.data_cache = new DataManager(20, this);
this.left_offset = 200;
};
-$.extend( FeatureTrack.prototype, TiledTrack.prototype, {
+$.extend(FeatureTrack.prototype, TiledTrack.prototype, {
/**
* Place features in slots for drawing (i.e. pack features).
* this.inc_slots[level] is created in this method. this.inc_slots[level]
@@ -2501,14 +2516,10 @@
/**
* Draw FeatureTrack tile.
*/
- draw_tile: function(resolution, tile_index, parent_element, w_scale, callback, ref_seq, result) {
+ draw_tile: function(result, resolution, tile_index, parent_element, w_scale, ref_seq) {
// Fetch reference sequence data if it exists and we are displaying
var track = this;
- if (track.view.reference_track && w_scale > CHAR_WIDTH_PX && ref_seq === undefined) {
- return track.view.reference_track.tile_data(resolution, tile_index, {}, function(ret_ref_seq) {
- track.draw_tile(resolution, tile_index, parent_element, w_scale, callback, ret_ref_seq);
- });
- }
+
var tile_low = tile_index * DENSITY * resolution,
tile_high = ( tile_index + 1 ) * DENSITY * resolution,
tile_span = tile_high - tile_low,
@@ -2516,21 +2527,6 @@
resolution: this.view.resolution, mode: this.mode };
//
- // Get tile data; if data not available, issue get_data request and rerun with data
- //
- if (result === undefined) {
- var cached = this.data_cache.get_data(tile_low, tile_high, this.mode),
- key = resolution + "_" + tile_index + "_" + this.mode;
- if (cached === undefined) {
- return track.tile_data(resolution, tile_index, params, function(get_data_result) {
- track.data_cache.set_data(tile_low, tile_high, this.mode, get_data_result);
- track.draw_tile(resolution, tile_index, parent_element, w_scale, callback, ref_seq, get_data_result);
- }, key);
- }
- result = cached;
- }
-
- //
// Create/set/compute some useful vars.
//
var width = Math.ceil( tile_span * w_scale ),
@@ -2611,7 +2607,7 @@
if (mode === "summary_tree") {
this.draw_summary_tree(canvas, result.data, result.delta, result.max, w_scale, required_height,
tile_low, left_offset);
- return callback(canvas);
+ return canvas;
}
//
@@ -2631,7 +2627,7 @@
// If there's no data, return.
if (!result.data) {
- return callback(canvas);
+ return canvas;
}
}
@@ -2674,7 +2670,7 @@
width, left_offset, ref_seq);
}
}
- callback(canvas);
+ return canvas;
}
});
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
24 Mar '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/5b0edf34839e/
changeset: r5268:5b0edf34839e
user: richard_burhans
date: 2011-03-24 20:03:12
summary: fixed calculation of codon starts
affected #: 1 file (59 bytes)
--- a/tools/filters/ucsc_gene_bed_to_exon_bed.py Thu Mar 24 14:33:05 2011 -0400
+++ b/tools/filters/ucsc_gene_bed_to_exon_bed.py Thu Mar 24 15:03:12 2011 -0400
@@ -103,13 +103,12 @@
i+=1
#for non-intron regions:
else:
- shift = 0
for start, end in zip( exon_starts, exon_ends ):
start = max( start, region_start )
end = min( end, region_end )
if start < end:
if options.region == 'codon':
- start += shift
+ start += (3 - ((start-region_start)%3))%3
c_start = start
while c_start+3 <= end:
if strand:
@@ -117,7 +116,6 @@
else:
print_tab_sep(out_file, chrom, c_start, c_start+3)
c_start += 3
- shift = (3 - ((end-start)%3))%3
else:
if strand:
print_tab_sep(out_file, chrom, start, end, name, "0", strand )
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/galaxy-central: natefoo: Update the check_galaxy script for the recent changes to the User controller
by Bitbucket 24 Mar '11
by Bitbucket 24 Mar '11
24 Mar '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/b41ea12642ad/
changeset: r5267:b41ea12642ad
user: natefoo
date: 2011-03-24 19:33:05
summary: Update the check_galaxy script for the recent changes to the User controller
affected #: 1 file (14 bytes)
--- a/scripts/check_galaxy.py Thu Mar 24 13:52:04 2011 -0400
+++ b/scripts/check_galaxy.py Thu Mar 24 14:33:05 2011 -0400
@@ -274,7 +274,7 @@
self.get("/root/delete?id=%s" % did)
def check_if_logged_in(self):
- self.get("/user")
+ self.get("/user?cntrller=user")
p = loggedinParser()
p.feed(tc.browser.get_html())
return p.logged_in
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/galaxy-central: jgoecks: Trackster: small fix for read drawing and added note about larger issue.
by Bitbucket 24 Mar '11
by Bitbucket 24 Mar '11
24 Mar '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/c0330af57060/
changeset: r5266:c0330af57060
user: jgoecks
date: 2011-03-24 18:52:04
summary: Trackster: small fix for read drawing and added note about larger issue.
affected #: 1 file (213 bytes)
--- a/static/scripts/trackster.js Thu Mar 24 11:45:50 2011 -0400
+++ b/static/scripts/trackster.js Thu Mar 24 13:52:04 2011 -0400
@@ -2782,8 +2782,10 @@
// Keep list of items that need to be drawn on top of initial drawing layer.
var draw_last = [];
+ // Gap is needed so that read is offset and hence first base can be drawn on read.
+ // TODO-FIX: using this gap offsets reads so that their start is not visually in sync with other tracks.
if ((mode === "Pack" || this.mode === "Auto") && orig_seq !== undefined && w_scale > CHAR_WIDTH_PX) {
- gap = Math.round(w_scale/2);
+ gap = Math.ceil(CHAR_WIDTH_PX/2 + 1);
}
if (!cigar) {
// If no cigar string, then assume all matches
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/galaxy-central: dan: Add more verbose error reporting to FASTQ Groomer tool.
by Bitbucket 24 Mar '11
by Bitbucket 24 Mar '11
24 Mar '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/acf9c73836f3/
changeset: r5265:acf9c73836f3
user: dan
date: 2011-03-24 16:45:50
summary: Add more verbose error reporting to FASTQ Groomer tool.
affected #: 2 files (2.3 KB)
--- a/lib/galaxy_utils/sequence/fastq.py Wed Mar 23 19:32:32 2011 -0400
+++ b/lib/galaxy_utils/sequence/fastq.py Thu Mar 24 11:45:50 2011 -0400
@@ -455,6 +455,44 @@
while True:
yield self.next()
+class ReadlineCountFile( object ):
+ def __init__( self, f ):
+ self.__file = f
+ self.readline_count = 0
+ def readline( self, *args, **kwds ):
+ self.readline_count += 1
+ return self.__file.readline( *args, **kwds )
+ def __getattr__( self, name ):
+ return getattr( self.__file, name )
+
+class fastqVerboseErrorReader( fastqReader ):
+ MAX_PRINT_ERROR_BYTES = 1024
+ def __init__( self, fh, **kwds ):
+ super( fastqVerboseErrorReader, self ).__init__( ReadlineCountFile( fh ), **kwds )
+ self.last_good_identifier = None
+ def next( self ):
+ last_good_end_offset = self.file.tell()
+ last_readline_count = self.file.readline_count
+ try:
+ block = super( fastqVerboseErrorReader, self ).next()
+ self.last_good_identifier = block.identifier
+ return block
+ except StopIteration, e:
+ raise e
+ except Exception, e:
+ print "There was an error reading your input file. Your input file is likely malformed.\nIt is suggested that you double-check your original input file for errors -- helpful information for this purpose has been provided below.\nHowever, if you think that you have encountered an actual error with this tool, please do tell us by using the bug reporting mechanism.\n\nThe reported error is: '%s'." % e
+ if self.last_good_identifier is not None:
+ print "The last valid FASTQ read had an identifier of '%s'." % self.last_good_identifier
+ else:
+ print "The error occurred at the start of your file and no valid FASTQ reads were found."
+ error_offset = self.file.tell()
+ error_byte_count = error_offset - last_good_end_offset
+ print_error_bytes = min( self.MAX_PRINT_ERROR_BYTES, error_byte_count )
+ print "The error in your file occurs between lines '%i' and '%i', which corresponds to byte-offsets '%i' and '%i', and contains the text (%i of %i bytes shown):\n" % ( last_readline_count + 1, self.file.readline_count, last_good_end_offset, error_offset, print_error_bytes, error_byte_count )
+ self.file.seek( last_good_end_offset )
+ print self.file.read( print_error_bytes )
+ raise e
+
class fastqNamedReader( object ):
def __init__( self, fh, format = 'sanger' ):
self.file = fh
--- a/tools/fastq/fastq_groomer.py Wed Mar 23 19:32:32 2011 -0400
+++ b/tools/fastq/fastq_groomer.py Thu Mar 24 11:45:50 2011 -0400
@@ -1,6 +1,6 @@
#Dan Blankenberg
import sys
-from galaxy_utils.sequence.fastq import fastqReader, fastqAggregator, fastqWriter
+from galaxy_utils.sequence.fastq import fastqReader, fastqVerboseErrorReader, fastqAggregator, fastqWriter
def main():
input_filename = sys.argv[1]
@@ -15,7 +15,11 @@
aggregator = fastqAggregator()
out = fastqWriter( open( output_filename, 'wb' ), format = output_type, force_quality_encoding = force_quality_encoding )
read_count = None
- for read_count, fastq_read in enumerate( fastqReader( open( input_filename ), format = input_type ) ):
+ if summarize_input:
+ reader = fastqVerboseErrorReader
+ else:
+ reader = fastqReader
+ for read_count, fastq_read in enumerate( reader( open( input_filename ), format = input_type ) ):
if summarize_input:
aggregator.consume_read( fastq_read )
out.write( fastq_read )
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0