Skip to content

Commit 126b0f6

Browse files
working on automation
1 parent b3e0ca1 commit 126b0f6

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

src/sbmlutils/cytoscape.py

+20-5
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,11 @@ def visualize_sbml(sbml_path: Path, delete_session: bool = False) -> Optional[in
4949
p4c.session.close_session(save_before_closing=False)
5050

5151
networks_views = p4c.networks.import_network_from_file(str(sbml_path))
52-
console.print(f"{networks_views}")
52+
# console.print(f"{networks_views}")
5353
network = networks_views["networks"][1]
5454
p4c.set_current_view(network=network) # set the base network
5555
return network
5656

57-
return networks_views
58-
5957
except RequestException:
6058
logger.error(
6159
"Could not connect to a running Cytoscape instance. "
@@ -78,14 +76,13 @@ def apply_layout(layout: pd.DataFrame, network=None) -> None:
7876

7977
# get SUIDs, sbml_id from node table;
8078
df_nodes = p4c.get_table_columns(table="node", columns=["sbml id"], network=network)
81-
console.print(df_nodes)
8279
sid2suid = {row["sbml id"]: suid for suid, row in df_nodes.iterrows()}
83-
console.print(sid2suid)
8480

8581
# FIXME: necessary to check that all sids exist
8682
suids = [sid2suid[sid] for sid in layout.index.values]
8783
x_values = layout["x"].values.tolist()
8884
y_values = layout["y"].values.tolist()
85+
# z_values = layout["z"].values.tolist()
8986

9087
# set positions
9188
# see: https://github.com/cytoscape/py4cytoscape/issues/144
@@ -213,6 +210,24 @@ def add_annotations(annotations, network=None):
213210
)
214211

215212

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+
216231
if __name__ == "__main__":
217232
pass
218233
# # visual style

0 commit comments

Comments
 (0)