- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
因此,如前所述,我正在尝试找到一种将 graphml 文件(或其他格式,如 xgmml、csv、edgelist)从 networkx 或 igraph(python 或 R)转换为 SBML 的方法。格式。
我相信应该有一种简单的方法,但是……我找不到。有任何想法吗?
编辑:有一些 other fomats可以用来最终降落在 SBML 星球上,但我仍然不知道如何导出到其中任何一个。
编辑二:here我发布了一个与 SBML 和 Cytoscape 相关的问题,所以......可能对其他对该主题感兴趣的人有用。
最佳答案
SBML 主要是基于编码过程或 react 的模型。这种模型对应的网络图是一个二分图,即图中有两类节点( react 和物种),物种和 react 节点之间只有边,而物种-物种或物种- react 之间没有边。
SBML 中的一个重要概念是 react 中的化学计量,它基本上是定义物种如何在相应 react 中发生的边缘属性。
因此,对于要转换为 SBML 的图,它们必须遵循一定的结构,即它们必须是具有反应和物种节点的二分有向图,边上有化学计量信息。
可以使用例如 libsbml 或 JSBML(用于操作 SBML 的两个库)轻松地将此类图转换为 SBML。
我在下面附上了一个示例,其中包含来自 libsbml 的 python 绑定(bind)。
"""
Converts simple bipartite species-reaction graph to SBML
using python bindings in libsbml
requirements:
pip install python-libsbml networkx
"""
import networkx as nx
import libsbml
'''
Create bipartite networkx graph consisting of species and reaction nodes.
Edges require stoichiometry (or set to 1 otherwise).
'''
G = nx.DiGraph()
# add species nodes
G.add_node("S1", ntype="specie")
G.add_node("S2", ntype="specie")
G.add_node("S3", ntype="specie")
G.add_node("S4", ntype="specie")
G.add_node("S5", ntype="specie")
G.add_node("S6", ntype="specie")
# add reaction nodes (and reaction edges)
G.add_node("r1", ntype="reaction") # 2 S1 -> S2
G.add_edges_from([
("S1", "r1", {'stoichiometry': 2}),
("r1", "S2", {'stoichiometry': 1})])
G.add_node("r2", ntype="reaction") # S2 -> S3
G.add_edges_from([
("S2", "r2", {'stoichiometry': 1}),
("r2", "S3", {'stoichiometry': 1})])
G.add_node("r3", ntype="reaction") # S3 + S4 -> S5 + S6
G.add_edges_from([
("S3", "r3", {'stoichiometry': 1}),
("S4", "r3", {'stoichiometry': 1}),
("r3", "S5", {'stoichiometry': 1}),
("r3", "S6", {'stoichiometry': 1})
])
print(G)
for sid, n in G.nodes.items():
print(sid, n)
for sid, e in G.edges.items():
print(sid, e)
'''
Create SBML model from the graph
'''
doc = libsbml.SBMLDocument() # type: libsbml.SBMLDocument
model = doc.createModel() # type: libsbml.Model
model.setId("graph_model")
# create species
for sid, n in G.nodes.items():
print(sid, n)
if n['ntype'] == "specie":
s = model.createSpecies() # type: libsbml.Species
s.setId(sid)
# create reactions
for sid, n in G.nodes.items():
if n['ntype'] == "reaction":
r = model.createReaction() # type: libsbml.Reaction
r.setId(sid)
for reactant_id in G.predecessors(sid):
stoichiometry = G.edges[reactant_id, sid]['stoichiometry']
reactant = model.getSpecies(reactant_id)
r.addReactant(reactant, stoichiometry)
for product_id in G.successors(sid):
product = model.getSpecies(product_id)
stoichiometry = G.edges[sid, product_id]['stoichiometry']
r.addProduct(product, stoichiometry)
# serialization
sbml_str = libsbml.writeSBMLToString(doc)
print("-" * 80)
print(sbml_str)
libsbml.writeSBMLToFile(doc, "graph2sbml.xml")
S1 {'ntype': 'specie'}
S2 {'ntype': 'specie'}
S3 {'ntype': 'specie'}
S4 {'ntype': 'specie'}
S5 {'ntype': 'specie'}
S6 {'ntype': 'specie'}
r1 {'ntype': 'reaction'}
r2 {'ntype': 'reaction'}
r3 {'ntype': 'reaction'}
('S1', 'r1') {'stoichiometry': 2}
('S2', 'r2') {'stoichiometry': 1}
('S3', 'r3') {'stoichiometry': 1}
('S4', 'r3') {'stoichiometry': 1}
('r1', 'S2') {'stoichiometry': 1}
('r2', 'S3') {'stoichiometry': 1}
('r3', 'S5') {'stoichiometry': 1}
('r3', 'S6') {'stoichiometry': 1}
S1 {'ntype': 'specie'}
S2 {'ntype': 'specie'}
S3 {'ntype': 'specie'}
S4 {'ntype': 'specie'}
S5 {'ntype': 'specie'}
S6 {'ntype': 'specie'}
r1 {'ntype': 'reaction'}
r2 {'ntype': 'reaction'}
r3 {'ntype': 'reaction'}
--------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<sbml xmlns="http://www.sbml.org/sbml/level3/version2/core" level="3" version="2">
<model id="graph_model">
<listOfSpecies>
<species id="S1"/>
<species id="S2"/>
<species id="S3"/>
<species id="S4"/>
<species id="S5"/>
<species id="S6"/>
</listOfSpecies>
<listOfReactions>
<reaction id="r1">
<listOfReactants>
<speciesReference species="S1" stoichiometry="2" constant="true"/>
</listOfReactants>
<listOfProducts>
<speciesReference species="S2" stoichiometry="1" constant="true"/>
</listOfProducts>
</reaction>
<reaction id="r2">
<listOfReactants>
<speciesReference species="S2" stoichiometry="1" constant="true"/>
</listOfReactants>
<listOfProducts>
<speciesReference species="S3" stoichiometry="1" constant="true"/>
</listOfProducts>
</reaction>
<reaction id="r3">
<listOfReactants>
<speciesReference species="S3" stoichiometry="1" constant="true"/>
<speciesReference species="S4" stoichiometry="1" constant="true"/>
</listOfReactants>
<listOfProducts>
<speciesReference species="S5" stoichiometry="1" constant="true"/>
<speciesReference species="S6" stoichiometry="1" constant="true"/>
</listOfProducts>
</reaction>
</listOfReactions>
</model>
</sbml>
关于python - 如何从其他格式导出 sbml 文件,例如 graphml?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60053821/
我正在开发 cytoscape.js项目。我有一个 graphml 文件(一种用于表示图形的基于 XML 的文件格式),我需要将其显示在浏览器上。为此,我使用扩展库 cytoscape-graphml
Closed. This question does not meet Stack Overflow guidelines。它当前不接受答案。 想要改善这个问题吗?更新问题,以便将其作为on-topi
我正在尝试查看 .graphml file按照 this thread 中的建议在图表 yEd 编辑器中.但是我很难查看节点中的值。 当我打开 .graphml 文件时,它如图 1 所示。然后我单击L
我有一个 prefuse 应用程序,用于加载 GraphML 文件,其中节点具有“Color”字符串属性。即。 Green 我想允许指定一系列预定义颜色,并且不想强制创建 GraphML 的程
将 networkx 图转换为 graphml 时遇到以下问题(无法在此处发布所有代码,但这是要点)。 NetworkX版本为1.6.2 我有一个名为 G 的 networkx 有向图 G = nx.
我最近发现了一个 .graphml 文件,但不知道如何从命令行打开它。我是否需要安装一些东西才能从命令行在 ubuntu 中查看此类文件?我试过谷歌,但找不到与该主题相关的任何结果。 最佳答案 Gra
您好,我有一个简单的 graphML 文件,我想从 GraphML 中删除节点标记并将其保存在另一个 GraphML 文件中。 GraphML 大小为 3GB,下面给出的是示例。 输入文件:
谁能解释一下 Boost 使用的 GraphML 格式?它包括其他 GraphML 作者不使用的间接级别。我包含了来自 2 个来源的 GraphML 输出,它们都来自相同的输入数据。我不明白为什么 B
我对如何将图形导出为 svg 或 graphml 有点困惑。直到现在,forum.jgraph.com 上的 API、示例或线程都没有帮助我。 我需要将图表导出为 svg 和 graphml。我得到了
我是 python 的新手,我想导出一个图形(传输网络),它是我使用名为 OSMnx 的 python 包构建的。我无法将其导出为 graphml 文件以进一步分析网络。我附上了我使用的代码和我遇到的
我正在尝试将包含单个有向图的 GraphML 文件读入 Haskell Data.Graph 为了使用 Math.Combinatorics.Graph 运行分析模块。 但是,我找不到任何允许我读取
因此,我在我的一个脚本中切换 graphML 导入方法,但在清理导入的数据时遇到了问题。目前,graphML 数据如下所示: www.someURL.com Guy, This /dir
我正在使用 NetworkX 1.9.1。 我有一张图表,需要根据位置进行组织,然后导出为 graphml 格式。 我试过 this question 中的代码.它不起作用,这是我的例子 import
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,
我正在尝试使用 Java 中的 XOM 编写一个 graphML 文档,但我无法弄清楚如何使所有 namespace 声明都正确。要拥有有效的 graphML,我需要有一个如下所示的根元素: 我已经
因此,如前所述,我正在尝试找到一种将 graphml 文件(或其他格式,如 xgmml、csv、edgelist)从 networkx 或 igraph(python 或 R)转换为 SBML 的方法
我有以下 GraphML 文件“mygraph.gml”,我想用一个简单的 python 脚本解析它: 这表示一个简单的图,有 2 个节点“node0”、“node1”和它们之间的边
早上好,我想在 gephi 中可视化一个 emoji graphml 文件,但是,当我导入它时,它一直显示黑点,如下所示: 我不确定发生了什么。我错过了什么吗?如果可以,请给我一些指导,我使用的是 W
什么是标准图形表示文件格式或最常用的一种? 我会说这三个之一: GraphSON GEXF GraphML 但如果有人能指出他们每个人的优点/缺点,那就太好了。 最佳答案 答案最终取决于您问题的规模以
当我尝试使用 JUNG 在文本文件中读取和写入图形时,我遇到了问题。情况如下:给定一个文件,其中包含多重图的坐标及其权重。 一个例子是: 6346 6728 5911 156 5 6
我是一名优秀的程序员,十分优秀!