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

@@ -30,21 +30,21 @@ biocypher:
30
30
  root_node: entity
31
31
 
32
32
  ### Optional parameters ###
33
- ## Logging granularity
34
- ## Set debug to true if more granular logging is desired
35
33
 
36
- debug: true
34
+ ## Logging
35
+ # Write log to disk
36
+ log_to_disk: true
37
37
 
38
- ## Set to change the log directory
38
+ # Activate more granular logging
39
+ debug: true
39
40
 
41
+ # Change the log directory
40
42
  # log_directory: biocypher-log
41
43
 
42
- ## Set to change the output directory
43
-
44
+ ## Data output directory
44
45
  # output_directory: biocypher-out
45
46
 
46
- ## Set to change the cache directory
47
-
47
+ ## Resource cache directory
48
48
  # cache_directory: .cache
49
49
 
50
50
  ## Optional tail ontologies
biocypher/_core.py CHANGED
@@ -181,7 +181,7 @@ class BioCypher:
181
181
  """
182
182
 
183
183
  if not self._schema_config_path:
184
- return None
184
+ self._ontology_mapping = OntologyMapping()
185
185
 
186
186
  if not self._ontology_mapping:
187
187
  self._ontology_mapping = OntologyMapping(
biocypher/_logger.py CHANGED
@@ -60,11 +60,27 @@ def get_logger(name: str = "biocypher") -> logging.Logger:
60
60
  now = datetime.now()
61
61
  date_time = now.strftime("%Y%m%d-%H%M%S")
62
62
 
63
- logdir = (
64
- _config.config("biocypher").get("log_directory") or "biocypher-log"
65
- )
66
- os.makedirs(logdir, exist_ok=True)
67
- logfile = os.path.join(logdir, f"biocypher-{date_time}.log")
63
+ log_to_disk = _config.config("biocypher").get("log_to_disk")
64
+
65
+ if log_to_disk:
66
+ logdir = (
67
+ _config.config("biocypher").get("log_directory")
68
+ or "biocypher-log"
69
+ )
70
+ os.makedirs(logdir, exist_ok=True)
71
+ logfile = os.path.join(logdir, f"biocypher-{date_time}.log")
72
+
73
+ # file handler
74
+ file_handler = logging.FileHandler(logfile)
75
+
76
+ if _config.config("biocypher").get("debug"):
77
+ file_handler.setLevel(logging.DEBUG)
78
+ else:
79
+ file_handler.setLevel(logging.INFO)
80
+
81
+ file_handler.setFormatter(file_formatter)
82
+
83
+ logger.addHandler(file_handler)
68
84
 
69
85
  # handlers
70
86
  # stream handler
@@ -72,23 +88,15 @@ def get_logger(name: str = "biocypher") -> logging.Logger:
72
88
  stdout_handler.setLevel(logging.INFO)
73
89
  stdout_handler.setFormatter(stdout_formatter)
74
90
 
75
- # file handler
76
- file_handler = logging.FileHandler(logfile)
77
-
78
- if _config.config("biocypher").get("debug"):
79
- file_handler.setLevel(logging.DEBUG)
80
- else:
81
- file_handler.setLevel(logging.INFO)
82
-
83
- file_handler.setFormatter(file_formatter)
84
-
85
91
  # add handlers
86
- logger.addHandler(file_handler)
87
92
  logger.addHandler(stdout_handler)
88
93
 
89
94
  # startup message
90
95
  logger.info(f"This is BioCypher v{__version__}.")
91
- logger.info(f"Logging into `{logfile}`.")
96
+ if log_to_disk:
97
+ logger.info(f"Logging into `{logfile}`.")
98
+ else:
99
+ logger.info("Logging into stdout.")
92
100
 
93
101
  return logging.getLogger(name)
94
102
 
biocypher/_mapping.py CHANGED
@@ -40,7 +40,7 @@ class OntologyMapping:
40
40
  Read the configuration file and store the ontology mapping and extensions.
41
41
  """
42
42
  if config_file is None:
43
- schema_config = _config.module_data("schema_config")
43
+ schema_config = {}
44
44
 
45
45
  # load yaml file from web
46
46
  elif config_file.startswith("http"):
