parse_fasta 2.1.1 → 2.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 605e579f4970a6c9a7af84c1717b2b381fcbacf9
4
- data.tar.gz: a60a0c7632ef0b316214995fdc7e0b28db8876e1
3
+ metadata.gz: e2fe1d91cfec3272d6f28872c5f048edd518b290
4
+ data.tar.gz: ef220e3c20cba089556a727a1cbe739f9a869037
5
5
  SHA512:
6
- metadata.gz: a905d2eb000620a7b474279cf1e21863548c18161c2bff6e4a5f82024893dc384462d0eecbfc48a3cde6eaf27c4a72fecd13640b3b77ae5e8111e55d5dcaa014
7
- data.tar.gz: c6b33d1c8e134317bb21ddd59e22ca75740236e2ca97e9f9e1c57e65e51e645451c781f837ef095c464d53e2d836acc6b0e79929aed74977490deaa8a362b67e
6
+ metadata.gz: 909f37e235e112841ec124768e30ccbccd92e50065446ca132475b7c148dd63f5a4d6ce08be7a3194c8bd15cd12cd8e243008739ae26c0c6b9d09bb37b0e1cac
7
+ data.tar.gz: e6a9080b6f836a1b14987b3b9c8185c3a05997583d82d209f7b9f8c5f83b98fad4a5ce02c66bc9880e1a872feeb4fee1cbac34f98714ec37cb8022832009325c
@@ -1,5 +1,9 @@
1
1
  ## Versions ##
2
2
 
3
+ ### 2.2.0 ###
4
+
5
+ Add `id` attribute to `Record`.
6
+
3
7
  ### 2.1.1 ###
4
8
 
5
9
  Speed up `Record.new`
@@ -22,6 +22,9 @@ module ParseFasta
22
22
  # @!attribute header
23
23
  # @return [String] the full header of the record without the '>'
24
24
  # or '@'
25
+ # @!attribute id
26
+ # @return [String] the "id" i.e., the first token when split by
27
+ # whitespace
25
28
  # @!attribute seq
26
29
  # @return [String] the sequence of the record
27
30
  # @!attribute desc
@@ -30,7 +33,7 @@ module ParseFasta
30
33
  # @!attribute qual
31
34
  # @return [String or Nil] if the record is from a fastA file, it
32
35
  # is nil; else, the quality string of the fastQ record
33
- attr_accessor :header, :seq, :desc, :qual
36
+ attr_accessor :header, :id, :seq, :desc, :qual
34
37
 
35
38
  # The constructor takes keyword args.
36
39
  #
@@ -48,6 +51,7 @@ module ParseFasta
48
51
  # character in it
49
52
  def initialize args = {}
50
53
  @header = args.fetch :header
54
+ @id = @header.split(" ")[0]
51
55
 
52
56
  @desc = args.fetch :desc, nil
53
57
  @qual = args.fetch :qual, nil
@@ -17,5 +17,5 @@
17
17
  # along with parse_fasta. If not, see <http://www.gnu.org/licenses/>.
18
18
 
19
19
  module ParseFasta
20
- VERSION = "2.1.1"
20
+ VERSION = "2.2.0"
21
21
  end
@@ -21,8 +21,9 @@ require "spec_helper"
21
21
  module ParseFasta
22
22
  describe Record do
23
23
  let(:header) { "apple pie is good"}
24
+ let(:id) { "apple" }
24
25
  let(:seq) { "ACTG" }
25
- let(:desc) { "apple" }
26
+ let(:desc) { "apple" }
26
27
  let(:qual) { "abcd" }
27
28
 
28
29
  let(:fasta_rec) {
@@ -37,15 +38,31 @@ module ParseFasta
37
38
  }
38
39
 
39
40
  describe "::new" do
40
- context "fastA input" do
41
+ context "either fastA or fastQ" do
41
42
  it "sets :header" do
42
43
  expect(fasta_rec.header).to eq header
44
+ expect(fastq_rec.header).to eq header
43
45
  end
44
46
 
45
47
  it "sets :seq" do
46
48
  expect(fasta_rec.seq).to eq seq
49
+ expect(fastq_rec.seq).to eq seq
50
+ end
51
+
52
+ it "sets :id" do
53
+ expect(fasta_rec.id).to eq id
54
+ expect(fastq_rec.id).to eq id
47
55
  end
48
56
 
57
+ it "sets :id to the first token when split by whitespace" do
58
+ rec = Record.new header: "apple\tpie is good",
59
+ seq: "actg"
60
+
61
+ expect(rec.id).to eq "apple"
62
+ end
63
+ end
64
+
65
+ context "fastA input" do
49
66
  it "sets :desc to nil" do
50
67
  expect(fasta_rec.desc).to eq nil
51
68
  end
@@ -65,19 +82,11 @@ module ParseFasta
65
82
  end
66
83
 
67
84
  context "fastQ input" do
68
- it "sets :header" do
69
- expect(fastq_rec.header).to eq header
70
- end
71
-
72
- it "sets :seq" do
73
- expect(fastq_rec.seq).to eq seq
74
- end
75
-
76
- it "sets :desc to nil" do
85
+ it "sets :desc to desc" do
77
86
  expect(fastq_rec.desc).to eq desc
78
87
  end
79
88
 
80
- it "sets :qual to nil" do
89
+ it "sets :qual to qual" do
81
90
  expect(fastq_rec.qual).to eq qual
82
91
  end
83
92
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parse_fasta
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Moore
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-01 00:00:00.000000000 Z
11
+ date: 2016-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler