class SequenceServer::BLAST::Formatter

Formatter is invoked during report generation or for results download to convert BLAST+ archive file to other formats. Formatter generates output in Job#dir. Output files persist till the job itself is deleted. Calling Formatter a second time (for the same input job and output format) will return saved ouput.

Attributes

format[R]
job[R]
mime[R]
specifiers[R]
type[R]

Public Class Methods

new(job, type) click to toggle source
# File lib/sequenceserver/blast/formatter.rb, line 18
def initialize(job, type)
  @job = job
  @type = type

  @format, @mime, @specifiers = OUTFMT[type]
  run
end

Public Instance Methods

filename() click to toggle source
# File lib/sequenceserver/blast/formatter.rb, line 36
def filename
  @filename ||= "sequenceserver-#{type}_report.#{mime}"
end
filepath() click to toggle source
# File lib/sequenceserver/blast/formatter.rb, line 28
def filepath
  @filepath ||= File.join(job.dir, filename)
end
read_file() click to toggle source
# File lib/sequenceserver/blast/formatter.rb, line 40
def read_file
  File.read(filepath)
end
size() click to toggle source
# File lib/sequenceserver/blast/formatter.rb, line 32
def size
  File.size(filepath)
end

Private Instance Methods

run() click to toggle source
# File lib/sequenceserver/blast/formatter.rb, line 48
def run
  return if File.exist?(filepath)

  command = "blast_formatter -archive '#{job.stdout}'" \
    " -outfmt '#{format} #{specifiers}'"
  sys(command, path: config[:bin], dir: DOTDIR, stdout: filepath)
rescue CommandFailed => e
  # Mostly we will never get here: empty archive file,
  # file permissions, broken BLAST binaries, etc. will
  # have been caught before reaching here.
  raise SystemError, e.stderr
end