Class: Bio::BaseSpace::Sample

Inherits:
Model
  • Object
show all
Defined in:
lib/basespace/model/sample.rb

Overview

Representation of a BaseSpace Sample object.

Instance Attribute Summary

Attributes inherited from Model

#attributes, #swagger_types

Instance Method Summary collapse

Methods inherited from Model

#get_attr, #method_missing, #set_attr, #to_str

Constructor Details

#initializeSample

Return a new Sample instance.



25
26
27
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
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/basespace/model/sample.rb', line 25

def initialize
  @swagger_types = {
    'HrefGenome'      => 'str',
    'SampleNumber'    => 'int',
    'ExperimentName'  => 'str',
    'HrefFiles'       => 'str',
    # AppSession
    'IsPairedEnd'     => 'int',
    'Read1'           => 'int',
    'Read2'           => 'int',
    'NumReadsRaw'     => 'int',
    'NumReadsPF'      => 'int',
    'Id'              => 'str',
    'Href'            => 'str',
    'UserOwnedBy'     => 'UserCompact',
    'Name'            => 'str',
    'SampleId'        => 'str',
    'Status'          => 'str',
    'StatusSummary'   => 'str',
    'DateCreated'     => 'datetime',
    'References'      => 'dict',
    'Run'             => 'RunCompact',
  }
  @attributes = {
    'Name'            => nil, # str
    'HrefFiles'       => nil, # str
    'DateCreated'     => nil, # datetime
    'SampleNumber'    => nil, # int
    'Id'              => nil, # str
    'Href'            => nil, # str
    'UserOwnedBy'     => nil, # UserCompact
    'ExperimentName'  => nil, # str
    'Run'             => nil, # RunCompact
    'HrefGenome'      => nil, # str
    'IsPairedEnd'     => nil, # int
    'Read1'           => nil, # int
    'Read2'           => nil, # int
    'NumReadsRaw'     => nil, # int
    'NumReadsPF'      => nil, # int
    'References'      => nil, # dict
    'SampleId'        => nil, # dict
    'Status'          => nil, # dict
    'StatusSummary'   => nil, # dict
  }
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 sample.

scope

The scope type that is requested (write|read).



90
91
92
93
# File 'lib/basespace/model/sample.rb', line 90

def get_access_str(scope = 'write')
  is_init
  return scope + ' sample ' + get_attr('Id').to_s
end

#get_files(api, my_qp = {}) ⇒ Object

Returns a list of File objects.

api

BaseSpaceAPI instance.

my_qp

Query parameters to sort and filter the file list by.



117
118
119
120
121
# File 'lib/basespace/model/sample.rb', line 117

def get_files(api, my_qp = {})
  is_init
  query_pars = QueryParameters.new(my_qp)
  return api.get_files_by_sample(get_attr('Id'), query_pars)
end

#get_referenced_app_results(api) ⇒ Object

Return the AppResults referenced by this sample.

Note: the returned AppResult objects do not have their “References” field set, to get a fully populate AppResult object you must use getAppResultById in BaseSpaceAPI.

api

BaseSpaceAPI instance.



101
102
103
104
105
106
107
108
109
110
111
# File 'lib/basespace/model/sample.rb', line 101

def get_referenced_app_results(api)
  res = []
  get_attr('References').each do |s|
    if s[:type] == 'AppResult'
      json_app_result = s[:content]
      my_ar = api.serialize_object(json_app_result, 'AppResult')
      res << my_ar
    end
  end
  return res
end

#is_initObject

Test if the sample instance has been initialized.

Throws ModelNotInitializedError, if the Id variable is not set.



79
80
81
# File 'lib/basespace/model/sample.rb', line 79

def is_init
  raise ModelNotInitializedError.new('The sample model has not been initialized yet') unless get_attr('Id')
end

#to_sObject

Return the name of the sample.



72
73
74
# File 'lib/basespace/model/sample.rb', line 72

def to_s
  return get_attr('Name')
end