genevalidator 1.6.1 → 1.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -1
  3. data/.travis.yml +2 -0
  4. data/README.md +78 -30
  5. data/Rakefile +11 -8
  6. data/aux/app_template_footer.erb +1 -6
  7. data/aux/app_template_header.erb +12 -32
  8. data/aux/files/css/style.css +2 -8
  9. data/aux/files/js/plots.js +564 -576
  10. data/aux/files/js/script.js +10 -0
  11. data/aux/json_footer.erb +8 -0
  12. data/aux/json_header.erb +19 -0
  13. data/aux/json_query.erb +14 -0
  14. data/aux/template_footer.erb +9 -58
  15. data/aux/template_header.erb +18 -58
  16. data/aux/template_query.erb +8 -36
  17. data/bin/genevalidator +45 -32
  18. data/genevalidator.gemspec +11 -7
  19. data/lib/genevalidator.rb +75 -455
  20. data/lib/genevalidator/arg_validation.rb +78 -107
  21. data/lib/genevalidator/blast.rb +57 -60
  22. data/lib/genevalidator/clusterization.rb +15 -15
  23. data/lib/genevalidator/exceptions.rb +32 -5
  24. data/lib/genevalidator/get_raw_sequences.rb +70 -33
  25. data/lib/genevalidator/hsp.rb +1 -4
  26. data/lib/genevalidator/json_to_gv_results.rb +109 -0
  27. data/lib/genevalidator/output.rb +177 -185
  28. data/lib/genevalidator/pool.rb +2 -1
  29. data/lib/genevalidator/sequences.rb +3 -3
  30. data/lib/genevalidator/tabular_parser.rb +24 -18
  31. data/lib/genevalidator/validation.rb +279 -0
  32. data/lib/genevalidator/validation_alignment.rb +31 -47
  33. data/lib/genevalidator/validation_blast_reading_frame.rb +19 -18
  34. data/lib/genevalidator/validation_duplication.rb +23 -19
  35. data/lib/genevalidator/validation_gene_merge.rb +30 -65
  36. data/lib/genevalidator/validation_length_cluster.rb +14 -53
  37. data/lib/genevalidator/validation_length_rank.rb +10 -11
  38. data/lib/genevalidator/validation_open_reading_frame.rb +18 -19
  39. data/lib/genevalidator/validation_report.rb +2 -5
  40. data/lib/genevalidator/validation_test.rb +8 -4
  41. data/lib/genevalidator/version.rb +1 -1
  42. data/test/test_all_validations.rb +51 -66
  43. data/test/test_blast.rb +68 -51
  44. data/test/test_clusterization.rb +1 -1
  45. data/test/test_clusterization_2d.rb +19 -13
  46. data/test/test_extended_array_methods.rb +1 -1
  47. data/test/test_files/all_validations_mrna/mrna.blast_tab6 +1806 -0
  48. data/test/test_files/all_validations_mrna/mrna.blast_tab7 +1865 -0
  49. data/test/test_files/all_validations_mrna/{all_validations_mrna.fasta.blast_xml → mrna.blast_xml} +18642 -1
  50. data/test/test_files/all_validations_mrna/{all_validations_mrna.fasta.blast_xml.index → mrna.blast_xml.index} +300 -0
  51. data/test/test_files/all_validations_mrna/{all_validations_mrna.fasta → mrna.fa} +0 -0
  52. data/test/test_files/all_validations_mrna/mrna.raw_seq +3970 -0
  53. data/test/test_files/all_validations_mrna/{all_validations_mrna.fasta.blast_xml.raw_seq.idx → mrna.raw_seq.idx} +901 -1
  54. data/test/test_files/all_validations_prot/{all_validations_prot.fasta.blast_tab → prot.blast_tab6} +416 -0
  55. data/test/test_files/all_validations_prot/prot.blast_tab7 +2400 -0
  56. data/test/test_files/all_validations_prot/{all_validations_prot.fasta.blast_xml → prot.blast_xml} +18299 -6723
  57. data/test/test_files/all_validations_prot/{all_validations_prot.fasta.blast_xml.index → prot.blast_xml.index} +408 -0
  58. data/test/test_files/all_validations_prot/{all_validations_prot.fasta → prot.fa} +0 -0
  59. data/test/test_files/all_validations_prot/{all_validations_prot.fasta.blast_xml.raw_seq → prot.raw_seq} +2735 -0
  60. data/test/test_files/all_validations_prot/{all_validations_prot.fasta.blast_xml.raw_seq.idx → prot.raw_seq.idx} +3032 -1808
  61. data/test/test_sequences.rb +46 -41
  62. data/test/test_validation_open_reading_frame.rb +318 -202
  63. data/test/test_validations.rb +48 -32
  64. metadata +76 -102
  65. data/doc/AliasDuplicationError.html +0 -134
  66. data/doc/AlignmentValidation.html +0 -1687
  67. data/doc/AlignmentValidationOutput.html +0 -659
  68. data/doc/Blast.html +0 -1905
  69. data/doc/BlastRFValidationOutput.html +0 -545
  70. data/doc/BlastReadingFrameValidation.html +0 -370
  71. data/doc/BlastUtils.html +0 -875
  72. data/doc/ClasspathError.html +0 -134
  73. data/doc/Cluster.html +0 -1316
  74. data/doc/DuplciationValidationOutput.html +0 -564
  75. data/doc/DuplicationValidation.html +0 -920
  76. data/doc/DuplicationValidationOutput.html +0 -564
  77. data/doc/FileNotFoundException.html +0 -134
  78. data/doc/GeneMergeValidation.html +0 -935
  79. data/doc/GeneMergeValidationOutput.html +0 -652
  80. data/doc/HierarchicalClusterization.html +0 -994
  81. data/doc/Hsp.html +0 -1485
  82. data/doc/InconsistentTabularFormat.html +0 -135
  83. data/doc/LengthClusterValidation.html +0 -982
  84. data/doc/LengthClusterValidationOutput.html +0 -515
  85. data/doc/LengthRankValidation.html +0 -496
  86. data/doc/LengthRankValidationOutput.html +0 -517
  87. data/doc/NoInternetError.html +0 -135
  88. data/doc/NoMafftInstallationError.html +0 -134
  89. data/doc/NoPIdentError.html +0 -134
  90. data/doc/NoValidationError.html +0 -134
  91. data/doc/NotEnoughHitsError.html +0 -135
  92. data/doc/ORFValidationOutput.html +0 -593
  93. data/doc/OpenReadingFrameValidation.html +0 -1107
  94. data/doc/OtherError.html +0 -123
  95. data/doc/Output.html +0 -1540
  96. data/doc/Pair.html +0 -309
  97. data/doc/PairCluster.html +0 -767
  98. data/doc/Plot.html +0 -837
  99. data/doc/QueryError.html +0 -134
  100. data/doc/ReportClassError.html +0 -135
  101. data/doc/Sequence.html +0 -1299
  102. data/doc/SequenceTypeError.html +0 -135
  103. data/doc/TabularEntry.html +0 -837
  104. data/doc/TabularParser.html +0 -1104
  105. data/doc/Validation.html +0 -2147
  106. data/doc/ValidationClassError.html +0 -134
  107. data/doc/ValidationOutput.html +0 -460
  108. data/doc/ValidationReport.html +0 -940
  109. data/doc/ValidationTest.html +0 -939
  110. data/doc/_index.html +0 -449
  111. data/doc/class_list.html +0 -54
  112. data/doc/css/common.css +0 -1
  113. data/doc/css/full_list.css +0 -57
  114. data/doc/css/style.css +0 -338
  115. data/doc/file.README.html +0 -151
  116. data/doc/file_list.html +0 -56
  117. data/doc/frames.html +0 -26
  118. data/doc/index.html +0 -151
  119. data/doc/js/app.js +0 -214
  120. data/doc/js/full_list.js +0 -178
  121. data/doc/js/jquery.js +0 -4
  122. data/doc/method_list.html +0 -1505
  123. data/doc/top-level-namespace.html +0 -112
  124. data/test/test_files/all_validations_mrna/all_validations_mrna.fasta.blast_tab +0 -967
  125. data/test/test_files/all_validations_mrna/all_validations_mrna.fasta.blast_tab.index +0 -967
  126. data/test/test_files/all_validations_mrna/all_validations_mrna.fasta.blast_tab.raw_seq +0 -4929
  127. data/test/test_files/all_validations_mrna/all_validations_mrna.fasta.blast_tab.raw_seq.idx +0 -1006
  128. data/test/test_files/all_validations_mrna/all_validations_mrna.fasta.blast_xml.raw_seq +0 -2075
  129. data/test/test_files/all_validations_prot/all_validations_prot.fasta.blast_tab.index +0 -1864
  130. data/test/test_files/all_validations_prot/all_validations_prot.fasta.blast_tab.raw_seq +0 -42411
  131. data/test/test_files/all_validations_prot/all_validations_prot.fasta.blast_tab.raw_seq.idx +0 -3751
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f07216ae6800450b5a4d0bfcf9abf98e076075ba
4
- data.tar.gz: 9a610b7f1d9f8c9ad692e0b6502f2718d28b12e6
3
+ metadata.gz: 96ce3d3767132621e5b854bfbda040e4d9fdbf13
4
+ data.tar.gz: 647c391a49a6f066289cc97362c0374ef1aa56f3
5
5
  SHA512:
