dna 0.3.0 → 0.3.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ad48f8e0c0cb16eb16b15aac96835dd3cf14f95f
4
+ data.tar.gz: d93f3466c1de438e5241af282cc33fbf4a050c7e
5
+ SHA512:
6
+ metadata.gz: fbd9a6b2ac10635db59dbb23078fbc17889df5a49601ff59abcc0b1ce0d2a1fc157c9d2340487a58f9bb276ee3154b9633a9aae7df5c66b53dc3a11da56821b4
7
+ data.tar.gz: 0db717cea0f96fedbe4c33175e2f0b3a72a7421716f8feea4aa4783473d99036635486e781efe3f849a20a1694ee65d01313f4350ab7856622d2db4ff4ff391e
@@ -1,4 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
+ - 2.0.0
4
5
  script: bundle exec rspec
data/Gemfile CHANGED
@@ -2,6 +2,7 @@ source "https://rubygems.org"
2
2
 
3
3
  group :test do
4
4
  gem 'rspec', '~> 2.11.0'
5
+ gem 'coveralls', require: false
5
6
  end
6
7
 
7
8
  group :development do
@@ -2,17 +2,22 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
+ # stub: dna 0.3.1 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
8
  s.name = "dna"
8
- s.version = "0.3.0"
9
+ s.version = "0.3.1"
9
10
 
10
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
11
13
  s.authors = ["Austin G. Davis-Richardson"]
12
- s.date = "2013-08-02"
14
+ s.date = "2015-10-30"
13
15
  s.description = "Simple FASTA/FASTQ/QSEQ parser library for Ruby."
14
16
  s.email = "harekrishna@gmail.com"
15
17
  s.executables = ["dna"]
18
+ s.extra_rdoc_files = [
19
+ "readme.md"
20
+ ]
16
21
  s.files = [
17
22
  ".rspec",
18
23
  ".rvmrc",
@@ -31,6 +36,7 @@ Gem::Specification.new do |s|
31
36
  "lib/dna/version.rb",
32
37
  "readme.md",
33
38
  "spec/data/empty.txt",
39
+ "spec/data/single.fasta",
34
40
  "spec/data/test.fasta",
35
41
  "spec/data/test.fasta.gz",
36
42
  "spec/data/test.fastq",
@@ -42,12 +48,11 @@ Gem::Specification.new do |s|
42
48
  ]
43
49
  s.homepage = "http://audy.github.com/dna"
44
50
  s.licenses = ["MIT"]
45
- s.require_paths = ["lib"]
46
- s.rubygems_version = "1.8.25"
51
+ s.rubygems_version = "2.4.5.1"
47
52
  s.summary = "Simple FASTA/FASTQ/QSEQ parser library for Ruby"
48
53
 
49
54
  if s.respond_to? :specification_version then
50
- s.specification_version = 3
55
+ s.specification_version = 4
51
56
 
52
57
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
53
58
  s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
data/lib/dna.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require 'zlib'
2
2
 
3
- [ 'version.rb', 'dna.rb', 'phred.rb', 'record.rb'].each do |f|
4
- fp = File.join(File.dirname(__FILE__), 'dna', f)
5
- require fp
6
- end
3
+ $:.unshift(File.join(File.expand_path(File.dirname(__FILE__)), 'dna'))
4
+
5
+ require 'version'
6
+ require 'dna'
7
+ require 'phred'
8
+ require 'record'
@@ -7,12 +7,16 @@ class FastaParser
7
7
  def each
8
8
  sequence, header = nil, nil
9
9
  @handle.each do |line|
10
+
11
+ line.strip!
12
+ next if line.strip.empty? # skip blank lines
13
+
10
14
  if line[0].chr == '>'
11
15
  yield Fasta.new(:name => header, :sequence => sequence) if sequence
12
16
  sequence = ''
13
- header = line[1..-1].strip
17
+ header = line[1..-1]
14
18
  else
15
- sequence << line.strip.tr(' ','')
19
+ sequence << line.tr(' ','')
16
20
  end
17
21
  end
18
22
  yield Fasta.new(:name => header, :sequence => sequence)
@@ -2,7 +2,7 @@ class Dna
2
2
  class Version
3
3
  MAJOR = 0
4
4
  MINOR = 3
5
- PATCH = 0
5
+ PATCH = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].join('.')
8
8
  end
