@@ -129,6 +129,7 @@ def __init__(self):
129129 self .__forward_connections = set ()
130130 self .__node_nerves = set ()
131131 self .__node_mappings = set ()
132+ self .__expert_consultants = set ()
132133
133134 @property
134135 def as_dict (self ) -> dict [str , Any ] :
@@ -144,7 +145,8 @@ def as_dict(self) -> dict[str, Any] :
144145 'node-phenotypes' : self .__node_phenotypes ,
145146 'forward-connections' : list (self .__forward_connections ),
146147 'node-nerves' : list (self .__node_nerves ),
147- 'node-mappings' : list (self .__node_mappings )
148+ 'node-mappings' : list (self .__node_mappings ),
149+ 'expert-consultants' : list (self .__expert_consultants )
148150 }
149151 if len (self .__centrelines ):
150152 result ['centrelines' ] = list (self .__centrelines )
@@ -252,6 +254,17 @@ def extend_node_mappings(self, node_mappings: list[tuple]):
252254 """
253255 self .__node_mappings .update (node_mappings )
254256
257+ def extend_expert_consultants (self , expert_consultants : list [str ]):
258+ """
259+ Associate expert consultants with the path.
260+
261+ Arguments:
262+ ----------
263+ expert_consultants
264+ Expert consultants
265+ """
266+ self .__expert_consultants .update (expert_consultants )
267+
255268#===============================================================================
256269
257270class Route :
@@ -339,7 +352,8 @@ def list_to_tuple(obj):
339352 available_nodes = {
340353 list_to_tuple (json .loads (an ))
341354 for geojson_id in self .__paths [path_id ].as_dict ['nodes' ] + self .__paths [path_id ].as_dict ['nerves' ]
342- for an in self .__flatmap .get_feature_by_geojson_id (geojson_id ).anatomical_nodes
355+ if (feature := self .__flatmap .get_feature_by_geojson_id (geojson_id )) is not None
356+ for an in feature .anatomical_nodes
343357 }
344358
345359 # remove the missing nodes:
@@ -363,7 +377,7 @@ def list_to_tuple(obj):
363377 ],
364378 'node_phenotypes' : {
365379 phenotype : [connectivity_graph .nodes [node ]['node' ] for node in nodes if node in connectivity_graph .nodes ]
366- for phenotype , nodes in connectivity_graph .graph .get ('node-phenotypes' ).items ()
380+ for phenotype , nodes in connectivity_graph .graph .get ('node-phenotypes' , {} ).items ()
367381 },
368382 'forward_connections' : [
369383 conn_id for conn_id in connectivity_graph .graph .get ('forward-connections' , [])
@@ -381,6 +395,9 @@ def list_to_tuple(obj):
381395 (list_to_tuple (cn ['node' ]), list_to_tuple (n ))
382396 for _ , data in connectivity_graph .nodes (data = True )
383397 for n , cn in data .get ('contraction' , {}).items ()
398+ ],
399+ 'expert_consultants' : [
400+ consultant for consultant in connectivity_graph .graph .get ('expert-consultants' , [])
384401 ]
385402 }
386403 return rendered_data
@@ -405,6 +422,7 @@ def add_connectivity(self, path_id: str, line_geojson_ids: list[int],
405422 resolved_path .extend_forward_connections (rendered_data ['forward_connections' ])
406423 resolved_path .extend_node_nerves (rendered_data ['node_nerves' ])
407424 resolved_path .extend_node_mappings (rendered_data ['node_mappings' ])
425+ resolved_path .extend_expert_consultants (rendered_data ['expert_consultants' ])
408426 if centrelines is not None :
409427 resolved_path .add_centrelines (centrelines )
410428
@@ -419,8 +437,8 @@ def add_pathway(self, path_id: str, model: Optional[str], path_type: PATH_TYPE,
419437 self .__resolve_nodes_for_path (path_id , route .start_nodes )
420438 + self .__resolve_nodes_for_path (path_id , route .through_nodes )
421439 + self .__resolve_nodes_for_path (path_id , route .end_nodes ))
422- resolved_path .extend_lines (self .__flatmap .feature_ids_to_geojson_ids (lines ))
423- resolved_path .extend_nerves (self .__flatmap .feature_ids_to_geojson_ids (nerves ))
440+ resolved_path .extend_lines (self .__flatmap .feature_to_geojson_ids (lines ))
441+ resolved_path .extend_nerves (self .__flatmap .feature_to_geojson_ids (nerves ))
424442
425443#===============================================================================
426444
0 commit comments