pymetadata 0.4.2__tar.gz → 0.4.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pymetadata might be problematic. Click here for more details.

Files changed (49) hide show
  1. {pymetadata-0.4.2/src/pymetadata.egg-info → pymetadata-0.4.4}/PKG-INFO +22 -6
  2. {pymetadata-0.4.2 → pymetadata-0.4.4}/README.rst +21 -5
  3. {pymetadata-0.4.2 → pymetadata-0.4.4}/setup.cfg +1 -1
  4. {pymetadata-0.4.2 → pymetadata-0.4.4}/setup.py +1 -1
  5. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata/__init__.py +2 -2
  6. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata/cache.py +1 -0
  7. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata/chebi.py +11 -6
  8. pymetadata-0.4.4/src/pymetadata/examples/cache_path_example.py +15 -0
  9. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata/identifiers/registry.py +4 -4
  10. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata/ontologies/ols.py +9 -3
  11. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata/unichem.py +16 -13
  12. {pymetadata-0.4.2 → pymetadata-0.4.4/src/pymetadata.egg-info}/PKG-INFO +22 -6
  13. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata.egg-info/SOURCES.txt +1 -1
  14. {pymetadata-0.4.2 → pymetadata-0.4.4}/tests/test_unichem.py +2 -2
  15. pymetadata-0.4.2/src/pymetadata/resources/identifiers_registry.json +0 -46128
  16. {pymetadata-0.4.2 → pymetadata-0.4.4}/LICENSE +0 -0
  17. {pymetadata-0.4.2 → pymetadata-0.4.4}/MANIFEST.in +0 -0
  18. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata/console.py +0 -0
  19. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata/core/__init__.py +0 -0
  20. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata/core/annotation.py +0 -0
  21. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata/core/creator.py +0 -0
  22. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata/core/synonym.py +0 -0
  23. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata/core/xref.py +0 -0
  24. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata/examples/__init__.py +0 -0
  25. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata/examples/omex_example.py +0 -0
  26. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata/identifiers/__init__.py +0 -0
  27. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata/identifiers/miriam.py +0 -0
  28. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata/log.py +0 -0
  29. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata/metadata/__init__.py +0 -0
  30. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata/metadata/eco.py +0 -0
  31. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata/metadata/kisao.py +0 -0
  32. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata/metadata/sbo.py +0 -0
  33. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata/omex.py +0 -0
  34. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata/omex_v2.py +0 -0
  35. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata/ontologies/__init__.py +0 -0
  36. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata/ontologies/ontology.py +0 -0
  37. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata/py.typed +0 -0
  38. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata/resources/chebi_webservice_wsdl.xml +0 -0
  39. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata/resources/templates/ontology_enum.pytemplate +0 -0
  40. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata.egg-info/dependency_links.txt +0 -0
  41. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata.egg-info/requires.txt +0 -0
  42. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata.egg-info/top_level.txt +0 -0
  43. {pymetadata-0.4.2 → pymetadata-0.4.4}/src/pymetadata.egg-info/zip-safe +0 -0
  44. {pymetadata-0.4.2 → pymetadata-0.4.4}/tests/test_chebi.py +0 -0
  45. {pymetadata-0.4.2 → pymetadata-0.4.4}/tests/test_ols.py +0 -0
  46. {pymetadata-0.4.2 → pymetadata-0.4.4}/tests/test_omex.py +0 -0
  47. {pymetadata-0.4.2 → pymetadata-0.4.4}/tests/test_ontology.py +0 -0
  48. {pymetadata-0.4.2 → pymetadata-0.4.4}/tests/test_registry.py +0 -0
  49. {pymetadata-0.4.2 → pymetadata-0.4.4}/tests/test_sbo_kisao.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pymetadata
3
- Version: 0.4.2
3
+ Version: 0.4.4
4
4
  Summary: pymetadata are python utilities for working with metadata.
5
5
  Home-page: https://github.com/matthiaskoenig/pymetadata
6
6
  Download-URL: https://pypi.org/project/pymetadata
@@ -131,11 +131,14 @@ PARTICULAR PURPOSE. See the GNU General Public License for more details.
131
131
 
132
132
  Funding
133
133
  =======
