genevalidator 1.6.1 → 1.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/.travis.yml +2 -0
- data/README.md +78 -30
- data/Rakefile +11 -8
- data/aux/app_template_footer.erb +1 -6
- data/aux/app_template_header.erb +12 -32
- data/aux/files/css/style.css +2 -8
- data/aux/files/js/plots.js +564 -576
- data/aux/files/js/script.js +10 -0
- data/aux/json_footer.erb +8 -0
- data/aux/json_header.erb +19 -0
- data/aux/json_query.erb +14 -0
- data/aux/template_footer.erb +9 -58
- data/aux/template_header.erb +18 -58
- data/aux/template_query.erb +8 -36
- data/bin/genevalidator +45 -32
- data/genevalidator.gemspec +11 -7
- data/lib/genevalidator.rb +75 -455
- data/lib/genevalidator/arg_validation.rb +78 -107
- data/lib/genevalidator/blast.rb +57 -60
- data/lib/genevalidator/clusterization.rb +15 -15
- data/lib/genevalidator/exceptions.rb +32 -5
- data/lib/genevalidator/get_raw_sequences.rb +70 -33
- data/lib/genevalidator/hsp.rb +1 -4
- data/lib/genevalidator/json_to_gv_results.rb +109 -0
- data/lib/genevalidator/output.rb +177 -185
- data/lib/genevalidator/pool.rb +2 -1
- data/lib/genevalidator/sequences.rb +3 -3
- data/lib/genevalidator/tabular_parser.rb +24 -18
- data/lib/genevalidator/validation.rb +279 -0
- data/lib/genevalidator/validation_alignment.rb +31 -47
- data/lib/genevalidator/validation_blast_reading_frame.rb +19 -18
- data/lib/genevalidator/validation_duplication.rb +23 -19
- data/lib/genevalidator/validation_gene_merge.rb +30 -65
- data/lib/genevalidator/validation_length_cluster.rb +14 -53
- data/lib/genevalidator/validation_length_rank.rb +10 -11
- data/lib/genevalidator/validation_open_reading_frame.rb +18 -19
- data/lib/genevalidator/validation_report.rb +2 -5
- data/lib/genevalidator/validation_test.rb +8 -4
- data/lib/genevalidator/version.rb +1 -1
- data/test/test_all_validations.rb +51 -66
- data/test/test_blast.rb +68 -51
- data/test/test_clusterization.rb +1 -1
- data/test/test_clusterization_2d.rb +19 -13
- data/test/test_extended_array_methods.rb +1 -1
- data/test/test_files/all_validations_mrna/mrna.blast_tab6 +1806 -0
- data/test/test_files/all_validations_mrna/mrna.blast_tab7 +1865 -0
- data/test/test_files/all_validations_mrna/{all_validations_mrna.fasta.blast_xml → mrna.blast_xml} +18642 -1
- data/test/test_files/all_validations_mrna/{all_validations_mrna.fasta.blast_xml.index → mrna.blast_xml.index} +300 -0
- data/test/test_files/all_validations_mrna/{all_validations_mrna.fasta → mrna.fa} +0 -0
- data/test/test_files/all_validations_mrna/mrna.raw_seq +3970 -0
- data/test/test_files/all_validations_mrna/{all_validations_mrna.fasta.blast_xml.raw_seq.idx → mrna.raw_seq.idx} +901 -1
- data/test/test_files/all_validations_prot/{all_validations_prot.fasta.blast_tab → prot.blast_tab6} +416 -0
- data/test/test_files/all_validations_prot/prot.blast_tab7 +2400 -0
- data/test/test_files/all_validations_prot/{all_validations_prot.fasta.blast_xml → prot.blast_xml} +18299 -6723
- data/test/test_files/all_validations_prot/{all_validations_prot.fasta.blast_xml.index → prot.blast_xml.index} +408 -0
- data/test/test_files/all_validations_prot/{all_validations_prot.fasta → prot.fa} +0 -0
- data/test/test_files/all_validations_prot/{all_validations_prot.fasta.blast_xml.raw_seq → prot.raw_seq} +2735 -0
- data/test/test_files/all_validations_prot/{all_validations_prot.fasta.blast_xml.raw_seq.idx → prot.raw_seq.idx} +3032 -1808
- data/test/test_sequences.rb +46 -41
- data/test/test_validation_open_reading_frame.rb +318 -202
- data/test/test_validations.rb +48 -32
- metadata +76 -102
- data/doc/AliasDuplicationError.html +0 -134
- data/doc/AlignmentValidation.html +0 -1687
- data/doc/AlignmentValidationOutput.html +0 -659
- data/doc/Blast.html +0 -1905
- data/doc/BlastRFValidationOutput.html +0 -545
- data/doc/BlastReadingFrameValidation.html +0 -370
- data/doc/BlastUtils.html +0 -875
- data/doc/ClasspathError.html +0 -134
- data/doc/Cluster.html +0 -1316
- data/doc/DuplciationValidationOutput.html +0 -564
- data/doc/DuplicationValidation.html +0 -920
- data/doc/DuplicationValidationOutput.html +0 -564
- data/doc/FileNotFoundException.html +0 -134
- data/doc/GeneMergeValidation.html +0 -935
- data/doc/GeneMergeValidationOutput.html +0 -652
- data/doc/HierarchicalClusterization.html +0 -994
- data/doc/Hsp.html +0 -1485
- data/doc/InconsistentTabularFormat.html +0 -135
- data/doc/LengthClusterValidation.html +0 -982
- data/doc/LengthClusterValidationOutput.html +0 -515
- data/doc/LengthRankValidation.html +0 -496
- data/doc/LengthRankValidationOutput.html +0 -517
- data/doc/NoInternetError.html +0 -135
- data/doc/NoMafftInstallationError.html +0 -134
- data/doc/NoPIdentError.html +0 -134
- data/doc/NoValidationError.html +0 -134
- data/doc/NotEnoughHitsError.html +0 -135
- data/doc/ORFValidationOutput.html +0 -593
- data/doc/OpenReadingFrameValidation.html +0 -1107
- data/doc/OtherError.html +0 -123
- data/doc/Output.html +0 -1540
- data/doc/Pair.html +0 -309
- data/doc/PairCluster.html +0 -767
- data/doc/Plot.html +0 -837
- data/doc/QueryError.html +0 -134
- data/doc/ReportClassError.html +0 -135
- data/doc/Sequence.html +0 -1299
- data/doc/SequenceTypeError.html +0 -135
- data/doc/TabularEntry.html +0 -837
- data/doc/TabularParser.html +0 -1104
- data/doc/Validation.html +0 -2147
- data/doc/ValidationClassError.html +0 -134
- data/doc/ValidationOutput.html +0 -460
- data/doc/ValidationReport.html +0 -940
- data/doc/ValidationTest.html +0 -939
- data/doc/_index.html +0 -449
- data/doc/class_list.html +0 -54
- data/doc/css/common.css +0 -1
- data/doc/css/full_list.css +0 -57
- data/doc/css/style.css +0 -338
- data/doc/file.README.html +0 -151
- data/doc/file_list.html +0 -56
- data/doc/frames.html +0 -26
- data/doc/index.html +0 -151
- data/doc/js/app.js +0 -214
- data/doc/js/full_list.js +0 -178
- data/doc/js/jquery.js +0 -4
- data/doc/method_list.html +0 -1505
- data/doc/top-level-namespace.html +0 -112
- data/test/test_files/all_validations_mrna/all_validations_mrna.fasta.blast_tab +0 -967
- data/test/test_files/all_validations_mrna/all_validations_mrna.fasta.blast_tab.index +0 -967
- data/test/test_files/all_validations_mrna/all_validations_mrna.fasta.blast_tab.raw_seq +0 -4929
- data/test/test_files/all_validations_mrna/all_validations_mrna.fasta.blast_tab.raw_seq.idx +0 -1006
- data/test/test_files/all_validations_mrna/all_validations_mrna.fasta.blast_xml.raw_seq +0 -2075
- data/test/test_files/all_validations_prot/all_validations_prot.fasta.blast_tab.index +0 -1864
- data/test/test_files/all_validations_prot/all_validations_prot.fasta.blast_tab.raw_seq +0 -42411
- 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96ce3d3767132621e5b854bfbda040e4d9fdbf13
|
4
|
+
data.tar.gz: 647c391a49a6f066289cc97362c0374ef1aa56f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22452fd09598a352ad386011150a71ceb24dda54cdcbed1ae691b0e1a7258318479b80d83478003ddfc5e4e4b3fd60a5ffa07335bad55e2465ca83d338045d8a
|
7
|
+
data.tar.gz: 81ea0ebbeeaa81ffc18bd359b531cf0b8000019f37e266fad0fcd6ffa00867a49c8c1a2adfd37141dc0b052c16bc7a4d373d9e3ed9ab60b4ec32efc9613c7614
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -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
|
-
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
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
|
-
|
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
|
-
#####
|
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
|
109
|
+
$ genevalidator -d 'Path-to-local-BLAST-db' -n 8 Input_FASTA_File
|
102
110
|
```
|
103
|
-
|
104
|
-
|
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 '
|
115
|
+
$ genevalidator -d 'Path-to-local-BLAST-db' -n 8 -f Input_FASTA_File
|
108
116
|
```
|
109
117
|
|
110
|
-
#####
|
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
|
-
$
|
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
|
-
#####
|
125
|
+
##### Local Database, with pre-computed BLAST XML file, with custom number of threads (in this case 8)
|
118
126
|
|
119
127
|
```bash
|
120
|
-
$
|
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
|
-
####
|
136
|
-
The output is also produced in
|
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
|
-
|
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 '
|
6
|
-
task :build do
|
7
|
-
|
8
|
-
|
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 '
|
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
|
-
|
27
|
+
sh "yardoc 'lib/**/*.rb'"
|
25
28
|
end
|
data/aux/app_template_footer.erb
CHANGED
@@ -1,6 +1 @@
|
|
1
|
-
|
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>
|
data/aux/app_template_header.erb
CHANGED
@@ -1,32 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
<
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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> <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> <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>
|
data/aux/files/css/style.css
CHANGED
@@ -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
|
|
data/aux/files/js/plots.js
CHANGED
@@ -1,151 +1,170 @@
|
|
1
1
|
function show_all_plots(button){
|
2
2
|
'use strict';
|
3
|
-
var
|
4
|
-
if (
|
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
|
-
|
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
|
18
|
+
hide_all_plots(button);
|
23
19
|
};
|
24
20
|
}
|
25
21
|
|
26
|
-
//
|
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
|
-
|
32
|
-
|
33
|
-
|
34
|
-
}
|
35
|
-
|
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
|
45
|
-
'
|
46
|
-
|
47
|
-
|
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(
|
41
|
+
function remove_all_plots() {
|
57
42
|
'use strict';
|
58
|
-
|
59
|
-
|
60
|
-
|
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
|
-
|
71
|
-
|
72
|
-
|
73
|
-
}
|
47
|
+
$('.plot_btn').each (function(){
|
48
|
+
this.status = 'released';
|
49
|
+
});
|
74
50
|
}
|
75
51
|
|
76
|
-
function hide_all_plots(button
|
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(
|
59
|
+
remove_all_plots();
|
84
60
|
}
|
85
61
|
|
86
|
-
function
|
62
|
+
function addData(source, val){
|
87
63
|
'use strict';
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
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
|
-
|
84
|
+
|
85
|
+
$('table').trigger('update');
|
86
|
+
|
95
87
|
}
|
96
88
|
|
97
|
-
function
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
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
|
-
|
109
|
-
|
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
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
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
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
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
|
155
|
+
function addExplanation(target, jsonData){
|
136
156
|
'use strict';
|
137
|
-
var row = '#' + target
|
138
|
-
var approach_html = '<p><b>Approach:</b> ' +
|
139
|
-
var explanation_html = '<p><b>Explanation:</b> ' +
|
140
|
-
var conclusion_html = '<p><b>Conclusion:</b> ' +
|
141
|
-
|
142
|
-
var explain = $('<div id="' + target + 'explanation" class="alert alert-info explanation_alert" role="alert">' +
|
143
|
-
|
144
|
-
|
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(
|
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(
|
178
|
+
plot_scatter(jsonData, target, title, footer, xtitle, ytitle, aux1, aux2);
|
160
179
|
break;
|
161
180
|
case 'bars':
|
162
|
-
plot_bars(
|
181
|
+
plot_bars(jsonData, target, title, legend, xtitle, ytitle, aux1);
|
163
182
|
break;
|
164
183
|
case 'simplebars':
|
165
|
-
plot_simple_bars(
|
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(
|
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(
|
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(
|
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
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
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
|
-
|
240
|
-
|
241
|
-
|
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
|
-
|
250
|
-
|
251
|
-
|
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
|
-
|
254
|
-
|
255
|
-
|
256
|
-
.ticks(8)
|
266
|
+
var x = d3.scale.linear()
|
267
|
+
.domain([xMin-padding, xMax+padding])
|
268
|
+
.range([13, width]);
|
257
269
|
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
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(
|
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
|
-
|
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
|
-
|
384
|
-
.domain([xMin-padding, xMax+padding])
|
385
|
-
.range([13, width]);
|
382
|
+
var padding = 0;
|
386
383
|
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
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
|
-
|
393
|
-
|
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
|
-
|
399
|
-
|
400
|
-
|
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(
|
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
|
-
|
445
|
-
|
452
|
+
width = 500 - margin.left - margin.right,
|
453
|
+
height = 500 - margin.top - margin.bottom;
|
446
454
|
|
447
455
|
var x = d3.scale.linear()
|
448
|
-
|
456
|
+
.range([0, width]);
|
449
457
|
var y = d3.scale.linear()
|
450
|
-
|
458
|
+
.range([height, 0]);
|
451
459
|
|
452
460
|
var color = d3.scale.category10();
|
453
461
|
|
454
462
|
var xAxis = d3.svg.axis()
|
455
|
-
|
456
|
-
|
457
|
-
|
463
|
+
.scale(x)
|
464
|
+
.orient("bottom")
|
465
|
+
.ticks(8);
|
458
466
|
var yAxis = d3.svg.axis()
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
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
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
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
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
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
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
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
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
539
|
+
if (yMaxValue < yMin){
|
540
|
+
xMaxValue = (yMin-yLine)/slope;
|
541
|
+
yMaxValue = yMin;
|
542
|
+
}
|
551
543
|
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
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(
|
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
|
-
|
571
|
-
|
572
|
-
|
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
|
-
|
576
|
+
.range([0, width]);
|
576
577
|
var y = d3.scale.linear()
|
577
|
-
|
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
|
-
|
584
|
-
|
585
|
-
|
584
|
+
.scale(x)
|
585
|
+
.orient("bottom")
|
586
|
+
.ticks(0);
|
586
587
|
} else {
|
587
588
|
var xAxis = d3.svg.axis()
|
588
|
-
|
589
|
-
|
590
|
-
|
589
|
+
.scale(x)
|
590
|
+
.orient("bottom")
|
591
|
+
.ticks(5);
|
591
592
|
}
|
592
593
|
|
593
594
|
var yAxis = d3.svg.axis()
|
594
|
-
|
595
|
-
|
596
|
-
|
595
|
+
.scale(y)
|
596
|
+
.orient("left")
|
597
|
+
.ticks(5);
|
597
598
|
|
598
599
|
var svg = d3.select("#".concat(target)).append("svg")
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
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
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
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
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
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
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
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
|
-
|
657
|
+
.data(data)
|
661
658
|
.enter().append("line")
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
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
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
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
|
-
|
695
|
-
|
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
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
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(
|
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
|
-
|
724
|
-
|
725
|
-
|
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
|
-
|
722
|
+
.range([0, width]);
|
729
723
|
var y = d3.scale.linear()
|
730
|
-
|
724
|
+
.range([height, 0]);
|
731
725
|
|
732
726
|
var color = d3.scale.category10();
|
733
727
|
|
734
728
|
var xAxis = d3.svg.axis()
|
735
|
-
|
736
|
-
|
737
|
-
|
729
|
+
.scale(x)
|
730
|
+
.orient("bottom")
|
731
|
+
.ticks(5);
|
738
732
|
|
739
733
|
var yAxis = d3.svg.axis()
|
740
|
-
|
741
|
-
|
742
|
-
|
734
|
+
.scale(y)
|
735
|
+
.orient("left")
|
736
|
+
.ticks(5);
|
743
737
|
|
744
738
|
var svg = d3.select("#".concat(target)).append("svg")
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
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
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
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
|
-
|
818
|
-
|
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
|
-
|
821
|
-
|
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
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
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
|
+
}
|