本文整理匯總了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