orf_finder 0.1.2 → 0.1.4
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 +4 -4
- data/lib/orf.rb +12 -7
- data/lib/orf_finder.rb +12 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae74e9c90fae051a04bfafe5930dfd240fd44a9f
|
4
|
+
data.tar.gz: dd333404439214b4584a4fe99b70f737c3acf269
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7506ba3acf6f16e0dbc01118135c3427719384cfd5894752c03a667e520e6f36b2458a80cf53e2fef0796c07c18851925b4a8f96c5384df540f655cac340388a
|
7
|
+
data.tar.gz: 5a0fa12da4db509ac1d1e090bd4778aff7521ec3b565a0ab8c8265f029440e8c7e8d33061f30be91f70a83f11282b070752c6b82bcbcf2e07f29a870fb1fa321
|
data/lib/orf.rb
CHANGED
@@ -9,10 +9,11 @@ class ORF
|
|
9
9
|
#
|
10
10
|
include ORF::ORFCommon
|
11
11
|
#
|
12
|
+
DEFAULT_CODON_TABLE = 1
|
12
13
|
#
|
13
14
|
attr_reader :logger, :options, :seq, :sequence
|
14
15
|
attr_writer :options
|
15
|
-
|
16
|
+
#
|
16
17
|
# class initializer that normalizes sequence to Bio::Sequence,
|
17
18
|
# merges given options and creates logger
|
18
19
|
def initialize(sequence, options = {}, logger_file = nil)
|
@@ -47,20 +48,20 @@ class ORF
|
|
47
48
|
|
48
49
|
#
|
49
50
|
# return aminoacid sequence
|
50
|
-
def aa
|
51
|
+
def aa(codon_table = DEFAULT_CODON_TABLE)
|
51
52
|
# return already generated aa sequence
|
52
53
|
return @res_aa unless @res_aa.nil?
|
53
54
|
# save result
|
54
|
-
l = longest
|
55
|
+
l = longest(codon_table)
|
55
56
|
return l if @res_aa.nil?
|
56
57
|
@res_aa
|
57
58
|
end
|
58
59
|
|
59
60
|
#
|
60
61
|
# return nucletotide sequence
|
61
|
-
def nt
|
62
|
+
def nt(codon_table = DEFAULT_CODON_TABLE)
|
62
63
|
return @res_nt unless @res_nt.nil?
|
63
|
-
longest
|
64
|
+
longest(codon_table)
|
64
65
|
end
|
65
66
|
|
66
67
|
#
|
@@ -128,7 +129,7 @@ class ORF
|
|
128
129
|
#
|
129
130
|
# get the longest sequence in each frame and translate
|
130
131
|
# to aminoacid
|
131
|
-
def longest
|
132
|
+
def longest(codon_table = DEFAULT_CODON_TABLE)
|
132
133
|
# run find method if search has not been done
|
133
134
|
find if @orf.nil?
|
134
135
|
#
|
@@ -144,7 +145,11 @@ class ORF
|
|
144
145
|
# translate to aa sequence
|
145
146
|
unless @res_nt.nil?
|
146
147
|
@res_nt.each do |key, val|
|
147
|
-
res_aa[key] = val.
|
148
|
+
res_aa[key] = if val.nil? || val.empty?
|
149
|
+
''
|
150
|
+
else
|
151
|
+
val.translate(1, codon_table)
|
152
|
+
end
|
148
153
|
end
|
149
154
|
end
|
150
155
|
@res_aa = res_aa
|
data/lib/orf_finder.rb
CHANGED
@@ -4,6 +4,8 @@ require_relative 'orf'
|
|
4
4
|
#
|
5
5
|
# Wrapper class that processes the direct and reverse sequences
|
6
6
|
class ORFFinder
|
7
|
+
#
|
8
|
+
attr_reader :codon_table
|
7
9
|
#
|
8
10
|
DEFAULT_OPTIONS = { start: %w(atg),
|
9
11
|
stop: %w(tag taa tga),
|
@@ -12,7 +14,7 @@ class ORFFinder
|
|
12
14
|
min: 6,
|
13
15
|
debug: false }
|
14
16
|
|
15
|
-
def initialize(sequence, options = {}, logger = nil)
|
17
|
+
def initialize(sequence, codon_table = 1, options = {}, logger = nil)
|
16
18
|
#
|
17
19
|
sequence = Bio::Sequence::NA.new(sequence) if sequence.class == String
|
18
20
|
options = DEFAULT_OPTIONS.merge(options.nil? ? {} : options)
|
@@ -20,15 +22,18 @@ class ORFFinder
|
|
20
22
|
@output = {}
|
21
23
|
@output[:direct] = ORF.new(sequence, options, logger) if options[:direct]
|
22
24
|
#
|
23
|
-
|
24
|
-
|
25
|
-
|
25
|
+
if options[:reverse]
|
26
|
+
compl = sequence.complement
|
27
|
+
@output[:reverse] = ORF.new(compl, options, logger)
|
28
|
+
end
|
29
|
+
#
|
30
|
+
@codon_table = codon_table
|
26
31
|
end
|
27
32
|
|
28
33
|
def nt
|
29
34
|
res = {}
|
30
35
|
@output.each do |key, value|
|
31
|
-
res[key] = value.nt
|
36
|
+
res[key] = value.nt(@codon_table)
|
32
37
|
res[key][:sequence] = value.seq
|
33
38
|
end
|
34
39
|
res
|
@@ -37,8 +42,8 @@ class ORFFinder
|
|
37
42
|
def aa
|
38
43
|
res = {}
|
39
44
|
@output.each do |key, value|
|
40
|
-
res[key] = value.aa
|
41
|
-
res[key][:sequence] = value.sequence.translate.to_s
|
45
|
+
res[key] = value.aa(@codon_table)
|
46
|
+
res[key][:sequence] = value.sequence.translate(@codon_table).to_s
|
42
47
|
end
|
43
48
|
res
|
44
49
|
end
|