ros知识网络

ros的Python项目详细描述


请参见主页以获取格式更高的版本。

<;src>;

概述

ros执行查询图以协作地组成知识网络。

尽管该语言提供了支持变量、模块性、可扩展性、模板和类型系统的公共结构,但它的目标是创建能够进行推理和推理的高度详细的知识图。

用法

从命令行本地运行工作流会产生如下输出:

<;src>;

并构建此知识图:

<;/src>;

语言参考

概述

工作流是一系列步骤。 步骤可以引用前面步骤的输出。 一般来说,它们可以访问共享图。 它们还可以交换子图。 步骤可以有相关的元数据来描述其允许的输入和输出类型。

工作流计算有向无环图(DAG)建模作业依赖关系,然后按DAG的拓扑排序指示的顺序执行。

变量

通过命令行或api传递给工作流的变量可以动态解析。在本例中,$disease_name是指执行上下文为此工作流提供的参数。提供的值将在运行时被替换。

在下面的示例中,disease_identifiers是作业的名称。它产生一个图形。表示该图的json对象将存储为作业名称的值。图形也会写入共享图形数据库。亚赛克用户作业可以与任一表示交互。

代码标记告诉引擎要执行哪个功能块。

args部分列出对此操作员的输入。

  disease_identifiers:
    doc: |
      Resolve an English disease name to an ontology identifier.
    code: bionames
    args:
      type: disease
      input: $disease_name

操作员

工作流是围绕图运算符组织的。每个人都可以访问ros框架的所有设施,包括共享图。

通常,工作流作业具有以下字段:

  • 文档:文档字符串。
  • 代码:提供功能的组件的名称。
  • 参数:运算符的参数。

ROS目前提供以下核心运营商:

  • get:调用指定资源上的http get操作。
  • 并集:将两个或多个结果并集到一个对象中。

它还包括特定于翻译人员的模块。将来,这些将作为ros插件实现:

  • 生物铰链:生物铰链模块。当前工作流1的模块4和5。
  • gamma:调用gamma推理器。下面的例子用不同的机器问题调用gamma几次。将更新为使用新的Quick API以增加灵活性。
  • X射线:X射线推理器模块。当前工作流1的模块1和2。

图表

ROS提供两种基本模式的图形:

  • 结果:以前工作流步骤的结果可以作为传递给后续步骤的变量引用。可以使用json路径查询语法查询此图。以下示例使用ros框架中的json select工具查询名为condition的变量:
    diseases = event.select (
             query = "$.[*].result_list.[*].[*].result_graph.node_list.[*]",
             obj = event.conditions)
    
  • 共享:所有操作员都可以使用cypher查询语言访问共享图。本例使用ros框架对共享图的cypher查询和biolink模型概念。
    diseases = event.context.graph.query ("match (a:disease) return  a")
    

每个操作员接收ros框架提供的事件对象。事件提供框架服务,包括共享图形、图形操作工具和调用运算符的参数。

这些功能允许操作员在执行其主逻辑之前查询图形并对其进行更新。

元数据

该语言支持元数据功能,使模块能够指定其输入和输出。

输入支持这些标记:

  • 文档:文档
  • 类型:类型当前派生自标准库,但将来将是可扩展和可组合的。
  • 必需:是否需要参数。

输出支持这些标记:

  • 文档:文档。
  • 类型:返回对象的类型。

元数据的使用是可选的。

模板

模板允许通过组合将现有库函数专门化为新功能来扩展语言。模板是在独立于工作流的模板部分中定义的。它们也可以在单独的、可重复使用的模块中定义。

模块

外部模块可以通过导入标记加载。

与其他高级编程语言中的功能类似的库路径控制库的加载位置。

自动验证

当一个工作流运行时,我们希望运行验证来测试我们得到的答案的完整性。在第一个ros版本中,我们支持有限形式的自动验证。限制的动机是使ros安全。因为我们是远程执行查询的,所以在Internet上运行从客户端发布的任意图形查询是不现实的。相反,我们提供了一个有限的查询语法,它仍然允许我们进行大量的验证。查询语法称为yfur-一个功能较弱的查询系统,让人想起cypher。

Workflow One下面的示例显示了Syfur的用法。

