sequenceserver 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 910445c0b05d5d6a4fa903c392c9db1bf591849e
4
- data.tar.gz: 73971a25168f906c4dea26876f3a56b9033baaba
3
+ metadata.gz: 9040c6020c1e07fdb573d72393de66c9db7fc48c
4
+ data.tar.gz: 6d42a977fd1d4a26528f60738b35c3155eb65c12
5
5
  SHA512:
6
- metadata.gz: a1c9b4f0d8804a510e25ce67efd741b409d71a43dd3385eac5478e6d89d79eb7c7b8dac6ef465a1b429b211b1d29cc152d5d16d787a054fd1407bb35f9093d77
7
- data.tar.gz: f164914652ab3657ab784b19a6d75fb911b18bac067403d02dca10cbd1e94e16341182891562f470de63317b54bc0b4e96904bd3751a373a19779be119d6294c
6
+ metadata.gz: 5f23f8d52e26144ce797c833bcad02bb278da705aae2c6acd58d857973895c4845287d5b2fd2010ba1cd661f15a38a59437713a4fb2f8ee5dcba145d83767c26
7
+ data.tar.gz: d0d705074535ea97e6935e4e098aade727dad62b3aa641b3028da10309c959eb0b3a7726dfa02ec4f427b1317f42a23bb30eefbf24f24aad86523c92abe52b3e
data/.rubocop.yml CHANGED
@@ -14,6 +14,12 @@ Metrics/MethodLength:
14
14
  Exclude:
15
15
  # TODO:
16
16
  - 'lib/sequenceserver.rb'
17
+ Metrics/ModuleLength:
18
+ Exclude:
19
+ # TODO:
20
+ # Revisit later.
21
+ - 'lib/sequenceserver.rb'
22
+ - 'spec/blast_spec.rb'
17
23
  Metrics/ClassLength:
18
24
  Exclude:
19
25
  # TODO:
data/bin/sequenceserver CHANGED
@@ -8,6 +8,18 @@ ENV['RACK_ENV'] ||= 'production'
8
8
  # display name for tools like `ps`
9
9
  $PROGRAM_NAME = 'sequenceserver'
10
10
 
11
+ # Given a url downloads the archive into a temporary file
12
+ # and and extratcs it into ~/.sequenceserver
13
+ def download_from_url(url)
14
+ archive = File.join('/tmp', File.basename(url))
15
+ # -ip4 is required to avoid this curl bug http://sourceforge.net/p/curl/bugs/1424/?limit=25
16
+ # see also https://github.com/yannickwurm/sequenceserver/issues/139
17
+ cmd = "curl -ip4 -C - #{url} -o #{archive} && " \
18
+ 'mkdir -p ~/.sequenceserver && ' \
19
+ "tar xvf #{archive} -C ~/.sequenceserver"
20
+ system cmd
21
+ end
22
+
11
23
  begin
12
24
  Slop.parse!(:strict => true, :help => true) do
13
25
  banner <<BANNER
@@ -19,31 +31,40 @@ USAGE
19
31
 
20
32
  sequenceserver [options]
21
33
 
22
- Example:
34
+ EXAMPLE
23
35
 
24
- # launch SequenceServer with the given config file
36
+ # Launch SequenceServer. This will read configuration from
37
+ # ~/.sequenceserver.conf, if present.
38
+ $ sequenceserver
39
+
40
+ # Use a different config file.
25
41
  $ sequenceserver -c ~/.sequenceserver.ants.conf
26
42
 
27
- # use the bundled database formatter utility to prepare databases for use
28
- # with SequenceServer
43
+ # Set number of threads to use. This will save the number
44
+ # of threads to use in config file.
45
+ $ sequenceserver -s -n 16
46
+
47
+ # See if you have FASTA files in database dir that haven't
48
+ # been converted into BLAST database.
49
+ $ sequenceserver -u
50
+
51
+ # Search for FASTA files in database dir that haven't been
52
+ # converted into BLAST database yet, and convert them.
29
53
  $ sequenceserver -m
30
54
 
31
55
  DESCRIPTION
32
56
 
33
57
  SequenceServer lets you rapidly set up a BLAST+ server with an intuitive user
34
- interface for use locally or over the web.
35
-
36
- If BLAST+ is not installed on your system, SequenceServer will offer to install
37
- BLAST+ for you.
38
-
39
- You should only ever have to point it to a directory of FASTA files.
58
+ interface for use locally or over the web. If BLAST+ is not installed on your
59
+ system, SequenceServer will offer to install BLAST+ for you. You should only
60
+ ever have to point it to a directory of FASTA files / BLAST+ databases.
40
61
 
41
62
  In a given directory, SequenceServer is able to tell FASTA files that are yet
42
63
  to be formatted for use with BLAST+ and format them, and FASTA files that are
43
64
  already formatted for use with BLAST+, heuristically skipping all other files
44
65
  in the directory. Directories are scanned recursively. Type of sequences in a
45
- FASTA file is detected automagically. `parse_seqids` option of `makeblastdb` is
46
- used to create BLAST+ databases.
66
+ FASTA file is detected automagically. `parse_seqids` and `hash_index` options
67
+ of `makeblastdb` are used to create BLAST+ databases.
47
68
  BANNER
48
69
 
49
70
  on 'c', 'config_file=',
@@ -83,6 +104,9 @@ BANNER
83
104
  on 'm', 'make-blast-databases',
84
105
  'Create BLAST databases'
85
106
 
107
+ on 'download-taxdb',
108
+ 'Download the taxdb files'
109
+
86
110
  on 'l', 'list_databases',
87
111
  'List BLAST databases'
88
112
 
@@ -248,13 +272,7 @@ https://github.com/yannickwurm/sequenceserver/issues
248
272
 
249
273
  ERR
250
274
  end
251
-
252
- archive = File.join('/tmp', File.basename(url))
253
- # -ip4 is required to avoid this curl bug http://sourceforge.net/p/curl/bugs/1424/?limit=25
254
- # see also https://github.com/yannickwurm/sequenceserver/issues/139
255
- system "curl -ip4 -C - #{url} -o #{archive} && " \
256
- 'mkdir -p ~/.sequenceserver && ' \
257
- "tar xvf #{archive} -C ~/.sequenceserver"
275
+ download_from_url(url)
258
276
  unless $CHILD_STATUS.success?
259
277
  puts 'Failed to install BLAST+.'
260
278
  puts ' You may need to download BLAST+ from - '
@@ -381,6 +399,14 @@ MSG
381
399
  exit
382
400
  end
383
401
 
402
+ if download_taxdb?
403
+ download_from_url('ftp://ftp.ncbi.nlm.nih.gov/blast/db/'\
404
+ 'taxdb.tar.gz')
405
+ puts
406
+ puts 'taxdb downloaded!'
407
+ exit
408
+ end
409
+
384
410
  if set?
385
411
  SequenceServer.config.write_config_file
386
412
  exit
@@ -1,4 +1,7 @@
1
+ # Define constants used by SequenceServer module
1
2
  module SequenceServer
3
+ # Constant for denoting the path ~/.sequenceserver
4
+ DOTDIR = File.expand_path('~/.sequenceserver')
2
5
  # Define constanst used by BLAST module.
3
6
  module BLAST
4
7
  ERROR_LINE = /\(CArgException.*\)\s(.*)/
@@ -11,7 +11,7 @@ module SequenceServer
11
11
  # RuntimeError is raised when BLAST+'s exits status is one of 2, 3, 4, or
12
12
  # 255; see [1]. These are rare, infrastructure errors, used internally,
13
13
  # and of concern only to the admins/developers.
14
- class RuntimeError < RuntimeError
14
+ class RuntimeError < RuntimeError
15
15
  def initialize(status, message)
16
16
  @status = status
17
17
  @message = message
@@ -41,7 +41,7 @@ module SequenceServer
41
41
  " -outfmt '#{format} #{specifiers}'" \
42
42
  " -out '#{file.path}' 2> /dev/null"
43
43
  logger.debug("Executing: #{command}")
44
- system command
44
+ system(command, :chdir => (File.exist?(DOTDIR) && DOTDIR || Dir.pwd))
45
45
  end
46
46
 
47
47
  def validate
@@ -26,7 +26,7 @@ module SequenceServer
26
26
  def links
27
27
  links = Links.instance_methods.map { |m| send m }
28
28
  links.compact!
29
- links.sort_by { |link| link[:order] }
29
+ links.sort_by { |link| [link[:order], link[:title]] }
30
30
  end
31
31
 
32
32
  # Returns an array of database objects which contain the queried sequence
@@ -27,6 +27,7 @@ module SequenceServer
27
27
  # Returns a Hash of stats common to all BLAST algorithms. Subclasses must
28
28
  # update the returned Hash to add relevant stats of their own.
29
29
  #
30
+ # rubocop:disable Metrics/AbcSize
30
31
  def stats
31
32
  {
32
33
  'Score' => [in_twodecimal(bit_score), score],
@@ -37,6 +38,7 @@ module SequenceServer
37
38
  in_percentage(gaps, length)]
38
39
  }
39
40
  end
41
+ # rubocop:enable Metrics/AbcSize
40
42
 
41
43
  # Returns pretty formatted alignment String.
42
44
  #
@@ -17,7 +17,8 @@ module SequenceServer
17
17
  end
18
18
 
19
19
  def sort_hits_by_evalue!
20
- @hits = hits.sort_by(&:evalue)
20
+ # change made here
21
+ @hits = hits.sort_by { |h| [h.evalue, h.score] }
21
22
  end
22
23
 
23
24
  attr_reader :id, :title
@@ -96,6 +96,8 @@ module SequenceServer
96
96
  end
97
97
 
98
98
  # Recurisvely scan `database_dir` for blast databases.
99
+ #
100
+ # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
99
101
  def scan_databases_dir
100
102
  cmd = "blastdbcmd -recursive -list #{config[:database_dir]}" \
101
103
  ' -list_outfmt "%f %t %p %n %l %d"'
@@ -115,6 +117,7 @@ module SequenceServer
115
117
  throw_scan_error(cmd, out, err, $CHILD_STATUS)
116
118
  end
117
119
  end
120
+ # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
118
121
 
119
122
  def throw_scan_error(cmd, out, err, child_status)
120
123
  errpat = /BLAST Database error/
@@ -156,12 +159,14 @@ module SequenceServer
156
159
  def make_blast_database(file, type)
157
160
  return unless make_blast_database? file, type
158
161
  title = get_database_title(file)
159
- _make_blast_database(file, type, title)
162
+ taxid = fetch_tax_id
163
+ _make_blast_database(file, type, title, taxid)
160
164
  end
161
165
 
162
- def _make_blast_database(file, type, title, quiet = false)
166
+ def _make_blast_database(file, type, title, taxid, quiet = false)
163
167
  cmd = 'makeblastdb -parse_seqids -hash_index ' \
164
- "-in #{file} -dbtype #{type.to_s.slice(0, 4)} -title '#{title}'"
168
+ "-in #{file} -dbtype #{type.to_s.slice(0, 4)} -title '#{title}'" \
169
+ " -taxid #{taxid}"
165
170
  cmd << ' &> /dev/null' if quiet
166
171
  system cmd
167
172
  end
@@ -176,7 +181,6 @@ module SequenceServer
176
181
  puts "FASTA file: #{file}"
177
182
  puts "FASTA type: #{type}"
178
183
  print 'Proceed? [y/n] (Default: y): '
179
-
180
184
  response = STDIN.gets.to_s.strip
181
185
  !response.match(/n/i)
182
186
  end
@@ -188,8 +192,19 @@ module SequenceServer
188
192
  def get_database_title(path)
189
193
  default = make_db_title(File.basename(path))
190
194
  print "Enter a database title or will use '#{default}': "
191
- from_user = STDIN.gets.to_s
192
- from_user.strip.empty? && default || from_user
195
+ from_user = STDIN.gets.to_s.strip
196
+ from_user.empty? && default || from_user
197
+ end
198
+
199
+ # Get taxid from the user. Returns user input or 0.
200
+ #
201
+ # Using 0 as taxid is equivalent to not setting taxid for the database
202
+ # that will be created.
203
+ def fetch_tax_id
204
+ default = 0
205
+ print 'Enter taxid (optional): '
206
+ response_user = STDIN.gets.to_s.strip
207
+ response_user.empty? && default || response_user
193
208
  end
194
209
 
195
210
  # Returns true if the database name appears to be a multi-part database
@@ -200,7 +215,7 @@ module SequenceServer
200
215
  # /home/ben/pd.ben/sequenceserver/db/nr => no
201
216
  # /home/ben/pd.ben/sequenceserver/db/img3.5.finished.faa.01 => yes
202
217
  def multipart_database_name?(db_name)
203
- !(db_name.match(/.+\/\S+\d{2}$/).nil?)
218
+ !(db_name.match(%r{.+/\S+\d{2}$}).nil?)
204
219
  end
205
220
 
206
221
  # Returns true if first character of the file is '>'.
@@ -8,7 +8,8 @@ module SequenceServer
8
8
  #
9
9
  alias_method :encode, :url_encode
10
10
 
11
- NCBI_ID_PATTERN = /gi\|(\d+)\|/
11
+ NCBI_ID_PATTERN = /gi\|(\d+)\|/
12
+ UNIPROT_ID_PATTERN = /sp\|(\w+)\|/
12
13
 
13
14
  # Link generators return a Hash like below.
14
15
  #
@@ -101,6 +102,19 @@ module SequenceServer
101
102
  :icon => 'fa-external-link'
102
103
  }
103
104
  end
105
+
106
+ def uniprot
107
+ return nil unless id.match(UNIPROT_ID_PATTERN)
108
+ uniprot_id = Regexp.last_match[1]
109
+ uniprot_id = encode uniprot_id
110
+ url = "http://www.uniprot.org/uniprot/#{uniprot_id}"
111
+ {
112
+ :order => 2,
113
+ :title => 'Uniprot',
114
+ :url => url,
115
+ :icon => 'fa-external-link'
116
+ }
117
+ end
104
118
  end
105
119
  end
106
120
 
@@ -46,7 +46,7 @@ module SequenceServer
46
46
  # 'ALLOW-FROM uri'.
47
47
  set :protection, lambda {
48
48
  frame_options = SequenceServer.config[:frame_options]
49
- frame_options && {:frame_options => frame_options}
49
+ frame_options && { :frame_options => frame_options }
50
50
  }
51
51
  end
52
52
 
@@ -1,4 +1,4 @@
1
1
  # Define version number.
2
2
  module SequenceServer
3
- VERSION = '1.0.3'
3
+ VERSION = '1.0.4'
4
4
  end