134
- Matthias König was supported by the Federal Ministry of Education and Research (BMBF, Germany)
135
- within the research network Systems Medicine of the Liver (**LiSyM**, grant number 031L0054)
136
- and is supported by the German Research Foundation (DFG) within the Research Unit Programme FOR 5151
137
- "`QuaLiPerF <https://qualiperf.de>`__ (Quantifying Liver Perfusion-Function Relationship in Complex Resection -
138
- A Systems Medicine Approach)" by grant number 436883643 and by grant number 465194077 (Priority Programme SPP 2311, Subproject SimLivA), and
134
+ Matthias König (MK) was supported by the Federal Ministry of Education and Research
135
+ (BMBF, Germany) within the research network Systems Medicine of the Liver
136
+ (**LiSyM**, grant number 031L0054). MK is supported by the Federal Ministry of
137
+ Education and Research (BMBF, Germany) within ATLAS by grant number 031L0304B and
138
+ by the German Research Foundation (DFG) within the Research Unit Program FOR 5151
139
+ QuaLiPerF (Quantifying Liver Perfusion-Function Relationship in Complex Resection
140
+ - A Systems Medicine Approach) by grant number 436883643 and by grant number
141
+ 465194077 (Priority Programme SPP 2311, Subproject SimLivA).
139
142
 
140
143
  Installation
141
144
  ============
@@ -156,8 +159,21 @@ Or via cloning the repository and installing via::
156
159
  cd pymetadata
157
160
  pip install -e .
158
161
 
162
+
159
163
  To install for development use::
160
164
 
161
165
  pip install -e .[development]
162
166
 
167
+
168
+ Cache path
169
+ ==========
170
+ `pymetadata` caches some information for faster retrieval. The cache path is set to::
171
+
172
+ CACHE_PATH: Path = Path.home() / ".cache" / "pymetadata"
173
+
174
+ To use a custom cache path use::
175
+
176
+ import pymetadata
177
+ pymetadata.CACHE_PATH = <cache_path>
178
+
163
179
  © 2021-2024 Matthias König
@@ -80,11 +80,14 @@ PARTICULAR PURPOSE. See the GNU General Public License for more details.
80
80
 
81
81
  Funding
82
82
  =======
83
- Matthias König was supported by the Federal Ministry of Education and Research (BMBF, Germany)
84
- within the research network Systems Medicine of the Liver (**LiSyM**, grant number 031L0054)
85
- and is supported by the German Research Foundation (DFG) within the Research Unit Programme FOR 5151
86
- "`QuaLiPerF <https://qualiperf.de>`__ (Quantifying Liver Perfusion-Function Relationship in Complex Resection -
87
- A Systems Medicine Approach)" by grant number 436883643 and by grant number 465194077 (Priority Programme SPP 2311, Subproject SimLivA), and
83
+ Matthias König (MK) was supported by the Federal Ministry of Education and Research
84
+ (BMBF, Germany) within the research network Systems Medicine of the Liver
85
+ (**LiSyM**, grant number 031L0054). MK is supported by the Federal Ministry of
86
+ Education and Research (BMBF, Germany) within ATLAS by grant number 031L0304B and
87
+ by the German Research Foundation (DFG) within the Research Unit Program FOR 5151
88
+ QuaLiPerF (Quantifying Liver Perfusion-Function Relationship in Complex Resection
89
+ - A Systems Medicine Approach) by grant number 436883643 and by grant number
90
+ 465194077 (Priority Programme SPP 2311, Subproject SimLivA).
88
91
 
89
92
  Installation
90
93
  ============
@@ -105,8 +108,21 @@ Or via cloning the repository and installing via::
105
108
  cd pymetadata
106
109
  pip install -e .
107
110
 
111
+
108
112
  To install for development use::
109
113
 
110
114
  pip install -e .[development]
111
115
 
116
+
117
+ Cache path
118
+ ==========
119
+ `pymetadata` caches some information for faster retrieval. The cache path is set to::
120
+
121
+ CACHE_PATH: Path = Path.home() / ".cache" / "pymetadata"
122
+
123
+ To use a custom cache path use::
124
+
125
+ import pymetadata
126
+ pymetadata.CACHE_PATH = <cache_path>
127
+
112
128
  © 2021-2024 Matthias König
@@ -1,5 +1,5 @@
1
1
  [bumpversion]
2
- current_version = 0.4.2
2
+ current_version = 0.4.4
3
3
  commit = True
4
4
  tag = True
5
5
  parse = (?P<major>\d+)
@@ -4,4 +4,4 @@ from setuptools import setup # type: ignore
4
4
 
5
5
 
6
6
  if __name__ == "__main__":
7
- setup(version="0.4.2")
7
+ setup(version="0.4.4")
@@ -3,7 +3,7 @@
3
3
  from pathlib import Path
4
4
 
5
5
  __author__ = "Matthias Koenig"
