seqtkrb 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0f088f76ffd7699ab981e2c8a13a92681f80cb57
4
+ data.tar.gz: 8d67ca12680ce5274c0157fdf8c4dd09ec475ffa
5
+ SHA512:
6
+ metadata.gz: 223535cfe07ba02d7e307a2fa3b623afad630a63958a21bc9f3a3d43d17a759881be47c9bc25b11074960f61adcd8dde0c4a18f685367e269fa9f481ce91510b
7
+ data.tar.gz: b6f48d258777f30efd09403b6d048fea07d05dfba20a36ffe24728926056f486b6d68c96e2aa2f877860f04365bcb56eb78de7492e7fcc18f758a0ea613f8726
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in seqtkrb.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Richard Smith-Unna
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,52 @@
1
+ # seqtkrb [![Build Status](https://img.shields.io/travis/Blahah/seqtkrb.svg)](https://travis-ci.org/Blahah/seqtkrb) [![Coverage Status](https://img.shields.io/coveralls/jekyll/jekyll.svg)](https://coveralls.io/r/Blahah/seqtkrb?branch=master)
2
+
3
+ seqtkrb is a ruby gem that wraps [seqtk](). This gives you fast access to basic operations on FASTA/FASTQ files without having to roll your own C extension or write a slow implementation in ruby.
4
+
5
+ Currently only the sampling functionality of seqtk is exposed. Create an issue or a Pull Request if you want more functionality.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'seqtkrb'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ ```
18
+ $ bundle
19
+ ```
20
+
21
+ Or install it yourself as:
22
+
23
+ ```
24
+ $ gem install seqtkrb
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ ```ruby
30
+ require 'seqtkrb'
31
+
32
+ seq = Seqtkrb::Seqtk.new # will download and install seqtk if it is not found
33
+
34
+ # basic sampling
35
+ seq.sample('reads.fq', 'sampled.fq' 10_000) # sample 10,000 reads
36
+ seq.sample('reads.fq', 'sampled.fq' 0.5) # sample reads with 50% chance of taking each read
37
+
38
+ # sampling from paired files
39
+ seq.sample('reads_l.fq', 'sampled_l.fq', 1_000, 1234) # sample 1,000 left reads with seed 1234
40
+ seq.sample('reads_r.fq', 'sampled_r.fq', 1_000, 1234) # sample the matching right reads
41
+
42
+ # low memory sampling (uses two passes)
43
+ seq.sample_lowmem('reads.fq', 'sampled.fq', 1_000_000) # sample 1 million reads
44
+ ```
45
+
46
+ ## Contributing
47
+
48
+ 1. Fork it ( https://github.com/[my-github-username]/seqtkrb/fork )
49
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
50
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
51
+ 4. Push to the branch (`git push origin my-new-feature`)
52
+ 5. Create a new Pull Request
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << 'test'
6
+ end
7
+
8
+ desc "Run tests"
9
+ task :default => :test
@@ -0,0 +1,10 @@
1
+ seqtk:
2
+ binaries:
3
+ - seqtk
4
+ version:
5
+ number: 1.0-r82
6
+ command: seqtk
7
+ url:
8
+ 64bit:
9
+ macosx: https://github.com/Blahah/seqtk/releases/download/1.0-r82/seqtk_1.0_osx.tar.gz
10
+ linux: https://github.com/Blahah/seqtk/releases/download/1.0-r82/seqtk_1.0_linux.tar.gz
@@ -0,0 +1,49 @@
1
+ require 'seqtkrb/version'
2
+ require 'seqtkrb/cmd'
3
+ require 'bindeps'
4
+ require 'fixwhich'
5
+
6
+ module Seqtk
7
+
8
+ class Seqtk
9
+
10
+ include Which
11
+
12
+ def initialize
13
+
14
+ # check seqtk is installed - install it if not
15
+ gem_dir = Gem.loaded_specs['seqtkrb'].full_gem_path
16
+ gem_deps = File.join(gem_dir, 'deps.yaml')
17
+ Bindeps.require gem_deps
18
+
19
+ missing = Bindeps.missing gem_deps
20
+ unless missing.empty?
21
+ raise StandardError.new('seqtk was not found and ' +
22
+ 'could not be installed')
23
+ end
24
+
25
+ @bin = which('seqtk').first
26
+
27
+ end
28
+
29
+ def run cmd
30
+
31
+ task = Cmd.new "#{@bin} #{cmd}"
32
+ task.run
33
+
34
+ unless task.status.success?
35
+ msg = "seqtk command #{cmd} failed\n"
36
+ msg << "stdout:\n"
37
+ msg << task.stdout
38
+ msg << "\nstderr:\n"
39
+ msg << task.stderr
40
+ raise StandardError.new(msg)
41
+ end
42
+
43
+ end
44
+
45
+ end
46
+
47
+ end
48
+
49
+ require 'seqtkrb/sample'
@@ -0,0 +1,23 @@
1
+ require 'open3'
2
+
3
+ module Seqtk
4
+
5
+ class Cmd
6
+
7
+ attr_accessor :cmd, :stdout, :stderr, :status
8
+
9
+ def initialize cmd
10
+ @cmd = cmd
11
+ end
12
+
13
+ def run
14
+ @stdout, @stderr, @status = Open3.capture3 @cmd
15
+ end
16
+
17
+ def to_s
18
+ @cmd
19
+ end
20
+
21
+ end
22
+
23
+ end
@@ -0,0 +1,19 @@
1
+ module Seqtk
2
+
3
+ class Seqtk
4
+
5
+ def sample(infile, outfile, n, seed=-1)
6
+ run "sample #{seedstr seed} #{infile} #{n} > #{outfile}"
7
+ end
8
+
9
+ def sample_lowmem(infile, outfile, n, seed=-1)
10
+ run "sample -2 #{seedstr seed} #{infile} #{n} > #{outfile}"
11
+ end
12
+
13
+ def seedstr seed
14
+ seed == -1 ? "" : "-s #{seed}"
15
+ end
16
+
17
+ end
18
+
19
+ end
@@ -0,0 +1,3 @@
1
+ module Seqtkrb
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'seqtkrb/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "seqtkrb"
8
+ spec.version = Seqtkrb::VERSION
9
+ spec.authors = ["Richard Smith-Unna"]
10
+ spec.email = ["richardsmith404@gmail.com"]
11
+
12
+ spec.summary = %q{ Fast processing of FASTA/FASTQ files }
13
+ spec.description = %q{ Fast processing of FASTA/FASTQ files - a ruby wrapper around seqtk}
14
+ spec.homepage = "https://github.com/blahah/seqtkrb"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency 'bindeps'
23
+ spec.add_dependency 'fixwhich'
24
+
25
+ spec.add_development_dependency 'bundler', '~> 1.7'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
27
+ spec.add_development_dependency 'test-unit', '~> 3.0'
28
+ spec.add_development_dependency 'turn', '~> 0.9', '>= 0.9.7'
29
+ spec.add_development_dependency 'minitest', '~> 4', '>= 4.7.5'
30
+ spec.add_development_dependency 'simplecov', '~> 0.8', '>= 0.8.2'
31
+ spec.add_development_dependency 'shoulda', '~> 3.5', '>= 3.5.0'
32
+ spec.add_development_dependency 'coveralls', '~> 0.7', '>= 0.7.2'
33
+ end
metadata ADDED
@@ -0,0 +1,227 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: seqtkrb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Richard Smith-Unna
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-06-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bindeps
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: fixwhich
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: test-unit
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: turn
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.9'
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: 0.9.7
93
+ type: :development
94
+ prerelease: false
95
+ version_requirements: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '0.9'
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: 0.9.7
103
+ - !ruby/object:Gem::Dependency
104
+ name: minitest
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '4'
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 4.7.5
113
+ type: :development
114
+ prerelease: false
115
+ version_requirements: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - "~>"
118
+ - !ruby/object:Gem::Version
119
+ version: '4'
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: 4.7.5
123
+ - !ruby/object:Gem::Dependency
124
+ name: simplecov
125
+ requirement: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - "~>"
128
+ - !ruby/object:Gem::Version
129
+ version: '0.8'
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: 0.8.2
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '0.8'
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: 0.8.2
143
+ - !ruby/object:Gem::Dependency
144
+ name: shoulda
145
+ requirement: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - "~>"
148
+ - !ruby/object:Gem::Version
149
+ version: '3.5'
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: 3.5.0
153
+ type: :development
154
+ prerelease: false
155
+ version_requirements: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '3.5'
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: 3.5.0
163
+ - !ruby/object:Gem::Dependency
164
+ name: coveralls
165
+ requirement: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - "~>"
168
+ - !ruby/object:Gem::Version
169
+ version: '0.7'
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ version: 0.7.2
173
+ type: :development
174
+ prerelease: false
175
+ version_requirements: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - "~>"
178
+ - !ruby/object:Gem::Version
179
+ version: '0.7'
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: 0.7.2
183
+ description: " Fast processing of FASTA/FASTQ files - a ruby wrapper around seqtk"
184
+ email:
185
+ - richardsmith404@gmail.com
186
+ executables: []
187
+ extensions: []
188
+ extra_rdoc_files: []
189
+ files:
190
+ - ".gitignore"
191
+ - ".travis.yml"
192
+ - CODE_OF_CONDUCT.md
193
+ - Gemfile
194
+ - LICENSE.txt
195
+ - README.md
196
+ - Rakefile
197
+ - deps.yaml
198
+ - lib/seqtkrb.rb
199
+ - lib/seqtkrb/cmd.rb
200
+ - lib/seqtkrb/sample.rb
201
+ - lib/seqtkrb/version.rb
202
+ - seqtkrb.gemspec
203
+ homepage: https://github.com/blahah/seqtkrb
204
+ licenses:
205
+ - MIT
206
+ metadata: {}
207
+ post_install_message:
208
+ rdoc_options: []
209
+ require_paths:
210
+ - lib
211
+ required_ruby_version: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ required_rubygems_version: !ruby/object:Gem::Requirement
217
+ requirements:
218
+ - - ">="
219
+ - !ruby/object:Gem::Version
220
+ version: '0'
221
+ requirements: []
222
+ rubyforge_project:
223
+ rubygems_version: 2.4.6
224
+ signing_key:
225
+ specification_version: 4
226
+ summary: Fast processing of FASTA/FASTQ files
227
+ test_files: []