-
Notifications
You must be signed in to change notification settings - Fork 1
/
create_knowledge_graph.py
51 lines (41 loc) · 1.28 KB
/
create_knowledge_graph.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from biocypher import BioCypher
from meta_graph.adapters.adapter import (
BioCypherMetaAdapter,
BioCypherMetaAdapterNodeType,
BioCypherMetaAdapterEdgeType,
BioCypherMetaAdapterIssueField,
)
# Instantiate the BioCypher interface
# You can use `config/biocypher_config.yaml` to configure the framework or
# supply settings via parameters below
bc = BioCypher()
# Choose node types to include in the knowledge graph.
# These are defined in the adapter (`adapter.py`).
node_types = [
BioCypherMetaAdapterNodeType.ISSUE,
]
# Choose protein adapter fields to include in the knowledge graph.
# These are defined in the adapter (`adapter.py`).
node_fields = [
# Issues
BioCypherMetaAdapterIssueField.NUMBER,
BioCypherMetaAdapterIssueField.TITLE,
BioCypherMetaAdapterIssueField.BODY,
]
edge_types = [
BioCypherMetaAdapterEdgeType.PART_OF,
]
# Create a protein adapter instance
adapter = BioCypherMetaAdapter(
node_types=node_types,
node_fields=node_fields,
edge_types=edge_types,
# we can leave edge fields empty, defaulting to all fields in the adapter
)
# Create a knowledge graph from the adapter
bc.write_nodes(adapter.get_nodes())
bc.write_edges(adapter.get_edges())
# Write admin import statement
bc.write_import_call()
# Summary
bc.summary()