sequenceserver 2.0.0.beta3 → 2.0.0.beta4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +5 -5
  2. data/.eslintrc.json +36 -0
  3. data/.rubocop.yml +1 -1
  4. data/.travis.yml +53 -20
  5. data/AppImage/recipe.yml +15 -0
  6. data/AppImage/sequenceserver.desktop +8 -0
  7. data/AppImage/sequenceserver.png +0 -0
  8. data/AppImage/sequenceserver.sh +11 -0
  9. data/README.md +79 -46
  10. data/bin/sequenceserver +4 -4
  11. data/lib/sequenceserver/version.rb +1 -1
  12. data/package.json +2 -0
  13. data/public/css/grapher.css +3 -0
  14. data/public/css/sequenceserver.css +17 -6
  15. data/public/css/sequenceserver.min.css +3 -3
  16. data/public/js/circos.js +515 -491
  17. data/public/js/grapher.js +12 -6
  18. data/public/js/hits_overview.js +321 -308
  19. data/public/js/hsp.js +12 -7
  20. data/public/js/length_distribution.js +241 -234
  21. data/public/js/report.js +196 -174
  22. data/public/js/search.js +3 -3
  23. data/public/js/sequenceserver.js +9 -9
  24. data/public/js/utils.js +17 -10
  25. data/public/js/visualisation_helpers.js +77 -77
  26. data/public/sequenceserver-report.min.js +17 -17
  27. data/public/sequenceserver-search.min.js +1 -1
  28. data/public/vendor/github/nicgirault/circosJs@1.7.0/dist/circosJS.js +1 -5
  29. data/sequenceserver.gemspec +1 -2
  30. data/spec/blast_versions/blast_2.2.30/blast_2.2.30_spec.rb +13 -13
  31. data/spec/blast_versions/blast_2.2.30/import_spec_capybara_local_2.2.30.rb +555 -25
  32. data/spec/blast_versions/blast_2.2.31/blast_2.2.31_spec.rb +13 -13
  33. data/spec/blast_versions/blast_2.2.31/import_spec_capybara_local_2.2.31.rb +558 -24
  34. data/spec/blast_versions/blast_2.3.0/blast_2.3.0_spec.rb +13 -13
  35. data/spec/blast_versions/blast_2.3.0/import_spec_capybara_local_2.3.0.rb +561 -26
  36. data/spec/blast_versions/blast_2.4.0/blast_2.4.0_spec.rb +13 -13
  37. data/spec/blast_versions/blast_2.4.0/import_spec_capybara_local_2.4.0.rb +561 -25
  38. data/spec/blast_versions/blast_2.5.0/blast_2.5.0_spec.rb +13 -13
  39. data/spec/blast_versions/blast_2.5.0/import_spec_capybara_local_2.5.0.rb +558 -24
  40. data/spec/blast_versions/blast_2.6.0/blast_2.6.0_spec.rb +13 -13
  41. data/spec/blast_versions/blast_2.6.0/import_spec_capybara_local_2.6.0.rb +559 -24
  42. data/spec/blast_versions/blast_2.7.1/blast_2.7.1_spec.rb +13 -13
  43. data/spec/blast_versions/blast_2.7.1/import_spec_capybara_local_2.7.1.rb +559 -28
  44. data/spec/blast_versions/blast_2.8.1/blast_2.8.1_spec.rb +13 -13
  45. data/spec/blast_versions/blast_2.8.1/import_spec_capybara_local_2.8.1.rb +559 -27
  46. data/spec/blast_versions/blast_2.9.0/blast_2.9.0_spec.rb +13 -13
  47. data/spec/blast_versions/blast_2.9.0/import_spec_capybara_local_2.9.0.rb +557 -25
  48. data/spec/blast_versions/diamond_0.9.24/diamond_0.9.24_spec.rb +13 -13
  49. data/spec/blast_versions/diamond_0.9.24/import_spec_capybara_local_0.9.24.rb +219 -21
  50. data/spec/capybara_spec.rb +25 -28
  51. data/spec/download_helper.rb +6 -3
  52. data/spec/sequences/MH011443_1_gi_1486783306_gb_MH011443_1.txt +6 -0
  53. data/spec/sequences/MH011443_1_gi_1486783307_gb_AYF55702_1.txt +6 -0
  54. data/spec/sequences/MH011443_1_gi_1528997474_gb_MH447967_1.txt +30 -0
  55. data/spec/sequences/MH011443_1_sp_P04637_P53_HUMAN.txt +6 -0
  56. data/spec/sequences/alignment-35_hits_diamond_blastp.txt +210 -0
  57. data/spec/sequences/alignment-35_hits_diamond_blastx.txt +210 -0
  58. data/spec/sequences/alignment-3_hits.txt +18 -0
  59. data/spec/sequences/alignment-40_hits_blastn.txt +246 -0
  60. data/spec/sequences/alignment-40_hits_blastp.txt +240 -0
  61. data/spec/sequences/alignment-40_hits_blastp_2.2.30.txt +240 -0
  62. data/spec/sequences/alignment-40_hits_blastx.txt +240 -0
  63. data/spec/sequences/alignment-40_hits_tblastn.txt +240 -0
  64. data/spec/sequences/alignment-40_hits_tblastn_2.2.30.txt +240 -0
  65. data/spec/sequences/alignment-40_hits_tblastx.txt +2664 -0
  66. data/spec/sequences/alignment-4_hits.txt +24 -0
  67. data/spec/sequences/alignment-4_hits_blastn.txt +24 -0
  68. data/spec/sequences/alignment-4_hits_blastp.txt +24 -0
  69. data/spec/sequences/alignment-4_hits_blastp_2.2.30.txt +24 -0
  70. data/spec/sequences/alignment-4_hits_blastx.txt +24 -0
  71. data/spec/sequences/alignment-4_hits_diamond_blastp.txt +24 -0
  72. data/spec/sequences/alignment-4_hits_diamond_blastx.txt +24 -0
  73. data/spec/sequences/alignment-4_hits_tblastn.txt +24 -0
  74. data/spec/sequences/alignment-4_hits_tblastn_2.2.30.txt +24 -0
  75. data/spec/sequences/alignment-4_hits_tblastx.txt +318 -0
  76. data/spec/sequences/sp_P04637_P53_HUMAN_gi_1099170394_ref_XP_018868681_1.txt +6 -0
  77. data/spec/sequences/sp_P04637_P53_HUMAN_gi_120407068_ref_NP_000537_3.txt +6 -0
  78. data/spec/sequences/sp_P04637_P53_HUMAN_gi_1484127324_gb_MG595988_1.txt +6 -0
  79. data/spec/sequences/sp_P04637_P53_HUMAN_gi_395440626_gb_JQ694049_1.txt +6 -0
  80. data/spec/sequences/sp_P04637_P53_HUMAN_sp_P04637_P53_HUMAN.txt +6 -0
  81. data/spec/spec_helper.rb +3 -3
  82. metadata +67 -57
  83. data/.eslintrc +0 -213
  84. data/Rakefile +0 -8
  85. data/spec/dotdir/blast_2.4.0/blastn/TBLASTN_XML_2.4.0.xml +0 -1181
  86. data/spec/dotdir/blast_2.5.0/blastn/BLASTN_LONG_XML_2.5.0.xml +0 -18813
  87. data/spec/import_spec_capybara_local.rb +0 -61
