Exemplo n.º 1
0
from pathlib import Path
import pkg_resources

from libsbml_draw.sbml_layout import SBMLlayout

model_file_name = "model.xml"

model_file = Path(
    pkg_resources.resource_filename("libsbml_draw",
                                    "model/libs/" + model_file_name))

s = SBMLlayout(str(model_file))

# s._describeModel()

s.setNodeFontSize('all', 15)
s.setReactionCurveWidth('all', 3)
s.setNodeColor('all', 'red')
s.setNodeFontColor('all', 'white')

s.drawNetwork()

s.regenerateLayout()

s.drawNetwork()
Exemplo n.º 2
0
import pkg_resources

from libsbml_draw.sbml_layout import SBMLlayout

#model_file_name = "complicated_nodes-L3V1.xml"
model_file_name = "complicated_nodes.xml"

model_file = Path(pkg_resources.resource_filename(
        "libsbml_draw", "model/libs/" + model_file_name))

# https://stackoverflow.com/questions/33635439/matplotlib-patch-size-in-points

#print("validate: ", SBMLlayout._validate_sbml_filename(str(model_file)))


sl = SBMLlayout(str(model_file))


sl.describeModel()

#sl.drawNetwork("complicated_nodes.png", figsize=(6,6))
#sl.drawNetwork("complicated_nodes.png", figsize=(8,8))
sl.drawNetwork("complicated_nodes.png")

#sl.setNodeFontSize("all", 6)

#sl.drawNetwork()


#for node in sl.getNodeIds():
#    centroid = sl.getNodeCentroid(node)
Exemplo n.º 3
0
#from libsbml import readSBMLFromFile, read`SBMLFromString

#import libsbml_draw.c_api.sbnw_c_api as sbnw
from libsbml_draw.sbml_layout import SBMLlayout

#model_file = "C:\\tmp\\model.xml"
#model_file = "C:\\tmp\\copasi.xml"
#model_file = "C:\\tmp\\render_sbml.xml"
#model_file = "C:\\tmp\\largerpathway.xml"
model_file = "C:\\tmp\\simple-L2-render-global.xml"

# read model
sl = SBMLlayout(model_file)

# generate layout
if not sl.layoutSpecified:
    sl._randomizeLayout()
    sl._doLayoutAlgorithm()

# describe network
print("num nodes: ", sl.getNumberOfNodes())
print("num reactions: ", sl.getNumberOfReactions())

# create network
sl._createNetwork()

# draw network
sl.drawNetwork()

# print node id's
print("node ids: ", sl.getNodeIds())
Exemplo n.º 4
0
from pathlib import Path
import pkg_resources

from libsbml_draw.sbml_layout import SBMLlayout

small_models = [
    "model.xml", "largerpathway.xml", "modexmpl.xml",
    "random_network_5s_8r.xml", "random_network_5s_6r.xml"
]

for model_file_name in small_models:

    model_file = Path(
        pkg_resources.resource_filename("libsbml_draw",
                                        "model/libs/" + model_file_name))

    sl = SBMLlayout(str(model_file))

    sl.describeModel()

    sl.drawNetwork()
Exemplo n.º 5
0
"""
"""
from pathlib import Path
import pkg_resources

from libsbml_draw.sbml_layout import SBMLlayout

model_file_name = "model.xml"

model_file = Path(
    pkg_resources.resource_filename("libsbml_draw",
                                    "model/libs/" + model_file_name))

sl = SBMLlayout()

sl.loadSBMLFile(str(model_file))

sl.describeModel()

sl.drawNetwork()

ss = SBMLlayout()

sbmlString = sl.getSBMLString()

ss.loadSBMLString(sbmlString)

ss.describeModel()

ss.drawNetwork()
Exemplo n.º 6
0
file_name = "veronica-network.xml"

if platform.system() == "Windows":
    model_dir = "C:\\Users\\nrhaw\\Documents\\repos\\libsbml-draw\\model_files\\"
