ms-fasta 0.2.0 → 0.2.3
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/History +16 -1
- data/{README → README.rdoc} +0 -0
- data/lib/ms/fasta.rb +16 -0
- data/lib/ms/fasta/archive.rb +1 -1
- data/lib/ms/fasta/entry.rb +2 -2
- data/lib/ms/load/fasta.rb +31 -16
- data/lib/ms/random/fasta.rb +3 -3
- data/lib/ms/select/fasta.rb +29 -0
- metadata +8 -6
data/History
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
== 0.2.3 / 2009-06-17
|
2
|
+
|
3
|
+
* added Ms::Fasta.new and Ms::Fasta.open methods and specs
|
4
|
+
* Ms::Fasta::Archive parsing can handle fasta files with "\r\n"
|
5
|
+
|
6
|
+
== 0.2.2
|
7
|
+
|
8
|
+
* transfered tests into specs
|
9
|
+
* version determined by Ms::Fasta::VERSION
|
10
|
+
|
11
|
+
== 0.2.1
|
12
|
+
|
13
|
+
* reworked load/fasta to load fasta off a stream
|
14
|
+
* refactored the previous load/fasta to select/fasta
|
15
|
+
|
1
16
|
== 0.2.0 / 2009-05-06
|
2
17
|
|
3
18
|
* updated to use tap-0.17.0
|
@@ -6,4 +21,4 @@
|
|
6
21
|
== 0.1.0 / 2009-03-24
|
7
22
|
|
8
23
|
Initial release with tasks to load entries
|
9
|
-
from a FASTA file.
|
24
|
+
from a FASTA file.
|
data/{README → README.rdoc}
RENAMED
File without changes
|
data/lib/ms/fasta.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'ms/fasta/archive'
|
2
|
+
|
3
|
+
module Ms
|
4
|
+
module Fasta
|
5
|
+
VERSION = '0.2.3'
|
6
|
+
|
7
|
+
def self.new(*args, &block)
|
8
|
+
Ms::Fasta::Archive.new(*args, &block).reindex
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.open(*args, &block)
|
12
|
+
Ms::Fasta::Archive.open(*args, &block)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
data/lib/ms/fasta/archive.rb
CHANGED
data/lib/ms/fasta/entry.rb
CHANGED
@@ -25,7 +25,7 @@ module Ms
|
|
25
25
|
raise "input should begin with '>'"
|
26
26
|
end
|
27
27
|
|
28
|
-
seq_begin = str.index(
|
28
|
+
seq_begin = str.index(/\r?\n/)
|
29
29
|
Entry.new(str[1, seq_begin-1], str[seq_begin, str.length - seq_begin].gsub(/\r?\n/, ""))
|
30
30
|
end
|
31
31
|
end
|
@@ -72,4 +72,4 @@ module Ms
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
75
|
-
end
|
75
|
+
end
|
data/lib/ms/load/fasta.rb
CHANGED
@@ -1,29 +1,44 @@
|
|
1
|
-
require '
|
1
|
+
require 'tap/tasks/load'
|
2
|
+
require 'ms/fasta/entry'
|
2
3
|
|
3
4
|
module Ms
|
4
5
|
module Load
|
5
6
|
# :startdoc::task loads entries in a fasta file
|
6
7
|
#
|
7
|
-
# Loads entries from a fasta file.
|
8
|
-
# by default as Ms::Fasta::Entry objects.
|
8
|
+
# Loads entries from a fasta file.
|
9
9
|
#
|
10
|
-
class Fasta < Tap::
|
10
|
+
class Fasta < Tap::Tasks::Load
|
11
|
+
Entry = Ms::Fasta::Entry
|
11
12
|
|
12
|
-
config :
|
13
|
-
config :
|
13
|
+
config :header, true, &c.switch
|
14
|
+
config :sequence, true, &c.switch
|
15
|
+
|
16
|
+
def entry_break?(io)
|
17
|
+
if c = io.getc
|
18
|
+
io.ungetc(c)
|
19
|
+
c == ?>
|
20
|
+
else
|
21
|
+
true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def load(io)
|
26
|
+
header = io.readline
|
27
|
+
sequence = []
|
28
|
+
while !entry_break?(io)
|
29
|
+
sequence << io.readline
|
30
|
+
end
|
14
31
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
#
|
22
|
-
# watch (http://bahuvrihi.lighthouseapp.com/projects/10590-external/tickets/7-for-strings)
|
23
|
-
entries.collect! {|entry| entry.to_s } if fasta
|
24
|
-
entries
|
32
|
+
case
|
33
|
+
when !self.header
|
34
|
+
sequence.join('')
|
35
|
+
when !self.sequence
|
36
|
+
header
|
37
|
+
else
|
38
|
+
"#{header}#{sequence.join('')}"
|
25
39
|
end
|
26
40
|
end
|
41
|
+
|
27
42
|
end
|
28
43
|
end
|
29
44
|
end
|
data/lib/ms/random/fasta.rb
CHANGED
@@ -9,9 +9,9 @@ module Ms
|
|
9
9
|
#
|
10
10
|
class Fasta < Tap::Task
|
11
11
|
|
12
|
-
config :n, 1, &c.integer #
|
13
|
-
config :fasta, false, &c.switch #
|
14
|
-
config :distinct, true, &c.switch #
|
12
|
+
config :n, 1, &c.integer # The number of fasta to select
|
13
|
+
config :fasta, false, &c.switch # Returns entries as fasta strings
|
14
|
+
config :distinct, true, &c.switch # Requires entries to be unique by sequence
|
15
15
|
|
16
16
|
def process(fasta_file)
|
17
17
|
entries = []
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'ms/fasta/archive'
|
2
|
+
|
3
|
+
module Ms
|
4
|
+
module Select
|
5
|
+
# :startdoc::task selects entries from a fasta file
|
6
|
+
#
|
7
|
+
# Load the selected entries from a fasta file. Entries are returned as an
|
8
|
+
# array and by default as Ms::Fasta::Entry objects.
|
9
|
+
#
|
10
|
+
class Fasta < Tap::Task
|
11
|
+
|
12
|
+
config :range, 0..10, &c.range # The range of entries to select
|
13
|
+
config :fasta, false, &c.switch # Returns entries as fasta strings
|
14
|
+
|
15
|
+
def process(fasta_file)
|
16
|
+
Ms::Fasta::Archive.open(fasta_file) do |archive|
|
17
|
+
entries = archive[range]
|
18
|
+
|
19
|
+
# totally wasteful... ExternalArchive needs
|
20
|
+
# a way to read a selection of string without
|
21
|
+
# conversion to entries.
|
22
|
+
# watch (http://bahuvrihi.lighthouseapp.com/projects/10590-external/tickets/7-for-strings)
|
23
|
+
entries.collect! {|entry| entry.to_s } if fasta
|
24
|
+
entries
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ms-fasta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Chiang
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-06-17 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.17.
|
23
|
+
version: 0.17.1
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: tap-test
|
@@ -50,23 +50,25 @@ extensions: []
|
|
50
50
|
|
51
51
|
extra_rdoc_files:
|
52
52
|
- History
|
53
|
-
- README
|
53
|
+
- README.rdoc
|
54
54
|
- MIT-LICENSE
|
55
55
|
files:
|
56
|
+
- lib/ms/fasta.rb
|
56
57
|
- lib/ms/fasta/archive.rb
|
57
58
|
- lib/ms/fasta/entry.rb
|
58
59
|
- lib/ms/load/fasta.rb
|
59
60
|
- lib/ms/random/fasta.rb
|
61
|
+
- lib/ms/select/fasta.rb
|
60
62
|
- tap.yml
|
61
63
|
- History
|
62
|
-
- README
|
64
|
+
- README.rdoc
|
63
65
|
- MIT-LICENSE
|
64
66
|
has_rdoc: true
|
65
67
|
homepage: http://mspire.rubyforge.org/projects/ms-fasta
|
66
68
|
post_install_message:
|
67
69
|
rdoc_options:
|
68
70
|
- --main
|
69
|
-
- README
|
71
|
+
- README.rdoc
|
70
72
|
- -S
|
71
73
|
- -N
|
72
74
|
- --title
|