6
- metadata.gz: 13c125b3ce9cf977c666d7e95ee12f2d9ae0198991fe65d0a25ae6d5c826b5c1e341bc84bbad6b37eb2ad8bd60d74ead430e0b294addb9090ab146df9b0795bf
7
- data.tar.gz: 2964e12515bc80b1159e941e51d5be44da8ec36407259f45195350545f83ee319da30e6b8987058de86b085a7985617f88f0dd348bbaa99eb9d14ee5f59836f7
6
+ metadata.gz: 22452fd09598a352ad386011150a71ceb24dda54cdcbed1ae691b0e1a7258318479b80d83478003ddfc5e4e4b3fd60a5ffa07335bad55e2465ca83d338045d8a
7
+ data.tar.gz: 81ea0ebbeeaa81ffc18bd359b531cf0b8000019f37e266fad0fcd6ffa00867a49c8c1a2adfd37141dc0b052c16bc7a4d373d9e3ed9ab60b4ec32efc9613c7614
data/.gitignore CHANGED
@@ -4,4 +4,6 @@
4
4
  .DS_Store
5
5
  Gemfile.lock
6
6
  # Gemnasium gem configuration file
7
- config/gemnasium.yml
7
+ config/gemnasium.yml
8
+ doc
9
+ .yardoc
@@ -10,6 +10,8 @@ before_install:
10
10
  - ruby -pi -e "gsub(/^PREFIX = \/usr\/local/, 'PREFIX = ~/mafft/')" ~/mafft-7.205-with-extensions/core/Makefile
11
11
  - (cd ~/mafft-7.205-with-extensions/core/ && make clean && make && make install)
12
12
  - export PATH=$PATH:~/mafft/bin
13
+ cache: bundler
14
+ sudo: false
13
15
  script: bundle exec rake test
14
16
  addons:
15
17
  code_climate:
data/README.md CHANGED
@@ -48,16 +48,16 @@ $ gem install genevalidator
48
48
 
49
49
 
50
50
  ## Usage
51
- 1) After installing, GeneValidator can be run by typing the following command in the terminal
51
+ 1) After installing, GeneValidator can be run by typing the following command in the terminal:
52
52
 
53
- ```bash
54
53
 
54
+ ```bash
55
55
  USAGE:
56
56
  $ genevalidator [OPTIONS] Input_File
57
-
57
+
58
58
  ARGUMENTS:
59
59
  Input_File: Path to the input fasta file containing the predicted sequences.
60
-
60
+
61
61
  OPTIONAL ARGUMENTS
62
62
  -v, --validations <String> The Validations to be applied.
63
63
  Validation Options Available (separated by coma):
@@ -72,59 +72,63 @@ OPTIONAL ARGUMENTS
72
72
  -d, --db [BLAST_DATABASE] Path to the BLAST database
73
73
  GeneValidator also supports remote databases:
74
74
  e.g. $ genevalidator -d "swissprot -remote" Input_File
75
- -x, --blast_xml_file [FILE] Provide GeneValidator with a pre-computed BLAST XML output
76
- file (BLAST -outfmt option 5).
77
- -t, --blast_tabular_file [FILE] Provide GeneValidator with a pre-computed BLAST tabular output
78
- file. (BLAST -outfmt option 6).
79
- -o [Options], Custom format used in BLAST -outfmt argument
75
+ -e, --extract_raw_seqs Produces a fasta file of the raw sequences of all BLAST hits in the
76
+ supplied BLAST output file. This fasta file can then be provided to
77
+ GeneValidator with the "-r", "--raw_sequences" argument
78
+ -j, --json_file [JSON_FILE] Generate GV results from a json file (or a subset of a json file)
79
+ produced from GeneValidator
80
+ -x [BLAST_XML_FILE], Provide GeneValidator with a pre-computed BLAST XML output
81
+ --blast_xml_file file (BLAST -outfmt option 5).
82
+ -t [BLAST_TABULAR_FILE], Provide GeneValidator with a pre-computed BLAST tabular output
83
+ --blast_tabular_file file. (BLAST -outfmt option 6).
84
+ -o [BLAST_TABULAR_OPTIONS], Custom format used in BLAST -outfmt argument
80
85
  --blast_tabular_options See BLAST+ manual pages for more details
81
86
  -n, --num_threads num_of_threads Specify the number of processor threads to use when running
82
87
  BLAST and Mafft within GeneValidator.
83
88
  -f, --fast Run BLAST on all sequences together (rather than separately)
84
89
  to speed up the analysis.
85
- The speed difference is more apparent on larger input files
90
+ However, this means that there will be a longer wait before the
91
+ results can be viewed (as GeneValidator will need to run BLAST
92
+ on all sequences before producing any results).
93
+ The speed difference will be more apparent on larger input files
94
+ -r, --raw_sequences [raw_seq] Supply a fasta file of the raw sequences of all BLAST hits present
95
+ in the supplied BLAST XML or BLAST tabular file.
86
96
  -m, --mafft_bin [MAFFT_PATH] Path to MAFFT bin folder (is added to $PATH variable)
87
97
  -b, --blast_bin [BLAST_PATH] Path to BLAST+ bin folder (is added to $PATH variable)
88
98
  --version The version of GeneValidator that you are running.
89
99
  -h, --help Show this screen.
90
-
91
-
92
100
  ```
93
101
 
94
102
  Please type `genevalidator -h` into your terminal to see this information in your terminal.
95
103
 
96
104
  ## Example Usage Scenarios
97
105
 
98
- ##### Running GeneValidator with a local Database, with two threads
106
+ ##### Local Database, with custom number of threads (in this case 8)
99
107
 
100
108
  ```bash
101
- $ genevalidator -d 'Path-to-local-BLAST-db' -n 2 Input_FASTA_File
109
+ $ genevalidator -d 'Path-to-local-BLAST-db' -n 8 Input_FASTA_File
102
110
  ```
103
-
104
- ##### Running GeneValidator with a remote Database
111
+ ##### Local Database, with the fast mode, with custom number of threads (in this case 8)
112
+ Internally, GV will run BLAST on all input sequences before analysing any sequences (instead of running BLAST on each sequence and then analysing the sequence).
105
113
 
106
114
  ```bash