elif platform.system() == "Linux":    
    model_dir = "/home/radix/repos/libsbml-draw/model_files/"
else:
    model_dir = "/Users/natalieh/repos/libsbml-draw/model_files/"
    
model_file = model_dir + file_name

print("model file: \n", model_file)



sl = SBMLlayout(model_file)

sl.describeModel()

my_fig = sl.drawNetwork()

color1 = ["S6", "S7", "S5", "S4", "S8"]
color2 = ["S0", "S1", "S2", "S3", "S9", "S10", "S11"]

for node in color1:
    sl.setNodeFillColor(node, "lightblue")
    
for node in color2: 
    sl.setNodeFillColor(node, "lightgreen")

for reaction in sl.getReactionIds():
Exemplo n.º 7
0
from pathlib import Path
import pkg_resources

from libsbml_draw.sbml_layout import SBMLlayout

MODEL_FILE_NAME = "largerpathway.xml"

MODEL_FILE = Path(
    pkg_resources.resource_filename("libsbml_draw",
                                    "model/libs/" + MODEL_FILE_NAME))

print("model file: ", str(MODEL_FILE))

sl = SBMLlayout(str(MODEL_FILE))

#sl.describeModel()

sl.setReactionColor("all", "#0000ff50")
sl.setNodeColor("all", "#00ff0030")

#sl.setNodeFontSize("all", 24)

sl.drawNetwork("largerpathway.png")

#sl.drawNetwork(figsize=(12,12))

print("node ids: ", sl.getNodeIds())
print("reaction ids: ", sl.getReactionIds())
print()

for node in sl._SBMLlayout__network.nodes.values():
Exemplo n.º 8
0
import platform

from libsbml_draw.sbml_layout import SBMLlayout

if platform.system() == "Windows":
    model_file = "C:\\Users\\nrhaw\\Documents\\repos\\libsbml-draw\\model_files\\render_sbml_pink_green.xml"
elif platform.system() == "Linux":
    model_file = "/home/radix/repos/libsbml-draw/model_files/render_sbml.xml"
else:
    model_file = "/Users/natalieh/repos/libsbml-draw/model_files/render_sbml.xml"

sl = SBMLlayout(model_file)

#sl.describeModel()

sl.drawNetwork()

print("node ids: ", sl.getNodeIds())
print("reaction ids: ", sl.getReactionIds())
Exemplo n.º 9
0
#import libsbml

from libsbml_draw.sbml_layout import SBMLlayout
#from libsbml_draw.model.render import Render

#model_file = "C:\\tmp\\copasi.xml"
model_file = "C:\\tmp\\largerpathway.xml"

#doc = libsbml.readSBMLFromFile(model_file)
#model = doc.getModel()
#layout_plugin = model.getPlugin("layout")

#if layout_plugin:
#    print("num layouts: ", layout_plugin.getNumLayouts())

sl = SBMLlayout(model_file)

sl.describeModel()

sl.drawNetwork()
#r = Render(model_file, sl.layout_number)
#r._describeRenderInfo()

#print("render: ", type(r))
#print("num layouts: ", r.layout_plugin.getNumLayouts())

#sl._applyRenderInformation(None)

#a0e0a030

reactionIds = sl.getReactionIds()
Exemplo n.º 10
0
from pathlib import Path
import pkg_resources

from libsbml_draw.sbml_layout import SBMLlayout

bio_models = [
    "BIOMD0000000042_url.xml", "BIOMD0000000061_url.xml",
    "BIOMD0000000247_url.xml", "BIOMD0000000281_url.xml",
    "BIOMD0000000606_url.xml", "BIOMD0000000691_url.xml",
    "MODEL1202170000_url.xml", "MODEL1209260000_url.xml",
    "MODEL1303260016_url.xml", "MODEL1504290001_url.xml"
]

bio_models = ["BIOMD0000000393_url.xml", "BIOMD0000000051_url.xml"]

