igemsoftware / SYSU-Software_2014

This is a repo owned by SYSU-Software team for iGEM 2014.
GNU Lesser General Public License v3.0
9 stars 1 forks source link

前后端交互接口定义 #1

Open cairijun opened 10 years ago

cairijun commented 10 years ago
{
  "result": [
    {"type": "input", "name": "Input XXX", "id": 1234},
    {"type": "input", "name": "Input YYY", "id": 5687},
    ...]
}
{
  "result": {"type": "input", "name": "Input XXX", "id": 1234}
}
{
  "result": [
    {"type": "promoter", "name": "Input XXX", "id": 1234},
    {"type": "promoter", "name": "Input YYY", "id": 5687},
    ...]
}
{
  "result": [
    {"type": "receptor", "name": "Input XXX", "id": 1234},
    {"type": "receptor", "name": "Input YYY", "id": 5687},
    ...]
}
{
  //限制输入最多为两个
  "inputs": [
    {"id": 1, "promoter_ids": [1], "receptor_id": 1},
    {"id": 2, "promoter_ids": [1], "receptor_id": 1}
  ],
  //限制输出最多为三个
  "outputs": [1, 2, 3],
  "truth_table": [
    {"inputs": [true, true], "outputs": [true, true, false]},
    {"inputs": [true, false], "outputs": [false, true, false]},
    {"inputs": [false, true], "outputs": [true, false, false]},
    {"inputs": [false, false], "outputs": [false, true, true]}
  ]
}

响应格式:

{
  "inputs": [
    {
      "eid": "c5820968a77f4c278093a048fe60e28a",
      "type": "input", "id": 1, "name": "Input 1", 
      "promoters": [
        {"type": "promoter", "eid": "02d32d2742a2494f98a641b3c535d0fe",
        "name": "Promoter 1", "id": 1}
      ], 
      "receptor": {
        "type": "receptor", "eid": "418d4ad9ebf04655a4815799af23a915",
        "name": "Receptor 1", "id": 1
      }
    },
    {
      //input 2...
    }
  ], 
  "schemes": [
    {
      "outputs": [
        "51f0549840b54342bcaa4789e6a20239", 
        "b8d861b45b054c20a88a71f3b2be9e5c", 
        "5c0647b146174d36adfc278c365fa046"
      ], 
      "logic_gates": [
        {
          "id": 4, "name": "Not 1", "logic": "NOT", 
          "eid": "abab5341130042cca9ecadcba0156570", 
          "inputs": [
            "51f0549840b54342bcaa4789e6a20239"
          ], 
        }, 
        {
          "id": 3, "name": "Or 1", "logic": "OR", 
          "eid": "58d44e82aa1c4ca0bf3983583fedc556", 
          "inputs": [
            "c5820968a77f4c278093a048fe60e28a", 
            "51f0549840b54342bcaa4789e6a20239"
          ], 
        }, 
        {
          //其他逻辑门
        }
      ]
    }, 
    {
      //其他方案
    }
  ]
}

每个元件用eid来唯一标识。

其他的还在设计,尽快写~

LiuXiangyu commented 10 years ago

非常好!

cairijun commented 10 years ago

更新后的数据结构定义:

{
    "circuits": [
        {/* A circuit object */},
        {/* A circuit object */},
        {/* A circuit object */},
    ],
    "relationships": [
        {
            "from": "58d44e82aa1c4ca0bf3983583fedc556",
            "to": "c5820968a77f4c278093a048fe60e28a",
            "type": "promote",
        },
        {
            "from": "02d32d2742a2494f98a641b3c535d0fe",
            "to": "418d4ad9ebf04655a4815799af23a915",
            "type": "repress",
        }
    ]
}

基本元件会根据需要添加其他字段用于对元件进行更详细的描述。

LiuXiangyu commented 9 years ago

改动:

{
    "id": 1,
    "type": "XXX",
    "name": "Input XXX",
    //以下字段仅在Circuit或Device中存在
    "eid": "c5820968a77f4c278093a048fe60e28a",
}
{
    "id": 1,
    "type": "logic",
    "name": "And Gate XXX",
    "truth_table": "FFFT",
    "intermedia": ["XXX", "YYY"],
    //以下两个字段在Circuit或Device中能被替换
    /* 如果不存在逻辑门,比如只有一个input,那么以下就只会得到promoter和output。*/
    "inputparts": [
        [
            {/* An promoter biobrick */},
            {/* An RBS biobrick */},
            {/* An output biobrick */}
            {/* An terminator biobrick */}
        ],
        [
            {/* An promoter biobrick */},
            {/* An RBS biobrick */},
            {/* An output biobrick */}
            {/* An terminator biobrick */}
        ],
    ],
    "outputpart": 
    [
            {/* An promoter biobrick */},
            {/* An RBS biobrick */},
            {/* An output biobrick */}
            {/* An terminator biobrick */}
     ],
    //以下字段仅在Circuit或Device中存在
    "eid": "c5820968a77f4c278093a048fe60e28a",
}

一个circuit可能会有多个不同的logic,output直接存在logic里

{
    "inputs": [
       [/*a biobrick array*/], /*其实就是存input和receptor*/
       [/*a biobrick array*/],
    ],
    "logics": [
        {/* An logic object */},
        {/* An logic object */},
        {/* An logic object */}
    ]
}

增加type为terminator的Biobrick

cairijun commented 9 years ago

感觉把inputparts中的promoters移到inputs中会比较好:

{
    "inputs": [
        [
            {/* An input object */},
            {/* A receptor object */},
            {/* A promoter object */},
            {/* A promoter object */}
        ],
        [
            /* ... */
        ]
    ],
    "logics": [
        {/* A logic object */},
        {/* A logic object */}
    ]
}

因为inputparts中的promoters不是logic的一部分,不是存储在数据库中的,移出来后logic可以使用数据库中取出来的数据,不用再去修改了

另外,circuit实现方案的响应格式如下:

{
    "inputs": [/* ... */],
    "logics": [
        [{/* Option 1 for output 1 */}, {/* Option 2 for output 2 */}],
        [{/* Option 1 for output 2 */}],
        [{/* Option 1 for output 3 */}, {/* Option 2 for output 3 */}, {/* Option 3 for output 3 */}]
    ]
}
cairijun commented 9 years ago

此外,考虑到存在多个输出的Logic,outputpart改为outputparts,是一个数组,类似inputparts

cairijun commented 9 years ago

circuit的promoter的放置按照原来 @LiuXiangyu 的方案

terminator需要用户选择,circuit实现方案的请求格式如下:

{
    "inputs": [
        {"id": 1, "receptor_id": 1, "promoter_id": 3},
        {"id": 2, "receptor_id": 2, "promoter_id": 4},
    ],
    "outputs": [
        {"id": 1, "terminator_id": 1},
        {"id": 2, "terminator_id": 1},
    ],
    "truth_table": [/* 略 */]
}
LiuXiangyu commented 9 years ago
{
    "inputs": [
        {"id": 1, "receptor_id": 1, "promoter_id": 3},
        {"id": 2, "receptor_id": 2, "promoter_id": 4},
    ],
    "outputs": [1, 2], /*用户不用选择terminator,还是改成id的数组*/
    "truth_table": [/* 略 */]
}