forage 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/forage +5 -2
- data/lib/forage.rb +15 -6
- metadata +39 -22
data/bin/forage
CHANGED
@@ -7,10 +7,13 @@ if ARGV.length != 2
|
|
7
7
|
exit
|
8
8
|
end
|
9
9
|
|
10
|
-
|
10
|
+
filename, query = ARGV[0], ARGV[1]
|
11
|
+
|
12
|
+
|
13
|
+
forage = Forage.new File.open(filename), query
|
11
14
|
|
12
15
|
forage.each do |matches|
|
13
16
|
matches[1].each_with_index do |match, i|
|
14
|
-
puts ">#{matches[0]}:#{i}\n#{match}"
|
17
|
+
puts ">#{matches[0]}:#{i}\n#{match.join}"
|
15
18
|
end
|
16
19
|
end
|
data/lib/forage.rb
CHANGED
@@ -4,10 +4,19 @@ class Forage
|
|
4
4
|
def initialize(handle, query)
|
5
5
|
@handle = handle
|
6
6
|
|
7
|
-
@iupac = Hash.new
|
8
|
-
|
9
|
-
'
|
10
|
-
'
|
7
|
+
@iupac = Hash.new{ |h, k| h[k] = k }.merge({
|
8
|
+
'R' => '[AG]',
|
9
|
+
'Y' => '[CTUY]',
|
10
|
+
'S' => '[GCS]',
|
11
|
+
'W' => '[ATUW]',
|
12
|
+
'K' => '[GTUK]',
|
13
|
+
'M' => '[ACM]',
|
14
|
+
'B' => '[CGTUB]',
|
15
|
+
'D' => '[AGTUD]',
|
16
|
+
'H' => '[ACTUH]',
|
17
|
+
'V' => '[ACGV]',
|
18
|
+
'N' => '.',
|
19
|
+
'-' => '.'}
|
11
20
|
)
|
12
21
|
|
13
22
|
@regex = self.convert query
|
@@ -26,7 +35,7 @@ class Forage
|
|
26
35
|
|
27
36
|
# convert string to regex
|
28
37
|
def convert(s)
|
29
|
-
@regex = s.each_char.collect { |n| "
|
38
|
+
@regex = s.each_char.collect { |n| "#{@iupac[n]}" }.join
|
30
39
|
Regexp.new @regex
|
31
40
|
end
|
32
41
|
|
@@ -39,7 +48,7 @@ class Forage
|
|
39
48
|
sequence = ''
|
40
49
|
header = line[1..-1].strip
|
41
50
|
else
|
42
|
-
sequence << line.strip.tr(' ','')
|
51
|
+
sequence << line.strip.tr(' ','').upcase
|
43
52
|
end
|
44
53
|
end
|
45
54
|
yield [ header, sequence ]
|
metadata
CHANGED
@@ -1,48 +1,65 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: forage
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 3
|
9
|
+
version: 0.0.3
|
6
10
|
platform: ruby
|
7
|
-
authors:
|
11
|
+
authors:
|
8
12
|
- Austin G. Davis-Richardson
|
9
13
|
autorequire:
|
10
14
|
bindir: bin
|
11
15
|
cert_chain: []
|
12
|
-
|
16
|
+
|
17
|
+
date: 2011-07-06 00:00:00 -04:00
|
18
|
+
default_executable: forage
|
13
19
|
dependencies: []
|
14
|
-
|
15
|
-
|
20
|
+
|
21
|
+
description: Forage is grep for nucleotide data. With Forage, you can grep nucleotide sequences in FASTA using the IUPAC ambiguous nucleotides code. Useful for predicting PCR products.
|
16
22
|
email: harekrishna@gmail.com
|
17
|
-
executables:
|
23
|
+
executables:
|
18
24
|
- forage
|
19
25
|
extensions: []
|
26
|
+
|
20
27
|
extra_rdoc_files: []
|
21
|
-
|
28
|
+
|
29
|
+
files:
|
22
30
|
- bin/forage
|
23
31
|
- lib/forage.rb
|
32
|
+
has_rdoc: true
|
24
33
|
homepage: http://www.github.com/audy/forage
|
25
34
|
licenses: []
|
35
|
+
|
26
36
|
post_install_message:
|
27
37
|
rdoc_options: []
|
28
|
-
|
38
|
+
|
39
|
+
require_paths:
|
29
40
|
- lib
|
30
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
42
|
none: false
|
32
|
-
requirements:
|
33
|
-
- -
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
|
36
|
-
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
version: "0"
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
50
|
none: false
|
38
|
-
requirements:
|
39
|
-
- -
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
42
57
|
requirements: []
|
58
|
+
|
43
59
|
rubyforge_project: forage
|
44
|
-
rubygems_version: 1.
|
60
|
+
rubygems_version: 1.3.7
|
45
61
|
signing_key:
|
46
62
|
specification_version: 3
|
47
63
|
summary: Grep for nucleotide data.
|
48
64
|
test_files: []
|
65
|
+
|