biocypher 0.9.4__py3-none-any.whl → 0.9.6__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.

Potentially problematic release.


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

biocypher/_get.py CHANGED
@@ -420,7 +420,7 @@ class Downloader:
420
420
  with open(self.cache_file, "w") as f:
421
421
  json.dump({}, f)
422
422
 
423
- with open(self.cache_file, "r") as f:
423
+ with open(self.cache_file) as f:
424
424
  logger.info(f"Loading cache file {self.cache_file}.")
425
425
  return json.load(f)
426
426
 
biocypher/_metadata.py CHANGED
@@ -10,7 +10,7 @@ import pathlib
10
10
 
11
11
  import toml
12
12
 
13
- _VERSION = "0.9.4"
13
+ _VERSION = "0.9.6"
14
14
 
15
15
 
16
16
  def get_metadata():
@@ -16,14 +16,18 @@ __all__ = ["get_connector"]
16
16
  def get_connector(
17
17
  dbms: str,
18
18
  translator: Translator,
19
- ):
20
- """
21
- Function to return the connector class.
19
+ ) -> _Neo4jDriver:
20
+ """Return the connector class.
22
21
 
23
- Returns:
22
+ Returns
23
+ -------
24
24
  class: the connector class
25
- """
26
25
 
26
+ Raises
27
+ ------
28
+ NotImplementedError: if the DBMS is not supported
29
+
30
+ """
27
31
  dbms_config = _config(dbms)
28
32
 
29
33
  if dbms == "neo4j":
@@ -36,5 +40,7 @@ def get_connector(
36
40
  multi_db=dbms_config["multi_db"],
37
41
  translator=translator,
38
42
  )
39
- else:
40
- raise NotImplementedError(f"Online mode is not supported for the DBMS {dbms}.")
43
+
44
+ msg = f"Online mode is not supported for the DBMS {dbms}."
45
+ logger.error(msg)
46
+ raise NotImplementedError(msg)
@@ -1,12 +1,20 @@
1
+ """BioCypher 'in_memory' module.
2
+
3
+ Handles the in-memory Knowledge Graph instance.
1
4
  """
2
- BioCypher 'in_memory' module. Handles the in-memory Knowledge Graph instance.
3
- """
4
5
 
5
- from biocypher._deduplicate import Deduplicator
6
+ from __future__ import annotations
7
+
8
+ from typing import TYPE_CHECKING
9
+
6
10
  from biocypher._logger import logger
7
11
  from biocypher.output.in_memory._networkx import NetworkxKG
8
12
  from biocypher.output.in_memory._pandas import PandasKG
9
13
 
14
+ if TYPE_CHECKING:
15
+ from biocypher._deduplicate import Deduplicator
16
+ from biocypher.output.in_memory._in_memory_kg import _InMemoryKG
17
+
10
18
  logger.debug(f"Loading module {__name__}.")
11
19
 
12
20
  __all__ = ["get_in_memory_kg"]
@@ -17,18 +25,20 @@ IN_MEMORY_DBMS = ["csv", "pandas", "tabular", "networkx"]
17
25
  def get_in_memory_kg(
18
26
  dbms: str,
19
27
  deduplicator: Deduplicator,
20
- ):
21
- """
22
- Function to return the in-memory KG class.
28
+ ) -> _InMemoryKG:
29
+ """Return the in-memory KG class.
30
+
31
+ Returns
32
+ -------
33
+ _InMemoryKG: the in-memory KG class
23
34
 
24
- Returns:
25
- class: the in-memory KG class
26
35
  """
27
36
  if dbms in ["csv", "pandas", "tabular"]:
28
37
  return PandasKG(deduplicator)
29
- elif dbms == "networkx":
38
+
39
+ if dbms == "networkx":
30
40
  return NetworkxKG(deduplicator)
