@@ -86,13 +86,6 @@ def pairwise(iterable):
86
86
from mapmaker .properties import PropertiesStore
87
87
from mapmaker .properties .pathways import Path
88
88
89
- #===============================================================================
90
-
91
- NOT_LATERAL_NODES = [
92
- 'UBERON:0001896' ,
93
- 'UBERON:0000988' ,
94
- 'UBERON:0001891'
95
- ]
96
89
97
90
#=============================================================
98
91
@@ -758,7 +751,7 @@ def __feature_properties_from_node(self, connectivity_node: AnatomicalNode) -> d
758
751
759
752
elif matched is not None :
760
753
properties ['name' ] = matched [0 ].name
761
- features = set (f for f in matched [1 ] if f .id is not None )
754
+ features = set (f for f in matched [1 ] if f .id is not None and not f . get_property ( 'unrouted' , False ) )
762
755
if len (features ):
763
756
properties ['type' ] = 'feature'
764
757
properties ['features' ] = features
@@ -967,7 +960,7 @@ def add_route_edges_from_graph(G, used_nodes):
967
960
# else connect to one closest no_segment point and neighbour feature.
968
961
features = (
969
962
neighbour_dict ['features' ]
970
- if len (neighbour_dict ['features' ]) <= 2 and all ( item not in { neighbour_dict [ 'node' ][ 0 ], * neighbour_dict [ 'node' ][ 1 ]} for item in NOT_LATERAL_NODES )
963
+ if len (neighbour_dict ['features' ]) <= 2
971
964
else sorted (neighbour_dict ['features' ], key = lambda f : f .id )[:1 ]
972
965
)
973
966
for feature in features :
@@ -1204,14 +1197,18 @@ def get_node_feature(node_dict, neighbour_features, used_features) -> Feature:
1204
1197
one_feature_terminals = {
1205
1198
n : min ([
1206
1199
features [0 ].geometry .centroid .distance (nf .geometry .centroid )
1207
- for neighbour in connectivity_graph .neighbors (n )
1208
- for nf in (
1209
- connectivity_graph .nodes [neighbour ].get ("features" , set ()) |
1210
- {self .__flatmap .get_feature (f_id ) for f_id in connectivity_graph .nodes [neighbour ].get ("used" , set ())}
1211
- )
1200
+ for nf in nfs
1212
1201
])
1213
1202
for n , n_dict in connectivity_graph .nodes (data = True )
1214
- if connectivity_graph .degree (n ) == 1 and len (features := list (n_dict .get ("features" , []))) == 1
1203
+ if connectivity_graph .degree (n ) == 1
1204
+ and len (features := list (n_dict .get ("features" , []))) == 1
1205
+ and len (nfs := [
1206
+ nf for neighbour in connectivity_graph .neighbors (n )
1207
+ for nf in (
1208
+ connectivity_graph .nodes [neighbour ].get ("features" , set ()) |
1209
+ {self .__flatmap .get_feature (f_id ) for f_id in connectivity_graph .nodes [neighbour ].get ("used" , set ())}
1210
+ )
1211
+ ]) > 0
1215
1212
}
1216
1213
one_feature_terminals = dict (sorted (one_feature_terminals .items (), key = lambda item : item [1 ]))
1217
1214
two_feature_terminals = [
@@ -1274,7 +1271,7 @@ def add_paths_to_neighbours(node, node_dict):
1274
1271
else used_features .get (node , set ())
1275
1272
if connectivity_graph .degree (node ) > 1 and len (used_features .get (node , set ())) in [1 , 2 ]
1276
1273
else set (node_dict ['features' ])
1277
- if connectivity_graph .degree (node ) == 1 and all ( item not in { node_dict [ 'node' ][ 0 ], * node_dict [ 'node' ][ 1 ]} for item in NOT_LATERAL_NODES )
1274
+ if connectivity_graph .degree (node ) == 1
1278
1275
else [get_node_feature (node_dict , neighbour_features , used_features )]
1279
1276
)
1280
1277
for node_feature in node_features :
@@ -1302,7 +1299,6 @@ def add_paths_to_neighbours(node, node_dict):
1302
1299
neighbour_features = (
1303
1300
neighbour_dict .get ('features' , [])
1304
1301
if len (neighbour_dict .get ('features' , [])) <= 2 and degree == 1 and len (node_features ) == 1
1305
- and all (item not in {neighbour_dict ['node' ][0 ], * neighbour_dict ['node' ][1 ]} for item in NOT_LATERAL_NODES )
1306
1302
else [get_node_feature (neighbour_dict , [node_feature ], used_features )]
1307
1303
if len (neighbour_terminal_laterals ) > 0 and len (used_features .get (neighbour , set ())) == 0
1308
1304
else [get_node_feature (neighbour_dict , [node_feature ], used_features )]
0 commit comments