Class: Bio::MAFFT
- Inherits:
-
Object
- Object
- Bio::MAFFT
- Defined in:
- lib/bio/appl/mafft.rb,
lib/bio/appl/mafft/report.rb
Overview
module Alignment
Defined Under Namespace
Classes: Report
Instance Attribute Summary (collapse)
-
- (Object) command
readonly
Shows last command-line string.
-
- (Object) data_stdout
Last output to the stdout.
-
- (Object) exit_status
readonly
Last exit status.
-
- (Object) options
options.
-
- (Object) output
readonly
Shows latest raw alignment result.
-
- (Object) program
program name (usually 'mafft' in UNIX).
-
- (Object) report
readonly
Shows last alignment result (instance of Bio::MAFFT::Report class) performed by the factory.
Class Method Summary (collapse)
-
+ (Object) fftns(n = nil)
Creates a new alignment factory.
-
+ (Object) fftnsi
Creates a new alignment factory.
-
+ (Object) new2(dir, prog, *opt)
Creates a new alignment factory.
-
+ (Object) nwap(n = nil)
Creates a new alignment factory.
-
+ (Object) nwns(n = nil, ap = nil)
Creates a new alignment factory.
-
+ (Object) nwnsi(all_positive = nil)
Creates a new alignment factory.
Instance Method Summary (collapse)
-
- (MAFFT) initialize(program = 'mafft', opt = [])
constructor
Creates a new alignment factory.
-
- (Object) log
log is deprecated (no replacement) and returns empty string.
-
- (Object) option
option is deprecated.
-
- (Object) query(seqs)
Executes the program.
-
- (Object) query_align(seqs, *arg)
Note that this method will be renamed to query_alignment.
-
- (Object) query_alignment(seqs)
Performs alignment for seqs.
-
- (Object) query_by_filename(fn, *arg)
Performs alignment of sequences in the file named fn.
-
- (Object) query_string(str, *arg)
Performs alignment for str.
-
- (Object) reset
Clear the internal data and status, except program and options.
Constructor Details
- (MAFFT) initialize(program = 'mafft', opt = [])
Creates a new alignment factory. program is the name of the program. opt is options of the program.
108 109 110 111 112 113 114 115 116 |
# File 'lib/bio/appl/mafft.rb', line 108 def initialize(program = 'mafft', opt = []) @program = program @options = opt @command = nil @output = nil @report = nil @data_stdout = nil @exit_status = nil end |
Instance Attribute Details
- (Object) command (readonly)
Shows last command-line string. Returns nil or an array of String. Note that filenames described in the command-line may already be removed because they are temporary files.
133 134 135 |
# File 'lib/bio/appl/mafft.rb', line 133 def command @command end |
- (Object) data_stdout
Last output to the stdout.
161 162 163 |
# File 'lib/bio/appl/mafft.rb', line 161 def data_stdout @data_stdout end |
- (Object) exit_status (readonly)
Last exit status
158 159 160 |
# File 'lib/bio/appl/mafft.rb', line 158 def exit_status @exit_status end |
- (Object) output (readonly)
Shows latest raw alignment result. Return a string. (Changed in bioruby-1.1.0). Compatibility note: If you want an array of Bio::FastaFormat instances, you should use report.data instead.
151 152 153 |
# File 'lib/bio/appl/mafft.rb', line 151 def output @output end |
- (Object) program
program name (usually 'mafft' in UNIX)
119 120 121 |
# File 'lib/bio/appl/mafft.rb', line 119 def program @program end |
- (Object) report (readonly)
Shows last alignment result (instance of Bio::MAFFT::Report class) performed by the factory.
155 156 157 |
# File 'lib/bio/appl/mafft.rb', line 155 def report @report end |
Class Method Details
+ (Object) fftns(n = nil)
Creates a new alignment factory. When n is a number (1,2,3, ...), performs 'fftns n'. When n is :i or 'i', performs 'fftnsi'.
47 48 49 50 51 52 53 54 55 |
# File 'lib/bio/appl/mafft.rb', line 47 def self.fftns(n = nil) opt = [] if n.to_s == 'i' then self.new2(nil, 'fftnsi', *opt) else opt << n.to_s if n self.new2(nil, 'fftns', *opt) end end |
+ (Object) fftnsi
Creates a new alignment factory. Performs 'fftnsi'.
59 60 61 |
# File 'lib/bio/appl/mafft.rb', line 59 def self.fftnsi self.new2(nil, 'fftnsi') end |
+ (Object) new2(dir, prog, *opt)
Creates a new alignment factory. dir is the path of the MAFFT program. prog is the name of the program. opt is options of the program.
98 99 100 101 102 103 |
# File 'lib/bio/appl/mafft.rb', line 98 def self.new2(dir, prog, *opt) if dir then prog = File.join(dir, prog) end self.new(prog, opt) end |
+ (Object) nwap(n = nil)
Creates a new alignment factory. Performs 'nwns --all-positive n' or 'nwnsi --all-positive'. Same as Bio::MAFFT.nwap(n, true).
90 91 92 |
# File 'lib/bio/appl/mafft.rb', line 90 def self.nwap(n = nil) self.nwns(n, true) end |
+ (Object) nwns(n = nil, ap = nil)
Creates a new alignment factory. When n is a number (1,2,3, ...), performs 'nwns n'. When n is :i or 'i', performs 'nwnsi'. In both case, if all_positive is true, add option '--all-positive'.
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/bio/appl/mafft.rb', line 67 def self.nwns(n = nil, ap = nil) opt = [] opt << '--all-positive' if ap if n.to_s == 'i' then self.new2(nil, 'nwnsi', *opt) else opt << n.to_s if n self.new2(nil, 'nwns', *opt) end end |
+ (Object) nwnsi(all_positive = nil)
Creates a new alignment factory. Performs 'nwnsi'. If all_positive is true, add option '--all-positive'.
81 82 83 84 85 |
# File 'lib/bio/appl/mafft.rb', line 81 def self.nwnsi(all_positive = nil) opt = [] opt << '--all-positive' if all_positive self.new2(nil, 'nwnsi', *opt) end |
Instance Method Details
- (Object) log
log is deprecated (no replacement) and returns empty string.
141 142 143 144 |
# File 'lib/bio/appl/mafft.rb', line 141 def log warn "Bio::MAFFT#log is deprecated (no replacement) and returns empty string." '' end |
- (Object) option
option is deprecated. Instead, please use options.
125 126 127 128 |
# File 'lib/bio/appl/mafft.rb', line 125 def option warn "Bio::MAFFT#option is deprecated. Please use options." end |
- (Object) query(seqs)
Executes the program. If seqs is not nil, perform alignment for seqs. If seqs is nil, simply executes the program.
Compatibility note: When seqs is nil, returns true if the program exits normally, and returns false if the program exits abnormally.
179 180 181 182 183 184 185 186 |
# File 'lib/bio/appl/mafft.rb', line 179 def query(seqs) if seqs then query_align(seqs) else exec_local(@options) @exit_status.exitstatus == 0 ? true : false end end |
- (Object) query_align(seqs, *arg)
Note that this method will be renamed to query_alignment.
Performs alignment for seqs. seqs should be Bio::Alignment or Array of sequences or nil.
Compatibility Note: arg is deprecated and ignored.
194 195 196 197 198 199 200 201 202 |
# File 'lib/bio/appl/mafft.rb', line 194 def query_align(seqs, *arg) if arg.size > 0 then warn '2nd and other arguments of Bio::MAFFT#query_align is ignored' end unless seqs.is_a?(Bio::Alignment) seqs = Bio::Alignment.new(seqs) end query_string(seqs.output_fasta(:width => 70)) end |
- (Object) query_alignment(seqs)
Performs alignment for seqs. seqs should be Bio::Alignment or Array of sequences or nil.
206 207 208 |
# File 'lib/bio/appl/mafft.rb', line 206 def query_alignment(seqs) query_align(seqs) end |
- (Object) query_by_filename(fn, *arg)
Performs alignment of sequences in the file named fn.
Compatibility Note: 2nd argument (seqtype) is deprecated and ignored.
232 233 234 235 236 237 238 239 240 |
# File 'lib/bio/appl/mafft.rb', line 232 def query_by_filename(fn, *arg) if arg.size > 0 then warn '2nd argument of Bio::MAFFT#query_filename is ignored' end opt = @options + [ fn ] exec_local(opt) @report = Report.new(@output) @report end |
- (Object) query_string(str, *arg)
Performs alignment for str. Str should be a string that can be recognized by the program.
Compatibility Note: arg is deprecated and ignored.
214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/bio/appl/mafft.rb', line 214 def query_string(str, *arg) if arg.size > 0 then warn '2nd and other arguments of Bio::MAFFT#query_string is ignored' end begin tf_in = Tempfile.open('align') tf_in.print str ensure tf_in.close(false) end r = query_by_filename(tf_in.path, *arg) tf_in.close(true) r end |
- (Object) reset
Clear the internal data and status, except program and options.
164 165 166 167 168 169 170 |
# File 'lib/bio/appl/mafft.rb', line 164 def reset @command = nil @output = nil @report = nil @exit_status = nil @data_stdout = nil end |