ms-fasta 0.2.3 → 0.4.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.
- data/.gitignore +7 -0
- data/History +4 -0
- data/{MIT-LICENSE → LICENSE} +1 -0
- data/Rakefile +98 -0
- data/VERSION +1 -0
- data/lib/ms/fasta.rb +66 -2
- data/lib/ms/fasta/ipi.rb +31 -0
- data/lib/ms/fasta/ipi/dat.rb +14 -0
- data/spec/ms/fasta/archive_spec.rb +49 -0
- data/spec/ms/fasta/entry_spec.rb +86 -0
- data/spec/ms/fasta/ipi/dat_spec.rb +7 -0
- data/spec/ms/fasta/ipi_spec.rb +34 -0
- data/spec/ms/fasta_spec.rb +76 -0
- data/spec/spec_helper.rb +4 -0
- metadata +36 -44
data/.gitignore
ADDED
data/History
CHANGED
data/{MIT-LICENSE → LICENSE}
RENAMED
data/Rakefile
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rake'
|
4
|
+
require 'jeweler'
|
5
|
+
require 'rake/testtask'
|
6
|
+
require 'rcov/rcovtask'
|
7
|
+
|
8
|
+
NAME = "ms-fasta"
|
9
|
+
WEBSITE_BASE = "website"
|
10
|
+
WEBSITE_OUTPUT = WEBSITE_BASE + "/output"
|
11
|
+
|
12
|
+
gemspec = Gem::Specification.new do |s|
|
13
|
+
s.name = NAME
|
14
|
+
s.authors = ["John T. Prince"]
|
15
|
+
s.email = "jtprince@gmail.com"
|
16
|
+
s.homepage = "http://jtprince.github.com/" + NAME
|
17
|
+
s.summary = "An mspire library for working with fasta formatted files"
|
18
|
+
s.description = "provides programmatic access to fasta files"
|
19
|
+
s.rubyforge_project = 'mspire'
|
20
|
+
s.add_development_dependency("spec-more", ">= 1.1.0")
|
21
|
+
end
|
22
|
+
|
23
|
+
Jeweler::Tasks.new(gemspec)
|
24
|
+
|
25
|
+
Rake::TestTask.new(:spec) do |spec|
|
26
|
+
spec.libs << 'lib' << 'spec'
|
27
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
28
|
+
spec.verbose = true
|
29
|
+
end
|
30
|
+
|
31
|
+
Rcov::RcovTask.new do |spec|
|
32
|
+
spec.libs << 'spec'
|
33
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
34
|
+
spec.verbose = true
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
def rdoc_redirect(base_rdoc_output_dir, package_website_page, version)
|
39
|
+
content = %Q{
|
40
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
41
|
+
<html><head><title>mspire: } + NAME + %Q{rdoc</title>
|
42
|
+
<meta http-equiv="REFRESH" content="0;url=#{package_website_page}/rdoc/#{version}/">
|
43
|
+
</head> </html>
|
44
|
+
}
|
45
|
+
FileUtils.mkpath(base_rdoc_output_dir)
|
46
|
+
File.open("#{base_rdoc_output_dir}/index.html", 'w') {|out| out.print content }
|
47
|
+
end
|
48
|
+
|
49
|
+
require 'rake/rdoctask'
|
50
|
+
Rake::RDocTask.new do |rdoc|
|
51
|
+
base_rdoc_output_dir = WEBSITE_OUTPUT + '/rdoc'
|
52
|
+
version = File.read('VERSION')
|
53
|
+
rdoc.rdoc_dir = base_rdoc_output_dir + "/#{version}"
|
54
|
+
rdoc.title = NAME + ' ' + version
|
55
|
+
rdoc.rdoc_files.include('README*')
|
56
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
57
|
+
end
|
58
|
+
|
59
|
+
task :create_redirect do
|
60
|
+
base_rdoc_output_dir = WEBSITE_OUTPUT + '/rdoc'
|
61
|
+
rdoc_redirect(base_rdoc_output_dir, gemspec.homepage,version)
|
62
|
+
end
|
63
|
+
|
64
|
+
task :rdoc => :create_redirect
|
65
|
+
|
66
|
+
namespace :website do
|
67
|
+
desc "checkout and configure the gh-pages submodule"
|
68
|
+
task :init do
|
69
|
+
if File.exist?(WEBSITE_OUTPUT + "/.git")
|
70
|
+
puts "!! not doing anything, #{WEBSITE_OUTPUT + "/.git"} already exists !!"
|
71
|
+
else
|
72
|
+
|
73
|
+
puts "(not sure why this won't work programmatically)"
|
74
|
+
puts "################################################"
|
75
|
+
puts "[Execute these commands]"
|
76
|
+
puts "################################################"
|
77
|
+
puts "git submodule init"
|
78
|
+
puts "git submodule update"
|
79
|
+
puts "pushd #{WEBSITE_OUTPUT}"
|
80
|
+
puts "git co --track -b gh-pages origin/gh-pages ;"
|
81
|
+
puts "popd"
|
82
|
+
puts "################################################"
|
83
|
+
|
84
|
+
# not sure why this won't work!
|
85
|
+
#%x{git submodule init}
|
86
|
+
#%x{git submodule update}
|
87
|
+
#Dir.chdir(WEBSITE_OUTPUT) do
|
88
|
+
# %x{git co --track -b gh-pages origin/gh-pages ;}
|
89
|
+
#end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
task :default => :spec
|
95
|
+
|
96
|
+
task :build => :gemspec
|
97
|
+
|
98
|
+
# credit: Rakefile modeled after Jeweler's
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.4.0
|
data/lib/ms/fasta.rb
CHANGED
@@ -2,15 +2,79 @@ require 'ms/fasta/archive'
|
|
2
2
|
|
3
3
|
module Ms
|
4
4
|
module Fasta
|
5
|
-
VERSION = '0.2.3'
|
6
|
-
|
7
5
|
def self.new(*args, &block)
|
8
6
|
Ms::Fasta::Archive.new(*args, &block).reindex
|
9
7
|
end
|
10
8
|
|
9
|
+
#def self.open(filename, &block)
|
10
|
+
#Ms::Fasta::Archive.open(filename, 'rb', [], &block)
|
11
|
+
#end
|
12
|
+
|
11
13
|
def self.open(*args, &block)
|
12
14
|
Ms::Fasta::Archive.open(*args, &block)
|
13
15
|
end
|
14
16
|
|
17
|
+
def self.foreach(*args, &block)
|
18
|
+
Ms::Fasta::Archive.open(*args) do |fasta|
|
19
|
+
fasta.each(&block)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# returns :ipi, :ncbi, or nil if can't be determined
|
24
|
+
def self.filetype(file_or_io)
|
25
|
+
ft = nil
|
26
|
+
io =
|
27
|
+
if file_or_io.is_a?(String)
|
28
|
+
File.open(file_or_io)
|
29
|
+
else
|
30
|
+
init_pos = file_or_io.pos
|
31
|
+
file_or_io.rewind
|
32
|
+
file_or_io
|
33
|
+
end
|
34
|
+
io.each_line do |line|
|
35
|
+
if line =~ /^>/
|
36
|
+
ft = header_to_filetype(line[1..-1])
|
37
|
+
break
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
if file_or_io.is_a?(String)
|
42
|
+
io.close
|
43
|
+
else
|
44
|
+
io.pos = init_pos
|
45
|
+
end
|
46
|
+
ft
|
47
|
+
end
|
48
|
+
|
49
|
+
# takes the header line (no leading >) and returns the kind of file
|
50
|
+
def self.header_to_filetype(line)
|
51
|
+
if line =~ /^IPI\:/
|
52
|
+
:ipi
|
53
|
+
elsif line =~ /^gi\|/
|
54
|
+
:ncbi
|
55
|
+
else
|
56
|
+
nil
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# kind is :ipi or :ncbi or a String (the header)
|
61
|
+
# gives the regular expression for parsing the header (no leading >)
|
62
|
+
def self.id_regexp(kind)
|
63
|
+
sym =
|
64
|
+
if kind.is_a?(String)
|
65
|
+
header_to_filetype(kind)
|
66
|
+
else ; kind
|
67
|
+
end
|
68
|
+
case sym
|
69
|
+
when :ipi
|
70
|
+
/^IPI:(.*?)\|/o
|
71
|
+
when :ncbi
|
72
|
+
/^gi\|(.*?)\|/o
|
73
|
+
else
|
74
|
+
nil
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
15
78
|
end
|
16
79
|
end
|
80
|
+
|
data/lib/ms/fasta/ipi.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
module Ms
|
3
|
+
module Fasta
|
4
|
+
module Ipi
|
5
|
+
IPI_RE = /IPI:([\w\.]+)\|/o
|
6
|
+
class << self
|
7
|
+
# returns a hash of header information where the values are all
|
8
|
+
# strings (does NOT attempt to separate on ';'). The gene description
|
9
|
+
# is held in the key 'description'
|
10
|
+
def parse(header)
|
11
|
+
gap_index = header.index(' ')
|
12
|
+
hash = {}
|
13
|
+
header[0...gap_index].split('|').each do |str|
|
14
|
+
(key, val) = str.split(':')
|
15
|
+
hash[key] = val
|
16
|
+
end
|
17
|
+
pieces = header[gap_index..-1].split(' ')
|
18
|
+
hash.store(*pieces.shift.split('='))
|
19
|
+
hash.store(*pieces.shift.split('='))
|
20
|
+
hash.store('description', pieces.join(' '))
|
21
|
+
hash
|
22
|
+
end
|
23
|
+
|
24
|
+
# returns the ipi index for the header (.e.g, ipi0000093.1)
|
25
|
+
def ipi(header)
|
26
|
+
IPI_RE.match(header)[1]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../spec_helper.rb')
|
2
|
+
require 'ms/fasta/archive'
|
3
|
+
|
4
|
+
class FastaAchiveSpec
|
5
|
+
include Ms::Fasta
|
6
|
+
|
7
|
+
describe 'fasta archive operations' do
|
8
|
+
|
9
|
+
FASTA_0 = %Q{>gi|5524211|gb|AAD44166.1| cytochrome b [Elephas maximus maximus]
|
10
|
+
LCLYTHIGRNIYYGSYLYSETWNTGIMLLLITMATAFMGYVLPWGQMSFWGATVITNLFSAIPYIGTNLV
|
11
|
+
GLMPFLHTSKHRSMMLRPLSQALFWTLTMDLLTLTWIGSQPVEYPYTIIGQMASILYFSIILAFLPIAGX
|
12
|
+
IENY
|
13
|
+
}
|
14
|
+
|
15
|
+
FASTA_1 = %Q{>gi|1048576| protein sequence
|
16
|
+
PROTEIN
|
17
|
+
}
|
18
|
+
|
19
|
+
it 'reindexes' do
|
20
|
+
strio = StringIO.new(FASTA_0 + FASTA_1)
|
21
|
+
begin
|
22
|
+
a = Archive.new(strio)
|
23
|
+
|
24
|
+
a.length.is 0
|
25
|
+
a.reindex
|
26
|
+
a.length.is 2
|
27
|
+
|
28
|
+
a[0].to_s.is FASTA_0
|
29
|
+
a[1].to_s.is FASTA_1
|
30
|
+
a[1].header.is "gi|1048576| protein sequence"
|
31
|
+
ensure
|
32
|
+
a.close
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'properly converts the fasta string to an entry object' do
|
37
|
+
begin
|
38
|
+
a = Archive.new
|
39
|
+
e = a.str_to_entry(FASTA_0)
|
40
|
+
|
41
|
+
e.isa Entry
|
42
|
+
e.header.is "gi|5524211|gb|AAD44166.1| cytochrome b [Elephas maximus maximus]"
|
43
|
+
e.sequence.is("LCLYTHIGRNIYYGSYLYSETWNTGIMLLLITMATAFMGYVLPWGQMSFWGATVITNLFSAIPYIGTNLV" + "GLMPFLHTSKHRSMMLRPLSQALFWTLTMDLLTLTWIGSQPVEYPYTIIGQMASILYFSIILAFLPIAGX" + "IENY")
|
44
|
+
ensure
|
45
|
+
a.close
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../spec_helper.rb')
|
2
|
+
require 'ms/fasta/entry'
|
3
|
+
|
4
|
+
class FastaEntryTest
|
5
|
+
include Ms::Fasta
|
6
|
+
|
7
|
+
describe 'basic Entry operations' do
|
8
|
+
# Abbreviated FASTA entry from wikipedia (http://en.wikipedia.org/wiki/FASTA_format)
|
9
|
+
FASTA_0 = %Q{>gi|5524211|gb|AAD44166.1| cytochrome b [Elephas maximus maximus]
|
10
|
+
LCLYTHIGRNIYYGSYLYSETWNTGIMLLLITMATAFMGYVLPWGQMSFWGATVITNLFSAIPYIGTNLV
|
11
|
+
GLMPFLHTSKHRSMMLRPLSQALFWTLTMDLLTLTWIGSQPVEYPYTIIGQMASILYFSIILAFLPIAGX
|
12
|
+
IENY
|
13
|
+
}
|
14
|
+
|
15
|
+
#
|
16
|
+
# documentation test
|
17
|
+
#
|
18
|
+
|
19
|
+
it 'parses an entry as per docs' do
|
20
|
+
entry = Entry.parse %q{
|
21
|
+
>gi|5524211|gb|AAD44166.1| cytochrome b [Elephas maximus maximus]
|
22
|
+
LCLYTHIGRNIYYGSYLYSETWNTGIMLLLITMATAFMGYVLPWGQMSFWGATVITNLFSAIPYIGTNLV
|
23
|
+
EWIWGGFSVDKATLNRFFAFHFILPFTMVALAGVHLTFLHETGSNNPLGLTSDSDKIPFHPYYTIKDFLG
|
24
|
+
LLILILLLLLLALLSPDMLGDPDNHMPADPLNTPLHIKPEWYFLFAYAILRSVPNKLGGVLALFLSIVIL
|
25
|
+
GLMPFLHTSKHRSMMLRPLSQALFWTLTMDLLTLTWIGSQPVEYPYTIIGQMASILYFSIILAFLPIAGX
|
26
|
+
IENY
|
27
|
+
}.strip
|
28
|
+
|
29
|
+
entry.header[0,30].is 'gi|5524211|gb|AAD44166.1| cyto'
|
30
|
+
entry.sequence[0,30].is 'LCLYTHIGRNIYYGSYLYSETWNTGIMLLL'
|
31
|
+
end
|
32
|
+
|
33
|
+
#
|
34
|
+
# class parse tests
|
35
|
+
#
|
36
|
+
|
37
|
+
it 'parses header and sequence' do
|
38
|
+
e = Entry.parse(FASTA_0)
|
39
|
+
e.header.is "gi|5524211|gb|AAD44166.1| cytochrome b [Elephas maximus maximus]"
|
40
|
+
e.sequence.is(
|
41
|
+
"LCLYTHIGRNIYYGSYLYSETWNTGIMLLLITMATAFMGYVLPWGQMSFWGATVITNLFSAIPYIGTNLV" +
|
42
|
+
"GLMPFLHTSKHRSMMLRPLSQALFWTLTMDLLTLTWIGSQPVEYPYTIIGQMASILYFSIILAFLPIAGX" + "IENY")
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'raises error for entries that do not start with gt' do
|
46
|
+
|
47
|
+
lambda { Entry.parse "\n#{FASTA_0}" }.should.raise(RuntimeError).message.should.equal("input should begin with '>'")
|
48
|
+
end
|
49
|
+
|
50
|
+
#
|
51
|
+
# initialize tests
|
52
|
+
#
|
53
|
+
|
54
|
+
def test_entry_initialization
|
55
|
+
e = Entry.new
|
56
|
+
assert_equal("", e.header)
|
57
|
+
assert_equal("", e.sequence)
|
58
|
+
|
59
|
+
e = Entry.new "head", "SEQ"
|
60
|
+
assert_equal("head", e.header)
|
61
|
+
assert_equal("SEQ", e.sequence)
|
62
|
+
end
|
63
|
+
|
64
|
+
#
|
65
|
+
# dump tests
|
66
|
+
#
|
67
|
+
|
68
|
+
def test_dump_formats_a_fasta_entry
|
69
|
+
e = Entry.new
|
70
|
+
assert_equal(">\n", e.dump)
|
71
|
+
|
72
|
+
e = Entry.new "head", "SEQ"
|
73
|
+
assert_equal(">head\nSEQ\n", e.dump)
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_dump_formats_output_with_desired_line_length
|
77
|
+
e = Entry.new "header", "ABCDEFGH"
|
78
|
+
assert_equal(">header\nABC\nDEF\nGH\n", e.dump("", :line_length => 3))
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_dump_line_length_less_than_1_raises_error
|
82
|
+
e = Entry.new
|
83
|
+
assert_raise(ArgumentError) { e.dump("", :line_length => 0) }
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
require 'ms/fasta/ipi'
|
4
|
+
|
5
|
+
class IpiSpec
|
6
|
+
include Ms::Fasta
|
7
|
+
|
8
|
+
describe 'basic IPI operations' do
|
9
|
+
|
10
|
+
before do
|
11
|
+
@headers = ['IPI:IPI00000001.2|SWISS-PROT:O95793-1|TREMBL:A8K622;Q59F99|ENSEMBL:ENSP00000360922;ENSP00000379466|REFSEQ:NP_059347|H-INV:HIT000329496|VEGA:OTTHUMP00000031233 Tax_Id=9606 Gene_Symbol=STAU1 Isoform Long of Double-stranded RNA-binding protein Staufen homolog 1',
|
12
|
+
'IPI:IPI00000005.1|SWISS-PROT:P01111|TREMBL:Q5U091|ENSEMBL:ENSP00000358548;ENSP00000385392|REFSEQ:NP_002515|VEGA:OTTHUMP00000013879 Tax_Id=9606 Gene_Symbol=NRAS GTPase NRas']
|
13
|
+
|
14
|
+
@answers = [{"Gene_Symbol"=>"STAU1", "VEGA"=>"OTTHUMP00000031233", "IPI"=>"IPI00000001.2", "H-INV"=>"HIT000329496", "REFSEQ"=>"NP_059347", "Tax_Id"=>"9606", "SWISS-PROT"=>"O95793-1", "ENSEMBL"=>"ENSP00000360922;ENSP00000379466", "TREMBL"=>"A8K622;Q59F99", "description"=>"Isoform Long of Double-stranded RNA-binding protein Staufen homolog 1"},
|
15
|
+
{"Gene_Symbol"=>"NRAS", "VEGA"=>"OTTHUMP00000013879", "IPI"=>"IPI00000005.1", "REFSEQ"=>"NP_002515", "Tax_Id"=>"9606", "SWISS-PROT"=>"P01111", "ENSEMBL"=>"ENSP00000358548;ENSP00000385392", "TREMBL"=>"Q5U091", "description"=>"GTPase NRas"}]
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'parses IPI headers' do
|
19
|
+
# assumes that the leading '>' has been removed
|
20
|
+
@headers.zip(@answers) do |header, answ|
|
21
|
+
Ipi.parse(header).is answ
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'can retrive the IPI ID' do
|
26
|
+
answers = ["IPI00000001.2", "IPI00000005.1"]
|
27
|
+
|
28
|
+
@headers.zip(answers) do |header, answ|
|
29
|
+
Ipi.ipi(header).is answ
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
require 'ms/fasta'
|
4
|
+
|
5
|
+
describe 'basic fasta operations' do
|
6
|
+
|
7
|
+
before do
|
8
|
+
@headers = [">gi|5524211 [hello]", ">another B", ">again C"]
|
9
|
+
@entries = ["LCLYTHIGRNIYYGSYLYSETWNTGIMLLLITMATAFMGYVLPWGQMSFWGATVITNLFSAIPYIGTNLV\nGLMPFLHTSKHRSMMLRPLSQALFWTLTMDLLTLTWIGSQPVEYPYTIIGQMASILYFSIILAFLPIAGX\nIENY", "ABCDEF\nGHIJK", "ABCD"]
|
10
|
+
@sequences = @entries.map {|v| v.gsub("\n", '') }
|
11
|
+
@data = {}
|
12
|
+
@data['newlines'] = @headers.zip(@entries).map do |header, data|
|
13
|
+
header + "\n" + data
|
14
|
+
end.join("\n")
|
15
|
+
@data['carriage_returns_and_newlines'] = @data['newlines'].gsub("\n", "\r\n")
|
16
|
+
@data.each do |k,v|
|
17
|
+
file_key = k + '_file'
|
18
|
+
filename = k + '.tmp'
|
19
|
+
@data[file_key] = filename
|
20
|
+
File.open(filename, 'w') {|out| out.print v }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
after do
|
25
|
+
@data.select {|k,v| k =~ /_file$/ }.each do |k,filename|
|
26
|
+
index = filename.sub('.tmp', '.index')
|
27
|
+
[filename, index].each do |fn|
|
28
|
+
File.unlink(fn) if File.exist? fn
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def fasta_correct?(fasta)
|
34
|
+
fasta.size.is 3
|
35
|
+
(0...@headers.size).each do |i|
|
36
|
+
header, sequence, entry = @headers[i], @sequences[i], fasta[i]
|
37
|
+
entry.header.isnt nil
|
38
|
+
entry.sequence.isnt nil
|
39
|
+
entry.header.is header[1..-1]
|
40
|
+
entry.sequence.is sequence
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'can read a file' do
|
45
|
+
%w(newlines_file carriage_returns_and_newlines_file).each do |file|
|
46
|
+
Ms::Fasta.open(@data[file]) do |fasta|
|
47
|
+
fasta_correct? fasta
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'can read an IO object' do
|
53
|
+
%w(newlines_file carriage_returns_and_newlines_file).each do |file|
|
54
|
+
File.open(@data[file]) do |io|
|
55
|
+
fasta = Ms::Fasta.new(io)
|
56
|
+
fasta_correct? fasta
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'can read a string' do
|
62
|
+
%w(newlines carriage_returns_and_newlines).each do |key|
|
63
|
+
fasta = Ms::Fasta.new @data[key]
|
64
|
+
fasta_correct? fasta
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'iterates entries with foreach' do
|
69
|
+
%w(newlines_file carriage_returns_and_newlines_file).each do |file|
|
70
|
+
Ms::Fasta.foreach(@data[file]) do |entry|
|
71
|
+
entry.isa Ms::Fasta::Entry
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,78 +1,65 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ms-fasta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- John T. Prince
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-12-09 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
17
|
-
type: :runtime
|
18
|
-
version_requirement:
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.17.1
|
24
|
-
version:
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: tap-test
|
16
|
+
name: spec-more
|
27
17
|
type: :development
|
28
18
|
version_requirement:
|
29
19
|
version_requirements: !ruby/object:Gem::Requirement
|
30
20
|
requirements:
|
31
21
|
- - ">="
|
32
22
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
34
|
-
version:
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: external
|
37
|
-
type: :runtime
|
38
|
-
version_requirement:
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
40
|
-
requirements:
|
41
|
-
- - ">="
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: 0.3.0
|
23
|
+
version: 1.1.0
|
44
24
|
version:
|
45
|
-
description:
|
46
|
-
email:
|
25
|
+
description: provides programmatic access to fasta files
|
26
|
+
email: jtprince@gmail.com
|
47
27
|
executables: []
|
48
28
|
|
49
29
|
extensions: []
|
50
30
|
|
51
31
|
extra_rdoc_files:
|
52
|
-
-
|
32
|
+
- LICENSE
|
53
33
|
- README.rdoc
|
54
|
-
- MIT-LICENSE
|
55
34
|
files:
|
35
|
+
- .gitignore
|
36
|
+
- History
|
37
|
+
- LICENSE
|
38
|
+
- README.rdoc
|
39
|
+
- Rakefile
|
40
|
+
- VERSION
|
56
41
|
- lib/ms/fasta.rb
|
57
42
|
- lib/ms/fasta/archive.rb
|
58
43
|
- lib/ms/fasta/entry.rb
|
44
|
+
- lib/ms/fasta/ipi.rb
|
45
|
+
- lib/ms/fasta/ipi/dat.rb
|
59
46
|
- lib/ms/load/fasta.rb
|
60
47
|
- lib/ms/random/fasta.rb
|
61
48
|
- lib/ms/select/fasta.rb
|
49
|
+
- spec/ms/fasta/archive_spec.rb
|
50
|
+
- spec/ms/fasta/entry_spec.rb
|
51
|
+
- spec/ms/fasta/ipi/dat_spec.rb
|
52
|
+
- spec/ms/fasta/ipi_spec.rb
|
53
|
+
- spec/ms/fasta_spec.rb
|
54
|
+
- spec/spec_helper.rb
|
62
55
|
- tap.yml
|
63
|
-
- History
|
64
|
-
- README.rdoc
|
65
|
-
- MIT-LICENSE
|
66
56
|
has_rdoc: true
|
67
|
-
homepage: http://
|
57
|
+
homepage: http://jtprince.github.com/ms-fasta
|
58
|
+
licenses: []
|
59
|
+
|
68
60
|
post_install_message:
|
69
61
|
rdoc_options:
|
70
|
-
- --
|
71
|
-
- README.rdoc
|
72
|
-
- -S
|
73
|
-
- -N
|
74
|
-
- --title
|
75
|
-
- Ms-Fasta
|
62
|
+
- --charset=UTF-8
|
76
63
|
require_paths:
|
77
64
|
- lib
|
78
65
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -90,9 +77,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
77
|
requirements: []
|
91
78
|
|
92
79
|
rubyforge_project: mspire
|
93
|
-
rubygems_version: 1.3.
|
80
|
+
rubygems_version: 1.3.5
|
94
81
|
signing_key:
|
95
|
-
specification_version:
|
96
|
-
summary:
|
97
|
-
test_files:
|
98
|
-
|
82
|
+
specification_version: 3
|
83
|
+
summary: An mspire library for working with fasta formatted files
|
84
|
+
test_files:
|
85
|
+
- spec/ms/fasta/archive_spec.rb
|
86
|
+
- spec/ms/fasta/ipi_spec.rb
|
87
|
+
- spec/ms/fasta/ipi/dat_spec.rb
|
88
|
+
- spec/ms/fasta/entry_spec.rb
|
89
|
+
- spec/ms/fasta_spec.rb
|
90
|
+
- spec/spec_helper.rb
|