class Bio::BaseSpace::AppResult

Contains the files that are output by an App.

App results are usually BAM or VCF files, even though other file types may also be provided.

Public Class Methods

new() click to toggle source

Create a new AppResult instance.

# File lib/basespace/model/app_result.rb, line 28
def initialize
  @swagger_types = {
    'Name'           => 'str',
    #'Status'        => 'str',        # will be deprecated
    'Description'    => 'str',
    'StatusSummary'  => 'str',
    'HrefFiles'      => 'str',
    'DateCreated'    => 'datetime',
    'Id'             => 'str',
    'Href'           => 'str',
    'UserOwnedBy'    => 'UserCompact',
    'StatusDetail'   => 'str',
    'HrefGenome'     => 'str',
    'AppSession'     => 'AppSession',
    'References'     => 'dict',
  }
  @attributes = {
    'Name'           => nil,
    'Description'    => nil,
    'StatusSummary'  => nil,
    'HrefFiles'      => nil,
    'DateCreated'    => nil,
    'Id'             => nil,
    'Href'           => nil,
    'UserOwnedBy'    => nil, # UserCompact
    'StatusDetail'   => nil,
    'HrefGenome'     => nil,
    'AppSession'     => nil, # AppSession
    'References'     => nil,
  }
end

Public Instance Methods

get_access_str(scope = 'write') click to toggle source

Returns the scope-string to be used for requesting BaseSpace access to the object.

scope

The scope-type that is request (write|read).

# File lib/basespace/model/app_result.rb, line 71
def get_access_str(scope = 'write')
  is_init
  return "#{scope} appresult #{get_attr('Id')}"
end
get_files(api, my_qp = {}) click to toggle source

Returns a list of file objects in the result set.

api

BaseSpaceAPI instance.

my_qp

QueryParameters for sorting and filtering the file list.

# File lib/basespace/model/app_result.rb, line 122
def get_files(api, my_qp = {})
  is_init
  query_pars = QueryParameters.new(my_qp)
  return api.get_app_result_files(get_attr('Id'), query_pars)
end
get_referenced_samples(api) click to toggle source

Returns a list of sample objects references by the AppResult.

NOTE This method makes one request to REST server per sample.

api

BaseSpaceAPI instance.

# File lib/basespace/model/app_result.rb, line 101
def get_referenced_samples(api)
  res = []
  ids = get_referenced_samples_ids
  ids.each do |id|
    begin
      sample = api.get_sample_by_id(id)
      res << sample
    rescue => err
      # [TODO] What to do with this 'err'?
      $stderr.puts "    # ----- AppResult#get_referenced_samples ----- "
      $stderr.puts "    # Error: #{err}"
      $stderr.puts "    # "
    end
  end
  return res
end
get_referenced_samples_ids() click to toggle source

Return a list of sample IDs for the samples referenced.

# File lib/basespace/model/app_result.rb, line 84
def get_referenced_samples_ids
  res= []
  get_attr('References').each do |s|
    # [TODO] check this Hash contains the key :type (or should we use 'Type'?)
    if s[:type] == 'Sample'
      id = s[:href_content].split('/').last
      res << id
    end
  end
  return res
end
is_init() click to toggle source

Tests if the Project instance has been initialized.

Throws ModelNotInitializedError, if the instance has not been populated.

# File lib/basespace/model/app_result.rb, line 79
def is_init
  raise ModelNotInitializedError.new('The AppResult model has not been initialized yet') unless get_attr('Id')
end
to_s() click to toggle source

Return the name of the AppResult.

# File lib/basespace/model/app_result.rb, line 61
def to_s
  # NOTE Simplified in Ruby to align with the Sample class.
  #      See example 3_accessing_files.rb (3_AccessingFiles.py)
  #return "AppResult: #{get_attr('Name')}" #+ " - #{get_attr('Status')"
  return get_attr('Name')
end
upload_file(api, local_path, file_name, directory, content_type) click to toggle source

Uploads a local file to the BaseSpace AppResult.

api

BaseSpaceAPI instance.

local_path: Local path of the file.

file_name

Filename.

directory: The remote directory that the file is uploaded to.

+param content_type+

Content-type of the file.

# File lib/basespace/model/app_result.rb, line 135
def upload_file(api, local_path, file_name, directory, content_type)
  is_init
  return api.app_result_file_upload(get_attr('Id'), local_path, file_name, directory, content_type)
end