Class: Bio::ClustalW
- Defined in:
- lib/bio/appl/clustalw.rb,
lib/bio/appl/clustalw/report.rb
Overview
Bio::ClustalW is a CLUSTAL W execution wrapper class. Its object is also called an alignment factory. CLUSTAL W is a very popular software for multiple sequence alignment.
Defined Under Namespace
Classes: Report
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns last command-line strings executed by this factory.
-
#data_stdout ⇒ Object
Last output to the stdout.
-
#exit_status ⇒ Object
readonly
Last exit status.
-
#options ⇒ Object
options.
-
#output ⇒ Object
readonly
Returns last raw alignment result (String or nil).
-
#output_dnd ⇒ Object
readonly
Returns last alignment guild-tree (file.dnd).
-
#program ⇒ Object
name of the program (usually ‘clustalw’ in UNIX).
-
#report ⇒ Object
readonly
Returns last alignment result.
Instance Method Summary collapse
-
#errorlog ⇒ Object
— Returns last error messages (to stderr) of CLUSTAL W execution.
-
#initialize(program = 'clustalw', opt = []) ⇒ ClustalW
constructor
Creates a new CLUSTAL W execution wrapper object (alignment factory).
-
#log ⇒ Object
This method will be deprecated.
-
#option ⇒ Object
option is deprecated.
-
#query(seqs) ⇒ Object
Executes the program(clustalw).
-
#query_align(seqs) ⇒ Object
Note that this method will be renamed to query_alignment.
-
#query_alignment(seqs) ⇒ Object
Performs alignment for
seqs
. -
#query_by_filename(path, *arg) ⇒ Object
Performs alignment of sequences in the file named
path
. -
#query_string(str, *arg) ⇒ Object
Performs alignment for
str
. -
#reset ⇒ Object
Clear the internal data and status, except program and options.
Constructor Details
#initialize(program = 'clustalw', opt = []) ⇒ ClustalW
Creates a new CLUSTAL W execution wrapper object (alignment factory).
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/bio/appl/clustalw.rb', line 41 def initialize(program = 'clustalw', opt = []) @program = program @options = opt @command = nil @output = nil @report = nil @data_stdout = nil @exit_status = nil @output_dnd = nil end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns last command-line strings executed by this factory. Note that filenames described in the command-line may already be removed because they are temporary files. Returns an array.
68 69 70 |
# File 'lib/bio/appl/clustalw.rb', line 68 def command @command end |
#data_stdout ⇒ Object
Last output to the stdout.
89 90 91 |
# File 'lib/bio/appl/clustalw.rb', line 89 def data_stdout @data_stdout end |
#exit_status ⇒ Object (readonly)
Last exit status
86 87 88 |
# File 'lib/bio/appl/clustalw.rb', line 86 def exit_status @exit_status end |
#output ⇒ Object (readonly)
Returns last raw alignment result (String or nil).
79 80 81 |
# File 'lib/bio/appl/clustalw.rb', line 79 def output @output end |
#output_dnd ⇒ Object (readonly)
Returns last alignment guild-tree (file.dnd).
189 190 191 |
# File 'lib/bio/appl/clustalw.rb', line 189 def output_dnd @output_dnd end |
#program ⇒ Object
name of the program (usually ‘clustalw’ in UNIX)
53 54 55 |
# File 'lib/bio/appl/clustalw.rb', line 53 def program @program end |
#report ⇒ Object (readonly)
Returns last alignment result. Returns a Bio::ClustalW::Report object.
83 84 85 |
# File 'lib/bio/appl/clustalw.rb', line 83 def report @report end |
Instance Method Details
#errorlog ⇒ Object
Returns last error messages (to stderr) of CLUSTAL W execution. attr_reader :errorlog +++ errorlog is deprecated (no replacement) and returns empty string.
196 197 198 199 |
# File 'lib/bio/appl/clustalw.rb', line 196 def errorlog warn "errorlog is deprecated (no replacement) and returns empty string." '' end |
#log ⇒ Object
This method will be deprecated.
Returns last messages of CLUSTAL W execution.
73 74 75 76 |
# File 'lib/bio/appl/clustalw.rb', line 73 def log #warn 'Bio::ClustalW#log will be deprecated.' @data_stdout end |
#option ⇒ Object
option is deprecated. Instead, please use options.
59 60 61 62 |
# File 'lib/bio/appl/clustalw.rb', line 59 def option warn "Bio::ClustalW#option is deprecated. Please use options." end |
#query(seqs) ⇒ Object
Executes the program(clustalw). If seqs
is not nil, perform alignment for seqs. If seqs
is nil, simply executes CLUSTAL W.
Compatibility note: When seqs is nil, returns true if the program exits normally, and returns false if the program exits abnormally.
108 109 110 111 112 113 114 115 |
# File 'lib/bio/appl/clustalw.rb', line 108 def query(seqs) if seqs then query_align(seqs) else exec_local(@options) @exit_status.exitstatus == 0 ? true : false end end |
#query_align(seqs) ⇒ Object
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: Nucleic or amino is not determined by this method.
123 124 125 126 127 128 129 |
# File 'lib/bio/appl/clustalw.rb', line 123 def query_align(seqs) unless seqs.is_a?(Bio::Alignment) seqs = Bio::Alignment.new(seqs) end query_string(seqs.output_fasta(:width => 70, :avoid_same_name => true)) end |
#query_alignment(seqs) ⇒ Object
Performs alignment for seqs
. seqs
should be Bio::Alignment or Array of sequences or nil.
133 134 135 |
# File 'lib/bio/appl/clustalw.rb', line 133 def query_alignment(seqs) query_align(seqs) end |
#query_by_filename(path, *arg) ⇒ Object
Performs alignment of sequences in the file named path
.
Compatibility Note: 2nd argument (seqtype) is deprecated and ignored.
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/bio/appl/clustalw.rb', line 159 def query_by_filename(path, *arg) if arg.size > 0 then warn '2nd argument of Bio::ClustalW#query_by_filename is ignored' end tf_out = Tempfile.open('clustalout') tf_out.close(false) tf_dnd = Tempfile.open('clustaldnd') tf_dnd.close(false) opt = [ "-align", "-infile=#{path}", "-outfile=#{tf_out.path}", "-newtree=#{tf_dnd.path}", "-outorder=input" ] #opt << "-type=#{seqtype}" if seqtype opt.concat(@options) exec_local(opt) tf_out.open @output = tf_out.read tf_out.close(true) tf_dnd.open @output_dnd = tf_dnd.read tf_dnd.close(true) @report = Report.new(@output) @report end |
#query_string(str, *arg) ⇒ Object
Performs alignment for str
. str
should be a string that can be recognized by CLUSTAL W.
Compatibility Note: 2nd argument is deprecated and ignored.
141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/bio/appl/clustalw.rb', line 141 def query_string(str, *arg) if arg.size > 0 then warn '2nd argument of Bio::ClustalW#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) tf_in.close(true) r end |
#reset ⇒ Object
Clear the internal data and status, except program and options.
92 93 94 95 96 97 98 99 |
# File 'lib/bio/appl/clustalw.rb', line 92 def reset @command = nil @output = nil @report = nil @exit_status = nil @data_stdout = nil @output_dnd = nil end |