我有一个像这样的.sif文件
NodeA "phosphorylation" NodeB
NodeA "binding" NodeC
NodeB "phosphorylation" NodeC
NodeD "binding" NodeC
我需要将其转换为JSON,Cytoscape JS可以使用它来生成使用节点及其关系的图形。
我需要它的格式
[
{"data":{"id":"n40","weight":53},"position":
{"x":50,"y":45},"group":"nodes","removed":false,"selected":false,
"selectable":true,"locked":false,"grabbable":true,"classes":""},
{"data":{"id":"n41","weight":23},"position":
{"x":150,"y":45},"group":"nodes","removed":false,
"selected":false,"selectable":true,"locked":false,
"grabbable":true,"classes":""},
..........................
{"data":{"id":"e129","weight":31,"source":"n65","target":"n58"},
"position":{},"group":"edges","removed":false,"selected":false,
"selectable":true,"locked":false,"grabbable":true,"classes":""},
{"data":{"id":"e131","weight":90,"source":"n53","target":"n43"},
"position:{},"group":"edges","removed":false,"selected":false,
"selectable":true,"locked":false,"grabbable":true,"classes":""},
]
答案 0 :(得分:0)
你试过SIF.js吗?我在npm发现了它:https://www.npmjs.com/package/sif.js
它与Cytoscape的JSON格式不完全相同,但您可以使用它和.map()
条目,以便它们匹配。或者您可以使用the repo中的代码构建自己的解析函数,直接输出Cytoscape format。
您也可以使用Cytoscape desktop software将SIF转换为JSON,但这不能作为JS应用程序的一部分自动生成。