genfrag 0.0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.bnsignore +16 -0
- data/History.txt +4 -0
- data/LICENSE.txt +58 -0
- data/README.rdoc +40 -0
- data/Rakefile +53 -0
- data/bin/genfrag +8 -0
- data/lib/genfrag.rb +129 -0
- data/lib/genfrag/app.rb +105 -0
- data/lib/genfrag/app/command.rb +145 -0
- data/lib/genfrag/app/index_command.rb +227 -0
- data/lib/genfrag/app/index_command/db.rb +105 -0
- data/lib/genfrag/app/search_command.rb +298 -0
- data/lib/genfrag/app/search_command/match.rb +165 -0
- data/lib/genfrag/app/search_command/process_file.rb +125 -0
- data/lib/genfrag/app/search_command/trim.rb +121 -0
- data/lib/genfrag/debug.rb +0 -0
- data/spec/data/index_command/in/a.fasta +109 -0
- data/spec/data/index_command/out/1-a_lookup.tdf +4 -0
- data/spec/data/index_command/out/2-a_lookup.db +0 -0
- data/spec/data/index_command/out/3-a_lookup.tdf +2 -0
- data/spec/data/index_command/out/4-a_lookup.db +0 -0
- data/spec/data/index_command/out/5-a_lookup.tdf +4 -0
- data/spec/data/index_command/out/6-a_lookup.db +0 -0
- data/spec/data/index_command/out/a.fasta.db +0 -0
- data/spec/data/index_command/out/a.fasta.tdf +6 -0
- data/spec/genfrag/app/command_spec.rb +55 -0
- data/spec/genfrag/app/index_command_spec.rb +258 -0
- data/spec/genfrag/app/search_command/match_spec.rb +77 -0
- data/spec/genfrag/app/search_command/process_file_spec.rb +185 -0
- data/spec/genfrag/app/search_command/trim_spec.rb +75 -0
- data/spec/genfrag/app/search_command_spec.rb +260 -0
- data/spec/genfrag/app_spec.rb +77 -0
- data/spec/genfrag_spec.rb +87 -0
- data/spec/spec_helper.rb +56 -0
- data/tasks/ann.rake +80 -0
- data/tasks/bones.rake +20 -0
- data/tasks/gem.rake +201 -0
- data/tasks/git.rake +40 -0
- data/tasks/notes.rake +27 -0
- data/tasks/post_load.rake +34 -0
- data/tasks/rdoc.rake +50 -0
- data/tasks/rubyforge.rake +55 -0
- data/tasks/setup.rb +300 -0
- data/tasks/spec.rake +54 -0
- data/tasks/svn.rake +47 -0
- data/tasks/test.rake +40 -0
- metadata +136 -0
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,6 @@
|
|
1
|
+
id Definitions Sequence
|
2
|
+
1 At1g65300: mRNA 837bp atgaagagaaagatgaagttatcgttaatagaaaacagtgtatcgaggaaaacaacattcaccaaaaggaagaaagggatgacgaagaaactaaccgagctagtcactctatgtggtgttgaagcatgtgcggtcgtctatagtccgttcaactcgatcccggaggcttggccgtcaagggaaggcgttgaagacgtggtgtcgaaatttatggagttgtcggtgttggaccggaccaagaagatggtggatcaagagacttttataagtcaaaggatcgccaaagaaaaagagcagctgcagaagctacgtgatgagaaccataattctcagattcgggagttaatgtttggttgtctcaaaggggagacgaatgtgtataatcttgatggaagggatcttcaagatttgagtttatatattgataagtatcttaatggtcttactcgcaggattgagatcctTAttgagaacggtgagtcttcttcatctttacctcttcctattgttgcgaatgcagctgcaccagtcggatttgatggtcctatgtttcaatatcataatcaaaatcagcaaaagccggttcaattccaatatcaggctctttatgatttttatgatcagattccaaagaaaattcatggttttaatatgaatatgaataaggattcgaatcaaagtatggttttggatttgaatcaaaatcttaatgatggagaggacgagggcattccttgcatggacaacaacaactaccaccccgaaatcgattgtctcgctaccgtcaccactgcccccactgatgtttgtgctcctaacatcaccaatgatctctag
|
3
|
+
2 At1g65300: mRNA 837bp (shortened at end) atgaagagaaagatgaagttatcgttaatagaaaacagtgtatcgaggaaaacaacattcaccaaaaggaagaaagggatgacgaagaaactaaccgagctagtcactctatgtggtgttgaagcatgtgcggtcgtctatagtccgttcaactcgatcccggaggcttggccgtcaagggaaggcgttgaagacgtggtgtcgaaatttatggagttgtcggtgttggaccggaccaagaagatggtggatcaagagacttttataagtcaaaggatcgccaaagaaaaagagcagctgcagaagctacgtgatgagaaccataattctcagattcgggagttaatgtttggttgtctcaaaggggagacgaatgtgtataatcttgatggaagggatcttcaagatttgagtttatatattgataagtatcttaatggtcttactcgcaggattgagatcctTAttgagaacggtgagtcttcttcatctttacctcttcctattgttgcgaatgcagctgcaccagtcggatttgatggtcctatgtttcaatatcataatcaaaatcagcaaaagccggttcaattccaatatcaggctctttatgatttttatgatcag
|
4
|
+
3 At1g65300: mRNA 837bp (shortened from start) ttcatctttacctcttcctattgttgcgaatgcagctgcaccagtcggatttgatggtcctatgtttcaatatcataatcaaaatcagcaaaagccggttcaattccaatatcaggctctttatgatttttatgatcagattccaaagaaaattcatggttttaatatgaatatgaataaggattcgaatcaaagtatggttttggatttgaatcaaaatcttaatgatggagaggacgagggcattccttgcatggacaacaacaactaccaccccgaaatcgattgtctcgctaccgtcaccactgcccccactgatgtttgtgctcctaacatcaccaatgatctctag
|
5
|
+
4 At1g02580 mRNA (2291 bp) UTR's and CDS,At1g02580 mRNA (2291 bp) UTR's and CDS (duplicate) aggcgagtggttaatggagaaggaaaaccatgaggacgatggtgagggtttgccacccgaactaaatcagataaaagagcaaatcgaaaaggagagatttctgcatatcaagagaaaattcgagctgagatacattccaagtgtggctactcatgcttcacaccatcaatcgtttgacttaaaccagcccgctgcagaggatgataatggaggagacaacaaatcacttttgtcgagaatgcaaaacccacttcgtcatttcagtgcctcatctgattataattcttacgaagatcaaggttatgttcttgatgaggatcaagattatgctcttgaagaagatgtaccattatttcttgatgaagatgtaccattattaccaagtgtcaagcttccaattgttgagaagctaccacgatccattacatgggtcttcaccaaaagtagccagctgatggctgaaagtgattctgtgattggtaagagacaaatctattatttgaatggtgaggcactagaattgagcagtgaagaagatgaggaagatgaagaagaagatgaggaagaaatcaagaaagaaaaatgcgaattttctgaagatgtagaccgatttatatggacggttgggcaggactatggtttggatgatctggtcgtgcggcgtgctctcgccaagtacctcgaagtggatgtttcggacatattggaaagatacaatgaactcaagcttaagaatgatggaactgctggtgaggcttctgatttgacatccaagacaataactactgctttccaggattttgctgatagacgtcattgccgtcgttgcatgatattcgattgtcatatgcatgagaagtatgagcccgagtctagatccagcgaagacaaatctagtttgtttgaggatgaagatagacaaccatgcagtgagcattgttacctcaaggtgaggagtgtgacagaagctgatcatgtgatggataatgataactctatatcaaacaagattgtggtctcagatccaaacaacactatgtggacgcctgtagagaaggatctttacttgaaaggaattgagatatttgggagaaacagttgtgatgttgcattaaacatacttcgggggcttaagacgtgcctagagatttacaattacatgcgcgaacaagatcaatgtactatgtcattagaccttaacaaaactacacaaagacacaatcaggttaccaaaaaagtatctcgaaaaagtagtaggtcggtccgcaaaaaatcgagactccgaaaatatgctcgttatccgcctgctttaaagaaaacaactagtggagaagctaagttttataagcactacacaccatgcacttgcaagtcaaaatgtggacagcaatgcccttgtttaactcacgaaaattgctgcgagaaatattgcgggtgctcaaaggattgcaacaatcgctttggaggatgtaattgtgcaattggccaatgcacaaatcgacaatgtccttgttttgctgctaatcgtgaatgcgatccagatctttgtcggagttgtcctcttagctgtggagatggcactcttggtgagacaccagtgcaaatccaatgcaagaacatgcaattcctccttcaaaccaataaaaagattctcattggaaagtctgatgttcatggatggggtgcatttacatgggactctcttaaaaagaatgagtatctcggagaatatactggagaactgatcactcatgatgaagctaatgagcgtgggagaatagaagatcggattggttcttcctacctctttaccttgaatgatcagctcgaaatcgatgctcgccgtaaaggaaacgagttcaaatttctcaatcactcagcaagacctaactgctacgccaagttgatgattgtgagaggagatcagaggattggtctatttgcggagagagcaatcgaagaaggtgaggagcttttcttcgactactgctatggaccagaacatgcggattggtcgcgtggtcgagaacctagaaagactggtgcttctaaaaggtctaaggaagcccgtccagctcgttagtttttgatctgaggagaagcagcaattcaagcagtcctttttttatgttatggtatatcaattaataatgtaatgctattttgtgttactaaaccaaaacttaagtttctgttttatttgttttagggtgttttgtttgtatcatatgtgtcttaactttcaaagttttctttttgtatttcaatttaaaaacaatgtttatgttgtt
|
6
|
+
5 At1g02580 - shortened for test - inserted cutpoint gattgcaacaatcgctttggaggatgtaattgtgcaattggccaatgcacaaatcgacaatgtccttgttttgctgctaatcgtgaatgcgatccagatctttgtcggagttgtcctcttagctgtggagatggcactcttggtgagacaccagtgcaaatccaatgcaagaacatgcaataataaaaagattctcattggaaagtctgatgttcatggattcatggttttaattggggtgcatttacatgggactctcttaaaaagaatgagtatctcggagaatatactggagaactgatcactcatgatgaagctaatgagcgtgggagaatagaagatcggattggttcttcctacctctttaccttgaatgatca
|
@@ -0,0 +1,55 @@
|
|
1
|
+
|
2
|
+
require File.expand_path(
|
3
|
+
File.join(File.dirname(__FILE__), %w[.. .. spec_helper]))
|
4
|
+
|
5
|
+
# --------------------------------------------------------------------------
|
6
|
+
describe Genfrag::App::Command do
|
7
|
+
|
8
|
+
before :all do
|
9
|
+
@out = StringIO.new
|
10
|
+
@err = StringIO.new
|
11
|
+
#@input_dir = File.join(GENFRAG_SPEC_DATA_DIR, 'index_command')
|
12
|
+
#@output_dir = File.join(GENFRAG_SPEC_TMP_DIR, %w[index_command])
|
13
|
+
#FileUtils.mkdir(@output_dir) unless File.directory? @output_dir
|
14
|
+
end
|
15
|
+
|
16
|
+
before :each do
|
17
|
+
@app = Genfrag::App::Command.new(@out, @err)
|
18
|
+
@app.ops = OpenStruct.new({:quiet => true})
|
19
|
+
end
|
20
|
+
|
21
|
+
after :each do
|
22
|
+
@out.clear
|
23
|
+
@err.clear
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'output' do
|
27
|
+
it 'should print in command-line mode and respect quiet' do
|
28
|
+
cli = true
|
29
|
+
@app.ops.quiet = false
|
30
|
+
@app.cli_p(cli, 'hello')
|
31
|
+
@out.readline.should match(%r/hello/)
|
32
|
+
@out.clear
|
33
|
+
|
34
|
+
@app.ops.quiet = true
|
35
|
+
@app.cli_p(cli, 'hello')
|
36
|
+
@out.readline.should be_nil
|
37
|
+
end
|
38
|
+
|
39
|
+
it "shouldn't print in library mode" do
|
40
|
+
cli = false
|
41
|
+
@app.ops.quiet = false
|
42
|
+
@app.cli_p(cli, 'hello')
|
43
|
+
@out.readline.should be_nil
|
44
|
+
@out.clear
|
45
|
+
|
46
|
+
@app.ops.quiet = true
|
47
|
+
@app.cli_p(cli, 'hello')
|
48
|
+
@out.readline.should be_nil
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
# EOF
|
@@ -0,0 +1,258 @@
|
|
1
|
+
|
2
|
+
require File.expand_path(
|
3
|
+
File.join(File.dirname(__FILE__), %w[.. .. spec_helper]))
|
4
|
+
|
5
|
+
# --------------------------------------------------------------------------
|
6
|
+
describe Genfrag::App::IndexCommand do
|
7
|
+
|
8
|
+
before :all do
|
9
|
+
@out = StringIO.new
|
10
|
+
@err = StringIO.new
|
11
|
+
@input_dir = File.join(GENFRAG_SPEC_DATA_DIR, 'index_command', 'in')
|
12
|
+
@frozen_output_dir = File.join(GENFRAG_SPEC_DATA_DIR, 'index_command', 'out')
|
13
|
+
@working_output_dir = File.join(GENFRAG_SPEC_TMP_DIR, %w[index_command])
|
14
|
+
FileUtils.mkdir_p(@working_output_dir) unless File.directory? @working_output_dir
|
15
|
+
end
|
16
|
+
|
17
|
+
before :each do
|
18
|
+
@app = Genfrag::App::IndexCommand.new(@out, @err)
|
19
|
+
end
|
20
|
+
|
21
|
+
after :each do
|
22
|
+
@out.clear
|
23
|
+
@err.clear
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'when used from the command-line' do
|
27
|
+
it 'should provide a help command and exit' do
|
28
|
+
lambda {@app.cli_run %w[--help]}.should raise_error(SystemExit)
|
29
|
+
@out.readline.should match(%r/Usage: genfrag index \[options\]/)
|
30
|
+
@out.clear
|
31
|
+
|
32
|
+
lambda {@app.cli_run %w[--help]}.should raise_error(SystemExit)
|
33
|
+
@out.readline.should match(%r/Usage: genfrag index \[options\]/)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should default to the help message and exit if no command is given' do
|
37
|
+
lambda {@app.cli_run %w[]}.should raise_error(SystemExit)
|
38
|
+
@out.readline.should match(%r/Usage: genfrag index \[options\]/)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should stop on unrecognized options' do
|
42
|
+
lambda {@app.cli_run %w[--bad]}.should raise_error(OptionParser::InvalidOption)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should recognize a fasta file passed as an argument' do
|
46
|
+
pending 'feature'
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should recognize multiple fasta files passed as arguments' do
|
50
|
+
pending 'feature'
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should stop on missing --fasta' do
|
54
|
+
lambda {@app.cli_run %w[-v --re5 BstYI --re3 BstYI]}.should raise_error(SystemExit)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should stop on missing --re5' do
|
58
|
+
lambda {@app.cli_run %w[-v --fasta a --re3 BstYI]}.should raise_error(SystemExit)
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should stop on missing --re3' do
|
62
|
+
lambda {@app.cli_run %w[-v --fasta a --re5 BstYI]}.should raise_error(SystemExit)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should stop when --re3 is passed something it can't recognize" do
|
66
|
+
lambda {@app.cli_run %w[-v --fasta a --re5 BstYI --re3 notanenzyme]}.should raise_error
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should stop when --re5 is passed something it can't recognize" do
|
70
|
+
lambda {@app.cli_run %w[-v --fasta a --re3 BstYI --re5 notanenzyme]}.should raise_error
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe 'command-line option parser' do
|
75
|
+
it 'should stop on unrecognized options' do
|
76
|
+
lambda {@app.parse %w[--bad]}.should raise_error(OptionParser::InvalidOption)
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'should recognize verbose' do
|
80
|
+
@app.parse(%w[--verbose])
|
81
|
+
@app.parse(%w[-v])
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'should recognize tracktime' do
|
85
|
+
@app.parse(%w[--tracktime])
|
86
|
+
@app.parse(%w[-m])
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'should recognize quiet' do
|
90
|
+
@app.parse(%w[--quiet])
|
91
|
+
@app.parse(%w[-q])
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'should recognize re5 with string' do
|
95
|
+
@app.parse(%w[--re5 a])
|
96
|
+
@app.parse(%w[-5 a])
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'should recognize re3 with string' do
|
100
|
+
@app.parse(%w[--re3 a])
|
101
|
+
@app.parse(%w[-3 a])
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'should recognize sqlite' do
|
105
|
+
@app.parse(%w[--sqlite])
|
106
|
+
@app.parse(%w[-t])
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'should recognize lookup with string' do
|
110
|
+
@app.parse(%w[--lookup a])
|
111
|
+
@app.parse(%w[-l a])
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'should recognize fasta with string' do
|
115
|
+
@app.parse(%w[--fasta a])
|
116
|
+
@app.parse(%w[-f a])
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'should recognize a combination of arguments' do
|
120
|
+
@app.parse(%w[-v --re5 a --re3 a])
|
121
|
+
@app.parse(%w[--verbose -5 a -3 a])
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
describe 'with working example,' do
|
126
|
+
|
127
|
+
after :all do
|
128
|
+
#FileUtils.rm Dir.glob(File.join(@working_output_dir,'*'))
|
129
|
+
end
|
130
|
+
|
131
|
+
describe 'a.fasta' do
|
132
|
+
|
133
|
+
before :each do
|
134
|
+
@fasta = 'a.fasta'
|
135
|
+
@app = Genfrag::App::IndexCommand.new(@out, @err)
|
136
|
+
@app.ops.indir = @input_dir
|
137
|
+
@app.ops.outdir = @working_output_dir
|
138
|
+
@app.ops.filefasta = @fasta
|
139
|
+
end
|
140
|
+
|
141
|
+
############################################################
|
142
|
+
describe 'using re5 = BstYI and re3 = MseI' do
|
143
|
+
|
144
|
+
before :each do
|
145
|
+
@app.ops.re5 = 'BstYI'
|
146
|
+
@app.ops.re3 = 'MseI'
|
147
|
+
end
|
148
|
+
|
149
|
+
describe 'without sqlite' do
|
150
|
+
it 'should execute' do
|
151
|
+
@app.ops.filelookup = '1-a_lookup'
|
152
|
+
@app.ops.sqlite = false
|
153
|
+
@app.run
|
154
|
+
end
|
155
|
+
it 'lookup should be the same' do
|
156
|
+
compare('1-a_lookup', '.tdf')
|
157
|
+
end
|
158
|
+
it 'fasta should be the same' do
|
159
|
+
compare(@fasta, '.tdf')
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
describe 'with sqlite' do
|
164
|
+
it 'should execute' do
|
165
|
+
@app.ops.filelookup = '2-a_lookup'
|
166
|
+
@app.ops.sqlite = true
|
167
|
+
@app.run
|
168
|
+
end
|
169
|
+
it 'lookup should be the same' do
|
170
|
+
compare('2-a_lookup', '.db')
|
171
|
+
end
|
172
|
+
it 'fasta should be the same' do
|
173
|
+
compare(@fasta, '.tdf')
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
############################################################
|
179
|
+
describe 'using re5 = MseI and re3 = BstYI' do
|
180
|
+
|
181
|
+
before :each do
|
182
|
+
@app.ops.re5 = 'MseI'
|
183
|
+
@app.ops.re3 = 'BstYI'
|
184
|
+
end
|
185
|
+
|
186
|
+
describe 'without sqlite' do
|
187
|
+
it 'should execute' do
|
188
|
+
@app.ops.filelookup = '3-a_lookup'
|
189
|
+
@app.ops.sqlite = false
|
190
|
+
@app.run
|
191
|
+
end
|
192
|
+
it 'lookup should be the same' do
|
193
|
+
compare('3-a_lookup', '.tdf')
|
194
|
+
end
|
195
|
+
it 'fasta should be the same' do
|
196
|
+
compare(@fasta, '.tdf')
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
describe 'with sqlite' do
|
201
|
+
it 'should execute' do
|
202
|
+
@app.ops.filelookup = '4-a_lookup'
|
203
|
+
@app.ops.sqlite = true
|
204
|
+
@app.run
|
205
|
+
end
|
206
|
+
it 'lookup should be the same' do
|
207
|
+
compare('4-a_lookup', '.db')
|
208
|
+
end
|
209
|
+
it 'fasta should be the same' do
|
210
|
+
compare(@fasta, '.tdf')
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
############################################################
|
216
|
+
describe 'using re5 = TaqI and re3 = AluI' do
|
217
|
+
|
218
|
+
before :each do
|
219
|
+
@app.ops.re5 = 'TaqI'
|
220
|
+
@app.ops.re3 = 'AluI'
|
221
|
+
end
|
222
|
+
|
223
|
+
describe 'without sqlite' do
|
224
|
+
it 'should execute' do
|
225
|
+
@app.ops.filelookup = '5-a_lookup'
|
226
|
+
@app.ops.sqlite = false
|
227
|
+
@app.run
|
228
|
+
end
|
229
|
+
it 'lookup should be the same' do
|
230
|
+
compare('5-a_lookup', '.tdf')
|
231
|
+
end
|
232
|
+
it 'fasta should be the same' do
|
233
|
+
compare(@fasta, '.tdf')
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
describe 'with sqlite' do
|
238
|
+
it 'should execute' do
|
239
|
+
@app.ops.filelookup = '6-a_lookup'
|
240
|
+
@app.ops.sqlite = true
|
241
|
+
@app.run
|
242
|
+
end
|
243
|
+
it 'lookup should be the same' do
|
244
|
+
compare('6-a_lookup', '.db')
|
245
|
+
end
|
246
|
+
it 'fasta should be the same' do
|
247
|
+
compare(@fasta, '.tdf')
|
248
|
+
end
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
end # a.fasta
|
253
|
+
|
254
|
+
end # with working example
|
255
|
+
|
256
|
+
end
|
257
|
+
|
258
|
+
# EOF
|
@@ -0,0 +1,77 @@
|
|
1
|
+
|
2
|
+
require File.expand_path(
|
3
|
+
File.join(File.dirname(__FILE__), %w[.. .. .. spec_helper]))
|
4
|
+
|
5
|
+
# --------------------------------------------------------------------------
|
6
|
+
describe Genfrag::App::SearchCommand do
|
7
|
+
|
8
|
+
before :all do
|
9
|
+
@out = StringIO.new
|
10
|
+
@err = StringIO.new
|
11
|
+
@input_dir = File.join(GENFRAG_SPEC_DATA_DIR, 'index_command', 'out')
|
12
|
+
@frozen_output_dir = File.join(GENFRAG_SPEC_DATA_DIR, 'search_command', 'out')
|
13
|
+
@working_output_dir = File.join(GENFRAG_SPEC_TMP_DIR, %w[search_command])
|
14
|
+
FileUtils.mkdir_p(@working_output_dir) unless File.directory? @working_output_dir
|
15
|
+
end
|
16
|
+
|
17
|
+
before :each do
|
18
|
+
@app = Genfrag::App::SearchCommand.new(@out, @err)
|
19
|
+
end
|
20
|
+
|
21
|
+
after :each do
|
22
|
+
@out.clear
|
23
|
+
@err.clear
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'test matches_adapter' do
|
27
|
+
it 'test' do
|
28
|
+
pending 'tbd'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe 'test find_matching_fragments' do
|
33
|
+
it 'test' do
|
34
|
+
pending 'tbd'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'test right_tail_of' do
|
39
|
+
it 'finds this right-most fragment preceding cut' do
|
40
|
+
# PpiI
|
41
|
+
p = 'n n n n n n^n n n n n n n g a a c n n n n n c t c n n n n n n n n n n n n n^n'
|
42
|
+
@app.right_tail_of(p).should == 'n'
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'finds this right-most fragment preceding cut' do
|
46
|
+
# BstYI
|
47
|
+
p = 'r^g a t c y'
|
48
|
+
@app.right_tail_of(p).should == 'gatcy'
|
49
|
+
end
|
50
|
+
|
51
|
+
it "raises an error when there isn't a cut symbol" do
|
52
|
+
p = 'r g a t c y'
|
53
|
+
lambda {@app.right_tail_of(p)}.should raise_error
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe 'test left_tail_of' do
|
58
|
+
it 'finds this left-most fragment preceding cut' do
|
59
|
+
# PpiI
|
60
|
+
p = 'n n n n n n^n n n n n n n g a a c n n n n n c t c n n n n n n n n n n n n n^n'
|
61
|
+
@app.left_tail_of(p).should == 'nnnnnn'
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'finds this left-most fragment preceding cut' do
|
65
|
+
# BstYI
|
66
|
+
p = 'r^g a t c y'
|
67
|
+
@app.left_tail_of(p).should == 'r'
|
68
|
+
end
|
69
|
+
|
70
|
+
it "raises an error when there isn't a cut symbol" do
|
71
|
+
p = 'r g a t c y'
|
72
|
+
lambda {@app.left_tail_of(p)}.should raise_error
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# EOF
|
@@ -0,0 +1,185 @@
|
|
1
|
+
|
2
|
+
require File.expand_path(
|
3
|
+
File.join(File.dirname(__FILE__), %w[.. .. .. spec_helper]))
|
4
|
+
|
5
|
+
# --------------------------------------------------------------------------
|
6
|
+
describe Genfrag::App::SearchCommand::ProcessFile do
|
7
|
+
|
8
|
+
before :all do
|
9
|
+
@out = StringIO.new
|
10
|
+
@err = StringIO.new
|
11
|
+
@input_dir = File.join(GENFRAG_SPEC_DATA_DIR, 'index_command', 'out')
|
12
|
+
@frozen_output_dir = File.join(GENFRAG_SPEC_DATA_DIR, 'search_command', 'out')
|
13
|
+
@working_output_dir = File.join(GENFRAG_SPEC_TMP_DIR, %w[search_command])
|
14
|
+
FileUtils.mkdir_p(@working_output_dir) unless File.directory? @working_output_dir
|
15
|
+
end
|
16
|
+
|
17
|
+
before :each do
|
18
|
+
@app = Genfrag::App::IndexCommand.new(@out, @err)
|
19
|
+
end
|
20
|
+
|
21
|
+
after :each do
|
22
|
+
@out.clear
|
23
|
+
@err.clear
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'test process_tdf_fasta_file' do
|
27
|
+
|
28
|
+
describe 'with a.fasta.tdf' do
|
29
|
+
before :all do
|
30
|
+
d = IO.readlines File.join(@input_dir, 'a.fasta.tdf')
|
31
|
+
@res = Genfrag::App::SearchCommand::ProcessFile.process_tdf_fasta_file d
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should have five elements' do
|
35
|
+
@res.size.should == 5
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'element 5 definitions' do
|
39
|
+
@res[5][:definitions].should == ["At1g02580 - shortened for test - inserted cutpoint"]
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'element 4 definitions' do
|
43
|
+
@res[4][:definitions].sort.should == ["At1g02580 mRNA (2291 bp) UTR's and CDS", "At1g02580 mRNA (2291 bp) UTR's and CDS (duplicate)"].sort
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'element 5 sequence' do
|
47
|
+
@res[5][:sequence].should == 'gattgcaacaatcgctttggaggatgtaattgtgcaattggccaatgcacaaatcgacaatgtccttgttttgctgctaatcgtgaatgcgatccagatctttgtcggagttgtcctcttagctgtggagatggcactcttggtgagacaccagtgcaaatccaatgcaagaacatgcaataataaaaagattctcattggaaagtctgatgttcatggattcatggttttaattggggtgcatttacatgggactctcttaaaaagaatgagtatctcggagaatatactggagaactgatcactcatgatgaagctaatgagcgtgggagaatagaagatcggattggttcttcctacctctttaccttgaatgatca'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe 'with an array of data' do
|
52
|
+
before :all do
|
53
|
+
ary = [ %w(id Definitions Sequence),
|
54
|
+
[1,'DescA,DescB','seq-abc'],
|
55
|
+
[2,'DescC','seq-def'],
|
56
|
+
[3,'DescD,DescE,DescF','seq-ghi'] ]
|
57
|
+
d = ary.map {|x| x.join("\t")}
|
58
|
+
@res = Genfrag::App::SearchCommand::ProcessFile.process_tdf_fasta_file d
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should have three elements' do
|
62
|
+
@res.size.should == 3
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'element 1 definitions' do
|
66
|
+
@res[1][:definitions].sort.should == ['DescA', 'DescB'].sort
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'element 2 definitions' do
|
70
|
+
@res[2][:definitions].sort.should == ['DescC'].sort
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'element 3 sequence' do
|
74
|
+
@res[3][:sequence].should == 'seq-ghi'
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
describe 'test process_db_fasta_file' do
|
81
|
+
|
82
|
+
describe 'with a.fasta.db' do
|
83
|
+
before :all do
|
84
|
+
d = SQLite3::Database.new( File.join(@input_dir, 'a.fasta.db') )
|
85
|
+
@res = Genfrag::App::SearchCommand::ProcessFile.process_db_fasta_file d
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'should have five elements' do
|
89
|
+
@res.size.should == 5
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'element 5 definitions' do
|
93
|
+
@res[5][:definitions].should == ["At1g02580 - shortened for test - inserted cutpoint"]
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'element 4 definitions' do
|
97
|
+
@res[4][:definitions].sort.should == ["At1g02580 mRNA (2291 bp) UTR's and CDS", "At1g02580 mRNA (2291 bp) UTR's and CDS (duplicate)"].sort
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'element 5 sequence' do
|
101
|
+
@res[5][:sequence].should == 'gattgcaacaatcgctttggaggatgtaattgtgcaattggccaatgcacaaatcgacaatgtccttgttttgctgctaatcgtgaatgcgatccagatctttgtcggagttgtcctcttagctgtggagatggcactcttggtgagacaccagtgcaaatccaatgcaagaacatgcaataataaaaagattctcattggaaagtctgatgttcatggattcatggttttaattggggtgcatttacatgggactctcttaaaaagaatgagtatctcggagaatatactggagaactgatcactcatgatgaagctaatgagcgtgggagaatagaagatcggattggttcttcctacctctttaccttgaatgatca'
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
describe 'test process_tdf_freq_lookup' do
|
109
|
+
describe 'with 1-a_lookup.tdf' do
|
110
|
+
before :all do
|
111
|
+
d = IO.readlines File.join(@input_dir, '1-a_lookup.tdf')
|
112
|
+
@res = Genfrag::App::SearchCommand::ProcessFile.process_tdf_freq_lookup d
|
113
|
+
end
|
114
|
+
|
115
|
+
# { 193=>[{:offset=>457, :raw_size=>193, :fasta_id=>1}],
|
116
|
+
# 138=>[{:offset=>95, :raw_size=>138, :fasta_id=>5}],
|
117
|
+
# 168=>[{:offset=>1539, :raw_size=>168, :fasta_id=>4}]}
|
118
|
+
|
119
|
+
it 'should have three elements' do
|
120
|
+
@res.size.should == 3
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'elements should have an array of hashes with three keys' do
|
124
|
+
@res.each do |k,ary|
|
125
|
+
ary.each do |hsh|
|
126
|
+
hsh.keys.size.should == 3
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'elements key should match :raw_size' do
|
132
|
+
@res.each do |k,ary|
|
133
|
+
ary.each do |hsh|
|
134
|
+
k.should == hsh[:raw_size]
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
describe 'test process_db_freq_lookup' do
|
143
|
+
describe 'with 2-a_lookup.db' do
|
144
|
+
before :all do
|
145
|
+
d = SQLite3::Database.new( File.join(@input_dir, '2-a_lookup.db') )
|
146
|
+
@res = Genfrag::App::SearchCommand::ProcessFile.process_db_freq_lookup d
|
147
|
+
end
|
148
|
+
|
149
|
+
# { 193=>[{:offset=>457, :raw_size=>193, :fasta_id=>1}],
|
150
|
+
# 138=>[{:offset=>95, :raw_size=>138, :fasta_id=>5}],
|
151
|
+
# 168=>[{:offset=>1539, :raw_size=>168, :fasta_id=>4}]}
|
152
|
+
|
153
|
+
it 'should have three elements' do
|
154
|
+
@res.size.should == 3
|
155
|
+
end
|
156
|
+
|
157
|
+
it 'elements should have an array of hashes with three keys' do
|
158
|
+
@res.each do |k,ary|
|
159
|
+
ary.each do |hsh|
|
160
|
+
hsh.keys.size.should == 3
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
it 'elements key should match :raw_size' do
|
166
|
+
@res.each do |k,ary|
|
167
|
+
ary.each do |hsh|
|
168
|
+
k.should == hsh[:raw_size]
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
describe 'test process_tdf_adapters' do
|
177
|
+
it 'test' do
|
178
|
+
pending 'tbd'
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
|
183
|
+
end
|
184
|
+
|
185
|
+
# EOF
|