class Bio::Sim4

The sim4 execution wrapper class.

Attributes

command[R]

last command-line strings executed by the object

database[RW]

default file name of database('seq2')

options[RW]

options

output[R]

last result text (String)

program[R]

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

report[R]

last result. Returns a Bio::Sim4::Report object.

Public Class Methods

new(program = 'sim4', database = nil, opt = []) click to toggle source

Creates a new sim4 execution wrapper object.

program

Program name. Usually 'sim4' in UNIX.

database

Default file name of database('seq2').

option

Options (array of strings).

# File lib/bio/appl/sim4.rb, line 32
def initialize(program = 'sim4', database = nil, opt = [])
  @program = program
  @options = opt
  @database = database #seq2
  @command = nil
  @output = nil
  @report = nil
end

Public Instance Methods

exec(filename1, filename2 = nil)
Alias for: exec_local
exec_local(filename1, filename2 = nil) click to toggle source

Executes the sim4 program. Perform mRNA-genome alignment between sequences in given files. filename1 and filename2 should be file name strings. If filename2 is not specified, using self.database.

# File lib/bio/appl/sim4.rb, line 109
def exec_local(filename1, filename2 = nil)
  @command = [ @program, filename1, (filename2 or @database), *@options ]
  @output = nil
  @report = nil
  Bio::Command.call_command(@command) do |io|
    io.close_write
    @output = io.read
    @report = Bio::Sim4::Report.new(@output)
  end
  @report
end
Also aliased as: exec
log() click to toggle source

log is deprecated (no replacement) and returns empty string.

# File lib/bio/appl/sim4.rb, line 65
def log
  warn "log is deprecated (no replacement) and returns empty string."
  ''
end
option() click to toggle source

option is deprecated. Instead, please use options.

# File lib/bio/appl/sim4.rb, line 51
def option
  warn "option is deprecated. Please use options."
  options
end
query(seq1) click to toggle source

Executes the sim4 program. seq1 shall be a Bio::Sequence object. Returns a Bio::Sim4::Report object.

# File lib/bio/appl/sim4.rb, line 79
def query(seq1)
  tf = Tempfile.open('sim4')
  tf.print seq1.to_fasta('seq1', 70)
  tf.close(false)
  r = exec_local(tf.path)
  tf.close(true)
  r
end
query_pairwise(seq1, seq2) click to toggle source

Executes the sim4 program. Perform mRNA-genome alignment between given sequences. seq1 and seq2 should be Bio::Sequence objects. Returns a Bio::Sim4::Report object.

# File lib/bio/appl/sim4.rb, line 92
def query_pairwise(seq1, seq2)
  tf = Tempfile.open('sim4')
  tf.print seq1.to_fasta('seq1', 70)
  tf.close(false)
  tf2 = Tempfile.open('seq2')
  tf2.print seq1.to_fasta('seq2', 70)
  tf2.close(false)
  r = exec_local(tf.path, tf2.path)
  tf.close(true)
  tf2.close(true)
  r
end