31
- else:
32
- raise NotImplementedError(
33
- f"Getting the in memory BioCypher KG is not supported for the DBMS {dbms}. Supported: {IN_MEMORY_DBMS}."
34
- )
41
+
42
+ msg = f"Getting the in memory BioCypher KG is not supported for the DBMS {dbms}. Supported: {IN_MEMORY_DBMS}."
43
+ logger.error(msg)
44
+ raise NotImplementedError(msg)
@@ -278,9 +278,7 @@ class _Neo4jBatchWriter(_BatchWriter):
278
278
  """
279
279
  import_call_neo4j_v4 = self._get_import_call("import", "--database=", "--force=")
280
280
  import_call_neo4j_v5 = self._get_import_call("database import full", "", "--overwrite-destination=")
281
- neo4j_version_check = (
282
- f"version=$({self._get_default_import_call_bin_prefix()}neo4j-admin --version | cut -d '.' -f 1)"
283
- )
281
+ neo4j_version_check = f"version=$({self.import_call_bin_prefix}neo4j-admin --version | cut -d '.' -f 1)"
284
282
 
285
283
  import_script = (
286
284
  f"#!/bin/bash\n{neo4j_version_check}\nif [[ $version -ge 5 ]]; "
@@ -6,7 +6,8 @@ from biocypher.output.write._batch_writer import _BatchWriter
6
6
 
7
7
 
8
8
  class _PostgreSQLBatchWriter(_BatchWriter):
9
- """
9
+ """Write node and edge representations for PostgreSQL.
10
+
10
11
  Class for writing node and edge representations to disk using the
11
12
  format specified by PostgreSQL for the use of "COPY FROM...". Each batch
12
13
  writer instance has a fixed representation that needs to be passed
@@ -39,12 +40,13 @@ class _PostgreSQLBatchWriter(_BatchWriter):
39
40
  self._copy_from_csv_commands = set()
40
41
  super().__init__(*args, **kwargs)
41
42
 
42
- def _get_default_import_call_bin_prefix(self):
43
- """
44
- Method to provide the default string for the import call bin prefix.
43
+ def _get_default_import_call_bin_prefix(self) -> str:
44
+ """Provide the default string for the import call bin prefix.
45
45
 
46
- Returns:
46
+ Returns
47
+ -------
47
48
  str: The default location for the psql command
49
+
48
50
  """
49
51
  return ""
50
52
 
@@ -56,33 +58,36 @@ class _PostgreSQLBatchWriter(_BatchWriter):
56
58
  return "VARCHAR"
57
59
 
58
60
  def _quote_string(self, value: str) -> str:
59
- """
60
- Quote a string.
61
- """
62
-
61
+ """Quote a string."""
63
62
  return f"{self.quote}{value}{self.quote}"
64
63
 
65
64
  def _write_array_string(self, string_list) -> str:
66
- """
67
- Abstract method to output.write the string representation of an array into a .csv file
68
- as required by the postgresql COPY command, with '{','}' brackets and ',' separation.
65
+ """Write the string representation of an array into a .csv file.
66
+
67
+ Abstract method to output.write the string representation of an array
68
+ into a .csv file as required by the postgresql COPY command, with
69
+ '{','}' brackets and ',' separation.
69
70
 
70
71
  Args:
72
+ ----
71
73
  string_list (list): list of ontology strings
72
74
 
73
75
  Returns:
76
+ -------
74
77
  str: The string representation of an array for postgres COPY
78
+
75
79
  """
76
80
  string = ",".join(string_list)
77
81
  string = f'"{{{string}}}"'
78
82
  return string
79
83
 
80
84
  def _get_import_script_name(self) -> str:
81
- """
82
- Returns the name of the psql import script
85
+ """Return the name of the psql import script.
83
86
 
84
- Returns:
87
+ Returns
88
+ -------
85
89
  str: The name of the import script (ending in .sh)
90
+
86
91
  """
87
92
  return f"{self.db_name}-import-call.sh"
88
93
 
@@ -91,14 +96,17 @@ class _PostgreSQLBatchWriter(_BatchWriter):
91
96
  string = string.lower()
92
97
  return string
93
98
 
94
- def _write_node_headers(self):
95
- """
99
+ def _write_node_headers(self) -> bool:
100
+ """Write node header files for PostgreSQL.
101
+
96
102
  Writes single CSV file for a graph entity that is represented
97
103
  as a node as per the definition in the `schema_config.yaml`,
98
104
  containing only the header for this type of node.
99
105
 
100
- Returns:
106
+ Returns
107
+ -------
101
108
  bool: The return value. True for success, False otherwise.
109
+
102
110
  """
103
111
  # load headers from data parse
104
112
  if not self.node_property_dict:
@@ -158,7 +166,7 @@ class _PostgreSQLBatchWriter(_BatchWriter):
158
166
  )
159
167
 
160
168
  self._copy_from_csv_commands.add(
161
- f"\\copy {pascal_label} FROM '{parts_path}' DELIMITER E'{self.delim}' CSV;"
169
+ f"\\copy {pascal_label} FROM '{parts_path}' DELIMITER E'{self.delim}' CSV;",
162
170
  )
163
171
 
164
172
  # add file path to import statement
@@ -175,13 +183,14 @@ class _PostgreSQLBatchWriter(_BatchWriter):
175
183
  return True
176
184
 
177
185
  def _write_edge_headers(self):
178
- """
179
- Writes single CSV file for a graph entity that is represented
186
+ """Writes single CSV file for a graph entity that is represented
180
187
  as an edge as per the definition in the `schema_config.yaml`,
181
188
  containing only the header for this type of edge.
182
189
 
183
- Returns:
190
+ Returns
191
+ -------
184
192
  bool: The return value. True for success, False otherwise.
193
+
185
194
  """
