New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vsm-dictionary-ensembl

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vsm-dictionary-ensembl - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

2

package.json
{
"name": "vsm-dictionary-ensembl",
"version": "1.0.2",
"version": "1.0.3",
"description": "Implementation of a VSM-dictionary that uses the EBI search RESTful Web Services to interact with the Ensembl genome database",

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

@@ -69,4 +69,6 @@ # vsm-dictionary-ensembl

Since `vsm-dictionary-ensembl` has only one sub-dictionary
(it's a uni-dictionary!), `getDictInfos` returns a static object with properties:
If the `options.filter.id` is not properly defined
or the `https://www.ensembl.org` dictID is included in the
list of ids used for filtering, `getDictInfos` returns a static object
with the following properties:
- `id`: 'https://www.ensembl.org' (will be used as a `dictID`)

@@ -76,2 +78,4 @@ - `abbrev`: 'Ensembl'

Otherwise, an empty result is returned.
### Map Ensembl to Entry VSM object

@@ -82,2 +86,6 @@

Firstly, if the `options.filter.dictID` is properly defined and in the list of
dictIDs the `https://www.ensembl.org` dictID is not included, then
an **empty array** of entry objects is returned.
If the `options.filter.id` is properly defined (with IDs like

@@ -148,4 +156,8 @@ `https://www.ensembl.org/id/ENSG00000142208`) then we use a query like this:

An example of a URL string that is being built and send to the EBI Search's REST
API when requesting for `tp53`, is:
Firstly, if the `options.filter.dictID` is properly defined and in the list of
dictIDs the `https://www.ensembl.org` dictID is not included, then
an **empty array** of match objects is returned.
Otherwise, an example of a URL string that is being built and send to the EBI
Search's REST API when requesting for `tp53`, is:
```

@@ -152,0 +164,0 @@ https://www.ebi.ac.uk/ebisearch/ws/rest/ensembl_gene?query=tp53&fields=id%2Cname%2Cdescription%2Cgene_name%2Cgene_synonym%2Ctranscript_count%2Cspecies&size=20&start=0&format=json

@@ -32,15 +32,40 @@ const Dictionary = require('vsm-dictionary');

getDictInfos(options, cb) {
return cb(null,
{
items: [
{
id: this.ensemblDictID,
abbrev: 'Ensembl',
name: 'Ensembl'
}
]
});
let res = {
items: [
{
id: this.ensemblDictID,
abbrev: 'Ensembl',
name: 'Ensembl'
}
]
};
if (!this.hasProperFilterIDProperty(options)) {
return cb(null, res);
} else {
// keep only the domain-specific dictID(s)
let idList = options.filter.id.filter(dictID =>
dictID.trim() === this.ensemblDictID
);
if (idList.length === 0) {
return cb(null, {items: []});
} else {
return cb(null, res);
}
}
}
getEntries(options, cb) {
if (this.hasProperFilterDictIDProperty(options)) {
// keep only the domain-specific dictID(s)
let idList = options.filter.dictID.filter(dictID =>
dictID.trim() === this.ensemblDictID
);
if (idList.length === 0) {
return cb(null, { items: [] });
}
}
const url = this.prepareEntrySearchURL(options);

@@ -73,2 +98,13 @@

if (this.hasProperFilterDictIDProperty(options)) {
// keep only the domain-specific dictID(s)
let idList = options.filter.dictID.filter(dictID =>
dictID.trim() === this.ensemblDictID
);
if (idList.length === 0) {
return cb(null, { items: [] });
}
}
const url = this.prepareMatchStringSearchURL(str, options);

@@ -283,2 +319,9 @@

hasProperFilterDictIDProperty(options) {
return options.hasOwnProperty('filter')
&& options.filter.hasOwnProperty('dictID')
&& Array.isArray(options.filter.dictID)
&& options.filter.dictID.length !== 0;
}
hasProperFilterIDProperty(options) {

@@ -285,0 +328,0 @@ return options.hasOwnProperty('filter')

@@ -36,17 +36,83 @@ const DictionaryEnsembl = require('./DictionaryEnsembl');

describe('getDictInfos', () => {
it('returns proper RNAcentral dictInfo object', cb => {
it('returns empty result when the list of dictIDs does not '
+ ' include the domain\'s dictID', cb => {
dict.getDictInfos({ filter: { id: [
' ',
'https://www.uniprot.org',
'https://www.ensemblgenomes.org' ]}},
(err, res) => {
expect(err).to.equal(null);
res.should.deep.equal({ items: [] });
cb();
});
});
it('returns proper dictInfo object when `options.filter` is not properly ' +
'defined or the domain\'s dictID is in the list of specified dictIDs', cb => {
let expectedResult = { items: [
{
id: 'https://www.ensembl.org',
abbrev: 'Ensembl',
name: 'Ensembl'
}
]};
dict.getDictInfos({}, (err, res) => {
expect(err).to.be.null;
res.should.deep.equal({
items: [
{
id: 'https://www.ensembl.org',
abbrev: 'Ensembl',
name: 'Ensembl'
}
]
expect(err).to.equal(null);
res.should.deep.equal(expectedResult);
});
dict.getDictInfos({ filter: { id: [
'http://www.ensemblgenomes.org',
'https://www.ebi.ac.uk/complexportal',
'https://www.ensembl.org' ]}},
(err, res) => {
expect(err).to.equal(null);
res.should.deep.equal(expectedResult);
});
cb();
});
});
describe('getEntries', () => {
it('returns empty result when the `options.filter.dictID` is properly ' +
'defined and in the list of dictIDs the domain\'s dictID is not included', cb => {
dict.getEntries({filter: { dictID: ['']}}, (err, res) => {
expect(err).to.equal(null);
res.should.deep.equal({ items: [] });
});
dict.getEntries({filter: { dictID: [
' ',
'https://www.uniprot.org',
'http://www.ensemblgenomes.org'
]}}, (err, res) => {
expect(err).to.equal(null);
res.should.deep.equal({ items: [] });
});
cb();
});
});
describe('getEntryMatchesForString', () => {
it('returns empty result when the `options.filter.dictID` is properly ' +
'defined and in the list of dictIDs the domain\'s dictID is not included', cb => {
dict.getEntryMatchesForString(melanomaStr, {filter: { dictID: ['']}},
(err, res) => {
expect(err).to.equal(null);
res.should.deep.equal({ items: [] });
});
cb();
dict.getEntryMatchesForString(melanomaStr, {filter: { dictID: [
' ',
'https://www.uniprot.org',
'http://www.ensemblgenomes.org']}},
(err, res) => {
expect(err).to.equal(null);
res.should.deep.equal({ items: [] });
});
cb();
});

@@ -53,0 +119,0 @@ });

Sorry, the diff of this file is too big to display

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