nuget server logo nuget api documents
↑

API Docs / SMRUCC.genomics.Data.GO_OWL / Builder

Builder

Full name SMRUCC.genomics.Data.GeneOntology.DAG.Builder Assembly SMRUCC.genomics.Data.GO_OWL Members 12

01 Syntax

SMRUCC.genomics.Data.GeneOntology.DAG.Builder

02 Methods

NameOverloadsSummary
safeArray 1 安全的空值处理
isTrue 1 判断obo文本之中的逻辑值标记是否为真,例如is_obsolete: true
DescendantSets 1 由祖先闭包反查得到子孙索引
AncestorSets 1 计算出DAG图之中所有节点的祖先闭包集合
walkAncestors 1 记忆化的祖先闭包递归求解,visiting用于防止因为数据错误 而出现的环导致的无限递归
ParentIndex 1 构建出[term_id => parent term_id()]的索引
AltIdIndex 1 建立[alt_id => primary term id]映射表
CreateClusterMembers 1 由祖先集合反查得到每一个GO词条的所有的子孙节点
BuildTree 1 从obo词条集合之中构建出DAG图的节点集合
ConstructNode 1 Creates a node in this DAG graph
TermXrefParser 1
GetTermXrefs 1

03 Members

method safeArray #
safeArray``1(``0())

安全的空值处理

Remarks

与SafeQuery的区别在于:SafeQuery在遇到Nothing的时候会向 控制台输出一条警告信息,而在go.obo之中有大量的词条并没有 is_a/relationship/xref这些字段,使用SafeQuery会 刷出数以十万计的警告信息,从而严重的拖慢构建的 speed

Type Parameters
NameDescription
T
Parameters
NameTypeDescription
source``0()

-

method isTrue #
isTrue(String)

判断obo文本之中的逻辑值标记是否为真,例如is_obsolete: true

Parameters
NameTypeDescription
value$String

-

method DescendantSets #
DescendantSets(Dictionary(Of TermNode), Dictionary(Of String, String()))

由祖先闭包反查得到子孙索引

Remarks

这个函数是Builder.CreateClusterMembers()的新的实现: 只需要对祖先集合做一次反查聚合即可,复杂度为O(N * A), 而不像旧版本那样需要枚举出所有指数级数量的祖先路径。

Parameters
NameTypeDescription
treeDictionary(Of TermNode)

-

ancestorsDictionary(Of String, String())

[term_id => all ancestor term_id],即Builder.AncestorSets()的产物

Returns

[term_id => all descendant nodes],不包含term自身

method AncestorSets #
AncestorSets(Dictionary(Of String, String()))

计算出DAG图之中所有节点的祖先闭包集合

Remarks

由于GO是一个有向无环图,一个节点可能会有多个父节点,所以直接递归枚举路径 会得到指数级数量的结果。在这里只关心集合而不关心路径,所以通过记忆化 的DFS,让每一个节点的祖先集合只被计算一次。

Parameters
NameTypeDescription
parentsDictionary(Of String, String())

[term_id => parent term_id()],即Builder.ParentIndex()的产物

Returns

[term_id => all ancestor term_id],不包含term自身,与拓扑顺序无关

method walkAncestors #
walkAncestors(String, Dictionary(Of String, String()), Dictionary(Of String, String()), HashSet(Of String))

记忆化的祖先闭包递归求解,visiting用于防止因为数据错误 而出现的环导致的无限递归

method ParentIndex #
ParentIndex(Dictionary(Of TermNode), OntologyRelations())

构建出[term_id => parent term_id()]的索引

Remarks

注意:has_part/regulates之类的关系按照GO官方的约定不参与 注释的传播,所以默认只使用is_a与part_of。

Parameters
NameTypeDescription
treeDictionary(Of TermNode)

-

relationsOntologyRelations()

除了is_a之外,还需要参与计算的relationship关系类型列表, 默认为Graph.DefaultRelations

method AltIdIndex #
AltIdIndex(IEnumerable(Of Term))

建立[alt_id => primary term id]映射表

Remarks

旧的注释数据之中可能会使用已经被废弃掉的alt_id编号, 通过这个映射表可以将其回填为最新的主编号

Parameters
NameTypeDescription
fileIEnumerable(Of Term)

-

method CreateClusterMembers #
CreateClusterMembers(Graph)

由祖先集合反查得到每一个GO词条的所有的子孙节点

Parameters
NameTypeDescription
treeGraph

-

method BuildTree #
BuildTree(IEnumerable(Of Term))

从obo词条集合之中构建出DAG图的节点集合

Remarks

在这里会做如下的几项数据清洗工作:

  1. 跳过被标记为is_obsolete的废弃词条;
  2. 跳过重复编号的词条,避免Dictionary添加元素的时候抛出异常;
  3. 跳过在当前的词表之中不存在的父节点引用,避免产生悬空的Nothing引用;
  4. 将relationship关系也解析为节点引用,使得part_of之类的边也可以被遍历。
Parameters
NameTypeDescription
fileIEnumerable(Of Term)

-

method ConstructNode #
ConstructNode(Term)

Creates a node in this DAG graph

Parameters
NameTypeDescription
termTerm

-

method TermXrefParser #
TermXrefParser(String)
method GetTermXrefs #
GetTermXrefs(Term)