Output Driver
Connector Retrieval
Return the connector class.
Returns
class: the connector class
Raises
NotImplementedError: if the DBMS is not supported
Source code in biocypher/output/connect/_get_connector.py
Neo4j Driver
Manages a BioCypher connection to a Neo4j database using the
neo4j_utils.Driver
class.
Args:
database_name (str): The name of the database to connect to.
wipe (bool): Whether to wipe the database before importing.
uri (str): The URI of the database.
user (str): The username to use for authentication.
password (str): The password to use for authentication.
multi_db (bool): Whether to use multi-database mode.
fetch_size (int): The number of records to fetch at a time.
increment_version (bool): Whether to increment the version number.
translator (Translator): The translator to use for mapping.
Source code in biocypher/output/connect/_neo4j_driver.py
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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
|
_create_constraints()
Creates constraints on node types in the graph. Used for initial setup.
Grabs leaves of the schema_config.yaml
file and creates
constraints on the id of all entities represented as nodes.
Source code in biocypher/output/connect/_neo4j_driver.py
_get_neo4j_version()
Get neo4j version.
Source code in biocypher/output/connect/_neo4j_driver.py
add_biocypher_edges(edges, explain=False, profile=False)
Accepts an edge type handoff class
(:class:biocypher.create.BioCypherEdge
) with source
and target ids, label, and a dict of properties (passing on the
type of property, ie, int, string ...).
The individual edge is either passed as a singleton, in the case of representation as an edge in the graph, or as a 4-tuple, in the case of representation as a node (with two edges connecting to interaction partners).
The dict retrieved by the
:meth:biocypher.create.BioCypherEdge.get_dict()
method is
passed into Neo4j as a map of maps, explicitly encoding source
and target ids and the relationship label, and adding all edge
properties from the 'properties' key of the dict. The merge is
performed via APOC, matching only on source and target id to
prevent duplicates. The same properties are set on match and on
create, irrespective of the actual event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edges
|
Iterable[BioCypherEdge]
|
An iterable of :class: |
required |
explain
|
bool
|
Call |
False
|
profile
|
bool
|
Do profiling on the CYPHER query. |
False
|
Returns:
Type | Description |
---|---|
bool
|
|
Source code in biocypher/output/connect/_neo4j_driver.py
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
|
add_biocypher_nodes(nodes, explain=False, profile=False)
Accepts a node type handoff class
(:class:biocypher.create.BioCypherNode
) with id,
label, and a dict of properties (passing on the type of
property, ie, int
, str
, ...).
The dict retrieved by the
:meth:biocypher.create.BioCypherNode.get_dict()
method is
passed into Neo4j as a map of maps, explicitly encoding node id
and label, and adding all other properties from the 'properties'
key of the dict. The merge is performed via APOC, matching only
on node id to prevent duplicates. The same properties are set on
match and on create, irrespective of the actual event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nodes
|
Iterable[BioCypherNode]
|
An iterable of :class: |
required |
explain
|
bool
|
Call |
False
|
profile
|
bool
|
Do profiling on the CYPHER query. |
False
|
Returns:
Type | Description |
---|---|
bool
|
True for success, False otherwise. |
Source code in biocypher/output/connect/_neo4j_driver.py
add_edges(id_src_tar_type_tuples)
Generic edge adder method to add any kind of input to the graph
via the :class:biocypher.create.BioCypherEdge
class. Employs
translation functionality and calls the
:meth:add_biocypher_edges()
method.
Args:
id_src_tar_type_tuples (iterable of 5-tuple):
for each edge to add to the biocypher graph, a 5-tuple
with the following layout: first, the optional unique ID
of the interaction. This can be `None` if there is no
systematic identifier (which for many interactions is
the case). Second and third, the (unique if constrained)
IDs of the source and target nodes of the relationship;
fourth, the type of the relationship; and fifth, a
dictionary of arbitrary properties the edge should
possess (can be empty).
Returns:
2-tuple: the query result of :meth:`add_biocypher_edges()`
- first entry: data
- second entry: Neo4j summary.
Source code in biocypher/output/connect/_neo4j_driver.py
add_nodes(id_type_tuples)
Generic node adder method to add any kind of input to the graph via the
:class:biocypher.create.BioCypherNode
class. Employs translation
functionality and calls the :meth:add_biocypher_nodes()
method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_type_tuples
|
iterable of 3-tuple
|
for each node to add to
the biocypher graph, a 3-tuple with the following layout:
first, the (unique if constrained) ID of the node; second, the
type of the node, capitalised or PascalCase and in noun form
(Neo4j primary label, eg |
required |
Returns:
Type | Description |
---|---|
tuple
|
2-tuple: the query result of :meth: |
Source code in biocypher/output/connect/_neo4j_driver.py
init_db()
Used to initialise a property graph database by setting up new
constraints. Wipe has been performed by the neo4j_utils.Driver
class` already.
Todo
- set up constraint creation interactively depending on the need of the database