Skip to content

Commit fce0c44

Browse files
committed
Remove unused abstraction
1) the name is misleading, as of a recent refactoring the generation activity is "lazy", meaning the report generation is not triggered until it's being accessed. This allows to instantiate and object and do other opeations on it. 2) The abstraction is not used and just makes the code harder to reason about. If a different report type is needed, an abstraction can be added knowing all the context about it, not prematurely...
1 parent 98993b9 commit fce0c44

12 files changed

Lines changed: 118 additions & 124 deletions

File tree

lib/sequenceserver/report.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ module SequenceServer
66
# Report is a generic superclass. Programs, like BLAST, must implement their
77
# own report subclass.
88
class Report
9-
class << self
10-
def generate(job)
11-
BLAST::Report.new(job)
12-
end
13-
end
14-
159
# Provide access to global `config` & `logger` services to the report
1610
# objects.
1711
extend Forwardable

lib/sequenceserver/routes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class Routes < Sinatra::Base
116116
halt 404, { error: 'Job not found' }.to_json if job.nil?
117117
halt 202 unless job.done?
118118

119-
report = Report.generate(job)
119+
report = BLAST::Report.new(job)
120120
halt 202 unless report.done?
121121

122122
if display_large_result_warning?(report.xml_file_size)

spec/blast_versions/blast_2.2.30/blast_2.2.30_spec.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ module SequenceServer
88
init
99

1010
describe 'Report' do
11-
hits_report = Report.generate(with_hits)
12-
no_hits_report = Report.generate(no_hits)
11+
hits_report = BLAST::Report.new(with_hits)
12+
no_hits_report = BLAST::Report.new(no_hits)
1313

1414
it 'will return an Array of queries' do
1515
hits_report.queries.should be_a Array
@@ -28,8 +28,8 @@ module SequenceServer
2828
end
2929

3030
describe 'Query' do
31-
hits_report = Report.generate(with_hits)
32-
no_hits_report = Report.generate(no_hits)
31+
hits_report = BLAST::Report.new(with_hits)
32+
no_hits_report = BLAST::Report.new(no_hits)
3333

3434
it 'will return queries with valid length' do
3535
hits_report.queries.first.length.should be_a Integer
@@ -45,8 +45,8 @@ module SequenceServer
4545
end
4646

4747
describe 'Hits' do
48-
hits_report = Report.generate(with_hits)
49-
no_hits_report = Report.generate(no_hits)
48+
hits_report = BLAST::Report.new(with_hits)
49+
no_hits_report = BLAST::Report.new(no_hits)
5050

5151
it 'will have non zero length' do
5252
hits_report.queries.last.hits.first.length.should satisfy { |n| n > 0 }
@@ -68,7 +68,7 @@ module SequenceServer
6868
# Test general features of HSPs. Algorithm specific customizations are
6969
# tested separetly.
7070
describe 'HSPs' do
71-
hits_report = Report.generate(with_hits)
71+
hits_report = BLAST::Report.new(with_hits)
7272

7373
# Currently using all 17 HSP parameters in BLAST Report + 1 to refer to the
7474
# hit object it belongs to.
@@ -138,7 +138,7 @@ module SequenceServer
138138
#
139139
describe 'BLASTN' do
140140
let 'hsp' do
141-
report = Report.generate(Job.fetch('blast_2.2.30/blastn'))
141+
report = BLAST::Report.new(Job.fetch('blast_2.2.30/blastn'))
142142
report.queries.first.hits.last.hsps.first
143143
end
144144

@@ -158,7 +158,7 @@ module SequenceServer
158158

159159
describe 'BLASTP' do
160160
let 'hsp' do
161-
report = Report.generate(Job.fetch('blast_2.2.30/blastp'))
161+
report = BLAST::Report.new(Job.fetch('blast_2.2.30/blastp'))
162162
report.queries.first.hits.last.hsps.first
163163
end
164164

@@ -176,7 +176,7 @@ module SequenceServer
176176

177177
describe 'BLASTX' do
178178
let 'hsp' do
179-
report = Report.generate(Job.fetch('blast_2.2.30/blastx'))
179+
report = BLAST::Report.new(Job.fetch('blast_2.2.30/blastx'))
180180

