查询本体术语的框架
项目描述
ontquery
查询本体术语的框架
安装
Ontquery支持两种不同的使用场景,每种都有相应的安装说明。
默认情况下,ontquery仅安装精简的核心库,以便可以将其嵌入并用于其他需要减少依赖的应用程序。对于此使用场景,可以将ontquery作为依赖项包含在包的要求中,无需任何特殊更改,例如 ontquery>=0.0.6
。
第二种使用场景通过插件基础设施启用远程服务。要安装此版本,您应该使用pip extras语法,例如 pip install "ontquery[services]"
。
SciCrunch API密钥
如果您没有自己的SciGraph实例,则需要SciCunch API密钥才能运行演示(例如 python __init__.py
)。
为此,请前往SciCrunch并注册账户,然后获取API密钥。
然后您可以为环境变量设置SCICRUNCH_API_KEY
。例如,在bash中 export SCICRUNCH_API_KEY=my-api-key
。
有关如何传递密钥的说明,请参阅https://github.com/tgbugs/ontquery/blob/db8cad7463704bce9010651c3744452aa5370114/ontquery/__init__.py#L557-L558。
SciGraphRemote 使用说明
from ontquery import OntQuery, OntTerm, OntCuries
from ontquery.plugins.namespaces.nifstd import CURIE_MAP
from ontquery.plugins.services.scigraph import SciGraphRemote
curies = OntCuries(CURIE_MAP)
query = OntQuery(SciGraphRemote(), instrumented=OntTerm)
OntTerm.query = query
list(query('mouse'))
显示3个潜在匹配项
Query {'term': 'mouse', 'limit': 10} returned more than one result. Please review.
OntTerm('NCBITaxon:10090', label='Mus musculus', synonyms=['mouse', 'house mouse', 'mice C57BL/6xCBA/CaJ hybrid', 'Mus muscaris'])
OntTerm('NCBITaxon:10088', label='Mus <mouse, genus>', synonyms=['mouse', 'Mus', 'mice'])
OntTerm('BIRNLEX:167', label='Mouse', synonyms=['mouse', 'Mus musculus', 'house mouse'])
我们正在寻找的是 Mus musculus
,我们可以使用 OntTerm('NCBITaxon:10090', label='Mus musculus')
或 OntTerm(curie='NCBITaxon:10090')
来选择它。
此工作流程适用于各种类别
- 物种(例如,“老鼠”,“大鼠”,“恒河猴”)
- 大脑区域(例如,“海马体”,“CA1”,“S1”)
- 细胞类型(例如,“苔藓细胞”,“锥体细胞”)
- 机构(例如,“加州大学旧金山分校”,“布朗大学”)
- 疾病(例如,“帕金森病”,“肌萎缩侧索硬化症”)
构建发布版本
python setup.py sdist --release && python setup.py bdist_wheel --universal --release
构建发布版本需要安装pyontutils,以便构建scigraph客户端库。 --release
告诉设置构建scigraph客户端。
相关问题
https://github.com/NeurodataWithoutBorders/nwb-schema/issues/1#issuecomment-368741867
https://github.com/NeurodataWithoutBorders/nwb-schema/issues/1#issuecomment-369215854
InterlexRemote 备注
ilx_id和任何接受uri值的键也可以给定该uri的curie或片段,它仍然有效。
InterLexRemote 使用说明
要程序化访问InterLex,您可以设置SCICRUNCH_API_KEY
或设置INTERLEX_API_KEY
,两种方式都有效,但如果两者都设置,则INTERLEX_API_KEY
具有优先级。
导入
from ontquery.interlex import interlex_client
针对TEST的设置
这应首先用于测试您的代码是否正常工作
ilx_cli = interlex_client('test3.scicrunch.org')
针对PRODUCTION的设置
ilx_cli = interlex_client('scicrunch.org')
需要添加实体
added_entity_data = ilx_cli.add_entity(
label = '',
type = '', # term, fde, cde, pde, relationship, annotation
)
添加实体示例
added_entity_data = ilx_cli.add_entity(
label = 'Label of entity you wish to create',
type = 'A type that should be one of the following: term, relationship, annotation, cde, fde, pde',
# subThingOf can take either iri or curie form of ID
subThingOf = 'http://uri.interlex.org/base/ilx_0108124', # superclass or subClassOf ILX ID
definition = 'Entities definition',
comment = 'A comment to help understand entity',
synonyms = ['synonym1', {'literal': 'synonym2', 'type': 'hasExactSynonym'}, 'etc'],
# exisiting IDs are List[dict] with keys iri & curie
existing_ids = [{'iri':'https://example.org/example_1', 'curie':'EXAMPLE:1'}],
cid = 504, # community ID
predicates = {
# annotation_entity_ilx_id : 'annotation_value',
'http://uri.interlex.org/base/tmp_0381624': 'PMID:12345', # annotation
# relationship_entity_ilx_id : 'entity2_ilx_id',
'http://uri.interlex.org/base/ilx_0112772': 'http://uri.interlex.org/base/ilx_0100001', # relationship
}
)
更新实体示例
updated_entity = update_entity(
ilx_id='ilx_1234567',
label='Brain',
type='term', # options: term, pde, fde, cde, annotation, or relationship
definition='Official definition for entity.',
comment='Additional casual notes for the next person.',
superclass='ilx_1234567',
add_synonyms=[{
'literal': 'Better Brains', # label of synonym
'type': 'obo:hasExactSynonym', # Often predicate defined in ref ontology.
}],
delete_synonyms=[{
'literal': 'Brains', # label of synonym
'type': 'obo:hasExactSynonym', # Often predicate defined in ref ontology.
}],
add_existing_ids=[{
'iri': 'http://purl.obolibrary.org/obo/UBERON_0000956',
'curie': 'UBERON:0000956', # Obeys prefix:id structure.
'preferred': '1', # Can be 0 or 1 with a type of either str or int.
}],
delet_existing_ids=[{
'iri': 'http://purl.obolibrary.org/obo/UBERON_0000955',
'curie': 'UBERON:0000955', # Obeys prefix:id structure.
}],
cid='504', # SPARC Community,
status='0', # remove delete
)
项目详情
下载文件
下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。