107
- $ genevalidator -d 'swissprot -remote' Input_FASTA_File
115
+ $ genevalidator -d 'Path-to-local-BLAST-db' -n 8 -f Input_FASTA_File
108
116
  ```
109
117
 
110
- ##### Running GeneValidator with a pre-computed BLAST XML file
111
-
118
+ ##### Local Database, with pre-computed BLAST XML file, with custom number of threads (in this case 8)
112
119
 
113
120
  ```bash
114
- $ genevalidator -d 'local-or-remote-BLAST-db' -x 'Path-to-XML-file' Input_FASTA_File
121
+ $ blast(p/x) -db SwissProt -out Path-to-XML-file -num_threads 8 -outfmt 5 -query Input_FASTA_File
122
+ $ genevalidator -d 'local-or-remote-BLAST-db' -n 8 -x 'Path-to-XML-file' Input_FASTA_File
115
123
  ```
116
124
 
117
- ##### Running GeneValidator with a pre-computed BLAST tabular file
125
+ ##### Local Database, with pre-computed BLAST XML file, with custom number of threads (in this case 8)
118
126
 
119
127
  ```bash
120
- $ genevalidator -d 'local-or-remote-BLAST-db' -t 'Path-to-tabular-file' -o 'qseqid sseqid sacc slen qstart qend sstart send length qframe pident evalue' Input_FASTA_File
128
+ $ blast(p/x) -db SwissProt -out Path-to-tabular-file -num_threads 8 -outfmt "7 qseqid sseqid sacc slen qstart qend sstart send length qframe pident nident evalue qseq sseq" -query Input_FASTA_File
129
+ $ genevalidator -d 'local-or-remote-BLAST-db' -n 8 -t 'Path-to-tabular-file' -o 'qseqid sseqid sacc slen qstart qend sstart send length qframe pident evalue' Input_FASTA_File
121
130
  ```
122
131
 
123
- ##### Running GeneValidator with the fast option
124
-
125
- ```bash
126
- $ genevalidator -d 'Path-to-local-BLAST-db' -n 2 -f Input_FASTA_File
127
- ```
128
132
 
129
133
  ## Output
130
134
  The output produced by GeneValidator is presented in three manners.
@@ -132,12 +136,56 @@ The output produced by GeneValidator is presented in three manners.
132
136
  #### HTML Output
133
137
  Firstly, the output is produced as a colourful, HTML file. This file is titled 'results.html' (found in the 'html' folder) and can be opened in a web browser (please use Mozilla Firefox). This file contains all the results in an easy-to-view manner with graphical visualisations. See exemplar html output [here](http://wurmlab.github.io/tools/genevalidator/exemplar_data/protein_input/) (protein input data) and [here](http://wurmlab.github.io/tools/genevalidator/exemplar_data/genetic_input/) (DNA input data).
134
138
 
135
- #### Yaml Output
136
- The output is also produced in YAML. This allows you to reuse the results and all the related global variables within your own programs.
139
+ #### JSON Output
140
+ The output is also produced in JSON. GeneValidator is able to re-generate results for any JSON files (or derived JSON files) with that were previously generated by the program. This means that you are able to use the JSON file in your own analysis pipelines and then use GeneValidator to produce the HTML output for the analysed JSON file.
137
141
 
138
142
  #### Terminal Output
139
143
  Lastly, a summary of the results is also outputted in the terminal to provide quick feedback on the results.
140
144
 
141
- ### Other Resources
145
+
146
+ ## Analysing the JSON output
147
+
148
+ There are numerous methods to analyse the JSON output including the [streamable JSON command line program](http://trentm.com/json/). The below examples use this tool.
149
+
150
+ ### Examplar JSON CLI Installation
151
+ After installing node:
152
+
153
+ ```bash
154
+ $ npm install -g json
155
+ ```
156
+
157
+ ### Filtering the results
158
+
159
+ - Extract sequences that have an overall score of 100
160
+
161
+ ```bash
162
+ $ json -f INPUT_JSON_FILE -c 'this.overall_score == 100' > OUTPUT_JSON_FILE
163
+ ```
164
+
165
+ - Extract sequences that have an overall score of over 70
166
+
167
+ ```bash
168
+ $ json -f INPUT_JSON_FILE -c 'this.overall_score > 70' > OUTPUT_JSON_FILE
169
+ ```
170
+
171
+ - Extract sequences that have more than 50 hits
172
+
173
+ ```bash
174
+ $ json -f INPUT_JSON_FILE -c 'this.no_hits > 50' > OUTPUT_JSON_FILE
175
+ ```
176
+
177
+ - Sort the JSON based on the overall score (ascending - 0 to 100)
178
+
179
+ ```bash
180
+ $ json -f INPUT_JSON_FILE -A -e 'this.sort(function(a,b) {return (a.overall_score > b.overall_score) ? 1 : ((b.overall_score > a.overall_score) ? -1 : 0);} );' > OUTPUT_JSON_FILE
181
+ ```
182
+
183
+ - Sort the JSON based on the overall score (decending - 100 to 0)
184
+
185
+ ```bash
186
+ json -f INPUT_JSON_FILE -A -e 'this.sort(function(a,b) {return (a.overall_score < b.overall_score) ? 1 : ((b.overall_score < a.overall_score) ? -1 : 0);} );' > OUTPUT_JSON_FILE
187
+ ```
188
+
189
+ ## Other Resources
142
190
 
143
191
  * [Full Documentation](http://wurmlab.github.io/tools/genevalidator/documentation/v1/)
data/Rakefile CHANGED
@@ -2,15 +2,18 @@ require 'rake/testtask'
2
2
 
3
3
  task default: [:build]
4
4
 
5
- desc 'Installs the ruby gem'
6
- task :build do
7
- lib = File.expand_path('../lib', __FILE__)
8
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
9
- require 'genevalidator/version'
10
- exec("gem build genevalidator.gemspec && gem install ./genevalidator-#{GeneValidator::VERSION}.gem")
5
+ desc 'Builds and installs'
6
+ task install: [:build] do
7
+ require_relative 'lib/genevalidator/version'
8
+ sh "gem install ./genevalidator-#{GeneValidator::VERSION}.gem"
11
9
  end
12
10
 
13
- desc 'Unit tests for the majority of class methods'
11
+ desc 'Runs tests, generates documentation, builds gem (default)'
12
+ task :build => [:test, :doc] do
13
+ sh 'gem build genevalidator.gemspec'
14
+ end
15
+
16
+ desc 'Runs tests'
14
17
  task :test do
15
18
  Rake::TestTask.new do |t|
16
19
  t.libs.push 'lib'
@@ -21,5 +24,5 @@ end
21
24
 
22
25
  desc 'Generates documentation'
23
26
  task :doc do
24
- exec("yardoc 'lib/**/*.rb'")
27
+ sh "yardoc 'lib/**/*.rb'"
25
28
  end
@@ -1,6 +1 @@
1
- </tbody>
2
- </table>
3
- <script>
4
- var evaluation_div = document.getElementById('report_1');
5
- evaluation_div.innerHTML = "<%= less %>";
6
- </script>
1
+ </tbody></table><script>var evaluation_div = document.getElementById('report_1');evaluation_div.innerHTML = "<%= less %>";</script>
@@ -1,32 +1,12 @@
1
- <h4>Overview</h4>
2
- <div id="report">
3
- <div id="report_1"></div>
4
- </div>
5
- <hr>
6
- <h4 id="results_header">Results</h4>
7
- <table id="sortable_table" class="table table-bordered table-condensed tablesorter">
8
- <thead>
9
- <tr id="header">
10
- <th>#</th>
11
- <th>Ranking</th>
12
- <th>Sequence Definition
13
- <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>
14
- </th>
15
- <th>No. Hits
16
- <span data-toggle="tooltip" title="Number of non-identical hits found by BLAST." data-placement="top"><i class="fa fa-question-circle"></i></span>
17
- </th>
18
- <% @validations.each do |item| %>
19
- <th class="sorter-false">
20
- <b><%= item.header %></b>
21
- <% if item.short_header == "LengthCluster" || item.short_header == "Gene_Merge" || item.short_header == "ORF" || item.short_header == "MA" %>
22
- <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>
23
- <% else %>
24
- <span data-toggle="tooltip" title="<%=item.description%>" data-placement="top"><i class="fa fa-question-circle"></i></span>
25
- <% end %>
26
- </th>
27
- <% end %>
28
- <th class="sorter-false chart-column"></th>
29
- </tr>
30
- </thead>
31
-
32
- <tbody>
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>
@@ -75,12 +75,6 @@ tr {
75
75
  text-align: center;
76
76
  }
77
77
 
78
- /* table striped backgrounds ___________*/
79
-
80
- tbody > tr:nth-child(4n+1), tbody > tr:nth-child(4n+2) {
81
- background-color: #f5f5f5;
82
- }
83
-
84
78
  /* table sorter ___________*/
85
79
 
86
80
  .tablesorter-default .header,
@@ -158,11 +152,11 @@ tbody > tr:nth-child(4n+1), tbody > tr:nth-child(4n+2) {
158
152
  cursor: pointer !important;
159
153
  }
160
154
 
161
- .danger:hover {
155
+ .table tbody td.danger:hover {
162
156
  background-color: rgb(242, 203, 203) !important;
163
157
  }
164
158
 
165
- .success:hover{
159
+ .table tbody td.success:hover{
166
160
  background-color: rgb(204, 228, 200) !important;
167
161
  }
168
162
 
@@ -1,151 +1,170 @@
1
1
  function show_all_plots(button){
2
2
  'use strict';
3
- var expand_children = document.getElementsByName('plot_row');
4
- if (expand_children.length < 30){
3
+ var plotBtns = $('.plot_btn');
4
+ if (plotBtns.length > 30){
5
+ $('#alert').modal();
6
+ } else {
5
7
  if (window.chrome && (window.location.protocol === 'file:') ) {
6
- if (($('#browser-alert').length) === 0) {
7
- $('#browseralertText').html('<stong>Sorry, this feature is not supported in your browser.');
8
- $('#browseralert').modal();
9
- }
8
+ createChromeModal();
10
9
  } else {
11
-
10
+
12
11
  // show activity spinner
13
- $('#spinner1').modal({
14
- backdrop: 'static',
15
- keyboard: 'false'
16
- });
12
+ $('#spinner1').modal({ backdrop: 'static', keyboard: 'false' });
17
13
 
18
14
  if (button.status !== 'pressed'){
19
15
  button.status = 'pressed';
20
16
  button.innerHTML = '<i class="fa fa-2x fa-bar-chart-o"></i><br>Hide All Charts';
21
17
  button.onclick = function() {
22
- hide_all_plots(button, expand_children);
18
+ hide_all_plots(button);
23
19
  };
24
20
  }
25
21
 
26
- //display plots in the dom
27
- var buttons_dom = document.getElementsByName('plot_btn');
28
- // remove all plots
29
- remove_all_plots(expand_children);
22
+ remove_all_plots(); // remove all plots
30
23
 
31
- for (var i = 0; i < expand_children.length; i++) {
32
- var expand_child_div = expand_children[i].getElementsByTagName('div')[0];
33
- show_plot(buttons_dom[i], expand_child_div);
34
- }
35
- // remove progress notification
36
- $('#spinner1').modal('hide');
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
37
30
  }
38
31
  }
39
- else {
40
- $('#alert').modal();
41
- }
42
32
  }
43
33
 
44
- function show_plot(pressedButton, expand_child_div){
45
- 'use strict';
46
- if (pressedButton.status !== 'pressed'){
47
- var eachPlotBtn = pressedButton.getAttribute('onclick');
48
- var tmpFunc = new Function(eachPlotBtn);
49
- tmpFunc();
50
- pressedButton.status='pressed';
51
- $(expand_child_div).parent().parent().show();
52
- expand_child_div.style.display = 'block';
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();
53
38
  }
54
39
  }
55
40
 
56
- function remove_all_plots(expand_children){
41
+ function remove_all_plots() {
57
42
  'use strict';
58
- var extensions = document.querySelectorAll('div');
59
- for (var i = 0; i < extensions.length; i++) {
60
- if (extensions[i].id.search(/toggle*/) === 0){
61
- d3.select('#'.concat(extensions[i].id)).selectAll('svg').remove();
62
- }
63
- }
64
-
65
- for (var j = 0; j < expand_children.length; j++) {
66
- var expand_child_div = expand_children[j].getElementsByTagName('div')[0];
67
- $(expand_child_div).parent().parent().hide();
68
- }
43
+ $('.tablesorter-childRow').each (function(){
44
+ $(this).remove();
45
+ });
69
46
 
70
- var buttons = document.getElementsByTagName('button');
71
- for (var k = 0; k < buttons.length; k++) {
72
- buttons[k].status = 'released';
73
- }
47
+ $('.plot_btn').each (function(){
48
+ this.status = 'released';
49
+ });
74
50
  }
75
51
 
76
- function hide_all_plots(button, expand_children){
52
+ function hide_all_plots(button){
77
53
  'use strict';
78
54
  button.status = 'released';
79
55
  button.innerHTML = '<i class="fa fa-2x fa-bar-chart-o"></i><br>Show All Charts';
80
56
  button.onclick = function() {
81
57
  show_all_plots(button);
82
58
  };
83
- remove_all_plots(expand_children);
59
+ remove_all_plots();
84
60
  }
85
61
 
86
- function getElementByAttributeValue(attribute, value) {
62
+ function addData(source, val){
87
63
  'use strict';
88
- var allElements = document.getElementsByTagName('*');
89
- for (var i = 0; i < allElements.length; i++) {
90
- if (allElements[i].getAttribute(attribute) === value) {
91
- return allElements[i];
92
- }
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);
93
83
  }
94
- return null;
84
+
85
+ $('table').trigger('update');
86
+
95
87
  }
96
88
 
97
- function showDiv(source, target){
98
- 'use strict';
99
- if (window.chrome && (window.location.protocol === 'file:') ) {
100
- if (($('#browser-alert').length) === 0) {
101
- $('#browseralertText').html('<stong>Sorry, this feature is not supported in your browser.');
102
- $('#browseralert').modal();
103
- }
104
- return;
105
- }
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;
106
111
  var explanationId = '#' + target + 'explanation';
112
+ $(targetId).empty();
113
+ $(explanationId).remove();
114
+ resetStatusOfOtherButtons($currentRow);
115
+ source.status = 'pressed';
116
+ }
107
117
 
108
- if ( $(explanationId).length) {
109
- $(explanationId).remove();
110
- }
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
+ }
111
126
 
112
- var button = document.getElementById(target);
113
- if (source.status === 'pressed'){
114
- button.style.display = 'none';
115
- $(button).parent().parent().hide();
116
- } else {
117
- d3.select('#'.concat(target)).selectAll('svg').remove();
118
- button.style.display = 'block';
119
- $(button).parent().parent().show();
120
- var pressedButtons = document.querySelectorAll('td');
121
- for (var i = 0; i < pressedButtons.length; i++) {
122
- if (pressedButtons[i].status === 'pressed') {
123
- pressedButtons[i].status = 'released';
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);
124
141
  }
125
142
  }
126
- }
143
+ });
144
+ }
127
145
 
128
- if (source.status=='pressed') {
129
- source.status='released';
130
- } else {
131
- source.status='pressed';
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);
132
152
  }
133
153
  }
134
154
 
135
- function AddExplanation(source, target){
155
+ function addExplanation(target, jsonData){
136
156
  'use strict';
137
- var row = '#' + target +'row';
138
- var approach_html = '<p><b>Approach:</b> ' + source.getAttribute("data-approach") + '</p>';
139
- var explanation_html = '<p><b>Explanation:</b> ' + source.getAttribute("data-explanation") + '</p>';
140
- var conclusion_html = '<p><b>Conclusion:</b> ' + source.getAttribute("data-conclusion") + '</p>';
141
-
142
- var explain = $('<div id="' + target + 'explanation" class="alert alert-info explanation_alert" role="alert">' + approach_html + explanation_html + conclusion_html + '</div>');
143
- if (source.status === 'pressed') {
144
- $(row).prepend(explain);
145
- }
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);
146
165
  }
147
166
 
148
- function addPlot(target, filename, type, title, footer, xtitle, ytitle, aux1, aux2){
167
+ function addPlot(jsonData, target, type, title, footer, xtitle, ytitle, aux1, aux2){
149
168
  'use strict';
150
169
  var legend;
151
170
  if (footer === '') {
@@ -156,25 +175,25 @@ function addPlot(target, filename, type, title, footer, xtitle, ytitle, aux1, au
156
175
 
157
176
  switch(type) {
158
177
  case 'scatter':
159
- plot_scatter(filename, target, title, footer, xtitle, ytitle, aux1, aux2);
178
+ plot_scatter(jsonData, target, title, footer, xtitle, ytitle, aux1, aux2);
160
179
  break;
161
180
  case 'bars':
162
- plot_bars(filename, target, title, legend, xtitle, ytitle, aux1);
181
+ plot_bars(jsonData, target, title, legend, xtitle, ytitle, aux1);
163
182
  break;
164
183
  case 'simplebars':
165
- plot_simple_bars(filename, target, title, legend, xtitle, ytitle);
184
+ plot_simple_bars(jsonData, target, title, legend, xtitle, ytitle);
166
185
  break;
167
186
  case 'lines':
168
- if (aux2 !== '') {
187
+ if (aux2 !== null) {
169
188
  aux2 = aux2.split(',');
170
189
  }
171
- plot_lines(filename, target, title, legend, xtitle, ytitle, aux1, aux2);
190
+ plot_lines(jsonData, target, title, legend, xtitle, ytitle, aux1, aux2);
172
191
  break;
173
192
  case 'align':
174
- if (aux2 !== '') {
193
+ if (aux2 !== null) {
175
194
  aux2 = aux2.split(',');
176
195
  }
177
- plot_align(filename, target, title, legend, xtitle, ytitle, aux1, aux2);
196
+ plot_align(jsonData, target, title, legend, xtitle, ytitle, aux1, aux2);
178
197
  break;
179
198
  default:
180
199
  break;
@@ -204,87 +223,85 @@ function color_beautification(color){
204
223
  }
205
224
 
206
225
  // bars plot
207
- function plot_bars(filename, target, title, footer, xTitle, yTitle, bar){
226
+ function plot_bars(alldata, target, title, footer, xTitle, yTitle, bar){
208
227
  var margin = {top: 70, right: 50, bottom: 75, left: 50},
209
228
  width = 600 - margin.left - margin.right,
210
- height = 500 - margin.top - margin.bottom;
211
- var legend_width = 15
229
+ height = 500 - margin.top - margin.bottom;
230
+ var legend_width = 15;
212
231
 
213
232
  var svg = d3.select("#".concat(target)).append("svg")
214
233
  .attr("width", width + margin.left + margin.right)
215
234
  .attr("height", height + margin.top + margin.bottom)
216
235
  .append("g")
217
236
  .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
218
-
237
+
219
238
  svg.append("text")
220
- .attr("x", (width / 2))
239
+ .attr("x", (width / 2))
221
240
  .attr("y", -45)
222
- .attr("text-anchor", "middle")
223
- .style("font-size", "16px")
224
- .text(title);
225
-
241
+ .attr("text-anchor", "middle")
242
+ .style("font-size", "16px")
243
+ .text(title);
244
+
226
245
  var colors = new Array("orange", "blue", "green", "yellow", "brown");
227
- var no_colors = colors.length
246
+ var no_colors = colors.length;
228
247
 
229
- var padding = 100
248
+ var padding = 100;
230
249
 
231
- d3.json(filename, function(error, alldata) {
232
-
233
- flattened_data = [].concat.apply([], alldata)
234
- var yMax = d3.max(flattened_data, function(d) { return d.value; }) + 3
235
- var y = d3.scale.linear()
236
- .domain([0, yMax + yMax/10])
237
- .range([height, 0]);
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]);
238
255
 
239
- var xMin = d3.min(flattened_data, function(d) { return d.key; })
240
- if (bar!=undefined){
241
- var xMin = Math.min(xMin, bar);
242
- }
243
-
244
- var xMax = d3.max(flattened_data, function(d) { return d.key; })
245
- if (bar!=undefined){
246
- var xMax = Math.max(xMax, bar);
247
- }
256
+ var xMin = d3.min(flattened_data, function(d) { return d.key; });
257
+ if (bar!=undefined){
258
+ var xMin = Math.min(xMin, bar);
259
+ }
248
260
 
249
- var x = d3.scale.linear()
250
- .domain([xMin-padding, xMax+padding])
251
- .range([13, width]);
261
+ var xMax = d3.max(flattened_data, function(d) { return d.key; });
262
+ if (bar!=undefined){
263
+ var xMax = Math.max(xMax, bar);
264
+ }
252
265
 
253
- var xAxis = d3.svg.axis()
254
- .scale(x)
255
- .orient("bottom")
256
- .ticks(8)
266
+ var x = d3.scale.linear()
267
+ .domain([xMin-padding, xMax+padding])
268
+ .range([13, width]);
257
269
 
258
- var yAxis = d3.svg.axis()
259
- .scale(y)
260
- .orient("left")
261
- .tickFormat(d3.format("d"))
262
- .ticks(8)
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);
263
302
 
264
- svg.append("g")
265
- .attr("class", "x axis")
266
- .attr("transform", "translate(0," + height + ")")
267
- .call(xAxis)
268
- .append("text")
269
- .attr("class", "label")
270
- .attr("x", (width-xTitle.length)/2-50)
271
- .attr("y", 35)
272
- .style("text-anchor", "start")
273
- .text(xTitle)
274
-
275
- svg.append("g")
276
- .attr("class", "y axis")
277
- .call(yAxis)
278
- .append("text")
279
- .attr("class", "label")
280
- .attr("transform", "rotate(-90)")
281
- .attr("x", -(height+yTitle.length)/2-50)
282
- .attr("y", -40)
283
- .style("text-anchor", "start")
284
- .text(yTitle)
285
-
286
303
  alldata.map( function(data, i) {
287
-
304
+
288
305
  color = colors[i % (no_colors - 1)];
289
306
  svg.selectAll(".bar")
290
307
  .data(data)
@@ -294,7 +311,7 @@ function plot_bars(filename, target, title, footer, xTitle, yTitle, bar){
294
311
  .attr("y", function(d) { return y(d.value); })
295
312
  .attr("height", function(d) { return height - y(d.value); })
296
313
  .attr("fill", function(d) { if (d.main == true) return color_beautification("red"); return color_beautification("blue");});
297
- });
314
+ });
298
315
 
299
316
  if (bar!=undefined){
300
317
  svg.append("rect")
@@ -310,531 +327,502 @@ function plot_bars(filename, target, title, footer, xTitle, yTitle, bar){
310
327
  .attr("x", -yMax/10 - 35)
311
328
  .attr("y", x(bar) - 5)
312
329
  .text("query");
313
- }
314
- });
330
+ }
315
331
 
316
- var offset = 0
317
- var total_len = 0
332
+ var offset = 0;
333
+ var total_len = 0;
318
334
  for (var i = 0; i < footer.length; i++) {
319
- var array = footer[i].split(",");
335
+ var array = footer[i].split(",");
320
336
  total_len = total_len + array[0].length*8 + 15;
321
337
  }
322
338
 
323
339
  for (var i = 0; i < footer.length; i++) {
324
340
 
325
- var array = footer[i].split(",");
341
+ var array = footer[i].split(",");
326
342
  svg.append("rect")
327
- .attr("x", (width-total_len)/2 + offset)
343
+ .attr("x", (width-total_len)/2 + offset)
328
344
  .attr("y", -30)
329
345
  .attr("width", 10)
330
346
  .attr("height", 10)
331
- .style("fill", color_beautification(array[1].replace(/\s+/g, '')))
332
-
347
+ .style("fill", color_beautification(array[1].replace(/\s+/g, '')));
348
+
333
349
  svg.append("text")
334
- .attr("x", (width-total_len)/2 + offset + 15)
350
+ .attr("x", (width-total_len)/2 + offset + 15)
335
351
  .attr("y", -20)
336
352
  .text(array[0]);
337
- offset = offset + array[0].length*8 + 15
338
-
353
+ offset = offset + array[0].length*8 + 15;
339
354
  }
340
-
341
-
342
-
343
- }
355
+ }
344
356
 
345
357
  // bars plot
346
- function plot_simple_bars(filename, target, title, footer, xTitle, yTitle){
358
+ function plot_simple_bars(alldata, target, title, footer, xTitle, yTitle){
347
359
  'use strict';
348
360
 
349
361
  var margin = {top: 70, right: 50, bottom: 75, left: 50},
350
362
  width = 600 - margin.left - margin.right,
351
- height = 500 - margin.top - margin.bottom;
352
- var legend_width = 15
363
+ height = 500 - margin.top - margin.bottom;
364
+ var legend_width = 15;
353
365
 
354
366
  var svg = d3.select("#".concat(target)).append("svg")
355
367
  .attr("width", width + margin.left + margin.right)
356
368
  .attr("height", height + margin.top + margin.bottom)
357
369
  .append("g")
358
370
  .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
359
-
371
+
360
372
  svg.append("text")
361
- .attr("x", (width / 2))
373
+ .attr("x", (width / 2))
362
374
  .attr("y", -45)
363
- .attr("text-anchor", "middle")
364
- .style("font-size", "16px")
365
- .text(title);
366
-
367
- var colors = new Array("orange", "blue", "green", "yellow", "brown");
368
- var no_colors = colors.length
369
-
370
- var padding = 0
375
+ .attr("text-anchor", "middle")
376
+ .style("font-size", "16px")
377
+ .text(title);
371
378
 
372
- d3.json(filename, function(error, alldata) {
373
-
374
- flattened_data = [].concat.apply([], alldata)
375
- var yMax = d3.max(flattened_data, function(d) { return d.value; }) + 3
376
- var y = d3.scale.linear()
377
- .domain([0, yMax])
378
- .range([height, 0]);
379
-
380
- var xMin = d3.min(flattened_data, function(d) { return d.key; })
381
- var xMax = d3.max(flattened_data, function(d) { return d.key; })
379
+ var colors = new Array("orange", "blue", "green", "yellow", "brown");
380
+ var no_colors = colors.length;
382
381
 
383
- var x = d3.scale.linear()
384
- .domain([xMin-padding, xMax+padding])
385
- .range([13, width]);
382
+ var padding = 0;
386
383
 
387
- var xAxis = d3.svg.axis()
388
- .scale(x)
389
- .orient("bottom")
390
- .ticks(8)
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]);
391
389
 
392
- var yAxis = d3.svg.axis()
393
- .scale(y)
394
- .orient("left")
395
- .tickFormat(d3.format("d"))
396
- .ticks(8)
390
+ var xMin = d3.min(flattened_data, function(d) { return d.key; });
391
+ var xMax = d3.max(flattened_data, function(d) { return d.key; });
397
392
 
398
- svg.append("g")
399
- .attr("class", "x axis")
400
- .attr("transform", "translate(0," + height + ")")
401
- .call(xAxis)
402
- .append("text")
403
- .attr("class", "label")
404
- .attr("x", (width-xTitle.length)/2-50)
405
- .attr("y", 35)
406
- .style("text-anchor", "start")
407
- .text(xTitle)
408
-
409
- svg.append("g")
410
- .attr("class", "y axis")
411
- .call(yAxis)
412
- .append("text")
413
- .attr("class", "label")
414
- .attr("transform", "rotate(-90)")
415
- .attr("x", -(height+yTitle.length)/2-50)
416
- .attr("y", -40)
417
- .style("text-anchor", "start")
418
- .text(yTitle)
419
-
420
- alldata.map( function(data, i) {
421
-
422
- color = colors[i % (no_colors - 1)];
423
- svg.selectAll(".bar")
424
- .data(data)
425
- .enter().append("rect")
426
- .attr("x", function(d) { return x(d.key); })
427
- .attr("width", 6)
428
- .attr("y", function(d) { return y(d.value); })
429
- .attr("height", function(d) { return height - y(d.value); })
430
- .attr("fill", function(d) { if (d.main == true) return color_beautification("red"); return color_beautification("blue");});
431
- });
393
+ var x = d3.scale.linear()
394
+ .domain([xMin-padding, xMax+padding])
395
+ .range([13, width]);
432
396
 
433
- });
397
+ var xAxis = d3.svg.axis()
398
+ .scale(x)
399
+ .orient("bottom")
400
+ .ticks(8);
434
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
+ });
435
443
  }
436
444
 
437
445
 
438
446
  // scatter plot
439
447
  // ecuation of the line: slope * x + yLine
440
- function plot_scatter(filename, target, title, footer, xTitle, yTitle, yLine, slope){
448
+ function plot_scatter(data, target, title, footer, xTitle, yTitle, yLine, slope){
441
449
  'use strict';
442
450
 
443
451
  var margin = {top: 50, right: 30, bottom: 75, left: 50},
444
- width = 500 - margin.left - margin.right,
445
- height = 500 - margin.top - margin.bottom;
452
+ width = 500 - margin.left - margin.right,
453
+ height = 500 - margin.top - margin.bottom;
446
454
 
447
455
  var x = d3.scale.linear()
448
- .range([0, width]);
456
+ .range([0, width]);
449
457
  var y = d3.scale.linear()
450
- .range([height, 0]);
458
+ .range([height, 0]);
451
459
 
452
460
  var color = d3.scale.category10();
453
461
 
454
462
  var xAxis = d3.svg.axis()
455
- .scale(x)
456
- .orient("bottom")
457
- .ticks(8);
463
+ .scale(x)
464
+ .orient("bottom")
465
+ .ticks(8);
458
466
  var yAxis = d3.svg.axis()
459
- .scale(y)
460
- .orient("left")
461
- .tickFormat(d3.format("d"))
462
- .ticks(8);
467
+ .scale(y)
468
+ .orient("left")
469
+ .tickFormat(d3.format("d"))
470
+ .ticks(8);
463
471
 
464
472
  var svg = d3.select("#".concat(target)).append("svg")
465
- .attr("width", width + margin.left + margin.right)
466
- .attr("height", height + margin.top + margin.bottom)
467
- .append("g")
468
- .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
469
-
470
- svg.append("text")
471
- .attr("x", (width / 2))
472
- .attr("y", -25)
473
- .attr("text-anchor", "middle")
474
- .style("font-size", "16px")
475
- .text(title);
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 + ")");
476
477
 
477
478
  svg.append("text")
478
- .attr("x", (width / 2))
479
- .attr("y", height+ 55)
480
- .attr("text-anchor", "middle")
481
- .style("font-size", "12px")
482
- .text(footer);
483
-
484
- d3.json(filename, function(error, data) {
479
+ .attr("x", (width / 2))
480
+ .attr("y", -25)
481
+ .attr("text-anchor", "middle")
482
+ .style("font-size", "16px")
483
+ .text(title);
485
484
 
486
- var xMax = d3.max(data, function(d) { return d.x; })
487
- var xMin = d3.min(data, function(d) { return d.x; })
488
- var yMax = d3.max(data, function(d) { return d.y; })
489
- var yMin = d3.min(data, function(d) { return d.y; })
490
- x.domain(d3.extent(data, function(d) { return d.x; })).nice();
491
- y.domain(d3.extent(data, function(d) { return d.y; })).nice();
492
-
493
- svg.append("g")
494
- .attr("class", "x axis")
495
- .attr("transform", "translate(0," + height + ")")
496
- .call(xAxis)
497
- .append("text")
498
- .attr("class", "label")
499
- .attr("x", (width-xTitle.length)/2-50)
500
- .attr("y", 35)
501
- .style("text-anchor", "start")
502
- .text(xTitle)
503
-
504
- svg.append("g")
505
- .attr("class", "y axis")
506
- .call(yAxis)
507
- .append("text")
508
- .attr("class", "label")
509
- .attr("transform", "rotate(-90)")
510
- .attr("x", -(height+yTitle.length)/2-50)
511
- .attr("y", -40)
512
- .style("text-anchor", "start")
513
- .text(yTitle)
514
-
515
- svg.selectAll(".dot")
516
- .data(data)
517
- .enter().append("circle")
518
- //.attr("class", "dot")
519
- .attr("r", 2)
520
- .attr("cx", function(d) { return x(d.x); })
521
- .attr("cy", function(d) { return y(d.y); })
522
- .style("fill", function(d) { return color_beautification("red"); })
523
- .style("opacity",0.6);
524
-
525
- if ((slope!=undefined && slope != "") && (yLine!=undefined && yLine != "")){
526
-
527
- yLine = parseFloat(yLine.replace(",", "."));
528
- var xMaxValue = xMax
529
- var yMaxValue = yLine + slope * xMax
530
- if (yMaxValue > yMax){
531
- xMaxValue = (yMax-yLine)/slope
532
- yMaxValue = yMax
533
- }
534
-
535
- if (yMaxValue < yMin){
536
- xMaxValue = (yMin-yLine)/slope
537
- yMaxValue = yMin
538
- }
539
-
540
- var xMinValue = xMin
541
- var yMinValue = yLine + slope * xMin
542
- if (yMinValue > yMax){
543
- xMinValue = (yMax-yLine)/slope
544
- yMinValue = yMin
545
- }
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
+ }
546
538
 
547
- if (yMinValue < yMin){
548
- xMinValue = (yMin-yLine)/slope
549
- yMinValue = yMin
550
- }
539
+ if (yMaxValue < yMin){
540
+ xMaxValue = (yMin-yLine)/slope;
541
+ yMaxValue = yMin;
542
+ }
551
543
 
552
- svg.append("line")
553
- .attr("x1", x(xMinValue))
554
- .attr("y1", y(yMinValue))
555
- .attr("x2", x(xMaxValue))
556
- .attr("y2", y(yMaxValue))
557
- .attr("stroke-width", 2)
558
- .attr("stroke", "black")
559
- }
544
+ var xMinValue = xMin;
545
+ var yMinValue = yLine + slope * xMin;
546
+ if (yMinValue > yMax){
547
+ xMinValue = (yMax-yLine)/slope;
548
+ yMinValue = yMin;
549
+ }
560
550
 
551
+ if (yMinValue < yMin){
552
+ xMinValue = (yMin-yLine)/slope;
553
+ yMinValue = yMin;
554
+ }
561
555
 
562
- });
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
+ }
563
564
  }
564
565
 
565
566
  // line plot
566
567
  // maximum 80 lines
567
- function plot_lines(filename, target, title, footer, xTitle, yTitle, no_lines, yValues){
568
+ function plot_lines(data, target, title, footer, xTitle, yTitle, no_lines, yValues){
568
569
  'use strict';
569
570
  var margin = {top: 70, right: 50, bottom: 75, left: 50},
570
- width = 600 - margin.left - margin.right,
571
- height = 500 - margin.top - margin.bottom;
572
- var legend_width = 17
571
+ width = 600 - margin.left - margin.right,
572
+ height = 500 - margin.top - margin.bottom;
573
+ var legend_width = 17;
573
574
 
574
575
  var x = d3.scale.linear()
575
- .range([0, width]);
576
+ .range([0, width]);
576
577
  var y = d3.scale.linear()
577
- .range([height, 0]);
578
+ .range([height, 0]);
578
579
 
579
580
  var color = d3.scale.category10();
580
581
 
581
- if (title === 'Open Reading Frames in all 6 Frames') {
582
+ if (title === 'Open Reading Frames in all 6 Frames') {
582
583
  var xAxis = d3.svg.axis()
583
- .scale(x)
584
- .orient("bottom")
585
- .ticks(0);
584
+ .scale(x)
585
+ .orient("bottom")
586
+ .ticks(0);
586
587
  } else {
587
588
  var xAxis = d3.svg.axis()
588
- .scale(x)
589
- .orient("bottom")
590
- .ticks(5);
589
+ .scale(x)
590
+ .orient("bottom")
591
+ .ticks(5);
591
592
  }
592
593
 
593
594
  var yAxis = d3.svg.axis()
594
- .scale(y)
595
- .orient("left")
596
- .ticks(5)
595
+ .scale(y)
596
+ .orient("left")
597
+ .ticks(5);
597
598
 
598
599
  var svg = d3.select("#".concat(target)).append("svg")
599
- .attr("width", width + margin.left + margin.right)
600
- .attr("height", height + margin.top + margin.bottom)
601
- .append("g")
602
- .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
603
-
604
- svg.append("text")
605
- .attr("x", (width / 2))
606
- .attr("y", -35)
607
- .attr("text-anchor", "middle")
608
- .style("font-size", "16px")
609
- .text(title);
610
-
611
- d3.json(filename, function(error, data) {
612
-
613
- var idx = -1
614
-
615
- x.domain([0, d3.max(data, function(d) { return d.stop; })]);
616
- y.domain(d3.extent(data, function(d) { return d.y; })).nice();
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 + ")");
617
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){
618
629
  svg.append("g")
619
- .attr("class", "x axis")
620
- .attr("transform", "translate(0," + (height + height/no_lines) + ")")
621
- .call(xAxis)
622
- .append("text")
623
- .attr("class", "label")
624
- .attr("x", (width-xTitle.length)/2-50)
625
- .attr("y", 35)
626
- .style("text-anchor", "start")
627
- .text(xTitle)
628
-
629
- if (yValues != ""){
630
- svg.append("g")
631
- .attr("class", "y axis")
632
- .call(yAxis
633
- .ticks(yValues.length)
634
- .tickFormat(function (d) {
635
- idx = idx + 1;
636
- return yValues[idx];
630
+ .attr("class", "y axis")
631
+ .call(yAxis.ticks(yValues.length)
632
+ .tickFormat(function (d) {
633
+ idx = idx + 1;
634
+ return yValues[idx];
637
635
  }))
638
- .append("text")
639
- .attr("class", "label")
640
- .attr("transform", "rotate(-90)")
641
- .attr("x", -(height+yTitle.length)/2-50)
642
- .attr("y", -40)
643
- .style("text-anchor", "start")
644
- .text(yTitle)
645
- }
646
- else{
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 {
647
644
  svg.append("g")
648
- .attr("class", "y axis")
649
- .call(yAxis)
650
- .append("text")
651
- .attr("class", "label")
652
- .attr("transform", "rotate(-90)")
653
- .attr("x", -(height+yTitle.length)/2)
654
- .attr("y", -40)
655
- .style("text-anchor", "start")
656
- .text(yTitle)
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);
657
654
  }
658
655
 
659
656
  svg.selectAll(".dot")
660
- .data(data)
657
+ .data(data)
661
658
  .enter().append("line")
662
- .attr("x1", function(d) { return x(d.start); })
663
- .attr("y1", function(d) { return y(d.y); })
664
- .attr("x2", function(d) { return x(d.stop); })
665
- .attr("x2", function(d) { return x(d.stop); })
666
- .attr("y2", function(d) { return y(d.y); })
667
- .attr("stroke-width", function(d) {
668
- if (d.dotted == undefined) {
669
- if (d.color == "red" ) {
670
- return height/no_lines/2.5
671
- } else {
672
- return height/no_lines
673
- }
674
- } else {
675
- return height/no_lines/5
676
- }
677
- })
678
- .style("stroke-dasharray", function(d) { if (d.dotted == undefined) return ("0, 0"); return ("2, 6");})
679
- .attr("stroke", function(d) { return color_beautification(d.color); })
680
- });
681
-
682
- // add legend
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
683
679
  var legend = svg.append("g")
684
- .attr("class", "legend")
685
- .attr("height", 100)
686
- .attr("width", 100)
687
- .attr('transform', 'translate(-20,50)')
688
-
689
- var h = 0
690
-
691
- var offset = 40
692
- var total_len = 0
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;
693
689
  for (var i = 0; i < footer.length; i++) {
694
- var array = footer[i].split(",");
695
- total_len = total_len + array[0].length*8 + 15;
690
+ var array = footer[i].split(",");
691
+ total_len = total_len + array[0].length*8 + 15;
696
692
  }
697
693
 
698
694
  for (var i = 0; i < footer.length; i++) {
699
-
700
- var array = footer[i].split(",");
701
- svg.append("rect")
702
- .attr("x", (width-total_len)/2 + offset)
703
- .attr("y", -30)
704
- .attr("width", 10)
705
- .attr("height", 10)
706
- .style("fill", color_beautification(array[1].replace(/\s+/g, '')))
707
-
708
- svg.append("text")
709
- .attr("x", (width-total_len)/2 + offset + 15)
710
- .attr("y", -20)
711
- .text(array[0]);
712
- offset = offset + array[0].length*8 + 15
713
-
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;
714
708
  }
715
709
  }
716
710
 
717
711
  // line plot
718
712
  // maximum 80 lines
719
- function plot_align(filename, target, title, footer, xTitle, yTitle, no_lines, yValues){
713
+ function plot_align(data, target, title, footer, xTitle, yTitle, no_lines, yValues){
720
714
  'use strict';
721
715
 
722
716
  var margin = {top: 75, right: 50, bottom: 75, left: 150},
723
- width = 600 - margin.left - margin.right,
724
- height = 300 - margin.top - margin.bottom;
725
- var legend_width = 17
717
+ width = 600 - margin.left - margin.right,
718
+ height = 300 - margin.top - margin.bottom;
719
+ var legend_width = 17;
726
720
 
727
721
  var x = d3.scale.linear()
728
- .range([0, width]);
722
+ .range([0, width]);
729
723
  var y = d3.scale.linear()
730
- .range([height, 0]);
724
+ .range([height, 0]);
731
725
 
732
726
  var color = d3.scale.category10();
733
727
 
734
728
  var xAxis = d3.svg.axis()
735
- .scale(x)
736
- .orient("bottom")
737
- .ticks(5);
729
+ .scale(x)
730
+ .orient("bottom")
731
+ .ticks(5);
738
732
 
739
733
  var yAxis = d3.svg.axis()
740
- .scale(y)
741
- .orient("left")
742
- .ticks(5)
734
+ .scale(y)
735
+ .orient("left")
736
+ .ticks(5);
743
737
 
744
738
  var svg = d3.select("#".concat(target)).append("svg")
745
- .style("vertical-align", "top")
746
- .attr("width", width + margin.left + margin.right)
747
- .attr("height", height + margin.top + margin.bottom)
748
- .append("g")
749
- .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
750
-
751
- svg.append("text")
752
- .attr("x", (width / 2))
753
- .attr("y", -35)
754
- .attr("text-anchor", "middle")
755
- .style("font-size", "16px")
756
- .text(title);
757
-
758
- d3.json(filename, function(error, data) {
759
-
760
- var idx = -1
761
-
762
- x.domain([0, d3.max(data, function(d) { return d.stop; })]);
763
- y.domain(d3.extent(data, function(d) { return d.y; })).nice();
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 + ")");
764
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){
765
769
  svg.append("g")
766
- .attr("class", "x axis")
767
- .attr("transform", "translate(0," + (height+height/no_lines) + ")")
768
- .call(xAxis)
769
- .append("text")
770
- .attr("class", "label")
771
- .attr("x", (width-xTitle.length)/2-50)
772
- .attr("y", 35)
773
- .style("text-anchor", "start")
774
- .text(xTitle)
775
-
776
- if (yValues != ""){
777
- svg.append("g")
778
- .attr("class", "y axis")
779
- .call(yAxis
780
- .ticks(yValues.length)
781
- .tickFormat(function (d) {
782
- idx = idx + 1;
783
- return yValues[idx];
784
- }))
785
- .append("text")
786
- .attr("class", "label")
787
- .attr("transform", "rotate(-90)")
788
- .attr("x", -(height+yTitle.length)/2-50)
789
- .attr("y", -40)
790
- .style("text-anchor", "start")
791
- .text(yTitle)
792
- }
793
- else{
794
- svg.append("g")
795
- .attr("class", "y axis")
796
- .call(yAxis)
797
- .append("text")
798
- .attr("class", "label")
799
- .attr("transform", "rotate(-90)")
800
- .attr("x", -(height+yTitle.length)/2-50)
801
- .attr("y", -40)
802
- .style("text-anchor", "start")
803
- .text(yTitle)
804
- }
805
-
806
- svg.selectAll(".dot")
807
- .data(data)
808
- .enter().append("line")
809
- .attr("x1", function(d) { return x(d.start); })
810
- .attr("y1", function(d) { return y(d.y); })
811
- .attr("x2", function(d) { return x(d.stop); })
812
- .attr("y2", function(d) { return y(d.y); })
813
- .attr("stroke-width", function(d) { if (d.height == -1) return height/no_lines; return (height/no_lines * d.height) ; })
814
- .attr("stroke", function(d) { return color_beautification(d.color); })
815
- });
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
+ }
816
795
 
817
- var offset = 0
818
- var total_len = 0
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;
819
808
  for (var i = 0; i < footer.length; i++) {
820
- var array = footer[i].split(",");
821
- total_len = total_len + array[0].length*8 + 15;
809
+ var array = footer[i].split(",");
810
+ total_len = total_len + array[0].length*8 + 15;
822
811
  }
823
812
 
824
813
  for (var i = 0; i < footer.length; i++) {
825
-
826
- var array = footer[i].split(",");
827
- svg.append("rect")
828
- .attr("x", (width-total_len)/2 + offset)
829
- .attr("y", -30)
830
- .attr("width", 10)
831
- .attr("height", 10)
832
- .style("fill", color_beautification(array[1].replace(/\s+/g, '')))
833
-
834
- svg.append("text")
835
- .attr("x", (width-total_len)/2 + offset + 15)
836
- .attr("y", -20)
837
- .text(array[0]);
838
- offset = offset + array[0].length*8 + 15
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;
839
827
  }
840
- }
828
+ }