Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@biothings-explorer/annotator

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@biothings-explorer/annotator - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

37

__test__/index.test.js

@@ -77,2 +77,39 @@ const annotate = require("../src/index");

})
test("test with chemical ids", async () => {
const ids = {
"CHEBI:8863": {
"id": {
"label": "RILUZOLE",
"identifier": "CHEBI:8863"
},
"db_ids": {
"CHEBI": [
"CHEBI:8863"
],
"CHEMBL.COMPOUND": [
"CHEMBL744"
]
}
},
"CHEBI:133809": {
"id": {
"label": "ANISINDIONE",
"identifier": "CHEBI:133809"
},
"db_ids": {
"CHEBI": [
"CHEBI:133809"
],
"CHEMBL.COMPOUND": [
"CHEMBL712"
]
}
}
};
let res = await annotate("ChemicalSubstance", ids);
expect(res).toHaveProperty('CHEBI:133809');
expect(Object.keys(res).length).toBe(2);
expect(res["CHEBI:133809"]).toHaveProperty("max_phase")
})
})

2

package.json
{
"name": "@biothings-explorer/annotator",
"version": "1.0.0",
"version": "2.0.0",
"description": "A nodejs package providing batch annotating features for biomedical entities",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -25,5 +25,88 @@ [![Build Status](https://travis-ci.com/kevinxin90/annotator.js.svg?branch=master)](https://travis-ci.com/kevinxin90/annotator.js)

```javascript
const annotator = require("@biothings-explorer/annotator")
const annotate = require("@biothings-explorer/annotator")
```
- Annotate Gene IDs
```javascript
const gene_ids = {
"NCBIGene:4888": {
"db_ids": {
"NCBIGene": [
"4888"
],
"HGNC": [
"7959"
],
"SYMBOL": [
"NPY6R"
],
"UMLS": [
"C1417819"
]
}
},
"NCBIGene:4597": {
"db_ids": {
"NCBIGene": [
"4597"
],
"ENSEMBL": [
"ENSG00000167508"
],
"HGNC": [
"7529"
],
"SYMBOL": [
"MVD"
],
"UMLS": [
"C1417507"
]
}
}
}
let res = await annotate("Gene", gene_ids);
console.log(res);
// {"NCBIGene:4888": {"genomic_position": ..., "generif": ..., "biological_process": ...},"NCBIGene:4597": {"genomic_position": ..., "reactome": ..., "wikipathways": ...}}
```
- Annotate ChemicalSubstance IDs
```javascript
const chemical_ids = {
"CHEBI:8863": {
"id": {
"label": "RILUZOLE",
"identifier": "CHEBI:8863"
},
"db_ids": {
"CHEBI": [
"CHEBI:8863"
],
"CHEMBL.COMPOUND": [
"CHEMBL744"
]
}
},
"CHEBI:133809": {
"id": {
"label": "ANISINDIONE",
"identifier": "CHEBI:133809"
},
"db_ids": {
"CHEBI": [
"CHEBI:133809"
],
"CHEMBL.COMPOUND": [
"CHEMBL712"
]
}
}
};
let res = await annotate("ChemicalSubstance", chemical_ids);
console.log(res);
// {"CHEBI:133809": {"max_phase": ..., "molecular_weight": ..., "molecular_type": ...}, "CHEBI:8863": {"max_phase": ..., "enzymes": ..., "targets": ...}}
```
## Run tests

@@ -30,0 +113,0 @@

@@ -113,3 +113,3 @@ exports.APIMETA = {

"molecular_weight": {
"fields": ["chembl.molecule_properties.full_mwt, drugbank.weight.average"],
"fields": ["chembl.molecule_properties.full_mwt", "drugbank.weight.average"],
"nested": false

@@ -122,3 +122,3 @@ },

"ATC_classification": {
"fields": ["chembl.atc_classifications, drugbank.xrefs.atc_codes"],
"fields": ["chembl.atc_classifications", "drugbank.xrefs.atc_codes"],
"nested": false

@@ -177,6 +177,2 @@ },

"nested": false
},
"parent": {
"fields": ["drugbank.taxonomy.direct-parent"],
"nested": false
}

@@ -187,2 +183,6 @@ }

exports.MAX_CONCURRENT_QUERIES = 4;
exports.MAX_CONCURRENT_QUERIES = 4;
exports.CURIE = {
ALWAYS_PREFIXED: ["GO", "CHEBI", "HP", "MONDO", "DOID", "EFO", "UBERON", "MP", "CL", "MGI"]
}

@@ -47,3 +47,3 @@ const meta = require("./config");

}
inputs = Array.from(inputs).join(',');
inputs = Array.from(inputs).map(item => "'" + item + "'").join(',');
let apimeta = meta.APIMETA[this.semantic];

@@ -50,0 +50,0 @@ let fields = [];

const config = require("./config");
const _ = require('lodash');
const jp = require("jsonpath");
const { method } = require("lodash");

@@ -18,3 +19,3 @@ module.exports = class {

this.response.data.filter(rec => {
if (_.isEmpty(rec) || 'notfound' in rec) {
if (_.isEmpty(rec) || 'notfound' in rec || _.difference(Object.keys(rec), ['query', "_score", "_id"]).length === 0) {
return false

@@ -24,8 +25,20 @@ };

}).map(rec => {
curie = this.prefix + ':' + rec['query'];
result[curie] = {};
if (config.CURIE.ALWAYS_PREFIXED.includes(this.prefix)) {
curie = rec['query'];
} else {
curie = this.prefix + ':' + rec['query'];
}
if (!(curie in result)) {
result[curie] = {};
}
for (let [mapped_field, fields] of Object.entries(mapping)) {
for (let field of fields.fields) {
let path = "$." + field;
let tmp = jp.query(rec, path);
let tmp = [];
try {
tmp = jp.query(rec, path);
} catch (e) {
console.log(e)
}
if (tmp.length !== 0) {

@@ -32,0 +45,0 @@ result[curie][mapped_field] = tmp;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc