@@ -49,13 +49,11 @@ def visualize_sbml(sbml_path: Path, delete_session: bool = False) -> Optional[in
49
49
p4c .session .close_session (save_before_closing = False )
50
50
51
51
networks_views = p4c .networks .import_network_from_file (str (sbml_path ))
52
- console .print (f"{ networks_views } " )
52
+ # console.print(f"{networks_views}")
53
53
network = networks_views ["networks" ][1 ]
54
54
p4c .set_current_view (network = network ) # set the base network
55
55
return network
56
56
57
- return networks_views
58
-
59
57
except RequestException :
60
58
logger .error (
61
59
"Could not connect to a running Cytoscape instance. "
@@ -78,14 +76,13 @@ def apply_layout(layout: pd.DataFrame, network=None) -> None:
78
76
79
77
# get SUIDs, sbml_id from node table;
80
78
df_nodes = p4c .get_table_columns (table = "node" , columns = ["sbml id" ], network = network )
81
- console .print (df_nodes )
82
79
sid2suid = {row ["sbml id" ]: suid for suid , row in df_nodes .iterrows ()}
83
- console .print (sid2suid )
84
80
85
81
# FIXME: necessary to check that all sids exist
86
82
suids = [sid2suid [sid ] for sid in layout .index .values ]
87
83
x_values = layout ["x" ].values .tolist ()
88
84
y_values = layout ["y" ].values .tolist ()
85
+ # z_values = layout["z"].values.tolist()
89
86
90
87
# set positions
91
88
# see: https://github.com/cytoscape/py4cytoscape/issues/144
@@ -213,6 +210,24 @@ def add_annotations(annotations, network=None):
213
210
)
214
211
215
212
213
+ def export_image (image_path : Path , format = "PNG" , fit_content : bool = False , hide_labels : bool = True ):
214
+ """Helper for exporting cytoscape images.
215
+
216
+ format (str): Type of image to export, e.g., PNG (default), JPEG, PDF, SVG, PS (PostScript).
217
+ """
218
+ if fit_content :
219
+ p4c .fit_content ()
220
+
221
+ p4c .export_image (
222
+ filename = str (image_path ),
223
+ type = format ,
224
+ zoom = 400.0 ,
225
+ overwrite_file = True ,
226
+ all_graphics_details = True ,
227
+ hide_labels = False ,
228
+ )
229
+
230
+
216
231
if __name__ == "__main__" :
217
232
pass
218
233
# # visual style
0 commit comments