186
195
  # load headers from data parse
187
196
  if not self.edge_property_dict:
@@ -221,7 +230,7 @@ class _PostgreSQLBatchWriter(_BatchWriter):
221
230
  raise ValueError(
222
231
  "Column name '_ID' is reserved for internal use, "
223
232
  "denoting the relationship ID. Please choose a "
224
- "different name for your column."
233
+ "different name for your column.",
225
234
  )
226
235
 
227
236
  columns.append(f"{col_name} {col_type}")
@@ -255,7 +264,7 @@ class _PostgreSQLBatchWriter(_BatchWriter):
255
264
  )
256
265
 
257
266
  self._copy_from_csv_commands.add(
258
- f"\\copy {pascal_label} FROM '{parts_path}' DELIMITER E'{self.delim}' CSV;"
267
+ f"\\copy {pascal_label} FROM '{parts_path}' DELIMITER E'{self.delim}' CSV;",
259
268
  )
260
269
 
261
270
  # add file path to import statement
@@ -272,14 +281,15 @@ class _PostgreSQLBatchWriter(_BatchWriter):
272
281
  return True
273
282
 
274
283
  def _construct_import_call(self) -> str:
275
- """
276
- Function to construct the import call detailing folder and
284
+ """Function to construct the import call detailing folder and
277
285
  individual node and edge headers and data files, as well as
278
286
  delimiters and database name. Built after all data has been
279
287
  processed to ensure that nodes are called before any edges.
280
288
 
281
- Returns:
289
+ Returns
290
+ -------
282
291
  str: a bash command for postgresql import
292
+
283
293
  """
284
294
  import_call = ""
285
295
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: biocypher
3
- Version: 0.9.4
3
+ Version: 0.9.6
4
4
  Summary: A unifying framework for biomedical research knowledge graphs
5
5
  Home-page: https://github.com/biocypher/biocypher
6
6
  License: MIT
@@ -8,19 +8,19 @@ biocypher/_config/test_schema_config_extended.yaml,sha256=wn3A76142hhjnImhMF6ROD
8
8
  biocypher/_core.py,sha256=lP5CC35oXPtfiFY3C-UxZev8p1nMg9E2E4qN5BD9BTg,27437
9
9
  biocypher/_create.py,sha256=QsvXrwEQ8k0uNXvCG06UKejvw-QsJwzSaumrBjx9n1k,9884
10
10
  biocypher/_deduplicate.py,sha256=rtglcaLRaVzNjLtaPwTGP8VvCM4PHYQ5CZ-cm32CrKQ,4840
11
- biocypher/_get.py,sha256=BDNnvw6Xbz_Lq0ekU1Y60J4DI1zQKiZugJV6zGnWPsI,14873
11
+ biocypher/_get.py,sha256=_wUjhRjH2J6Qhq0Ndy3kdfaWhHDTT-dxyCvtuH36My4,14868
12
12
  biocypher/_logger.py,sha256=y9dh3SPJOCWXnkFSYSK7aj_-pB7zlAkNCf43Dp1lt74,2941
13
13
  biocypher/_mapping.py,sha256=ntspG2C_NaQODhWTBFk0CDvolkOCjtqlQ9E-NkJAuTg,9030
14
- biocypher/_metadata.py,sha256=BUH21dOZRsE7nvKZhWyqRfIp1j1ZqzsfMf8EVi7P-ok,1415
14
+ biocypher/_metadata.py,sha256=Jb4Uva2PzrPbxzio7DMQnX0WuIFrl_pgyDW89L1R1oQ,1415
15
15
  biocypher/_misc.py,sha256=YzlY7zwa0mim9QFg9HwXErkJFIH3cvLrbgjF8tKOIT8,6353
16
16
  biocypher/_ontology.py,sha256=lipZxU3aj6zrTbBrJZmCW6IRCuz-KQG3AfbYCVq6aFE,33133
17
17
  biocypher/_translate.py,sha256=9E19eLRL0VnxxDuiNhZ5vu54XyKXnfLuBhCgNcL9yAE,17000
18
18
  biocypher/output/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  biocypher/output/connect/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
- biocypher/output/connect/_get_connector.py,sha256=r-DeDnvGyFEWOd9bXaXQOgVws9rgWz5kwwdzbmt5eKk,1038
20
+ biocypher/output/connect/_get_connector.py,sha256=Qimv3kTkXYkhJZRT6nq8mwIM2wORCnyqqHqF2IByuuc,1152
21
21
  biocypher/output/connect/_neo4j_driver.py,sha256=kXjOXW12wZFfEp7plAuo40bPSvOfd-i9m4YaXoMq-p0,12357
22
22
  biocypher/output/in_memory/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
- biocypher/output/in_memory/_get_in_memory_kg.py,sha256=JuNwVx-qABeLikkI9VXQJNQH8xQWvYLEK_KKz3BrXPI,937
23
+ biocypher/output/in_memory/_get_in_memory_kg.py,sha256=29DvmOdRUuzEblyMxy5001R4zjEXW3eHNv0htko7c4Y,1115
24
24
  biocypher/output/in_memory/_in_memory_kg.py,sha256=g1TPN8PkeAyXbrRuTAjshqC8voI6EmLqR8S_otmviwU,1423
25
25
  biocypher/output/in_memory/_networkx.py,sha256=cSOSAreP7S3oeGT6noZ1kAIvSnkVnU3NUp1OY4yqzn0,1515
26
26
  biocypher/output/in_memory/_pandas.py,sha256=Ot2jbK5t_YLHqw0BUv9Z_qWNy9r6IX1LYEyejOSJzos,3288
@@ -30,15 +30,15 @@ biocypher/output/write/_get_writer.py,sha256=JozRWCMhvh65aQAlcGiiD5x3Nl1HSW8mK1Z
30
30
  biocypher/output/write/_writer.py,sha256=y0dWI-RyQdrBLr9Fs91Y9KcCMjnlCaKJT0eWsIS2hG4,7158
31
31
  biocypher/output/write/graph/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
32
  biocypher/output/write/graph/_arangodb.py,sha256=xue3hm_DVB5pMR5qqfGXlXll3RpILA0tXos2J-as1-E,7906
33
- biocypher/output/write/graph/_neo4j.py,sha256=EK5gqQNyVMYfpH1DaDTtGfRKiiq4jx5DLtYCCjY-jbY,12081
33
+ biocypher/output/write/graph/_neo4j.py,sha256=tBPhxn8JAmSS6KmiePofwr9LpGjHQH9BTnpHVK2ellM,12042
34
34
  biocypher/output/write/graph/_networkx.py,sha256=2WYkw5ZM3Bp236iwAxEAp3A1DxHKT4_hEPNMUKvPHp4,2320
35
35
  biocypher/output/write/graph/_owl.py,sha256=2DlxQuAXGnCW068N8bPgADjk_LFhU9D_LJV5lWQeu4A,21333
36
36
  biocypher/output/write/graph/_rdf.py,sha256=1TgECkoTHFX0eXtWc_-pr9G55AesReGlh7rg5zvUj5w,21925
37
37
  biocypher/output/write/relational/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
38
38
  biocypher/output/write/relational/_csv.py,sha256=m0BSQXts88Qu5AEvoIgnwRz54ia38g4VN3PaA3LCYM8,2807
39
- biocypher/output/write/relational/_postgresql.py,sha256=RckQJBiuwvDmHAyXxS8zCavYqDecHHWW_piofurokfQ,11965
39
+ biocypher/output/write/relational/_postgresql.py,sha256=75iJvv-0ewSsQXhVeoYoGnmYQnKY_B4iItZV7DpEBto,12190
40
40
  biocypher/output/write/relational/_sqlite.py,sha256=BuGWOeeNA83lbUvjpkzqcR9_baWLsbfmLXBKe4O1EPE,2105
41
- biocypher-0.9.4.dist-info/LICENSE,sha256=oejgxuxyjSnyPw3YPloz6-dCBB_nYizJ4jDQnr-xZUU,1082
42
- biocypher-0.9.4.dist-info/METADATA,sha256=0RHGsElP0N8_NFH_NtFR4aHhfT-WmPBhlrkDYo9DRfU,10600
43
- biocypher-0.9.4.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
44
- biocypher-0.9.4.dist-info/RECORD,,
41
+ biocypher-0.9.6.dist-info/LICENSE,sha256=oejgxuxyjSnyPw3YPloz6-dCBB_nYizJ4jDQnr-xZUU,1082
42
+ biocypher-0.9.6.dist-info/METADATA,sha256=8zvMLLWli78WBCjcBMhkqdwQb2rEqIinHz4aePh8RZw,10600
43
+ biocypher-0.9.6.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
44
+ biocypher-0.9.6.dist-info/RECORD,,