@@ -15,4 +15,4 @@ r.has(q)?p[d]=e:r.set(q,e),t.push(q);for(d=-1;++d<l;)q=b.call(c,f=c[d],d),(e=r.g
15
15
  b.P=null,b.N=a,a.P=a.L=b,c=a):(b.P=b.N=null,this._=b,c=null);for(b.L=b.R=null,b.U=c,b.C=!0,a=b;c&&c.C;)d=c.U,c===d.L?(e=d.R,e&&e.C?(c.C=e.C=!1,d.C=!0,a=d):(a===c.R&&($c(this,c),a=c,c=a.U),c.C=!1,d.C=!0,_c(this,d))):(e=d.L,e&&e.C?(c.C=e.C=!1,d.C=!0,a=d):(a===c.L&&(_c(this,c),a=c,c=a.U),c.C=!1,d.C=!0,$c(this,d))),c=a.U;this._.C=!1},remove:function(a){a.N&&(a.N.P=a.P),a.P&&(a.P.N=a.N),a.N=a.P=null;var b,c,d,e=a.U,f=a.L,g=a.R;if(c=f?g?ad(g):f:g,e?e.L===a?e.L=c:e.R=c:this._=c,f&&g?(d=c.C,c.C=a.C,c.L=f,f.U=c,c!==g?(e=c.U,c.U=a.U,a=c.R,e.L=a,c.R=g,g.U=c):(c.U=e,e=c,a=c.R)):(d=a.C,a=c),a&&(a.U=e),!d){if(a&&a.C)return void(a.C=!1);do{if(a===this._)break;if(a===e.L){if(b=e.R,b.C&&(b.C=!1,e.C=!0,$c(this,e),b=e.R),b.L&&b.L.C||b.R&&b.R.C){b.R&&b.R.C||(b.L.C=!1,b.C=!0,_c(this,b),b=e.R),b.C=e.C,e.C=b.R.C=!1,$c(this,e),a=this._;break}}else if(b=e.L,b.C&&(b.C=!1,e.C=!0,_c(this,e),b=e.L),b.L&&b.L.C||b.R&&b.R.C){b.L&&b.L.C||(b.R.C=!1,b.C=!0,$c(this,b),b=e.L),b.C=e.C,e.C=b.L.C=!1,_c(this,e),a=this._;break}b.C=!0,a=e,e=e.U}while(!a.C);a&&(a.C=!1)}}},Sf.geom.voronoi=function(a){function b(a){var b=new Array(a.length),d=h[0][0],e=h[0][1],f=h[1][0],g=h[1][1];return bd(c(a),h).cells.forEach(function(c,h){var i=c.edges,j=c.site,k=b[h]=i.length?i.map(function(a){var b=a.start();return[b.x,b.y]}):j.x>=d&&j.x<=f&&j.y>=e&&j.y<=g?[[d,g],[f,g],[f,e],[d,e]]:[];k.point=a[h]}),b}function c(a){return a.map(function(a,b){return{x:Math.round(f(a,b)/zg)*zg,y:Math.round(g(a,b)/zg)*zg,i:b}})}var d=xc,e=yc,f=d,g=e,h=Yh;return a?b(a):(b.links=function(a){return bd(c(a)).edges.filter(function(a){return a.l&&a.r}).map(function(b){return{source:a[b.l.i],target:a[b.r.i]}})},b.triangles=function(a){var b=[];return bd(c(a)).cells.forEach(function(c,d){for(var e,f,g=c.site,h=c.edges.sort(Nc),i=-1,j=h.length,k=h[j-1].edge,l=k.l===g?k.r:k.l;++i<j;)e=k,f=l,k=h[i].edge,l=k.l===g?k.r:k.l,d<f.i&&d<l.i&&dd(g,f,l)<0&&b.push([a[d],a[f.i],a[l.i]])}),b},b.x=function(a){return arguments.length?(f=wa(d=a),b):d},b.y=function(a){return arguments.length?(g=wa(e=a),b):e},b.clipExtent=function(a){return arguments.length?(h=null==a?Yh:a,b):h===Yh?null:h},b.size=function(a){return arguments.length?b.clipExtent(a&&[[0,0],a]):h===Yh?null:h&&h[1]},b)};var Yh=[[-1e6,-1e6],[1e6,1e6]];Sf.geom.delaunay=function(a){return Sf.geom.voronoi().triangles(a)},Sf.geom.quadtree=function(a,b,c,d,e){function f(a){function f(a,b,c,d,e,f,g,h){if(!isNaN(c)&&!isNaN(d))if(a.leaf){var i=a.x,k=a.y;if(null!=i)if(eg(i-c)+eg(k-d)<.01)j(a,b,c,d,e,f,g,h);else{var l=a.point;a.x=a.y=a.point=null,j(a,l,i,k,e,f,g,h),j(a,b,c,d,e,f,g,h)}else a.x=c,a.y=d,a.point=b}else j(a,b,c,d,e,f,g,h)}function j(a,b,c,d,e,g,h,i){var j=.5*(e+h),k=.5*(g+i),l=c>=j,m=d>=k,n=(m<<1)+l;a.leaf=!1,a=a.nodes[n]||(a.nodes[n]=gd()),l?e=j:h=j,m?g=k:i=k,f(a,b,c,d,e,g,h,i)}var k,l,m,n,o,p,q,r,s,t=wa(h),u=wa(i);if(null!=b)p=b,q=c,r=d,s=e;else if(r=s=-(p=q=1/0),l=[],m=[],o=a.length,g)for(n=0;o>n;++n)k=a[n],k.x<p&&(p=k.x),k.y<q&&(q=k.y),k.x>r&&(r=k.x),k.y>s&&(s=k.y),l.push(k.x),m.push(k.y);else for(n=0;o>n;++n){var v=+t(k=a[n],n),w=+u(k,n);p>v&&(p=v),q>w&&(q=w),v>r&&(r=v),w>s&&(s=w),l.push(v),m.push(w)}var x=r-p,y=s-q;x>y?s=q+x:r=p+y;var z=gd();if(z.add=function(a){f(z,a,+t(a,++n),+u(a,n),p,q,r,s)},z.visit=function(a){hd(a,z,p,q,r,s)},n=-1,null==b){for(;++n<o;)f(z,a[n],l[n],m[n],p,q,r,s);--n}else a.forEach(z.add);return l=m=a=k=null,z}var g,h=xc,i=yc;return(g=arguments.length)?(h=ed,i=fd,3===g&&(e=c,d=b,c=b=0),f(a)):(f.x=function(a){return arguments.length?(h=a,f):h},f.y=function(a){return arguments.length?(i=a,f):i},f.extent=function(a){return arguments.length?(null==a?b=c=d=e=null:(b=+a[0][0],c=+a[0][1],d=+a[1][0],e=+a[1][1]),f):null==b?null:[[b,c],[d,e]]},f.size=function(a){return arguments.length?(null==a?b=c=d=e=null:(b=c=0,d=+a[0],e=+a[1]),f):null==b?null:[d-b,e-c]},f)},Sf.interpolateRgb=id,Sf.interpolateObject=jd,Sf.interpolateNumber=kd,Sf.interpolateString=ld;var Zh=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,$h=new RegExp(Zh.source,"g");Sf.interpolate=md,Sf.interpolators=[function(a,b){var c=typeof b;return("string"===c?Rg.has(b)||/^(#|rgb\(|hsl\()/.test(b)?id:ld:b instanceof ca?id:Array.isArray(b)?nd:"object"===c&&isNaN(b)?jd:kd)(a,b)}],Sf.interpolateArray=nd;var _h=function(){return xa},ai=Sf.map({linear:_h,poly:ud,quad:function(){return rd},cubic:function(){return sd},sin:function(){return vd},exp:function(){return wd},circle:function(){return xd},elastic:yd,back:zd,bounce:function(){return Ad}}),bi=Sf.map({"in":xa,out:pd,"in-out":qd,"out-in":function(a){return qd(pd(a))}});Sf.ease=function(a){var b=a.indexOf("-"),c=b>=0?a.substring(0,b):a,d=b>=0?a.substring(b+1):"in";return c=ai.get(c)||_h,d=bi.get(d)||xa,od(d(c.apply(null,Tf.call(arguments,1))))},Sf.interpolateHcl=Bd,Sf.interpolateHsl=Cd,Sf.interpolateLab=Dd,Sf.interpolateRound=Ed,Sf.transform=function(a){var b=Vf.createElementNS(Sf.ns.prefix.svg,"g");return(Sf.transform=function(a){if(null!=a){b.setAttribute("transform",a);var c=b.transform.baseVal.consolidate()}return new Fd(c?c.matrix:ci)})(a)},Fd.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var ci={a:1,b:0,c:0,d:1,e:0,f:0};Sf.interpolateTransform=Jd,Sf.layout={},Sf.layout.bundle=function(){return function(a){for(var b=[],c=-1,d=a.length;++c<d;)b.push(Md(a[c]));return b}},Sf.layout.chord=function(){function a(){var a,j,l,m,n,o={},p=[],q=Sf.range(f),r=[];for(c=[],d=[],a=0,m=-1;++m<f;){for(j=0,n=-1;++n<f;)j+=e[m][n];p.push(j),r.push(Sf.range(f)),a+=j}for(g&&q.sort(function(a,b){return g(p[a],p[b])}),h&&r.forEach(function(a,b){a.sort(function(a,c){return h(e[b][a],e[b][c])})}),a=(xg-k*f)/a,j=0,m=-1;++m<f;){for(l=j,n=-1;++n<f;){var s=q[m],t=r[s][n],u=e[s][t],v=j,w=j+=u*a;o[s+"-"+t]={index:s,subindex:t,startAngle:v,endAngle:w,value:u}}d[s]={index:s,startAngle:l,endAngle:j,value:(j-l)/a},j+=k}for(m=-1;++m<f;)for(n=m-1;++n<f;){var x=o[m+"-"+n],y=o[n+"-"+m];(x.value||y.value)&&c.push(x.value<y.value?{source:y,target:x}:{source:x,target:y})}i&&b()}function b(){c.sort(function(a,b){return i((a.source.value+a.target.value)/2,(b.source.value+b.target.value)/2)})}var c,d,e,f,g,h,i,j={},k=0;return j.matrix=function(a){return arguments.length?(f=(e=a)&&e.length,c=d=null,j):e},j.padding=function(a){return arguments.length?(k=a,c=d=null,j):k},j.sortGroups=function(a){return arguments.length?(g=a,c=d=null,j):g},j.sortSubgroups=function(a){return arguments.length?(h=a,c=null,j):h},j.sortChords=function(a){return arguments.length?(i=a,c&&b(),j):i},j.chords=function(){return c||a(),c},j.groups=function(){return d||a(),d},j},Sf.layout.force=function(){function a(a){return function(b,c,d,e){if(b.point!==a){var f=b.cx-a.x,g=b.cy-a.y,h=e-c,i=f*f+g*g;if(i>h*h/q){if(o>i){var j=b.charge/i;a.px-=f*j,a.py-=g*j}return!0}if(b.point&&i&&o>i){var j=b.pointCharge/i;a.px-=f*j,a.py-=g*j}}return!b.charge}}function b(a){a.px=Sf.event.x,a.py=Sf.event.y,h.resume()}var c,d,e,f,g,h={},i=Sf.dispatch("start","tick","end"),j=[1,1],k=.9,l=di,m=ei,n=-30,o=fi,p=.1,q=.64,r=[],s=[];return h.tick=function(){if((d*=.99)<.005)return i.end({type:"end",alpha:d=0}),!0;var b,c,h,l,m,o,q,t,u,v=r.length,w=s.length;for(c=0;w>c;++c)h=s[c],l=h.source,m=h.target,t=m.x-l.x,u=m.y-l.y,(o=t*t+u*u)&&(o=d*f[c]*((o=Math.sqrt(o))-e[c])/o,t*=o,u*=o,m.x-=t*(q=l.weight/(m.weight+l.weight)),m.y-=u*q,l.x+=t*(q=1-q),l.y+=u*q);if((q=d*p)&&(t=j[0]/2,u=j[1]/2,c=-1,q))for(;++c<v;)h=r[c],h.x+=(t-h.x)*q,h.y+=(u-h.y)*q;if(n)for(Td(b=Sf.geom.quadtree(r),d,g),c=-1;++c<v;)(h=r[c]).fixed||b.visit(a(h));for(c=-1;++c<v;)h=r[c],h.fixed?(h.x=h.px,h.y=h.py):(h.x-=(h.px-(h.px=h.x))*k,h.y-=(h.py-(h.py=h.y))*k);i.tick({type:"tick",alpha:d})},h.nodes=function(a){return arguments.length?(r=a,h):r},h.links=function(a){return arguments.length?(s=a,h):s},h.size=function(a){return arguments.length?(j=a,h):j},h.linkDistance=function(a){return arguments.length?(l="function"==typeof a?a:+a,h):l},h.distance=h.linkDistance,h.linkStrength=function(a){return arguments.length?(m="function"==typeof a?a:+a,h):m},h.friction=function(a){return arguments.length?(k=+a,h):k},h.charge=function(a){return arguments.length?(n="function"==typeof a?a:+a,h):n},h.chargeDistance=function(a){return arguments.length?(o=a*a,h):Math.sqrt(o)},h.gravity=function(a){return arguments.length?(p=+a,h):p},h.theta=function(a){return arguments.length?(q=a*a,h):Math.sqrt(q)},h.alpha=function(a){return arguments.length?(a=+a,d?d=a>0?a:0:a>0&&(i.start({type:"start",alpha:d=a}),Sf.timer(h.tick)),h):d},h.start=function(){function a(a,d){if(!c){for(c=new Array(i),h=0;i>h;++h)c[h]=[];for(h=0;j>h;++h){var e=s[h];c[e.source.index].push(e.target),c[e.target.index].push(e.source)}}for(var f,g=c[b],h=-1,j=g.length;++h<j;)if(!isNaN(f=g[h][a]))return f;return Math.random()*d}var b,c,d,i=r.length,k=s.length,o=j[0],p=j[1];for(b=0;i>b;++b)(d=r[b]).index=b,d.weight=0;for(b=0;k>b;++b)d=s[b],"number"==typeof d.source&&(d.source=r[d.source]),"number"==typeof d.target&&(d.target=r[d.target]),++d.source.weight,++d.target.weight;for(b=0;i>b;++b)d=r[b],isNaN(d.x)&&(d.x=a("x",o)),isNaN(d.y)&&(d.y=a("y",p)),isNaN(d.px)&&(d.px=d.x),isNaN(d.py)&&(d.py=d.y);if(e=[],"function"==typeof l)for(b=0;k>b;++b)e[b]=+l.call(this,s[b],b);else for(b=0;k>b;++b)e[b]=l;if(f=[],"function"==typeof m)for(b=0;k>b;++b)f[b]=+m.call(this,s[b],b);else for(b=0;k>b;++b)f[b]=m;if(g=[],"function"==typeof n)for(b=0;i>b;++b)g[b]=+n.call(this,r[b],b);else for(b=0;i>b;++b)g[b]=n;return h.resume()},h.resume=function(){return h.alpha(.1)},h.stop=function(){return h.alpha(0)},h.drag=function(){return c||(c=Sf.behavior.drag().origin(xa).on("dragstart.force",Pd).on("drag.force",b).on("dragend.force",Qd)),arguments.length?void this.on("mouseover.force",Rd).on("mouseout.force",Sd).call(c):c},Sf.rebind(h,i,"on")};var di=20,ei=1,fi=1/0;Sf.layout.hierarchy=function(){function a(e){var f,g=[e],h=[];for(e.depth=0;null!=(f=g.pop());)if(h.push(f),(j=c.call(a,f,f.depth))&&(i=j.length)){for(var i,j,k;--i>=0;)g.push(k=j[i]),k.parent=f,k.depth=f.depth+1;d&&(f.value=0),f.children=j}else d&&(f.value=+d.call(a,f,f.depth)||0),delete f.children;return Wd(e,function(a){var c,e;b&&(c=a.children)&&c.sort(b),d&&(e=a.parent)&&(e.value+=a.value)}),h}var b=Zd,c=Xd,d=Yd;return a.sort=function(c){return arguments.length?(b=c,a):b},a.children=function(b){return arguments.length?(c=b,a):c},a.value=function(b){return arguments.length?(d=b,a):d},a.revalue=function(b){return d&&(Vd(b,function(a){a.children&&(a.value=0)}),Wd(b,function(b){var c;b.children||(b.value=+d.call(a,b,b.depth)||0),(c=b.parent)&&(c.value+=b.value)})),b},a},Sf.layout.partition=function(){function a(b,c,d,e){var f=b.children;if(b.x=c,b.y=b.depth*e,b.dx=d,b.dy=e,f&&(g=f.length)){var g,h,i,j=-1;for(d=b.value?d/b.value:0;++j<g;)a(h=f[j],c,i=h.value*d,e),c+=i}}function b(a){var c=a.children,d=0;if(c&&(e=c.length))for(var e,f=-1;++f<e;)d=Math.max(d,b(c[f]));return 1+d}function c(c,f){var g=d.call(this,c,f);return a(g[0],0,e[0],e[1]/b(g[0])),g}var d=Sf.layout.hierarchy(),e=[1,1];return c.size=function(a){return arguments.length?(e=a,c):e},Ud(c,d)},Sf.layout.pie=function(){function a(f){var g=f.map(function(c,d){return+b.call(a,c,d)}),h=+("function"==typeof d?d.apply(this,arguments):d),i=(("function"==typeof e?e.apply(this,arguments):e)-h)/Sf.sum(g),j=Sf.range(f.length);null!=c&&j.sort(c===gi?function(a,b){return g[b]-g[a]}:function(a,b){return c(f[a],f[b])});var k=[];return j.forEach(function(a){var b;k[a]={data:f[a],value:b=g[a],startAngle:h,endAngle:h+=b*i}}),k}var b=Number,c=gi,d=0,e=xg;return a.value=function(c){return arguments.length?(b=c,a):b},a.sort=function(b){return arguments.length?(c=b,a):c},a.startAngle=function(b){return arguments.length?(d=b,a):d},a.endAngle=function(b){return arguments.length?(e=b,a):e},a};var gi={};Sf.layout.stack=function(){function a(h,i){var j=h.map(function(c,d){return b.call(a,c,d)}),k=j.map(function(b){return b.map(function(b,c){return[f.call(a,b,c),g.call(a,b,c)]})}),l=c.call(a,k,i);j=Sf.permute(j,l),k=Sf.permute(k,l);var m,n,o,p=d.call(a,k,i),q=j.length,r=j[0].length;for(n=0;r>n;++n)for(e.call(a,j[0][n],o=p[n],k[0][n][1]),m=1;q>m;++m)e.call(a,j[m][n],o+=k[m-1][n][1],k[m][n][1]);return h}var b=xa,c=ce,d=de,e=be,f=_d,g=ae;return a.values=function(c){return arguments.length?(b=c,a):b},a.order=function(b){return arguments.length?(c="function"==typeof b?b:hi.get(b)||ce,a):c},a.offset=function(b){return arguments.length?(d="function"==typeof b?b:ii.get(b)||de,a):d},a.x=function(b){return arguments.length?(f=b,a):f},a.y=function(b){return arguments.length?(g=b,a):g},a.out=function(b){return arguments.length?(e=b,a):e},a};var hi=Sf.map({"inside-out":function(a){var b,c,d=a.length,e=a.map(ee),f=a.map(fe),g=Sf.range(d).sort(function(a,b){return e[a]-e[b]}),h=0,i=0,j=[],k=[];for(b=0;d>b;++b)c=g[b],i>h?(h+=f[c],j.push(c)):(i+=f[c],k.push(c));return k.reverse().concat(j)},reverse:function(a){return Sf.range(a.length).reverse()},"default":ce}),ii=Sf.map({silhouette:function(a){var b,c,d,e=a.length,f=a[0].length,g=[],h=0,i=[];for(c=0;f>c;++c){for(b=0,d=0;e>b;b++)d+=a[b][c][1];d>h&&(h=d),g.push(d)}for(c=0;f>c;++c)i[c]=(h-g[c])/2;return i},wiggle:function(a){var b,c,d,e,f,g,h,i,j,k=a.length,l=a[0],m=l.length,n=[];for(n[0]=i=j=0,c=1;m>c;++c){for(b=0,e=0;k>b;++b)e+=a[b][c][1];for(b=0,f=0,h=l[c][0]-l[c-1][0];k>b;++b){for(d=0,g=(a[b][c][1]-a[b][c-1][1])/(2*h);b>d;++d)g+=(a[d][c][1]-a[d][c-1][1])/h;f+=g*a[b][c][1]}n[c]=i-=e?f/e*h:0,j>i&&(j=i)}for(c=0;m>c;++c)n[c]-=j;return n},expand:function(a){var b,c,d,e=a.length,f=a[0].length,g=1/e,h=[];for(c=0;f>c;++c){for(b=0,d=0;e>b;b++)d+=a[b][c][1];if(d)for(b=0;e>b;b++)a[b][c][1]/=d;else for(b=0;e>b;b++)a[b][c][1]=g}for(c=0;f>c;++c)h[c]=0;return h},zero:de});Sf.layout.histogram=function(){function a(a,f){for(var g,h,i=[],j=a.map(c,this),k=d.call(this,j,f),l=e.call(this,k,j,f),f=-1,m=j.length,n=l.length-1,o=b?1:1/m;++f<n;)g=i[f]=[],g.dx=l[f+1]-(g.x=l[f]),g.y=0;if(n>0)for(f=-1;++f<m;)h=j[f],h>=k[0]&&h<=k[1]&&(g=i[Sf.bisect(l,h,1,n)-1],g.y+=o,g.push(a[f]));return i}var b=!0,c=Number,d=je,e=he;return a.value=function(b){return arguments.length?(c=b,a):c},a.range=function(b){return arguments.length?(d=wa(b),a):d},a.bins=function(b){return arguments.length?(e="number"==typeof b?function(a){return ie(a,b)}:wa(b),a):e},a.frequency=function(c){return arguments.length?(b=!!c,a):b},a},Sf.layout.pack=function(){function a(a,f){var g=c.call(this,a,f),h=g[0],i=e[0],j=e[1],k=null==b?Math.sqrt:"function"==typeof b?b:function(){return b};if(h.x=h.y=0,Wd(h,function(a){a.r=+k(a.value)}),Wd(h,oe),d){var l=d*(b?1:Math.max(2*h.r/i,2*h.r/j))/2;Wd(h,function(a){a.r+=l}),Wd(h,oe),Wd(h,function(a){a.r-=l})}return re(h,i/2,j/2,b?1:1/Math.max(2*h.r/i,2*h.r/j)),g}var b,c=Sf.layout.hierarchy().sort(ke),d=0,e=[1,1];return a.size=function(b){return arguments.length?(e=b,a):e},a.radius=function(c){return arguments.length?(b=null==c||"function"==typeof c?c:+c,a):b},a.padding=function(b){return arguments.length?(d=+b,a):d},Ud(a,c)},Sf.layout.tree=function(){function a(a,e){var k=g.call(this,a,e),l=k[0],m=b(l);if(Wd(m,c),m.parent.m=-m.z,Vd(m,d),j)Vd(l,f);else{var n=l,o=l,p=l;Vd(l,function(a){a.x<n.x&&(n=a),a.x>o.x&&(o=a),a.depth>p.depth&&(p=a)});var q=h(n,o)/2-n.x,r=i[0]/(o.x+h(o,n)/2+q),s=i[1]/(p.depth||1);Vd(l,function(a){a.x=(a.x+q)*r,a.y=a.depth*s})}return k}function b(a){for(var b,c={A:null,children:[a]},d=[c];null!=(b=d.pop());)for(var e,f=b.children,g=0,h=f.length;h>g;++g)d.push((f[g]=e={_:f[g],parent:b,children:(e=f[g].children)&&e.slice()||[],A:null,a:null,z:0,m:0,c:0,s:0,t:null,i:g}).a=e);return c.children[0]}function c(a){var b=a.children,c=a.parent.children,d=a.i?c[a.i-1]:null;if(b.length){xe(a);var f=(b[0].z+b[b.length-1].z)/2;d?(a.z=d.z+h(a._,d._),a.m=a.z-f):a.z=f}else d&&(a.z=d.z+h(a._,d._));a.parent.A=e(a,d,a.parent.A||c[0])}function d(a){a._.x=a.z+a.parent.m,a.m+=a.parent.m}function e(a,b,c){if(b){for(var d,e=a,f=a,g=b,i=e.parent.children[0],j=e.m,k=f.m,l=g.m,m=i.m;g=ve(g),e=ue(e),g&&e;)i=ue(i),f=ve(f),f.a=a,d=g.z+l-e.z-j+h(g._,e._),d>0&&(we(ye(g,a,c),a,d),j+=d,k+=d),l+=g.m,j+=e.m,m+=i.m,k+=f.m;g&&!ve(f)&&(f.t=g,f.m+=l-k),e&&!ue(i)&&(i.t=e,i.m+=j-m,c=a)}return c}function f(a){a.x*=i[0],a.y=a.depth*i[1]}var g=Sf.layout.hierarchy().sort(null).value(null),h=te,i=[1,1],j=null;return a.separation=function(b){return arguments.length?(h=b,a):h},a.size=function(b){return arguments.length?(j=null==(i=b)?f:null,a):j?null:i},a.nodeSize=function(b){return arguments.length?(j=null==(i=b)?null:f,a):j?i:null},Ud(a,g)},Sf.layout.cluster=function(){function a(a,f){var g,h=b.call(this,a,f),i=h[0],j=0;Wd(i,function(a){var b=a.children;b&&b.length?(a.x=Ae(b),a.y=ze(b)):(a.x=g?j+=c(a,g):0,a.y=0,g=a)});var k=Be(i),l=Ce(i),m=k.x-c(k,l)/2,n=l.x+c(l,k)/2;return Wd(i,e?function(a){a.x=(a.x-i.x)*d[0],a.y=(i.y-a.y)*d[1]}:function(a){a.x=(a.x-m)/(n-m)*d[0],a.y=(1-(i.y?a.y/i.y:1))*d[1]}),h}var b=Sf.layout.hierarchy().sort(null).value(null),c=te,d=[1,1],e=!1;return a.separation=function(b){return arguments.length?(c=b,a):c},a.size=function(b){return arguments.length?(e=null==(d=b),a):e?null:d},a.nodeSize=function(b){return arguments.length?(e=null!=(d=b),a):e?d:null},Ud(a,b)},Sf.layout.treemap=function(){function a(a,b){for(var c,d,e=-1,f=a.length;++e<f;)d=(c=a[e]).value*(0>b?0:b),c.area=isNaN(d)||0>=d?0:d}function b(c){var f=c.children;if(f&&f.length){var g,h,i,j=l(c),k=[],m=f.slice(),o=1/0,p="slice"===n?j.dx:"dice"===n?j.dy:"slice-dice"===n?1&c.depth?j.dy:j.dx:Math.min(j.dx,j.dy);for(a(m,j.dx*j.dy/c.value),k.area=0;(i=m.length)>0;)k.push(g=m[i-1]),k.area+=g.area,"squarify"!==n||(h=d(k,p))<=o?(m.pop(),o=h):(k.area-=k.pop().area,e(k,p,j,!1),p=Math.min(j.dx,j.dy),k.length=k.area=0,o=1/0);k.length&&(e(k,p,j,!0),k.length=k.area=0),f.forEach(b)}}function c(b){var d=b.children;if(d&&d.length){var f,g=l(b),h=d.slice(),i=[];for(a(h,g.dx*g.dy/b.value),i.area=0;f=h.pop();)i.push(f),i.area+=f.area,null!=f.z&&(e(i,f.z?g.dx:g.dy,g,!h.length),i.length=i.area=0);d.forEach(c)}}function d(a,b){for(var c,d=a.area,e=0,f=1/0,g=-1,h=a.length;++g<h;)(c=a[g].area)&&(f>c&&(f=c),c>e&&(e=c));return d*=d,b*=b,d?Math.max(b*e*o/d,d/(b*f*o)):1/0}function e(a,b,c,d){var e,f=-1,g=a.length,h=c.x,j=c.y,k=b?i(a.area/b):0;if(b==c.dx){for((d||k>c.dy)&&(k=c.dy);++f<g;)e=a[f],e.x=h,e.y=j,e.dy=k,h+=e.dx=Math.min(c.x+c.dx-h,k?i(e.area/k):0);e.z=!0,e.dx+=c.x+c.dx-h,c.y+=k,c.dy-=k}else{for((d||k>c.dx)&&(k=c.dx);++f<g;)e=a[f],e.x=h,e.y=j,e.dx=k,j+=e.dy=Math.min(c.y+c.dy-j,k?i(e.area/k):0);e.z=!1,e.dy+=c.y+c.dy-j,c.x+=k,c.dx-=k}}function f(d){var e=g||h(d),f=e[0];return f.x=0,f.y=0,f.dx=j[0],f.dy=j[1],g&&h.revalue(f),a([f],f.dx*f.dy/f.value),(g?c:b)(f),m&&(g=e),e}var g,h=Sf.layout.hierarchy(),i=Math.round,j=[1,1],k=null,l=De,m=!1,n="squarify",o=.5*(1+Math.sqrt(5));return f.size=function(a){return arguments.length?(j=a,f):j},f.padding=function(a){function b(b){var c=a.call(f,b,b.depth);return null==c?De(b):Ee(b,"number"==typeof c?[c,c,c,c]:c)}function c(b){return Ee(b,a)}if(!arguments.length)return k;var d;return l=null==(k=a)?De:"function"==(d=typeof a)?b:"number"===d?(a=[a,a,a,a],c):c,f},f.round=function(a){return arguments.length?(i=a?Math.round:Number,f):i!=Number},f.sticky=function(a){return arguments.length?(m=a,g=null,f):m},f.ratio=function(a){return arguments.length?(o=a,f):o},f.mode=function(a){return arguments.length?(n=a+"",f):n},Ud(f,h)},Sf.random={normal:function(a,b){var c=arguments.length;return 2>c&&(b=1),1>c&&(a=0),function(){var c,d,e;do c=2*Math.random()-1,d=2*Math.random()-1,e=c*c+d*d;while(!e||e>1);return a+b*c*Math.sqrt(-2*Math.log(e)/e)}},logNormal:function(){var a=Sf.random.normal.apply(Sf,arguments);return function(){return Math.exp(a())}},bates:function(a){var b=Sf.random.irwinHall(a);return function(){return b()/a}},irwinHall:function(a){return function(){for(var b=0,c=0;a>c;c++)b+=Math.random();return b}}},Sf.scale={};var ji={floor:xa,ceil:xa};Sf.scale.linear=function(){return Le([0,1],[0,1],md,!1)};var ki={s:1,g:1,p:1,r:1,e:1};Sf.scale.log=function(){return Te(Sf.scale.linear().domain([0,1]),10,!0,[1,10])};var li=Sf.format(".0e"),mi={floor:function(a){return-Math.ceil(-a)},ceil:function(a){return-Math.floor(-a)}};Sf.scale.pow=function(){return Ue(Sf.scale.linear(),1,[0,1])},Sf.scale.sqrt=function(){return Sf.scale.pow().exponent(.5)},Sf.scale.ordinal=function(){return We([],{t:"range",a:[[]]})},Sf.scale.category10=function(){return Sf.scale.ordinal().range(ni)},Sf.scale.category20=function(){return Sf.scale.ordinal().range(oi)},Sf.scale.category20b=function(){return Sf.scale.ordinal().range(pi)},Sf.scale.category20c=function(){return Sf.scale.ordinal().range(qi)};var ni=[2062260,16744206,2924588,14034728,9725885,9197131,14907330,8355711,12369186,1556175].map(pa),oi=[2062260,11454440,16744206,16759672,2924588,10018698,14034728,16750742,9725885,12955861,9197131,12885140,14907330,16234194,8355711,13092807,12369186,14408589,1556175,10410725].map(pa),pi=[3750777,5395619,7040719,10264286,6519097,9216594,11915115,13556636,9202993,12426809,15186514,15190932,8666169,11356490,14049643,15177372,8077683,10834324,13528509,14589654].map(pa),qi=[3244733,7057110,10406625,13032431,15095053,16616764,16625259,16634018,3253076,7652470,10607003,13101504,7695281,10394312,12369372,14342891,6513507,9868950,12434877,14277081].map(pa);Sf.scale.quantile=function(){return Xe([],[])},Sf.scale.quantize=function(){return Ye(0,1,[0,1])},Sf.scale.threshold=function(){return Ze([.5],[0,1])},Sf.scale.identity=function(){return $e([0,1])},Sf.svg={},Sf.svg.arc=function(){function a(){var a=b.apply(this,arguments),f=c.apply(this,arguments),g=d.apply(this,arguments)+ri,h=e.apply(this,arguments)+ri,i=(g>h&&(i=g,g=h,h=i),h-g),j=wg>i?"0":"1",k=Math.cos(g),l=Math.sin(g),m=Math.cos(h),n=Math.sin(h);return i>=si?a?"M0,"+f+"A"+f+","+f+" 0 1,1 0,"+-f+"A"+f+","+f+" 0 1,1 0,"+f+"M0,"+a+"A"+a+","+a+" 0 1,0 0,"+-a+"A"+a+","+a+" 0 1,0 0,"+a+"Z":"M0,"+f+"A"+f+","+f+" 0 1,1 0,"+-f+"A"+f+","+f+" 0 1,1 0,"+f+"Z":a?"M"+f*k+","+f*l+"A"+f+","+f+" 0 "+j+",1 "+f*m+","+f*n+"L"+a*m+","+a*n+"A"+a+","+a+" 0 "+j+",0 "+a*k+","+a*l+"Z":"M"+f*k+","+f*l+"A"+f+","+f+" 0 "+j+",1 "+f*m+","+f*n+"L0,0Z"}var b=_e,c=af,d=bf,e=cf;return a.innerRadius=function(c){return arguments.length?(b=wa(c),a):b},a.outerRadius=function(b){return arguments.length?(c=wa(b),a):c},a.startAngle=function(b){return arguments.length?(d=wa(b),a):d},a.endAngle=function(b){return arguments.length?(e=wa(b),a):e},a.centroid=function(){var a=(b.apply(this,arguments)+c.apply(this,arguments))/2,f=(d.apply(this,arguments)+e.apply(this,arguments))/2+ri;return[Math.cos(f)*a,Math.sin(f)*a]},a};var ri=-yg,si=xg-zg;Sf.svg.line=function(){return df(xa)};var ti=Sf.map({linear:ef,"linear-closed":ff,step:gf,"step-before":hf,"step-after":jf,basis:pf,"basis-open":qf,"basis-closed":rf,bundle:sf,cardinal:mf,"cardinal-open":kf,"cardinal-closed":lf,monotone:yf});ti.forEach(function(a,b){b.key=a,b.closed=/-closed$/.test(a)});var ui=[0,2/3,1/3,0],vi=[0,1/3,2/3,0],wi=[0,1/6,2/3,1/6];Sf.svg.line.radial=function(){var a=df(zf);return a.radius=a.x,delete a.x,a.angle=a.y,delete a.y,a},hf.reverse=jf,jf.reverse=hf,Sf.svg.area=function(){return Af(xa)},Sf.svg.area.radial=function(){var a=Af(zf);return a.radius=a.x,delete a.x,a.innerRadius=a.x0,delete a.x0,a.outerRadius=a.x1,delete a.x1,a.angle=a.y,delete a.y,a.startAngle=a.y0,delete a.y0,a.endAngle=a.y1,delete a.y1,a},Sf.svg.chord=function(){function a(a,h){var i=b(this,f,a,h),j=b(this,g,a,h);return"M"+i.p0+d(i.r,i.p1,i.a1-i.a0)+(c(i,j)?e(i.r,i.p1,i.r,i.p0):e(i.r,i.p1,j.r,j.p0)+d(j.r,j.p1,j.a1-j.a0)+e(j.r,j.p1,i.r,i.p0))+"Z"}function b(a,b,c,d){var e=b.call(a,c,d),f=h.call(a,e,d),g=i.call(a,e,d)+ri,k=j.call(a,e,d)+ri;return{r:f,a0:g,a1:k,p0:[f*Math.cos(g),f*Math.sin(g)],p1:[f*Math.cos(k),f*Math.sin(k)]}}function c(a,b){return a.a0==b.a0&&a.a1==b.a1}function d(a,b,c){return"A"+a+","+a+" 0 "+ +(c>wg)+",1 "+b}function e(a,b,c,d){return"Q 0,0 "+d}var f=nc,g=oc,h=Bf,i=bf,j=cf;return a.radius=function(b){return arguments.length?(h=wa(b),a):h},a.source=function(b){return arguments.length?(f=wa(b),a):f},a.target=function(b){return arguments.length?(g=wa(b),a):g},a.startAngle=function(b){return arguments.length?(i=wa(b),a):i},a.endAngle=function(b){return arguments.length?(j=wa(b),a):j},a},Sf.svg.diagonal=function(){function a(a,e){var f=b.call(this,a,e),g=c.call(this,a,e),h=(f.y+g.y)/2,i=[f,{x:f.x,y:h},{x:g.x,y:h},g];return i=i.map(d),"M"+i[0]+"C"+i[1]+" "+i[2]+" "+i[3]}var b=nc,c=oc,d=Cf;return a.source=function(c){return arguments.length?(b=wa(c),a):b},a.target=function(b){return arguments.length?(c=wa(b),a):c},a.projection=function(b){return arguments.length?(d=b,a):d},a},Sf.svg.diagonal.radial=function(){var a=Sf.svg.diagonal(),b=Cf,c=a.projection;return a.projection=function(a){return arguments.length?c(Df(b=a)):b},a},Sf.svg.symbol=function(){function a(a,d){return(xi.get(b.call(this,a,d))||Gf)(c.call(this,a,d))}var b=Ff,c=Ef;return a.type=function(c){return arguments.length?(b=wa(c),a):b},a.size=function(b){return arguments.length?(c=wa(b),a):c},a};var xi=Sf.map({circle:Gf,cross:function(a){var b=Math.sqrt(a/5)/2;return"M"+-3*b+","+-b+"H"+-b+"V"+-3*b+"H"+b+"V"+-b+"H"+3*b+"V"+b+"H"+b+"V"+3*b+"H"+-b+"V"+b+"H"+-3*b+"Z"},diamond:function(a){var b=Math.sqrt(a/(2*Bi)),c=b*Bi;return"M0,"+-b+"L"+c+",0 0,"+b+" "+-c+",0Z"},square:function(a){var b=Math.sqrt(a)/2;return"M"+-b+","+-b+"L"+b+","+-b+" "+b+","+b+" "+-b+","+b+"Z"},"triangle-down":function(a){var b=Math.sqrt(a/Ai),c=b*Ai/2;return"M0,"+c+"L"+b+","+-c+" "+-b+","+-c+"Z"},"triangle-up":function(a){var b=Math.sqrt(a/Ai),c=b*Ai/2;return"M0,"+-c+"L"+b+","+c+" "+-b+","+c+"Z"}});Sf.svg.symbolTypes=xi.keys();var yi,zi,Ai=Math.sqrt(3),Bi=Math.tan(30*Bg),Ci=[],Di=0;Ci.call=og.call,Ci.empty=og.empty,Ci.node=og.node,Ci.size=og.size,Sf.transition=function(a){return arguments.length?yi?a.transition():a:rg.transition()},Sf.transition.prototype=Ci,Ci.select=function(a){var b,c,d,e=this.id,f=[];a=w(a);for(var g=-1,h=this.length;++g<h;){f.push(b=[]);for(var i=this[g],j=-1,k=i.length;++j<k;)(d=i[j])&&(c=a.call(d,d.__data__,j,g))?("__data__"in d&&(c.__data__=d.__data__),Kf(c,j,e,d.__transition__[e]),b.push(c)):b.push(null)}return Hf(f,e)},Ci.selectAll=function(a){var b,c,d,e,f,g=this.id,h=[];a=x(a);for(var i=-1,j=this.length;++i<j;)for(var k=this[i],l=-1,m=k.length;++l<m;)if(d=k[l]){f=d.__transition__[g],c=a.call(d,d.__data__,l,i),h.push(b=[]);for(var n=-1,o=c.length;++n<o;)(e=c[n])&&Kf(e,n,g,f),b.push(e)}return Hf(h,g)},Ci.filter=function(a){var b,c,d,e=[];"function"!=typeof a&&(a=I(a));for(var f=0,g=this.length;g>f;f++){e.push(b=[]);for(var c=this[f],h=0,i=c.length;i>h;h++)(d=c[h])&&a.call(d,d.__data__,h,f)&&b.push(d)}return Hf(e,this.id)},Ci.tween=function(a,b){var c=this.id;return arguments.length<2?this.node().__transition__[c].tween.get(a):K(this,null==b?function(b){b.__transition__[c].tween.remove(a)}:function(d){d.__transition__[c].tween.set(a,b)})},Ci.attr=function(a,b){function c(){this.removeAttribute(h)}function d(){this.removeAttributeNS(h.space,h.local)}function e(a){return null==a?c:(a+="",function(){var b,c=this.getAttribute(h);return c!==a&&(b=g(c,a),function(a){this.setAttribute(h,b(a))})})}function f(a){return null==a?d:(a+="",function(){var b,c=this.getAttributeNS(h.space,h.local);return c!==a&&(b=g(c,a),function(a){this.setAttributeNS(h.space,h.local,b(a))})})}if(arguments.length<2){for(b in a)this.attr(b,a[b]);return this}var g="transform"==a?Jd:md,h=Sf.ns.qualify(a);return If(this,"attr."+a,b,h.local?f:e)},Ci.attrTween=function(a,b){function c(a,c){var d=b.call(this,a,c,this.getAttribute(e));return d&&function(a){this.setAttribute(e,d(a))}}function d(a,c){var d=b.call(this,a,c,this.getAttributeNS(e.space,e.local));return d&&function(a){this.setAttributeNS(e.space,e.local,d(a))}}var e=Sf.ns.qualify(a);return this.tween("attr."+a,e.local?d:c)},Ci.style=function(a,b,c){function d(){this.style.removeProperty(a)}function e(b){return null==b?d:(b+="",function(){var d,e=Xf.getComputedStyle(this,null).getPropertyValue(a);return e!==b&&(d=md(e,b),function(b){this.style.setProperty(a,d(b),c)})})}var f=arguments.length;if(3>f){if("string"!=typeof a){2>f&&(b="");for(c in a)this.style(c,a[c],b);return this}c=""}return If(this,"style."+a,b,e)},Ci.styleTween=function(a,b,c){function d(d,e){var f=b.call(this,d,e,Xf.getComputedStyle(this,null).getPropertyValue(a));return f&&function(b){this.style.setProperty(a,f(b),c)}}return arguments.length<3&&(c=""),this.tween("style."+a,d)},Ci.text=function(a){return If(this,"text",a,Jf)},Ci.remove=function(){return this.each("end.transition",function(){var a;this.__transition__.count<2&&(a=this.parentNode)&&a.removeChild(this)})},Ci.ease=function(a){var b=this.id;return arguments.length<1?this.node().__transition__[b].ease:("function"!=typeof a&&(a=Sf.ease.apply(Sf,arguments)),K(this,function(c){c.__transition__[b].ease=a}))},Ci.delay=function(a){var b=this.id;return arguments.length<1?this.node().__transition__[b].delay:K(this,"function"==typeof a?function(c,d,e){c.__transition__[b].delay=+a.call(c,c.__data__,d,e)}:(a=+a,function(c){c.__transition__[b].delay=a}))},Ci.duration=function(a){var b=this.id;return arguments.length<1?this.node().__transition__[b].duration:K(this,"function"==typeof a?function(c,d,e){c.__transition__[b].duration=Math.max(1,a.call(c,c.__data__,d,e))}:(a=Math.max(1,a),function(c){c.__transition__[b].duration=a}))},Ci.each=function(a,b){var c=this.id;if(arguments.length<2){var d=zi,e=yi;yi=c,K(this,function(b,d,e){zi=b.__transition__[c],a.call(b,b.__data__,d,e)}),zi=d,yi=e}else K(this,function(d){var e=d.__transition__[c];(e.event||(e.event=Sf.dispatch("start","end"))).on(a,b)});return this},Ci.transition=function(){for(var a,b,c,d,e=this.id,f=++Di,g=[],h=0,i=this.length;i>h;h++){g.push(a=[]);for(var b=this[h],j=0,k=b.length;k>j;j++)(c=b[j])&&(d=Object.create(c.__transition__[e]),d.delay+=d.duration,Kf(c,j,f,d)),a.push(c)}return Hf(g,f)},Sf.svg.axis=function(){function a(a){a.each(function(){var a,j=Sf.select(this),k=this.__chart__||c,l=this.__chart__=c.copy(),m=null==i?l.ticks?l.ticks.apply(l,h):l.domain():i,n=null==b?l.tickFormat?l.tickFormat.apply(l,h):xa:b,o=j.selectAll(".tick").data(m,l),p=o.enter().insert("g",".domain").attr("class","tick").style("opacity",zg),q=Sf.transition(o.exit()).style("opacity",zg).remove(),r=Sf.transition(o.order()).style("opacity",1),s=Ge(l),t=j.selectAll(".domain").data([0]),u=(t.enter().append("path").attr("class","domain"),Sf.transition(t));p.append("line"),p.append("text");var v=p.select("line"),w=r.select("line"),x=o.select("text").text(n),y=p.select("text"),z=r.select("text");switch(d){case"bottom":a=Lf,v.attr("y2",e),y.attr("y",Math.max(e,0)+g),w.attr("x2",0).attr("y2",e),z.attr("x",0).attr("y",Math.max(e,0)+g),x.attr("dy",".71em").style("text-anchor","middle"),u.attr("d","M"+s[0]+","+f+"V0H"+s[1]+"V"+f);break;case"top":a=Lf,v.attr("y2",-e),y.attr("y",-(Math.max(e,0)+g)),w.attr("x2",0).attr("y2",-e),z.attr("x",0).attr("y",-(Math.max(e,0)+g)),x.attr("dy","0em").style("text-anchor","middle"),u.attr("d","M"+s[0]+","+-f+"V0H"+s[1]+"V"+-f);break;case"left":a=Mf,v.attr("x2",-e),y.attr("x",-(Math.max(e,0)+g)),w.attr("x2",-e).attr("y2",0),z.attr("x",-(Math.max(e,0)+g)).attr("y",0),x.attr("dy",".32em").style("text-anchor","end"),u.attr("d","M"+-f+","+s[0]+"H0V"+s[1]+"H"+-f);break;case"right":a=Mf,v.attr("x2",e),y.attr("x",Math.max(e,0)+g),w.attr("x2",e).attr("y2",0),z.attr("x",Math.max(e,0)+g).attr("y",0),x.attr("dy",".32em").style("text-anchor","start"),u.attr("d","M"+f+","+s[0]+"H0V"+s[1]+"H"+f)}if(l.rangeBand){var A=l,B=A.rangeBand()/2;k=l=function(a){return A(a)+B}}else k.rangeBand?k=l:q.call(a,l);p.call(a,k),r.call(a,l)})}var b,c=Sf.scale.linear(),d=Ei,e=6,f=6,g=3,h=[10],i=null;return a.scale=function(b){return arguments.length?(c=b,a):c},a.orient=function(b){return arguments.length?(d=b in Fi?b+"":Ei,a):d},a.ticks=function(){return arguments.length?(h=arguments,a):h},a.tickValues=function(b){return arguments.length?(i=b,a):i},a.tickFormat=function(c){return arguments.length?(b=c,a):b},a.tickSize=function(b){var c=arguments.length;return c?(e=+b,
16
16
  f=+arguments[c-1],a):e},a.innerTickSize=function(b){return arguments.length?(e=+b,a):e},a.outerTickSize=function(b){return arguments.length?(f=+b,a):f},a.tickPadding=function(b){return arguments.length?(g=+b,a):g},a.tickSubdivide=function(){return arguments.length&&a},a};var Ei="bottom",Fi={top:1,right:1,bottom:1,left:1};Sf.svg.brush=function(){function a(f){f.each(function(){var f=Sf.select(this).style("pointer-events","all").style("-webkit-tap-highlight-color","rgba(0,0,0,0)").on("mousedown.brush",e).on("touchstart.brush",e),g=f.selectAll(".background").data([0]);g.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),f.selectAll(".extent").data([0]).enter().append("rect").attr("class","extent").style("cursor","move");var h=f.selectAll(".resize").data(o,xa);h.exit().remove(),h.enter().append("g").attr("class",function(a){return"resize "+a}).style("cursor",function(a){return Gi[a]}).append("rect").attr("x",function(a){return/[ew]$/.test(a)?-3:null}).attr("y",function(a){return/^[ns]/.test(a)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),h.style("display",a.empty()?"none":null);var k,l=Sf.transition(f),m=Sf.transition(g);i&&(k=Ge(i),m.attr("x",k[0]).attr("width",k[1]-k[0]),c(l)),j&&(k=Ge(j),m.attr("y",k[0]).attr("height",k[1]-k[0]),d(l)),b(l)})}function b(a){a.selectAll(".resize").attr("transform",function(a){return"translate("+k[+/e$/.test(a)]+","+l[+/^s/.test(a)]+")"})}function c(a){a.select(".extent").attr("x",k[0]),a.selectAll(".extent,.n>rect,.s>rect").attr("width",k[1]-k[0])}function d(a){a.select(".extent").attr("y",l[0]),a.selectAll(".extent,.e>rect,.w>rect").attr("height",l[1]-l[0])}function e(){function e(){32==Sf.event.keyCode&&(C||(t=null,E[0]-=k[1],E[1]-=l[1],C=2),s())}function o(){32==Sf.event.keyCode&&2==C&&(E[0]+=k[1],E[1]+=l[1],C=0,s())}function p(){var a=Sf.mouse(v),e=!1;u&&(a[0]+=u[0],a[1]+=u[1]),C||(Sf.event.altKey?(t||(t=[(k[0]+k[1])/2,(l[0]+l[1])/2]),E[0]=k[+(a[0]<t[0])],E[1]=l[+(a[1]<t[1])]):t=null),A&&q(a,i,0)&&(c(y),e=!0),B&&q(a,j,1)&&(d(y),e=!0),e&&(b(y),x({type:"brush",mode:C?"move":"resize"}))}function q(a,b,c){var d,e,h=Ge(b),i=h[0],j=h[1],o=E[c],p=c?l:k,q=p[1]-p[0];return C&&(i-=o,j-=q+o),d=(c?n:m)?Math.max(i,Math.min(j,a[c])):a[c],C?e=(d+=o)+q:(t&&(o=Math.max(i,Math.min(j,2*t[c]-d))),d>o?(e=d,d=o):e=o),p[0]!=d||p[1]!=e?(c?g=null:f=null,p[0]=d,p[1]=e,!0):void 0}function r(){p(),y.style("pointer-events","all").selectAll(".resize").style("display",a.empty()?"none":null),Sf.select("body").style("cursor",null),F.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),D(),x({type:"brushend"})}var t,u,v=this,w=Sf.select(Sf.event.target),x=h.of(v,arguments),y=Sf.select(v),z=w.datum(),A=!/^(n|s)$/.test(z)&&i,B=!/^(e|w)$/.test(z)&&j,C=w.classed("extent"),D=R(),E=Sf.mouse(v),F=Sf.select(Xf).on("keydown.brush",e).on("keyup.brush",o);if(Sf.event.changedTouches?F.on("touchmove.brush",p).on("touchend.brush",r):F.on("mousemove.brush",p).on("mouseup.brush",r),y.interrupt().selectAll("*").interrupt(),C)E[0]=k[0]-E[0],E[1]=l[0]-E[1];else if(z){var G=+/w$/.test(z),H=+/^n/.test(z);u=[k[1-G]-E[0],l[1-H]-E[1]],E[0]=k[G],E[1]=l[H]}else Sf.event.altKey&&(t=E.slice());y.style("pointer-events","none").selectAll(".resize").style("display",null),Sf.select("body").style("cursor",w.style("cursor")),x({type:"brushstart"}),p()}var f,g,h=u(a,"brushstart","brush","brushend"),i=null,j=null,k=[0,0],l=[0,0],m=!0,n=!0,o=Hi[0];return a.event=function(a){a.each(function(){var a=h.of(this,arguments),b={x:k,y:l,i:f,j:g},c=this.__chart__||b;this.__chart__=b,yi?Sf.select(this).transition().each("start.brush",function(){f=c.i,g=c.j,k=c.x,l=c.y,a({type:"brushstart"})}).tween("brush:brush",function(){var c=nd(k,b.x),d=nd(l,b.y);return f=g=null,function(e){k=b.x=c(e),l=b.y=d(e),a({type:"brush",mode:"resize"})}}).each("end.brush",function(){f=b.i,g=b.j,a({type:"brush",mode:"resize"}),a({type:"brushend"})}):(a({type:"brushstart"}),a({type:"brush",mode:"resize"}),a({type:"brushend"}))})},a.x=function(b){return arguments.length?(i=b,o=Hi[!i<<1|!j],a):i},a.y=function(b){return arguments.length?(j=b,o=Hi[!i<<1|!j],a):j},a.clamp=function(b){return arguments.length?(i&&j?(m=!!b[0],n=!!b[1]):i?m=!!b:j&&(n=!!b),a):i&&j?[m,n]:i?m:j?n:null},a.extent=function(b){var c,d,e,h,m;return arguments.length?(i&&(c=b[0],d=b[1],j&&(c=c[0],d=d[0]),f=[c,d],i.invert&&(c=i(c),d=i(d)),c>d&&(m=c,c=d,d=m),(c!=k[0]||d!=k[1])&&(k=[c,d])),j&&(e=b[0],h=b[1],i&&(e=e[1],h=h[1]),g=[e,h],j.invert&&(e=j(e),h=j(h)),e>h&&(m=e,e=h,h=m),(e!=l[0]||h!=l[1])&&(l=[e,h])),a):(i&&(f?(c=f[0],d=f[1]):(c=k[0],d=k[1],i.invert&&(c=i.invert(c),d=i.invert(d)),c>d&&(m=c,c=d,d=m))),j&&(g?(e=g[0],h=g[1]):(e=l[0],h=l[1],j.invert&&(e=j.invert(e),h=j.invert(h)),e>h&&(m=e,e=h,h=m))),i&&j?[[c,e],[d,h]]:i?[c,d]:j&&[e,h])},a.clear=function(){return a.empty()||(k=[0,0],l=[0,0],f=g=null),a},a.empty=function(){return!!i&&k[0]==k[1]||!!j&&l[0]==l[1]},Sf.rebind(a,h,"on")};var Gi={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Hi=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]],Ii=_g.format=fh.timeFormat,Ji=Ii.utc,Ki=Ji("%Y-%m-%dT%H:%M:%S.%LZ");Ii.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Nf:Ki,Nf.parse=function(a){var b=new Date(a);return isNaN(b)?null:b},Nf.toString=Ki.toString,_g.second=Ja(function(a){return new ah(1e3*Math.floor(a/1e3))},function(a,b){a.setTime(a.getTime()+1e3*Math.floor(b))},function(a){return a.getSeconds()}),_g.seconds=_g.second.range,_g.seconds.utc=_g.second.utc.range,_g.minute=Ja(function(a){return new ah(6e4*Math.floor(a/6e4))},function(a,b){a.setTime(a.getTime()+6e4*Math.floor(b))},function(a){return a.getMinutes()}),_g.minutes=_g.minute.range,_g.minutes.utc=_g.minute.utc.range,_g.hour=Ja(function(a){var b=a.getTimezoneOffset()/60;return new ah(36e5*(Math.floor(a/36e5-b)+b))},function(a,b){a.setTime(a.getTime()+36e5*Math.floor(b))},function(a){return a.getHours()}),_g.hours=_g.hour.range,_g.hours.utc=_g.hour.utc.range,_g.month=Ja(function(a){return a=_g.day(a),a.setDate(1),a},function(a,b){a.setMonth(a.getMonth()+b)},function(a){return a.getMonth()}),_g.months=_g.month.range,_g.months.utc=_g.month.utc.range;var Li=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Mi=[[_g.second,1],[_g.second,5],[_g.second,15],[_g.second,30],[_g.minute,1],[_g.minute,5],[_g.minute,15],[_g.minute,30],[_g.hour,1],[_g.hour,3],[_g.hour,6],[_g.hour,12],[_g.day,1],[_g.day,2],[_g.week,1],[_g.month,1],[_g.month,3],[_g.year,1]],Ni=Ii.multi([[".%L",function(a){return a.getMilliseconds()}],[":%S",function(a){return a.getSeconds()}],["%I:%M",function(a){return a.getMinutes()}],["%I %p",function(a){return a.getHours()}],["%a %d",function(a){return a.getDay()&&1!=a.getDate()}],["%b %d",function(a){return 1!=a.getDate()}],["%B",function(a){return a.getMonth()}],["%Y",xb]]),Oi={range:function(a,b,c){return Sf.range(Math.ceil(a/c)*c,+b,c).map(Pf)},floor:xa,ceil:xa};Mi.year=_g.year,_g.scale=function(){return Of(Sf.scale.linear(),Mi,Ni)};var Pi=Mi.map(function(a){return[a[0].utc,a[1]]}),Qi=Ji.multi([[".%L",function(a){return a.getUTCMilliseconds()}],[":%S",function(a){return a.getUTCSeconds()}],["%I:%M",function(a){return a.getUTCMinutes()}],["%I %p",function(a){return a.getUTCHours()}],["%a %d",function(a){return a.getUTCDay()&&1!=a.getUTCDate()}],["%b %d",function(a){return 1!=a.getUTCDate()}],["%B",function(a){return a.getUTCMonth()}],["%Y",xb]]);Pi.year=_g.year.utc,_g.scale.utc=function(){return Of(Sf.scale.linear(),Pi,Qi)},Sf.text=ya(function(a){return a.responseText}),Sf.json=function(a,b){return za(a,"application/json",Qf,b)},Sf.html=function(a,b){return za(a,"text/html",Rf,b)},Sf.xml=ya(function(a){return a.responseXML}),"function"==typeof define&&define.amd?define(Sf):"object"==typeof module&&module.exports&&(module.exports=Sf),this.d3=Sf}(),require=function c(a,b,d){function e(g,h){if(!b[g]){if(!a[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=b[g]={exports:{}};a[g][0].call(k.exports,function(b){var c=a[g][1][b];return e(c?c:b)},k,k.exports,c,a,b,d)}return b[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(c,d){$.browser=c("jquery-browser-plugin");var e=c("js-class"),f="onSelectionChange",g="onSelectionChanged",h="onAnnotationClicked";Sequence=e({constructor:function(a){var b=this;this.opt=jQuery.extend(this.opt,a),this._container=jQuery(this.opt.target),0==this._container.length&&(this._container=jQuery("#"+this.opt.target)),0==this._container.length&&console.log("empty target container"),this.opt.target=this._container[0].id,this._container.ready(function(){b._initialize()})},opt:{sequence:"",id:"",target:"",format:"FASTA",selection:{start:0,end:0},columns:{size:35,spacedEach:10},highlights:[],annotations:[],sequenceUrl:"http://www.ebi.ac.uk/das-srv/uniprot/das/uniprot/sequence",selectionColor:"Yellow",selectionFontColor:"black",highlightFontColor:"red",highlightBackgroundColor:"white",fontColor:"inherit",backgroundColor:"inherit",width:void 0,height:void 0,formatSelectorVisible:!0},eventTypes:["onSelectionChanged","onSelectionChange","onAnnotationClicked"],getId:function(){return this.opt.id},_headerDiv:null,_contentDiv:null,_initialize:function(){void 0!==this.opt.width&&this._container.width(this.opt.width),void 0!==this.opt.height&&this._container.height(this.opt.height),this._buildFormatSelector(),this._contentDiv=jQuery("<div/>").appendTo(this._container),this._highlights=this.opt.highlights,this._annotations=this.opt.annotations;var a="sequenceTip"+this.opt.target;jQuery('<div id="'+a+'"></div>').css({position:"absolute","z-index":"999999",color:"#fff","font-size":"12px",width:"auto",display:"none"}).addClass("tooltip").appendTo("body").hide(),this.opt._tooltip=document.getElementById(a),this.opt.sequence?this._redraw():this.opt.id?this._requestSequence(this.opt.id):this.clearSequence("No sequence available","../biojs/css/images/warning_icon.png")},setSequence:function(a,b){a.match(/^([A-N,R-Z][0-9][A-Z][A-Z, 0-9][A-Z, 0-9][0-9])|([O,P,Q][0-9][A-Z, 0-9][A-Z, 0-9][A-Z, 0-9][0-9])(\.\d+)?$/i)?this._requestSequence(arguments[0]):(this.opt.sequence=a,this.opt.id=b,this._highlights=[],this._highlightsCount=0,this.opt.selection={start:0,end:0},this._annotations=[],this._contentDiv.children().remove(),this._redraw())},_requestSequence:function(a){var b=this;console.log("Requesting sequence for: "+a),jQuery.ajax({url:b.opt.sequenceUrl,dataType:"xml",data:{segment:a},success:function(a){try{var c=jQuery(a).find("SEQUENCE:first");b.setSequence(c.text(),c.attr("id"),c.attr("label"))}catch(d){console.log("Error decoding response data: "+d.message),b.clearSequence("No sequence available","../biojs/css/images/warning_icon.png")}},error:function(a,c){console.log("Error decoding response data: "+c),b.clearSequence("Error requesting the sequence to the server "+this.url,"../biojs/css/images/warning_icon.png")}})},clearSequence:function(a,b){var c=void 0;this.opt.sequence="",this.opt.id="",this._highlights=[],this._highlightsCount=0,this.opt.selection={start:0,end:0},this._annotations=[],this._contentDiv.children().remove(),this._headerDiv.hide(),void 0!==a&&(c=jQuery("<div>"+a+"</div>").appendTo(this._contentDiv).addClass("message"),void 0!==b&&c.css({background:'transparent url("'+b+'") no-repeat center left',"padding-left":"20px"}))},setSelection:function(a,b){if(a>b){var c=b;b=a,a=c}(a!=this.opt.selection.start||b!=this.opt.selection.end)&&(this._setSelection(a,b),this.trigger(g,{start:a,end:b}))},_buildFormatSelector:function(){var a=this;this._headerDiv=jQuery("<div></div>").appendTo(this._container),this._headerDiv.append("Format: "),this._formatSelector=jQuery('<select> <option value="FASTA">FASTA</option><option value="CODATA">CODATA</option><option value="PRIDE">PRIDE</option><option value="RAW">RAW</option></select>').appendTo(a._headerDiv),this._formatSelector.change(function(){a.opt.format=jQuery(this).val(),a._redraw()}),this._formatSelector.val(a.opt.format),this.formatSelectorVisible(this.opt.formatSelectorVisible)},addHighlight:function(a){var b="-1",c="",d="",e={};return a instanceof Object&&a.start<=a.end&&(c="string"==typeof a.color?a.color:this.opt.highlightFontColor,d="string"==typeof a.background?a.background:this.opt.highlightBackgroundColor,b="string"==typeof a.id?a.id:new Number(this._highlightsCount++).toString(),e={start:a.start,end:a.end,color:c,background:d,id:b},this._highlights.push(e),this._applyHighlight(e),this._restoreSelection(a.start,a.end)),b},_applyHighlight:function(a){for(var b=this._contentDiv.find(".sequence"),c=a.start-1;c<a.end;c++)zindex=jQuery(b[c]).css("z-index"),"auto"==zindex?(z=1,o=1):(z=0,o=.5),jQuery(b[c]).css({color:a.color,"background-color":a.background,"z-index":z,opacity:o}).addClass("highlighted")},_applyHighlights:function(a){for(var b in a)this._applyHighlight(a[b])},_restoreHighlights:function(c,d){var e=this._highlights;this._applyHighlight({start:c,end:d,color:this.opt.fontColor,background:this.opt.backgroundColor});for(var f in e)e[f].start>d||e[f].end<c||(a=e[f].start<c?c:e[f].start,b=e[f].end>d?d:e[f].end,this._applyHighlight({start:a,end:b,color:e[f].color,background:e[f].background}))},_restoreSelection:function(c,d){var e=this.opt.selection;c>e.end||d<e.start||(a=c<e.start?e.start:c,b=d>e.end?e.end:d,this._applyHighlight({start:a,end:b,color:this.opt.selectionFontColor,background:this.opt.selectionColor}))},removeHighlight:function(a){var b=this._highlights;for(i in b)if(b[i].id==a){start=b[i].start,end=b[i].end,b.splice(i,1),this._restoreHighlights(start,end),this._restoreSelection(start,end);break}},removeAllHighlights:function(){this._highlights=[],this._restoreHighlights(1,this.opt.sequence.length),this._restoreSelection(1,this.opt.sequence.length)},setFormat:function(a){this.opt.format!=a.toUpperCase()&&(this.opt.format=a.toUpperCase(),this._redraw());var b=this;this._headerDiv.find("option").each(function(){jQuery(this).val()==b.opt.format.toUpperCase()&&jQuery(this).attr("selected","selected")})},setNumCols:function(a){this.opt.columns.size=a,this._redraw()},formatSelectorVisible:function(a){a?this._headerDiv.show():this._headerDiv.hide()},showFormatSelector:function(){this._headerDiv.show()},hideFormatSelector:function(){this._headerDiv.hide()},hide:function(){this._headerDiv.hide(),this._contentDiv.hide()},show:function(){this._headerDiv.show(),this._contentDiv.show()},_setSelection:function(a,b){var c=this.opt.selection,d={};c.start==a?c.end<b?(d.start=c.end,d.end=b):this._restoreHighlights(b+1,c.end):c.end==b?c.start>a?(d.start=a,d.end=c.start):this._restoreHighlights(c.start,a-1):(this._restoreHighlights(c.start,c.end),d.start=a,d.end=b),c.start=a,c.end=b},_repaintSelection:function(){var a=this.opt.selection;this._setSelection(0,0),this._setSelection(a.start,a.end)},_redraw:function(){this._contentDiv.children().remove(),"RAW"==this.opt.format?this._drawRaw():"CODATA"==this.opt.format?this._drawCodata():"FASTA"==this.opt.format?this._drawFasta():(this.opt.format="PRIDE",this._drawPride()),this._applyHighlights(this._highlights),this._repaintSelection(),this._addSpanEvents()},_drawFasta:function(){var a=this.opt.sequence.toUpperCase().split(""),b=jQuery("<pre></pre>").appendTo(this._contentDiv),c=">"+this.opt.id+" "+a.length+" bp<br/>",d=this.opt.columns.size;this.opt.sequence.length<this.opt.columns.size&&(d=this.opt.sequence.length);var e={numCols:d,numColsForSpace:0};c+=this._drawSequence(a,e),b.html(c),this._drawAnnotations(e)},_drawCodata:function(){var a=this.opt.sequence.toUpperCase().split("");if(void 0!==this.opt.formatOptions&&void 0!==this.opt.formatOptions.title&&0!=this.opt.formatOptions.title){var b=$("<pre/>").addClass("header").appendTo(this._contentDiv);b.html("ENTRY "+this.opt.id+"<br/>SEQUENCE<br/>")}var c=this.opt.columns.size;this.opt.sequence.length<this.opt.columns.size&&(c=this.opt.sequence.length);var d={numLeft:!0,numLeftSize:7,numLeftPad:" ",numTop:!0,numTopEach:5,numCols:c,numColsForSpace:0,spaceBetweenChars:!0};if(this._drawSequence(a,d),void 0!==this.opt.formatOptions&&void 0!==this.opt.formatOptions.footer&&0!=this.opt.formatOptions.footer){var e=$("<pre/>").addClass("footer").appendTo(this._contentDiv);e.html("<br/>///")}this._drawAnnotations(d)},_drawAnnotations:function(a){var b=this,c=this.opt.sequence.toLowerCase().split(""),d=this._annotations,e="",f="",g="";a.numLeft&&(e+=this._formatIndex(" ",a.numLeftSize+2," "));for(var i=0;i<c.length;i+=a.numCols){f="";for(var j in d)d[j].id=this.getId()+"_"+j,g=this._getHTMLRowAnnot(i+1,d[j],a),g.length>0&&(f+="<br/>",f+=e,f+=g,f+="<br/>");var k=a.numCols,l=c.length-i;k>l&&(k=l),jQuery(f).insertAfter(a.numRight?"div#"+b.opt.target+" div pre span#numRight_"+this.getId()+"_"+(i+k):"div#"+b.opt.target+" div pre span#"+this.getId()+"_"+(i+k))}jQuery(this._contentDiv).find(".annotation").each(function(){b._addToolTip(this,function(){return b._getAnnotationString(jQuery(this).attr("id"))}),jQuery(this).mouseover(function(a){jQuery(".annotation."+jQuery(a.target).attr("id")).each(function(){jQuery(this).css("background-color",jQuery(this).attr("color"))})}).mouseout(function(){jQuery(".annotation").css("background-color","transparent")}).click(function(a){for(var c=void 0,d=jQuery(a.target).attr("id"),e=0;e<b._annotations.length;e++)b._annotations[e].id!=d||(c=b._annotations[e].name);b.trigger(h,{name:c})})})},_getAnnotationString:function(a){var b=this._annotations[a.substr(a.indexOf("_")+1)];return b.name+"<br/>"+(b.html?b.html:"")},_getHTMLRowAnnot:function(a,b,c){for(var d="border-left:1px solid; border-bottom:1px solid; border-color:",e="border-bottom:1px solid; border-color:",f="border-bottom:1px solid; border-right:1px solid; border-color:",g="border-left:1px solid; border-right:1px solid; border-bottom:1px solid; border-color:",h=[],i=a+c.numCols,j=c.spaceBetweenChars?" ":"",k=b.color,l=b.id,m=a;i>m;m++)for(var n in b.regions)region=b.regions[n],spaceAfter="",spaceAfter+=m%c.numColsForSpace==0?" ":"",spaceAfter+=j,color=region.color?region.color:k,data='class="annotation '+l+'" id="'+l+'" color="'+color+'" pos="'+m+'"',m==region.start&&m==region.end?(h[m]='<span style="'+g+color+'" '+data+"> ",h[m]+=spaceAfter,h[m]+="</span>"):m==region.start?(h[m]='<span style="'+d+color+'" '+data+"> ",h[m]+=spaceAfter,h[m]+="</span>"):m==region.end?(h[m]='<span style="'+f+color+' " '+data+"> ",h[m]+="</span>"):m>region.start&&m<region.end?(h[m]='<span style="'+e+color+'" '+data+"> ",h[m]+=spaceAfter,h[m]+="</span>"):h[m]||(h[m]=" ",h[m]+=spaceAfter);var o=h.join("");return-1==o.indexOf("span")?"":o},_drawRaw:function(){var a=this.opt.sequence.toLowerCase().split(""),b=jQuery("<pre></pre>").appendTo(this._contentDiv),c=this.opt.columns.size;this.opt.sequence.length<this.opt.columns.size&&(c=this.opt.sequence.length);var d={numCols:c};b.html(this._drawSequence(a,d)),this._drawAnnotations(d)},_drawPride:function(){var a=this.opt.sequence.toUpperCase().split(""),b=this.opt.columns.size;this.opt.sequence.length<this.opt.columns.size&&(b=this.opt.sequence.length),opt={numLeft:!0,numLeftSize:5,numLeftPad:" ",numRight:!1,numRightSize:5,numRightPad:"",numCols:b,numColsForSpace:this.opt.columns.spacedEach},this._drawSequence(a,opt),this._drawAnnotations(opt)},_drawSequence:function(a,b){var c="",d="",e="\n",f="";if(b.numTop){d+='<span class="numTop pos-marker">';var g=b.spaceBetweenChars?2*b.numTopEach:b.numTopEach;b.numLeft&&(d+=this._formatIndex(" ",b.numLeftSize," ")),d+=this._formatIndex(" ",g," ");for(var h=b.numTopEach;h<b.numCols;h+=b.numTopEach)d+=this._formatIndex(h,g," ",!0);d+="</span>"}b.numLeft&&(c+='<span id="numLeft_'+this.getId()+'_0"',c+='class="pos-marker">',c+=this._formatIndex(1,b.numLeftSize,b.numLeftPad),c+=" ",c+="</span>",c+="\n");for(var i=1,j=1;j<=a.length;j++)if(j%b.numCols==0){f+='<span class="sequence" id="'+this.getId()+"_"+j+'">'+a[j-1]+"</span>",b.numRight&&(e+='<span id="numRight_'+this.getId()+"_"+j+'"',e+='class="pos-marker">',e+=" ",e+=this._formatIndex(j,b.numRightSize,b.numRightPad),e+="</span>",e+="\n"),f+="<br/>";var k=a.length-j;b.numLeft&&k>0&&(c+='<span id="numLeft_'+this.getId()+"_"+j+'"',c+='class="pos-marker">',c+=this._formatIndex(j+1,b.numLeftSize,b.numLeftPad),c+=" ",c+="</span>",c+="\n"),i=1}else f+='<span class="sequence" id="'+this.getId()+"_"+j+'"',f+=i%b.numColsForSpace==0?' style="letter-spacing: 1em;"':"",f+=b.spaceBetweenChars?' style="letter-spacing: 1em;"':"",f+='">'+a[j-1],f+="</span>",i++;f+="<br/>",jQuery.browser.msie&&(f="<pre>"+f+"</pre>");return b.numTop&&$("<pre/>").html(d).addClass("indT").css({color:"#aaa"}).appendTo(this._contentDiv),b.numLeft&&$("<pre/>").html(c).addClass("indL").css({color:"#aaa",display:"inline-block"}).appendTo(this._contentDiv),$("<pre/>").html(f).addClass("seqF").css({display:"inline-block"}).appendTo(this._contentDiv),b.numRight&&$("<pre/>").html(e).addClass("indR").css({color:"#aaa",display:"inline-block"}).appendTo(this._contentDiv),f},_formatIndex:function(a,b,c,d){var e=a.toString(),f="",g=b-e.length;if(g>0){for(;g-->0;)f+="<span>"+c+"</span>";e=d?a+f:f+a}return e},_addSpanEvents:function(){var a,b,c=this,d=!1;c._contentDiv.find(".sequence").each(function(){jQuery(this).mousedown(function(){var e=jQuery(this).attr("id");b=parseInt(e.substr(e.indexOf("_")+1)),a=b,c._setSelection(a,b),d=!0,c.trigger(f,{start:c.opt.selection.start,end:c.opt.selection.end})}).mouseover(function(){var e=jQuery(this).attr("id");b=parseInt(e.substr(e.indexOf("_")+1)),d&&(b>a?c._setSelection(a,b):c._setSelection(b,a),c.trigger(f,{start:c.opt.selection.start,end:c.opt.selection.end}))}).mouseup(function(){d=!1,c.trigger(g,{start:c.opt.selection.start,end:c.opt.selection.end})}),c._addToolTip.call(c,this,function(){return d?"["+c.opt.selection.start+", "+c.opt.selection.end+"]":b})}).css("cursor","pointer")},_addToolTip:function(a,b){var c=this.opt._tooltip;jQuery(a).mouseover(function(d){var e=jQuery(d.target).offset();jQuery(c).is(":visible")||jQuery(c).css({"background-color":"#000",padding:"3px 10px 3px 10px",top:e.top+jQuery(d.target).height()+"px",left:e.left+jQuery(d.target).width()+"px"}).animate({opacity:"0.85"},10).html(b.call(a)).show()}).mouseout(function(){jQuery(c).hide()})},addAnnotation:function(a){this._annotations.push(a),this._redraw()},removeAnnotation:function(a){for(var b=0;b<this._annotations.length;b++)if(a!=this._annotations[b].name){this._annotations.splice(b,1),this._redraw();break}},removeAllAnnotations:function(){this._annotations=[],this._redraw()}}),c("biojs-events").mixin(Sequence.prototype),d.exports=Sequence},{"biojs-events":2,"jquery-browser-plugin":20,"js-class":22}],2:[function(a,b){var c=a("backbone-events-standalone");c.onAll=function(a,b){return this.on("all",a,b),this},c.oldMixin=c.mixin,c.mixin=function(a){c.oldMixin(a);for(var b=["onAll"],d=0;d<b.length;d++){var e=b[d];a[e]=this[e]}return a},b.exports=c},{"backbone-events-standalone":4}],3:[function(a,b,c){!function(){function a(){return{keys:Object.keys||function(a){if("object"!=typeof a&&"function"!=typeof a||null===a)throw new TypeError("keys() called on a non-object");var b,c=[];for(b in a)a.hasOwnProperty(b)&&(c[c.length]=b);return c},uniqueId:function(a){var b=++j+"";return a?a+b:b},has:function(a,b){return h.call(a,b)},each:function(a,b,c){if(null!=a)if(g&&a.forEach===g)a.forEach(b,c);else if(a.length===+a.length){for(var d=0,e=a.length;e>d;d++)if(b.call(c,a[d],d,a)===f)return}else for(var h in a)if(this.has(a,h)&&b.call(c,a[h],h,a)===f)return},once:function(a){var b,c=!1;return function(){return c?b:(c=!0,b=a.apply(this,arguments),a=null,b)}}}}var d,e=this,f={},g=Array.prototype.forEach,h=Object.prototype.hasOwnProperty,i=Array.prototype.slice,j=0,k=a();d={on:function(a,b,c){if(!m(this,"on",a,[b,c])||!b)return this;this._events||(this._events={});var d=this._events[a]||(this._events[a]=[]);return d.push({callback:b,context:c,ctx:c||this}),this},once:function(a,b,c){if(!m(this,"once",a,[b,c])||!b)return this;var d=this,e=k.once(function(){d.off(a,e),b.apply(this,arguments)});return e._callback=b,this.on(a,e,c)},off:function(a,b,c){var d,e,f,g,h,i,j,l;if(!this._events||!m(this,"off",a,[b,c]))return this;if(!a&&!b&&!c)return this._events={},this;for(g=a?[a]:k.keys(this._events),h=0,i=g.length;i>h;h++)if(a=g[h],f=this._events[a]){if(this._events[a]=d=[],b||c)for(j=0,l=f.length;l>j;j++)e=f[j],(b&&b!==e.callback&&b!==e.callback._callback||c&&c!==e.context)&&d.push(e);d.length||delete this._events[a]}return this},trigger:function(a){if(!this._events)return this;var b=i.call(arguments,1);if(!m(this,"trigger",a,b))return this;var c=this._events[a],d=this._events.all;return c&&n(c,b),d&&n(d,arguments),this},stopListening:function(a,b,c){var d=this._listeners;if(!d)return this;var e=!b&&!c;"object"==typeof b&&(c=this),a&&((d={})[a._listenerId]=a);for(var f in d)d[f].off(b,c,this),e&&delete this._listeners[f];return this}};var l=/\s+/,m=function(a,b,c,d){if(!c)return!0;if("object"==typeof c){for(var e in c)a[b].apply(a,[e,c[e]].concat(d));return!1}if(l.test(c)){for(var f=c.split(l),g=0,h=f.length;h>g;g++)a[b].apply(a,[f[g]].concat(d));return!1}return!0},n=function(a,b){var c,d=-1,e=a.length,f=b[0],g=b[1],h=b[2];switch(b.length){case 0:for(;++d<e;)(c=a[d]).callback.call(c.ctx);return;case 1:for(;++d<e;)(c=a[d]).callback.call(c.ctx,f);return;case 2:for(;++d<e;)(c=a[d]).callback.call(c.ctx,f,g);return;case 3:for(;++d<e;)(c=a[d]).callback.call(c.ctx,f,g,h);return;default:for(;++d<e;)(c=a[d]).callback.apply(c.ctx,b)}},o={listenTo:"on",listenToOnce:"once"};k.each(o,function(a,b){d[b]=function(b,c,d){var e=this._listeners||(this._listeners={}),f=b._listenerId||(b._listenerId=k.uniqueId("l"));return e[f]=b,"object"==typeof c&&(d=this),b[a](c,d,this),this}}),d.bind=d.on,d.unbind=d.off,d.mixin=function(a){var b=["on","once","off","trigger","stopListening","listenTo","listenToOnce","bind","unbind"];return k.each(b,function(b){a[b]=this[b]},this),a},"function"==typeof define?define(function(){return d}):"undefined"!=typeof c?("undefined"!=typeof b&&b.exports&&(c=b.exports=d),c.BackboneEvents=d):e.BackboneEvents=d}(this)},{}],4:[function(a,b){b.exports=a("./backbone-events-standalone")},{"./backbone-events-standalone":3}],5:[function(a,b){var c,d;d=a("nets"),b.exports=c=function(){function a(){}return a.read=function(a,b){var c;return c=function(a){return function(c,d,e){return a._onRetrieval(e,b)}}(this),d(a,c)},a._onRetrieval=function(a,b){var c;return c=this.parse(a),b(c)},a}()},{nets:12}],6:[function(a,b){var c,d,e,f,g={}.hasOwnProperty,h=function(a,b){function c(){this.constructor=a}for(var d in b)g.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};f=a("./strings"),d=a("./generic_reader"),e=a("biojs-model").seq,b.exports=c=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return h(b,a),b.parse=function(a){var b,c,d,g,h,i,j,k,l,m;for(k=[],"[object Array]"!==Object.prototype.toString.call(a)&&(a=a.split("\n")),l=0,m=a.length;m>l;l++)if(j=a[l],">"===j[0]||";"===j[0]){if(i=j.slice(1),b=new e("",i,k.length),k.push(b),f.contains("|",j)){for(g=i.split("|"),h=1;h<g.length;)c=g[h],d=g[h+1],b.meta[c]=d,h+=2;b.name=g[g.length-1]}}else b.seq+=j;return k},b}(d)},{"./generic_reader":5,"./strings":7,"biojs-model":10}],7:[function(a,b){var c;c={contains:function(a,b){return-1!=="".indexOf.call(a,b,0)}},b.exports=c},{}],8:[function(a,b){var c;c={},c.splitNChars=function(a,b){var c,d,e,f;for(d=[],c=e=0,f=a.length-1;b>0?f>=e:e>=f;c=e+=b)d.push(a.substr(c,b));return d},b.exports=c},{}],9:[function(a,b){var c,d;d=a("./utils"),b.exports=c=function(){function a(){}return a["export"]=function(a,b){var c,e,f,g;for(e="",f=0,g=a.length;g>f;f++)c=a[f],null!=b&&(c=b(c)),e+=">"+c.name+"\n",e+=d.splitNChars(c.seq,80).join("\n"),e+="\n";return e},a}()},{"./utils":8}],10:[function(a,b){b.exports.seq=a("./seq")},{"./seq":11}],11:[function(a,b){b.exports=function(a,b,c){this.seq=a,this.name=b,this.id=c,this.meta={}}},{}],12:[function(a,b){function c(a,b,c){d(a,b,c)}var d=a("request");b.exports=c},{request:13}],13:[function(a,b){function c(a,b){function c(){4===p.readyState&&x()}function e(){var a=null;if(p.response?a=p.response:"text"!==p.responseType&&p.responseType||(a=p.responseText||p.responseXML),w)try{a=JSON.parse(a)}catch(b){}return a}function k(){return 1223===p.status?204:p.status}function l(a,b){var c=null;if(0===a||a>=400&&600>a){var d=("string"==typeof b?b:!1)||h[String(a).charAt(0)];c=new Error(d),c.statusCode=a}return c}function m(){var a=k(),c=e(),d=l(a,c),f={body:c,statusCode:a,statusText:p.statusText,raw:p};f.headers=p.getAllResponseHeaders?g(p.getAllResponseHeaders()):{},b(d,f,f.body)}function n(){var a=k(),c=l(a);p.status=p.statusCode=a,p.body=e(),p.headers=g(p.getAllResponseHeaders()),b(c,p,p.body)}function o(a){b(a,p)}"string"==typeof a&&(a={uri:a}),a=a||{},b=f(b);var p=a.xhr||null;p||(p=a.cors||a.useXDR?new j:new i);var q,r=p.url=a.uri||a.url,s=p.method=a.method||"GET",t=a.body||a.data,u=p.headers=a.headers||{},v=!!a.sync,w=!1,x=a.response?m:n;if("json"in a&&(w=!0,u.Accept="application/json","GET"!==s&&"HEAD"!==s&&(u["Content-Type"]="application/json",t=JSON.stringify(a.json))),p.onreadystatechange=c,p.onload=x,p.onerror=o,p.onprogress=function(){},p.ontimeout=d,p.open(s,r,!v),(a.withCredentials||a.cors&&a.withCredentials!==!1)&&(p.withCredentials=!0),v||(p.timeout="timeout"in a?a.timeout:5e3),p.setRequestHeader)for(q in u)u.hasOwnProperty(q)&&p.setRequestHeader(q,u[q]);else if(a.headers)throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in a&&(p.responseType=a.responseType),"beforeSend"in a&&"function"==typeof a.beforeSend&&a.beforeSend(p),p.send(t),p}function d(){}var e=a("global/window"),f=a("once"),g=a("parse-headers"),h={0:"Internal XMLHttpRequest Error",4:"4xx Client Error",5:"5xx Server Error"},i=e.XMLHttpRequest||d,j="withCredentials"in new i?i:e.XDomainRequest;b.exports=c},{"global/window":14,once:15,"parse-headers":19}],14:[function(a,b){(function(a){b.exports="undefined"!=typeof window?window:"undefined"!=typeof a?a:"undefined"!=typeof self?self:{}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],15:[function(a,b){function c(a){var b=!1;return function(){return b?void 0:(b=!0,a.apply(this,arguments))}}b.exports=c,c.proto=c(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return c(this)},configurable:!0})})},{}],16:[function(a,b){function c(a,b,c){if(!g(b))throw new TypeError("iterator must be a function");arguments.length<3&&(c=this),"[object Array]"===h.call(a)?d(a,b,c):"string"==typeof a?e(a,b,c):f(a,b,c)}function d(a,b,c){for(var d=0,e=a.length;e>d;d++)i.call(a,d)&&b.call(c,a[d],d,a)}function e(a,b,c){for(var d=0,e=a.length;e>d;d++)b.call(c,a.charAt(d),d,a)}function f(a,b,c){for(var d in a)i.call(a,d)&&b.call(c,a[d],d,a)}var g=a("is-function");b.exports=c;var h=Object.prototype.toString,i=Object.prototype.hasOwnProperty},{"is-function":17}],17:[function(a,b){function c(a){var b=d.call(a);return"[object Function]"===b||"function"==typeof a&&"[object RegExp]"!==b||"undefined"!=typeof window&&(a===window.setTimeout||a===window.alert||a===window.confirm||a===window.prompt)}b.exports=c;var d=Object.prototype.toString},{}],18:[function(a,b,c){function d(a){return a.replace(/^\s*|\s*$/g,"")}c=b.exports=d,c.left=function(a){return a.replace(/^\s*/,"")},c.right=function(a){return a.replace(/\s*$/,"")}},{}],19:[function(a,b){var c=a("trim"),d=a("for-each"),e=function(a){return"[object Array]"===Object.prototype.toString.call(a)};b.exports=function(a){if(!a)return{};
17
17
 
18
- var b={};return d(c(a).split("\n"),function(a){var d=a.indexOf(":"),f=c(a.slice(0,d)).toLowerCase(),g=c(a.slice(d+1));"undefined"==typeof b[f]?b[f]=g:e(b[f])?b[f].push(g):b[f]=[b[f],g]}),b}},{"for-each":16,trim:18}],20:[function(a,b){b.exports=a("./jquery.browser")},{"./jquery.browser":21}],21:[function(a,b){var c,d,e=function(a){a=a.toLowerCase();var b=/(opr)[\/]([\w.]+)/.exec(a)||/(chrome)[ \/]([\w.]+)/.exec(a)||/(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(a)||/(webkit)[ \/]([\w.]+)/.exec(a)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(a)||/(msie) ([\w.]+)/.exec(a)||a.indexOf("trident")>=0&&/(rv)(?::| )([\w.]+)/.exec(a)||a.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(a)||[],c=/(ipad)/.exec(a)||/(iphone)/.exec(a)||/(android)/.exec(a)||/(windows phone)/.exec(a)||/(win)/.exec(a)||/(mac)/.exec(a)||/(linux)/.exec(a)||/(cros)/i.exec(a)||[];return{browser:b[3]||b[1]||"",version:b[2]||"0",platform:c[0]||""}};if(c=e(window.navigator.userAgent),d={},d.uaMatch=e,c.browser&&(d[c.browser]=!0,d.version=c.version,d.versionNumber=parseInt(c.version)),c.platform&&(d[c.platform]=!0),(d.android||d.ipad||d.iphone||d["windows phone"])&&(d.mobile=!0),(d.cros||d.mac||d.linux||d.win)&&(d.desktop=!0),(d.chrome||d.opr||d.safari)&&(d.webkit=!0),d.rv){var f="msie";c.browser=f,d[f]=!0}if(d.opr){var g="opera";c.browser=g,d[g]=!0}if(d.safari&&d.android){var h="android";c.browser=h,d[h]=!0}d.name=c.browser,d.platform=c.platform,b.exports=d},{}],22:[function(a,b){(function(a){function c(a,b,c){for(;b&&b!==Object.prototype&&(Object.getOwnPropertyNames(b).forEach(function(c){if(".class"!=c&&!a.hasOwnProperty(c)){var d=Object.getOwnPropertyDescriptor(b,c);Object.defineProperty(a,c,d)}}),!c);)b=b.__proto__;return a}function d(a,b){for(;a;){if(a.type.prototype===b.prototype)return!0;for(var c in a["implements"]){var e=a["implements"][c],f=e[".class.meta"];if(f){if(d(f,b))return!0}else for(var g=e.prototype;g;g=g.__proto__)if(g===b.prototype)return!0}a=a.base?a.base[".class.meta"]:void 0}return!1}var e=function(a,b,c){"function"!=typeof a&&(c=b,b=a,a=Object),b||(b={}),c||(c={});var d={name:c.name,base:a,"implements":[]},f=e.clone(b);c["implements"]&&(Array.isArray(c["implements"])?c["implements"]:[c["implements"]]).forEach(function(a){"function"==typeof a&&a.prototype&&(d["implements"].push(a),e.extend(f,a.prototype))}),f.__proto__=a.prototype;var g=function(){"function"==typeof this.constructor&&this.constructor.apply(this,arguments)};return d.type=g,g.prototype=f,Object.defineProperty(g,".class.meta",{value:d,enumerable:!1,configurable:!1,writable:!1}),Object.defineProperty(f,".class",{value:g,enumerable:!1,configurable:!1,writable:!1}),c.statics&&e.extend(g,c.statics),g};e.extend=c,e.clone=function(a){return c({},a)};var f=e({constructor:function(a){this.object=a},typeOf:function(a){if(this.object instanceof a)return!0;var b=e.typeInfo(this.object);return b&&d(b,a)}});f.prototype.a=f.prototype.typeOf,f.prototype.an=f.prototype.typeOf,e.is=function(a){return new f(a)},e.typeInfo=function(a){var b=a.__proto__[".class"];return b?b[".class.meta"]:void 0},e.VERSION=[0,0,2],b?b.exports=e:a.Class=e}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],"biojs-io-fasta":[function(a,b){b.exports.parse=a("./parser"),b.exports.writer=a("./writer")},{"./parser":6,"./writer":9}],"biojs-vis-sequence":[function(a,b){b.exports=a("./lib/index")},{"./lib/index":1}]},{},["biojs-vis-sequence"]),$.webshims.polyfill("forms"),function(a){a.fn.disable=function(){return this.prop("disabled",!0).addClass("disabled")},a.fn.enable=function(){return this.prop("disabled",!1).removeClass("disabled")},a.fn.check=function(){return this.prop("checked",!0)},a.fn.uncheck=function(){return this.prop("checked",!1)},a.fn._tooltip=a.fn.tooltip,a.fn.tooltip=function(b){return this._tooltip("destroy")._tooltip(a.extend({container:"body",placement:"left"},b))},a.modalActive=function(){var b=!1;return a(".modal").each(function(){var c=a(this).data("bs.modal");return c?(b=c.isShown,!b):void 0}),b},a.fn.wiggle=function(){this.finish().effect("bounce",{direction:"left",distance:24,times:4},250)},a.fn.poll=function(){var a,b=this,c=null;return function d(){a=b.val(),a!=c&&(c=a,b.change()),setTimeout(d,100)}(),this}}(jQuery);var SS;SS||(SS={}),function(){SS.FASTA_FORMAT=/^>/,SS.decorate=function(a){return a.match(/(.?)(blast)(.?)/).slice(1).map(function(a){return a?"blast"!==a?"<strong>"+a+"</strong>":a:void 0}).join("")},SS.onedb=function(){var a=$(".databases input:checkbox");1===a.length&&a.check()},SS.generateGraphicalOverview=function(){$("[data-graphit='overview']").each(function(){var a=$(this),b=$("<div/>").addClass("graphical-overview");a.children().eq(1).children().eq(0).before(b),$.graphIt(a,b,0,20)})},SS.updateDownloadFastaOfAllLink=function(){var a=$(".hitn").length,b=$(".download-fasta-of-all");if(a>=1&&30>=a){var c=$(".hitn :checkbox").map(function(){return this.value}).get();return void b.enable().attr("href",SS.generateURI(c,b.data().databases)).tooltip({title:a+" hit(s)."})}0===a&&b.tooltip({title:"No hit to download."}),a>30&&b.tooltip({title:"Can't download more than 30 hits."}),b.disable().removeAttr("href")},SS.updateDownloadFastaOfSelectedLink=function(){var a=$(".hitn :checkbox:checked").length,b=$(".download-fasta-of-selected"),c=b.find("span");if(a>=1&&30>=a){var d=$(".hitn :checkbox:checked").map(function(){return this.value}).get();return void b.enable().attr("href",SS.generateURI(d,b.data().databases)).tooltip({title:a+" hit(s) selected."}).find("span").html(a)}0===a&&(c.empty(),b.tooltip({title:"No hit selected."})),a>30&&b.tooltip({title:"Can't download more than 30 hits."}),b.disable().removeAttr("href")},SS.updateSequenceViewerLinks=function(){var a=1e4;$(".view-sequence").each(function(){var b=$(this),c=b.closest(".hitn");c.data().hitLen>a&&b.disable().removeAttr("href").tooltip({title:"Sequence too long to show. Please view it locally after download."})})},SS.setupTooltips=function(){$(".pos-label").each(function(){$(this).tooltip({placement:"right"})}),$(".downloads a").each(function(){$(this).tooltip()})},SS.setupDownloadLinks=function(){$(".download").on("click",function(a){if(a.preventDefault(),a.stopPropagation(),!a.target.disabled){var b=this.href;$.get(b).done(function(){window.location.href=b}).fail(function(a){SS.showErrorModal(a,function(){})})}})},SS.generateURI=function(a,b){a=encodeURIComponent(a.join(" ")),b=encodeURIComponent(b);var c="get_sequence/?sequence_ids="+a+"&database_ids="+b+"&download=fasta";return c},SS.showErrorModal=function(a,b){setTimeout(function(){b(),a.responseText?$("#error").html(a.responseText).modal():$("#error-no-response").modal()},500)},SS.init=function(){this.$sequence=$("#sequence"),this.$sequenceFile=$("#sequence-file"),this.$sequenceControls=$(".sequence-controls"),SS.blast.init()}}(),SS.selectHit=function(a){if(a&&a.value){var b=$($(a).data("target"));a.checked?b.addClass("glow").find(":checkbox").not(a).check():b.removeClass("glow").find(":checkbox").not(a).uncheck(),this.updateDownloadFastaOfSelectedLink()}},SS.showSequenceViewer=function(){var a=$("#sequence-viewer"),b=$(".spinner",a),c=$(".modal-body",a),d=$(".modal-footer",a),e="biojs-vis-sequence",f=function(e){c.empty(),d.empty(),g(e),b.show(),a.modal("show")},g=function(a){var b=a.parent().clone(),c=b.find(".view-sequence"),e=$(c[0].nextSibling);c.remove(),e.remove(),d.empty().append(b)},h=function(a,b){a.forEach(j),b.forEach(i)},i=function(a){var b=a.id+"<small>&nbsp;"+a.title+"</small>",d=e+(new Date).getUTCMilliseconds();c.append($("<div/>").addClass("fastan").append($("<div/>").addClass("page-header").append($("<h4/>").html(b)),$("<div/>").attr("id",d).addClass(e).addClass("page-content")));var f=new Sequence({sequence:a.value,target:d,format:"PRIDE",columns:{size:40,spacedEach:5},formatOptions:{title:!1,footer:!1}});f.hideFormatSelector()},j=function(a){c.append($("<div/>").addClass("page-header").append($("<h4/>").html(a[0])),$("<div/>").addClass("page-content").append($("<pre/>").addClass("pre-reset").html(a[1])),$("<br>"))};return function(c){var d=$(c);f(d);var e=d.attr("href");$.getJSON(e).done(function(a){h(a.error_msgs,a.sequences),b.hide()}).fail(function(b){SS.showErrorModal(b,function(){a.modal("hide")})})}}(),$(document).ready(function(){SS.init();var a,b=$(".dnd-overlay"),c=$("#sequence"),d=function(a){$(".dnd-error").hide(),$("#"+a+"-notification").show(),b.effect("fade",2500)};$(document).on("dragenter",function(a){if(!$.modalActive){var d=a.originalEvent.dataTransfer,e=d.types&&(d.types.indexOf&&-1!=d.types.indexOf("Files")||d.types.contains&&d.types.contains("application/x-moz-file"));e&&($(".dnd-error").hide(),b.stop(!0,!0),b.show(),d.effectAllowed="copy",""===c.val()?($(".dnd-overlay-overwrite").hide(),$(".dnd-overlay-drop").show("drop",{direction:"down"},"fast")):($(".dnd-overlay-drop").hide(),$(".dnd-overlay-overwrite").show("drop",{direction:"down"},"fast")))}}).on("dragleave",".dnd-overlay",function(){b.hide(),$(".dnd-overlay-drop").hide(),$(".dnd-overlay-overwrite").hide()}).on("dragover",".dnd-overlay",function(a){a.originalEvent.dataTransfer.dropEffect="copy",a.preventDefault()}).on("drop",".dnd-overlay",function(a){a.preventDefault(),a.stopPropagation();var c=$("#sequence"),e=$("#sequence-file");c.focus();var f=a.originalEvent.dataTransfer.files;if(f.length>1)return void d("dnd-multi");var g=f[0];if(g.size>10485760)return void d("dnd-large-file");var h=new FileReader;h.onload=function(a){var f=a.target.result;SS.FASTA_FORMAT.test(f)?(c.val(f),e.text(g.name),b.hide()):d("dnd-format")},h.onerror=function(){d("dnd-format")},h.readAsText(g)}),SS.$sequence.change(function(){if(SS.$sequence.val()){var a=SS.$sequence[0].offsetWidth-SS.$sequence[0].clientWidth;SS.$sequenceControls.css("right",a+17),SS.$sequenceControls.removeClass("hidden")}else SS.$sequenceFile.empty(),SS.$sequenceControls.addClass("hidden"),SS.$sequence.parent().removeClass("has-error")}),$("#btn-sequence-clear").click(function(){$("#sequence").val("").focus()}),SS.onedb(),$("#methods").tooltip({title:function(){var a=$(".databases input:checkbox:checked");return 0===a.length?"You must select one or more databases above before you can run a search!":void 0}}),$("#method").tooltip({title:function(){var a="Click to BLAST or press Ctrl+Enter.";return 0!==$(this).siblings().length&&(a+=" Click dropdown button on the right for other BLAST algorithms that can be used."),a},delay:{show:1e3,hide:0}}),$(document).bind("keydown",function(a){a.ctrlKey&&13===a.keyCode&&!$("#method").is(":disabled")&&$("#method").trigger("submit")}),$("#sequence").on("sequence_type_changed",function(b,c){clearTimeout(a),$(this).parent().removeClass("has-error"),$(".notifications .active").hide().removeClass("active"),c&&($("#"+c+"-sequence-notification").show("drop",{direction:"up"}).addClass("active"),a=setTimeout(function(){$(".notifications .active").hide("drop",{direction:"up"}).removeClass("active")},5e3),"mixed"===c&&$(this).parent().addClass("has-error"))}),$("body").click(function(){$(".notifications .active").hide("drop",{direction:"up"}).removeClass("active")}),$(".databases").on("database_type_changed",function(a,b){switch(b){case"protein":$(".databases.nucleotide input:checkbox").disable(),$(".databases.nucleotide .checkbox").addClass("disabled");break;case"nucleotide":$(".databases.protein input:checkbox").disable(),$(".databases.protein .checkbox").addClass("disabled");break;default:$(".databases input:checkbox").enable(),$(".databases .checkbox").removeClass("disabled")}}),$("form").on("blast_method_changed",function(a,b){if($("#method").disable().val("").html("blast"),$("#methods").removeClass("input-group").children().not("#method").remove(),b.length>0){var c=b.shift();$("#method").enable().val(c).html(SS.decorate(c)),b.length>=1&&$("#methods").addClass("input-group").append($("<div/>").addClass("input-group-btn").append($("<button/>").attr("type","button").addClass("btn btn-primary dropdown-toggle").attr("data-toggle","dropdown").append($("<span/>").addClass("caret")),$("<ul/>").addClass("dropdown-menu dropdown-menu-right").append($.map(b,function(a){return $("<li/>").html(SS.decorate(a))})))),$("#methods").wiggle()}}),$(document).on("click","#methods .dropdown-menu li",function(){var a=$(this),b=$("#method"),c=b.text(),d=a.text();a.html(SS.decorate(c)),b.val(d).html(SS.decorate(d)),$("#methods").wiggle()}),$(".result").on("mousedown",".hitn > .page-header > h4",function(){var a=$(this);a.on("mouseup mousemove",function b(c){"mouseup"===c.type?(a.attr("data-toggle","collapse"),a.find(".fa-chevron-down").toggleClass("fa-rotate-270")):a.attr("data-toggle",""),a.off("mouseup mousemove",b)})}),$(".result").on("click",".view-sequence",function(a){a.preventDefault(),a.stopPropagation(),a.target.disabled||SS.showSequenceViewer(a.target)}),$(document).on("change",".hitn :checkbox",function(a){a.stopPropagation(),SS.selectHit(this)}),$("#blast").submit(function(){var a=$(this).attr("action"),b=a.indexOf("#"),c=a.slice(0,b),d=a.slice(b,a.length);location.hash="",$("#spinner").modal();var e=$(this).serialize()+"&method="+$("#method").val();return $.post(c,e).done(function(a){$(".result").html(a).show();var b=$(".sidebar");0!==b.length&&b.affix({offset:{top:b.offset().top}}).width(b.width()),location.hash=d,SS.generateGraphicalOverview(),SS.updateDownloadFastaOfAllLink(),SS.updateDownloadFastaOfSelectedLink(),SS.updateSequenceViewerLinks(),SS.setupTooltips(),SS.setupDownloadLinks(),$("body").scrollspy({target:".sidebar"}),$("#spinner").modal("hide")}).fail(function(a){SS.showErrorModal(a,function(){$("#spinner").modal("hide")})}),!1}),SS.$sequence.poll()}),function(a){var b=function(){a('[data-toggle="tooltip"]').tooltip({placement:"top",container:"body",html:"true","white-space":"nowrap"})},c=function(b){a("a",b).click(function(b){b.preventDefault(),b.stopPropagation(),window.location.hash=a(this).attr("href")})},d=function(b,c,d,e){var f=a(window).width(),g=_.debounce(function(){if(f!==a(window).width()){var g=b.find(".ghit > g").length;a.graphIt(b,c,g,d,e),f=a(window).width()}},125);a(window).resize(g)},e=function(c,d,e){var f,g,h,i,j=20,k=function(){f=c.data().hitCount,g=c.find(".ghit > g").length},l=function(b,c){c.append(a("<button/>").addClass("btn btn-link more").attr("type","button").attr("data-parent-query",b.attr("id")).html("View More&nbsp;").append(a("<i/>").addClass("fa fa-angle-double-down")),a("<button/>").addClass("btn btn-link less").attr("type","button").attr("data-parent-query",b.attr("id")).html("View Less&nbsp;").append(a("<i/>").addClass("fa fa-angle-double-up"))),h=a(".less",c),i=a(".more",c)},m=function(){k(),f===j||j>g?(h.hide(),i.hide()):g===f?(i.hide(),h.show()):g===j?(h.hide(),i.show()):(h.show(),i.show())};e===!0&&(l(c,d),m()),i.on("click",function(e){k(),a.graphIt(c,d,g,j),m(),b(),e.stopPropagation()}),h.on("click",function(e){k();var f=g-j;f>=j?(a.graphIt(c,d,g,-j),m()):0!==f&&(a.graphIt(c,d,g,j-g),m()),b(),e.stopPropagation()})},f=function(b,c,d){var e,f=[];return e=b.find(".hitn").slice(0,c+d),e.map(function(){var b=a(this),c=[];b.find(".hsp").each(function(){var b=[];b=a(this).data(),b.hspId=this.id,c.push(b)}),c.hitId=b.attr("id"),c.hitDef=b.data().hitDef,c.hitEvalue=b.data().hitEvalue,f.push(c)}),f},g=function(a,b,c,d){var e=a.append("g").attr("transform","translate(0,"+(d-b.margin-1.25*b.legend)+")");e.append("rect").attr("x",7*(c-2*b.margin)/10).attr("width",2*(c-4*b.margin)/10).attr("height",b.legend).attr("fill","url(#legend-grad)"),e.append("text").attr("transform","translate(0, "+b.legend+")").attr("x",6*(c-2*b.margin)/10-b.margin/2).text("Weaker hits"),e.append("text").attr("transform","translate(0, "+b.legend+")").attr("x",9*(c-2*b.margin)/10+b.margin/2).text("Stronger hits"),a.append("linearGradient").attr("id","legend-grad").selectAll("stop").data([{offset:"0%",color:"#ccc"},{offset:"50%",color:"#888"},{offset:"100%",color:"#000"}]).enter().append("stop").attr("offset",function(a){return a.offset}).attr("stop-color",function(a){return a.color})};a.extend({graphIt:function(h,i,j,k,l){var m={barHeight:4,barPadding:5,legend:10,margin:20},n=a.extend(m,l),o=f(h,j,k);if(o.length<1)return!1;0!==j&&i.find("svg").remove();var p=h.data().queryLen,q=h.attr("id"),r=i.width(),s=o.length*(n.barHeight+n.barPadding)+5*n.margin+3*n.legend,t=d3.select(i[0]).selectAll("svg").data([o]).enter().insert("svg",":first-child").attr("width",r).attr("height",s).append("g").attr("transform","translate("+n.margin/4+", "+n.margin/4+")"),u=d3.scale.linear().range([0,r-n.margin]);u.domain([1,p]);var v=u.ticks(11);v.pop();var w=d3.svg.axis().scale(u).orient("top").tickValues(v.concat([1,p]));t.append("g").attr("transform","translate(0, "+n.margin+")").append("g").attr("class","x axis").call(w);var x=d3.scale.ordinal().rangeBands([0,s-3*n.margin-2*n.legend],.3);x.domain(o.map(function(a){return a.hitId}));var y=d3.scale.log().domain([d3.min([1e-5,d3.min(o.map(function(a){return 0===parseFloat(a.hitEvalue)?void 0:a.hitEvalue}))]),d3.max(o.map(function(a){return a.hitEvalue}))]).range([40,150]);t.append("g").attr("class","ghit").attr("transform","translate(0, "+(2*n.margin-n.legend)+")").selectAll(".hits").data(o).enter().append("g").attr("data-toggle","tooltip").attr("title",function(a){var b=/(\d*\.\d*)e?([+-]\d*)?/,c=b.exec(a.hitEvalue),d=parseFloat(c[1]).toFixed(3),e=a.hitDef+"<br><strong>E value:</strong> "+d;return void 0!==c[2]&&(e+=" &times; 10<sup>"+c[2]+"</sup>"),e}).each(function(a,b){var c=b+1,d=a,e=a.hitId,f=a.length;d3.select(this).selectAll(".hsp").data(a).enter().append("a").each(function(a,b){var g=x(e)+n.barHeight/2,h=d3.rgb(y(d.hitEvalue),y(d.hitEvalue),y(d.hitEvalue));f>b+1&&(d[b].hspEnd<=d[b+1].hspStart?d3.select(this.parentNode).append("line").attr("x1",u(d[b].hspEnd)).attr("y1",g).attr("x2",u(d[b+1].hspStart)).attr("y2",g).attr("stroke",h):d[b].hspStart>d[b+1].hspEnd&&d3.select(this.parentNode).append("line").attr("x1",u(d[b+1].hspEnd)).attr("y1",g).attr("x2",u(d[b].hspStart)).attr("y2",g).attr("stroke",h)),d3.select(this).attr("xlink:href","#"+q+"_hit_"+c).append("rect").attr("x",function(a){return u(a.hspStart)}).attr("y",x(e)).attr("width",function(a){return u(a.hspEnd-a.hspStart+1)}).attr("height",n.barHeight).attr("fill",d3.rgb(h))})}),o.length>1&&g(t,n,r,s),0===j&&(e(h,i,!0),d(h,i,j,l)),b(),c(i)}})}(jQuery),SS.blast=function(){var a=function(a){if(a=a.replace(/[^A-Z]/gi,""),a=a.replace(/[NX]/gi,""),a.length<10)return void 0;var b,c,d;for(b=0,c=.9*a.length,d=0;d<a.length;d++)a[d].match(/[ACGTU]/i)&&(b+=1);return b>c?"nucleotide":"protein"},b=function(){var b,c,d,e=$("#sequence").val().split(/>.*/);for(d=0;d<e.length;d++)if(c=a(e[d]))if(b){if(c!==b)return"mixed"}else b=c;return b},c=function(){return $(".databases input:checked").data("type")},d=function(){return $("#sequence").val()&&$(".databases input:checked").val()?!0:!1},e=function(){var a,c;$("#sequence").change(function(){c=b(),c&&c===a||(a=c,$(this).trigger("sequence_type_changed",a))})},f=function(){var a,b=c();$(".databases input").change(function(){a=c(),a!=b&&(b=a,$(this).trigger("database_type_changed",b))})},g=function(){var a,b;$("#blast").on("sequence_type_changed database_type_changed",function(){b=h(),_.isEqual(b,a)||(a=b,$(this).trigger("blast_method_changed",[a.slice()]))})},h=function(){if(!d())return[];var a=c(),e=b();switch(a){case"protein":switch(e){case void 0:return["blastp","blastx"];case"protein":return["blastp"];case"nucleotide":return["blastx"]}break;case"nucleotide":switch(e){case void 0:return["tblastn","blastn","tblastx"];case"protein":return["tblastn"];case"nucleotide":return["blastn","tblastx"]}}return[]},i=function(){return void 0};return i.init=function(){e(),f(),g()},i}();
18
+ var b={};return d(c(a).split("\n"),function(a){var d=a.indexOf(":"),f=c(a.slice(0,d)).toLowerCase(),g=c(a.slice(d+1));"undefined"==typeof b[f]?b[f]=g:e(b[f])?b[f].push(g):b[f]=[b[f],g]}),b}},{"for-each":16,trim:18}],20:[function(a,b){b.exports=a("./jquery.browser")},{"./jquery.browser":21}],21:[function(a,b){var c,d,e=function(a){a=a.toLowerCase();var b=/(opr)[\/]([\w.]+)/.exec(a)||/(chrome)[ \/]([\w.]+)/.exec(a)||/(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(a)||/(webkit)[ \/]([\w.]+)/.exec(a)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(a)||/(msie) ([\w.]+)/.exec(a)||a.indexOf("trident")>=0&&/(rv)(?::| )([\w.]+)/.exec(a)||a.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(a)||[],c=/(ipad)/.exec(a)||/(iphone)/.exec(a)||/(android)/.exec(a)||/(windows phone)/.exec(a)||/(win)/.exec(a)||/(mac)/.exec(a)||/(linux)/.exec(a)||/(cros)/i.exec(a)||[];return{browser:b[3]||b[1]||"",version:b[2]||"0",platform:c[0]||""}};if(c=e(window.navigator.userAgent),d={},d.uaMatch=e,c.browser&&(d[c.browser]=!0,d.version=c.version,d.versionNumber=parseInt(c.version)),c.platform&&(d[c.platform]=!0),(d.android||d.ipad||d.iphone||d["windows phone"])&&(d.mobile=!0),(d.cros||d.mac||d.linux||d.win)&&(d.desktop=!0),(d.chrome||d.opr||d.safari)&&(d.webkit=!0),d.rv){var f="msie";c.browser=f,d[f]=!0}if(d.opr){var g="opera";c.browser=g,d[g]=!0}if(d.safari&&d.android){var h="android";c.browser=h,d[h]=!0}d.name=c.browser,d.platform=c.platform,b.exports=d},{}],22:[function(a,b){(function(a){function c(a,b,c){for(;b&&b!==Object.prototype&&(Object.getOwnPropertyNames(b).forEach(function(c){if(".class"!=c&&!a.hasOwnProperty(c)){var d=Object.getOwnPropertyDescriptor(b,c);Object.defineProperty(a,c,d)}}),!c);)b=b.__proto__;return a}function d(a,b){for(;a;){if(a.type.prototype===b.prototype)return!0;for(var c in a["implements"]){var e=a["implements"][c],f=e[".class.meta"];if(f){if(d(f,b))return!0}else for(var g=e.prototype;g;g=g.__proto__)if(g===b.prototype)return!0}a=a.base?a.base[".class.meta"]:void 0}return!1}var e=function(a,b,c){"function"!=typeof a&&(c=b,b=a,a=Object),b||(b={}),c||(c={});var d={name:c.name,base:a,"implements":[]},f=e.clone(b);c["implements"]&&(Array.isArray(c["implements"])?c["implements"]:[c["implements"]]).forEach(function(a){"function"==typeof a&&a.prototype&&(d["implements"].push(a),e.extend(f,a.prototype))}),f.__proto__=a.prototype;var g=function(){"function"==typeof this.constructor&&this.constructor.apply(this,arguments)};return d.type=g,g.prototype=f,Object.defineProperty(g,".class.meta",{value:d,enumerable:!1,configurable:!1,writable:!1}),Object.defineProperty(f,".class",{value:g,enumerable:!1,configurable:!1,writable:!1}),c.statics&&e.extend(g,c.statics),g};e.extend=c,e.clone=function(a){return c({},a)};var f=e({constructor:function(a){this.object=a},typeOf:function(a){if(this.object instanceof a)return!0;var b=e.typeInfo(this.object);return b&&d(b,a)}});f.prototype.a=f.prototype.typeOf,f.prototype.an=f.prototype.typeOf,e.is=function(a){return new f(a)},e.typeInfo=function(a){var b=a.__proto__[".class"];return b?b[".class.meta"]:void 0},e.VERSION=[0,0,2],b?b.exports=e:a.Class=e}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],"biojs-io-fasta":[function(a,b){b.exports.parse=a("./parser"),b.exports.writer=a("./writer")},{"./parser":6,"./writer":9}],"biojs-vis-sequence":[function(a,b){b.exports=a("./lib/index")},{"./lib/index":1}]},{},["biojs-vis-sequence"]),$.webshims.polyfill("forms"),function(a){a.fn.disable=function(){return this.prop("disabled",!0).addClass("disabled")},a.fn.enable=function(){return this.prop("disabled",!1).removeClass("disabled")},a.fn.check=function(){return this.prop("checked",!0)},a.fn.uncheck=function(){return this.prop("checked",!1)},a.fn._tooltip=a.fn.tooltip,a.fn.tooltip=function(b){return this._tooltip("destroy")._tooltip(a.extend({container:"body",placement:"left"},b))},a.modalActive=function(){var b=!1;return a(".modal").each(function(){var c=a(this).data("bs.modal");return c?(b=c.isShown,!b):void 0}),b},a.fn.wiggle=function(){this.finish().effect("bounce",{direction:"left",distance:24,times:4},250)},a.fn.poll=function(){var a,b=this,c=null;return function d(){a=b.val(),a!=c&&(c=a,b.change()),setTimeout(d,100)}(),this}}(jQuery);var SS;SS||(SS={}),function(){SS.FASTA_FORMAT=/^>/,SS.decorate=function(a){return a.match(/(.?)(blast)(.?)/).slice(1).map(function(a){return a?"blast"!==a?"<strong>"+a+"</strong>":a:void 0}).join("")},SS.onedb=function(){var a=$(".databases input:checkbox");1===a.length&&a.check()},SS.generateGraphicalOverview=function(){$("[data-graphit='overview']").each(function(){var a=$(this),b=$("<div/>").addClass("graphical-overview");a.children().eq(1).children().eq(0).before(b),$.graphIt(a,b,0,20)})},SS.updateDownloadFastaOfAllLink=function(){var a=$(".hitn").length,b=$(".download-fasta-of-all");if(a>=1&&30>=a){var c=$(".hitn :checkbox").map(function(){return this.value}).get();return void b.enable().attr("href",SS.generateURI(c,b.data().databases)).tooltip({title:a+" hit(s)."})}0===a&&b.tooltip({title:"No hit to download."}),a>30&&b.tooltip({title:"Can't download more than 30 hits."}),b.disable().removeAttr("href")},SS.updateDownloadFastaOfSelectedLink=function(){var a=$(".hitn :checkbox:checked").length,b=$(".download-fasta-of-selected"),c=b.find("span");if(a>=1&&30>=a){var d=$(".hitn :checkbox:checked").map(function(){return this.value}).get();return void b.enable().attr("href",SS.generateURI(d,b.data().databases)).tooltip({title:a+" hit(s) selected."}).find("span").html(a)}0===a&&(c.empty(),b.tooltip({title:"No hit selected."})),a>30&&b.tooltip({title:"Can't download more than 30 hits."}),b.disable().removeAttr("href")},SS.updateSequenceViewerLinks=function(){var a=1e4;$(".view-sequence").each(function(){var b=$(this),c=b.closest(".hitn");c.data().hitLen>a&&b.disable().removeAttr("href").tooltip({title:"Sequence too long to show. Please view it locally after download."})})},SS.setupTooltips=function(){$(".pos-label").each(function(){$(this).tooltip({placement:"right"})}),$(".downloads a").each(function(){$(this).tooltip()})},SS.setupDownloadLinks=function(){$(".download").on("click",function(a){if(a.preventDefault(),a.stopPropagation(),!a.target.disabled){var b=this.href;$.get(b).done(function(){window.location.href=b}).fail(function(a){SS.showErrorModal(a,function(){})})}})},SS.generateURI=function(a,b){a=encodeURIComponent(a.join(" ")),b=encodeURIComponent(b);var c="get_sequence/?sequence_ids="+a+"&database_ids="+b+"&download=fasta";return c},SS.showErrorModal=function(a,b){setTimeout(function(){b(),a.responseText?$("#error").html(a.responseText).modal():$("#error-no-response").modal()},500)},SS.init=function(){this.$sequence=$("#sequence"),this.$sequenceFile=$("#sequence-file"),this.$sequenceControls=$(".sequence-controls"),SS.blast.init()}}(),SS.selectHit=function(a){if(a&&a.value){var b=$($(a).data("target"));a.checked?b.addClass("glow").find(":checkbox").not(a).check():b.removeClass("glow").find(":checkbox").not(a).uncheck(),this.updateDownloadFastaOfSelectedLink()}},SS.showSequenceViewer=function(){var a=$("#sequence-viewer"),b=$(".spinner",a),c=$(".modal-body",a),d=$(".modal-footer",a),e="biojs-vis-sequence",f=function(e){c.empty(),d.empty(),g(e),b.show(),a.modal("show")},g=function(a){var b=a.parent().clone(),c=b.find(".view-sequence"),e=$(c[0].nextSibling);c.remove(),e.remove(),d.empty().append(b)},h=function(a,b){a.forEach(j),b.forEach(i)},i=function(a){var b=a.id+"<small>&nbsp;"+a.title+"</small>",d=e+(new Date).getUTCMilliseconds();c.append($("<div/>").addClass("fastan").append($("<div/>").addClass("page-header").append($("<h4/>").html(b)),$("<div/>").attr("id",d).addClass(e).addClass("page-content")));var f=new Sequence({sequence:a.value,target:d,format:"PRIDE",columns:{size:40,spacedEach:5},formatOptions:{title:!1,footer:!1}});f.hideFormatSelector()},j=function(a){c.append($("<div/>").addClass("page-header").append($("<h4/>").html(a[0])),$("<div/>").addClass("page-content").append($("<pre/>").addClass("pre-reset").html(a[1])),$("<br>"))};return function(c){var d=$(c);f(d);var e=d.attr("href");$.getJSON(e).done(function(a){h(a.error_msgs,a.sequences),b.hide()}).fail(function(b){SS.showErrorModal(b,function(){a.modal("hide")})})}}(),$(document).ready(function(){SS.init();var a,b=$(".dnd-overlay"),c=$("#sequence"),d=function(a){$(".dnd-error").hide(),$("#"+a+"-notification").show(),b.effect("fade",2500)};$(document).on("dragenter",function(a){if(!$.modalActive()){var d=a.originalEvent.dataTransfer,e=d.types&&(d.types.indexOf&&-1!=d.types.indexOf("Files")||d.types.contains&&d.types.contains("application/x-moz-file"));e&&($(".dnd-error").hide(),b.stop(!0,!0),b.show(),d.effectAllowed="copy",""===c.val()?($(".dnd-overlay-overwrite").hide(),$(".dnd-overlay-drop").show("drop",{direction:"down"},"fast")):($(".dnd-overlay-drop").hide(),$(".dnd-overlay-overwrite").show("drop",{direction:"down"},"fast")))}}).on("dragleave",".dnd-overlay",function(){b.hide(),$(".dnd-overlay-drop").hide(),$(".dnd-overlay-overwrite").hide()}).on("dragover",".dnd-overlay",function(a){a.originalEvent.dataTransfer.dropEffect="copy",a.preventDefault()}).on("drop",".dnd-overlay",function(a){a.preventDefault(),a.stopPropagation();var c=$("#sequence"),e=$("#sequence-file");c.focus();var f=a.originalEvent.dataTransfer.files;if(f.length>1)return void d("dnd-multi");var g=f[0];if(g.size>10485760)return void d("dnd-large-file");var h=new FileReader;h.onload=function(a){var f=a.target.result;SS.FASTA_FORMAT.test(f)?(c.val(f),e.text(g.name),b.hide()):d("dnd-format")},h.onerror=function(){d("dnd-format")},h.readAsText(g)}),SS.$sequence.change(function(){if(SS.$sequence.val()){var a=SS.$sequence[0].offsetWidth-SS.$sequence[0].clientWidth;SS.$sequenceControls.css("right",a+17),SS.$sequenceControls.removeClass("hidden")}else SS.$sequenceFile.empty(),SS.$sequenceControls.addClass("hidden"),SS.$sequence.parent().removeClass("has-error")}),$("#btn-sequence-clear").click(function(){$("#sequence").val("").focus()}),SS.onedb(),$("#methods").tooltip({title:function(){var a=$(".databases input:checkbox:checked");return 0===a.length?"You must select one or more databases above before you can run a search!":void 0}}),$("#method").tooltip({title:function(){var a="Click to BLAST or press Ctrl+Enter.";return 0!==$(this).siblings().length&&(a+=" Click dropdown button on the right for other BLAST algorithms that can be used."),a},delay:{show:1e3,hide:0}}),$(document).bind("keydown",function(a){a.ctrlKey&&13===a.keyCode&&!$("#method").is(":disabled")&&$("#method").trigger("submit")}),$("#sequence").on("sequence_type_changed",function(b,c){clearTimeout(a),$(this).parent().removeClass("has-error"),$(".notifications .active").hide().removeClass("active"),c&&($("#"+c+"-sequence-notification").show("drop",{direction:"up"}).addClass("active"),a=setTimeout(function(){$(".notifications .active").hide("drop",{direction:"up"}).removeClass("active")},5e3),"mixed"===c&&$(this).parent().addClass("has-error"))}),$("body").click(function(){$(".notifications .active").hide("drop",{direction:"up"}).removeClass("active")}),$(".databases").on("database_type_changed",function(a,b){switch(b){case"protein":$(".databases.nucleotide input:checkbox").disable(),$(".databases.nucleotide .checkbox").addClass("disabled");break;case"nucleotide":$(".databases.protein input:checkbox").disable(),$(".databases.protein .checkbox").addClass("disabled");break;default:$(".databases input:checkbox").enable(),$(".databases .checkbox").removeClass("disabled")}}),$("form").on("blast_method_changed",function(a,b){if($("#method").disable().val("").html("blast"),$("#methods").removeClass("input-group").children().not("#method").remove(),b.length>0){var c=b.shift();$("#method").enable().val(c).html(SS.decorate(c)),b.length>=1&&$("#methods").addClass("input-group").append($("<div/>").addClass("input-group-btn").append($("<button/>").attr("type","button").addClass("btn btn-primary dropdown-toggle").attr("data-toggle","dropdown").append($("<span/>").addClass("caret")),$("<ul/>").addClass("dropdown-menu dropdown-menu-right").append($.map(b,function(a){return $("<li/>").html(SS.decorate(a))})))),$("#methods").wiggle()}}),$(document).on("click","#methods .dropdown-menu li",function(){var a=$(this),b=$("#method"),c=b.text(),d=a.text();a.html(SS.decorate(c)),b.val(d).html(SS.decorate(d)),$("#methods").wiggle()}),$(".result").on("mousedown",".hitn > .page-header > h4",function(){var a=$(this);a.on("mouseup mousemove",function b(c){"mouseup"===c.type?(a.attr("data-toggle","collapse"),a.find(".fa-chevron-down").toggleClass("fa-rotate-270")):a.attr("data-toggle",""),a.off("mouseup mousemove",b)})}),$(".result").on("click",".view-sequence",function(a){a.preventDefault(),a.stopPropagation(),a.target.disabled||SS.showSequenceViewer(a.target)}),$(document).on("change",".hitn :checkbox",function(a){a.stopPropagation(),SS.selectHit(this)}),$("#blast").submit(function(){var a=$(this).attr("action"),b=a.indexOf("#"),c=a.slice(0,b),d=a.slice(b,a.length);location.hash="",$("#spinner").modal();var e=$(this).serialize()+"&method="+$("#method").val();return $.post(c,e).done(function(a){$(".result").html(a).show();var b=$(".sidebar");0!==b.length&&b.affix({offset:{top:b.offset().top}}).width(b.width()),location.hash=d,SS.generateGraphicalOverview(),SS.updateDownloadFastaOfAllLink(),SS.updateDownloadFastaOfSelectedLink(),SS.updateSequenceViewerLinks(),SS.setupTooltips(),SS.setupDownloadLinks(),$("body").scrollspy({target:".sidebar"}),$("#spinner").modal("hide")}).fail(function(a){SS.showErrorModal(a,function(){$("#spinner").modal("hide")})}),!1}),SS.$sequence.poll()}),function(a){var b=function(){a('[data-toggle="tooltip"]').tooltip({placement:"top",container:"body",html:"true","white-space":"nowrap"})},c=function(b){a("a",b).click(function(b){b.preventDefault(),b.stopPropagation(),window.location.hash=a(this).attr("href")})},d=function(b,c,d,e){var f=a(window).width(),g=_.debounce(function(){if(f!==a(window).width()){var g=b.find(".ghit > g").length;a.graphIt(b,c,g,d,e),f=a(window).width()}},125);a(window).resize(g)},e=function(c,d,e){var f,g,h,i,j=20,k=function(){f=c.data().hitCount,g=c.find(".ghit > g").length},l=function(b,c){c.append(a("<button/>").addClass("btn btn-link more").attr("type","button").attr("data-parent-query",b.attr("id")).html("View More&nbsp;").append(a("<i/>").addClass("fa fa-angle-double-down")),a("<button/>").addClass("btn btn-link less").attr("type","button").attr("data-parent-query",b.attr("id")).html("View Less&nbsp;").append(a("<i/>").addClass("fa fa-angle-double-up"))),h=a(".less",c),i=a(".more",c)},m=function(){k(),f===j||j>g?(h.hide(),i.hide()):g===f?(i.hide(),h.show()):g===j?(h.hide(),i.show()):(h.show(),i.show())};e===!0&&(l(c,d),m()),i.on("click",function(e){k(),a.graphIt(c,d,g,j),m(),b(),e.stopPropagation()}),h.on("click",function(e){k();var f=g-j;f>=j?(a.graphIt(c,d,g,-j),m()):0!==f&&(a.graphIt(c,d,g,j-g),m()),b(),e.stopPropagation()})},f=function(b,c,d){var e,f=[];return e=b.find(".hitn").slice(0,c+d),e.map(function(){var b=a(this),c=[];b.find(".hsp").each(function(){var b=[];b=a(this).data(),b.hspId=this.id,c.push(b)}),c.hitId=b.attr("id"),c.hitDef=b.data().hitDef,c.hitEvalue=b.data().hitEvalue,f.push(c)}),f},g=function(a,b,c,d){var e=a.append("g").attr("transform","translate(0,"+(d-b.margin-1.25*b.legend)+")");e.append("rect").attr("x",7*(c-2*b.margin)/10).attr("width",2*(c-4*b.margin)/10).attr("height",b.legend).attr("fill","url(#legend-grad)"),e.append("text").attr("transform","translate(0, "+b.legend+")").attr("x",6*(c-2*b.margin)/10-b.margin/2).text("Weaker hits"),e.append("text").attr("transform","translate(0, "+b.legend+")").attr("x",9*(c-2*b.margin)/10+b.margin/2).text("Stronger hits"),a.append("linearGradient").attr("id","legend-grad").selectAll("stop").data([{offset:"0%",color:"#ccc"},{offset:"50%",color:"#888"},{offset:"100%",color:"#000"}]).enter().append("stop").attr("offset",function(a){return a.offset}).attr("stop-color",function(a){return a.color})};a.extend({graphIt:function(h,i,j,k,l){var m={barHeight:4,barPadding:5,legend:10,margin:20},n=a.extend(m,l),o=f(h,j,k);if(o.length<1)return!1;0!==j&&i.find("svg").remove();var p=h.data().queryLen,q=h.attr("id"),r=i.width(),s=o.length*(n.barHeight+n.barPadding)+5*n.margin+3*n.legend,t=d3.select(i[0]).selectAll("svg").data([o]).enter().insert("svg",":first-child").attr("width",r).attr("height",s).append("g").attr("transform","translate("+n.margin/4+", "+n.margin/4+")"),u=d3.scale.linear().range([0,r-n.margin]);u.domain([1,p]);var v=u.ticks(11);v.pop();var w=d3.svg.axis().scale(u).orient("top").tickValues(v.concat([1,p]));t.append("g").attr("transform","translate(0, "+n.margin+")").append("g").attr("class","x axis").call(w);var x=d3.scale.ordinal().rangeBands([0,s-3*n.margin-2*n.legend],.3);x.domain(o.map(function(a){return a.hitId}));var y=d3.scale.log().domain([d3.min([1e-5,d3.min(o.map(function(a){return 0===parseFloat(a.hitEvalue)?void 0:a.hitEvalue}))]),d3.max(o.map(function(a){return a.hitEvalue}))]).range([40,150]);t.append("g").attr("class","ghit").attr("transform","translate(0, "+(2*n.margin-n.legend)+")").selectAll(".hits").data(o).enter().append("g").attr("data-toggle","tooltip").attr("title",function(a){var b=/(\d*\.\d*)e?([+-]\d*)?/,c=b.exec(a.hitEvalue),d=parseFloat(c[1]).toFixed(3),e=a.hitDef+"<br><strong>E value:</strong> "+d;return void 0!==c[2]&&(e+=" &times; 10<sup>"+c[2]+"</sup>"),e}).each(function(a,b){var c=b+1,d=a,e=a.hitId,f=a.length;d3.select(this).selectAll(".hsp").data(a).enter().append("a").each(function(a,b){var g=x(e)+n.barHeight/2,h=d3.rgb(y(d.hitEvalue),y(d.hitEvalue),y(d.hitEvalue));f>b+1&&(d[b].hspEnd<=d[b+1].hspStart?d3.select(this.parentNode).append("line").attr("x1",u(d[b].hspEnd)).attr("y1",g).attr("x2",u(d[b+1].hspStart)).attr("y2",g).attr("stroke",h):d[b].hspStart>d[b+1].hspEnd&&d3.select(this.parentNode).append("line").attr("x1",u(d[b+1].hspEnd)).attr("y1",g).attr("x2",u(d[b].hspStart)).attr("y2",g).attr("stroke",h)),d3.select(this).attr("xlink:href","#"+q+"_hit_"+c).append("rect").attr("x",function(a){return u(a.hspStart)}).attr("y",x(e)).attr("width",function(a){return u(a.hspEnd-a.hspStart+1)}).attr("height",n.barHeight).attr("fill",d3.rgb(h))})}),o.length>1&&g(t,n,r,s),0===j&&(e(h,i,!0),d(h,i,j,l)),b(),c(i)}})}(jQuery),SS.blast=function(){var a=function(a){if(a=a.replace(/[^A-Z]/gi,""),a=a.replace(/[NX]/gi,""),a.length<10)return void 0;var b,c,d;for(b=0,c=.9*a.length,d=0;d<a.length;d++)a[d].match(/[ACGTU]/i)&&(b+=1);return b>c?"nucleotide":"protein"},b=function(){var b,c,d,e=$("#sequence").val().split(/>.*/);for(d=0;d<e.length;d++)if(c=a(e[d]))if(b){if(c!==b)return"mixed"}else b=c;return b},c=function(){return $(".databases input:checked").data("type")},d=function(){return $("#sequence").val()&&$(".databases input:checked").val()?!0:!1},e=function(){var a,c;$("#sequence").change(function(){c=b(),c&&c===a||(a=c,$(this).trigger("sequence_type_changed",a))})},f=function(){var a,b=c();$(".databases input").change(function(){a=c(),a!=b&&(b=a,$(this).trigger("database_type_changed",b))})},g=function(){var a,b;$("#blast").on("sequence_type_changed database_type_changed",function(){b=h(),_.isEqual(b,a)||(a=b,$(this).trigger("blast_method_changed",[a.slice()]))})},h=function(){if(!d())return[];var a=c(),e=b();switch(a){case"protein":switch(e){case void 0:return["blastp","blastx"];case"protein":return["blastp"];case"nucleotide":return["blastx"]}break;case"nucleotide":switch(e){case void 0:return["tblastn","blastn","tblastx"];case"protein":return["tblastn"];case"nucleotide":return["blastn","tblastx"]}}return[]},i=function(){return void 0};return i.init=function(){e(),f(),g()},i}();
@@ -479,7 +479,7 @@ $(document).ready(function(){
479
479
  $(document)
480
480
  .on('dragenter', function (evt) {
481
481
  // Do not activate DnD if a modal is active.
482
- if ($.modalActive) return;
482
+ if ($.modalActive()) return;
483
483
 
484
484
  // Based on http://stackoverflow.com/a/8494918/1205465.
485
485
  // Contrary to what the above link says, the snippet below can't
@@ -25,7 +25,7 @@ DESC
25
25
  s.add_development_dependency('rack-test', '~> 0.6', '>= 0.6.2')
26
26
  s.add_development_dependency('rspec', '~> 2.8', '>= 2.8.0')
27
27
  s.add_development_dependency('rake', '~> 10.3', '>= 10.3.2')
28
- s.add_development_dependency('rubocop', '~> 0.28', '>= 0.28.0')
28
+ s.add_development_dependency('rubocop', '~> 0.31', '>= 0.31.0')
29
29
  s.add_development_dependency('capybara', '~> 2.4', '>= 2.4.4')
30
30
  s.add_development_dependency('capybara-webkit', '~> 1.3', '>= 1.3.0')
31
31
  s.add_development_dependency('codeclimate-test-reporter',
data/views/result.erb CHANGED
@@ -42,6 +42,7 @@
42
42
  <th>Sequences producing significant alignments</th>
43
43
  <th class="text-right"> Total score </th>
44
44
  <th class="text-right"> E value </th>
45
+ <th class="text-right"> Length </th>
45
46
  </thead>
46
47
  <tbody>
47
48
  <% query.hits.each_with_index do |hit, h| %>
@@ -50,6 +51,7 @@
50
51
  <td> <a href="<%="#Query_#{query.number}_hit_#{hit.number}"%>"><%= "#{hit.id}" %></a> </td>
51
52
  <td class="text-right"><%= prettify hit.score %></td>
52
53
  <td class="text-right"><%= prettify hit.evalue %></td>
54
+ <td class="text-right"><%= prettify hit.length %></td>
53
55
  </tr>
54
56
  <% end %>
55
57
  </tbody>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequenceserver
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anurag Priyam
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-05-12 00:00:00.000000000 Z
14
+ date: 2015-05-18 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: sinatra
@@ -159,20 +159,20 @@ dependencies:
159
159
  requirements:
160
160
  - - "~>"
161
161
  - !ruby/object:Gem::Version
162
- version: '0.28'
162
+ version: '0.31'
163
163
  - - ">="
164
164
  - !ruby/object:Gem::Version
165
- version: 0.28.0
165
+ version: 0.31.0
166
166
  type: :development
167
167
  prerelease: false
168
168
  version_requirements: !ruby/object:Gem::Requirement
169
169
  requirements:
170
170
  - - "~>"
171
171
  - !ruby/object:Gem::Version
172
- version: '0.28'
172
+ version: '0.31'
173
173
  - - ">="
174
174
  - !ruby/object:Gem::Version
175
- version: 0.28.0
175
+ version: 0.31.0
176
176
  - !ruby/object:Gem::Dependency
177
177
  name: capybara
178
178
  requirement: !ruby/object:Gem::Requirement
@@ -689,3 +689,4 @@ signing_key:
689
689
  specification_version: 4
690
690
  summary: BLAST search made easy!
691
691
  test_files: []
692
+ has_rdoc: