genevalidator 1.6.2 → 1.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +147 -76
  3. data/Rakefile +1 -1
  4. data/aux/files/css/genevalidator.compiled.min.css +16 -0
  5. data/aux/files/css/{bootstrap.min.css → src/bootstrap.min.css} +0 -0
  6. data/aux/files/css/{font-awesome.min.css → src/font-awesome.min.css} +0 -0
  7. data/aux/files/css/{style.css → src/style.css} +0 -0
  8. data/aux/files/js/genevalidator.compiled.min.js +28 -0
  9. data/aux/files/js/{bootstrap.min.js → src/bootstrap.min.js} +0 -0
  10. data/aux/files/js/{d3.v3.min.js → src/d3.v3.min.js} +0 -0
  11. data/aux/files/js/{jquery-2.1.1.min.js → src/jquery-2.1.1.min.js} +0 -0
  12. data/aux/files/js/{jquery.tablesorter.min.js → src/jquery.tablesorter.min.js} +0 -0
  13. data/aux/files/js/src/plots.js +814 -0
  14. data/aux/files/js/src/script.js +43 -0
  15. data/aux/json_header.erb +6 -6
  16. data/aux/json_query.erb +2 -1
  17. data/aux/template_footer.erb +0 -11
  18. data/aux/template_header.erb +4 -4
  19. data/aux/template_query.erb +1 -1
  20. data/bin/genevalidator +8 -6
  21. data/genevalidator.gemspec +1 -1
  22. data/lib/genevalidator.rb +7 -5
  23. data/lib/genevalidator/arg_validation.rb +12 -9
  24. data/lib/genevalidator/blast.rb +18 -11
  25. data/lib/genevalidator/clusterization.rb +35 -31
  26. data/lib/genevalidator/exceptions.rb +0 -1
  27. data/lib/genevalidator/get_raw_sequences.rb +115 -69
  28. data/lib/genevalidator/hsp.rb +8 -8
  29. data/lib/genevalidator/json_to_gv_results.rb +4 -4
  30. data/lib/genevalidator/output.rb +40 -41
  31. data/lib/genevalidator/pool.rb +5 -4
  32. data/lib/genevalidator/query.rb +37 -0
  33. data/lib/genevalidator/tabular_parser.rb +3 -4
  34. data/lib/genevalidator/validation.rb +16 -11
  35. data/lib/genevalidator/validation_alignment.rb +17 -23
  36. data/lib/genevalidator/validation_blast_reading_frame.rb +3 -3
  37. data/lib/genevalidator/validation_duplication.rb +8 -18
  38. data/lib/genevalidator/validation_gene_merge.rb +11 -9
  39. data/lib/genevalidator/validation_length_cluster.rb +8 -11
  40. data/lib/genevalidator/validation_length_rank.rb +5 -4
  41. data/lib/genevalidator/validation_open_reading_frame.rb +5 -5
  42. data/lib/genevalidator/version.rb +1 -1
  43. data/test/test_all_validations.rb +2 -1
  44. data/test/test_blast.rb +4 -3
  45. data/test/test_extended_array_methods.rb +2 -1
  46. data/test/{test_sequences.rb → test_query.rb} +5 -23
  47. data/test/test_validation_open_reading_frame.rb +7 -7
  48. data/test/test_validations.rb +8 -6
  49. metadata +16 -16
  50. data/aux/app_template_footer.erb +0 -1
  51. data/aux/app_template_header.erb +0 -12
  52. data/aux/files/js/plots.js +0 -828
  53. data/aux/files/js/script.js +0 -71
  54. data/lib/genevalidator/sequences.rb +0 -101
@@ -97,8 +97,7 @@ module GeneValidator
97
97
  # +LengthClusterValidationOutput+ object
98
98
  def run
99
99
  fail NotEnoughHitsError unless hits.length >= 5
100
- fail Exception unless prediction.is_a?(Sequence) &&
101
- hits[0].is_a?(Sequence)
100
+ fail unless prediction.is_a?(Query) && hits[0].is_a?(Query)
102
101
 
103
102
  start = Time.now
104
103
  # get [clusters, max_density_cluster_idx]
@@ -125,7 +124,7 @@ module GeneValidator
125
124
  @validation_report = ValidationReport.new('Not enough evidence', :warning,
126
125
  @short_header, @header,
127
126
  @description)
128
- rescue Exception
127
+ rescue
129
128
  @validation_report = ValidationReport.new('Unexpected error', :error,
130
129
  @short_header, @header,
131
130
  @description)
@@ -136,16 +135,15 @@ module GeneValidator
136
135
  # Clusterization by length from a list of sequences
137
136
  # Params:
138
137
  # +debug+ (optional):: true to display debug information, false by default
139
- # +lst+:: array of +Sequence+ objects
140
- # +predicted_seq+:: +Sequence+ objetc
138
+ # +lst+:: array of +Query+ objects
139
+ # +predicted_seq+:: +Query+ objetc
141
140
  # Output
142
141
  # output 1:: array of Cluster objects
143
142
  # output 2:: the index of the most dense cluster
144
143
  def clusterization_by_length(_debug = false,
145
144
  lst = @hits,
146
145
  predicted_seq = @prediction)
147
- fail TypeError unless lst[0].is_a?(Sequence) &&
148
- predicted_seq.is_a?(Sequence)
146
+ fail TypeError unless lst[0].is_a?(Query) && predicted_seq.is_a?(Query)
149
147
 
150
148
  contents = lst.map { |x| x.length_protein.to_i }.sort { |a, b| a <=> b }
151
149
 
@@ -179,10 +177,9 @@ module GeneValidator
179
177
  # +prediction+: +Sequence+ object
180
178
  # Output:
181
179
  # +Plot+ object
182
- def plot_histo_clusters(output = "#{@plot_path}_len_clusters.json",
183
- clusters = @clusters,
184
- max_density_cluster = @max_density_cluster,
185
- prediction = @prediction)
180
+ def plot_histo_clusters(clusters = @clusters,
181
+ max_density_cluster = @max_density_cluster,
182
+ prediction = @prediction)
186
183
 
187
184
  data = clusters.each_with_index.map { |cluster, i|
188
185
  cluster.lengths.collect { |k, v|
@@ -44,7 +44,7 @@ module GeneValidator
44
44
  end
45
45
 
46
46
  def explain
47
- diff = (@query_length < @median) ? 'longer' : 'shorter'
47
+ diff = (@query_length > @median) ? 'longer' : 'shorter'
48
48
  exp1 = "The query sequence is #{@query_length} amino-acids long. BLAST" \
49
49
  " identified #{@no_of_hits} hit sequences with lengths from" \
50
50
  " #{@smallest_hit} to #{@largest_hit} amino-acids (median:" \
@@ -105,11 +105,12 @@ module GeneValidator
105
105
  # +LengthRankValidationOutput+ object
106
106
  def run(hits = @hits, prediction = @prediction)
107
107
  fail NotEnoughHitsError unless hits.length >= 5
108
- fail Exception unless prediction.is_a?(Sequence) && hits[0].is_a?(Sequence)
108
+ fail unless prediction.is_a?(Query) && hits[0].is_a?(Query)
109
109
 
110
110
  start = Time.now
111
111
 
112
- hits_lengths = hits.map { |x| x.length_protein.to_i }.sort { |a, b| a <=> b }
112
+ hits_lengths = hits.map { |x| x.length_protein.to_i }
113
+ .sort { |a, b| a <=> b }
113
114
 
114
115
  no_of_hits = hits_lengths.length
115
116
  median = hits_lengths.median.round
@@ -151,7 +152,7 @@ module GeneValidator
151
152
  @validation_report = ValidationReport.new('Not enough evidence', :warning,
152
153
  @short_header, @header,
153
154
  @description)
154
- rescue Exception
155
+ rescue
155
156
  @validation_report = ValidationReport.new('Unexpected error', :error,
156
157
  @short_header, @header,
157
158
  @description)
@@ -91,7 +91,7 @@ module GeneValidator
91
91
  return @validation_report
92
92
  end
93
93
 
94
- fail Exception unless prediction.is_a?(Sequence)
94
+ fail unless prediction.is_a?(Query)
95
95
 
96
96
  start = Time.new
97
97
  orfs = get_orfs
@@ -109,7 +109,7 @@ module GeneValidator
109
109
 
110
110
  @validation_report.plot_files.push(plot1)
111
111
  @validation_report
112
- rescue Exception
112
+ rescue
113
113
  @validation_report = ValidationReport.new('Unexpected error', :error,
114
114
  @short_header, @header,
115
115
  @description)
@@ -160,7 +160,7 @@ module GeneValidator
160
160
  # +orfs+: +Hash+ containing the open reading frame
161
161
  # +output+: location where the plot will be saved in jped file format
162
162
  # +prediction+: Sequence objects
163
- def plot_orfs(orfs, translated_length, output = "#{@plot_path}_orfs.json")
163
+ def plot_orfs(orfs, translated_length)
164
164
  fail QueryError unless orfs.is_a? Hash
165
165
 
166
166
  data = []
@@ -169,13 +169,13 @@ module GeneValidator
169
169
  (-3..3).each do |frame|
170
170
  next if frame == 0
171
171
  data << { 'y' => frame, 'start' => 1, 'stop' => translated_length,
172
- 'color' => 'gray' }
172
+ 'color' => 'gray' }
173
173
  end
174
174
 
175
175
  # Create the hashes for the ORFs...
176
176
  orfs.each do |_key, h|
177
177
  data << { 'y' => h[:frame], 'start' => h[:orf_start],
178
- 'stop' => h[:orf_end], 'color' => 'red' }
178
+ 'stop' => h[:orf_end], 'color' => 'red' }
179
179
  end
180
180
 
