本文整理汇总了Python中ontology.Ontology.add_typedef方法的典型用法代码示例。如果您正苦于以下问题:Python Ontology.add_typedef方法的具体用法?Python Ontology.add_typedef怎么用?Python Ontology.add_typedef使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ontology.Ontology
的用法示例。
在下文中一共展示了Ontology.add_typedef方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse
# 需要导入模块: from ontology import Ontology [as 别名]
# 或者: from ontology.Ontology import add_typedef [as 别名]
def parse(oboFile, typedefs):
"""
Parses an OBO (ontology file) creating a correspoinding Ontology
object composed of Term objects that relate to the terms found in the
ontology file.
"""
ontology = Ontology()
## Use groupby to group the lines of our file into chunks of text, some
## stanzas, some typedefs, and other metadata to be processed
with open(oboFile) as f:
for (key, group) in groupby(f, is_data):
if key:
header = group.next().rstrip('\n')
if header.find('[Typedef]') != -1:
dataDict = get_data_as_dict(group)
ontology.add_typedef(dataDict['name'])
elif header.find('[Term]') != -1:
dataDict = get_data_as_dict(group, typedefs)
ontology.add_term(build_term(dataDict))
else:
# We are dealing with ontology metadata that should be
# captured in our ontology object.
ontology.metadata.append(header)
ontology.metadata.extend([x.strip() for x in group])
return ontology