bge-python-sdk 0.6.2__py3-none-any.whl → 0.7.0__py3-none-any.whl
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.
- {bge_python_sdk-0.6.2.dist-info → bge_python_sdk-0.7.0.dist-info}/METADATA +7 -2
- {bge_python_sdk-0.6.2.dist-info → bge_python_sdk-0.7.0.dist-info}/RECORD +28 -24
- {bge_python_sdk-0.6.2.dist-info → bge_python_sdk-0.7.0.dist-info}/WHEEL +1 -1
- {bge_python_sdk-0.6.2.dist-info → bge_python_sdk-0.7.0.dist-info}/entry_points.txt +1 -0
- bgesdk/client.py +198 -34
- bgesdk/management/commands/api/commands/aggregate_omics_data.py +1 -2
- bgesdk/management/commands/api/commands/applet_url.py +77 -0
- bgesdk/management/commands/api/commands/download.py +1 -1
- bgesdk/management/commands/api/commands/ferry_to_oss.py +117 -0
- bgesdk/management/commands/api/commands/get_data_items.py +1 -2
- bgesdk/management/commands/api/commands/get_externals.py +1 -2
- bgesdk/management/commands/api/commands/get_func_abundance.py +1 -2
- bgesdk/management/commands/api/commands/get_gene_abundance.py +1 -2
- bgesdk/management/commands/api/commands/get_overview.py +95 -0
- bgesdk/management/commands/api/commands/get_range_stream.py +1 -2
- bgesdk/management/commands/api/commands/get_samples.py +1 -2
- bgesdk/management/commands/api/commands/get_taxon_abundance.py +1 -2
- bgesdk/management/commands/api/commands/get_user.py +0 -1
- bgesdk/management/commands/api/commands/get_variants.py +1 -2
- bgesdk/management/commands/api/commands/id_meta.py +71 -0
- bgesdk/management/commands/api/commands/task.py +1 -2
- bgesdk/management/commands/api/commands/upload.py +1 -1
- bgesdk/management/commands/api/commands/upload_dir.py +1 -1
- bgesdk/management/commands/model.py +74 -30
- bgesdk/models.py +64 -31
- bgesdk/version.py +1 -1
- {bge_python_sdk-0.6.2.dist-info → bge_python_sdk-0.7.0.dist-info}/LICENSE +0 -0
- {bge_python_sdk-0.6.2.dist-info → bge_python_sdk-0.7.0.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: bge-python-sdk
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.0
|
|
4
4
|
Summary: 可用于调用 BGE 开放平台的相关接口。
|
|
5
5
|
Home-page: https://github.com/teambge/bge-python-sdk
|
|
6
6
|
Author: leafcoder,xiangji1204
|
|
@@ -9,6 +9,7 @@ Maintainer: leafcoder
|
|
|
9
9
|
Maintainer-email: leafcoder@gmail.com
|
|
10
10
|
License: MIT
|
|
11
11
|
Keywords: bge-python-sdk bge bgesdk sdk
|
|
12
|
+
Platform: UNKNOWN
|
|
12
13
|
Classifier: Development Status :: 5 - Production/Stable
|
|
13
14
|
Classifier: Intended Audience :: Developers
|
|
14
15
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -23,12 +24,14 @@ Classifier: Programming Language :: Python :: 3.7
|
|
|
23
24
|
Classifier: Programming Language :: Python :: 3.8
|
|
24
25
|
Classifier: Programming Language :: Python :: 3.9
|
|
25
26
|
Classifier: Programming Language :: Python :: 3.10
|
|
27
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
28
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
29
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
26
30
|
Classifier: Topic :: Software Development :: Libraries
|
|
27
31
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
28
32
|
Classifier: Topic :: Utilities
|
|
29
33
|
Requires-Python: >=3.6.3
|
|
30
34
|
Description-Content-Type: text/markdown
|
|
31
|
-
License-File: LICENSE
|
|
32
35
|
Requires-Dist: aliyun-python-sdk-core
|
|
33
36
|
Requires-Dist: six
|
|
34
37
|
Requires-Dist: certifi
|
|
@@ -180,3 +183,5 @@ print(api.get_variants('E-B1243433', 'rs333'))
|
|
|
180
183
|
|
|
181
184
|
* xiangji1204's [github](https://github.com/xiangji1204)
|
|
182
185
|
* leafcoder(leafcoder@gmail.com)'s [github](https://github.com/leafcoder)
|
|
186
|
+
|
|
187
|
+
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
bgesdk/__init__.py,sha256=FgKWRqlkspNPC79IF6yLD6SEMST-gl55ZQXT_jOPUb4,124
|
|
2
2
|
bgesdk/__main__.py,sha256=IDvh-O043qXjyp1CX0FH_tX2ss1FWZKbWqOGpu_wtSk,2196
|
|
3
|
-
bgesdk/client.py,sha256=
|
|
3
|
+
bgesdk/client.py,sha256=_un6dX6ULpnolVD6iFIX2Crt5U5Bhy9Dbwy_KW0qVYU,60812
|
|
4
4
|
bgesdk/constants.py,sha256=bE60GPAHLg1UzacrOllPXGqUwhsVo5kjwJq9_ibB4Ng,636
|
|
5
5
|
bgesdk/error.py,sha256=GVxBbz1REoypN3OqDzZXd0f-B0J_P1pBRapH1TnQucc,462
|
|
6
6
|
bgesdk/fs.py,sha256=36wi3FEUHAirEFJpYEtjIN3wwDilPRFIEt45TjXUEVM,154
|
|
7
7
|
bgesdk/http.py,sha256=SZoPm4kO99QCHQU1p2G5zicl34n3dpMMxfA1oYo7EGA,4503
|
|
8
|
-
bgesdk/models.py,sha256=
|
|
8
|
+
bgesdk/models.py,sha256=pSCtft7CLLYKI4CTQP1j3x1wbguJDX23OUFxpjw5EUs,4566
|
|
9
9
|
bgesdk/utils.py,sha256=i-s74kQlnlQk7QQi9wur6ack1gUwyS1Mw4F-L0w1cpw,884
|
|
10
|
-
bgesdk/version.py,sha256=
|
|
10
|
+
bgesdk/version.py,sha256=v37Hxx1kbpEqtQ4RjPqxd8x3WvceaC9Z6-jl-k2d7KI,46
|
|
11
11
|
bgesdk/management/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
12
|
bgesdk/management/command.py,sha256=TyssJaZ_pUQ7JitJkfh0PMK8y8GATobd5yL2O1vm_Nk,701
|
|
13
13
|
bgesdk/management/constants.py,sha256=lPPix3TQ-OisDikIODK4-_1ebM5GiuITkJVFqWR8zYI,1508
|
|
@@ -16,26 +16,30 @@ bgesdk/management/validate.py,sha256=yPKIarj_MeeSvWWhVtQplw8yeCGDsBktmsMU_zYnaAQ
|
|
|
16
16
|
bgesdk/management/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
17
|
bgesdk/management/commands/config.py,sha256=FHjJcBs9UsFNUPGvr6YB0SycJf3uTBUecsOgjCXIMJo,7118
|
|
18
18
|
bgesdk/management/commands/login.py,sha256=M71zjflQtRgJ9IZNEdU10b2XBjgcy3VcNP5G1TvxBto,3919
|
|
19
|
-
bgesdk/management/commands/model.py,sha256=
|
|
19
|
+
bgesdk/management/commands/model.py,sha256=XvhZutCa-49ffNT3HuGI9ueTn4CCX68ZCnuTSNT3JtE,68976
|
|
20
20
|
bgesdk/management/commands/model_doc.py,sha256=uDLpie3-KQ5rOVXIHGdttoxrE9ZWySwV2eLnFUnmRq8,13811
|
|
21
21
|
bgesdk/management/commands/token.py,sha256=BqplYw-1ESBpxJOvs6kzcYqpcdqJGs35z5JR9jmMaiQ,2515
|
|
22
22
|
bgesdk/management/commands/workon.py,sha256=WEC__3tlVy7ZXGZug-rwf5pd59UTTsh6xxoKefKTL3s,1183
|
|
23
23
|
bgesdk/management/commands/api/__init__.py,sha256=nl_es-yj-q4Xo5sUny-i-gE26FVOYZNyX1zhUTvETS8,1975
|
|
24
24
|
bgesdk/management/commands/api/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
|
-
bgesdk/management/commands/api/commands/aggregate_omics_data.py,sha256=
|
|
26
|
-
bgesdk/management/commands/api/commands/
|
|
27
|
-
bgesdk/management/commands/api/commands/
|
|
28
|
-
bgesdk/management/commands/api/commands/
|
|
29
|
-
bgesdk/management/commands/api/commands/
|
|
30
|
-
bgesdk/management/commands/api/commands/
|
|
31
|
-
bgesdk/management/commands/api/commands/
|
|
32
|
-
bgesdk/management/commands/api/commands/
|
|
33
|
-
bgesdk/management/commands/api/commands/
|
|
34
|
-
bgesdk/management/commands/api/commands/
|
|
35
|
-
bgesdk/management/commands/api/commands/
|
|
36
|
-
bgesdk/management/commands/api/commands/
|
|
37
|
-
bgesdk/management/commands/api/commands/
|
|
38
|
-
bgesdk/management/commands/api/commands/
|
|
25
|
+
bgesdk/management/commands/api/commands/aggregate_omics_data.py,sha256=I8ujRKh33k1ul7ac2-5TivTbUPAA62setyteHa7Fk3I,3166
|
|
26
|
+
bgesdk/management/commands/api/commands/applet_url.py,sha256=WQAjxTYbjHzt90byEeyt9Cv8MFz8iqeZaYP_xZno91g,2506
|
|
27
|
+
bgesdk/management/commands/api/commands/download.py,sha256=jpcgeDGJzmWYUibEILTG0xNBc9a2RLERkJDFoz8fOgY,3510
|
|
28
|
+
bgesdk/management/commands/api/commands/ferry_to_oss.py,sha256=AR4yViRnLF7jonx2l9qG4uCcWvabDJoQYAN9Qv51qMw,4159
|
|
29
|
+
bgesdk/management/commands/api/commands/get_data_items.py,sha256=OFliXFtMd-yLIpmdSgQOZAUap01gKWez1otm9Cezido,2538
|
|
30
|
+
bgesdk/management/commands/api/commands/get_externals.py,sha256=iP8cmBJXtcLe850eiMMKc1BNdzMPDrHKIV4v7QP7-dw,1888
|
|
31
|
+
bgesdk/management/commands/api/commands/get_func_abundance.py,sha256=knFuDAe_HkrQydoyEiyx9RNjbbIQyg4JKkYX37nyciM,2664
|
|
32
|
+
bgesdk/management/commands/api/commands/get_gene_abundance.py,sha256=B4kGjp5mm6Dz6rEjT12rE4dZCrOX9Qe91JTS6QkFx1Q,2884
|
|
33
|
+
bgesdk/management/commands/api/commands/get_overview.py,sha256=Mt3mjTyjyr38R6JUg86xaPje5ZCenn4im5u2Uq48Djs,3042
|
|
34
|
+
bgesdk/management/commands/api/commands/get_range_stream.py,sha256=Q3kyJu9WgMW3KoFNLVoh6RQjhGxPdCIhUaRpd5g-PD4,2909
|
|
35
|
+
bgesdk/management/commands/api/commands/get_samples.py,sha256=oGtxJlxgrFU65snWqfkFO_Y8kRyTLxFLw4pxyxlqB4A,3468
|
|
36
|
+
bgesdk/management/commands/api/commands/get_taxon_abundance.py,sha256=HyHnnkCGRpEIC1U0UBNsWbtlv_Gl_SdAUHgDkxrZyF4,2336
|
|
37
|
+
bgesdk/management/commands/api/commands/get_user.py,sha256=3-CkPf8k9bvfZeDSmdpcnDF3q0WyYmc2dJPUGX6QR8U,1526
|
|
38
|
+
bgesdk/management/commands/api/commands/get_variants.py,sha256=8NlaT-dstZnLCYsMxsEmqa0iCIhFk2xzHU2SiDsUohI,1897
|
|
39
|
+
bgesdk/management/commands/api/commands/id_meta.py,sha256=PpzRclP1y9jZW-1ETKBYylvlrBWimH7aKSAC7Rz-30Q,1995
|
|
40
|
+
bgesdk/management/commands/api/commands/task.py,sha256=HrZ1aQLjajkbdqI-R_13Vaz8Q4yvsZz6LXDNyyBVrTo,1649
|
|
41
|
+
bgesdk/management/commands/api/commands/upload.py,sha256=K2JYuhnUQ9iLzfvJfSb0liVqyLCnb7jGg09k58ydi2o,3864
|
|
42
|
+
bgesdk/management/commands/api/commands/upload_dir.py,sha256=ZNkTDRay09zbhS0ecun3OLrrvjgXVaRrBjA0-YIoFck,4261
|
|
39
43
|
tests/__init__.py,sha256=v2XA5CqxLpudaDp6lNnK_rYSSII2w4L0Nj9NLnWK9xw,35
|
|
40
44
|
tests/conftest.py,sha256=TdyokQEP2eHmLvuTmW2N7pTs2WKlJKws4szQmoMkVPQ,3208
|
|
41
45
|
tests/test_abundance.py,sha256=OV0m0G-YmsWh9jejlu8Pr_IKtuBK5IfmZRPJ5MICwHQ,4013
|
|
@@ -47,9 +51,9 @@ tests/test_phenotype.py,sha256=3lntjMRPrYo-xFVi4mzmnyx6cLdzrTB6yxACNC4Cg7s,2264
|
|
|
47
51
|
tests/test_samples.py,sha256=qcAf6084KtKZORPxHZkEfRMLAUwEm989BJApcUw9Cng,3341
|
|
48
52
|
tests/test_user.py,sha256=QNCaIE38suadIHs0SMLM-s3bKUxZ0tjbcZCYBEWTeZ0,417
|
|
49
53
|
tests/test_variants.py,sha256=rkW0wKDLyEuLpN26PG7bQzEgNwEkJlDRxjad7WDNblA,3056
|
|
50
|
-
bge_python_sdk-0.
|
|
51
|
-
bge_python_sdk-0.
|
|
52
|
-
bge_python_sdk-0.
|
|
53
|
-
bge_python_sdk-0.
|
|
54
|
-
bge_python_sdk-0.
|
|
55
|
-
bge_python_sdk-0.
|
|
54
|
+
bge_python_sdk-0.7.0.dist-info/LICENSE,sha256=rX5ltHdvA1K75K8tRHlJyqnLLUgiosIAiakOYqNsx40,1063
|
|
55
|
+
bge_python_sdk-0.7.0.dist-info/METADATA,sha256=Ev4qb3ltdiwP5mDAp8Ek99SgGHW8jvFt1DobW1UNXbs,7661
|
|
56
|
+
bge_python_sdk-0.7.0.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
|
|
57
|
+
bge_python_sdk-0.7.0.dist-info/entry_points.txt,sha256=Kwg9cPG9uXFJgintikexeiir_eLER0cFnthglnI9-ic,46
|
|
58
|
+
bge_python_sdk-0.7.0.dist-info/top_level.txt,sha256=yKxDxOG0LXoztEOTej1WRMYXQdc2BT9es4ju24nGtOM,13
|
|
59
|
+
bge_python_sdk-0.7.0.dist-info/RECORD,,
|
bgesdk/client.py
CHANGED
|
@@ -74,9 +74,9 @@ def alive(self):
|
|
|
74
74
|
|
|
75
75
|
class OAuth2(object):
|
|
76
76
|
"""OAuth2 授权客户端类。
|
|
77
|
-
|
|
77
|
+
|
|
78
78
|
管理关于 OAuth2 相关接口的调用,包括获取授权页面地址、授权码交换访问令牌等;
|
|
79
|
-
|
|
79
|
+
|
|
80
80
|
Args:
|
|
81
81
|
client_id (字符串): 第三方客户端 client_id;
|
|
82
82
|
client_secret (字符串): 第三方客户端 client_secret;
|
|
@@ -278,6 +278,73 @@ class API(object):
|
|
|
278
278
|
result = request.get('/profile', params=params, timeout=timeout)
|
|
279
279
|
return models.Model(result)
|
|
280
280
|
|
|
281
|
+
def get_overview(
|
|
282
|
+
self,
|
|
283
|
+
idcard=None,
|
|
284
|
+
phone=None,
|
|
285
|
+
biosample_id=None,
|
|
286
|
+
project_id=None,
|
|
287
|
+
external_sample_id=None,
|
|
288
|
+
**kwargs,
|
|
289
|
+
):
|
|
290
|
+
"""获取用户数据概览
|
|
291
|
+
|
|
292
|
+
Args:
|
|
293
|
+
idcard (str, 非必填): 身份证;
|
|
294
|
+
phone (str, 非必填): 手机号;提供了参数 phone,禁止再提供 biosample_id、
|
|
295
|
+
project_id、external_sample_id;
|
|
296
|
+
biosample_id (str, 非必填): BGE 样本编号;提供了参数 biosample_id,禁
|
|
297
|
+
止再提供 phone、project_id、external_sample_id;
|
|
298
|
+
project_id (str, 非必填): BGE 项目编号;提供了参数 project_id 必须提
|
|
299
|
+
供 external_sample_id,且 phone 和 biosample_id 必须为空;
|
|
300
|
+
external_sample_id (str, 非必填): 外部样本编号;提供了参数
|
|
301
|
+
external_sample_id 必须提供 project_id,且 phone 和
|
|
302
|
+
biosample_id 必须为空;
|
|
303
|
+
|
|
304
|
+
Returns:
|
|
305
|
+
Model: 用户数据概览;
|
|
306
|
+
"""
|
|
307
|
+
data = {}
|
|
308
|
+
data.update(kwargs)
|
|
309
|
+
if phone and (biosample_id or project_id or external_sample_id):
|
|
310
|
+
raise BGEError(
|
|
311
|
+
'If the phone parameter is provided, the biosample_id, '
|
|
312
|
+
'project_id, and external_sample_id are prohibited.'
|
|
313
|
+
)
|
|
314
|
+
elif biosample_id and (phone or project_id or external_sample_id):
|
|
315
|
+
raise BGEError(
|
|
316
|
+
'If the biosample_id parameter is provided, the phone, '
|
|
317
|
+
'project_id, and external_sample_id are prohibited.'
|
|
318
|
+
)
|
|
319
|
+
else:
|
|
320
|
+
if (not project_id and external_sample_id) or \
|
|
321
|
+
(project_id and not external_sample_id):
|
|
322
|
+
raise BGEError(
|
|
323
|
+
'The project_id and external_sample_id must be provided'
|
|
324
|
+
' together.'
|
|
325
|
+
)
|
|
326
|
+
if project_id and external_sample_id and (phone or biosample_id):
|
|
327
|
+
raise BGEError(
|
|
328
|
+
'The provided parameters external_sample_id must provid'
|
|
329
|
+
'e the project_id, and the phone and biosample_id must '
|
|
330
|
+
'be empty.'
|
|
331
|
+
)
|
|
332
|
+
data.update({
|
|
333
|
+
'idcard': idcard,
|
|
334
|
+
'phone': phone,
|
|
335
|
+
'biosample_id': biosample_id,
|
|
336
|
+
'project_id': project_id,
|
|
337
|
+
'external_sample_id': external_sample_id,
|
|
338
|
+
})
|
|
339
|
+
timeout = self.timeout
|
|
340
|
+
verbose = self.verbose
|
|
341
|
+
max_retries = self.max_retries
|
|
342
|
+
request = HTTPRequest(
|
|
343
|
+
self.endpoint, max_retries=max_retries, verbose=verbose)
|
|
344
|
+
request.set_authorization(self.token_type, self.access_token)
|
|
345
|
+
result = request.post('/user/overview', data=data, timeout=timeout)
|
|
346
|
+
return models.Model(result)
|
|
347
|
+
|
|
281
348
|
def get_variants(self, biosample_id, rsids, **params):
|
|
282
349
|
"""根据rsid查询变异位点信息
|
|
283
350
|
|
|
@@ -290,9 +357,9 @@ class API(object):
|
|
|
290
357
|
list: 变异位点信息;
|
|
291
358
|
"""
|
|
292
359
|
if biosample_id:
|
|
293
|
-
biosample_id = biosample_id.upper()
|
|
360
|
+
biosample_id = biosample_id.upper().strip()
|
|
294
361
|
params.update({
|
|
295
|
-
'rsids': rsids,
|
|
362
|
+
'rsids': rsids.strip(),
|
|
296
363
|
'biosample_id': biosample_id
|
|
297
364
|
})
|
|
298
365
|
timeout = self.timeout
|
|
@@ -302,17 +369,14 @@ class API(object):
|
|
|
302
369
|
self.endpoint, max_retries=max_retries, verbose=verbose)
|
|
303
370
|
request.set_authorization(self.token_type, self.access_token)
|
|
304
371
|
result = request.get('/variants', params=params, timeout=timeout)
|
|
305
|
-
|
|
306
|
-
for item in result:
|
|
307
|
-
data.append(models.Model(item))
|
|
308
|
-
return data
|
|
372
|
+
return models.ListModel(result)
|
|
309
373
|
|
|
310
374
|
def professional_variant(self, biosample_id, only_variant_site=True,
|
|
311
375
|
regions=None, bed_file=None):
|
|
312
376
|
"""专业级变异数据接口
|
|
313
|
-
|
|
377
|
+
|
|
314
378
|
regions 与 bed_file 须且提供其中之一
|
|
315
|
-
|
|
379
|
+
|
|
316
380
|
Args:
|
|
317
381
|
biosample_id(str): 生物样品编号;
|
|
318
382
|
only_variant_site(bool): 是否仅输出变异位置,默认为True;
|
|
@@ -402,12 +466,7 @@ class API(object):
|
|
|
402
466
|
self.endpoint, max_retries=max_retries, verbose=verbose)
|
|
403
467
|
request.set_authorization(self.token_type, self.access_token)
|
|
404
468
|
result = request.get('/samples', params=params, timeout=timeout)
|
|
405
|
-
|
|
406
|
-
data = []
|
|
407
|
-
for item in result['result']:
|
|
408
|
-
data.append(models.Model(item))
|
|
409
|
-
result['result'] = data
|
|
410
|
-
return result
|
|
469
|
+
return models.Model(result)
|
|
411
470
|
|
|
412
471
|
def get_sample(self, biosample_id, require_files=None):
|
|
413
472
|
"""获取样品
|
|
@@ -458,7 +517,7 @@ class API(object):
|
|
|
458
517
|
self.endpoint, max_retries=max_retries, verbose=verbose)
|
|
459
518
|
request.set_authorization(self.token_type, self.access_token)
|
|
460
519
|
result = request.get(url, params=params, timeout=timeout)
|
|
461
|
-
return
|
|
520
|
+
return models.ListModel(result)
|
|
462
521
|
|
|
463
522
|
def register_sample(self, external_sample_id, biosample_site,
|
|
464
523
|
project_id, **kwargs):
|
|
@@ -550,14 +609,14 @@ class API(object):
|
|
|
550
609
|
'/microbiome/taxon_abundance', params=params, timeout=timeout)
|
|
551
610
|
# TODO: upgrade in the future
|
|
552
611
|
# 暂时特殊处理此接口,统一丰度数据的返回方式
|
|
553
|
-
ret =
|
|
612
|
+
ret = dict()
|
|
554
613
|
ret['count'] = count = pagination['count']
|
|
555
614
|
next_page = pagination['page'] + 1
|
|
556
615
|
if count == 0:
|
|
557
616
|
next_page = None
|
|
558
617
|
ret['next_page'] = next_page
|
|
559
|
-
ret['result'] =
|
|
560
|
-
return ret
|
|
618
|
+
ret['result'] = result
|
|
619
|
+
return models.Model(ret)
|
|
561
620
|
|
|
562
621
|
def get_func_abundance(self, biosample_id, catalog, ids=None, limit=50,
|
|
563
622
|
next_page=None, **params):
|
|
@@ -591,9 +650,7 @@ class API(object):
|
|
|
591
650
|
request.set_authorization(self.token_type, self.access_token)
|
|
592
651
|
result = request.get(
|
|
593
652
|
'/microbiome/func_abundance', params=params, timeout=timeout)
|
|
594
|
-
|
|
595
|
-
result['result'] = [models.Model(item) for item in result['result']]
|
|
596
|
-
return result
|
|
653
|
+
return models.Model(result)
|
|
597
654
|
|
|
598
655
|
def get_gene_abundance(self, biosample_id, catalog, data_type, ids=None,
|
|
599
656
|
limit=None, next_page=None, **params):
|
|
@@ -629,13 +686,11 @@ class API(object):
|
|
|
629
686
|
request.set_authorization(self.token_type, self.access_token)
|
|
630
687
|
result = request.get(
|
|
631
688
|
'/microbiome/gene_abundance', params=params, timeout=timeout)
|
|
632
|
-
|
|
633
|
-
result['result'] = [models.Model(item) for item in result['result']]
|
|
634
|
-
return result
|
|
689
|
+
return models.Model(result)
|
|
635
690
|
|
|
636
691
|
def get_upload_token(self, region_id=None, internal=False, **kwargs):
|
|
637
692
|
"""获取文件上传授权
|
|
638
|
-
|
|
693
|
+
|
|
639
694
|
获取的授权仅包括当前目录(不含子目录)下的文件读、写权限;
|
|
640
695
|
|
|
641
696
|
Returns:
|
|
@@ -733,7 +788,7 @@ class API(object):
|
|
|
733
788
|
sys.stdout.write('\n\n')
|
|
734
789
|
sys.stdout.flush()
|
|
735
790
|
object_names.append(object_name)
|
|
736
|
-
return object_names
|
|
791
|
+
return models.ListModel(object_names)
|
|
737
792
|
|
|
738
793
|
def upload_dir(self, dirpath, part_size=None,
|
|
739
794
|
multipart_threshold=None, multipart_num_threads=None,
|
|
@@ -774,7 +829,7 @@ class API(object):
|
|
|
774
829
|
sys.stdout.write('\n\n')
|
|
775
830
|
sys.stdout.flush()
|
|
776
831
|
object_names.append(object_name)
|
|
777
|
-
return object_names
|
|
832
|
+
return models.ListModel(object_names)
|
|
778
833
|
|
|
779
834
|
def _upload(self, token, filename, file_or_string, part_size=None,
|
|
780
835
|
multipart_threshold=None, multipart_num_threads=None,
|
|
@@ -877,6 +932,8 @@ class API(object):
|
|
|
877
932
|
domestic;
|
|
878
933
|
chunk_size(int): 下载块大小
|
|
879
934
|
expiration_time (int, 非必填): 下载地址过期时间,默认值 600s;
|
|
935
|
+
Returns:
|
|
936
|
+
None
|
|
880
937
|
"""
|
|
881
938
|
inst = self.get_download_url(
|
|
882
939
|
object_name, region=None, expiration_time=expiration_time,
|
|
@@ -922,6 +979,52 @@ class API(object):
|
|
|
922
979
|
except Exception as e:
|
|
923
980
|
raise BGEError(e)
|
|
924
981
|
|
|
982
|
+
def ferry_to_oss(self, account, password, project_no, biosample_cnt,
|
|
983
|
+
included_filename_exts=None, sample_names=None,
|
|
984
|
+
action=None, **kwargs):
|
|
985
|
+
"""下载科服文件转存至 BGE OSS
|
|
986
|
+
|
|
987
|
+
Args:
|
|
988
|
+
account (str): 华大科技账号;
|
|
989
|
+
password(str): 华大科技密码;
|
|
990
|
+
project_no (str): 华大科技项目编号;
|
|
991
|
+
biosample_cnt(int): 样本数,必须大于或等于 0;接口将通过计算下载文件中样
|
|
992
|
+
本名(参考参数 sample_names 解释)去重后与接口提供参数对比,数量无误
|
|
993
|
+
才会下载文件;
|
|
994
|
+
included_filename_exts (str, 非必填): 下载的文件后缀名可选范围:.txt、
|
|
995
|
+
.xls、.pdf、.tar.gz、.tar.gz.md5、.fq.gz,默认包含全部可选后缀,
|
|
996
|
+
多个后缀用英文逗号分割,如: .txt,.pdf;
|
|
997
|
+
sample_names (str, 非必填):样品名,将从过滤后将要下载的文件中,使用样本
|
|
998
|
+
名过滤所有 .fq.gz 的文件;样品名为要下载文件中文件名为 *_1.fq.gz 或
|
|
999
|
+
者 *_2.fq.gz 的文件, 如 E-V20000006992A_1.fq.gz 文件的样品名即
|
|
1000
|
+
为 E-V20000006992A,多个样本名用逗号分割;
|
|
1001
|
+
action (str, 非必填):动作名,可选值:restart,如果接口调用包含
|
|
1002
|
+
参数 action=restart,接口将使用接口调用的参数重新启动一个新的任务(
|
|
1003
|
+
如果相同参数的任务已经在运行,将无法重新启动任务,且接口将报错);
|
|
1004
|
+
Returns:
|
|
1005
|
+
Model: 科服文件下载转存结果
|
|
1006
|
+
"""
|
|
1007
|
+
data = {}
|
|
1008
|
+
data.update(kwargs)
|
|
1009
|
+
data.update({
|
|
1010
|
+
'account': account,
|
|
1011
|
+
'password': password,
|
|
1012
|
+
'project_no': project_no,
|
|
1013
|
+
'biosample_cnt': biosample_cnt,
|
|
1014
|
+
'included_filename_exts': included_filename_exts,
|
|
1015
|
+
'sample_names': sample_names,
|
|
1016
|
+
'action': action
|
|
1017
|
+
})
|
|
1018
|
+
timeout = self.timeout
|
|
1019
|
+
verbose = self.verbose
|
|
1020
|
+
max_retries = self.max_retries
|
|
1021
|
+
request = HTTPRequest(
|
|
1022
|
+
self.endpoint, max_retries=max_retries, verbose=verbose)
|
|
1023
|
+
request.set_authorization(self.token_type, self.access_token)
|
|
1024
|
+
result = request.post(
|
|
1025
|
+
'/ferry/download_to_oss', data=data, timeout=timeout)
|
|
1026
|
+
return models.Model(result)
|
|
1027
|
+
|
|
925
1028
|
def aggregate_omics_data(self, data_element_id, time_dimension, start_time,
|
|
926
1029
|
end_time=None, biosample_id=None,
|
|
927
1030
|
interval=1, periods=100, **kwargs):
|
|
@@ -936,7 +1039,7 @@ class API(object):
|
|
|
936
1039
|
biosample_id (str, 非必填): 生物样品编号,客户端模式下为必填;
|
|
937
1040
|
interval (int, 非必填): 聚合时间维度间隔,默认:1
|
|
938
1041
|
periods (int, 非必填): 聚合时间维度返回数,默认:100,最大值: 100
|
|
939
|
-
|
|
1042
|
+
|
|
940
1043
|
Returns:
|
|
941
1044
|
Model: 返回的聚合数据
|
|
942
1045
|
"""
|
|
@@ -968,8 +1071,7 @@ class API(object):
|
|
|
968
1071
|
sort_direction=None, limit=100, next_page=None,
|
|
969
1072
|
**kwargs):
|
|
970
1073
|
"""返回查询数据流
|
|
971
|
-
|
|
972
|
-
|
|
1074
|
+
|
|
973
1075
|
Args:
|
|
974
1076
|
biosample_id (str, 非必填): 生物样品编号,客户端模式下为必填;
|
|
975
1077
|
start_time (str, 非必填): 数据流生成时间的起始时间
|
|
@@ -977,7 +1079,7 @@ class API(object):
|
|
|
977
1079
|
sort_direction (str, 非必填): 排序方式,默认: desc
|
|
978
1080
|
limit (int, 非必填): 每页返回数量,默认:100
|
|
979
1081
|
next_page (str, 非必填): 下一页参数
|
|
980
|
-
|
|
1082
|
+
|
|
981
1083
|
Returns:
|
|
982
1084
|
Model: 返回的数据流数据
|
|
983
1085
|
"""
|
|
@@ -1340,7 +1442,7 @@ class API(object):
|
|
|
1340
1442
|
|
|
1341
1443
|
def upload_model_doc(self, doc_tab, model_id, doc_content):
|
|
1342
1444
|
"""上传模型文档
|
|
1343
|
-
|
|
1445
|
+
|
|
1344
1446
|
Args:
|
|
1345
1447
|
doc_tab (str): 文档所在的 tab。
|
|
1346
1448
|
model_id (str): 模型编号。
|
|
@@ -1399,3 +1501,65 @@ class API(object):
|
|
|
1399
1501
|
self.endpoint, max_retries=max_retries, verbose=verbose)
|
|
1400
1502
|
request.set_authorization(self.token_type, self.access_token)
|
|
1401
1503
|
request.post('/sms/send', data=data, timeout=timeout)
|
|
1504
|
+
|
|
1505
|
+
def applet_url(self, code, path=None, query=None, **kwargs):
|
|
1506
|
+
"""小程序链接
|
|
1507
|
+
|
|
1508
|
+
Args:
|
|
1509
|
+
code (字符串): BGE 平台微信应用中控所对应的编号(平台后台配置,需管理员处理);
|
|
1510
|
+
path (字符串,非必填): 通过 URL Link 进入的小程序页面路径,必须是已经发布的
|
|
1511
|
+
小程序存在的页面,不可携带 query 。path 为空时会跳转小程序主页;
|
|
1512
|
+
query (字符串,非必填): 通过 URL Link 进入小程序时的query,最大1024个字符,
|
|
1513
|
+
只支持数字,大小写英文以及部分特殊字符:!#$&’()*+,/:;=?@-._~%;
|
|
1514
|
+
|
|
1515
|
+
Returns:
|
|
1516
|
+
Model: 返回的小程序链接数据;
|
|
1517
|
+
"""
|
|
1518
|
+
data = dict()
|
|
1519
|
+
data.update(kwargs)
|
|
1520
|
+
data.update({
|
|
1521
|
+
'code': code,
|
|
1522
|
+
'path': path,
|
|
1523
|
+
'query': query,
|
|
1524
|
+
})
|
|
1525
|
+
timeout = self.timeout
|
|
1526
|
+
verbose = self.verbose
|
|
1527
|
+
max_retries = self.max_retries
|
|
1528
|
+
request = HTTPRequest(
|
|
1529
|
+
self.endpoint, max_retries=max_retries, verbose=verbose)
|
|
1530
|
+
request.set_authorization(self.token_type, self.access_token)
|
|
1531
|
+
result = request.post(
|
|
1532
|
+
'/service/wechat/applet/url', data=data, timeout=timeout)
|
|
1533
|
+
return models.Model(result)
|
|
1534
|
+
|
|
1535
|
+
def verify_id_meta(self, idcard, realname, phone=None, **kwargs):
|
|
1536
|
+
"""身份要素核验
|
|
1537
|
+
|
|
1538
|
+
传入姓名和身份证号,通过权威数据源验证其真实性和一致性。
|
|
1539
|
+
传入手机号、姓名、身份证号,通过权威数据源验证其真实性和一致性,如果不一致,返回不一致
|
|
1540
|
+
的原因。
|
|
1541
|
+
|
|
1542
|
+
Args:
|
|
1543
|
+
idcard (字符串): 身份证;
|
|
1544
|
+
realname (字符串): 真名;
|
|
1545
|
+
phone (字符串,非必填): 手机号;
|
|
1546
|
+
|
|
1547
|
+
Returns:
|
|
1548
|
+
Model: 返回的身份要素核验结果;
|
|
1549
|
+
"""
|
|
1550
|
+
data = dict()
|
|
1551
|
+
data.update(kwargs)
|
|
1552
|
+
data.update({
|
|
1553
|
+
'idcard': idcard,
|
|
1554
|
+
'realname': realname,
|
|
1555
|
+
'phone': phone,
|
|
1556
|
+
})
|
|
1557
|
+
timeout = self.timeout
|
|
1558
|
+
verbose = self.verbose
|
|
1559
|
+
max_retries = self.max_retries
|
|
1560
|
+
request = HTTPRequest(
|
|
1561
|
+
self.endpoint, max_retries=max_retries, verbose=verbose)
|
|
1562
|
+
request.set_authorization(self.token_type, self.access_token)
|
|
1563
|
+
result = request.post(
|
|
1564
|
+
'/service/verify/id_meta', data=data, timeout=timeout)
|
|
1565
|
+
return models.Model(result)
|
|
@@ -20,7 +20,7 @@ DEFAULT_TOKEN_SECTION = constants.DEFAULT_TOKEN_SECTION
|
|
|
20
20
|
|
|
21
21
|
class Command(BaseCommand):
|
|
22
22
|
|
|
23
|
-
order =
|
|
23
|
+
order = 12
|
|
24
24
|
help = '聚合组学数据(目前仅支持聚合数据流中符合平台设定 JSONPath 规则的数值型数据)。'
|
|
25
25
|
|
|
26
26
|
def add_arguments(self, parser):
|
|
@@ -99,7 +99,6 @@ class Command(BaseCommand):
|
|
|
99
99
|
output('[red]请求失败:[/red]')
|
|
100
100
|
output_json(e.result)
|
|
101
101
|
sys.exit(1)
|
|
102
|
-
output('[green]请求成功:[/green]')
|
|
103
102
|
output_json(
|
|
104
103
|
result,
|
|
105
104
|
cls=ModelEncoder
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
|
|
3
|
+
from bgesdk.client import API
|
|
4
|
+
from bgesdk.error import APIError
|
|
5
|
+
from bgesdk.management import constants
|
|
6
|
+
from bgesdk.management.command import BaseCommand
|
|
7
|
+
from bgesdk.management.utils import (
|
|
8
|
+
config_get,
|
|
9
|
+
get_active_project,
|
|
10
|
+
output,
|
|
11
|
+
output_json,
|
|
12
|
+
read_config
|
|
13
|
+
)
|
|
14
|
+
from bgesdk.models import ModelEncoder
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
DEFAULT_OAUTH2_SECTION = constants.DEFAULT_OAUTH2_SECTION
|
|
18
|
+
DEFAULT_TOKEN_SECTION = constants.DEFAULT_TOKEN_SECTION
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class Command(BaseCommand):
|
|
22
|
+
|
|
23
|
+
order = 17
|
|
24
|
+
help = (
|
|
25
|
+
'用于获取小程序加密 URL Link,链接默认于29天后过期,返回的 expire_time 字段'
|
|
26
|
+
'代表过期的时间戳(单位:秒)。'
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
def add_arguments(self, parser):
|
|
30
|
+
parser.add_argument(
|
|
31
|
+
'code',
|
|
32
|
+
type=str,
|
|
33
|
+
help='BGE 平台微信应用中控所对应的编号(平台后台配置,需管理员处理)。'
|
|
34
|
+
)
|
|
35
|
+
parser.add_argument(
|
|
36
|
+
'-p',
|
|
37
|
+
'--path',
|
|
38
|
+
type=str,
|
|
39
|
+
help='小程序路径;通过 URL Link 进入的小程序页面路径,必须是已经发布的小'
|
|
40
|
+
'程序存在的页面,不可携带 query 。path 为空时会跳转小程序主页。'
|
|
41
|
+
)
|
|
42
|
+
parser.add_argument(
|
|
43
|
+
'-q',
|
|
44
|
+
'--query',
|
|
45
|
+
type=str,
|
|
46
|
+
help='小程序参数;通过 URL Link 进入小程序时的query,最大1024个字符。'
|
|
47
|
+
)
|
|
48
|
+
parser.add_argument(
|
|
49
|
+
'-t',
|
|
50
|
+
'--access_token',
|
|
51
|
+
type=str,
|
|
52
|
+
help='访问令牌,为空时默认使用 bge token 命令获取到的 access_token。'
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
def handler(self, args):
|
|
56
|
+
access_token = args.access_token
|
|
57
|
+
project = get_active_project()
|
|
58
|
+
oauth2_section = DEFAULT_OAUTH2_SECTION
|
|
59
|
+
token_section = DEFAULT_TOKEN_SECTION
|
|
60
|
+
code = args.code
|
|
61
|
+
path = args.path
|
|
62
|
+
query = args.query
|
|
63
|
+
config = read_config(project)
|
|
64
|
+
if not access_token:
|
|
65
|
+
access_token = config_get(config.get, token_section, 'access_token')
|
|
66
|
+
endpoint = config_get(config.get, oauth2_section, 'endpoint')
|
|
67
|
+
api = API(access_token, endpoint=endpoint, timeout=18.)
|
|
68
|
+
try:
|
|
69
|
+
result = api.applet_url(code, path=path, query=query)
|
|
70
|
+
except APIError as e:
|
|
71
|
+
output('[red]请求失败:[/red]')
|
|
72
|
+
output_json(e.result)
|
|
73
|
+
sys.exit(1)
|
|
74
|
+
output_json(
|
|
75
|
+
result,
|
|
76
|
+
cls=ModelEncoder
|
|
77
|
+
)
|