Sha256: 50d6ec5ad25f7fd946684758231489b3012f2e0642a30f53d378efa304f90cd5
Contents?: true
Size: 1.62 KB
Versions: 7
Compression:
Stored size: 1.62 KB
Contents
require 'forwardable' module SequenceServer module BLAST # 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. class Formatter class << self alias run new end extend Forwardable def_delegators SequenceServer, :config, :sys def initialize(job, type) @job = job @type = type @format, @mime, @specifiers = OUTFMT[type] run end attr_reader :format, :mime, :specifiers def filepath @filepath ||= File.join(job.dir, filename) end def size File.size(filepath) end def filename @filename ||= "sequenceserver-#{type}_report.#{mime}" end def read_file File.read(filepath) end private attr_reader :job, :type 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 end end end # References # ---------- # [1]: http://www.ncbi.nlm.nih.gov/books/NBK1763/
Version data entries
7 entries across 7 versions & 1 rubygems