Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

前后端交互接口定义 #1

Open
cairijun opened this issue Sep 1, 2014 · 7 comments
Open

前后端交互接口定义 #1

cairijun opened this issue Sep 1, 2014 · 7 comments

Comments

@cairijun
Copy link
Member

cairijun commented Sep 1, 2014

  • GET /biobrick/<type>

    <type>可取值inputoutputreceptorpromoter,获取某种元件的列表。返回格式:

{
  "result": [
    {"type": "input", "name": "Input XXX", "id": 1234},
    {"type": "input", "name": "Input YYY", "id": 5687},
    ...]
}
  • GET /biobrick/<type>?id=XXX

    根据ID获取某个元件的信息。返回格式:

{
  "result": {"type": "input", "name": "Input XXX", "id": 1234}
}
  • GET /biobrick/suggest/promoters?input_id=XXX

    根据Input推荐Promoter。返回格式:

{
  "result": [
    {"type": "promoter", "name": "Input XXX", "id": 1234},
    {"type": "promoter", "name": "Input YYY", "id": 5687},
    ...]
}
  • GET /biobrick/suggest/receptors?input_id=XXX&promoter_id=YYY

    根据Input和Promoter推荐Receptor。返回格式:

{
  "result": [
    {"type": "receptor", "name": "Input XXX", "id": 1234},
    {"type": "receptor", "name": "Input YYY", "id": 5687},
    ...]
}
  • POST /circuit/schemes

    根据真值表设计通路。(目前的算法实现只能处理完整的真值表
    请求格式:

{
  //限制输入最多为两个
  "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
Copy link
Member

非常好!

@cairijun
Copy link
Member Author

更新后的数据结构定义:

  • Basic Component

    • input
    {
        "id": 1, //在Circuit或Device中时,"id": null表示无输入只有promoter(s)
        "type": "input",
        "name": "Input XXX",
        //以下字段仅在Circuit或Device中存在
        "receptor": {/* A receptor object */},
        "promoters": [
            {/* A promoter object */},
            {/* A promoter object */},
        ],
        "eid": "c5820968a77f4c278093a048fe60e28a",
    }
    • output
    {
        "id": 1,
        "type": "output",
        "name": "Output XXX",
        //以下字段仅在Circuit或Device中存在
        "eid": "c5820968a77f4c278093a048fe60e28a",
    }
    • receptor
    {
        "id": 1,
        "type": "receptor",
        "name": "Receptor XXX",
        //以下字段仅在Circuit或Device中存在
        "eid": "c5820968a77f4c278093a048fe60e28a",
    }
    • promoter
    {
        "id": 1,
        "type": "promoter",
        "name": "Promoter XXX",
        //以下字段仅在Circuit或Device中存在
        "eid": "c5820968a77f4c278093a048fe60e28a",
    }
    • RBS
    {
        "id": 1,
        "type": "rbs",
        "name": "RBS XXX",
        //以下字段仅在Circuit或Device中存在
        "eid": "c5820968a77f4c278093a048fe60e28a",
    }
    • logic
    {
        "id": 1,
        "type": "logic",
        "name": "And Gate XXX",
        "truth_table": "FFFT",
        "intermedia": ["XXX", "YYY"],
        //以下两个字段在Circuit或Device中能被替换
        "inputs": [
            {
                "RBS": {/* An RBS object */},
                "output": {/* An output object */}
            },
            {
                "RBS": {/* An RBS object */},
                "output": {/* An output object */}
            },
        ],
        "outputs": [
            {
                "promoter": {/* An promoter object */},
                "RBS": {/* An RBS object */},
            },
        ],
        //以下字段仅在Circuit或Device中存在
        "eid": "c5820968a77f4c278093a048fe60e28a",
    }
  • Circuit(能够用一个预先确定的方程组表示)

    • 单个完整通路
    {
        "inputs": [
            {/* An input object */},
            {/* An input object */},
        ],
        "outputs": [
            {/* An output object */},
        ],
        //如果是简单通路,则"logic": null
        //circuit的inputs和outputs,与logic中的inputs和outputs按顺序一一对应
        "logic": {/* An logic object */},
    }
    • 通路方案请求
    {
        "inputs": [
            {"id": 1, "receptor_id": 1, "promoter_ids": [1, 2]},
            {"id": 2, "receptor_id": 4, "promoter_ids": [5]},
        ],
        "outputs": [2],
        "truth_table": [ //可以不完整
            {"inputs": [false, false], "outputs": [false]}
            {"inputs": [false, true], "outputs": [false]},
            {"inputs": [true, false], "outputs": [false]},
            {"inputs": [true, true], "outputs": [true]},
        ]
    }
    • 通路方案列表
    {
        "logic": [
            null,
            {/* An logic object */},
            {/* An logic object */},
        ]
        //其余与单个完整通路一样
    }
  • Device(由一个或多个circuit(s),以及circuits之间的调控关系组成)

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

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

@LiuXiangyu
Copy link
Member

改动:

  • 把所有元件统一成一个Biobrick类
{
    "id": 1,
    "type": "XXX",
    "name": "Input XXX",
    //以下字段仅在Circuit或Device中存在
    "eid": "c5820968a77f4c278093a048fe60e28a",
}
  • logic
{
    "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里

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

增加type为terminator的Biobrick

@cairijun
Copy link
Member Author

感觉把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
Copy link
Member Author

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

@cairijun
Copy link
Member Author

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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants