scbi_fastq 0.0.16 → 0.0.17
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/History.txt +4 -0
- data/README.rdoc +19 -1
- data/lib/scbi_fastq.rb +1 -1
- data/lib/scbi_fastq/fastq_file.rb +12 -5
- data/test/test_scbi_fastq.rb +22 -1
- metadata +2 -2
data/History.txt
CHANGED
data/README.rdoc
CHANGED
@@ -13,10 +13,28 @@ scbi_fastq is a ruby gem to read/write FASTQ files (DNA/RNA sequences) with qual
|
|
13
13
|
* Quality values can be automatically splitted
|
14
14
|
* Write FASTQ files in Sanger format
|
15
15
|
* Iteration over large files without extra memory usage
|
16
|
-
|
16
|
+
* Can read gzip files directly
|
17
17
|
|
18
18
|
== SYNOPSIS:
|
19
19
|
|
20
|
+
=== Reading a compressed FASTQ in gzip with iterator:
|
21
|
+
|
22
|
+
require 'scbi_fastq'
|
23
|
+
|
24
|
+
# open gzip file in sanger mode
|
25
|
+
fqr=FastqFile.new('file1.fastq.gz')
|
26
|
+
|
27
|
+
fqr.each do |name,seq_fasta,qual,comments|
|
28
|
+
|
29
|
+
puts name
|
30
|
+
puts seq_fasta
|
31
|
+
puts qual
|
32
|
+
puts comments
|
33
|
+
end
|
34
|
+
|
35
|
+
fqr.close
|
36
|
+
|
37
|
+
|
20
38
|
=== Reading a FASTQ with iterator:
|
21
39
|
|
22
40
|
require 'scbi_fastq'
|
data/lib/scbi_fastq.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'zlib'
|
1
2
|
|
2
3
|
# add ord method to ruby 1.8
|
3
4
|
if !String.instance_methods.include?(:ord)
|
@@ -30,7 +31,7 @@ class FastqFile
|
|
30
31
|
end
|
31
32
|
|
32
33
|
@fastq_file = File.open(fasta_file_name,'a')
|
33
|
-
else #read only
|
34
|
+
else #read only
|
34
35
|
if !File.exist?(fasta_file_name)
|
35
36
|
raise "File #{fasta_file_name} doesn't exists"
|
36
37
|
end
|
@@ -38,7 +39,14 @@ class FastqFile
|
|
38
39
|
if fasta_file_name.is_a?(IO)
|
39
40
|
@fastq_file = fasta_file_name
|
40
41
|
else
|
41
|
-
|
42
|
+
begin
|
43
|
+
@fastq_file = Zlib::GzipReader.open(fasta_file_name)
|
44
|
+
# puts "GZIP file detected"
|
45
|
+
rescue
|
46
|
+
@fastq_file = File.open(fasta_file_name,'r')
|
47
|
+
# puts "NORMAL file detected"
|
48
|
+
end
|
49
|
+
|
42
50
|
end
|
43
51
|
end
|
44
52
|
|
@@ -127,10 +135,9 @@ class FastqFile
|
|
127
135
|
|
128
136
|
# goto first position in file
|
129
137
|
def rewind
|
130
|
-
|
131
138
|
@num_seqs = 0 ;
|
132
|
-
@fastq_file.pos=0
|
133
|
-
|
139
|
+
# @fastq_file.pos=0
|
140
|
+
@fastq_file.rewind
|
134
141
|
end
|
135
142
|
|
136
143
|
#------------------------------------
|
data/test/test_scbi_fastq.rb
CHANGED
@@ -4,12 +4,33 @@ class TestScbiFastq < Test::Unit::TestCase
|
|
4
4
|
|
5
5
|
def setup
|
6
6
|
@test_file='/tmp/sanger.fastq';
|
7
|
+
|
7
8
|
|
8
9
|
@seq_fasta='ACTG'
|
9
10
|
@seq_qual=[31]
|
10
11
|
@seq_name='SEQ'
|
11
12
|
|
12
13
|
end
|
14
|
+
|
15
|
+
def test_gz_sanger
|
16
|
+
|
17
|
+
fqr=FastqFile.new(File.join(File.dirname(__FILE__),'sanger2.fastq.gz'))
|
18
|
+
|
19
|
+
i=1
|
20
|
+
|
21
|
+
fqr.each do |n,s,q|
|
22
|
+
|
23
|
+
assert_equal(@seq_name+i.to_s,n)
|
24
|
+
assert_equal(@seq_fasta*i,s)
|
25
|
+
assert_equal((@seq_qual*i*@seq_fasta.length),q)
|
26
|
+
|
27
|
+
i+=1
|
28
|
+
end
|
29
|
+
|
30
|
+
fqr.close
|
31
|
+
|
32
|
+
|
33
|
+
end
|
13
34
|
|
14
35
|
|
15
36
|
def fill_file(n,offset=33)
|
@@ -134,7 +155,7 @@ class TestScbiFastq < Test::Unit::TestCase
|
|
134
155
|
i=1
|
135
156
|
|
136
157
|
fqr.each do |n,s,q|
|
137
|
-
puts n,s,q
|
158
|
+
# puts n,s,q
|
138
159
|
assert_equal(@seq_name+i.to_s,n)
|
139
160
|
assert_equal(@seq_fasta*i,s)
|
140
161
|
# assert_equal((@seq_qual*i*@seq_fasta.length),q)
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: scbi_fastq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.17
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Dario Guerrero
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-07-13 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: hoe
|