data/public/js/hsp.js CHANGED
@@ -45,10 +45,15 @@ export default class HSP extends React.Component {
45
45
  }
46
46
 
47
47
  /**
48
- * Return prettified stats for the given hsp and based on the BLAST
49
- * algorithm.
48
+ * Returns an array of span elements or plain strings (React automatically
49
+ * adds span tag around strings). This array is passed as it is to JSX to be
50
+ * rendered just above the pairwise alignment (see render method).
51
+ *
52
+ * We cannot return a string from this method otherwise we wouldn't be able
53
+ * to use JSX elements to format text (like, superscript).
50
54
  */
51
55
  hspStats () {
56
+ // An array to hold text or span elements that make up the line.
52
57
  let line = [];
53
58
 
54
59
  // Bit score and total score.
@@ -69,23 +74,23 @@ export default class HSP extends React.Component {
69
74
  }
70
75
 
71
76
  // Gaps
72
- line.push(`Gaps: ${Utils.inFraction(this.hsp.gaps, this.hsp.length)} (${Utils.inPercentage(this.hsp.gaps, this.hsp.length)}), `);
77
+ line.push(`Gaps: ${Utils.inFraction(this.hsp.gaps, this.hsp.length)} (${Utils.inPercentage(this.hsp.gaps, this.hsp.length)})`);
73
78
 
74
79
  // Query coverage
75
80
  //line.push(`Query coverage: ${this.hsp.qcovhsp}%, `)
76
81
 
77
82
  switch (this.props.algorithm) {
78
83
  case 'tblastx':
79
- line.push(`Frame: ${Utils.inFraction(this.hsp.qframe, this.hsp.sframe)}`)
84
+ line.push(`, Frame: ${Utils.inFraction(this.hsp.qframe, this.hsp.sframe)}`)
80
85
  break;
81
86
  case 'blastn':
82
- line.push(`Strand: ${(this.hsp.qframe > 0 ? '+' : '-')} / ${(this.hsp.sframe > 0 ? '+' : '-')}`)
87
+ line.push(`, Strand: ${(this.hsp.qframe > 0 ? '+' : '-')} / ${(this.hsp.sframe > 0 ? '+' : '-')}`)
83
88
  break;
84
89
  case 'blastx':
85
- line.push(`Query Frame: ${this.hsp.qframe}`)
90
+ line.push(`, Query Frame: ${this.hsp.qframe}`)
86
91
  break;
87
92
  case 'tblastn':
88
- line.push(`Hit Frame: ${this.hsp.sframe}`)
93
+ line.push(`, Hit Frame: ${this.hsp.sframe}`)
89
94
  break;
90
95
  }
91
96
 
@@ -8,246 +8,253 @@ import * as Helpers from './visualisation_helpers';
8
8
  */
9
9
 
10
10
  class Graph {
11
- static name() {
12
- return 'Length distribution of hits';
13
- }
14
-
15
- static className() {
16
- return 'length-distribution';
17
- }
18
-
19
- static collapseId(props) {
20
- return 'length_'+props.query.number;
21
- }
22
-
23
- static dataName(props) {
24
- return 'length-distribution-'+props.query.id
25
- }
26
-
27
- constructor($svg_container, props) {
28
- this.query = props.query;
29
- this._seq_type = Helpers.get_seq_type(props.algorithm);
30
- this.svg_container = $svg_container
31
-
32
- this._margin = {top: 30, right: 25, bottom: 55, left: 12.5};
33
- this.initiate($svg_container.width(), $svg_container.height());
34
- }
35
-
36
- initiate(width, height) {
37
- this._width = width - this._margin.left - this._margin.right;
38
- this._height = height - this._margin.top - this._margin.bottom;
39
- this.svg = d3.select(this.svg_container[0]).insert('svg', ':first-child')
40
- .attr('width', this._width + this._margin.right + this._margin.left)
41
- .attr('height', this._height + this._margin.top + this._margin.bottom)
42
- .append('g')
43
- .attr('transform','translate('+this._margin.left+','+this._margin.top+')');
44
- this.hit_lengths();
45
- this.define_scale_and_bins();
46
- this.update_data();
47
- this.draw();
48
- }
49
-
50
- draw() {
51
- this.draw_rectangles();
52
- this.draw_query_line();
53
- this.draw_axes();
54
- this.setupTooltip();
55
- }
56
-
57
- define_scale_and_bins() {
58
- this._scale_x = d3.scale.linear()
59
- .domain([
60
- 0,
61
- (d3.max([this.query.length,d3.max(this._data)]) * 1.05)
62
- ])
63
- .range([0, this._width]);
64
- this._bins = d3.layout.histogram()
65
- .range(this._scale_x.domain())
66
- .bins(this._scale_x.ticks(50))
67
- (this._data);
68
- this._scale_y = d3.scale.linear()
69
- .domain([0, d3.max(this._bins, function(d) { return d.length })])
70
- .range([this._height, 0]);
71
- }
72
-
73
- hit_lengths() {
74
- this._data = _.map(this.query.hits, _.iteratee('length'))
75
- }
76
-
77
- setupTooltip() {
78
- this.svg_container.find('[data-toggle="tooltip"]').tooltip({
79
- 'placement': 'top', 'container': 'body', 'html': 'true',
80
- 'delay': 0, 'white-space': 'nowrap'
81
- });
82
- }
83
-
84
- setupResponsiveness() {
85
- var currentWidth = $(window).width();
86
- console.log('cureent '+currentWidth);
87
- var debounced_draw = _.debounce(_.bind(function () {
88
- if (currentWidth != $(window).width()) {
89
- console.log('redraw initiated '+this._height);
90
- this.draw();
91
- currentWidth = $(window).width();
92
- }
93
- }, this), 125);
94
- $(window).resize(debounced_draw);
95
- }
96
-
97
- tick_formatter(seq_type) {
98
- var ticks = this._scale_x.ticks();
99
- var format = d3.format('.1f');
100
- var prefix = d3.formatPrefix(ticks[ticks.length - 1]);
101
- var suffixes = {amino_acid: 'aa', nucleic_acid: 'bp'};
102
- return function (d) {
103
- if (d === 0) { return ; }
104
- if (_.indexOf(ticks,d) >= 0) {
105
- if (suffixes[seq_type] == 'aa') {
106
- return (d + ' ' + suffixes[seq_type])
11
+ static name() {
12
+ return 'Length distribution of hits';
13
+ }
14
+
15
+ static className() {
16
+ return 'length-distribution';
17
+ }
18
+
19
+ static collapseId(props) {
20
+ return 'length_'+props.query.number;
21
+ }
22
+
23
+ static dataName(props) {
24
+ return 'length-distribution-'+props.query.id;
25
+ }
26
+
27
+ constructor($svg_container, props) {
28
+ this.query = props.query;
29
+ this._seq_type = Helpers.get_seq_type(props.algorithm);
30
+ this.svg_container = $svg_container;
31
+ if (props.algorithm == 'blastx') {
32
+ this.query_length = this.query.length / 3;
33
+ } else if (props.algorithm == 'tblastn') {
34
+ this.query_length = this.query.length * 3;
107
35
  } else {
108
- return (format(prefix.scale(d)) + ' ' + prefix.symbol + suffixes[seq_type]);
36
+ this.query_length = this.query.length;
109
37
  }
110
- } else {
111
- return ;
112
- }
113
- };
114
- }
115
-
116
- update_data() {
117
- var self = this;
118
- var data2 = [];
119
- this._bins.map(function (bin) {
120
- var inner_data = [];
121
- bin.reverse();
122
- var y0 = bin.length;
123
- bin.map(function (d,i) {
124
- var y1 = bin.length - (i+1);
125
- var len_index = _.findIndex(self.query.hits, {length: d});
126
- var item = {
127
- value: d,
128
- id: self.query.hits[len_index].id,
129
- evalue: self.query.hits[len_index].evalue,
130
- url: '#Query_'+self.query.number+'_hit_'+self.query.hits[len_index].number,
131
- y0: y0,
132
- y1: y0 += (y1 - y0),
133
- color: Helpers.get_colors_for_evalue(self.query.hits[len_index].evalue,self.query.hits)
134
- };
135
- inner_data.push(item);
136
- })
137
- var item = {data: inner_data, x: bin.x, dx: bin.dx, length: bin.length};
138
- data2.push(item);
139
- })
140
- this._update_data = data2;
141
- }
142
-
143
- draw_rectangles() {
144
- var self = this;
145
- var bar = this.svg.selectAll('.bar')
146
- .data(this._update_data)
147
- .enter().append('g')
148
- .attr('class', 'g')
149
- .attr('transform', function(d) {
150
- return 'translate('+(self._scale_x(d.x)+self._margin.left)+',0)';
38
+ this._margin = {top: 30, right: 25, bottom: 55, left: 12.5};
39
+ this.initiate($svg_container.width(), $svg_container.height());
40
+ }
41
+
42
+ initiate(width, height) {
43
+ this._width = width - this._margin.left - this._margin.right;
44
+ this._height = height - this._margin.top - this._margin.bottom;
45
+ this.svg = d3.select(this.svg_container[0]).insert('svg', ':first-child')
46
+ .attr('width', this._width + this._margin.right + this._margin.left)
47
+ .attr('height', this._height + this._margin.top + this._margin.bottom)
48
+ .append('g')
49
+ .attr('transform','translate('+this._margin.left+','+this._margin.top+')');
50
+ this.hit_lengths();
51
+ this.define_scale_and_bins();
52
+ this.update_data();
53
+ this.draw();
54
+ }
55
+
56
+ draw() {
57
+ this.draw_rectangles();
58
+ this.draw_query_line();
59
+ this.draw_axes();
60
+ this.setupTooltip();
61
+ }
62
+
63
+ define_scale_and_bins() {
64
+ this._scale_x = d3.scale.linear()
65
+ .domain([
66
+ 0,
67
+ (d3.max([this.query_length, d3.max(this._data)]) * 1.01)
68
+ ]).nice()
69
+ .range([0, this._width]);
70
+ this._bins = d3.layout.histogram()
71
+ .range(this._scale_x.domain())
72
+ .bins(this._scale_x.ticks(50))
73
+ (this._data);
74
+ this._scale_y = d3.scale.linear()
75
+ .domain([0, d3.max(this._bins, function(d) { return d.length; })])
76
+ .range([this._height, 0]).nice();
77
+ }
78
+
79
+ hit_lengths() {
80
+ this._data = _.map(this.query.hits, _.iteratee('length'));
81
+ }
82
+
83
+ setupTooltip() {
84
+ this.svg_container.find('[data-toggle="tooltip"]').tooltip({
85
+ 'placement': 'top', 'container': 'body', 'html': 'true',
86
+ 'delay': 0, 'white-space': 'nowrap'
151
87
  });
88
+ }
152
89
 
153
- bar.selectAll('rect')
154
- .data(function (d) { return d.data; })
155
- .enter().append('a')
156
- .attr('xlink:href', function(i) { return i.url })
157
- .append('rect')
158
- .attr('class','bar')
159
- .attr('data-toggle','tooltip')
160
- .attr('title', function(i) {
161
- return i.id+' '+'<br>E Value: '+Helpers.prettify_evalue(i.evalue)+'<br>Length: '+i.value;
162
- })
163
- .attr('x', 1)
164
- .attr('y', function(i) { return (self._scale_y(i.y0)); })
165
- .attr('width', self._scale_x(this._bins[1].x) - self._scale_x(this._bins[0].x) - 1)
166
- .attr('height', function (i) { return self._scale_y(i.y1) - self._scale_y(i.y0); })
167
- .attr('fill', function(i) {
168
- return i.color;
90
+ setupResponsiveness() {
91
+ var currentWidth = $(window).width();
92
+ console.log('cureent '+currentWidth);
93
+ var debounced_draw = _.debounce(_.bind(function () {
94
+ if (currentWidth != $(window).width()) {
95
+ console.log('redraw initiated '+this._height);
96
+ this.draw();
97
+ currentWidth = $(window).width();
98
+ }
99
+ }, this), 125);
100
+ $(window).resize(debounced_draw);
101
+ }
102
+
103
+ tick_formatter(seq_type) {
104
+ var ticks = this._scale_x.ticks();
105
+ var format = d3.format('.1f');
106
+ var prefix = d3.formatPrefix(ticks[ticks.length - 1]);
107
+ var suffixes = {amino_acid: 'aa', nucleic_acid: 'bp'};
108
+ return function (d) {
109
+ if (d === 0) { return ; }
110
+ if (_.indexOf(ticks,d) >= 0) {
111
+ if (suffixes[seq_type] == 'aa') {
112
+ return (d + ' ' + suffixes[seq_type]);
113
+ } else {
114
+ return (format(prefix.scale(d)) + ' ' + prefix.symbol + suffixes[seq_type]);
115
+ }
116
+ } else {
117
+ return ;
118
+ }
119
+ };
120
+ }
121
+
122
+ update_data() {
123
+ var self = this;
124
+ var data2 = [];
125
+ this._bins.map(function (bin) {
126
+ var inner_data = [];
127
+ bin.reverse();
128
+ var y0 = bin.length;
129
+ bin.map(function (d,i) {
130
+ var y1 = bin.length - (i+1);
131
+ var len_index = _.findIndex(self.query.hits, {length: d});
132
+ var item = {
133
+ value: d,
134
+ id: self.query.hits[len_index].id,
135
+ evalue: self.query.hits[len_index].evalue,
136
+ url: '#Query_'+self.query.number+'_hit_'+self.query.hits[len_index].number,
137
+ y0: y0,
138
+ y1: y0 += (y1 - y0),
139
+ color: Helpers.get_colors_for_evalue(self.query.hits[len_index].evalue,self.query.hits)
140
+ };
141
+ inner_data.push(item);
142
+ });
143
+ var item = {data: inner_data, x: bin.x, dx: bin.dx, length: bin.length};
144
+ data2.push(item);
169
145
  });
170
- }
171
-
172
- draw_query_line() {
173
- var query_line = this.svg.append('g')
174
- .attr('class','query_line')
175
- .attr('transform','translate('+(this._margin.left+this._scale_x(this.query.length))+',0)');
176
-
177
- query_line.append('rect')
178
- .attr('x',1)
179
- .attr('class','bar')
180
- .attr('width',4)
181
- .attr('height',this._height)
182
- .style('fill','rgb(95,122,183)');
183
-
184
- query_line.append('text')
185
- .attr('dy', '0.75em')
186
- .attr('y', -10)
187
- .attr('x', 2)
188
- .attr('text-anchor','start')
189
- .text('Query')
190
- .style('fill','#000')
191
- .attr('transform','rotate(-45)');
192
- }
193
-
194
- draw_axes() {
195
- var space, len;
196
- len = this._scale_y.ticks().length;
197
- if (len >= 8) {
198
- space = 8;
199
- } else {
200
- space = len;
201
- }
202
- var formatter = this.tick_formatter(this._seq_type.subject_seq_type);
203
- var x_axis = d3.svg.axis()
204
- .scale(this._scale_x)
205
- .orient('bottom')
206
- .ticks(50)
207
- .tickFormat(formatter);
208
- var y_axis = d3.svg.axis()
209
- .scale(this._scale_y)
210
- .orient('left')
211
- .tickValues(this._scale_y.ticks(space))
212
- .tickFormat(function (e) {
213
- if (Math.floor(e) != e) {
214
- return ;
215
- }
216
- return e;
146
+ this._update_data = data2;
147
+ }
148
+
149
+ draw_rectangles() {
150
+ var self = this;
151
+ var bar = this.svg.selectAll('.bar')
152
+ .data(this._update_data)
153
+ .enter().append('g')
154
+ .attr('class', 'g')
155
+ .attr('transform', function(d) {
156
+ return 'translate('+(self._scale_x(d.x)+self._margin.left)+',0)';
157
+ });
158
+
159
+ bar.selectAll('rect')
160
+ .data(function (d) { return d.data; })
161
+ .enter().append('a')
162
+ .attr('xlink:href', function(i) { return i.url; })
163
+ .append('rect')
164
+ .attr('class','bar')
165
+ .attr('data-toggle','tooltip')
166
+ .attr('title', function(i) {
167
+ return i.id+' '+'<br>E value: '+Helpers.prettify_evalue(i.evalue)+'<br>Length: '+i.value;
168
+ })
169
+ .attr('x', 1)
170
+ .attr('y', function(i) { return (self._scale_y(i.y0)); })
171
+ .attr('width', self._scale_x(this._bins[1].x) - self._scale_x(this._bins[0].x) - 1)
172
+ .attr('height', function (i) { return self._scale_y(i.y1) - self._scale_y(i.y0); })
173
+ .attr('fill', function(i) {
174
+ return i.color;
175
+ });
176
+ }
177
+
178
+ draw_query_line() {
179
+ var query_line = this.svg.append('g')
180
+ .attr('class','query_line')
181
+ .attr('transform','translate('+(this._margin.left+this._scale_x(this.query_length))+',0)');
182
+
183
+ query_line.append('rect')
184
+ .attr('x',1)
185
+ .attr('class','bar')
186
+ .attr('width',4)
187
+ .attr('height',this._height)
188
+ .style('fill','rgb(95,122,183)');
189
+
190
+ query_line.append('text')
191
+ .attr('dy', '0.75em')
192
+ .attr('y', -10)
193
+ .attr('x', 2)
194
+ .attr('text-anchor','start')
195
+ .text('Query')
196
+ .style('fill','#000')
197
+ .attr('transform','rotate(-45)');
198
+ }
199
+
200
+ draw_axes() {
201
+ var space, len;
202
+ len = this._scale_y.ticks().length;
203
+ if (len >= 5) {
204
+ space = 5;
205
+ } else {
206
+ space = len;
207
+ }
208
+ var formatter = this.tick_formatter(this._seq_type.subject_seq_type);
209
+ var x_axis = d3.svg.axis()
210
+ .scale(this._scale_x)
211
+ .orient('bottom')
212
+ .ticks(50)
213
+ .tickFormat(formatter);
214
+ var y_axis = d3.svg.axis()
215
+ .scale(this._scale_y)
216
+ .orient('left')
217
+ .tickValues(this._scale_y.ticks(space))
218
+ .outerTickSize(0)
219
+ .tickFormat(function (e) {
220
+ if (Math.floor(e) != e) {
221
+ return ;
222
+ }
223
+ return e;
224
+ });
225
+ var ticks = this._scale_y.ticks();
226
+ for (var i in ticks) {
227
+ if (ticks[i] % 1 != 0) {
228
+ y_axis.tickValues(d3.range(0, d3.max(this._bins, function(d) { return d.length; })+1));
229
+ break;
230
+ }
231
+ }
232
+ var self = this;
233
+ var xContainer = this.svg.append('g')
234
+ .attr('class', 'axis axis--x')
235
+ .attr('transform', 'translate('+this._margin.left+','+this._height+')')
236
+ .call(x_axis);
237
+
238
+ xContainer.selectAll('line').attr('y2',function (d) {
239
+ var ticks = self._scale_x.ticks();
240
+ if (_.indexOf(ticks, d) >= 0) {
241
+ return 7;
242
+ } else {
243
+ return 4;
244
+ }
217
245
  });
218
- var ticks = this._scale_y.ticks();
219
- for (var i in ticks) {
220
- if (ticks[i] % 1 != 0) {
221
- y_axis.tickValues(d3.range(0, d3.max(this._bins, function(d) { return d.length })+1));
222
- break;
223
- }
224
- }
225
- var self = this;
226
- var xContainer = this.svg.append('g')
227
- .attr('class', 'axis axis--x')
228
- .attr('transform', 'translate('+this._margin.left+','+this._height+')')
229
- .call(x_axis);
230
-
231
- xContainer.selectAll('line').attr('y2',function (d) {
232
- var ticks = self._scale_x.ticks();
233
- if (_.indexOf(ticks, d) >= 0) {
234
- return 7;
235
- } else {
236
- return 4;
237
- }
238
- });
239
-
240
- xContainer.selectAll('text').style('text-anchor','end')
241
- .attr('x', '-8px')
242
- .attr('y', '3px')
243
- .attr('dy', '0')
244
- .attr('transform','rotate(-90)');
245
-
246
- var yContainer = this.svg.append('g')
247
- .attr('class','axis axis--y')
248
- .attr('transform','translate('+this._margin.left+',0)')
249
- .call(y_axis);
250
- }
246
+
247
+ xContainer.selectAll('text').style('text-anchor','end')
248
+ .attr('x', '-8px')
249
+ .attr('y', '3px')
250
+ .attr('dy', '0')
251
+ .attr('transform','rotate(-90)');
252
+
253
+ var yContainer = this.svg.append('g')
254
+ .attr('class','axis axis--y')
255
+ .attr('transform','translate('+this._margin.left+',0)')
256
+ .call(y_axis);
257
+ }
251
258
  }
252
259
 
253
260
  var LengthDistribution = Grapher(Graph);