for model_file_name in bio_models:

    model_file = Path(
        pkg_resources.resource_filename("libsbml_draw",
                                        "model/libs/" + model_file_name))

    sl = SBMLlayout(str(model_file))

    sl.describeModel()

    sl.drawNetwork(scaling_factor=.5)

#    sl.aliasNode("ADP")
Exemplo n.º 11
0
from pathlib import Path
import pkg_resources

from libsbml_draw.sbml_layout import SBMLlayout

model_file_name = "BorisEJB.xml"

model_file = Path(
    pkg_resources.resource_filename("libsbml_draw",
                                    "model/libs/" + model_file_name))

sl = SBMLlayout(str(model_file), autoComputeLayout=True)

sl.describeModel()

sl.drawNetwork("Boris_EJB.png")
sl.drawNetwork("Boris_EJB.pdf")

sl2 = SBMLlayout(str(model_file))

sl2.describeModel()

sl2.drawNetwork()
Exemplo n.º 12
0
         </reaction>
         <reaction id = "J3" reversible = "false">
            <listOfReactants>
               <speciesReference species = "Node4" stoichiometry = "1"/>
            </listOfReactants>
            <listOfProducts>
               <speciesReference species = "Node0" stoichiometry = "1"/>
            </listOfProducts>
            <kineticLaw>
               <math xmlns = "http://www.w3.org/1998/Math/MathML">
                  <apply>
                     <times/>
                     <ci>
                           J3_k
                     </ci>
                     <ci>
                           Node4
                     </ci>
                  </apply>
               </math>
            </kineticLaw>
         </reaction>
      </listOfReactions>
   </model>
