class Bio::MAFFT
Bio::MAFFT
is a wrapper class to execute MAFFT
. MAFFT
is a very fast multiple sequence alignment software.
Though Bio::MAFFT
class currently supports only MAFFT
version 3, you can use MAFFT
version 5 because the class is a wrapper class.
Attributes
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.
Last output to the stdout.
Last exit status
options
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.
program name (usually ‘mafft’ in UNIX)
Shows last alignment result (instance of Bio::MAFFT::Report
class) performed by the factory.
Public Class Methods
Creates a new alignment factory. When n
is a number (1,2,3, …), performs ‘fftns n’. When n
is :i or ‘i’, performs ‘fftnsi’.
# File lib/bio/appl/mafft.rb 47 def self.fftns(n = nil) 48 opt = [] 49 if n.to_s == 'i' then 50 self.new2(nil, 'fftnsi', *opt) 51 else 52 opt << n.to_s if n 53 self.new2(nil, 'fftns', *opt) 54 end 55 end
Creates a new alignment factory. Performs ‘fftnsi’.
# File lib/bio/appl/mafft.rb 59 def self.fftnsi 60 self.new2(nil, 'fftnsi') 61 end
Creates a new alignment factory. program
is the name of the program. opt
is options of the program.
# File lib/bio/appl/mafft.rb 108 def initialize(program = 'mafft', opt = []) 109 @program = program 110 @options = opt 111 @command = nil 112 @output = nil 113 @report = nil 114 @data_stdout = nil 115 @exit_status = nil 116 end
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.
# File lib/bio/appl/mafft.rb 98 def self.new2(dir, prog, *opt) 99 if dir then 100 prog = File.join(dir, prog) 101 end 102 self.new(prog, opt) 103 end
Creates a new alignment factory. Performs ‘nwns –all-positive n’ or ‘nwnsi –all-positive’. Same as Bio::MAFFT.nwap(n, true)
.
# File lib/bio/appl/mafft.rb 90 def self.nwap(n = nil) 91 self.nwns(n, true) 92 end
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’.
# File lib/bio/appl/mafft.rb 67 def self.nwns(n = nil, ap = nil) 68 opt = [] 69 opt << '--all-positive' if ap 70 if n.to_s == 'i' then 71 self.new2(nil, 'nwnsi', *opt) 72 else 73 opt << n.to_s if n 74 self.new2(nil, 'nwns', *opt) 75 end 76 end
Creates a new alignment factory. Performs ‘nwnsi’. If all_positive
is true, add option ‘–all-positive’.
# File lib/bio/appl/mafft.rb 81 def self.nwnsi(all_positive = nil) 82 opt = [] 83 opt << '--all-positive' if all_positive 84 self.new2(nil, 'nwnsi', *opt) 85 end
Public Instance Methods
log is deprecated (no replacement) and returns empty string.
# File lib/bio/appl/mafft.rb 141 def log 142 warn "Bio::MAFFT#log is deprecated (no replacement) and returns empty string." 143 '' 144 end
option is deprecated. Instead, please use options.
# File lib/bio/appl/mafft.rb 125 def option 126 warn "Bio::MAFFT#option is deprecated. Please use options." 127 options 128 end
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.
# File lib/bio/appl/mafft.rb 179 def query(seqs) 180 if seqs then 181 query_align(seqs) 182 else 183 exec_local(@options) 184 @exit_status.exitstatus == 0 ? true : false 185 end 186 end
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.
# File lib/bio/appl/mafft.rb 194 def query_align(seqs, *arg) 195 if arg.size > 0 then 196 warn '2nd and other arguments of Bio::MAFFT#query_align is ignored' 197 end 198 unless seqs.is_a?(Bio::Alignment) 199 seqs = Bio::Alignment.new(seqs) 200 end 201 query_string(seqs.output_fasta(:width => 70)) 202 end
Performs alignment for seqs. seqs
should be Bio::Alignment
or Array of sequences or nil.
# File lib/bio/appl/mafft.rb 206 def query_alignment(seqs) 207 query_align(seqs) 208 end
Performs alignment of sequences in the file named fn
.
Compatibility Note: 2nd argument (seqtype) is deprecated and ignored.
# File lib/bio/appl/mafft.rb 232 def query_by_filename(fn, *arg) 233 if arg.size > 0 then 234 warn '2nd argument of Bio::MAFFT#query_filename is ignored' 235 end 236 opt = @options + [ fn ] 237 exec_local(opt) 238 @report = Report.new(@output) 239 @report 240 end
Performs alignment for str
. Str should be a string that can be recognized by the program.
Compatibility Note: arg is deprecated and ignored.
# File lib/bio/appl/mafft.rb 214 def query_string(str, *arg) 215 if arg.size > 0 then 216 warn '2nd and other arguments of Bio::MAFFT#query_string is ignored' 217 end 218 begin 219 tf_in = Tempfile.open('align') 220 tf_in.print str 221 ensure 222 tf_in.close(false) 223 end 224 r = query_by_filename(tf_in.path, *arg) 225 tf_in.close(true) 226 r 227 end
Clear the internal data and status, except program and options.
# File lib/bio/appl/mafft.rb 164 def reset 165 @command = nil 166 @output = nil 167 @report = nil 168 @exit_status = nil 169 @data_stdout = nil 170 end