automated_validation:
  doc: |
    Automated Validation
       We can test the knowledge network with constraints including all, match, and none.
       The depends arg ensures the validation runs only after the graph is built.
       Each test has a name, documentation, a query, and an operator defining the constraint to enforce
    Syfur
       A principal virtue of Ros is the ability to remotely execute workflows.
       To make this possible, it must be secured against remote code execution attacks
       This includes cypher injection.
       It may be possible to accomplish some of this in other ways, but for now, we provide Syfur
       Syfur is a restricted DSL that translates to a subset of Cypher. See examples below.
  code: validate
  args:
    depends: $biothings_module_4_and_5
    tests:
      test_type_2_diabetes_exists:
        doc: Ensure type 2 diabetes mellitus and other conditions are present.
        items: "match type=disease return id"
        all: [ "OMIM:600001", "MONDO:0005148", "DOID:9352" ]
      test_pioglitazone:
        doc: Test attributes of a specific chemical. Ensure type 2 diabetes mellitus is present.
        items: "match type=chemical_substance id=CHEMBL.COMPOUND:CHEMBL595 return node_attributes"
        match:
          - .*Thiazolidinedione.*
          - ".*{'name': 'EPC', 'value': 'Peroxisome Proliferator Receptor gamma Agonist'}.*"
      test_absence_of_something:
        doc: Verify there is none of something in our graph.
        items: "match return id"
        none: [ 'BAD:123' ]

把它们放在一起

下面是一个使用示例,用于将所有这些内容置于上下文中。

<H3>1。定义模板

我们从将用户提供的文本转换为本体标识符的常见用例开始。为此,我们创建了一个模板任务。

  • 它扩展了内置的http操作符,并将模式参数设置为定义的值。
  • 它被保存到库路径目录中名为bionames.ros的文件中。

bionames模板现在是一个可重用的组件,可以导入到各种工作流中。

<H3>2。可选模型输入和输出类型

尽管当前是可选的,但模板还指定

  • meta标记描述有关运算符的元数据。
  • 未指定子运算符时,使用main运算符。
  • 每个操作员都有输入和输出部分。
  • 输入部分指定输入值列表。
  • 每个标签都可能有doctype必需的标签。
  • 输出部分可能包含文档类型标记。
  • 在这两种情况下,类型的值必须(当前)来自ros标准库,如其他地方所述。
doc: |
  This module defines a reusable template.
  It can be imported into other workflows via the import directive.

templates:

  bionames:
    doc: |
      This template extends the built in get operator.
    code: get
    args:
      pattern: 'https://bionames.renci.org/lookup/{input}/{type}/'
    meta:
      main:
        args:
          input:
            doc: The name of the object to find identifiers for.
            type: string
            required: true
          type:
            doc: The intended biolink_model type of the resulting identifiers.
            type: biolink_model
            required: true
        output:
          doc: A Translator standard knowledge graph.
          type: knowledge_graph_standard

biolink模型和知识图标准目前直接在ros标准库中建模。

types:
  string :
    doc: A primitive string of characters.
    extends: primitive
  biolink_model:
    doc: An element from the Biolink-model 
    extends: string
  knowledge_graph_standard:
    doc: A Translator knowledge graph standard (KGS) knowledge graph.
    extends: primitive
<H3>3。构建工作流

接下来,我们将上述模板导入到工作流定义中。

doc: |
  NCATS Biomedical Translator - Workflow One
  
import:
  - bionames
  
workflow:

  disease_identifiers:
    doc: |
      Resolve an English disease name to an ontology identifier.
    code: bionames
    args:
      type: disease
      input: $disease_name
...

disease_identifiers任务实例化bionames模板。它提供所需的参数,包括解析特定于此工作流的疾病名称输入参数。

执行此模块后,后续步骤可以引用它通过变量$disease\u标识符生成的图形

工作流中的下一步通过引用模板调用的输出来利用此功能。工作流引擎看到此引用,并使新作业依赖于被引用的作业。这就是如何计算控制执行顺序的作业DAG。

  condition_to_drug:
    doc: |
      Module 1
        * What are the defining symptoms / phenotypes of [condition x]?
        * What conditions present [symptoms]?
        * Filter [conditions] to only keep ones with defined genetic causes.
        * What subset of conditions are most representative of [conditions]? (find archetypes)
      Module 2
        * What genes are implicated in [condition]?
        * What subset of genes are most representative of [conditions]?  (find archetypes)
        * What pathways/processes are [genes] involved in?
        * What genes are involved in [pathway/process]?
        * What drugs/compounds target gene products of [gene]?
      Invoke XRay module 1 and 2 given the disease identifier from bionames.
      The graph argument references the entire bionames response.
      The op argument specifies the XRay operation to execute.
    code: xray
    args:
      op: condition_expansion_to_gene_pathway_drug
      graph: $disease_identifiers