</sbml>
"""

s = SBMLlayout()

s.drawNetwork()
Exemplo n.º 13
0
from libsbml_draw.sbml_layout import SBMLlayout

'''

add a config argument to SBMLlayout. 
This is either nested dict or yaml string or fname.
Helper methods for generating the position dictionary

Create another module called styles, with ready importable
preconfigured styles
'''

fname = f'Schmierer2008.xml'

s = SBMLlayout(fname)
font = dict()
s.drawNetwork(
    save_file_name='network.png',
    show=True, dpi=300, width_shift=0.25,
    height_shift=0.25, scaling_factor=1
)
s.regenerateLayout()
s.drawNetwork()
# s.writeSBMLFile("Schmierer2008WithLayout.xml")
'''
# node attributes

# edge attributes
ArrowheadNumStyles
ArrowheadNumVerts
ArrowheadStyle
Exemplo n.º 14
0
from pathlib import Path
import pkg_resources

import libsbml

from libsbml_draw.sbml_layout import SBMLlayout


model_file_name = "simple-L2-render-local.xml"
#model_file_name = "simple-L2-render-local-L3V1.xml"

model_file = Path(pkg_resources.resource_filename("libsbml_draw", "model/libs/" + model_file_name))

sll = SBMLlayout(str(model_file))

sll.describeModel()

sll.drawNetwork()

sll.setCompartmentEdgeColor("vol1", "#0000ff")
sll.setCompartmentFillColor("vol1", "#ff000010")
sll.setCompartmentLineWidth("vol1", 5)

for node in sll._SBMLlayout__network.nodes.values():
    print("_Node shape points: ", node.shape, len(node.polygon_points), len(node.polygon_codes))
    for point in node.polygon_points:
        print("point: ", point)
    for code in node.polygon_codes:
        print("code: ", code)

sll.drawNetwork()
Exemplo n.º 15
0
from pathlib import Path
import pkg_resources

from libsbml_draw.sbml_layout import SBMLlayout

model_file_name = "model.xml"

model_file = Path(
    pkg_resources.resource_filename("libsbml_draw",
                                    "model/libs/" + model_file_name))

sl = SBMLlayout(str(model_file))

sl.describeModel()

print()
print("node ids: ", sl.getNodeIds())
print("reaction ids: ", sl.getReactionIds())

sl.drawNetwork()

#out_file = "model_out.xml"
#sl.writeSBMLFile("model_out.xml")

#sl.getCurvesAttachedToNodes()

#sl2 = SBMLlayout(out_file)

#print("sl2 layoutSpecified: ", sl2._SBMLlayout__layoutSpecified)

#sl2.drawNetwork()
Exemplo n.º 16
0
if platform.system() == "Windows":
    model_dir = "C:\\Users\\nrhaw\\Documents\\repos\\libsbml-draw\\model_files\\"
    # model_file = "C:\\tmp\\copasi.xml"
    model_file = model_dir + "copasi.xml"
    #model_file = model_dir + "render_sbml_pink_green.xml"
elif platform.system() == "Linux":
    model_dir = "/home/radix/repos/libsbml-draw/model_files/"    
    model_file = "/home/radix/repos/libsbml-draw/model_files/copasi.xml"
else:
    model_dir = "/Users/natalieh/repos/libsbml-draw/model_files/"
    model_file = "/Users/natalieh/repos/libsbml-draw/model_files/copasi.xml"
#model_file = Path(pkg_resources.resource_filename("libsbml_draw", "model_files/model.xml"))

print("model file: \n", model_file)

sl = SBMLlayout(model_file)

sl.describeModel()

## Draw Original copasi.xml
sl.drawNetwork()

print("node ids: ", sl.getNodeIds())
print("reaction ids: ", sl.getReactionIds())

sl.setNodeFontStyle("S1", "italic")
sl.setNodeColor("S1", "lightpink")
sl.setNodeColor("S2", "lightgreen")

sl.setNodeFontColor("S1", "white")
sl.setNodeFontStyle("S1", "italic")
Exemplo n.º 17
0
from pathlib import Path
import pkg_resources

from libsbml_draw.sbml_layout import SBMLlayout

#model_file_name = "GlycolysisOriginal_L3V1.xml"
#model_file_name = "GlycolysisOriginal-L3V1.xml"
model_file_name = "GlycolysisOriginal.xml"

model_file = Path(
    pkg_resources.resource_filename("libsbml_draw",
                                    "model/libs/" + model_file_name))

sl = SBMLlayout(str(model_file))

sl.describeModel()

print("node font size: ", sl.getNodeFontSize("ATP"))

sl.drawNetwork("GlycolysisOriginal.pdf")

#sl.drawNetwork(figsize=(20,20))

#sl.setNodeFontSize("all", 8)

#sl.drawNetwork()

#for node in sl._SBMLlayout__network.nodes.values():
#    print("node id, name: ", node.id, node.name)
Exemplo n.º 18
0
  Node5 = 0;
  Node6 = 0;
  Node7 = 0;
  Node8888888 = 0;
  Node9 = 0;
  Node10 = 0;
  Node11 = 0;
  Node12 = 0;
  Node13 = 0;
  Node14 = 0;
end
''')

from libsbml_draw.sbml_layout import SBMLlayout

sl = SBMLlayout(r.getSBML())

sl.describeModel()

sl.drawNetwork()

#sl.drawNetwork(figsize=(8,8))

#sl.drawNetwork(figsize=(8,8), node_mutation_scale=5)

#sl.drawNetwork("complicated_nodes_antimony.png", show=False)

# plt.show?
# import IPython.display as display
# display.Image("complicated_nodes_antimony.png", width=300)
Exemplo n.º 19
0
from pathlib import Path
import pkg_resources

from libsbml_draw.sbml_layout import SBMLlayout

model_file_name = "model.xml"

model_file = Path(
    pkg_resources.resource_filename("libsbml_draw",
                                    "model/libs/" + model_file_name))

sl = SBMLlayout(str(model_file))

sl.describeModel()

print("node ids: ", sl.getNodeIds())
print("reaction ids: ", sl.getReactionIds())

sl.drawNetwork()

sl._describeReaction(0)

sl.setNodeEdgeWidth("all", 2)

out_file = "model_out.xml"
sl.writeSBMLFile("model_out.xml")

sl2 = SBMLlayout(out_file)

print("sl2 layoutSpecified: ", sl2._SBMLlayout__layoutSpecified)