dna 0.0.8 → 0.0.9

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.
data/lib/dna.rb CHANGED
@@ -28,6 +28,8 @@ class Dna
28
28
  first_line = @handle.first
29
29
  @handle.rewind if @handle.class == File
30
30
 
31
+ return :unknown if first_line == nil
32
+
31
33
  # detect qseq by counting number of tabs.
32
34
  if first_line.split("\t").length == 11
33
35
  return :qseq
File without changes
data/spec/dna_spec.rb CHANGED
@@ -6,17 +6,22 @@ describe Dna do
6
6
  let(:fasta) { Dna.new(@fasta_file) }
7
7
  let(:fastq) { Dna.new @fastq_file }
8
8
  let(:qseq) { Dna.new @qseq_file }
9
+ let(:empty) { Dna.new @empty_file }
10
+
11
+ it 'doesnt freak out on empty files' do
12
+ fasta.format == :empty
13
+ end
9
14
 
10
15
  it 'can auto-detect fasta format' do
11
- fasta.format == 'fasta'
16
+ fasta.format.should == :fasta
12
17
  end
13
18
 
14
19
  it 'can auto-detect fastq format' do
15
- fastq.format == 'fastq'
20
+ fastq.format.should == :fastq
16
21
  end
17
22
 
18
23
  it 'can auto-detect qseq format' do
19
- qseq.format == 'qseq'
24
+ qseq.format.should == :qseq
20
25
  end
21
26
 
22
27
  it 'can properly parse a crappily formatted fasta file' do
data/spec/spec_helper.rb CHANGED
@@ -7,11 +7,13 @@ path = File.dirname(__FILE__)
7
7
  fasta_file = File.readlines(File.join(path, 'data/test.fasta'))
8
8
  fastq_file = File.readlines(File.join(path, 'data/test.fastq'))
9
9
  qseq_file = File.readlines(File.join(path, 'data/test.qseq'))
10
+ empty_file = File.readlines(File.join(path, 'data/empty.txt'))
10
11
 
11
12
  shared_context "parser stuff" do
12
13
  before do
13
14
  @fasta_file = fasta_file
14
15
  @fastq_file = fastq_file
15
16
  @qseq_file = qseq_file
17
+ @empty_fiel = empty_file
16
18
  end
17
19
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dna
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 8
10
- version: 0.0.8
9
+ - 9
10
+ version: 0.0.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Austin G. Davis-Richardson
@@ -34,6 +34,7 @@ files:
34
34
  - spec/dna_spec.rb
35
35
  - spec/record_spec.rb
36
36
  - spec/spec_helper.rb
37
+ - spec/data/empty.txt
37
38
  - spec/data/test.fasta
38
39
  - spec/data/test.fastq
39
40
  - spec/data/test.qseq