biocypher/_metadata.py CHANGED
@@ -19,7 +19,7 @@ import importlib.metadata
19
19
 
20
20
  import toml
21
21
 
22
- _VERSION = "0.5.28"
22
+ _VERSION = "0.5.31"
23
23
 
24
24
 
25
25
  def get_metadata():
biocypher/_ontology.py CHANGED
@@ -96,16 +96,7 @@ class OntologyAdapter:
96
96
  )
97
97
 
98
98
  def _rdf_to_nx(self, g, root_label, switch_id_and_label=True):
99
- # Loop through all labels in the ontology
100
- for s, _, o in g.triples((None, rdflib.RDFS.label, None)):
101
- # If the label is the root label, set the root node to the subject of the label
102
- if o.eq(root_label):
103
- root = s
104
- break
105
- else:
106
- raise ValueError(
107
- f"Could not find root node with label {root_label}"
108
- )
99
+ root = self._find_root_label(g, root_label)
109
100
 
110
101
  # Create a directed graph to represent the ontology as a tree
111
102
  G = nx.DiGraph()
@@ -177,6 +168,21 @@ class OntologyAdapter:
177
168
 
178
169
  return G
179
170
 
171
+ def _find_root_label(self, g, root_label):
172
+ # Loop through all labels in the ontology
173
+ for label_subject, _, label_in_ontology in g.triples(
174
+ (None, rdflib.RDFS.label, None)
175
+ ):
176
+ # If the label is the root label, set the root node to the label's subject
177
+ if str(label_in_ontology) == root_label:
178
+ root = label_subject
179
+ break
180
+ else:
181
+ raise ValueError(
182
+ f"Could not find root node with label {root_label}"
183
+ )
184
+ return root
185
+
180
186
  def _remove_prefix(self, uri: str) -> str:
