scbi_fqbin 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gemtest +0 -0
- data/History.txt +11 -0
- data/Manifest.txt +12 -0
- data/PostInstall.txt +7 -0
- data/README.rdoc +79 -0
- data/Rakefile +28 -0
- data/lib/scbi_fqbin/fbin_file.rb +223 -0
- data/lib/scbi_fqbin.rb +8 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/test/test_helper.rb +3 -0
- data/test/test_scbi_fbin_file.rb +158 -0
- metadata +137 -0
data/.gemtest
ADDED
File without changes
|
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/PostInstall.txt
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
= scbi_fqbin
|
2
|
+
|
3
|
+
* http://github.com/dariogf/scbi_fqbin
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
scbi_fqbin is a gem to handle compressed fastq and fasta files (FQbin files) made by Rafael Larrosa, Gonzalo Claros & Dario Guerrero for the Plataforma Andaluza de Bioinformática.
|
8
|
+
|
9
|
+
FastaBin was developed to handle huge fasta and qual files in a more efficient manner. To achieve its goals, FastaBin uses some
|
10
|
+
indexing and compression techniques in order to minimize disk accesses and thus increase the performance when reading fasta and qual files.
|
11
|
+
|
12
|
+
== FEATURES/PROBLEMS:
|
13
|
+
|
14
|
+
|
15
|
+
== SYNOPSIS:
|
16
|
+
|
17
|
+
=== Using command line tools:
|
18
|
+
|
19
|
+
* To generate a FastaBin file:
|
20
|
+
|
21
|
+
mk_fbin fasta qual extras fbin_file
|
22
|
+
|
23
|
+
* To read a random sequence fomr FastaBin file:
|
24
|
+
|
25
|
+
rd_seq_fbin fbin_file seqname
|
26
|
+
|
27
|
+
* To iterate over all sequences in FastaBin file:
|
28
|
+
|
29
|
+
|
30
|
+
=== Using ruby FastaBin gem:
|
31
|
+
|
32
|
+
|
33
|
+
== REQUIREMENTS:
|
34
|
+
|
35
|
+
*libfbin library
|
36
|
+
|
37
|
+
To install libfbin library, download this file http://www.scbi.uma.es/downloads/gems/libfbin.zip:
|
38
|
+
|
39
|
+
then unzip with:
|
40
|
+
|
41
|
+
unzip libfbin.zip
|
42
|
+
|
43
|
+
and install with:
|
44
|
+
|
45
|
+
make
|
46
|
+
|
47
|
+
sudo make install
|
48
|
+
|
49
|
+
By default the library will be installed to /usr/local/lib and binaries (mk_fbin, rd_seq_fbin and iterate_fbin) to /usr/local/bin
|
50
|
+
|
51
|
+
== INSTALL:
|
52
|
+
|
53
|
+
gem install scbi_fqbin
|
54
|
+
|
55
|
+
|
56
|
+
== LICENSE:
|
57
|
+
|
58
|
+
(The MIT License)
|
59
|
+
|
60
|
+
Copyright (c) 2010 Rafael Larrosa, Gonzalo Claros & Dario Guerrero
|
61
|
+
|
62
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
63
|
+
a copy of this software and associated documentation files (the
|
64
|
+
'Software'), to deal in the Software without restriction, including
|
65
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
66
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
67
|
+
permit persons to whom the Software is furnished to do so, subject to
|
68
|
+
the following conditions:
|
69
|
+
|
70
|
+
The above copyright notice and this permission notice shall be
|
71
|
+
included in all copies or substantial portions of the Software.
|
72
|
+
|
73
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
74
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
75
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
76
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
77
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
78
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
79
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
gem 'hoe', '>= 2.1.0'
|
3
|
+
require 'hoe'
|
4
|
+
require 'fileutils'
|
5
|
+
# require './lib/scbi_fqbin'
|
6
|
+
|
7
|
+
Hoe.plugin :newgem
|
8
|
+
Hoe.plugin :website
|
9
|
+
# Hoe.plugin :cucumberfeatures
|
10
|
+
|
11
|
+
# Generate all the Rake tasks
|
12
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
13
|
+
$hoe = Hoe.spec 'scbi_fqbin' do
|
14
|
+
self.developer 'Dario Guerrero', 'dariogf@gmail.com'
|
15
|
+
self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
|
16
|
+
self.rubyforge_name = self.name # TODO this is default value
|
17
|
+
self.extra_deps = [['scbi_fasta','>= 0.0.1']]
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'newgem/tasks'
|
22
|
+
Dir['tasks/**/*.rake'].each { |t| load t; puts t}
|
23
|
+
|
24
|
+
# TODO - want other tests/tasks run by default? Add them to the list
|
25
|
+
|
26
|
+
# remove_task :default
|
27
|
+
task :default => [:build, :install,:spec, :features]
|
28
|
+
|
@@ -0,0 +1,223 @@
|
|
1
|
+
require 'ffi'
|
2
|
+
|
3
|
+
class FFIString<FFI::MemoryPointer
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
super(:pointer,1)
|
7
|
+
# self.write_string('a')
|
8
|
+
# return FFI::MemoryPointer.from_string('a'*150000000)
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_s
|
12
|
+
resPtr = self.read_pointer()
|
13
|
+
|
14
|
+
#if null, return nil, if not return string
|
15
|
+
return resPtr.null? ? nil : resPtr.read_string()
|
16
|
+
end
|
17
|
+
|
18
|
+
def inspect
|
19
|
+
self.to_s
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
class FbinFile
|
25
|
+
|
26
|
+
CREATE_NEW_FILE=1
|
27
|
+
APPEND_TO_FILE=2
|
28
|
+
extend FFI::Library
|
29
|
+
|
30
|
+
ffi_lib(["libfbin"])
|
31
|
+
|
32
|
+
functions = [
|
33
|
+
|
34
|
+
[:read_seq, [:string,:string,:pointer,:pointer,:pointer],:int],
|
35
|
+
[:read_data_sequential, [:pointer,:pointer,:pointer,:pointer,:pointer],:int],
|
36
|
+
[:initialize_sequential_reads,[:pointer, :string],:int],
|
37
|
+
[:close_sequential_reads,[:pointer],:int],
|
38
|
+
[:write_seq,[:pointer, :string, :string, :string, :string],:int],
|
39
|
+
[:close_writes,[:pointer],:int],
|
40
|
+
[:initialize_writes,[:pointer, :string, :int, :int, :int, :int],:int],
|
41
|
+
[:inspect_file_data_struct,[:pointer],:void],
|
42
|
+
[:free_string,[:pointer],:int]
|
43
|
+
|
44
|
+
|
45
|
+
]
|
46
|
+
|
47
|
+
functions.each do |func|
|
48
|
+
begin
|
49
|
+
attach_function(*func)
|
50
|
+
private func[0]
|
51
|
+
rescue Object => e
|
52
|
+
puts "Could not attach #{func}, #{e.message}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
# Initializes the file
|
58
|
+
def initialize(file_path, mode = 'r', qual_to_phred=true, qual_to_array=true, discretize_qual=0, flatten_qual=0, create_index=1)
|
59
|
+
@file_path = file_path
|
60
|
+
@open_mode=mode
|
61
|
+
|
62
|
+
@qual_to_phred = qual_to_phred
|
63
|
+
@qual_to_array = qual_to_array
|
64
|
+
|
65
|
+
@to_phred = lambda{|q| q - 33}
|
66
|
+
|
67
|
+
if @open_mode.index('r')
|
68
|
+
@gzf_bin = FFI::MemoryPointer.new :pointer
|
69
|
+
initialize_sequential_reads(@gzf_bin,@file_path)
|
70
|
+
# inspect_file_data_struct(@gzf_bin)
|
71
|
+
@gzf_bin = @gzf_bin.get_pointer(0)
|
72
|
+
|
73
|
+
elsif @open_mode.index('w')
|
74
|
+
@write_struct = FFI::MemoryPointer.new :pointer
|
75
|
+
initialize_writes(@write_struct,@file_path, CREATE_NEW_FILE,discretize_qual, flatten_qual, create_index)
|
76
|
+
@write_struct = @write_struct.get_pointer(0)
|
77
|
+
# inspect_file_data_struct(@write_struct)
|
78
|
+
|
79
|
+
elsif @open_mode.index('a')
|
80
|
+
|
81
|
+
@write_struct = FFI::MemoryPointer.new :pointer
|
82
|
+
initialize_writes(@write_struct,@file_path, APPEND_TO_FILE,discretize_qual, flatten_qual, create_index)
|
83
|
+
@write_struct = @write_struct.get_pointer(0)
|
84
|
+
# inspect_file_data_struct(@write_struct)
|
85
|
+
|
86
|
+
else
|
87
|
+
raise "Invalid aperture mode #{mode}. Use r/w"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# Access a sequence by its name using the indexed read
|
92
|
+
def read_sequence(seq_name)
|
93
|
+
|
94
|
+
fastaPtr = FFIString.new
|
95
|
+
qualPtr = FFIString.new
|
96
|
+
extrasPtr = FFIString.new
|
97
|
+
|
98
|
+
if read_seq(@file_path,seq_name,fastaPtr,qualPtr,extrasPtr)==0
|
99
|
+
|
100
|
+
qual=qualPtr.to_s
|
101
|
+
|
102
|
+
if @qual_to_phred
|
103
|
+
qual=qual.each_char.map{|e| (@to_phred.call(e.ord))}
|
104
|
+
if !@qual_to_array
|
105
|
+
qual=qual.join(' ')
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
fasta=fastaPtr.to_s
|
110
|
+
extras = extrasPtr.to_s
|
111
|
+
|
112
|
+
free_string(qualPtr)
|
113
|
+
free_string(fastaPtr)
|
114
|
+
free_string(extrasPtr)
|
115
|
+
|
116
|
+
return seq_name, fasta, qual, extras
|
117
|
+
|
118
|
+
else
|
119
|
+
|
120
|
+
free_string(qualPtr)
|
121
|
+
free_string(fastaPtr)
|
122
|
+
free_string(extrasPtr)
|
123
|
+
|
124
|
+
return nil
|
125
|
+
# raise "Invalid sequence"
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
# Returns the next sequence in file, or nil if no more ara available
|
130
|
+
def next_sequence
|
131
|
+
return get_next_seq(@gzf_bin)
|
132
|
+
end
|
133
|
+
|
134
|
+
def get_next_seq(gzf_bin)
|
135
|
+
seq_namePtr = FFIString.new
|
136
|
+
fastaPtr = FFIString.new
|
137
|
+
qualPtr = FFIString.new
|
138
|
+
extrasPtr = FFIString.new
|
139
|
+
|
140
|
+
if ((r=read_data_sequential(gzf_bin, seq_namePtr, fastaPtr, qualPtr, extrasPtr))==0)
|
141
|
+
|
142
|
+
qual=qualPtr.to_s
|
143
|
+
if @qual_to_phred
|
144
|
+
qual=qual.each_char.map{|e| (@to_phred.call(e.ord))}
|
145
|
+
|
146
|
+
if !@qual_to_array
|
147
|
+
qual=qual.join(' ')
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
seq_name=seq_namePtr.to_s
|
152
|
+
fasta=fastaPtr.to_s
|
153
|
+
extras=extrasPtr.to_s
|
154
|
+
|
155
|
+
# seq_namePtr.free
|
156
|
+
# fastaPtr.free
|
157
|
+
# qualPtr.free
|
158
|
+
# extrasPtr.free
|
159
|
+
|
160
|
+
free_string(seq_namePtr)
|
161
|
+
free_string(fastaPtr)
|
162
|
+
free_string(qualPtr)
|
163
|
+
free_string(extrasPtr)
|
164
|
+
|
165
|
+
return seq_name, fasta, qual, extras
|
166
|
+
|
167
|
+
else
|
168
|
+
free_string(seq_namePtr)
|
169
|
+
free_string(fastaPtr)
|
170
|
+
free_string(qualPtr)
|
171
|
+
free_string(extrasPtr)
|
172
|
+
return nil
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
# Iterates over all sequences in file
|
177
|
+
def each
|
178
|
+
|
179
|
+
gzf_bin = FFI::MemoryPointer.new :pointer
|
180
|
+
initialize_sequential_reads(gzf_bin,@file_path)
|
181
|
+
gzf_bin = gzf_bin.get_pointer(0)
|
182
|
+
|
183
|
+
while seq=get_next_seq(gzf_bin)
|
184
|
+
yield seq
|
185
|
+
end
|
186
|
+
|
187
|
+
close_sequential_reads(gzf_bin)
|
188
|
+
end
|
189
|
+
|
190
|
+
# Writes a sequence to file
|
191
|
+
def write_sequence(seq_name,fasta,qual,extras)
|
192
|
+
|
193
|
+
if qual.is_a?(Array)
|
194
|
+
qual=qual.join(' ')
|
195
|
+
end
|
196
|
+
|
197
|
+
write_seq(@write_struct,seq_name,fasta,qual,extras)
|
198
|
+
end
|
199
|
+
|
200
|
+
|
201
|
+
# Closes file
|
202
|
+
def close
|
203
|
+
|
204
|
+
if @open_mode.index('r')
|
205
|
+
close_sequential_reads(@gzf_bin)
|
206
|
+
else # CREATE_NEW_FILE or APPEND_TO_FILE
|
207
|
+
# inspect_write_struct(@write_struct)
|
208
|
+
close_writes(@write_struct)
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
212
|
+
|
213
|
+
# Returns the number of sequences in file. Iterating over it
|
214
|
+
def count
|
215
|
+
res=0
|
216
|
+
each do #|n,f,q,e|
|
217
|
+
# puts n
|
218
|
+
res+=1
|
219
|
+
end
|
220
|
+
return res
|
221
|
+
end
|
222
|
+
|
223
|
+
end
|
data/lib/scbi_fqbin.rb
ADDED
data/script/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: script/console
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
+
|
5
|
+
libs = " -r irb/completion"
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/scbi_fqbin.rb'}"
|
9
|
+
puts "Loading scbi_fqbin gem"
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
# Ojo si va muy lento cuando se incrementa el numero de secuencias porque resulta que las longitudes de la secuencia va aumentando con cada número
|
4
|
+
|
5
|
+
class TestScbiFbinFile < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
#File.delete(TEST_FILE)
|
9
|
+
end
|
10
|
+
|
11
|
+
TEST_FILE='/tmp/fbinfile';
|
12
|
+
|
13
|
+
SEQ_FASTA='ACTG'
|
14
|
+
SEQ_FASTA400=SEQ_FASTA*100
|
15
|
+
SEQ_QUAL='B'
|
16
|
+
SEQ_QUAL400=(SEQ_QUAL*400*SEQ_FASTA.length)
|
17
|
+
PHRED_QUAL=[33]
|
18
|
+
SEQ_NAME='SEQ'
|
19
|
+
SEQ_EXTRAS='SOME EXTRAS IN SEQ'
|
20
|
+
|
21
|
+
PROGRESS=100
|
22
|
+
|
23
|
+
def this_method
|
24
|
+
caller[0] =~ /`([^']*)'/ and $1
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_seq(i)
|
28
|
+
# i=25
|
29
|
+
return SEQ_FASTA*i
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_qual(i)
|
33
|
+
# i=25
|
34
|
+
return (SEQ_QUAL*i*SEQ_FASTA.length)#.join(' ')
|
35
|
+
end
|
36
|
+
|
37
|
+
def fill_file(n)
|
38
|
+
fb=FbinFile.new(TEST_FILE,'w',false)
|
39
|
+
n.times do |c|
|
40
|
+
i = c+1
|
41
|
+
if (i%PROGRESS)==0
|
42
|
+
puts "#{this_method}: #{i}"
|
43
|
+
end
|
44
|
+
|
45
|
+
fb.write_sequence(SEQ_NAME+i.to_s,get_seq(i),get_qual(i),SEQ_EXTRAS)
|
46
|
+
#fb.write_sequence(SEQ_NAME+i.to_s,SEQ_FASTA400,SEQ_QUAL400,SEQ_EXTRAS)
|
47
|
+
end
|
48
|
+
puts "END #{this_method}"
|
49
|
+
fb.close
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_new
|
53
|
+
|
54
|
+
if File.exists?(TEST_FILE)
|
55
|
+
File.delete(TEST_FILE)
|
56
|
+
end
|
57
|
+
|
58
|
+
fb=FbinFile.new(TEST_FILE,'w',false)
|
59
|
+
# fb.write_sequence('hola','actg','50 50 50 50','extras')
|
60
|
+
fb.close
|
61
|
+
|
62
|
+
assert(File.exists?(TEST_FILE))
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_add100
|
66
|
+
num_seqs=100
|
67
|
+
# make new file and fill with data
|
68
|
+
fill_file(num_seqs)
|
69
|
+
|
70
|
+
fb=FbinFile.new(TEST_FILE,'r',false)
|
71
|
+
|
72
|
+
assert_equal(num_seqs,fb.count)
|
73
|
+
fb.close
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_read_random
|
78
|
+
num_seqs=100 #100
|
79
|
+
# make new file and fill with data
|
80
|
+
fill_file(100)
|
81
|
+
|
82
|
+
|
83
|
+
fb=FbinFile.new(TEST_FILE,'r',false)
|
84
|
+
|
85
|
+
num_seqs.times do |c|
|
86
|
+
i = c+1
|
87
|
+
n,s,q,e=fb.read_sequence(SEQ_NAME+i.to_s)
|
88
|
+
# puts n,s,q,s.length,q.length,'_______'
|
89
|
+
assert_equal(SEQ_NAME+i.to_s,n)
|
90
|
+
assert_equal(get_seq(i),s)
|
91
|
+
assert_equal(get_qual(i), q)
|
92
|
+
assert_equal(SEQ_EXTRAS , e)
|
93
|
+
# gets
|
94
|
+
end
|
95
|
+
|
96
|
+
fb.close
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_read_no_exists
|
100
|
+
|
101
|
+
fill_file(100)
|
102
|
+
|
103
|
+
fb=FbinFile.new(TEST_FILE,'r',false)
|
104
|
+
n,s,q=fb.read_sequence(SEQ_NAME+'NO_EXIST')
|
105
|
+
puts "H:#{n}"
|
106
|
+
assert(n.nil?)
|
107
|
+
fb.close
|
108
|
+
end
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
def test_each
|
113
|
+
fill_file(100)
|
114
|
+
|
115
|
+
i = 1
|
116
|
+
fb=FbinFile.new(TEST_FILE,'r',false)
|
117
|
+
|
118
|
+
fb.each do |n,s,q,e|
|
119
|
+
assert_equal(SEQ_NAME+i.to_s,n)
|
120
|
+
assert_equal(get_seq(i),s)
|
121
|
+
assert_equal(get_qual(i),q)
|
122
|
+
assert_equal(SEQ_EXTRAS,e)
|
123
|
+
|
124
|
+
i+=1
|
125
|
+
end
|
126
|
+
|
127
|
+
assert_equal(i,101)
|
128
|
+
|
129
|
+
fb.close
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_each_by_index
|
134
|
+
num_seqs=100
|
135
|
+
|
136
|
+
fill_file(num_seqs)
|
137
|
+
|
138
|
+
i = 1
|
139
|
+
|
140
|
+
fb=FbinFile.new(TEST_FILE,'r',false)
|
141
|
+
|
142
|
+
fb.each do |n,f,q,e|
|
143
|
+
if (i%PROGRESS)==0
|
144
|
+
puts "#{this_method}: #{i}"
|
145
|
+
end
|
146
|
+
assert_equal(SEQ_NAME+i.to_s,n)
|
147
|
+
assert_equal(get_seq(i),f)
|
148
|
+
assert_equal(get_qual(i),q)
|
149
|
+
assert_equal(SEQ_EXTRAS,e)
|
150
|
+
i+=1
|
151
|
+
end
|
152
|
+
|
153
|
+
assert_equal(i,num_seqs+1)
|
154
|
+
fb.close
|
155
|
+
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
metadata
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: scbi_fqbin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Dario Guerrero
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-09 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: scbi_fasta
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.0.1
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.0.1
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rdoc
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '4.0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '4.0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: newgem
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.5.3
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.5.3
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: hoe
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.6'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '3.6'
|
78
|
+
description: ! "scbi_fqbin is a gem to handle compressed fastq and fasta files (FQbin
|
79
|
+
files) made by Rafael Larrosa, Gonzalo Claros & Dario Guerrero for the Plataforma
|
80
|
+
Andaluza de Bioinformática.\n\nFastaBin was developed to handle huge fasta and qual
|
81
|
+
files in a more efficient manner. To achieve its goals, FastaBin uses some \nindexing
|
82
|
+
and compression techniques in order to minimize disk accesses and thus increase
|
83
|
+
the performance when reading fasta and qual files."
|
84
|
+
email:
|
85
|
+
- dariogf@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files:
|
89
|
+
- History.txt
|
90
|
+
- Manifest.txt
|
91
|
+
- PostInstall.txt
|
92
|
+
- README.rdoc
|
93
|
+
files:
|
94
|
+
- History.txt
|
95
|
+
- Manifest.txt
|
96
|
+
- PostInstall.txt
|
97
|
+
- README.rdoc
|
98
|
+
- Rakefile
|
99
|
+
- script/console
|
100
|
+
- script/destroy
|
101
|
+
- script/generate
|
102
|
+
- lib/scbi_fqbin/fbin_file.rb
|
103
|
+
- lib/scbi_fqbin.rb
|
104
|
+
- test/test_helper.rb
|
105
|
+
- test/test_scbi_fbin_file.rb
|
106
|
+
- .gemtest
|
107
|
+
homepage: http://github.com/dariogf/scbi_fqbin
|
108
|
+
licenses: []
|
109
|
+
post_install_message: PostInstall.txt
|
110
|
+
rdoc_options:
|
111
|
+
- --main
|
112
|
+
- README.rdoc
|
113
|
+
require_paths:
|
114
|
+
- lib
|
115
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
117
|
+
requirements:
|
118
|
+
- - ! '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
none: false
|
123
|
+
requirements:
|
124
|
+
- - ! '>='
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
requirements: []
|
128
|
+
rubyforge_project: scbi_fqbin
|
129
|
+
rubygems_version: 1.8.24
|
130
|
+
signing_key:
|
131
|
+
specification_version: 3
|
132
|
+
summary: scbi_fqbin is a gem to handle compressed fastq and fasta files (FQbin files)
|
133
|
+
made by Rafael Larrosa, Gonzalo Claros & Dario Guerrero for the Plataforma Andaluza
|
134
|
+
de Bioinformática
|
135
|
+
test_files:
|
136
|
+
- test/test_helper.rb
|
137
|
+
- test/test_scbi_fbin_file.rb
|