有关更多详细信息,请参见整个工作流

执行

对于所有工作流,引擎通过检查每个作业以确定其依赖关系来构建作业的有向非循环图(DAG)。

作业的拓扑类型提供执行顺序。

执行是异步的。如果您订阅了"concurrent"和"parallel"之间的语义区别工作流执行是并发的,但不是并行的。

当前的实现使用python的异步。这意味着多个操作可以在同一时间窗口内进行。但这并不意味着操作可以同时执行(运行cpu操作)。当前的操作配置文件是I/O绑定的,而不是CPU绑定的,因此这种方法可能在一段时间内就足够了。一些任务可以等待http请求返回,而其他任务则使用处理器处理结果。

api还使用sanic和tornado异步处理请求。

开始

码头工人

要求 < UL>
  • 码头工人
  • Docker合成(包含在Mac上的Docker中)
  • Git
  • 端口7474、7687和5002可用
  • 开始

    git clone git@github.com:NCATS-Tangerine/ros.git
    cd ros/deploy
    source ros.env
    docker-compose up
    

    用法-命令行

    • 连接到本地NEO4J
    • 连接到API Docker容器
    • 通过API运行工作流。
      disease_identifiers:
        doc: |
          Resolve an English disease name to an ontology identifier.
        code: bionames
        args:
          type: disease
          input: $disease_name
    
    0

    使用-编程

    ros可以远程执行工作流并返回生成的知识网络。客户端当前支持json和netowrkx表示。

      disease_identifiers:
        doc: |
          Resolve an English disease name to an ontology identifier.
        code: bionames
        args:
          type: disease
          input: $disease_name
    
    1

    安装

    要求:

    • 巨蟒>;3.7.x
    • NEO4J>;3.3.4

    步骤:

    这些步骤包括安装包、打印帮助文本和执行工作流1。要运行此操作,您需要repo中的workflow_one.ros和bionames.ros。-l workflows标志指定包含工作流的目录。

      disease_identifiers:
        doc: |
          Resolve an English disease name to an ontology identifier.
        code: bionames
        args:
          type: disease
          input: $disease_name
    
    2

    无损检测

    将工作流保存到ndex。

    • 创建一个ndex帐户。

    • 创建~/.ndex凭据文件,如下所示:

        disease_identifiers:
          doc: |
            Resolve an English disease name to an ontology identifier.
          code: bionames
          args:
            type: disease
            input: $disease_name
      
      3
    • 使用ndex输出运行工作流:

        disease_identifiers:
          doc: |
            Resolve an English disease name to an ontology identifier.
          code: bionames
          args:
            type: disease
            input: $disease_name
      
      4

    帮助

      disease_identifiers:
        doc: |
          Resolve an English disease name to an ontology identifier.
        code: bionames
        args:
          type: disease
          input: $disease_name
    
    5

    下一步

    • 信息架构:开发:
      • 受控词汇:特别是关于模块是什么以及它们之间的关系
      • 输入和输出签名:对于模块
      • 来源:在工作流来源(哪个用户、多长时间等)和源的元数据(scepio?)
    • 多态性:如果实现一个功能的多个实体可以实现相同的openapi接口来启用多态性调用,那将非常有帮助。这也有助于并行性。
    • kgx:也许kgx应该是共享图,至少是可选的。只需设计连接即可。
    • 并发/并行/分布式:ros现在支持通过python async执行并发任务。如果结果证明这还不够,可以探索通过一些能够并行或分布式执行的东西来运行。
    • 可组合性:允许工作流导入和重用其他工作流。

    欢迎加入QQ群-->: 979659372 Python中文网_新手群

    推荐PyPI第三方库


    热门话题
    java CXF和授权   java在网站中部署使用swing创建的表单   java为什么getHeaderField()返回一个字符串,其中getHeaderFields()返回HttpUrlConnection中的Map<String,List<String>>   java如何检测恶意数据包?   webview中的java网页为空   java SWT图像资源,用于将我的所有图像存储在一个位置   java计算数组的最大长度,使平均值小于给定值   java“发件人电话号码无效”和美国号码   将Swing组件作为内容的自定义Java工具提示不会显示   在并发HashMap中重新灰化期间的java检索   Java 7和Tomcat 7.0.64 ClassFormatException:常量池中的字节标记无效   使用JUnit的java assertNull因NullPointerException失败   java内存中的文件是否与文件系统中的文件大小相同?   循环内实例化的类型的java注入依赖项