Class: Bio::ClustalW

Inherits:
Object show all
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)

Instance Method Summary (collapse)

Constructor Details

- (ClustalW) initialize(program = 'clustalw', opt = [])

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

- (Object) command (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

- (Object) data_stdout

Last output to the stdout.



89
90
91
# File 'lib/bio/appl/clustalw.rb', line 89

def data_stdout
  @data_stdout
end

- (Object) exit_status (readonly)

Last exit status



86
87
88
# File 'lib/bio/appl/clustalw.rb', line 86

def exit_status
  @exit_status
end

- (Object) options

options



56
57
58
# File 'lib/bio/appl/clustalw.rb', line 56

def options
  @options
end

- (Object) output (readonly)

Returns last raw alignment result (String or nil).



79
80
81
# File 'lib/bio/appl/clustalw.rb', line 79

def output
  @output
end

- (Object) output_dnd (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

- (Object) program

name of the program (usually 'clustalw' in UNIX)



53
54
55
# File 'lib/bio/appl/clustalw.rb', line 53

def program
  @program
end

- (Object) report (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

- (Object) errorlog


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

- (Object) log

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

- (Object) option

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."
  options
end

- (Object) query(seqs)

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

- (Object) query_align(seqs)

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

- (Object) query_alignment(seqs)

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

- (Object) query_by_filename(path, *arg)

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

- (Object) query_string(str, *arg)

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

- (Object) reset

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