dna 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/dna.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "dna"
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Austin G. Davis-Richardson"]
12
- s.date = "2012-12-14"
12
+ s.date = "2012-12-19"
13
13
  s.description = "Simple FASTA/FASTQ/QSEQ parser library for Ruby."
14
14
  s.email = "harekrishna@gmail.com"
15
15
  s.executables = ["dna"]
data/lib/dna/dna.rb CHANGED
@@ -7,9 +7,9 @@ class Dna
7
7
 
8
8
  attr_reader :format
9
9
 
10
- def initialize(handle)
10
+ def initialize(handle, args = {})
11
11
  @handle = handle
12
- @format = detect_format
12
+ @format = args[:format] || detect_format
13
13
  @iterator =
14
14
  case @format
15
15
  when :fasta
data/lib/dna/phred.rb CHANGED
@@ -38,7 +38,7 @@ module Phred
38
38
  private
39
39
 
40
40
  def qualities_with_offset(offset)
41
- @qualities.each_byte.map { |q| q - offset }
41
+ @quality.each_byte.map { |q| q - offset }
42
42
  end
43
43
 
44
44
  def probabilities_with_offset(offset, func)
data/lib/dna/version.rb CHANGED
@@ -2,7 +2,7 @@ class Dna
2
2
  class Version
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- PATCH = 0
5
+ PATCH = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].join('.')
8
8
  end
data/readme.md CHANGED
@@ -53,9 +53,10 @@ File.open('sequences.qseq') do |handle|
53
53
  puts records.first.inspect
54
54
  end
55
55
 
56
- # Even supports Gzip
56
+ # Even supports Gzip but you must specify the format
57
+ # (can't rewind in Gzip)
57
58
  File.open('sequences.fasta.gz') do |handle|
58
- records = Dna.new handle
59
+ records = Dna.new handle, :format => :fasta
59
60
 
60
61
  records.each do |record|
61
62
  puts record.length
@@ -63,6 +64,31 @@ File.open('sequences.fasta.gz') do |handle|
63
64
  end
64
65
  ```
65
66
 
67
+ ## Support for PHRED score parsing
68
+
69
+ ```ruby
70
+
71
+ # Illumina > 1.3)
72
+
73
+ record.illumina_qualities # => [31, ..., 37]
74
+
75
+ # Error probabilities
76
+
77
+ record.illumina_probabilities
78
+ # => [1.0, 0.7943282347242815, ..., 0.3981071705534972]
79
+
80
+ # Solexa + Illumina =< 1.3
81
+
82
+ record.solexa_qualities
83
+ record.solexa_probabilities
84
+
85
+ # Sanger
86
+
87
+ record.sanger_qualities
88
+ record.sanger_probabilities
89
+
90
+ ```
91
+
66
92
  ## Bonus Feature
67
93
 
68
94
  The DNA gem is also a command-line tool with grep-like capabilities. Print records with (Ruby) regexp match in header.
data/spec/phred_spec.rb CHANGED
@@ -1,6 +1,7 @@
1
+ # XXX should probably use the actual record objects
1
2
  class TestRecord
2
3
  include Phred
3
- attr_accessor :qualities
4
+ attr_accessor :quality
4
5
  end
5
6
 
6
7
  ##
@@ -62,12 +63,12 @@ describe Phred do
62
63
  format_definitions.each_pair do |type, properties|
63
64
 
64
65
  it "should properly convert #{type} raw ascii PHRED scores to integers" do
65
- test_record.qualities = properties[:string]
66
+ test_record.quality = properties[:string]
66
67
  test_record.send(:"#{type}_scores").should == properties[:scores]
67
68
  end
68
69
 
69
70
  it "should properly convert #{type.to_s} raw ascii PHRED scores to probabilities" do
70
- test_record.qualities = properties[:string]
71
+ test_record.quality = properties[:string]
71
72
  test_record.send(:"#{type}_probabilities").should == properties[:probabilities]
72
73
  end
73
74
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dna
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-14 00:00:00.000000000 Z
12
+ date: 2012-12-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jeweler
@@ -74,7 +74,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
74
74
  version: '0'
75
75
  segments:
76
76
  - 0
77
- hash: -74029819579817896
77
+ hash: 1149140625798689145
78
78
  required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  none: false
80
80
  requirements: