Module: SequenceServer::Sequence::Retriever::IO

Defined in:
lib/sequenceserver/sequence.rb

Overview

Provides IO for Retriever similar to BLAST::Formatter. We dynamically extend Retriever object with this module if file download has been requested (here it must be remembered that Retriever is used by sequence viewer and FASTA download links).

Instance Method Summary collapse

Instance Method Details

#fileObject

Returns handle to a temporary file to which data should be written to or read from.


122
123
124
# File 'lib/sequenceserver/sequence.rb', line 122

def file
  @file ||= Tempfile.new filename
end

#filenameObject

Returns a file name to use for the temporary file.


127
128
129
130
131
132
# File 'lib/sequenceserver/sequence.rb', line 127

def filename
  return @filename if @filename
  name = sequence_ids.first            if sequence_ids.length == 1
  name = "#{sequence_ids.length}_hits" if sequence_ids.length >= 2
  @filename = "sequenceserver-#{name}.fa"
end

#mimeObject

Returns mime type to use if this file were to be transferred over Internet.


136
137
138
# File 'lib/sequenceserver/sequence.rb', line 136

def mime
  :fasta
end