181
181
  Plot.new(data,
@@ -1,3 +1,3 @@
1
1
  module GeneValidator
2
- VERSION = '1.6.2'
2
+ VERSION = '1.6.3'
3
3
  end
@@ -1,7 +1,8 @@
1
1
  require_relative 'test_helper'
2
2
  require 'minitest/autorun'
3
- require 'yaml'
4
3
  require 'fileutils'
4
+ require 'yaml'
5
+
5
6
  require 'genevalidator'
6
7
 
7
8
  module GeneValidator
data/test/test_blast.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require_relative 'test_helper'
2
2
  require 'minitest/autorun'
3
3
  require 'fileutils'
4
+
4
5
  require 'genevalidator'
5
6
  require 'genevalidator/blast'
6
7
  require 'genevalidator/tabular_parser'
@@ -202,7 +203,7 @@ module GeneValidator
202
203
 
203
204
  GeneValidator.init(default_opt)
204
205
 
205
- prediction = Sequence.new
206
+ prediction = Query.new
206
207
  prediction.length_protein = 1808
207
208
  tabular_headers = 'qseqid sseqid sacc slen qstart qend sstart' \
208
209
  ' send pident length qframe evalue'
@@ -241,7 +242,7 @@ module GeneValidator
241
242
 
242
243
  GeneValidator.init(default_opt)
243
244
 
244
- prediction = Sequence.new
245
+ prediction = Query.new
245
246
  prediction.length_protein = 219 / 3
246
247
  tabular_headers = 'qseqid sseqid pident length mismatch gapopen' \
247
248
  ' qstart qend sstart send evalue bitscore'
@@ -275,7 +276,7 @@ module GeneValidator
275
276
 
276
277
  GeneValidator.init(default_opt)
277
278
 
278
- prediction = Sequence.new
279
+ prediction = Query.new
279
280
  prediction.length_protein = 219 / 3
280
281
  output = File.open(ncbi_mrna_xml20, 'rb').read
281
282
  iterator = Bio::BlastXMLParser::NokogiriBlastXml.new(output).to_enum
@@ -1,9 +1,10 @@
1
1
  require_relative 'test_helper'
2
2
  require 'genevalidator/ext/array'
3
3
  require 'minitest/autorun'
4
+
4
5
  module GeneValidator
5
6
  # Test the Enumerable extension class
6
- class TestEnumerable < Minitest::Test
7
+ class TestArray < Minitest::Test
7
8
  describe 'Array Class' do
8
9
  it 'test1' do
9
10
  v = [1, 2, 3, 4, 5, 6]
@@ -1,36 +1,18 @@
1
1
  require_relative 'test_helper'
2
2
  require 'minitest/autorun'
3
- require 'genevalidator/sequences'
3
+
4
4
  require 'genevalidator/hsp'
5
+ require 'genevalidator/query'
6
+
5
7
  module GeneValidator
6
8
  # Test the Sequence class
7
- class TestSequenceClass < Minitest::Test
9
+ class TestQueryClass < Minitest::Test
8
10
  describe 'Test Sequence Class' do
9
- it 'should get sequence by accession for mrna' do
10
- seq_mrna = Sequence.new
11
- seq_mrna.get_sequence_by_accession_no('EF100000', 'nucleotide',
12
- 'swissprot -remote')
13
- assert_equal('AGAGTTTGAT', seq_mrna.raw_sequence[0..9])
14
- start_idx = seq_mrna.raw_sequence.length - 10
15
- end_idx = seq_mrna.raw_sequence.length - 1
16
- assert_equal('GCCCGTCAAG', seq_mrna.raw_sequence[start_idx..end_idx])
17
- end
18
-
19
- it 'should get sequence by accession for protein' do
20
- seq_prot = Sequence.new
21
- seq_prot.get_sequence_by_accession_no('F8WCM5', 'protein',
22
- 'swissprot -remote')
23
- assert_equal('MALWMRLLPL', seq_prot.raw_sequence[0..9])
24
- start_idx = seq_prot.raw_sequence.length - 10
25
- end_idx = seq_prot.raw_sequence.length - 1
26
- assert_equal('WPRRPQRSQN', seq_prot.raw_sequence[start_idx..end_idx])
27
- end
28
-
29
11
  it 'should initialize seq tabular attributes' do
30
12
  identifier = 'sp|Q8N302|AGGF1_HUMAN'
31
13
  accession_no = 'Q8N302'
32
14
  slen = 714
33
- seq = Sequence.new
15
+ seq = Query.new
34
16
  hash = { 'qseqid' => 'GB10034-PA',
35
17
  'sseqid' => identifier,
36
18
  'sacc' => accession_no,
@@ -1,10 +1,10 @@
1
1
  require_relative 'test_helper'
2
2
  require 'minitest/autorun'
3
3
 
4
- require 'genevalidator/validation_test'
5
- require 'genevalidator/validation_open_reading_frame'
6
- require 'genevalidator/sequences'
7
4
  require 'genevalidator'
5
+ require 'genevalidator/query'
6
+ require 'genevalidator/validation_open_reading_frame'
7
+ require 'genevalidator/validation_test'
8
8
 
9
9
  module GeneValidator
10
10
  # Classs to test the ORF validation
@@ -13,7 +13,7 @@ module GeneValidator
13
13
  it 'should find ORFs - test 1 ' do
14
14
  GeneValidator.config = {}
15
15
  GeneValidator.config[:type] = :nucleotide
16
- prediction = Sequence.new
16
+ prediction = Query.new
17
17
  prediction.raw_sequence = 'ATGGCTCTCTGGATCCGGTCGCTGCCTCTCCTGGCCCTTCTT' \
18
18
  'GCTCTTTCTGGCCCTGGGATCAGCCACGCAGCTGCCAACCAG' \
19
19
  'CACCTCTGTGGCTCCCACTTGGTTGAGGCTCTCTACCTGGTG' \
@@ -69,7 +69,7 @@ module GeneValidator
69
69
  it 'should find - test 2 ' do
70
70
  GeneValidator.config = {}
71
71
  GeneValidator.config[:type] = :nucleotide
72
- prediction = Sequence.new
72
+ prediction = Query.new
73
73
  prediction.raw_sequence = 'ATGGCTCTCTGGATCCGGTCGCTGCCTCTCCTGGCCCTTCTT' \
74
74
  'GCTCTTTCTGGCCCTGGGATCAGCCACGCAGCTGCCAACCAG' \
75
75
  'CACCTCTGTGGCTCCCACTTGGTTGAGGCTCTCTACCTGGTG' \
@@ -144,8 +144,8 @@ module GeneValidator
144
144
 
145
145
  it 'should find - test 3 ' do
146
146
  GeneValidator.config = {}
147
- GeneValidator.config[:type] = :nucleotide
148
- prediction = Sequence.new
147
+ GeneValidator.config[:type] = :nucleotide
148
+ prediction = Query.new
149
149
  prediction.raw_sequence = 'GGCGGGGCGGGAGGGCGGCGCGGAGTGCGCCGGCGCGTCGTC' \
150
150
  'GGGGACGCCGGGTCCAGGATCTTGCTAGGGAACCAGTGTTGT' \
151
151
  'CGCGTCGTCCCGCCCCCTCGGGGCTTTTGCTCCCGTTAACTG' \
@@ -2,6 +2,7 @@ require_relative 'test_helper'
2
2
  require 'minitest/autorun'
3
3
  require 'yaml'
4
4
  require 'fileutils'
5
+
5
6
  require 'genevalidator'
6
7
  require 'genevalidator/blast'
7
8
  require 'genevalidator/validation_length_cluster'
@@ -14,9 +15,10 @@ require 'genevalidator/validation_alignment'
14
15
  require 'genevalidator/validation'
15
16
 
16
17
  module GeneValidator
18
+ # Class that initalises a separate Validate.new() instance for each query.
17
19
  class Validate
18
20
  # Extend Validate Class with an alternative validate method that
19
- # doesn't produce the output and returns the output instance
21
+ # doesn't produce the output and returns the output instance
20
22
  def validate_without_output(prediction, hits, current_idx)
21
23
  hits = remove_identical_hits(prediction, hits)
22
24
  vals = create_validation_tests(prediction, hits)
@@ -50,7 +52,7 @@ module GeneValidator
50
52
 
51
53
  describe 'Detailed Validation of normal Insulin Query' do
52
54
  hits = BlastUtils.parse_next(iterator, :nucleotide)
53
- prediction = Sequence.new
55
+ prediction = Query.new
54
56
  prediction.definition = ''
55
57
  prediction.identifier = ''
56
58
  prediction.type = :nucleotide
@@ -153,7 +155,7 @@ module GeneValidator
153
155
 
154
156
  describe 'Validate a trancated sequence' do
155
157
  hits = BlastUtils.parse_next(iterator, :nucleotide)
156
- prediction = Sequence.new
158
+ prediction = Query.new
157
159
  prediction.definition = ''
158
160
  prediction.identifier = ''
159
161
  prediction.type = :nucleotide
@@ -186,7 +188,7 @@ module GeneValidator
186
188
 
187
189
  describe 'Validate a duplicated sequence' do
188
190
  hits = BlastUtils.parse_next(iterator, :nucleotide)
189
- prediction = Sequence.new
191
+ prediction = Query.new
190
192
  prediction.definition = ''
191
193
  prediction.identifier = ''
192
194
  prediction.type = :nucleotide
@@ -230,7 +232,7 @@ module GeneValidator
230
232
  describe 'Validate a merged sequence' do
231
233
  hits = BlastUtils.parse_next(iterator, :nucleotide)
232
234
 
233
- prediction = Sequence.new
235
+ prediction = Query.new
234
236
  prediction.definition = ''
235
237
  prediction.identifier = ''
236
238
  prediction.type = :nucleotide
@@ -272,7 +274,7 @@ module GeneValidator
272
274
  describe 'Validate a sequence with a frameshift' do
273
275
  hits = BlastUtils.parse_next(iterator, :nucleotide)
274
276
 
275
- prediction = Sequence.new
277
+ prediction = Query.new
276
278
  prediction.definition = ''
277
279
  prediction.identifier = ''
278
280
  prediction.type = :nucleotide
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: genevalidator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.2
4
+ version: 1.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Monica Dragan
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-07-18 00:00:00.000000000 Z
14
+ date: 2015-07-28 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -146,23 +146,23 @@ files:
146
146
  - LICENCE.txt
147
147
  - README.md
148
148
  - Rakefile
149
- - aux/app_template_footer.erb
150
- - aux/app_template_header.erb
151
- - aux/files/css/bootstrap.min.css
152
- - aux/files/css/font-awesome.min.css
153
- - aux/files/css/style.css
149
+ - aux/files/css/genevalidator.compiled.min.css
150
+ - aux/files/css/src/bootstrap.min.css
151
+ - aux/files/css/src/font-awesome.min.css
152
+ - aux/files/css/src/style.css
154
153
  - aux/files/fonts/FontAwesome.otf
155
154
  - aux/files/fonts/fontawesome-webfont.eot
156
155
  - aux/files/fonts/fontawesome-webfont.svg
157
156
  - aux/files/fonts/fontawesome-webfont.ttf
158
157
  - aux/files/fonts/fontawesome-webfont.woff
159
158
  - aux/files/img/gene.png
160
- - aux/files/js/bootstrap.min.js
161
- - aux/files/js/d3.v3.min.js
162
- - aux/files/js/jquery-2.1.1.min.js
163
- - aux/files/js/jquery.tablesorter.min.js
164
- - aux/files/js/plots.js
165
- - aux/files/js/script.js
159
+ - aux/files/js/genevalidator.compiled.min.js
160
+ - aux/files/js/src/bootstrap.min.js
161
+ - aux/files/js/src/d3.v3.min.js
162
+ - aux/files/js/src/jquery-2.1.1.min.js
163
+ - aux/files/js/src/jquery.tablesorter.min.js
164
+ - aux/files/js/src/plots.js
165
+ - aux/files/js/src/script.js
166
166
  - aux/files/json/.gitkeep
167
167
  - aux/json_footer.erb
168
168
  - aux/json_header.erb
@@ -190,7 +190,7 @@ files:
190
190
  - lib/genevalidator/json_to_gv_results.rb
191
191
  - lib/genevalidator/output.rb
192
192
  - lib/genevalidator/pool.rb
193
- - lib/genevalidator/sequences.rb
193
+ - lib/genevalidator/query.rb
194
194
  - lib/genevalidator/tabular_parser.rb
195
195
  - lib/genevalidator/validation.rb
196
196
  - lib/genevalidator/validation_alignment.rb
@@ -237,7 +237,7 @@ files:
237
237
  - test/test_files/test_sequences.fasta.blast_xml.raw_seq.idx
238
238
  - test/test_files/test_validations.fasta
239
239
  - test/test_helper.rb
240
- - test/test_sequences.rb
240
+ - test/test_query.rb
241
241
  - test/test_validation_open_reading_frame.rb
242
242
  - test/test_validations.rb
243
243
  homepage: https://github.com/wurmlab/GeneValidator
@@ -310,7 +310,7 @@ test_files:
310
310
  - test/test_files/test_sequences.fasta.blast_xml.raw_seq.idx
311
311
  - test/test_files/test_validations.fasta
312
312
  - test/test_helper.rb
313
- - test/test_sequences.rb
313
+ - test/test_query.rb
314
314
  - test/test_validation_open_reading_frame.rb
315
315
  - test/test_validations.rb
316
316
  has_rdoc:
@@ -1 +0,0 @@
1
- </tbody></table><script>var evaluation_div = document.getElementById('report_1');evaluation_div.innerHTML = "<%= less %>";</script>
@@ -1,12 +0,0 @@
1
- <h4>Overview</h4><div id="report"><div id="report_1"></div></div><hr><h4 id="results_header">Results</h4><table id="sortable_table" class="table table-bordered table-condensed tablesorter"><thead><tr id="header"><th>#</th><th>Ranking</th><th>Sequence Definition<span data-toggle="tooltip" title="Query definition as it apears in the input fasta file." data-placement="top"><i class="fa fa-question-circle"></i></span></th><th>No. Hits<span data-toggle="tooltip" title="Number of non-identical hits found by BLAST." data-placement="top"><i class="fa fa-question-circle"></i></span></th>
2
- <% @validations.each do |item| %>
3
- <th class="sorter-false">
4
- <b><%= item.header %></b>
5
- <% if item.short_header == "LengthCluster" || item.short_header == "Gene_Merge" || item.short_header == "ORF" || item.short_header == "MA" %>
6
- <span data-toggle="tooltip" title="Charts available for this validation" data-placement="top"><i class="fa fa-bar-chart-o chartIcon"></i></span>&nbsp;<span data-toggle="tooltip" title="<%=item.description%>" data-placement="top"><i class="fa fa-question-circle"></i></span>
7
- <% else %>
8
- <span data-toggle="tooltip" title="<%=item.description%>" data-placement="top"><i class="fa fa-question-circle"></i></span>
9
- <% end %>
10
- </th>
11
- <% end %>
12
- <th class="sorter-false chart-column"></th></tr></thead><tbody>
@@ -1,828 +0,0 @@
1
- function show_all_plots(button){
2
- 'use strict';
3
- var plotBtns = $('.plot_btn');
4
- if (plotBtns.length > 30){
5
- $('#alert').modal();
6
- } else {
7
- if (window.chrome && (window.location.protocol === 'file:') ) {
8
- createChromeModal();
9
- } else {
10
-
11
- // show activity spinner
12
- $('#spinner1').modal({ backdrop: 'static', keyboard: 'false' });
13
-
14
- if (button.status !== 'pressed'){
15
- button.status = 'pressed';
16
- button.innerHTML = '<i class="fa fa-2x fa-bar-chart-o"></i><br>Hide All Charts';
17
- button.onclick = function() {
18
- hide_all_plots(button);
19
- };
20
- }
21
-
22
- remove_all_plots(); // remove all plots
23
-
24
- //iterate over the plot_btns and add data to each childRow
25
- $('.plot_btn').each (function(){
26
- addData(this, 'all');
27
- });
28
-
29
- $('#spinner1').modal('hide'); // remove activity spinner
30
- }
31
- }
32
- }
33
-
34
- function createChromeModal() {
35
- if (($('#browser-alert').length) === 0) {
36
- $('#browseralertText').html('<stong>Sorry, this feature is not supported in your browser.');
37
- $('#browseralert').modal();
38
- }
39
- }
40
-
41
- function remove_all_plots() {
42
- 'use strict';
43
- $('.tablesorter-childRow').each (function(){
44
- $(this).remove();
45
- });
46
-
47
- $('.plot_btn').each (function(){
48
- this.status = 'released';
49
- });
50
- }
51
-
52
- function hide_all_plots(button){
53
- 'use strict';
54
- button.status = 'released';
55
- button.innerHTML = '<i class="fa fa-2x fa-bar-chart-o"></i><br>Show All Charts';
56
- button.onclick = function() {
57
- show_all_plots(button);
58
- };
59
- remove_all_plots();
60
- }
61
-
62
- function addData(source, val){
63
- 'use strict';
64
- if (window.chrome && (window.location.protocol === 'file:') ) {
65
- createChromeModal();
66
- return true;
67
- }
68
- var graphs = '',
69
- graphData = '',
70
- $currentRow = $(source).closest('tr'),
71
- target = $currentRow.attr("data-target"),
72
- $childRow = $('#mainrow' + target);
73
-
74
- if ($childRow.length && source.status !== 'pressed') {
75
- // if you click on another td...
76
- emptyChildRow($currentRow, target, source);
77
- addDataToChildRow($currentRow, target, val);
78
- } else if ($childRow.length === 0){
79
- createChildRow($currentRow, target, source);
80
- addDataToChildRow($currentRow, target, val);
81
- } else if ($childRow.length) {
82
- removeChildRow($currentRow, $childRow, source);
83
- }
84
-
85
- $('table').trigger('update');
86
-
87
- }
88
-
89
- function addOverallPlot(file){
90
- $.getJSON(file, function( json ) {
91
- addPlot(json.data, 'report_1', json.type, json.title, json.footer, json.xtitle, json.ytitle);
92
- });
93
- }
94
-
95
- function createChildRow($currentRow, target, source){
96
- var childRowHTML = '<tr class="tablesorter-childRow" id="mainrow' + target + '"><td colspan="12" id="row' +
97
- target + '"><div id="' + target + '" class="expanded-child"></div></td></tr>';
98
- $currentRow.addClass('tablesorter-hasChildRow');
99
- $currentRow.after(childRowHTML);
100
- source.status = 'pressed';
101
- }
102
-
103
- function removeChildRow($currentRow, $childRow, source){
104
- $currentRow.removeClass('tablesorter-hasChildRow');
105
- $childRow.remove();
106
- source.status = 'released';
107
- }
108
-
109
- function emptyChildRow($currentRow, target, source){
110
- var targetId = '#' + target;
111
- var explanationId = '#' + target + 'explanation';
112
- $(targetId).empty();
113
- $(explanationId).remove();
114
- resetStatusOfOtherButtons($currentRow);
115
- source.status = 'pressed';
116
- }
117
-
118
- function resetStatusOfOtherButtons($currentRow){
119
- $currentRow.find('td').each (function(){
120
- if (this.status == 'pressed') { this.status = 'released'; }
121
- });
122
- $currentRow.find('.plot_btn').each (function(){
123
- if (this.status == 'pressed') { this.status = 'released'; }
124
- });
125
- }
126
-
127
- function addDataToChildRow($currentRow, target, val){
128
- var file = $currentRow.attr("data-jsonFile");
129
-
130
- $.getJSON(file, function( json ) {
131
- if (val === 'all'){
132
- for (var i in json.validations){
133
- if (json.validations[i].graphs !== undefined) {
134
- generatePlotCommands(json.validations[i].graphs, target);
135
- }
136
- }
137
- } else {
138
- addExplanation(target, json.validations[val]);
139
- if (json.validations[val].graphs !== undefined) {
140
- generatePlotCommands(json.validations[val].graphs, target);
141
- }
142
- }
143
- });
144
- }
145
-
146
- function generatePlotCommands(graphs, target) {
147
- for (var g = 0; g < graphs.length; g++) {
148
- var graphData = graphs[g];
149
- addPlot(graphData.data, target, graphData.type, graphData.title,
150
- graphData.footer, graphData.xtitle, graphData.ytitle,
151
- graphData.aux1, graphData.aux2);
152
- }
153
- }
154
-
155
- function addExplanation(target, jsonData){
156
- 'use strict';
157
- var row = '#row' + target;
158
- var approach_html = '<p><b>Approach:</b> ' + jsonData.approach + '</p>';
159
- var explanation_html = '<p><b>Explanation:</b> ' + jsonData.explanation + '</p>';
160
- var conclusion_html = '<p><b>Conclusion:</b> ' + jsonData.conclusion + '</p>';
161
-
162
- var explain = $('<div id="' + target + 'explanation" class="alert alert-info explanation_alert" role="alert">' +
163
- approach_html + explanation_html + conclusion_html + '</div>');
164
- $(row).prepend(explain);
165
- }
166
-
167
- function addPlot(jsonData, target, type, title, footer, xtitle, ytitle, aux1, aux2){
168
- 'use strict';
169
- var legend;
170
- if (footer === '') {
171
- legend = [];
172
- } else {
173
- legend = footer.split(';');
174
- }
175
-
176
- switch(type) {
177
- case 'scatter':
178
- plot_scatter(jsonData, target, title, footer, xtitle, ytitle, aux1, aux2);
179
- break;
180
- case 'bars':
181
- plot_bars(jsonData, target, title, legend, xtitle, ytitle, aux1);
182
- break;
183
- case 'simplebars':
184
- plot_simple_bars(jsonData, target, title, legend, xtitle, ytitle);
185
- break;
186
- case 'lines':
187
- if (aux2 !== null) {
188
- aux2 = aux2.split(',');
189
- }
190
- plot_lines(jsonData, target, title, legend, xtitle, ytitle, aux1, aux2);
191
- break;
192
- case 'align':
193
- if (aux2 !== null) {
194
- aux2 = aux2.split(',');
195
- }
196
- plot_align(jsonData, target, title, legend, xtitle, ytitle, aux1, aux2);
197
- break;
198
- default:
199
- break;
200
- }
201
- }
202
-
203
- function color_beautification(color){
204
- 'use strict';
205
- switch(color){
206
- case 'red':
207
- return d3.rgb(189,54,47);
208
- case 'blue':
209
- return d3.rgb(58,135,173);
210
- case 'green':
211
- return d3.rgb(70,136,71);
212
- case 'yellow':
213
- return d3.rgb(255,255,51);
214
- case 'orange':
215
- return d3.rgb(248,148,6);
216
- case 'violet':
217
- return d3.rgb(153,0,153);
218
- case 'gray':
219
- return d3.rgb(160,160,160);
220
- default:
221
- return color;
222
- }
223
- }
224
-
225
- // bars plot
226
- function plot_bars(alldata, target, title, footer, xTitle, yTitle, bar){
227
- var margin = {top: 70, right: 50, bottom: 75, left: 50},
228
- width = 600 - margin.left - margin.right,
229
- height = 500 - margin.top - margin.bottom;
230
- var legend_width = 15;
231
-
232
- var svg = d3.select("#".concat(target)).append("svg")
233
- .attr("width", width + margin.left + margin.right)
234
- .attr("height", height + margin.top + margin.bottom)
235
- .append("g")
236
- .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
237
-
238
- svg.append("text")
239
- .attr("x", (width / 2))
240
- .attr("y", -45)
241
- .attr("text-anchor", "middle")
242
- .style("font-size", "16px")
243
- .text(title);
244
-
245
- var colors = new Array("orange", "blue", "green", "yellow", "brown");
246
- var no_colors = colors.length;
247
-
248
- var padding = 100;
249
-
250
- flattened_data = [].concat.apply([], alldata);
251
- var yMax = d3.max(flattened_data, function(d) { return d.value; }) + 3;
252
- var y = d3.scale.linear()
253
- .domain([0, yMax + yMax/10])
254
- .range([height, 0]);
255
-
256
- var xMin = d3.min(flattened_data, function(d) { return d.key; });
257
- if (bar!=undefined){
258
- var xMin = Math.min(xMin, bar);
259
- }
260
-
261
- var xMax = d3.max(flattened_data, function(d) { return d.key; });
262
- if (bar!=undefined){
263
- var xMax = Math.max(xMax, bar);
264
- }
265
-
266
- var x = d3.scale.linear()
267
- .domain([xMin-padding, xMax+padding])
268
- .range([13, width]);
269
-
270
- var xAxis = d3.svg.axis()
271
- .scale(x)
272
- .orient("bottom")
273
- .ticks(8);
274
-
275
- var yAxis = d3.svg.axis()
276
- .scale(y)
277
- .orient("left")
278
- .tickFormat(d3.format("d"))
279
- .ticks(8);
280
-
281
- svg.append("g")
282
- .attr("class", "x axis")
283
- .attr("transform", "translate(0," + height + ")")
284
- .call(xAxis)
285
- .append("text")
286
- .attr("class", "label")
287
- .attr("x", (width-xTitle.length)/2-50)
288
- .attr("y", 35)
289
- .style("text-anchor", "start")
290
- .text(xTitle);
291
-
292
- svg.append("g")
293
- .attr("class", "y axis")
294
- .call(yAxis)
295
- .append("text")
296
- .attr("class", "label")
297
- .attr("transform", "rotate(-90)")
298
- .attr("x", -(height+yTitle.length)/2-50)
299
- .attr("y", -40)
300
- .style("text-anchor", "start")
301
- .text(yTitle);
302
-
303
- alldata.map( function(data, i) {
304
-
305
- color = colors[i % (no_colors - 1)];
306
- svg.selectAll(".bar")
307
- .data(data)
308
- .enter().append("rect")
309
- .attr("x", function(d) { return x(d.key); })
310
- .attr("width", 6)
311
- .attr("y", function(d) { return y(d.value); })
312
- .attr("height", function(d) { return height - y(d.value); })
313
- .attr("fill", function(d) { if (d.main == true) return color_beautification("red"); return color_beautification("blue");});
314
- });
315
-
316
- if (bar!=undefined){
317
- svg.append("rect")
318
- .attr("x", x(bar))
319
- .attr("width", 4)
320
- .attr("y", y(yMax + yMax/10))
321
- .style("opacity",0.6)
322
- .attr("height", height - y(yMax + yMax/8))
323
- .attr("fill", color_beautification("black"));
324
-
325
- svg.append("text")
326
- .attr("transform", "rotate(-90)")
327
- .attr("x", -yMax/10 - 35)
328
- .attr("y", x(bar) - 5)
329
- .text("query");
330
- }
331
-
332
- var offset = 0;
333
- var total_len = 0;
334
- for (var i = 0; i < footer.length; i++) {
335
- var array = footer[i].split(",");
336
- total_len = total_len + array[0].length*8 + 15;
337
- }
338
-
339
- for (var i = 0; i < footer.length; i++) {
340
-
341
- var array = footer[i].split(",");
342
- svg.append("rect")
343
- .attr("x", (width-total_len)/2 + offset)
344
- .attr("y", -30)
345
- .attr("width", 10)
346
- .attr("height", 10)
347
- .style("fill", color_beautification(array[1].replace(/\s+/g, '')));
348
-
349
- svg.append("text")
350
- .attr("x", (width-total_len)/2 + offset + 15)
351
- .attr("y", -20)
352
- .text(array[0]);
353
- offset = offset + array[0].length*8 + 15;
354
- }
355
- }
356
-
357
- // bars plot
358
- function plot_simple_bars(alldata, target, title, footer, xTitle, yTitle){
359
- 'use strict';
360
-
361
- var margin = {top: 70, right: 50, bottom: 75, left: 50},
362
- width = 600 - margin.left - margin.right,
363
- height = 500 - margin.top - margin.bottom;
364
- var legend_width = 15;
365
-
366
- var svg = d3.select("#".concat(target)).append("svg")
367
- .attr("width", width + margin.left + margin.right)
368
- .attr("height", height + margin.top + margin.bottom)
369
- .append("g")
370
- .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
371
-
372
- svg.append("text")
373
- .attr("x", (width / 2))
374
- .attr("y", -45)
375
- .attr("text-anchor", "middle")
376
- .style("font-size", "16px")
377
- .text(title);
378
-
379
- var colors = new Array("orange", "blue", "green", "yellow", "brown");
380
- var no_colors = colors.length;
381
-
382
- var padding = 0;
383
-
384
- var flattened_data = [].concat.apply([], alldata);
385
- var yMax = d3.max(flattened_data, function(d) { return d.value; }) + 3;
386
- var y = d3.scale.linear()
387
- .domain([0, yMax])
388
- .range([height, 0]);
389
-
390
- var xMin = d3.min(flattened_data, function(d) { return d.key; });
391
- var xMax = d3.max(flattened_data, function(d) { return d.key; });
392
-
393
- var x = d3.scale.linear()
394
- .domain([xMin-padding, xMax+padding])
395
- .range([13, width]);
396
-
397
- var xAxis = d3.svg.axis()
398
- .scale(x)
399
- .orient("bottom")
400
- .ticks(8);
401
-
402
- var yAxis = d3.svg.axis()
403
- .scale(y)
404
- .orient("left")
405
- .tickFormat(d3.format("d"))
406
- .ticks(8);
407
-
408
- svg.append("g")
409
- .attr("class", "x axis")
410
- .attr("transform", "translate(0," + height + ")")
411
- .call(xAxis)
412
- .append("text")
413
- .attr("class", "label")
414
- .attr("x", (width-xTitle.length)/2-50)
415
- .attr("y", 35)
416
- .style("text-anchor", "start")
417
- .text(xTitle);
418
-
419
- svg.append("g")
420
- .attr("class", "y axis")
421
- .call(yAxis)
422
- .append("text")
423
- .attr("class", "label")
424
- .attr("transform", "rotate(-90)")
425
- .attr("x", -(height+yTitle.length)/2-50)
426
- .attr("y", -40)
427
- .style("text-anchor", "start")
428
- .text(yTitle);
429
-
430
- alldata.map( function(data, i) {
431
-
432
- var color = colors[i % (no_colors - 1)];
433
-
434
- svg.selectAll(".bar")
435
- .data(data)
436
- .enter().append("rect")
437
- .attr("x", function(d) { return x(d.key); })
438
- .attr("width", 6)
439
- .attr("y", function(d) { return y(d.value); })
440
- .attr("height", function(d) { return height - y(d.value); })
441
- .attr("fill", function(d) { if (d.main == true) return color_beautification("red"); return color_beautification("blue");});
442
- });
443
- }
444
-
445
-
446
- // scatter plot
447
- // ecuation of the line: slope * x + yLine
448
- function plot_scatter(data, target, title, footer, xTitle, yTitle, yLine, slope){
449
- 'use strict';
450
-
451
- var margin = {top: 50, right: 30, bottom: 75, left: 50},
452
- width = 500 - margin.left - margin.right,
453
- height = 500 - margin.top - margin.bottom;
454
-
455
- var x = d3.scale.linear()
456
- .range([0, width]);
457
- var y = d3.scale.linear()
458
- .range([height, 0]);
459
-
460
- var color = d3.scale.category10();
461
-
462
- var xAxis = d3.svg.axis()
463
- .scale(x)
464
- .orient("bottom")
465
- .ticks(8);
466
- var yAxis = d3.svg.axis()
467
- .scale(y)
468
- .orient("left")
469
- .tickFormat(d3.format("d"))
470
- .ticks(8);
471
-
472
- var svg = d3.select("#".concat(target)).append("svg")
473
- .attr("width", width + margin.left + margin.right)
474
- .attr("height", height + margin.top + margin.bottom)
475
- .append("g")
476
- .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
477
-
478
- svg.append("text")
479
- .attr("x", (width / 2))
480
- .attr("y", -25)
481
- .attr("text-anchor", "middle")
482
- .style("font-size", "16px")
483
- .text(title);
484
-
485
- svg.append("text")
486
- .attr("x", (width / 2))
487
- .attr("y", height+ 55)
488
- .attr("text-anchor", "middle")
489
- .style("font-size", "12px")
490
- .text(footer);
491
-
492
- var xMax = d3.max(data, function(d) { return d.x; });
493
- var xMin = d3.min(data, function(d) { return d.x; });
494
- var yMax = d3.max(data, function(d) { return d.y; });
495
- var yMin = d3.min(data, function(d) { return d.y; });
496
- x.domain(d3.extent(data, function(d) { return d.x; })).nice();
497
- y.domain(d3.extent(data, function(d) { return d.y; })).nice();
498
-
499
- svg.append("g")
500
- .attr("class", "x axis")
501
- .attr("transform", "translate(0," + height + ")")
502
- .call(xAxis)
503
- .append("text")
504
- .attr("class", "label")
505
- .attr("x", (width-xTitle.length)/2-50)
506
- .attr("y", 35)
507
- .style("text-anchor", "start")
508
- .text(xTitle);
509
-
510
- svg.append("g")
511
- .attr("class", "y axis")
512
- .call(yAxis)
513
- .append("text")
514
- .attr("class", "label")
515
- .attr("transform", "rotate(-90)")
516
- .attr("x", -(height+yTitle.length)/2-50)
517
- .attr("y", -40)
518
- .style("text-anchor", "start")
519
- .text(yTitle);
520
-
521
- svg.selectAll(".dot")
522
- .data(data)
523
- .enter().append("circle")
524
- .attr("r", 2)
525
- .attr("cx", function(d) { return x(d.x); })
526
- .attr("cy", function(d) { return y(d.y); })
527
- .style("fill", function(d) { return color_beautification("red"); })
528
- .style("opacity",0.6);
529
-
530
- if ((slope!=undefined && slope != "") && (yLine!=undefined && yLine != "")){
531
- yLine = parseFloat(yLine.replace(",", "."));
532
- var xMaxValue = xMax;
533
- var yMaxValue = yLine + slope * xMax;
534
- if (yMaxValue > yMax){
535
- xMaxValue = (yMax-yLine)/slope;
536
- yMaxValue = yMax;
537
- }
538
-
539
- if (yMaxValue < yMin){
540
- xMaxValue = (yMin-yLine)/slope;
541
- yMaxValue = yMin;
542
- }
543
-
544
- var xMinValue = xMin;
545
- var yMinValue = yLine + slope * xMin;
546
- if (yMinValue > yMax){
547
- xMinValue = (yMax-yLine)/slope;
548
- yMinValue = yMin;
549
- }
550
-
551
- if (yMinValue < yMin){
552
- xMinValue = (yMin-yLine)/slope;
553
- yMinValue = yMin;
554
- }
555
-
556
- svg.append("line")
557
- .attr("x1", x(xMinValue))
558
- .attr("y1", y(yMinValue))
559
- .attr("x2", x(xMaxValue))
560
- .attr("y2", y(yMaxValue))
561
- .attr("stroke-width", 2)
562
- .attr("stroke", "black");
563
- }
564
- }
565
-
566
- // line plot
567
- // maximum 80 lines
568
- function plot_lines(data, target, title, footer, xTitle, yTitle, no_lines, yValues){
569
- 'use strict';
570
- var margin = {top: 70, right: 50, bottom: 75, left: 50},
571
- width = 600 - margin.left - margin.right,
572
- height = 500 - margin.top - margin.bottom;
573
- var legend_width = 17;
574
-
575
- var x = d3.scale.linear()
576
- .range([0, width]);
577
- var y = d3.scale.linear()
578
- .range([height, 0]);
579
-
580
- var color = d3.scale.category10();
581
-
582
- if (title === 'Open Reading Frames in all 6 Frames') {
583
- var xAxis = d3.svg.axis()
584
- .scale(x)
585
- .orient("bottom")
586
- .ticks(0);
587
- } else {
588
- var xAxis = d3.svg.axis()
589
- .scale(x)
590
- .orient("bottom")
591
- .ticks(5);
592
- }
593
-
594
- var yAxis = d3.svg.axis()
595
- .scale(y)
596
- .orient("left")
597
- .ticks(5);
598
-
599
- var svg = d3.select("#".concat(target)).append("svg")
600
- .attr("width", width + margin.left + margin.right)
601
- .attr("height", height + margin.top + margin.bottom)
602
- .append("g")
603
- .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
604
-
605
- svg.append("text")
606
- .attr("x", (width / 2))
607
- .attr("y", -35)
608
- .attr("text-anchor", "middle")
609
- .style("font-size", "16px")
610
- .text(title);
611
-
612
- var idx = -1;
613
-
614
- x.domain([0, d3.max(data, function(d) { return d.stop; })]);
615
- y.domain(d3.extent(data, function(d) { return d.y; })).nice();
616
-
617
- svg.append("g")
618
- .attr("class", "x axis")
619
- .attr("transform", "translate(0," + (height + height/no_lines) + ")")
620
- .call(xAxis)
621
- .append("text")
622
- .attr("class", "label")
623
- .attr("x", (width-xTitle.length)/2-50)
624
- .attr("y", 35)
625
- .style("text-anchor", "start")
626
- .text(xTitle);
627
-
628
- if (yValues !== null){
629
- svg.append("g")
630
- .attr("class", "y axis")
631
- .call(yAxis.ticks(yValues.length)
632
- .tickFormat(function (d) {
633
- idx = idx + 1;
634
- return yValues[idx];
635
- }))
636
- .append("text")
637
- .attr("class", "label")
638
- .attr("transform", "rotate(-90)")
639
- .attr("x", -(height+yTitle.length)/2-50)
640
- .attr("y", -40)
641
- .style("text-anchor", "start")
642
- .text(yTitle);
643
- } else {
644
- svg.append("g")
645
- .attr("class", "y axis")
646
- .call(yAxis)
647
- .append("text")
648
- .attr("class", "label")
649
- .attr("transform", "rotate(-90)")
650
- .attr("x", -(height+yTitle.length)/2)
651
- .attr("y", -40)
652
- .style("text-anchor", "start")
653
- .text(yTitle);
654
- }
655
-
656
- svg.selectAll(".dot")
657
- .data(data)
658
- .enter().append("line")
659
- .attr("x1", function(d) { return x(d.start); })
660
- .attr("y1", function(d) { return y(d.y); })
661
- .attr("x2", function(d) { return x(d.stop); })
662
- .attr("x2", function(d) { return x(d.stop); })
663
- .attr("y2", function(d) { return y(d.y); })
664
- .attr("stroke-width", function(d) {
665
- if (d.dotted == undefined) {
666
- if (d.color == "red" ) {
667
- return height/no_lines/2.5;
668
- } else {
669
- return height/no_lines;
670
- }
671
- } else {
672
- return height/no_lines/5;
673
- }
674
- })
675
- .style("stroke-dasharray", function(d) { if (d.dotted == undefined) return ("0, 0"); return ("2, 6");})
676
- .attr("stroke", function(d) { return color_beautification(d.color); });
677
-
678
- // add legend
679
- var legend = svg.append("g")
680
- .attr("class", "legend")
681
- .attr("height", 100)
682
- .attr("width", 100)
683
- .attr('transform', 'translate(-20,50)');
684
-
685
- var h = 0;
686
-
687
- var offset = 40;
688
- var total_len = 0;
689
- for (var i = 0; i < footer.length; i++) {
690
- var array = footer[i].split(",");
691
- total_len = total_len + array[0].length*8 + 15;
692
- }
693
-
694
- for (var i = 0; i < footer.length; i++) {
695
- var array = footer[i].split(",");
696
- svg.append("rect")
697
- .attr("x", (width-total_len)/2 + offset)
698
- .attr("y", -30)
699
- .attr("width", 10)
700
- .attr("height", 10)
701
- .style("fill", color_beautification(array[1].replace(/\s+/g, '')));
702
-
703
- svg.append("text")
704
- .attr("x", (width-total_len)/2 + offset + 15)
705
- .attr("y", -20)
706
- .text(array[0]);
707
- offset = offset + array[0].length*8 + 15;
708
- }
709
- }
710
-
711
- // line plot
712
- // maximum 80 lines
713
- function plot_align(data, target, title, footer, xTitle, yTitle, no_lines, yValues){
714
- 'use strict';
715
-
716
- var margin = {top: 75, right: 50, bottom: 75, left: 150},
717
- width = 600 - margin.left - margin.right,
718
- height = 300 - margin.top - margin.bottom;
719
- var legend_width = 17;
720
-
721
- var x = d3.scale.linear()
722
- .range([0, width]);
723
- var y = d3.scale.linear()
724
- .range([height, 0]);
725
-
726
- var color = d3.scale.category10();
727
-
728
- var xAxis = d3.svg.axis()
729
- .scale(x)
730
- .orient("bottom")
731
- .ticks(5);
732
-
733
- var yAxis = d3.svg.axis()
734
- .scale(y)
735
- .orient("left")
736
- .ticks(5);
737
-
738
- var svg = d3.select("#".concat(target)).append("svg")
739
- .style("vertical-align", "top")
740
- .attr("width", width + margin.left + margin.right)
741
- .attr("height", height + margin.top + margin.bottom)
742
- .append("g")
743
- .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
744
-
745
- svg.append("text")
746
- .attr("x", (width / 2))
747
- .attr("y", -35)
748
- .attr("text-anchor", "middle")
749
- .style("font-size", "16px")
750
- .text(title);
751
-
752
- var idx = -1;
753
-
754
- x.domain([0, d3.max(data, function(d) { return d.stop; })]);
755
- y.domain(d3.extent(data, function(d) { return d.y; })).nice();
756
-
757
- svg.append("g")
758
- .attr("class", "x axis")
759
- .attr("transform", "translate(0," + (height+height/no_lines) + ")")
760
- .call(xAxis)
761
- .append("text")
762
- .attr("class", "label")
763
- .attr("x", (width-xTitle.length)/2-50)
764
- .attr("y", 35)
765
- .style("text-anchor", "start")
766
- .text(xTitle);
767
-
768
- if (yValues !== null){
769
- svg.append("g")
770
- .attr("class", "y axis")
771
- .call(yAxis.ticks(yValues.length)
772
- .tickFormat(function (d) {
773
- idx = idx + 1;
774
- return yValues[idx];
775
- }))
776
- .append("text")
777
- .attr("class", "label")
778
- .attr("transform", "rotate(-90)")
779
- .attr("x", -(height+yTitle.length)/2-50)
780
- .attr("y", -40)
781
- .style("text-anchor", "start")
782
- .text(yTitle);
783
- } else {
784
- svg.append("g")
785
- .attr("class", "y axis")
786
- .call(yAxis)
787
- .append("text")
788
- .attr("class", "label")
789
- .attr("transform", "rotate(-90)")
790
- .attr("x", -(height+yTitle.length)/2-50)
791
- .attr("y", -40)
792
- .style("text-anchor", "start")
793
- .text(yTitle);
794
- }
795
-
796
- svg.selectAll(".dot")
797
- .data(data)
798
- .enter().append("line")
799
- .attr("x1", function(d) { return x(d.start); })
800
- .attr("y1", function(d) { return y(d.y); })
801
- .attr("x2", function(d) { return x(d.stop); })
802
- .attr("y2", function(d) { return y(d.y); })
803
- .attr("stroke-width", function(d) { if (d.height == -1) return height/no_lines; return (height/no_lines * d.height) ; })
804
- .attr("stroke", function(d) { return color_beautification(d.color); });
805
-
806
- var offset = 0;
807
- var total_len = 0;
808
- for (var i = 0; i < footer.length; i++) {
809
- var array = footer[i].split(",");
810
- total_len = total_len + array[0].length*8 + 15;
811
- }
812
-
813
- for (var i = 0; i < footer.length; i++) {
814
- var array = footer[i].split(",");
815
- svg.append("rect")
816
- .attr("x", (width-total_len)/2 + offset)
817
- .attr("y", -30)
818
- .attr("width", 10)
819
- .attr("height", 10)
820
- .style("fill", color_beautification(array[1].replace(/\s+/g, '')));
821
-
822
- svg.append("text")
823
- .attr("x", (width-total_len)/2 + offset + 15)
824
- .attr("y", -20)
825
- .text(array[0]);
826
- offset = offset + array[0].length*8 + 15;
827
- }
828
- }