181181
report.queries.first.hits.last.hsps.first
182182
end
@@ -194,7 +194,7 @@ module SequenceServer
194194

195195
describe 'TBLASTX' do
196196
let 'hsp' do
197-
report = Report.generate(Job.fetch('blast_2.2.30/tblastx'))
197+
report = BLAST::Report.new(Job.fetch('blast_2.2.30/tblastx'))
198198
report.queries.first.hits.last.hsps.first
199199
end
200200

@@ -211,7 +211,7 @@ module SequenceServer
211211

212212
describe 'TBLASTN' do
213213
let 'hsp' do
214-
report = Report.generate(Job.fetch('blast_2.2.30/tblastn'))
214+
report = BLAST::Report.new(Job.fetch('blast_2.2.30/tblastn'))
215215
report.queries.first.hits.last.hsps.first
216216
end
217217

spec/blast_versions/blast_2.2.31/blast_2.2.31_spec.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ module SequenceServer
88
init
99

1010
describe 'Report' do
11-
hits_report = Report.generate(with_hits)
12-
no_hits_report = Report.generate(no_hits)
11+
hits_report = BLAST::Report.new(with_hits)
12+
no_hits_report = BLAST::Report.new(no_hits)
1313

1414
it 'will return an Array of queries' do
1515
hits_report.queries.should be_a Array
@@ -28,8 +28,8 @@ module SequenceServer
2828
end
2929

3030
describe 'Query' do
31-
hits_report = Report.generate(with_hits)
32-
no_hits_report = Report.generate(no_hits)
31+
hits_report = BLAST::Report.new(with_hits)
32+
no_hits_report = BLAST::Report.new(no_hits)
3333

3434
it 'will return queries with valid length' do
3535
hits_report.queries.first.length.should be_a Integer
@@ -45,8 +45,8 @@ module SequenceServer
4545
end
4646

4747
describe 'Hits' do
48-
hits_report = Report.generate(with_hits)
49-
no_hits_report = Report.generate(no_hits)
48+
hits_report = BLAST::Report.new(with_hits)
49+
no_hits_report = BLAST::Report.new(no_hits)
5050

5151
it 'will have non zero length' do
5252
hits_report.queries.last.hits.first.length.should satisfy { |n| n > 0 }
@@ -68,7 +68,7 @@ module SequenceServer
6868
# Test general features of HSPs. Algorithm specific customizations are
6969
# tested separetly.
7070
describe 'HSPs' do
71-
hits_report = Report.generate(with_hits)
71+
hits_report = BLAST::Report.new(with_hits)
7272

7373
# Currently using all 17 HSP parameters in BLAST Report + 1 to refer to the
7474
# hit object it belongs to.
@@ -138,7 +138,7 @@ module SequenceServer
138138
#
139139
describe 'BLASTN' do
140140
let 'hsp' do
141-
report = Report.generate(Job.fetch('blast_2.2.31/blastn'))
141+
report = BLAST::Report.new(Job.fetch('blast_2.2.31/blastn'))
142142
report.queries.first.hits.last.hsps.first
143143
end
144144

@@ -158,7 +158,7 @@ module SequenceServer
158158

159159
describe 'BLASTP' do
160160
let 'hsp' do
161-
report = Report.generate(Job.fetch('blast_2.2.31/blastp'))
161+
report = BLAST::Report.new(Job.fetch('blast_2.2.31/blastp'))
162162
report.queries.first.hits.last.hsps.first
163163
end
164164

@@ -176,7 +176,7 @@ module SequenceServer
176176

177177
describe 'BLASTX' do
178178
let 'hsp' do
179-
report = Report.generate(Job.fetch('blast_2.2.31/blastx'))
179+
report = BLAST::Report.new(Job.fetch('blast_2.2.31/blastx'))
180180

181181
report.queries.first.hits.last.hsps.first
182182
end
@@ -194,7 +194,7 @@ module SequenceServer
194194

