smartapi-kg DEMO

node v14.20.1
version: 2.0.0
endpointsharetweet
Initialize a new Meta Knowledge Graph object
const kg = require("@biothings-explorer/smartapi-kg")
let meta_kg = new kg()
Construct a meta knowledge graph through fetching SmartAPI Specs from SmartAPI API. when specify "source='remote'", the package will query: "https://smart-api.info/api/query?q=tags.name:translator&size=100" and retrieve all SmartAPI specs with translator tag. The SmartAPI Specs will then be loaded into meta_kg.
await meta_kg.constructMetaKG()
You can filter the meta_kg based on a specific field in "association". Available fields to be quried includes: input_id, api_name, input_type, output_type, output_id, source. The query below returns all meta-kg operations having "input_type" as "Disease".
let res = meta_kg.filter({input_type: "Disease"}); res;
List unique output types corresponding to "Disease" as input_type
new Set(res.map(item => item.association.output_type));
List all unique predicates corresponding to input_type as "Disease"
new Set(res.map(item => item.association.predicate));
You can also query on multiple fields. The query below returns all meta-kg operations having "predicate" as "treats" and using "CHEMBL.COMPOUND" as its "input_id".
meta_kg.filter({predicate: 'treats', input_id: 'CHEMBL.COMPOUND'})
The field value could also be a list. The query below returns all meta-kg operations having "predicate" as EITHER "treats" OR "physically_interacts_with" and using "CHEMBL.COMPOUND" as its "input_id".
meta_kg.filter({predicate: ['treats', 'physically_interacts_with'], input_id: 'CHEMBL.COMPOUND'})
Loading…

no comments

    sign in to comment