181
187
  """
182
188
  Remove the prefix of a URI. URIs can contain either "#" or "/" as a
@@ -565,7 +571,7 @@ class Ontology:
565
571
  else:
566
572
  msg = f"Showing ontology structure based on {len(self._tail_ontology_meta)+1} ontologies: "
567
573
 
568
- print(msg)
574
+ logger.info(msg)
569
575
 
570
576
  if not full:
571
577
  # set of leaves and their intermediate parents up to the root
@@ -594,7 +600,7 @@ class Ontology:
594
600
  f"{self.mapping.extended_schema[node].get('synonym_for')}"
595
601
  )
596
602
 
597
- tree.show()
603
+ logger.info(f"\n{tree}")
598
604
 
599
605
  return tree
600
606
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: biocypher
3
- Version: 0.5.28
3
+ Version: 0.5.31
4
4
  Summary: A unifying framework for biomedical research knowledge graphs
5
5
  Home-page: https://github.com/biocypher/biocypher
6
6
  License: MIT
@@ -1,24 +1,24 @@
1
1
  biocypher/__init__.py,sha256=ejNY53vH_pE3ZbIN8G_ZBYxxPG9aERovRLD0XhDvt4k,942
2
2
  biocypher/_config/__init__.py,sha256=fFHRFYxE2MtDAQWL6upe--MJ1vw3Z8CwIPhF2gW8cRU,3698
3
- biocypher/_config/biocypher_config.yaml,sha256=rPH0h1aQRPGkYQnoE-v-DJA6b01YuN5byPRbw_G7dUg,2430
3
+ biocypher/_config/biocypher_config.yaml,sha256=H0TKBJun7pQmIfIAgEiMkDDgE3kKoCElBuMt8lkkQcU,2404
4
4
  biocypher/_config/test_config.yaml,sha256=Np8jeS5_EP6HHOvMKb7B_Tkyqd5YaYlYz_DVsXypt-A,119
5
5
  biocypher/_config/test_schema_config.yaml,sha256=D1600WgEj3iTXrumVU9LIivJHJO36iaxfkOgyam9zVU,3129
6
6
  biocypher/_config/test_schema_config_disconnected.yaml,sha256=Qm8FLxEn2spHcyj_5F859KjcDvKSxNhxDvi4b4LLkvQ,68
7
7
  biocypher/_config/test_schema_config_extended.yaml,sha256=wn3A76142hhjnImhMF6RODbCFESTJ2TtPvcFdIFsAT0,3309
8
8
  biocypher/_connect.py,sha256=0oSyO6CEIlKL8rHo-HHE7y0FzGfSi4vnEXSDy1TnIUE,12456
9
- biocypher/_core.py,sha256=xDMIdpDXffUzUygC8B3GzXTGLvFH6dqTs39ele68VFE,22270
9
+ biocypher/_core.py,sha256=2o3hhhM6kfaZI6TU3ZmzoBJc-RJgFFGWGe0MZW-oA3U,22301
10
10
  biocypher/_create.py,sha256=vpUchUdEpWupZi1LgFLxAWMtqoBwnWbP7PwEDUCBS4A,10202
11
11
  biocypher/_deduplicate.py,sha256=BBvfpXzu6L5YDY5FdtXxnf8YlsbJpbCE8RdUoKsm0n0,4949
12
12
  biocypher/_get.py,sha256=HrJuBm_i9zfi_Mzzi1s5kp0OyPh_oKQk0wwyYsxg0qA,9189
13
- biocypher/_logger.py,sha256=soYtz1DiduLFw3XrMnphWWUxeuJqvSof4AYhlafxl08,2933
14
- biocypher/_mapping.py,sha256=XJZjmXTPnXVkyub1ZU0h3EKXQ2YROaGaJOaGyPMqgy4,9338
15
- biocypher/_metadata.py,sha256=pE1NUSdNABIhMjx_2yUuRcA098xXDyGzEm018cv55Tg,1658
13
+ biocypher/_logger.py,sha256=rEn_-ESh9cPxk6vdWZ1a25escCWHBWX4D1gtpNowyvI,3186
14
+ biocypher/_mapping.py,sha256=ERSNH2Bg19145KytxbFE4BInPaiP-LWW7osOBot29Eo,9304
15
+ biocypher/_metadata.py,sha256=kpXUxF5Umh3tsT9xxcrntbPWxL38kATPLhgrqRNV1cs,1658
16
16
  biocypher/_misc.py,sha256=wsjGVOqBDVM5hxbE_TEaZ69u1kJc8HXwRAtQHUgE8XQ,4545
17
- biocypher/_ontology.py,sha256=5TA4W0vcMyvFLtzuMLt_pFKXZmeLvgdyCHV4vMGrvmk,22794
17
+ biocypher/_ontology.py,sha256=lIEHtdUGPFVbj7jrojwHNmP2-KJlXSET8bqVLRam3vI,23010
18
18
  biocypher/_pandas.py,sha256=GVCFM68J7yBjh40MpkNVgD8qT1RFMrrIjMOtD3iKsf4,3040
19
19
  biocypher/_translate.py,sha256=nj4Y60F0U3JBH36N2dh5pFcC8Ot86rskJ2ChJwje9dI,16494
20
20
  biocypher/_write.py,sha256=nvb75OwElu8fLUp0FjEBqQ1VNpx6iRrk-t7v_TOlDhg,68165
21
- biocypher-0.5.28.dist-info/LICENSE,sha256=SjUaQkq671iQUZOxEUpC4jvJxXOlfSiHTTueyz9kXJM,1065
22
- biocypher-0.5.28.dist-info/WHEEL,sha256=vxFmldFsRN_Hx10GDvsdv1wroKq8r5Lzvjp6GZ4OO8c,88
23
- biocypher-0.5.28.dist-info/METADATA,sha256=APFsO_i3awV_7XdjE_kvSuWyKLUsc2yRC8Hn7QRHTVU,10274
24
- biocypher-0.5.28.dist-info/RECORD,,
21
+ biocypher-0.5.31.dist-info/LICENSE,sha256=SjUaQkq671iQUZOxEUpC4jvJxXOlfSiHTTueyz9kXJM,1065
22
+ biocypher-0.5.31.dist-info/METADATA,sha256=Kzl2LeK_Y4Ul8bzzfPzYv7aXEjAohoQqfRJO_GdFhXs,10274
23
+ biocypher-0.5.31.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
24
+ biocypher-0.5.31.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.3.2
2
+ Generator: poetry-core 1.6.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any