SunnyXu / SBMLDiagrams

MIT License
5 stars 1 forks source link

I'm not sure setBezierReactionType works #34

Closed hsauro closed 2 years ago

hsauro commented 2 years ago

In the following script, I am trying to use setBezierReactionType, but it doesn't seem to work.

    import SBMLDiagrams as sd

    import tellurium as te

    r = te.loada ('''
         J1: S1 -> S2 + S3; v;
         J2: S3 -> S4; v;       
         J3: S4 -> S5; v;
          v = 0; S1 = 0; S2 = 0;
          S3 = 0; S4 = 0;
    ''')

    x= sd.processSBML.load(r.getSBML())
    x.setBezierReactionType('J1', False)
    x.setBezierReactionType('J2', False)
    x.setBezierReactionType('J3', False)
    y = sd.visualizeSBML.plot(x.export())

produces the attached image, notice all straight lines no beziers.

image

hsauro commented 2 years ago

I discovered if I change the node positions after setting the bezier type then I do get bezier curves (notice all the node ids are missing).

import SBMLDiagrams as sd

r = te.loada (''' J1: S1 -> S2 + S3; v; J2: S3 -> S4; v;
J3: S4 -> S5; v; v = 0; S1 = 0; S2 = 0; S3 = 0; S4 = 0; ''')

coral = [255,127,80]

x = sd.processSBML.load(r.getSBML()) x.setBezierReactionType('J1', True) x.setBezierReactionType('J2', True) x.setBezierReactionType('J3', True)

x.setNodePosition ('S1', [10, 10]) x.setNodePosition ('S2', [100, 50]) x.setNodePosition ('S3', [150, 150]) x.setNodePosition ('S4', [200, 200]) x.setNodePosition ('S5', [250, 250])

y = sd.visualizeSBML.plot(x.export())

image

SunnyXu commented 2 years ago

node ids are not missing refer to issue 30.

SunnyXu commented 2 years ago

1) If there is no layout information from the SBML file, all reaction lines will look like straight lines even set as ‘bezier’ because they are set as default center and handle positions. 2) setBezierReactionType() does not work, so I have removed it from api. 3) You can use plot (reactionLineType='bezier'/'straight') to control all the reactions lines. 4) if you want to control only one reaction, you can either set their reactions by setReactionCenterPosition() and setReactionHandlePositions() as you want; or setReactionDefaultCenterAndHandlePositions() to make them look like straight lines.