| Class | Bio::MAFFT |
| In: |
lib/bio/appl/mafft/report.rb
lib/bio/appl/mafft.rb |
| Parent: | Object |
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.
| command | [R] | 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. |
| data_stdout | [RW] | Last output to the stdout. |
| exit_status | [R] | Last exit status |
| options | [RW] | options |
| output | [R] | 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 | [RW] | program name (usually ‘mafft’ in UNIX) |
| report | [R] | Shows last alignment result (instance of Bio::MAFFT::Report class) performed by the factory. |
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, line 47
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. program is the name of the program. opt is options of the program.
# File lib/bio/appl/mafft.rb, line 108
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. Performs ‘nwns —all-positive n’ or ‘nwnsi —all-positive’. Same as Bio::MAFFT.nwap(n, true).
# File lib/bio/appl/mafft.rb, line 90
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, line 67
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
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, line 179
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, line 194
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, line 206
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, line 232
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, line 214
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