195195
describe 'TBLASTX' do
196196
let 'hsp' do
197-
report = Report.generate(Job.fetch('blast_2.2.31/tblastx'))
197+
report = BLAST::Report.new(Job.fetch('blast_2.2.31/tblastx'))
198198
report.queries.first.hits.last.hsps.first
199199
end
200200

@@ -211,7 +211,7 @@ module SequenceServer
211211

212212
describe 'TBLASTN' do
213213
let 'hsp' do
214-
report = Report.generate(Job.fetch('blast_2.2.31/tblastn'))
214+
report = BLAST::Report.new(Job.fetch('blast_2.2.31/tblastn'))
215215
report.queries.first.hits.last.hsps.first
216216
end
217217

spec/blast_versions/blast_2.3.0/blast_2.3.0_spec.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ module SequenceServer
99
init
1010

1111
describe 'Report' do
12-
hits_report = Report.generate(with_hits)
13-
no_hits_report = Report.generate(no_hits)
12+
hits_report = BLAST::Report.new(with_hits)
13+
no_hits_report = BLAST::Report.new(no_hits)
1414

1515
it 'will return an Array of queries' do
1616
hits_report.queries.should be_a Array
@@ -29,8 +29,8 @@ module SequenceServer
2929
end
3030

3131
describe 'Query' do
32-
hits_report = Report.generate(with_hits)
33-
no_hits_report = Report.generate(no_hits)
32+
hits_report = BLAST::Report.new(with_hits)
33+
no_hits_report = BLAST::Report.new(no_hits)
3434

3535
it 'will return queries with valid length' do
3636
hits_report.queries.first.length.should be_a Integer
@@ -46,8 +46,8 @@ module SequenceServer
4646
end
4747

4848
describe 'Hits' do
49-
hits_report = Report.generate(with_hits)
50-
no_hits_report = Report.generate(no_hits)
49+
hits_report = BLAST::Report.new(with_hits)
50+
no_hits_report = BLAST::Report.new(no_hits)
5151

5252
it 'will have non zero length' do
5353
hits_report.queries.last.hits.first.length.should satisfy { |n| n > 0 }
@@ -69,7 +69,7 @@ module SequenceServer
6969
# Test general features of HSPs. Algorithm specific customizations are
7070
# tested separetly.
7171
describe 'HSPs' do
72-
hits_report = Report.generate(with_hits)
72+
hits_report = BLAST::Report.new(with_hits)
7373

7474
# Currently using all 17 HSP parameters in BLAST Report + 1 to refer to the
7575
# hit object it belongs to.
@@ -139,7 +139,7 @@ module SequenceServer
139139
#
140140
describe 'BLASTN' do
141141
let 'hsp' do
142-
report = Report.generate(Job.fetch('blast_2.3.0/blastn'))
142+
report = BLAST::Report.new(Job.fetch('blast_2.3.0/blastn'))
143143
report.queries.first.hits.last.hsps.first
144144
end
145145

@@ -159,7 +159,7 @@ module SequenceServer
159159

160160
describe 'BLASTP' do
161161
let 'hsp' do
162-
report = Report.generate(Job.fetch('blast_2.3.0/blastp'))
162+
report = BLAST::Report.new(Job.fetch('blast_2.3.0/blastp'))
163163
report.queries.first.hits.last.hsps.first
164164
end
165165

@@ -177,7 +177,7 @@ module SequenceServer
177177

178178
describe 'BLASTX' do
179179
let 'hsp' do
180-
report = Report.generate(Job.fetch('blast_2.3.0/blastx'))
180+
report = BLAST::Report.new(Job.fetch('blast_2.3.0/blastx'))
181181

182182
report.queries.first.hits.last.hsps.first
183183
end
@@ -195,7 +195,7 @@ module SequenceServer
195195

196196
describe 'TBLASTX' do
197197
let 'hsp' do
198-
report = Report.generate(Job.fetch('blast_2.3.0/tblastx'))
198+
report = BLAST::Report.new(Job.fetch('blast_2.3.0/tblastx'))
199199
report.queries.first.hits.last.hsps.first
200200
end
201201

@@ -212,7 +212,7 @@ module SequenceServer
212212

