Class: Bio::BaseSpace::AppResult
- Defined in:
- lib/basespace/model/app_result.rb
Overview
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.
Instance Attribute Summary
Attributes inherited from Model
Instance Method Summary collapse
-
#get_access_str(scope = 'write') ⇒ Object
Returns the scope-string to be used for requesting BaseSpace access to the object.
-
#get_files(api, my_qp = {}) ⇒ Object
Returns a list of file objects in the result set.
-
#get_referenced_samples(api) ⇒ Object
Returns a list of sample objects references by the AppResult.
-
#get_referenced_samples_ids ⇒ Object
Return a list of sample IDs for the samples referenced.
-
#initialize ⇒ AppResult
constructor
Create a new AppResult instance.
-
#is_init ⇒ Object
Tests if the Project instance has been initialized.
-
#to_s ⇒ Object
Return the name of the AppResult.
-
#upload_file(api, local_path, file_name, directory, content_type) ⇒ Object
Uploads a local file to the BaseSpace AppResult.
Methods inherited from Model
#get_attr, #method_missing, #set_attr
Constructor Details
#initialize ⇒ AppResult
Create a new AppResult instance.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# 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 |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Bio::BaseSpace::Model
Instance Method Details
#get_access_str(scope = 'write') ⇒ Object
Returns the scope-string to be used for requesting BaseSpace access to the object.
scope
-
The scope-type that is request (write|read).
71 72 73 74 |
# 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 = {}) ⇒ Object
Returns a list of file objects in the result set.
api
-
BaseSpaceAPI instance.
my_qp
-
QueryParameters for sorting and filtering the file list.
122 123 124 125 126 |
# 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) ⇒ Object
Returns a list of sample objects references by the AppResult.
NOTE This method makes one request to REST server per sample.
api
-
BaseSpaceAPI instance.
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# 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 ⇒ Object
Return a list of sample IDs for the samples referenced.
84 85 86 87 88 89 90 91 92 93 94 |
# 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 ⇒ Object
Tests if the Project instance has been initialized.
Throws ModelNotInitializedError, if the instance has not been populated.
79 80 81 |
# 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 ⇒ Object
Return the name of the AppResult.
61 62 63 64 65 66 |
# 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) ⇒ Object
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.
135 136 137 138 |
# 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 |