class SequenceServer::BLAST::Formatter
Formats BLAST+ archive file format into other file formats.
Attributes
archive_file[R]
format[R]
mime[R]
specifiers[R]
type[R]
Public Class Methods
new(search_id, type)
click to toggle source
# File lib/sequenceserver/blast/formatter.rb, line 15 def initialize(search_id, type) @archive_file = get_archive_file search_id @format, @mime, @specifiers = OUTFMT[type] @type = type validate && run end
Public Instance Methods
file()
click to toggle source
# File lib/sequenceserver/blast/formatter.rb, line 27 def file @file ||= Tempfile.new filename end
filename()
click to toggle source
# File lib/sequenceserver/blast/formatter.rb, line 31 def filename @filename ||= "sequenceserver-#{type}_report.#{mime}" end
Private Instance Methods
get_archive_file(file)
click to toggle source
Returns filename if path exists otherwise returns a path to tmp dir.
# File lib/sequenceserver/blast/formatter.rb, line 59 def get_archive_file(file) return unless file return file.path if file.respond_to? :path return file if File.exist? file File.join Dir.tmpdir, file end
run()
click to toggle source
# File lib/sequenceserver/blast/formatter.rb, line 38 def run command = "blast_formatter -archive '#{archive_file}'" \ " -outfmt '#{format} #{specifiers}'" \ " -out '#{file.path}' 2> /dev/null" logger.debug("Executing: #{command}") Dir.chdir(File.exist?(DOTDIR) && DOTDIR || Dir.pwd) do system(command) end end
validate()
click to toggle source
# File lib/sequenceserver/blast/formatter.rb, line 49 def validate return true if archive_file && format && File.exist?(archive_file) fail ArgumentError, <<MSG Incorrect request parameters. Please ensure that requested file name is correct and the file type is either xml or tsv. MSG end