bio-basespace-sdk 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
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
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.travis.yml
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 1.9.2
|
4
|
+
- 1.9.3
|
5
|
+
- jruby-19mode # JRuby in 1.9 mode
|
6
|
+
- rbx-19mode
|
7
|
+
- 1.8.7
|
8
|
+
- jruby-18mode # JRuby in 1.8 mode
|
9
|
+
|
10
|
+
# uncomment this line if your project needs to run something other than `rake`:
|
11
|
+
# script: bundle exec rspec spec
|
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
gem "getopt", ">= 1.4.1"
|
6
|
+
gem "addressable", ">= 2.3.2"
|
7
|
+
|
8
|
+
# Add dependencies to develop your gem here.
|
9
|
+
# Include everything needed to run rake, tests, features, etc.
|
10
|
+
group :development do
|
11
|
+
gem "rspec", "~> 2.8.0"
|
12
|
+
gem "bundler", ">= 1.1.5"
|
13
|
+
gem "jeweler", "~> 1.8.4"
|
14
|
+
gem "bio", ">= 1.4.2"
|
15
|
+
gem "rdoc", "~> 3.12"
|
16
|
+
end
|
data/License.txt
ADDED
@@ -0,0 +1,275 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
190
|
+
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
+
you may not use this file except in compliance with the License.
|
193
|
+
You may obtain a copy of the License at
|
194
|
+
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
+
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
+
See the License for the specific language governing permissions and
|
201
|
+
limitations under the License.
|
202
|
+
|
203
|
+
COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL)Version 1.1
|
204
|
+
1. Definitions.
|
205
|
+
1.1. "Contributor" means each individual or entity that creates or contributes to the creation of Modifications.
|
206
|
+
1.2. "Contributor Version" means the combination of the Original Software, prior Modifications used by a Contributor (if any), and the Modifications made by that particular Contributor.
|
207
|
+
1.3. "Covered Software" means (a) the Original Software, or (b) Modifications, or (c) the combination of files containing Original Software with files containing Modifications, in each case including portions thereof.
|
208
|
+
1.4. "Executable" means the Covered Software in any form other than Source Code.
|
209
|
+
1.5. "Initial Developer" means the individual or entity that first makes Original Software available under this License.
|
210
|
+
1.6. "Larger Work" means a work which combines Covered Software or portions thereof with code not governed by the terms of this License.
|
211
|
+
1.7. "License" means this document.
|
212
|
+
1.8. "Licensable" means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently acquired, any and all of the rights conveyed herein.
|
213
|
+
1.9. "Modifications" means the Source Code and Executable form of any of the following:
|
214
|
+
A. Any file that results from an addition to, deletion from or modification of the contents of a file containing Original Software or previous Modifications;
|
215
|
+
B. Any new file that contains any part of the Original Software or previous Modification; or
|
216
|
+
C. Any new file that is contributed or otherwise made available under the terms of this License.
|
217
|
+
1.10. "Original Software" means the Source Code and Executable form of computer software code that is originally released under this License.
|
218
|
+
1.11. "Patent Claims" means any patent claim(s), now owned or hereafter acquired, including without limitation, method, process, and apparatus claims, in any patent Licensable by grantor.
|
219
|
+
1.12. "Source Code" means (a) the common form of computer software code in which modifications are made and (b) associated documentation included in or with such code.
|
220
|
+
1.13. "You" (or "Your") means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, "control" means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity.
|
221
|
+
2. License Grants.
|
222
|
+
2.1. The Initial Developer Grant.
|
223
|
+
Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, the Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license:
|
224
|
+
(a) under intellectual property rights (other than patent or trademark) Licensable by Initial Developer, to use, reproduce, modify, display, perform, sublicense and distribute the Original Software (or portions thereof), with or without Modifications, and/or as part of a Larger Work; and
|
225
|
+
(b) under Patent Claims infringed by the making, using or selling of Original Software, to make, have made, use, practice, sell, and offer for sale, and/or otherwise dispose of the Original Software (or portions thereof).
|
226
|
+
(c) The licenses granted in Sections 2.1(a) and (b) are effective on the date Initial Developer first distributes or otherwise makes the Original Software available to a third party under the terms of this License.
|
227
|
+
(d) Notwithstanding Section 2.1(b) above, no patent license is granted: (1) for code that You delete from the Original Software, or (2) for infringements caused by: (i) the modification of the Original Software, or (ii) the combination of the Original Software with other software or devices.
|
228
|
+
2.2. Contributor Grant.
|
229
|
+
Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license:
|
230
|
+
(a) under intellectual property rights (other than patent or trademark) Licensable by Contributor to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof), either on an unmodified basis, with other Modifications, as Covered Software and/or as part of a Larger Work; and
|
231
|
+
(b) under Patent Claims infringed by the making, using, or selling of Modifications made by that Contributor either alone and/or in combination with its Contributor Version (or portions of such combination), to make, use, sell, offer for sale, have made, and/or otherwise dispose of: (1) Modifications made by that Contributor (or portions thereof); and (2) the combination of Modifications made by that Contributor with its Contributor Version (or portions of such combination).
|
232
|
+
(c) The licenses granted in Sections 2.2(a) and 2.2(b) are effective on the date Contributor first distributes or otherwise makes the Modifications available to a third party.
|
233
|
+
(d) Notwithstanding Section 2.2(b) above, no patent license is granted: (1) for any code that Contributor has deleted from the Contributor Version; (2) for infringements caused by: (i) third party modifications of Contributor Version, or (ii) the combination of Modifications made by that Contributor with other software (except as part of the Contributor Version) or other devices; or (3) under Patent Claims infringed by Covered Software in the absence of Modifications made by that Contributor.
|
234
|
+
3. Distribution Obligations.
|
235
|
+
3.1. Availability of Source Code.
|
236
|
+
Any Covered Software that You distribute or otherwise make available in Executable form must also be made available in Source Code form and that Source Code form must be distributed only under the terms of this License. You must include a copy of this License with every copy of the Source Code form of the Covered Software You distribute or otherwise make available. You must inform recipients of any such Covered Software in Executable form as to how they can obtain such Covered Software in Source Code form in a reasonable manner on or through a medium customarily used for software exchange.
|
237
|
+
3.2. Modifications.
|
238
|
+
The Modifications that You create or to which You contribute are governed by the terms of this License. You represent that You believe Your Modifications are Your original creation(s) and/or You have sufficient rights to grant the rights conveyed by this License.
|
239
|
+
3.3. Required Notices.
|
240
|
+
You must include a notice in each of Your Modifications that identifies You as the Contributor of the Modification. You may not remove or alter any copyright, patent or trademark notices contained within the Covered Software, or any notices of licensing or any descriptive text giving attribution to any Contributor or the Initial Developer.
|
241
|
+
3.4. Application of Additional Terms.
|
242
|
+
You may not offer or impose any terms on any Covered Software in Source Code form that alters or restricts the applicable version of this License or the recipients' rights hereunder. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, you may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear that any such warranty, support, indemnity or liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability terms You offer.
|
243
|
+
3.5. Distribution of Executable Versions.
|
244
|
+
You may distribute the Executable form of the Covered Software under the terms of this License or under the terms of a license of Your choice, which may contain terms different from this License, provided that You are in compliance with the terms of this License and that the license for the Executable form does not attempt to limit or alter the recipient's rights in the Source Code form from the rights set forth in this License. If You distribute the Covered Software in Executable form under a different license, You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer or Contributor. You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of any such terms You offer.
|
245
|
+
3.6. Larger Works.
|
246
|
+
You may create a Larger Work by combining Covered Software with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Software.
|
247
|
+
4. Versions of the License.
|
248
|
+
4.1. New Versions.
|
249
|
+
Oracle is the initial license steward and may publish revised and/or new versions of this License from time to time. Each version will be given a distinguishing version number. Except as provided in Section 4.3, no one other than the license steward has the right to modify this License.
|
250
|
+
4.2. Effect of New Versions.
|
251
|
+
You may always continue to use, distribute or otherwise make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. If the Initial Developer includes a notice in the Original Software prohibiting it from being distributed or otherwise made available under any subsequent version of the License, You must distribute and make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. Otherwise, You may also choose to use, distribute or otherwise make the Covered Software available under the terms of any subsequent version of the License published by the license steward.
|
252
|
+
4.3. Modified Versions.
|
253
|
+
When You are an Initial Developer and You want to create a new license for Your Original Software, You may create and use a modified version of this License if You: (a) rename the license and remove any references to the name of the license steward (except to note that the license differs from this License); and (b) otherwise make it clear that the license contains terms which differ from this License.
|
254
|
+
5. DISCLAIMER OF WARRANTY.
|
255
|
+
COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
|
256
|
+
6. TERMINATION.
|
257
|
+
6.1. This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive.
|
258
|
+
6.2. If You assert a patent infringement claim (excluding declaratory judgment actions) against Initial Developer or a Contributor (the Initial Developer or Contributor against whom You assert such claim is referred to as "Participant") alleging that the Participant Software (meaning the Contributor Version where the Participant is a Contributor or the Original Software where the Participant is the Initial Developer) directly or indirectly infringes any patent, then any and all rights granted directly or indirectly to You by such Participant, the Initial Developer (if the Initial Developer is not the Participant) and all Contributors under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant terminate prospectively and automatically at the expiration of such 60 day notice period, unless if within such 60 day period You withdraw Your claim with respect to the Participant Software against such Participant either unilaterally or pursuant to a written agreement with Participant.
|
259
|
+
6.3. If You assert a patent infringement claim against Participant alleging that the Participant Software directly or indirectly infringes any patent where such claim is resolved (such as by license or settlement) prior to the initiation of patent infringement litigation, then the reasonable value of the licenses granted by such Participant under Sections 2.1 or 2.2 shall be taken into account in determining the amount or value of any payment or license.
|
260
|
+
6.4. In the event of termination under Sections 6.1 or 6.2 above, all end user licenses that have been validly granted by You or any distributor hereunder prior to termination (excluding licenses granted to You by any distributor) shall survive termination.
|
261
|
+
7. LIMITATION OF LIABILITY.
|
262
|
+
UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
|
263
|
+
8. U.S. GOVERNMENT END USERS.
|
264
|
+
The Covered Software is a "commercial item," as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" (as that term is defined at 48 C.F.R. " 252.227-7014(a)(1)) and "commercial computer software documentation" as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Software with only those rights set forth herein. This U.S. Government Rights clause is in lieu of, and supersedes, any other FAR, DFAR, or other clause or provision that addresses Government rights in computer software under this License.
|
265
|
+
9. MISCELLANEOUS.
|
266
|
+
This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by the law of the jurisdiction specified in a notice contained within the Original Software (except to the extent applicable law, if any, provides otherwise), excluding such jurisdiction's conflict-of-law provisions. Any litigation relating to this License shall be subject to the jurisdiction of the courts located in the jurisdiction and venue specified in a notice contained within the Original Software, with the losing party responsible for costs, including, without limitation, court costs and reasonable attorneys' fees and expenses. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License. You agree that You alone are responsible for compliance with the United States export administration regulations (and the export control laws and regulation of any other countries) when You use, distribute or otherwise make available any Covered Software.
|
267
|
+
10. RESPONSIBILITY FOR CLAIMS.
|
268
|
+
As between Initial Developer and the Contributors, each party is responsible for claims and damages arising, directly or indirectly, out of its utilization of rights under this License and You agree to work with Initial Developer and Contributors to distribute such responsibility on an equitable basis. Nothing herein is intended or shall be deemed to constitute any admission of liability.
|
269
|
+
________________________________________
|
270
|
+
NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL)
|
271
|
+
The code released under the CDDL shall be governed by the laws of the State of California (excluding conflict-of-law provisions). Any litigation relating to this License shall be subject to the jurisdiction of the Federal Courts of the Northern District of California and the state courts of the State of California, with venue lying in Santa Clara County, California.
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
|
data/README.md
ADDED
@@ -0,0 +1,671 @@
|
|
1
|
+
# BaseSpace Ruby SDK
|
2
|
+
|
3
|
+
``Bio::BaseSpace`` is a Ruby based SDK to be used in the development of Apps and scripts for working with Illumina's BaseSpace cloud-computing solution for next-gen sequencing data analysis.
|
4
|
+
|
5
|
+
The primary purpose of the SDK is to provide an easy-to-use Ruby environment enabling developers to authenticate a user, retrieve data, and upload data/results from their own analysis to BaseSpace.
|
6
|
+
|
7
|
+
*Note:* It will be necessary to have created a BaseSpace account with a new App and have the ``client_key`` and ``client_secret`` codes for the App available to run a number of the following examples.
|
8
|
+
|
9
|
+
## Availability
|
10
|
+
|
11
|
+
Current version of ``Bio::BaseSpace`` can be checked out here:
|
12
|
+
|
13
|
+
git clone https://github.com/joejimbo/basespace-ruby-sdk.git
|
14
|
+
|
15
|
+
or by,
|
16
|
+
|
17
|
+
git clone git@github.com:joejimbo/basespace-ruby-sdk.git
|
18
|
+
|
19
|
+
*Note:* We will make the SDK available as a Ruby gem when our implementation is production ready. It will then also be listed on [Biogems.info](http://www.biogems.info).
|
20
|
+
|
21
|
+
## Setup
|
22
|
+
|
23
|
+
*Requirements:* Ruby 1.9.3 and above. The multi-part file upload will currently only run on a Unix setup.
|
24
|
+
|
25
|
+
You can include 'Bio::BaseSpace' by setting below environmental variable:
|
26
|
+
|
27
|
+
export RUBYLIB=/path/to/basespace-ruby-sdk/lib/
|
28
|
+
|
29
|
+
or add it to your Ruby scripts using Bio::BaseSpace:
|
30
|
+
|
31
|
+
$: << '/path/to/basespace-ruby-sdk/lib/'
|
32
|
+
|
33
|
+
To test that everything is working as expected, launch a Interactive Ruby and try importing 'Bio::BaseSpace':
|
34
|
+
|
35
|
+
$ irb
|
36
|
+
>> require 'basespace'
|
37
|
+
>> include Bio::BaseSpace
|
38
|
+
|
39
|
+
## Application triggering
|
40
|
+
|
41
|
+
This section demonstrates how to retrieve the ``AppSession`` object produced when a user triggers a BaseSpace App.
|
42
|
+
Further, we cover how to automatically generate the scope strings to request access to the data object (be it a project or a sample) that the App was triggered to analyze.
|
43
|
+
|
44
|
+
The initial http request to our App from BaseSpace is identified by an ``ApplicationActionId``, using this piece of information
|
45
|
+
we are able to obtain information about the user who launched the App and the data that is sought analyzed by the App.
|
46
|
+
First, we instantiate a BaseSpaceAPI object using the ``client_key`` and ``client_secret`` codes provided on the BaseSpace developer's website when registering our App, as well as the ``AppSessionId`` generated from the app-triggering:
|
47
|
+
|
48
|
+
|
49
|
+
require 'basespace'
|
50
|
+
|
51
|
+
include Bio::BaseSpace
|
52
|
+
|
53
|
+
# initialize an authentication object using the key and secret from your app
|
54
|
+
# Fill in with your own values
|
55
|
+
|
56
|
+
client_id = 'my client key'
|
57
|
+
client_secret = 'my client secret'
|
58
|
+
app_session_id = 'my app session id'
|
59
|
+
basespace_url = 'https://api.basespace.illumina.com/'
|
60
|
+
api_version = 'v1pre3'
|
61
|
+
|
62
|
+
# First we will initialize a BaseSpace API object using our app information and the appSessionId
|
63
|
+
bs_api = BaseSpaceAPI.new(client_id, client_secret, basespace_url, api_version, app_session_id)
|
64
|
+
|
65
|
+
# Using the bmy_app_session.spaceApi we can request the appSession object corresponding to the AppSession id supplied
|
66
|
+
my_app_session = bs_api.get_app_session
|
67
|
+
puts my_app_session
|
68
|
+
|
69
|
+
# An app session contains a referal to one or more appLaunchObjects which reference the data module
|
70
|
+
# the user launched the app on. This can be a list of projects, samples, or a mixture of objects
|
71
|
+
puts "Type of data the app was triggered on can be seen in 'references'"
|
72
|
+
puts my_app_session.references.inspect # .inspect is used to put surrounding []
|
73
|
+
puts
|
74
|
+
|
75
|
+
The output will be:
|
76
|
+
|
77
|
+
App session by 600602: Toshiaki Katayama - Id: <my app session id> - status: Complete
|
78
|
+
Type of data the app was triggered on can be seen in 'references'
|
79
|
+
[Project]
|
80
|
+
|
81
|
+
We can also get a handle to the user who started the AppSession and further information on the ``AppLaunchObject``:
|
82
|
+
|
83
|
+
# We can also get a handle to the user who started the AppSession
|
84
|
+
puts "We can get a handle for the user who triggered the app"
|
85
|
+
puts my_app_session.user_created_by
|
86
|
+
puts
|
87
|
+
|
88
|
+
# Let's have a closer look at the appSessionLaunchObject
|
89
|
+
my_reference = my_app_session.references.first
|
90
|
+
|
91
|
+
puts "We can get out information such as the href to the launch object:"
|
92
|
+
puts my_reference.href_content
|
93
|
+
puts
|
94
|
+
puts "and the specific type of that object:"
|
95
|
+
puts my_reference.type
|
96
|
+
puts
|
97
|
+
|
98
|
+
|
99
|
+
The output will be:
|
100
|
+
|
101
|
+
We can get a handle for the user who triggered the app
|
102
|
+
13039: Eri Kibukawa
|
103
|
+
|
104
|
+
We can get out information such as the href to the launch object:
|
105
|
+
v1pre3/projects/848850
|
106
|
+
|
107
|
+
and the specific type of that object:
|
108
|
+
Project
|
109
|
+
|
110
|
+
|
111
|
+
To start working, we will want to expand our permission scope for the trigger object so we can read and write data. The details of this process is the subject of the next section.
|
112
|
+
We end this section by demonstrating how one can easily obtain the so-called "scope string" and make the access request:
|
113
|
+
|
114
|
+
puts "\nWe can get out the specific project objects by using 'content':"
|
115
|
+
my_reference_content = my_reference.content
|
116
|
+
puts my_reference_content
|
117
|
+
puts "\nThe scope string for requesting write access to the reference object is:"
|
118
|
+
puts my_reference_content.get_access_str('write')
|
119
|
+
|
120
|
+
The output will be:
|
121
|
+
We can get out the specific project objects by using 'content':
|
122
|
+
MyProject - id=848850
|
123
|
+
|
124
|
+
The scope string for requesting write access to the reference object is:
|
125
|
+
write project 848850
|
126
|
+
|
127
|
+
We can easily request write access to the reference object so our App can start contributing analysis
|
128
|
+
by default we ask for write permission to and authentication for a device:
|
129
|
+
|
130
|
+
access_map = bs_api.get_access(my_reference_content, 'write')
|
131
|
+
puts "We get the following access map"
|
132
|
+
puts access_map
|
133
|
+
|
134
|
+
The output will be:
|
135
|
+
|
136
|
+
We get the following access map
|
137
|
+
{"device_code"=>"<my device code>", "user_code"=>"<my user code>", "verification_uri"=>"https://basespace.illumina.com/oauth/device", "verification_with_code_uri"=>"https://basespace.illumina.com/oauth/device?code=<my user code>", "expires_in"=>1800, "interval"=>1}
|
138
|
+
|
139
|
+
Have the user visit the verification uri to grant us access
|
140
|
+
|
141
|
+
puts "\nPlease visit the uri within 15 seconds and grant access"
|
142
|
+
puts access_map['verification_with_code_uri']
|
143
|
+
|
144
|
+
The output will be:
|
145
|
+
|
146
|
+
Please visit the uri within 15 seconds and grant access
|
147
|
+
https://basespace.illumina.com/oauth/device?code=<my user code>
|
148
|
+
|
149
|
+
Accept for this test code through web browser
|
150
|
+
|
151
|
+
link = access_map['verification_with_code_uri']
|
152
|
+
host = RbConfig::CONFIG['host_os']
|
153
|
+
case host
|
154
|
+
when /mswin|mingw|cygwin/
|
155
|
+
system("start #{link}")
|
156
|
+
when /darwin/
|
157
|
+
system("open #{link}")
|
158
|
+
when /linux/
|
159
|
+
system("xdg-open #{link}")
|
160
|
+
end
|
161
|
+
sleep(15)
|
162
|
+
|
163
|
+
Once the user has granted us access to objects we requested we can get the BaseSpace access-token and start browsing simply by calling ``updatePriviliges`` on the ``baseSpaceApi`` instance:
|
164
|
+
|
165
|
+
code = access_map['device_code']
|
166
|
+
bs_api.update_privileges(code)
|
167
|
+
puts "The BaseSpaceAPI instance was update with write privileges"
|
168
|
+
|
169
|
+
The output will be:
|
170
|
+
|
171
|
+
The BaseSpaceAPI instance was update with write privileges
|
172
|
+
|
173
|
+
For more details on access-requests and authentication and an example of the web-based case see example 1_authentication.rb
|
174
|
+
|
175
|
+
## Requesting an access-token for data browsing
|
176
|
+
|
177
|
+
Here we demonstrate the basic BaseSpace authentication process. The work-flow outlined here is
|
178
|
+
|
179
|
+
1. Request of access to a specific data-scope
|
180
|
+
2. User approval of access request
|
181
|
+
3. Browsing data
|
182
|
+
|
183
|
+
*Note:* It will be useful if you are logged in to the BaseSpace web-site before launching this example to make the access grant procedure faster.
|
184
|
+
|
185
|
+
Again, we will start out by initializing a ``BaseSpaceAPI`` object:
|
186
|
+
|
187
|
+
require 'basespace'
|
188
|
+
include Bio::BaseSpace
|
189
|
+
|
190
|
+
client_id = 'my client key'
|
191
|
+
client_secret = 'my client secret'
|
192
|
+
app_session_id = 'my app session id'
|
193
|
+
basespace_url = 'https://api.basespace.illumina.com/'
|
194
|
+
api_version = 'v1pre3'
|
195
|
+
|
196
|
+
# First we will initialize a BaseSpace API object using our app information and the appSessionId
|
197
|
+
bs_api = BaseSpaceAPI.new(client_id, client_secret, basespace_url, api_version, app_session_id)
|
198
|
+
|
199
|
+
First, get the verification code and uri for scope 'browse global'
|
200
|
+
|
201
|
+
device_info = bs_api.get_verification_code('browse global')
|
202
|
+
puts
|
203
|
+
puts "URL for user to visit and grant access: "
|
204
|
+
puts device_info['verification_with_code_uri']
|
205
|
+
|
206
|
+
At this point the user must visit the verification uri to grant us access
|
207
|
+
|
208
|
+
## PAUSE HERE
|
209
|
+
# Have the user visit the verification uri to grant us access
|
210
|
+
puts "\nPlease visit the uri within 15 seconds and grant access"
|
211
|
+
puts device_info['verification_with_code_uri']
|
212
|
+
|
213
|
+
link = device_info['verification_with_code_uri']
|
214
|
+
host = RbConfig::CONFIG['host_os']
|
215
|
+
case host
|
216
|
+
when /mswin|mingw|cygwin/
|
217
|
+
system("start #{link}")
|
218
|
+
when /darwin/
|
219
|
+
system("open #{link}")
|
220
|
+
when /linux/
|
221
|
+
system("xdg-open #{link}")
|
222
|
+
end
|
223
|
+
sleep(15)
|
224
|
+
## PAUSE HERE
|
225
|
+
|
226
|
+
The output will be:
|
227
|
+
|
228
|
+
URL for user to visit and grant access:
|
229
|
+
https://basespace.illumina.com/oauth/device?code=<my code>
|
230
|
+
|
231
|
+
Please visit the uri within 15 seconds and grant access
|
232
|
+
https://basespace.illumina.com/oauth/device?code=<my code>
|
233
|
+
|
234
|
+
Once the user has granted us access to objects we requested, we can get the basespace access_token and start browsing simply by calling ``updatePriviliges`` on the baseSpaceApi instance.
|
235
|
+
|
236
|
+
code = device_info['device_code']
|
237
|
+
bs_api.update_privileges(code)
|
238
|
+
|
239
|
+
As a reference the provided access-token can be obtained from the BaseSpaceApi object
|
240
|
+
|
241
|
+
puts "My Access-token: #{bs_api.get_access_token}"
|
242
|
+
puts
|
243
|
+
|
244
|
+
The output will be:
|
245
|
+
|
246
|
+
My Access-token:
|
247
|
+
<my access-token>
|
248
|
+
|
249
|
+
At this point we can start using the ``BaseSpaceAPI`` instance to browse the available data for the current user, the details of this process is the subject of the next section. Here we will end with showing how the API object can be used to list all BaseSpace genome instances:
|
250
|
+
|
251
|
+
# We will get all available genomes with our new api!
|
252
|
+
all_genomes = bs_api.get_available_genomes
|
253
|
+
puts "Genomes: #{all_genomes}"
|
254
|
+
|
255
|
+
The output will be:
|
256
|
+
|
257
|
+
Genomes
|
258
|
+
[Arabidopsis thaliana, Bos Taurus, Escherichia coli, Homo sapiens, Mus musculus, Phix,\
|
259
|
+
Rhodobacter sphaeroides, Rattus norvegicus, Saccharomyces cerevisiae, Staphylococcus aureus]
|
260
|
+
|
261
|
+
## Browsing data with global browse access
|
262
|
+
|
263
|
+
This section demonstrates basic browsing of BaseSpace objects once an access-token for global browsing has been obtained. We will see how
|
264
|
+
objects can be retrieved using either the ``BaseSpaceAPI`` class or by use of method calls on related object instances (for example once
|
265
|
+
a ``user`` instance we can use it to retrieve all project belonging to that user).
|
266
|
+
|
267
|
+
First we will initialize a ``BaseSpaceAPI`` using our access-token for ``global browse``:
|
268
|
+
|
269
|
+
require 'basespace'
|
270
|
+
include Bio::BaseSpace
|
271
|
+
|
272
|
+
# REST server information and user access_token
|
273
|
+
|
274
|
+
client_id = 'my client key'
|
275
|
+
client_secret = 'my client secret'
|
276
|
+
access_token = 'your access token'
|
277
|
+
app_session_id = 'my app session id'
|
278
|
+
basespace_url = 'https://api.basespace.illumina.com/'
|
279
|
+
api_version = 'v1pre3'
|
280
|
+
|
281
|
+
# First, create a client for making calls for this user session
|
282
|
+
my_api = BaseSpaceAPI.new(client_id, client_secret, basespace_url, api_version, app_session_id, access_token)
|
283
|
+
|
284
|
+
First we will try to retrieve a genome object:
|
285
|
+
|
286
|
+
# Now grab the genome with id=4
|
287
|
+
my_genome = my_api.get_genome_by_id('4')
|
288
|
+
puts "The Genome is #{my_genome}"
|
289
|
+
puts "We can get more information from the genome object"
|
290
|
+
puts "Id: #{my_genome.id}"
|
291
|
+
puts "Href: #{my_genome.href}"
|
292
|
+
puts "DisplayName: #{my_genome.display_name}"
|
293
|
+
|
294
|
+
The output will be:
|
295
|
+
|
296
|
+
The Genome is Homo sapiens
|
297
|
+
We can get more information from the genome object
|
298
|
+
Id: 4
|
299
|
+
Href: v1pre3/genomes/4
|
300
|
+
DisplayName: Homo Sapiens - UCSC (hg19)
|
301
|
+
|
302
|
+
Using a comparable method we can get a list of all available genomes:
|
303
|
+
|
304
|
+
# Get a list of all genomes
|
305
|
+
all_genomes = my_api.get_available_genomes
|
306
|
+
puts "Genomes: #{all_genomes}"
|
307
|
+
|
308
|
+
The output will be:
|
309
|
+
|
310
|
+
Genomes
|
311
|
+
[Arabidopsis thaliana, Bos Taurus, Escherichia coli, Homo sapiens, Mus musculus, Phix,\
|
312
|
+
Rhodobacter sphaeroides, Rattus norvegicus, Saccharomyces cerevisiae, Staphylococcus aureus]
|
313
|
+
|
314
|
+
Now, let us retrieve the ``User`` objects for the current user, and list all projects for this user:
|
315
|
+
|
316
|
+
# Take a look at the current user
|
317
|
+
user = my_api.get_user_by_id('current')
|
318
|
+
puts "The current user is #{user}"
|
319
|
+
puts
|
320
|
+
|
321
|
+
# Now list the projects for this user
|
322
|
+
my_projects = my_api.get_project_by_user('current')
|
323
|
+
puts "The projects for this user are #{my_projects}"
|
324
|
+
puts
|
325
|
+
|
326
|
+
The output will be:
|
327
|
+
|
328
|
+
[BaseSpaceDemo - id=2, Cancer Sequencing Demo - id=4, HiSeq 2500 - id=7, ResequencingPhixRun - id=12, TrainingRun - id=114, Note - id=165, 120313-tra - id=606, S.abortusequi-17_L2508 - id=619, TSChIP-Seq - id=14042, BCereusDemoData_Illumina - id=34061]
|
329
|
+
|
330
|
+
The current user is
|
331
|
+
<user id>: Your Name
|
332
|
+
|
333
|
+
The projects for this user are
|
334
|
+
[BaseSpaceDemo - id=2, Cancer Sequencing Demo - id=4, HiSeq 2500 - id=7, ResequencingPhixRun - id=12, TSChIP-Seq - id=14042, BCereusDemoData_Illumina - id=34061]
|
335
|
+
|
336
|
+
We can also achieve this by making a call using the ``user`` instance. Notice that these calls take an instance of ``BaseSpaceAPI`` with apporpriate
|
337
|
+
priviliges to complete the transaction as parameter, this true for all retrieval method calls made on data objects:
|
338
|
+
|
339
|
+
my_projects2 = user.get_projects(my_api)
|
340
|
+
puts "Projects retrieved from the user instance"
|
341
|
+
puts my_projects2
|
342
|
+
|
343
|
+
# List the runs available for the current user
|
344
|
+
runs = user.get_runs(my_api)
|
345
|
+
puts "The runs for this user are"
|
346
|
+
puts runs
|
347
|
+
|
348
|
+
The output will be:
|
349
|
+
|
350
|
+
Projects retrieved from the user instance
|
351
|
+
[BaseSpaceDemo - id=2, Cancer Sequencing Demo - id=4, HiSeq 2500 - id=7, ResequencingPhixRun - id=12, TSChIP-Seq - id=14042, BCereusDemoData_Illumina - id=34061]
|
352
|
+
|
353
|
+
The runs for this user are
|
354
|
+
[BacillusCereus, Genome-in-a-Day, TSCA_test, 2x151PhiX, TruSeq Amplicon_Cancer Panel, CancerDemo]
|
355
|
+
|
356
|
+
In the same manner we can get a list of accessible user runs:
|
357
|
+
|
358
|
+
runs = user.get_runs(my_api)
|
359
|
+
puts "Runs retrieved from user instance"
|
360
|
+
puts runs
|
361
|
+
|
362
|
+
The output will be:
|
363
|
+
|
364
|
+
Runs retrieved from user instance
|
365
|
+
[BacillusCereus, Genome-in-a-Day, TSCA_test, 2x151PhiX, TruSeq Amplicon_Cancer Panel, CancerDemo]
|
366
|
+
|
367
|
+
## Accessing file-trees and querying BAM or VCF files
|
368
|
+
|
369
|
+
In this section we demonstrate how to access samples and analysis from a projects and how to work with the available file data for such instances.
|
370
|
+
In addition, we take a look at some of the special queuring methods associated with BAM- and VCF-files.
|
371
|
+
|
372
|
+
Again, start out by initializing a ``BaseSpaceAPI`` instance and retrieving all projects belonging to the current user:
|
373
|
+
|
374
|
+
# First, create a client for making calls for this user session
|
375
|
+
require 'basespace'
|
376
|
+
include Bio::BaseSpace
|
377
|
+
|
378
|
+
client_id = 'my client key'
|
379
|
+
client_secret = 'my client secret'
|
380
|
+
access_token = 'your access token'
|
381
|
+
app_session_id = 'my app session id'
|
382
|
+
basespace_url = 'https://api.basespace.illumina.com/'
|
383
|
+
api_version = 'v1pre3'
|
384
|
+
|
385
|
+
my_api = BaseSpaceAPI.new(client_id, client_secret, basespace_url, api_version, app_session_id, access_token)
|
386
|
+
user = my_api.get_user_by_id('current')
|
387
|
+
my_projects = my_api.get_project_by_user('current')
|
388
|
+
|
389
|
+
app_results = nil
|
390
|
+
samples = nil
|
391
|
+
|
392
|
+
Now we can list all the analyses and samples for these projects
|
393
|
+
|
394
|
+
# Let's list all the AppResults and samples for these projects
|
395
|
+
|
396
|
+
my_projects.each do |single_project|
|
397
|
+
puts "# Project: #{single_project}"
|
398
|
+
|
399
|
+
app_results = single_project.get_app_results(my_api)
|
400
|
+
puts " The App results for project #{single_project} are"
|
401
|
+
puts " #{app_results}"
|
402
|
+
|
403
|
+
samples = single_project.get_samples(my_api)
|
404
|
+
puts " The samples for project #{single_project} are"
|
405
|
+
puts " #{samples}"
|
406
|
+
end
|
407
|
+
|
408
|
+
The output will be:
|
409
|
+
|
410
|
+
# Project: BaseSpaceDemo - id=2
|
411
|
+
The App results for project BaseSpaceDemo - id=2 are
|
412
|
+
[Resequencing, Resequencing, Resequencing, Resequencing, Resequencing, Resequencing, Resequencing, Resequencing, Resequencing, Resequencing]
|
413
|
+
The samples for project BaseSpaceDemo - id=2 are
|
414
|
+
[BC_1, BC_2, BC_3, BC_4, BC_5, BC_6, BC_7, BC_8, BC_9, BC_10]
|
415
|
+
# Project: Cancer Sequencing Demo - id=4
|
416
|
+
The App results for project Cancer Sequencing Demo - id=4 are
|
417
|
+
[Amplicon, Amplicon]
|
418
|
+
The samples for project Cancer Sequencing Demo - id=4 are
|
419
|
+
[L2I]
|
420
|
+
# Project: HiSeq 2500 - id=7
|
421
|
+
The App results for project HiSeq 2500 - id=7 are
|
422
|
+
[Resequencing]
|
423
|
+
The samples for project HiSeq 2500 - id=7 are
|
424
|
+
[NA18507]
|
425
|
+
......
|
426
|
+
|
427
|
+
|
428
|
+
We'll take a further look at the files belonging to the sample from the last project in the loop above:
|
429
|
+
|
430
|
+
samples.each do |sample|
|
431
|
+
puts "# Sample: #{sample}"
|
432
|
+
files = sample.get_files(my_api)
|
433
|
+
puts files
|
434
|
+
end
|
435
|
+
|
436
|
+
The output will be:
|
437
|
+
|
438
|
+
# Sample: Bcereus_1
|
439
|
+
Bcereus-1_S1_L001_R1_001.fastq.gz - id: '14235852', size: '179971155'
|
440
|
+
Bcereus-1_S1_L001_R2_001.fastq.gz - id: '14235853', size: '193698522'
|
441
|
+
# Sample: Bcereus_2
|
442
|
+
Bcereus-2_S2_L001_R1_001.fastq.gz - id: '14235871', size: '126164153'
|
443
|
+
Bcereus-2_S2_L001_R2_001.fastq.gz - id: '14235872', size: '137077949'
|
444
|
+
......
|
445
|
+
|
446
|
+
Now, have a look at some of the methods calls specific to ``Bam`` and ``VCF`` files. First, we will get a ``Bam``-file and then retrieve the coverage information available for chromosome 2 between positions 1 and 20000:
|
447
|
+
|
448
|
+
|
449
|
+
device_info = my_api.get_verification_code('read project 183184')
|
450
|
+
link = device_info['verification_with_code_uri']
|
451
|
+
host = RbConfig::CONFIG['host_os']
|
452
|
+
case host
|
453
|
+
when /mswin|mingw|cygwin/
|
454
|
+
system("start #{link}")
|
455
|
+
when /darwin/
|
456
|
+
system("open #{link}")
|
457
|
+
when /linux/
|
458
|
+
system("xdg-open #{link}")
|
459
|
+
end
|
460
|
+
sleep(15)
|
461
|
+
|
462
|
+
code = device_info['device_code']
|
463
|
+
my_api.update_privileges(code)
|
464
|
+
|
465
|
+
# Now do some work with files
|
466
|
+
# we'll grab a BAM by id and get the coverage for an interval + accompanying meta-data
|
467
|
+
|
468
|
+
my_bam = my_api.get_file_by_id('44154664')
|
469
|
+
puts "# BAM: #{my_bam}"
|
470
|
+
cov = my_bam.get_interval_coverage(my_api, 'chr1', '50000', '60000')
|
471
|
+
puts cov
|
472
|
+
cov_meta = my_bam.get_coverage_meta(my_api, 'chr1')
|
473
|
+
puts cov_meta
|
474
|
+
|
475
|
+
The output will be:
|
476
|
+
|
477
|
+
# BAM: sorted_S1.bam - id: '44154664', size: '105789387933', status: 'complete'
|
478
|
+
Chrom chr1: 1-1792, BucketSize=2
|
479
|
+
CoverageMeta: max=1158602 gran=128
|
480
|
+
|
481
|
+
For ``VCF``-files we can filter variant calls based on chromosome and location as well:
|
482
|
+
|
483
|
+
# and a vcf file
|
484
|
+
my_vcf = my_api.get_file_by_id('44154644')
|
485
|
+
|
486
|
+
# Get the variant meta info
|
487
|
+
|
488
|
+
var_meta = my_vcf.get_variant_meta(my_api)
|
489
|
+
puts var_meta
|
490
|
+
var = my_vcf.filter_variant(my_api, '1', '20000', '30000')
|
491
|
+
puts var
|
492
|
+
|
493
|
+
The output will be:
|
494
|
+
|
495
|
+
VariantHeader: SampleCount=1
|
496
|
+
[Variant - chr2: 10236 id=['.'], Variant - chr2: 10249 id=['.'], ....]
|
497
|
+
|
498
|
+
## Creating an AppResult and uploading files
|
499
|
+
|
500
|
+
In this section we will see how to create a new AppResults object, change the state of the related AppSession,
|
501
|
+
and upload result files to it as well as retrieve files from it.
|
502
|
+
|
503
|
+
First, create a client for making calls for this user session:
|
504
|
+
|
505
|
+
myBaseSpaceAPI = BaseSpaceAPI(client_key, client_secret, BaseSpaceUrl, version, AppSessionId,AccessToken=accessToken)
|
506
|
+
|
507
|
+
# Now we'll do some work of our own. First get a project to work on
|
508
|
+
# we'll need write permission, for the project we are working on
|
509
|
+
# meaning we will need get a new token and instantiate a new BaseSpaceAPI
|
510
|
+
p = myBaseSpaceAPI.getProjectById('89')
|
511
|
+
|
512
|
+
Assuming we have write access for the project, we will list the current analyses for the project:
|
513
|
+
|
514
|
+
appRes = p.getAppResults(myBaseSpaceAPI,statuses=['Running'])
|
515
|
+
print "\nThe current running AppResults are \n" + str(appRes)
|
516
|
+
|
517
|
+
The output will be:
|
518
|
+
|
519
|
+
Output[]:
|
520
|
+
|
521
|
+
The current running AppResults are
|
522
|
+
[Results for sample 123, Results for sample 124 ...]
|
523
|
+
|
524
|
+
|
525
|
+
To create an appResults for a project, simply give the name and description:
|
526
|
+
|
527
|
+
appResults = p.createAppResult(myBaseSpaceAPI,"testing","this is my results",appSessionId='')
|
528
|
+
print "\nSome info about our new app results"
|
529
|
+
print appResults
|
530
|
+
print appResults.Id
|
531
|
+
print "\nThe app results also comes with a reference to our AppSession"
|
532
|
+
myAppSession = appResults.AppSession
|
533
|
+
print myAppSession
|
534
|
+
|
535
|
+
The output will be:
|
536
|
+
|
537
|
+
Output[]:
|
538
|
+
|
539
|
+
Some info about our new app results
|
540
|
+
AppResult: testing
|
541
|
+
153153
|
542
|
+
|
543
|
+
The app results also comes with a reference to our AppSession
|
544
|
+
App session by 152152: Morten Kallberg - Id: <my appSession Id> - status: Running
|
545
|
+
|
546
|
+
We can change the status of our AppSession and add a status-summary as follows
|
547
|
+
|
548
|
+
myAppSession.setStatus(myBaseSpaceAPI,'needsattention',"We worked hard, but encountered some trouble.")
|
549
|
+
print "\nAfter a change of status of the app sessions we get\n" + str(myAppSession)
|
550
|
+
# we'll set our appSession back to running so we can do some more work
|
551
|
+
myAppSession.setStatus(myBaseSpaceAPI,'running',"Back on track")
|
552
|
+
|
553
|
+
The output will be:
|
554
|
+
|
555
|
+
Output[]:
|
556
|
+
|
557
|
+
After a change of status of the app sessions we get
|
558
|
+
App session by 152152: Morten Kallberg - Id: <my appSession Id> - status: NeedsAttention
|
559
|
+
|
560
|
+
Now we will make another AppResult and try to upload a file to it
|
561
|
+
|
562
|
+
appResults2 = p.createAppResult(myBaseSpaceAPI,"My second AppResult","This one I will upload to")
|
563
|
+
appResults2.uploadFile(myBaseSpaceAPI, '/home/mkallberg/Desktop/testFile2.txt', 'BaseSpaceTestFile.txt', '/mydir/', 'text/plain')
|
564
|
+
print "\nMy AppResult number 2 \n" + str(appResults2)
|
565
|
+
|
566
|
+
## let's see if our new file made it
|
567
|
+
appResultFiles = appResults2.getFiles(myBaseSpaceAPI)
|
568
|
+
print "\nThese are the files in the appResult"
|
569
|
+
print appResultFiles
|
570
|
+
f = appResultFiles[-1]
|
571
|
+
|
572
|
+
The output will be:
|
573
|
+
|
574
|
+
Output[]:
|
575
|
+
|
576
|
+
My AppResult number 2
|
577
|
+
AppResult: My second AppResult
|
578
|
+
|
579
|
+
These are the files in the appResult
|
580
|
+
[BaseSpaceTestFile.txt]
|
581
|
+
|
582
|
+
We can even download our newly uploaded file in the following manner:
|
583
|
+
|
584
|
+
f = myBaseSpaceAPI.getFileById(f.Id)
|
585
|
+
f.downloadFile(myBaseSpaceAPI,'/home/mkallberg/Desktop/')
|
586
|
+
|
587
|
+
## Cookbook
|
588
|
+
|
589
|
+
This section contains useful code-snippets demonstrating use-cases that frequently come up in App development.
|
590
|
+
|
591
|
+
### Filtering file-lists and AppResult-lists using query parameter dictionaries
|
592
|
+
|
593
|
+
Given a sample "a" we can retrieve a subset of the full file-list using a query parameter dictionary:
|
594
|
+
|
595
|
+
In [10]: a.getFiles(myAPI)
|
596
|
+
Out[10]: [sorted.bam, sorted.bam.bai, genome.vcf]
|
597
|
+
|
598
|
+
In [11]: a.getFiles(myAPI,myQp={'Extensions':'bam'})
|
599
|
+
Out[11]: [sorted.bam]
|
600
|
+
|
601
|
+
Filter with multiple extensions:
|
602
|
+
|
603
|
+
In [12]: a.getFiles(myAPI,myQp={'Extensions':'bam,vcf'})
|
604
|
+
Out[12]: [sorted.bam, genome.vcf]
|
605
|
+
|
606
|
+
You can provide all other legal sorting/filtering keyword in this dictionary to get further refinement of the list:
|
607
|
+
|
608
|
+
In [13]: a.getFiles(myAPI,myQp={'Extensions':'bam,vcf','SortBy':'Path'})
|
609
|
+
Out[13]: [genome.vcf, sorted.bam]
|
610
|
+
|
611
|
+
|
612
|
+
You can supply a dictionary of query parameters when you retrieving appresults, in the same way you filter file lists. Below is an example of how to limit the number of results from 100 (default value for “Limit”) to 10.
|
613
|
+
|
614
|
+
In [3]: res = p.getAppResults(myBaseSpaceAPI)
|
615
|
+
|
616
|
+
In [4]: len(res)
|
617
|
+
Out[4]: 100
|
618
|
+
|
619
|
+
In [5]: res = p.getAppResults(myBaseSpaceAPI,myQp={'Limit':'10'})
|
620
|
+
|
621
|
+
In [6]: len(res)
|
622
|
+
Out[6]: 10
|
623
|
+
|
624
|
+
## Feature Requests and Bugs
|
625
|
+
|
626
|
+
Please feel free to report any feedback regarding the BaseSpace Ruby SDK directly to the [GitHub repository](https://github.com/joejimbo/basespace-ruby-sdk). We appreciate any and all feedback about the SDKs and we will do anything we can to improve the functionality and quality of the SDK to make it easy for developers to use.
|
627
|
+
|
628
|
+
# SDK Development Manual
|
629
|
+
|
630
|
+
## Building a New Version of the Gem
|
631
|
+
|
632
|
+
bundle exec rake gemspec
|
633
|
+
bundle exec gem build bio-basespace.gemspec
|
634
|
+
sudo gem install bio-basespace
|
635
|
+
|
636
|
+
## Unit Testing
|
637
|
+
|
638
|
+
First, install the gem as described just above. Then use [RSpec](http://rspec.info) for unit testing:
|
639
|
+
|
640
|
+
rspec -c -f d
|
641
|
+
|
642
|
+
## Porting
|
643
|
+
|
644
|
+
BaseSpace Ruby SDK was initially ported by translating the BaseSpace Python SDK to Ruby. If it becomes necessary to port further code from the Python SDK, then the following porting guidelines should be observed:
|
645
|
+
|
646
|
+
* indentation: Python 4 spaces, Ruby 2 spaces
|
647
|
+
* compund words: Python `ExampleLabel`, Ruby `example_label`
|
648
|
+
* constructors: Python `def __init__(self):`, Ruby `def initialize`
|
649
|
+
* class variables: Python `self.swaggerTypes = { "Key":"value" }`, Ruby `@swagger_types = { "Key" => "value" }`
|
650
|
+
* void types: Python `None`, Ruby `nil`
|
651
|
+
* string representation: Python `__str__(self)`, Ruby `to_s (return @val.to_s)`
|
652
|
+
* object dump: Python `__repr__(self)`, Ruby `to_str (return self.inspect)` or `self.attributes.inspect` for attribute values
|
653
|
+
* exceptions: Python `FooBarException` -> `FooBarError`
|
654
|
+
* types:
|
655
|
+
* Python `str`, Ruby `String`
|
656
|
+
* Python `int`, Ruby `Integer`
|
657
|
+
* Python `float`, Ruby `Float`
|
658
|
+
* Python `bool`, Ruby `true`/`false`
|
659
|
+
* Python `list<>`, Ruby `Array`
|
660
|
+
* Python `dict`, Ruby `Hash`
|
661
|
+
* Python `file`, Ruby `File`
|
662
|
+
|
663
|
+
# Authors
|
664
|
+
|
665
|
+
Joachim Baran, Raoul Bonnal, Eri Kibukawa, Francesco Strozzi, Toshiaki Katayama
|
666
|
+
|
667
|
+
# Copying / License
|
668
|
+
|
669
|
+
See [License.txt](https://raw.github.com/joejimbo/basespace-ruby-sdk/master/License.txt) for details on licensing and distribution.
|
670
|
+
|
671
|
+
|