bio-basespace-sdk 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of bio-basespace-sdk might be problematic. Click here for more details.
- data/.document +5 -0
- data/.rspec +1 -0
- data/.travis.yml +11 -0
- data/Gemfile +16 -0
- data/License.txt +275 -0
- data/README.md +671 -0
- data/Rakefile +54 -0
- data/VERSION +1 -0
- data/examples/0_app_triggering.rb +135 -0
- data/examples/1_authentication.rb +156 -0
- data/examples/2_browsing.rb +84 -0
- data/examples/3_accessing_files.rb +129 -0
- data/examples/4_app_result_upload.rb +102 -0
- data/examples/5_purchasing.rb +119 -0
- data/lib/basespace.rb +126 -0
- data/lib/basespace/api/api_client.rb +313 -0
- data/lib/basespace/api/base_api.rb +242 -0
- data/lib/basespace/api/basespace_api.rb +789 -0
- data/lib/basespace/api/basespace_error.rb +80 -0
- data/lib/basespace/api/billing_api.rb +115 -0
- data/lib/basespace/model.rb +78 -0
- data/lib/basespace/model/app_result.rb +158 -0
- data/lib/basespace/model/app_result_response.rb +40 -0
- data/lib/basespace/model/app_session.rb +99 -0
- data/lib/basespace/model/app_session_compact.rb +43 -0
- data/lib/basespace/model/app_session_launch_object.rb +58 -0
- data/lib/basespace/model/app_session_response.rb +41 -0
- data/lib/basespace/model/application.rb +47 -0
- data/lib/basespace/model/application_compact.rb +44 -0
- data/lib/basespace/model/basespace_model.rb +60 -0
- data/lib/basespace/model/coverage.rb +48 -0
- data/lib/basespace/model/coverage_meta_response.rb +40 -0
- data/lib/basespace/model/coverage_metadata.rb +43 -0
- data/lib/basespace/model/coverage_response.rb +40 -0
- data/lib/basespace/model/file.rb +172 -0
- data/lib/basespace/model/file_response.rb +40 -0
- data/lib/basespace/model/genome_response.rb +40 -0
- data/lib/basespace/model/genome_v1.rb +56 -0
- data/lib/basespace/model/list_response.rb +53 -0
- data/lib/basespace/model/multipart_upload.rb +288 -0
- data/lib/basespace/model/product.rb +50 -0
- data/lib/basespace/model/project.rb +103 -0
- data/lib/basespace/model/project_response.rb +40 -0
- data/lib/basespace/model/purchase.rb +89 -0
- data/lib/basespace/model/purchase_response.rb +39 -0
- data/lib/basespace/model/purchased_product.rb +56 -0
- data/lib/basespace/model/query_parameters.rb +86 -0
- data/lib/basespace/model/query_parameters_purchased_product.rb +67 -0
- data/lib/basespace/model/refund_purchase_response.rb +40 -0
- data/lib/basespace/model/resource_list.rb +48 -0
- data/lib/basespace/model/response_status.rb +42 -0
- data/lib/basespace/model/run_compact.rb +55 -0
- data/lib/basespace/model/sample.rb +127 -0
- data/lib/basespace/model/sample_response.rb +40 -0
- data/lib/basespace/model/user.rb +80 -0
- data/lib/basespace/model/user_compact.rb +45 -0
- data/lib/basespace/model/user_response.rb +40 -0
- data/lib/basespace/model/variant.rb +57 -0
- data/lib/basespace/model/variant_header.rb +44 -0
- data/lib/basespace/model/variant_info.rb +48 -0
- data/lib/basespace/model/variants_header_response.rb +40 -0
- data/spec/basespaceapi_spec.rb +26 -0
- data/spec/basespaceerror_spec.rb +87 -0
- data/spec/basespacemodel_spec.rb +57 -0
- metadata +239 -0
@@ -0,0 +1,55 @@
|
|
1
|
+
# Copyright 2013 Toshiaki Katayama, Joachim Baran
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
#
|
8
|
+
# Unless required by applicable law or agreed to in writing, software
|
9
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
10
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
11
|
+
# See the License for the specific language governing permissions and
|
12
|
+
# limitations under the License.
|
13
|
+
|
14
|
+
require 'basespace/model'
|
15
|
+
|
16
|
+
module Bio
|
17
|
+
module BaseSpace
|
18
|
+
|
19
|
+
# Run compact model.
|
20
|
+
class RunCompact < Model
|
21
|
+
|
22
|
+
# Create a new RunCompact instance.
|
23
|
+
def initialize
|
24
|
+
@swagger_types = {
|
25
|
+
'DateCreated' => 'datetime',
|
26
|
+
'Id' => 'str',
|
27
|
+
'Href' => 'str',
|
28
|
+
'ExperimentName' => 'str',
|
29
|
+
}
|
30
|
+
@attributes = {
|
31
|
+
'DateCreated' => nil, # datetime
|
32
|
+
'Id' => nil, # str
|
33
|
+
'Href' => nil, # str
|
34
|
+
'ExperimentName' => nil, # str
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
# Return the experiment name.
|
39
|
+
def to_s
|
40
|
+
return get_attr('ExperimentName')
|
41
|
+
end
|
42
|
+
|
43
|
+
# Returns the scope-string to used for requesting BaseSpace access to the object.
|
44
|
+
#
|
45
|
+
# +scope+:: The type that is requested (write|read).
|
46
|
+
def get_access_str(scope = 'write')
|
47
|
+
is_init
|
48
|
+
return scope + ' run ' + get_attr('Id').to_s
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end # module BaseSpace
|
54
|
+
end # module Bio
|
55
|
+
|
@@ -0,0 +1,127 @@
|
|
1
|
+
# Copyright 2013 Toshiaki Katayama, Joachim Baran
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
#
|
8
|
+
# Unless required by applicable law or agreed to in writing, software
|
9
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
10
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
11
|
+
# See the License for the specific language governing permissions and
|
12
|
+
# limitations under the License.
|
13
|
+
|
14
|
+
require 'basespace/api/basespace_error'
|
15
|
+
require 'basespace/model'
|
16
|
+
require 'basespace/model/query_parameters'
|
17
|
+
|
18
|
+
module Bio
|
19
|
+
module BaseSpace
|
20
|
+
|
21
|
+
# Representation of a BaseSpace Sample object.
|
22
|
+
class Sample < Model
|
23
|
+
|
24
|
+
# Return a new Sample instance.
|
25
|
+
def initialize
|
26
|
+
@swagger_types = {
|
27
|
+
'HrefGenome' => 'str',
|
28
|
+
'SampleNumber' => 'int',
|
29
|
+
'ExperimentName' => 'str',
|
30
|
+
'HrefFiles' => 'str',
|
31
|
+
# AppSession
|
32
|
+
'IsPairedEnd' => 'int',
|
33
|
+
'Read1' => 'int',
|
34
|
+
'Read2' => 'int',
|
35
|
+
'NumReadsRaw' => 'int',
|
36
|
+
'NumReadsPF' => 'int',
|
37
|
+
'Id' => 'str',
|
38
|
+
'Href' => 'str',
|
39
|
+
'UserOwnedBy' => 'UserCompact',
|
40
|
+
'Name' => 'str',
|
41
|
+
'SampleId' => 'str',
|
42
|
+
'Status' => 'str',
|
43
|
+
'StatusSummary' => 'str',
|
44
|
+
'DateCreated' => 'datetime',
|
45
|
+
'References' => 'dict',
|
46
|
+
'Run' => 'RunCompact',
|
47
|
+
}
|
48
|
+
@attributes = {
|
49
|
+
'Name' => nil, # str
|
50
|
+
'HrefFiles' => nil, # str
|
51
|
+
'DateCreated' => nil, # datetime
|
52
|
+
'SampleNumber' => nil, # int
|
53
|
+
'Id' => nil, # str
|
54
|
+
'Href' => nil, # str
|
55
|
+
'UserOwnedBy' => nil, # UserCompact
|
56
|
+
'ExperimentName' => nil, # str
|
57
|
+
'Run' => nil, # RunCompact
|
58
|
+
'HrefGenome' => nil, # str
|
59
|
+
'IsPairedEnd' => nil, # int
|
60
|
+
'Read1' => nil, # int
|
61
|
+
'Read2' => nil, # int
|
62
|
+
'NumReadsRaw' => nil, # int
|
63
|
+
'NumReadsPF' => nil, # int
|
64
|
+
'References' => nil, # dict
|
65
|
+
'SampleId' => nil, # dict
|
66
|
+
'Status' => nil, # dict
|
67
|
+
'StatusSummary' => nil, # dict
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
71
|
+
# Return the name of the sample.
|
72
|
+
def to_s
|
73
|
+
return get_attr('Name')
|
74
|
+
end
|
75
|
+
|
76
|
+
# Test if the sample instance has been initialized.
|
77
|
+
#
|
78
|
+
# Throws ModelNotInitializedError, if the Id variable is not set.
|
79
|
+
def is_init
|
80
|
+
raise ModelNotInitializedError.new('The sample model has not been initialized yet') unless get_attr('Id')
|
81
|
+
end
|
82
|
+
|
83
|
+
#def get_genome
|
84
|
+
# pass
|
85
|
+
#end
|
86
|
+
|
87
|
+
# Returns the scope-string to be used for requesting BaseSpace access to the sample.
|
88
|
+
#
|
89
|
+
# +scope+:: The scope type that is requested (write|read).
|
90
|
+
def get_access_str(scope = 'write')
|
91
|
+
is_init
|
92
|
+
return scope + ' sample ' + get_attr('Id').to_s
|
93
|
+
end
|
94
|
+
|
95
|
+
# Return the AppResults referenced by this sample.
|
96
|
+
#
|
97
|
+
# Note: the returned AppResult objects do not have their "References" field set,
|
98
|
+
# to get a fully populate AppResult object you must use getAppResultById in BaseSpaceAPI.
|
99
|
+
#
|
100
|
+
# +api+:: BaseSpaceAPI instance.
|
101
|
+
def get_referenced_app_results(api)
|
102
|
+
res = []
|
103
|
+
get_attr('References').each do |s|
|
104
|
+
if s[:type] == 'AppResult'
|
105
|
+
json_app_result = s[:content]
|
106
|
+
my_ar = api.serialize_object(json_app_result, 'AppResult')
|
107
|
+
res << my_ar
|
108
|
+
end
|
109
|
+
end
|
110
|
+
return res
|
111
|
+
end
|
112
|
+
|
113
|
+
# Returns a list of File objects.
|
114
|
+
#
|
115
|
+
# +api+:: BaseSpaceAPI instance.
|
116
|
+
# +my_qp+:: Query parameters to sort and filter the file list by.
|
117
|
+
def get_files(api, my_qp = {})
|
118
|
+
is_init
|
119
|
+
query_pars = QueryParameters.new(my_qp)
|
120
|
+
return api.get_files_by_sample(get_attr('Id'), query_pars)
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
end # module BaseSpace
|
126
|
+
end # module Bio
|
127
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# Copyright 2013 Toshiaki Katayama, Joachim Baran
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
#
|
8
|
+
# Unless required by applicable law or agreed to in writing, software
|
9
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
10
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
11
|
+
# See the License for the specific language governing permissions and
|
12
|
+
# limitations under the License.
|
13
|
+
|
14
|
+
require 'basespace/model'
|
15
|
+
|
16
|
+
module Bio
|
17
|
+
module BaseSpace
|
18
|
+
|
19
|
+
# Sample response model.
|
20
|
+
class SampleResponse < Model
|
21
|
+
|
22
|
+
# Create a new SampleResponse instance.
|
23
|
+
def initialize
|
24
|
+
@swagger_types = {
|
25
|
+
'ResponseStatus' => 'ResponseStatus',
|
26
|
+
'Response' => 'Sample',
|
27
|
+
'Notifications' => 'list<Str>',
|
28
|
+
}
|
29
|
+
@attributes = {
|
30
|
+
'ResponseStatus' => nil, # ResponseStatus
|
31
|
+
'Response' => nil, # Sample
|
32
|
+
'Notifications' => nil, # list<Str>
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end # module BaseSpace
|
39
|
+
end # module Bio
|
40
|
+
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# Copyright 2013 Toshiaki Katayama, Joachim Baran
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
#
|
8
|
+
# Unless required by applicable law or agreed to in writing, software
|
9
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
10
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
11
|
+
# See the License for the specific language governing permissions and
|
12
|
+
# limitations under the License.
|
13
|
+
|
14
|
+
require 'basespace/api/basespace_error'
|
15
|
+
require 'basespace/model'
|
16
|
+
|
17
|
+
module Bio
|
18
|
+
module BaseSpace
|
19
|
+
|
20
|
+
# User model.
|
21
|
+
class User < Model
|
22
|
+
|
23
|
+
# Create a new User instance.
|
24
|
+
def initialize
|
25
|
+
@swagger_types = {
|
26
|
+
'Name' => 'str',
|
27
|
+
'Email' => 'str',
|
28
|
+
'DateLastActive' => 'datetime',
|
29
|
+
'GravatarUrl' => 'str',
|
30
|
+
'HrefProjects' => 'str',
|
31
|
+
'DateCreated' => 'datetime',
|
32
|
+
'Id' => 'str',
|
33
|
+
'Href' => 'str',
|
34
|
+
'HrefRuns' => 'str',
|
35
|
+
}
|
36
|
+
@attributes = {
|
37
|
+
'Name' => nil, # str
|
38
|
+
'Email' => nil, # str
|
39
|
+
'DateLastActive' => nil, # datetime
|
40
|
+
'GravatarUrl' => nil, # str
|
41
|
+
'HrefProjects' => nil, # str
|
42
|
+
'DateCreated' => nil, # datetime
|
43
|
+
'Id' => nil, # str
|
44
|
+
'Href' => nil, # str
|
45
|
+
'HrefRuns' => nil, # str
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
# Return the ID and name of the user as string.
|
50
|
+
def to_s
|
51
|
+
return "#{get_attr('Id')}: #{get_attr('Name')}"
|
52
|
+
end
|
53
|
+
|
54
|
+
# Test if the Project instance has been initialized.
|
55
|
+
#
|
56
|
+
# Throws ModelNotInitializedError, if the Id variable is not set.
|
57
|
+
def is_init
|
58
|
+
raise ModelNotInitializedError.new('The user model has not been initialized yet') unless get_attr('Id')
|
59
|
+
end
|
60
|
+
|
61
|
+
# Get a list of projects for the user.
|
62
|
+
#
|
63
|
+
# +api+:: BaseSpaceAPI instance.
|
64
|
+
def get_projects(api)
|
65
|
+
is_init
|
66
|
+
return api.get_project_by_user(get_attr('Id'))
|
67
|
+
end
|
68
|
+
|
69
|
+
# Returns a list of accessible runs for the current user.
|
70
|
+
#
|
71
|
+
# +api+:: BaseSpaceAPI instance.
|
72
|
+
def get_runs(api)
|
73
|
+
is_init
|
74
|
+
return api.get_accessible_runs_by_user('current')
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
end # module BaseSpace
|
79
|
+
end # module Bio
|
80
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# Copyright 2013 Toshiaki Katayama, Joachim Baran
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
#
|
8
|
+
# Unless required by applicable law or agreed to in writing, software
|
9
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
10
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
11
|
+
# See the License for the specific language governing permissions and
|
12
|
+
# limitations under the License.
|
13
|
+
|
14
|
+
require 'basespace/model'
|
15
|
+
|
16
|
+
module Bio
|
17
|
+
module BaseSpace
|
18
|
+
|
19
|
+
# User compact model.
|
20
|
+
class UserCompact < Model
|
21
|
+
|
22
|
+
# Return a new UserCompact instance.
|
23
|
+
def initialize
|
24
|
+
@swagger_types = {
|
25
|
+
'Name' => 'str',
|
26
|
+
'Id' => 'str',
|
27
|
+
'Href' => 'str',
|
28
|
+
}
|
29
|
+
@attributes = {
|
30
|
+
'Name' => nil, # str
|
31
|
+
'Id' => nil, # str
|
32
|
+
'Href' => nil, # str
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
# Return the user ID and name as string.
|
37
|
+
def to_s
|
38
|
+
return "#{get_attr('Id')}: #{get_attr('Name')}"
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end # module BaseSpace
|
44
|
+
end # module Bio
|
45
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# Copyright 2013 Toshiaki Katayama, Joachim Baran
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
#
|
8
|
+
# Unless required by applicable law or agreed to in writing, software
|
9
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
10
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
11
|
+
# See the License for the specific language governing permissions and
|
12
|
+
# limitations under the License.
|
13
|
+
|
14
|
+
require 'basespace/model'
|
15
|
+
|
16
|
+
module Bio
|
17
|
+
module BaseSpace
|
18
|
+
|
19
|
+
# User response model.
|
20
|
+
class UserResponse < Model
|
21
|
+
|
22
|
+
# Create a new UserResponse instance.
|
23
|
+
def initialize
|
24
|
+
@swagger_types = {
|
25
|
+
'ResponseStatus' => 'ResponseStatus',
|
26
|
+
'Response' => 'User',
|
27
|
+
'Notifications' => 'list<Str>',
|
28
|
+
}
|
29
|
+
@attributes = {
|
30
|
+
'ResponseStatus' => nil, # ResponseStatus
|
31
|
+
'Response' => nil, # User
|
32
|
+
'Notifications' => nil, # list<Str>
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end # module BaseSpace
|
39
|
+
end # module Bio
|
40
|
+
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# Copyright 2013 Toshiaki Katayama, Joachim Baran
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
#
|
8
|
+
# Unless required by applicable law or agreed to in writing, software
|
9
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
10
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
11
|
+
# See the License for the specific language governing permissions and
|
12
|
+
# limitations under the License.
|
13
|
+
|
14
|
+
require 'basespace/model'
|
15
|
+
|
16
|
+
module Bio
|
17
|
+
module BaseSpace
|
18
|
+
|
19
|
+
# Variant model.
|
20
|
+
class Variant < Model
|
21
|
+
|
22
|
+
# Create a new Variant instance.
|
23
|
+
def initialize
|
24
|
+
@swagger_types = {
|
25
|
+
'CHROM' => 'str',
|
26
|
+
'ALT' => 'str',
|
27
|
+
'ID' => 'list<Str>',
|
28
|
+
'SampleFormat' => 'dict',
|
29
|
+
'FILTER' => 'str',
|
30
|
+
'INFO' => 'dict',
|
31
|
+
'POS' => 'int',
|
32
|
+
'QUAL' => 'int',
|
33
|
+
'REF' => 'str',
|
34
|
+
}
|
35
|
+
@attributes = {
|
36
|
+
'CHROM' => nil,
|
37
|
+
'ALT' => nil,
|
38
|
+
'ID' => nil,
|
39
|
+
'SampleFormat' => nil,
|
40
|
+
'FILTER' => nil,
|
41
|
+
'INFO' => nil,
|
42
|
+
'POS' => nil,
|
43
|
+
'QUAL' => nil,
|
44
|
+
'REF' => nil,
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
# Return the genomic coordinate and ID of the variant as string.
|
49
|
+
def to_s
|
50
|
+
return "Variant - #{get_attr('CHROM')}: #{get_attr('POS')} id=#{get_attr('Id')}"
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end # module BaseSpace
|
56
|
+
end # module Bio
|
57
|
+
|