213213
describe 'TBLASTN' do
214214
let 'hsp' do
215-
report = Report.generate(Job.fetch('blast_2.3.0/tblastn'))
215+
report = BLAST::Report.new(Job.fetch('blast_2.3.0/tblastn'))
216216
report.queries.first.hits.last.hsps.first
217217
end
218218

spec/blast_versions/blast_2.4.0/blast_2.4.0_spec.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ module SequenceServer
88
init
99

1010
describe 'Report' do
11-
hits_report = Report.generate(with_hits)
12-
no_hits_report = Report.generate(no_hits)
11+
hits_report = BLAST::Report.new(with_hits)
12+
no_hits_report = BLAST::Report.new(no_hits)
1313

1414
it 'will return an Array of queries' do
1515
hits_report.queries.should be_a Array
@@ -28,8 +28,8 @@ module SequenceServer
2828
end
2929

3030
describe 'Query' do
31-
hits_report = Report.generate(with_hits)
32-
no_hits_report = Report.generate(no_hits)
31+
hits_report = BLAST::Report.new(with_hits)
32+
no_hits_report = BLAST::Report.new(no_hits)
3333

3434
it 'will return queries with valid length' do
3535
hits_report.queries.first.length.should be_a Integer
@@ -45,8 +45,8 @@ module SequenceServer
4545
end
4646

4747
describe 'Hits' do
48-
hits_report = Report.generate(with_hits)
49-
no_hits_report = Report.generate(no_hits)
48+
hits_report = BLAST::Report.new(with_hits)
49+
no_hits_report = BLAST::Report.new(no_hits)
5050

5151
it 'will have non zero length' do
5252
hits_report.queries.last.hits.first.length.should satisfy { |n| n > 0 }
@@ -68,7 +68,7 @@ module SequenceServer
6868
# Test general features of HSPs. Algorithm specific customizations are
6969
# tested separetly.
7070
describe 'HSPs' do
71-
hits_report = Report.generate(with_hits)
71+
hits_report = BLAST::Report.new(with_hits)
7272

7373
# Currently using all 17 HSP parameters in BLAST Report + 1 to refer to the
7474
# hit object it belongs to.
@@ -138,7 +138,7 @@ module SequenceServer
138138
#
139139
describe 'BLASTN' do
140140
let 'hsp' do
141-
report = Report.generate(Job.fetch('blast_2.4.0/blastn'))
141+
report = BLAST::Report.new(Job.fetch('blast_2.4.0/blastn'))
142142
report.queries.first.hits.last.hsps.first
143143
end
144144

@@ -158,7 +158,7 @@ module SequenceServer
158158

159159
describe 'BLASTP' do
160160
let 'hsp' do
161-
report = Report.generate(Job.fetch('blast_2.4.0/blastp'))
161+
report = BLAST::Report.new(Job.fetch('blast_2.4.0/blastp'))
162162
report.queries.first.hits.last.hsps.first
163163
end
164164

@@ -176,7 +176,7 @@ module SequenceServer
176176

177177
describe 'BLASTX' do
178178
let 'hsp' do
179-
report = Report.generate(Job.fetch('blast_2.4.0/blastx'))
179+
report = BLAST::Report.new(Job.fetch('blast_2.4.0/blastx'))
180180

181181
report.queries.first.hits.last.hsps.first
182182
end
@@ -194,7 +194,7 @@ module SequenceServer
194194

195195
describe 'TBLASTX' do
196196
let 'hsp' do
197-
report = Report.generate(Job.fetch('blast_2.4.0/tblastx'))
197+
report = BLAST::Report.new(Job.fetch('blast_2.4.0/tblastx'))
198198
report.queries.first.hits.last.hsps.first
199199
end
200200

@@ -211,7 +211,7 @@ module SequenceServer
211211

212212
describe 'TBLASTN' do
213213
let 'hsp' do
214-
report = Report.generate(Job.fetch('blast_2.4.0/tblastn'))
214+
report = BLAST::Report.new(Job.fetch('blast_2.4.0/tblastn'))
215215
report.queries.first.hits.last.hsps.first
216216
end
217217

0 commit comments

Comments
 (0)