Open matthiaskoenig opened 2 hours ago
Here the solution. The trick is to first set a bypass for the positions and then clear the bypass afterwards. The positions remain.
p4c.set_node_position_bypass("Gd-EOB-DTPA (liver)", new_x_locations=200, new_y_locations=200, network=1017)
p4c.clear_node_property_bypass(["Gd-EOB-DTPA (liver)"], 'NODE_Y_LOCATION')
p4c.clear_node_property_bypass(["Gd-EOB-DTPA (liver)"], 'NODE_X_LOCATION')
This only works when be executed separately. But not all together in a script. I.e. first the nodes bypass has to be set afterwards in a separate call the bypass must be removed.
Is there any way to set the node positions? E.g. to force an update or letting p4c know to apply everything before executing the next command?
p4c.set_node_position_bypass("Gd-EOB-DTPA (liver)", new_x_locations=200, new_y_locations=200, network=1017)
SOME_MAGIC_COMMAND
p4c.clear_node_property_bypass(["Gd-EOB-DTPA (liver)"], 'NODE_Y_LOCATION')
p4c.clear_node_property_bypass(["Gd-EOB-DTPA (liver)"], 'NODE_X_LOCATION')
Hi, Matthias ... I saw this but don't have time to give a proper answer. I'll be back later today.
Meanwhile, there's an example of what I think you're trying to do in the set_node_position_bypass() test suite in the test_style_bypasses.py file.
Does this help??
How can I set the x and y position of nodes? Unfortunately, I cannot find a solution for this basic operation.
I saw the discussion in https://github.com/cytoscape/py4cytoscape/issues/109, but the solutions via the bypass fix the respective node positions. I.e. the following functions set the positions, but have the side effect of freezing the positions.
I have to be able to change the positions of the nodes afterwards.