6
- __version__ = "0.4.2"
6
+ __version__ = "0.4.4"
7
7
 
8
8
 
9
9
  program_name: str = "pymetadata"
@@ -11,4 +11,4 @@ RESOURCES_DIR: Path = Path(__file__).parent / "resources"
11
11
  ENUM_DIR: Path = Path(__file__).parent / "metadata"
12
12
 
13
13
  CACHE_USE: bool = False
14
- CACHE_PATH: Path = RESOURCES_DIR / "cache"
14
+ CACHE_PATH: Path = Path.home() / ".cache" / "pymetadata"
@@ -43,6 +43,7 @@ def write_json_cache(
43
43
  :param json_encoder: optional JSON encoder
44
44
  :return:
45
45
  """
46
+ cache_path.parent.mkdir(parents=True, exist_ok=True)
46
47
  with open(cache_path, "w") as fp:
47
48
  logger.info(f"Write cache: {cache_path}")
48
49
  if json_encoder:
@@ -2,18 +2,19 @@
2
2
 
3
3
  from pathlib import Path
4
4
  from pprint import pprint
5
- from typing import Any, Dict
5
+ from typing import Any, Dict, Optional
6
6
 
7
7
  from zeep import Client
8
8
 
9
- from pymetadata import CACHE_PATH, CACHE_USE, RESOURCES_DIR, log
9
+ import pymetadata
10
+ from pymetadata import log
10
11
  from pymetadata.cache import DataclassJSONEncoder, read_json_cache, write_json_cache
11
12
 
12
13
 
13
14
  logger = log.get_logger(__name__)
14
15
 
15
- # client = Client('https://www.ebi.ac.uk/webservices/chebi/2.0/webservice?wsdl')
16
- client = Client(str(RESOURCES_DIR / "chebi_webservice_wsdl.xml"))
16
+ # FIXME: copy the file to the cache dir
17
+ client = Client(str(pymetadata.RESOURCES_DIR / "chebi_webservice_wsdl.xml"))
17
18
 
18
19
 
19
20
  class ChebiQuery:
@@ -25,15 +26,19 @@ class ChebiQuery:
25
26
 
26
27
  @staticmethod
27
28
  def query(
28
- chebi: str, cache: bool = CACHE_USE, cache_path: Path = CACHE_PATH
29
+ chebi: str, cache: Optional[bool] = None, cache_path: Optional[Path] = None
29
30
  ) -> Dict:
30
31
  """Query additional ChEBI information."""
31
32
 
32
33
  if not chebi:
33
34
  return dict()
35
+ if cache is None:
36
+ cache = pymetadata.CACHE_USE
37
+ if cache_path is None:
38
+ cache_path = pymetadata.CACHE_PATH
34
39
 
35
40
  # caching
36
- chebi_base_path = cache_path / "chebi"
41
+ chebi_base_path = Path(cache_path) / "chebi"
37
42
  if not chebi_base_path.exists():
38
43
  chebi_base_path.mkdir(parents=True)
39
44
 
@@ -0,0 +1,15 @@
1
+ """Example for customizing the cache path."""
2
+
3
+ from pathlib import Path
4
+
5
+ import pymetadata
6
+ from pymetadata.chebi import ChebiQuery
7
+
8
+
9
+ pymetadata.CACHE_PATH = Path.home() / ".cache" / "pymetadata"
10
+
11
+ if __name__ == "__main__":
12
+
13
+ chebis = ["CHEBI:2668", "CHEBI:138366", "CHEBI:9637", "CHEBI:155897"]
14
+ for chebi in chebis:
15
+ d = ChebiQuery.query(chebi=chebi, cache=True)
@@ -16,7 +16,8 @@ from typing import Any, Dict, List, Optional
16
16
 
17
17
  import requests
18
18
 
19
- from pymetadata import RESOURCES_DIR, log
19
+ import pymetadata
20
+ from pymetadata import CACHE_PATH, log
20
21
  from pymetadata.cache import DataclassJSONEncoder, read_json_cache, write_json_cache
21
22
 
22
23
 
@@ -298,7 +299,6 @@ class Registry:
298
299
 
299
300
  def __init__(
300
301
  self,
301
- registry_path: Path = RESOURCES_DIR / "identifiers_registry.json",
302
302
  cache_duration: int = 24,
303
303
  cache: bool = True,
304
304
  ):
@@ -308,13 +308,13 @@ class Registry:
308
308
  :param cache_duration: Duration of caching in hours.
309
309
  :param cache: boolean flag to stop caching
310
310
  """
311
- self.registry_path = registry_path
311
+ self.registry_path = pymetadata.CACHE_PATH / "identifiers_registry.json"
312
312
 
313
313
  # check if update needed
314
314
  if cache:
315
315
  if os.path.exists(self.registry_path):
316
316
  registry_age = (
317
- time.time() - os.path.getmtime(registry_path)
317
+ time.time() - os.path.getmtime(self.registry_path)
318
318
  ) / 3600 # [hr]
319
319
  update = registry_age > cache_duration
320
320
  else:
@@ -12,7 +12,8 @@ from typing import Any, Dict, List, Optional
12
12
 
13
13
  import requests
14
14
 
15
- from pymetadata import CACHE_PATH, CACHE_USE, log
15
+ import pymetadata
16
+ from pymetadata import log
16
17
  from pymetadata.cache import read_json_cache, write_json_cache
17
18
  from pymetadata.identifiers.registry import Registry
18
19
 
@@ -76,13 +77,18 @@ class OLSQuery:
76
77
  def __init__(
77
78
  self,
78
79
  ontologies: List[OLSOntology],
79
- cache_path: Path = CACHE_PATH,
80
- cache: bool = CACHE_USE,
80
+ cache_path: Optional[Path] = None,
81
+ cache: Optional[bool] = None,
81
82
  ):
82
83
  """Initialize OLSQuery."""
83
84
  self.ontologies: Dict[str, OLSOntology] = {
84
85
  ontology.name: ontology for ontology in ontologies
85
86
  }
87
+ if not cache_path:
88
+ cache_path = pymetadata.CACHE_PATH
89
+ if not cache:
90
+ cache = pymetadata.CACHE_USE
91
+
86
92
  self.cache_path = cache_path / "ols"
87
93
  self.cache = cache
88
94
 
@@ -14,7 +14,8 @@ from typing import Dict, List, Optional
14
14
 
15
15
  import requests
16
16
 
17
- from pymetadata import CACHE_PATH, CACHE_USE, log
17
+ import pymetadata
18
+ from pymetadata import log
18
19
  from pymetadata.cache import DataclassJSONEncoder, read_json_cache, write_json_cache
19
20
  from pymetadata.core.xref import CrossReference
20
21
 
@@ -59,27 +60,27 @@ class UnichemQuery:
59
60
 
60
61
  sources: Dict[int, UnichemSource] = {}
61
62
 
62
- def __init__(self, cache_path: Path = CACHE_PATH, cache: bool = CACHE_USE):
63
+ def __init__(self, cache_path: Optional[Path] = None, cache: Optional[bool] = None):
63
64
  """Initialize UnichemQuery."""
65
+ if cache_path is None:
66
+ cache_path = pymetadata.CACHE_PATH
67
+ if cache is None:
68
+ cache = pymetadata.CACHE_USE
69
+
64
70
  self.cache_path: Path = cache_path
65
71
  self.cache: bool = cache
66
72
 
67
73
  if not self.sources:
68
- self.sources = self.get_sources(
69
- cache_path=self.cache_path, cache=self.cache
70
- )
74
+ self.sources = self.get_sources()
71
75
 
72
- @classmethod
73
- def get_sources(
74
- cls, cache_path: Path = CACHE_PATH, cache: bool = CACHE_USE
75
- ) -> Dict[int, UnichemSource]:
76
+ def get_sources(self) -> Dict[int, UnichemSource]:
76
77
  """Retrieve or query the sources."""
77
78
 
78
79
  sources: Dict[int, UnichemSource]
79
- unichem_sources_path = cache_path / "unichem_sources.json"
80
+ unichem_sources_path = self.cache_path / "unichem_sources.json"
80
81
 
81
82
  data: Dict
82
- if cache and unichem_sources_path.exists():
83
+ if self.cache and unichem_sources_path.exists():
83
84
  data = read_json_cache(unichem_sources_path)
84
85
  sources = {int(k): UnichemSource(**v) for k, v in data.items()}
85
86
  else:
@@ -96,7 +97,7 @@ class UnichemQuery:
96
97
  sources = {source.sourceID: source for source in sources_list}
97
98
 
98
99
  # write cache
99
- if cache:
100
+ if self.cache:
100
101
  write_json_cache(
101
102
  data=sources,
102
103
  cache_path=unichem_sources_path,
@@ -174,8 +175,10 @@ class UnichemQuery:
174
175
 
175
176
 
176
177
  if __name__ == "__main__":
178
+ pymetadata.CACHE_PATH = Path.home() / ".cache" / "pymetadata"
179
+
177
180
  # query sources
178
- sources = UnichemQuery.get_sources()
181
+ sources = UnichemQuery().get_sources()
179
182
 
180
183
  # query xrefs
181
184
  inchikey = "NGBFQHCMQULJNZ-UHFFFAOYSA-N"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pymetadata
3
- Version: 0.4.2
3
+ Version: 0.4.4
4
4
  Summary: pymetadata are python utilities for working with metadata.
5
5
  Home-page: https://github.com/matthiaskoenig/pymetadata
6
6
  Download-URL: https://pypi.org/project/pymetadata
@@ -131,11 +131,14 @@ PARTICULAR PURPOSE. See the GNU General Public License for more details.
131
131
 
132
132
  Funding
133
133
  =======
134
- Matthias König was supported by the Federal Ministry of Education and Research (BMBF, Germany)
135
- within the research network Systems Medicine of the Liver (**LiSyM**, grant number 031L0054)
136
- and is supported by the German Research Foundation (DFG) within the Research Unit Programme FOR 5151
137
- "`QuaLiPerF <https://qualiperf.de>`__ (Quantifying Liver Perfusion-Function Relationship in Complex Resection -
138
- A Systems Medicine Approach)" by grant number 436883643 and by grant number 465194077 (Priority Programme SPP 2311, Subproject SimLivA), and
134
+ Matthias König (MK) was supported by the Federal Ministry of Education and Research
135
+ (BMBF, Germany) within the research network Systems Medicine of the Liver
136
+ (**LiSyM**, grant number 031L0054). MK is supported by the Federal Ministry of
137
+ Education and Research (BMBF, Germany) within ATLAS by grant number 031L0304B and
138
+ by the German Research Foundation (DFG) within the Research Unit Program FOR 5151
139
+ QuaLiPerF (Quantifying Liver Perfusion-Function Relationship in Complex Resection
140
+ - A Systems Medicine Approach) by grant number 436883643 and by grant number
141
+ 465194077 (Priority Programme SPP 2311, Subproject SimLivA).
139
142
 
140
143
  Installation
141
144
  ============
@@ -156,8 +159,21 @@ Or via cloning the repository and installing via::
156
159
  cd pymetadata
157
160
  pip install -e .
158
161
 
162
+
159
163
  To install for development use::
160
164
 
161
165
  pip install -e .[development]
162
166
 
167
+
168
+ Cache path
169
+ ==========
170
+ `pymetadata` caches some information for faster retrieval. The cache path is set to::
171
+
172
+ CACHE_PATH: Path = Path.home() / ".cache" / "pymetadata"
173
+
174
+ To use a custom cache path use::
175
+
176
+ import pymetadata
177
+ pymetadata.CACHE_PATH = <cache_path>
178
+
163
179
  © 2021-2024 Matthias König
@@ -24,6 +24,7 @@ src/pymetadata/core/creator.py
24
24
  src/pymetadata/core/synonym.py
25
25
  src/pymetadata/core/xref.py
26
26
  src/pymetadata/examples/__init__.py
27
+ src/pymetadata/examples/cache_path_example.py
27
28
  src/pymetadata/examples/omex_example.py
28
29
  src/pymetadata/identifiers/__init__.py
29
30
  src/pymetadata/identifiers/miriam.py
@@ -36,7 +37,6 @@ src/pymetadata/ontologies/__init__.py
36
37
  src/pymetadata/ontologies/ols.py
37
38
  src/pymetadata/ontologies/ontology.py
38
39
  src/pymetadata/resources/chebi_webservice_wsdl.xml
39
- src/pymetadata/resources/identifiers_registry.json
40
40
  src/pymetadata/resources/templates/ontology_enum.pytemplate
41
41
  tests/test_chebi.py
42
42
  tests/test_ols.py
@@ -9,11 +9,11 @@ from pymetadata.unichem import UnichemQuery, UnichemSource
9
9
  def test_get_sources(tmp_path: Path) -> None:
10
10
  """Test retrieving sources."""
11
11
  cache_path: Path = tmp_path
12
- sources = UnichemQuery.get_sources(cache=True, cache_path=cache_path)
12
+ sources = UnichemQuery(cache=True, cache_path=cache_path).get_sources()
13
13
  assert sources
14
14
  assert (cache_path / "unichem_sources.json").exists()
15
15
 
16
- sources = UnichemQuery.get_sources(cache=True, cache_path=cache_path)
16
+ sources = UnichemQuery(cache=True, cache_path=cache_path).get_sources()
17
17
  assert sources
18
18
 
19
19