ebi-eva-common-pyutils 0.6.8__py3-none-any.whl → 0.6.10__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.
- ebi_eva_common_pyutils/biosamples_communicators.py +7 -1
- ebi_eva_common_pyutils/contig_alias/contig_alias.py +46 -2
- {ebi_eva_common_pyutils-0.6.8.dist-info → ebi_eva_common_pyutils-0.6.10.dist-info}/METADATA +3 -3
- {ebi_eva_common_pyutils-0.6.8.dist-info → ebi_eva_common_pyutils-0.6.10.dist-info}/RECORD +8 -8
- {ebi_eva_common_pyutils-0.6.8.dist-info → ebi_eva_common_pyutils-0.6.10.dist-info}/WHEEL +1 -1
- {ebi_eva_common_pyutils-0.6.8.data → ebi_eva_common_pyutils-0.6.10.data}/scripts/archive_directory.py +0 -0
- {ebi_eva_common_pyutils-0.6.8.dist-info → ebi_eva_common_pyutils-0.6.10.dist-info}/LICENSE +0 -0
- {ebi_eva_common_pyutils-0.6.8.dist-info → ebi_eva_common_pyutils-0.6.10.dist-info}/top_level.txt +0 -0
|
@@ -103,9 +103,15 @@ class HALCommunicator(AppLogger):
|
|
|
103
103
|
url = re.sub('{(' + k + ')(:.*)?}', v, url)
|
|
104
104
|
if join_url:
|
|
105
105
|
url += '/' + join_url
|
|
106
|
+
text_only = False
|
|
107
|
+
if 'text_only' in kwargs and kwargs.get('text_only'):
|
|
108
|
+
text_only = kwargs.pop('text_only')
|
|
106
109
|
# Now query the url
|
|
107
|
-
|
|
110
|
+
response = self._req(method, url, **kwargs)
|
|
111
|
+
if text_only:
|
|
112
|
+
return response.text
|
|
108
113
|
|
|
114
|
+
json_response = response.json()
|
|
109
115
|
# Depaginate the call if requested
|
|
110
116
|
if all_pages is True:
|
|
111
117
|
# This depagination code will iterate over all the pages available until the pages comes back without a
|
|
@@ -22,6 +22,9 @@ class InternalServerError(Exception):
|
|
|
22
22
|
pass
|
|
23
23
|
|
|
24
24
|
|
|
25
|
+
CONTING_ALIAS_URL = 'https://www.ebi.ac.uk/eva/webservices/contig-alias'
|
|
26
|
+
|
|
27
|
+
|
|
25
28
|
# TODO add the get methods
|
|
26
29
|
class ContigAliasClient(AppLogger):
|
|
27
30
|
"""
|
|
@@ -29,8 +32,13 @@ class ContigAliasClient(AppLogger):
|
|
|
29
32
|
Authentication is required if using admin endpoints.
|
|
30
33
|
"""
|
|
31
34
|
|
|
32
|
-
def __init__(self, base_url, username=None, password=None):
|
|
33
|
-
|
|
35
|
+
def __init__(self, base_url=None, username=None, password=None, default_page_size=1000):
|
|
36
|
+
if base_url:
|
|
37
|
+
self.base_url = base_url
|
|
38
|
+
else:
|
|
39
|
+
self.base_url = os.environ.get('CONTING_ALIAS_URL') or CONTING_ALIAS_URL
|
|
40
|
+
# Used for get method
|
|
41
|
+
self.default_page_size=default_page_size
|
|
34
42
|
# Only required for admin endpoints
|
|
35
43
|
self.username = username
|
|
36
44
|
self.password = password
|
|
@@ -69,3 +77,39 @@ class ContigAliasClient(AppLogger):
|
|
|
69
77
|
raise InternalServerError
|
|
70
78
|
else:
|
|
71
79
|
self.error(f'Assembly accession {assembly} could not be deleted. Response: {response.text}')
|
|
80
|
+
|
|
81
|
+
@retry(tries=3, delay=2, backoff=1.2, jitter=(1, 3))
|
|
82
|
+
def _get_page_for_contig_alias_url(self, sub_url, page=0):
|
|
83
|
+
"""queries the contig alias to retrieve the page of the provided url"""
|
|
84
|
+
url = f'{self.base_url}/{sub_url}?page={page}&size={self.default_page_size}'
|
|
85
|
+
response = requests.get(url, headers={'accept': 'application/json'})
|
|
86
|
+
response.raise_for_status()
|
|
87
|
+
response_json = response.json()
|
|
88
|
+
return response_json
|
|
89
|
+
|
|
90
|
+
def _depaginate_iter(self, sub_url, entity_to_retrieve):
|
|
91
|
+
"""Generator that provides the contigs in the assembly requested."""
|
|
92
|
+
page = 0
|
|
93
|
+
response_json = self._get_page_for_contig_alias_url(sub_url, page=page)
|
|
94
|
+
for entity in response_json.get('_embedded', {}).get(entity_to_retrieve, []):
|
|
95
|
+
yield entity
|
|
96
|
+
while 'next' in response_json['_links']:
|
|
97
|
+
page += 1
|
|
98
|
+
response_json = self._get_page_for_contig_alias_url(sub_url, page=page)
|
|
99
|
+
for entity in response_json.get('_embedded', {}).get(entity_to_retrieve, []):
|
|
100
|
+
yield entity
|
|
101
|
+
|
|
102
|
+
def assembly_contig_iter(self, assembly_accession):
|
|
103
|
+
"""Generator that provides the contigs in the assembly requested."""
|
|
104
|
+
sub_url = f'v1/assemblies/{assembly_accession}/chromosomes'
|
|
105
|
+
return self._depaginate_iter(sub_url, 'chromosomeEntities')
|
|
106
|
+
|
|
107
|
+
def assembly(self, assembly_accession):
|
|
108
|
+
"""provides the description of the requested assembly."""
|
|
109
|
+
sub_url = f'v1/assemblies/{assembly_accession}'
|
|
110
|
+
response_json = self._get_page_for_contig_alias_url(sub_url)
|
|
111
|
+
return response_json.get('_embedded', {}).get('assemblyEntities', [])[0]
|
|
112
|
+
|
|
113
|
+
def contig_iter(self, insdc_accession):
|
|
114
|
+
sub_url = f'v1/chromosomes/genbank/{insdc_accession}'
|
|
115
|
+
return self._depaginate_iter(sub_url, 'chromosomeEntities')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
|
-
Name:
|
|
3
|
-
Version: 0.6.
|
|
2
|
+
Name: ebi-eva-common-pyutils
|
|
3
|
+
Version: 0.6.10
|
|
4
4
|
Summary: EBI EVA - Common Python Utilities
|
|
5
5
|
Home-page: https://github.com/EBIVariation/eva-common-pyutils
|
|
6
6
|
License: Apache
|
|
@@ -19,5 +19,5 @@ Requires-Dist: retry
|
|
|
19
19
|
Provides-Extra: eva-internal
|
|
20
20
|
Requires-Dist: psycopg2-binary ; extra == 'eva-internal'
|
|
21
21
|
Requires-Dist: pymongo ; extra == 'eva-internal'
|
|
22
|
-
Requires-Dist: networkx <=2.5 ; extra == 'eva-internal'
|
|
22
|
+
Requires-Dist: networkx (<=2.5) ; extra == 'eva-internal'
|
|
23
23
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
ebi_eva_common_pyutils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
ebi_eva_common_pyutils/assembly_utils.py,sha256=CklyCGlCjlFp0e9pugg6kSsh5L0xfCe2qPvA2eLVtn0,4187
|
|
3
|
-
ebi_eva_common_pyutils/biosamples_communicators.py,sha256=
|
|
3
|
+
ebi_eva_common_pyutils/biosamples_communicators.py,sha256=nyO0E_YpcAeBwbqOfbqe9RDxONq7Oe3NijSTGw7D01I,7815
|
|
4
4
|
ebi_eva_common_pyutils/command_utils.py,sha256=PtelWWqcC0eOwIVesjwBw3F9KaXRzEE_uAUJhQFZ4l8,2340
|
|
5
5
|
ebi_eva_common_pyutils/common_utils.py,sha256=ty_glvfRa3VGhnpAht4qtVkNNmv-IYfVtO958mY-BaA,1192
|
|
6
6
|
ebi_eva_common_pyutils/config.py,sha256=PtD2SgHf96kk21OA9tVIjEgsDXEFuAU-INy_kfQdoPw,4828
|
|
@@ -12,7 +12,7 @@ ebi_eva_common_pyutils/network_utils.py,sha256=iJjs5PPzT1V4CceZnCHOTs711AmpwlDo5
|
|
|
12
12
|
ebi_eva_common_pyutils/assembly/__init__.py,sha256=KSWPwBY5nZj00odxWFntk8Sqg_rw273xH8S5D6Jo-T4,67
|
|
13
13
|
ebi_eva_common_pyutils/assembly/assembly.py,sha256=IEmleROX4ZchPyhINKCuMmET_Ih1Jg4ok-opAKY6Z9A,3142
|
|
14
14
|
ebi_eva_common_pyutils/contig_alias/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
|
-
ebi_eva_common_pyutils/contig_alias/contig_alias.py,sha256=
|
|
15
|
+
ebi_eva_common_pyutils/contig_alias/contig_alias.py,sha256=7tQXljEJtRCMs_JPrglYvTEZ-fJvzl8txwnCvqRB3Ck,5214
|
|
16
16
|
ebi_eva_common_pyutils/reference/__init__.py,sha256=NsDjGCu2H2CZLOPaEL6GCoZo5ND_EA9RFmbzGfpSXRQ,134
|
|
17
17
|
ebi_eva_common_pyutils/reference/assembly.py,sha256=FK4zsvg4_GDeKd9z2z5ZeM9R84TsusgQYdMOGuggQU0,12162
|
|
18
18
|
ebi_eva_common_pyutils/reference/sequence.py,sha256=bg96QcuB-oytQYpaUkV10OzM_RIFhxsy6t3PQOg2Gy0,3911
|
|
@@ -20,7 +20,7 @@ ebi_eva_common_pyutils/taxonomy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm
|
|
|
20
20
|
ebi_eva_common_pyutils/taxonomy/taxonomy.py,sha256=p3XV4g3y0hEjyeZ4PwgN7Q3Et9G515ctQkSIo1kdDbU,2259
|
|
21
21
|
ebi_eva_common_pyutils/variation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
22
|
ebi_eva_common_pyutils/variation/contig_utils.py,sha256=kMNEW_P2yPnd8Xx1tep19hy5ee7ojxz6ZOO1grTQsRQ,5230
|
|
23
|
-
ebi_eva_common_pyutils-0.6.
|
|
23
|
+
ebi_eva_common_pyutils-0.6.10.data/scripts/archive_directory.py,sha256=0lWJ0ju_AB2ni7lMnJXPFx6U2OdTGbe-WoQs-4BfKOM,4976
|
|
24
24
|
ebi_eva_internal_pyutils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
25
|
ebi_eva_internal_pyutils/archive_directory.py,sha256=IxVEfh_gaCiT652k0Q_-58fonRusy1yzXu7BCO8yVLo,4989
|
|
26
26
|
ebi_eva_internal_pyutils/config_utils.py,sha256=EGRC5rsmU_ug7OY9-t1UW1XZXRsauSyZB9xPcBux8ts,7909
|
|
@@ -32,8 +32,8 @@ ebi_eva_internal_pyutils/mongodb/__init__.py,sha256=0oyTlkYZCV7udlPl09Zl-sDyE3c9
|
|
|
32
32
|
ebi_eva_internal_pyutils/mongodb/mongo_database.py,sha256=kesaJaaxYFeF_uYZBgL8tbufGKUXll7bXb4WlOS9vKM,9596
|
|
33
33
|
ebi_eva_internal_pyutils/nextflow/__init__.py,sha256=OOiJS8jZOz98q0t77NNog7aI_fFrVxi4kGmiSskuAqM,122
|
|
34
34
|
ebi_eva_internal_pyutils/nextflow/nextflow_pipeline.py,sha256=ew623hhK8jmFLQjJwLZbgBmW9RTiJBEULVqHfIUv_dc,10114
|
|
35
|
-
ebi_eva_common_pyutils-0.6.
|
|
36
|
-
ebi_eva_common_pyutils-0.6.
|
|
37
|
-
ebi_eva_common_pyutils-0.6.
|
|
38
|
-
ebi_eva_common_pyutils-0.6.
|
|
39
|
-
ebi_eva_common_pyutils-0.6.
|
|
35
|
+
ebi_eva_common_pyutils-0.6.10.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
36
|
+
ebi_eva_common_pyutils-0.6.10.dist-info/METADATA,sha256=bBaC1wBXTMZ8Sip4qg0Fb9MpapoMsaga7Hh0C8pQBWs,825
|
|
37
|
+
ebi_eva_common_pyutils-0.6.10.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
|
38
|
+
ebi_eva_common_pyutils-0.6.10.dist-info/top_level.txt,sha256=sXoiqiGU8vlMQpFWDlKrekxhlusk06AhkOH3kSvDT6c,48
|
|
39
|
+
ebi_eva_common_pyutils-0.6.10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
{ebi_eva_common_pyutils-0.6.8.dist-info → ebi_eva_common_pyutils-0.6.10.dist-info}/top_level.txt
RENAMED
|
File without changes
|