data/readme.md CHANGED
@@ -1,7 +1,4 @@
1
- # DNA
2
-
3
- [![Build Status](https://secure.travis-ci.org/audy/dna.png?branch=master)](http://travis-ci.org/audy/dna)
4
-
1
+ # DNA [![Gem Version](https://badge.fury.io/rb/dna.png)](http://badge.fury.io/rb/dna) [![Build Status](https://secure.travis-ci.org/audy/dna.png?branch=master)](http://travis-ci.org/audy/dna) [![Coverage Status](https://coveralls.io/repos/audy/dna/badge.png)](https://coveralls.io/r/audy/dna)
5
2
  A biological sequence file parser for Ruby
6
3
 
7
4
  Austin G. Davis-Richardson
@@ -12,9 +9,8 @@ Features
12
9
  - [fasta](http://en.wikipedia.org/wiki/FASTA)
13
10
  - [fastq](http://en.wikipedia.org/wiki/Fastq)
14
11
  - [qseq](http://blog.kokocinski.net/index.php/qseq-files-format?blog=2)
15
- - Autodetection of file formats so your scripts can be format agnostic
16
- - Automatic Gzip support
17
- - Files are read from disk (not stored in memory)
12
+ - Automatic format detection
13
+ - Lazy iteration
18
14
 
19
15
  ## Installation
20
16
 
@@ -53,9 +49,12 @@ File.open('sequences.qseq') do |handle|
53
49
  puts records.first.inspect
54
50
  end
55
51
 
56
- # Even supports Gzip but you must specify the format
57
- # (can't rewind in Gzip)
58
- File.open('sequences.fasta.gz') do |handle|
52
+ # **caveat:** If you are reading from a compressed file
53
+ # or `stdin` you MUST specify the sequence format:
54
+
55
+ require 'zlib'
56
+
57
+ Zlib::GzipReader('sequences.fasta.gz') do |handle|
59
58
  records = Dna.new handle, :format => :fasta
60
59
 
61
60
  records.each do |record|
@@ -0,0 +1,2 @@
1
+ >a single record
2
+ GATC
@@ -9,4 +9,6 @@ CGAAG
9
9
  GAGACAUAUC
10
10
 
11
11
  CNNNA
12
- A
12
+ A
13
+
14
+
@@ -13,6 +13,13 @@ describe Dna do
13
13
  fasta.format == :empty
14
14
  end
15
15
 
16
+ it 'can read a single record' do
17
+ File.open('spec/data/single.fasta') do |handle|
18
+ records = Dna.new(handle).to_a
19
+ records.first.sequence.should == 'GATC'
20
+ end
21
+ end
22
+
16
23
  it 'can automatically parse gzipped files' do
17
24
  gzipped.format.should == :fasta
18
25
  end
@@ -59,4 +66,4 @@ describe Dna do
59
66
  it 'generates qseq objects from a qseq file' do
60
67
  qseq.first.class.should == QSEQ
61
68
  end
62
- end
69
+ end
@@ -1,8 +1,12 @@
1
1
  $LOAD_PATH << File.join(File.dirname(__FILE__), 'lib')
2
2
 
3
+ require 'coveralls'
4
+ Coveralls.wear!
5
+
3
6
  require 'rspec'
4
7
  require 'dna'
5
8
 
9
+
6
10
  path = File.dirname(__FILE__)
7
11
  fasta_file = File.readlines(File.join(path, 'data/test.fasta'))
8
12
  fastq_file = File.readlines(File.join(path, 'data/test.fastq'))
@@ -17,4 +21,4 @@ shared_context "parser stuff" do
17
21
  @empty_file = empty_file
18
22
  @gzip_file = File.open(File.join(path, 'data/test.fasta.gz'))
19
23
  end
20
- end
24
+ end
metadata CHANGED
@@ -1,30 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dna
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
5
- prerelease:
4
+ version: 0.3.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Austin G. Davis-Richardson
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-08-02 00:00:00.000000000 Z
11
+ date: 2015-10-30 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: jeweler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: 1.8.4
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: 1.8.4
30
27
  description: Simple FASTA/FASTQ/QSEQ parser library for Ruby.
@@ -32,11 +29,12 @@ email: harekrishna@gmail.com
32
29
  executables:
33
30
  - dna
34
31
  extensions: []
35
- extra_rdoc_files: []
32
+ extra_rdoc_files:
33
+ - readme.md
36
34
  files:
37
- - .rspec
38
- - .rvmrc
39
- - .travis.yml
35
+ - ".rspec"
36
+ - ".rvmrc"
37
+ - ".travis.yml"
40
38
  - Gemfile
41
39
  - Rakefile
42
40
  - bin/dna
@@ -51,6 +49,7 @@ files:
51
49
  - lib/dna/version.rb
52
50
  - readme.md
53
51
  - spec/data/empty.txt
52
+ - spec/data/single.fasta
54
53
  - spec/data/test.fasta
55
54
  - spec/data/test.fasta.gz
56
55
  - spec/data/test.fastq
@@ -62,29 +61,25 @@ files:
62
61
  homepage: http://audy.github.com/dna
63
62
  licenses:
64
63
  - MIT
64
+ metadata: {}
65
65
  post_install_message:
66
66
  rdoc_options: []
67
67
  require_paths:
68
68
  - lib
69
69
  required_ruby_version: !ruby/object:Gem::Requirement
70
- none: false
71
70
  requirements:
72
- - - ! '>='
71
+ - - ">="
73
72
  - !ruby/object:Gem::Version
74
73
  version: '0'
75
- segments:
76
- - 0
77
- hash: -3491596072416341887
78
74
  required_rubygems_version: !ruby/object:Gem::Requirement
79
- none: false
80
75
  requirements:
81
- - - ! '>='
76
+ - - ">="
82
77
  - !ruby/object:Gem::Version
83
78
  version: '0'
84
79
  requirements: []
85
80
  rubyforge_project:
86
- rubygems_version: 1.8.25
81
+ rubygems_version: 2.4.5.1
87
82
  signing_key:
88
- specification_version: 3
83
+ specification_version: 4
89
84
  summary: Simple FASTA/FASTQ/QSEQ parser library for Ruby
90
85
  test_files: []