scbi_zcat 0.0.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.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +9 -0
- data/lib/scbi_zcat/scbi_zcat_file.rb +51 -0
- data/lib/scbi_zcat/version.rb +3 -0
- data/lib/scbi_zcat.rb +6 -0
- data/scbi_zcat.gemspec +23 -0
- data/test/minitest.fastq +28 -0
- data/test/minitest.fastq.gz +0 -0
- data/test/scbi_zcat_test.rb +82 -0
- data/test/test_helper.rb +3 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7f0f075ece84bd24a7987b664873af612267364e
|
4
|
+
data.tar.gz: 67fbf0861aef9764e20e9f540fbb2f304bdf40e9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1a90a7036bed5624776dab935c5d06d0c8efef59370fdeff3f709085084639e717486ea61212a7b93faac34b81b3a7ac895cde78c9128c459680eebfbfbfeb5e
|
7
|
+
data.tar.gz: 2131a6cb362f9538ef911f1b09e1a5d06449ebb4146e4cabb5eadf26d1a231a23b30b1fa26b17a4576562f928c2ff875e314bb7d155d02f1b6a86e26b05f05e7
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 dariogf
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# ScbiZcat
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'scbi_zcat'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install scbi_zcat
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/scbi_zcat/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
|
2
|
+
class ScbiZcatFile
|
3
|
+
|
4
|
+
def self.gz_file?(file_name)
|
5
|
+
res=`file "#{File.expand_path(file_name)}"`
|
6
|
+
|
7
|
+
return !res.index('gzip').nil?
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(file_name)
|
11
|
+
@file_name=file_name
|
12
|
+
open_file
|
13
|
+
end
|
14
|
+
|
15
|
+
def open_file
|
16
|
+
cmd="zcat \"#{File.expand_path(@file_name)}\""
|
17
|
+
#puts "OPEN: #{cmd}"
|
18
|
+
@file = IO.popen(cmd)
|
19
|
+
#@file.close_write
|
20
|
+
@eof=false
|
21
|
+
end
|
22
|
+
|
23
|
+
def readline
|
24
|
+
begin
|
25
|
+
res = @file.readline
|
26
|
+
rescue IOError
|
27
|
+
close
|
28
|
+
end
|
29
|
+
|
30
|
+
return res
|
31
|
+
end
|
32
|
+
|
33
|
+
def eof?
|
34
|
+
@file.eof?
|
35
|
+
end
|
36
|
+
|
37
|
+
def eof
|
38
|
+
eof?
|
39
|
+
end
|
40
|
+
|
41
|
+
def close
|
42
|
+
#@io.finish
|
43
|
+
@file.close if !@file.closed?
|
44
|
+
end
|
45
|
+
|
46
|
+
def rewind
|
47
|
+
close
|
48
|
+
open_file
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
data/lib/scbi_zcat.rb
ADDED
data/scbi_zcat.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'scbi_zcat/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "scbi_zcat"
|
8
|
+
spec.version = ScbiZcat::VERSION
|
9
|
+
spec.authors = ["dariogf"]
|
10
|
+
spec.email = ["dariogf@gmail.com"]
|
11
|
+
spec.summary = %q{Read files with readline from a zcat pipe of a gz file}
|
12
|
+
spec.description = %q{Read files from a zcat pipe of a gz file. Useful to read multiple gz streams that are stored on the same file}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
end
|
data/test/minitest.fastq
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
@SEQ1 comments
|
2
|
+
ACTG
|
3
|
+
+SEQ1 comments
|
4
|
+
@@@@
|
5
|
+
@SEQ2 comments
|
6
|
+
ACTGACTG
|
7
|
+
+SEQ2 comments
|
8
|
+
@@@@@@@@
|
9
|
+
@SEQ3 comments
|
10
|
+
ACTGACTGACTG
|
11
|
+
+SEQ98 comments
|
12
|
+
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
13
|
+
@SEQ99 comments
|
14
|
+
ACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTG
|
15
|
+
+SEQ99 comments
|
16
|
+
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
17
|
+
@SEQ100 comments
|
18
|
+
ACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTGACTG
|
19
|
+
+SEQ100 comments
|
20
|
+
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
21
|
+
@F1
|
22
|
+
acactgcagtactcata
|
23
|
+
+
|
24
|
+
#################
|
25
|
+
@F2
|
26
|
+
acactgcagtactcata
|
27
|
+
+
|
28
|
+
#################
|
Binary file
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class ScbiMultiGzReaderTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_zcat
|
10
|
+
|
11
|
+
# test a file with multiple gz streams
|
12
|
+
|
13
|
+
#file=ScbiZcatFile.new('/tmp/pair2.fastq.gz')
|
14
|
+
file=ScbiZcatFile.new(File.join(File.dirname(__FILE__),'minitest.fastq.gz'))
|
15
|
+
|
16
|
+
i=0
|
17
|
+
printing=0
|
18
|
+
|
19
|
+
loop do
|
20
|
+
res=file.readline
|
21
|
+
|
22
|
+
break if res.nil?
|
23
|
+
# #puts res
|
24
|
+
# if res.index('M00707:28:000000000-AFRC1:1:1102:16433:15968')
|
25
|
+
# printing=10
|
26
|
+
# end
|
27
|
+
# if printing>0
|
28
|
+
# puts res
|
29
|
+
# #sleep 2
|
30
|
+
# printing-=1
|
31
|
+
# end
|
32
|
+
|
33
|
+
|
34
|
+
i = i+1
|
35
|
+
end
|
36
|
+
|
37
|
+
file.close
|
38
|
+
|
39
|
+
#assert_equal(2813668,i)
|
40
|
+
assert_equal(28,i)
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_zcat_while
|
45
|
+
|
46
|
+
# test a file with multiple gz streams
|
47
|
+
|
48
|
+
#file=ScbiZcatFile.new('/tmp/pair2.fastq.gz')
|
49
|
+
file=ScbiZcatFile.new(File.join(File.dirname(__FILE__),'minitest.fastq.gz'))
|
50
|
+
|
51
|
+
i=0
|
52
|
+
printing=0
|
53
|
+
|
54
|
+
begin
|
55
|
+
res=file.readline
|
56
|
+
|
57
|
+
assert_equal(false,res.nil?)
|
58
|
+
|
59
|
+
i = i+1
|
60
|
+
end while !file.eof?
|
61
|
+
|
62
|
+
file.close
|
63
|
+
|
64
|
+
#assert_equal(2813668,i)
|
65
|
+
assert_equal(28,i)
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_gz_file?
|
70
|
+
|
71
|
+
# test a file with multiple gz streams
|
72
|
+
|
73
|
+
res=ScbiZcatFile.gz_file?(File.join(File.dirname(__FILE__),'minitest.fastq.gz'))
|
74
|
+
assert_equal(true,res)
|
75
|
+
|
76
|
+
res=ScbiZcatFile.gz_file?(File.join(File.dirname(__FILE__),'minitest.fastq'))
|
77
|
+
assert_equal(false,res)
|
78
|
+
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: scbi_zcat
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- dariogf
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Read files from a zcat pipe of a gz file. Useful to read multiple gz
|
42
|
+
streams that are stored on the same file
|
43
|
+
email:
|
44
|
+
- dariogf@gmail.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- lib/scbi_zcat.rb
|
55
|
+
- lib/scbi_zcat/scbi_zcat_file.rb
|
56
|
+
- lib/scbi_zcat/version.rb
|
57
|
+
- scbi_zcat.gemspec
|
58
|
+
- test/minitest.fastq
|
59
|
+
- test/minitest.fastq.gz
|
60
|
+
- test/scbi_zcat_test.rb
|
61
|
+
- test/test_helper.rb
|
62
|
+
homepage: ''
|
63
|
+
licenses:
|
64
|
+
- MIT
|
65
|
+
metadata: {}
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 2.4.4
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
85
|
+
summary: Read files with readline from a zcat pipe of a gz file
|
86
|
+
test_files:
|
87
|
+
- test/minitest.fastq
|
88
|
+
- test/minitest.fastq.gz
|
89
|
+
- test/scbi_zcat_test.rb
|
90
|
+
- test/test_helper.rb
|