Open sanast22 opened 1 month ago
This is related to a feature of the autolayout algorithm called 'alias nodes', which means you can have multiple graphical representation of a single node (a species for example) in your model. For the species which are involved in multiple reactions, the algorithm creates alias nodes to make the visualization looks better. You can control it by passing 'max_num_connected_edges', the maximum number of reactions a species is allowed to be involved before creating an alias node for it, to the autolayout function.
Once you have alias nodes in your model, in addition to the 'id' of each node, you need to pass the index of the alias node to each method you use to get access to its features. This index can be passed as 'graphical_object_index' to almost every method you use to get/set something about a graphical object. Its default value is set to 0, which is used in case no index is passed and there is no alias node in the model. As an example, you can call getX("S1", graphical_object_index=2)
to get the x value of the position of the 3rd graphical representation of the "S1" node in your model.
Great, thanks! Is there a way to get a list of all the alias nodes in the model? Or rather, a list of the graphical_object_indexes for one species?
You can make use of 'getNumSpeciesGlyphs' to get the number of SpeciesGlyphs (i.e graphical representation of a Species) associated with each Species.
Are the graphical object indices in the same order as the reactions? For example, if species A is in reaction 1 and reaction 2, would graphical_object_index = 1 correspond to species A in reaction 1 and graphical_object_index = 2 correspond to species A in reaction 2?
Not necessarily. To figure out which graphical object index belongs to which reaction, I would recommend using species glyph id, which is an id assigned to the graphical objects associated with each species. To do, you can loop through getNumSpeciesReferenceGlyphs of a reaction and call getSpeciesReferenceSpeciesGlyphId function to get the species glyph id. Then, loop through getNumSpeciesGlyphs and call getNthSpeciesGlyphId to get the id of each graphical object using its index. If the id is found, then it means you've found the index you were looking for. You can write all of it in the form of a function is used to multiple times in your code. Let us know If that works for you, then we can probably addd it to our code and give access to it to the users through an API function.
If you have the same species involved in multiple reactions, how does the model distinguish between those two species? I want to change the location of a metabolite but it appears in multiple reactions, so when I use setX() and setY() I'm not sure what id to give those methods to distinguish between model entities.
Thanks!