forked from bionode/bionode-ncbi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(bionode#33) [Feature] Do the ncbi valid db checks at lib level
Do the db filter at lib level Add tests to valid-dbs Fix identation Istanbul should use all the test files for coverage
- Loading branch information
1 parent
840fb34
commit 9149535
Showing
5 changed files
with
147 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
|
||
var dbs = { | ||
gquery: 'All Databases', | ||
assembly: 'Assembly', | ||
bioproject: 'BioProject', | ||
biosample: 'BioSample', | ||
biosystems: 'BioSystems', | ||
books: 'Books', | ||
clinvar: 'ClinVar', | ||
clone: 'Clone', | ||
cdd: 'Conserved Domains', | ||
gap: 'dbGaP', | ||
dbvar: 'dbVar', | ||
nucest: 'EST', | ||
gene: 'Gene', | ||
genome: 'Genome', | ||
gds: 'GEO DataSets', | ||
geoprofiles: 'GEO Profiles', | ||
nucgss: 'GSS', | ||
gtr: 'GTR', | ||
homologene: 'HomoloGene', | ||
medgen: 'MedGen', | ||
mesh: 'MeSH', | ||
ncbisearch: 'NCBI Web Site', | ||
nlmcatalog: 'NLM Catalog', | ||
nuccore: 'Nucleotide', | ||
omim: 'OMIM', | ||
pmc: 'PMC', | ||
popset: 'PopSet', | ||
probe: 'Probe', | ||
protein: 'Protein', | ||
proteinclusters: 'Protein Clusters', | ||
pcassay: 'PubChem BioAssay', | ||
pccompound: 'PubChem Compound', | ||
pcsubstance: 'PubChem Substance', | ||
pubmed: 'PubMed', | ||
pubmedhealth: 'PubMed Health', | ||
snp: 'SNP', | ||
sparcle: 'Sparcle', | ||
sra: 'SRA', | ||
structure: 'Structure', | ||
taxonomy: 'Taxonomy', | ||
toolkit: 'ToolKit', | ||
toolkitall: 'ToolKitAll', | ||
toolkitbook: 'ToolKitBook', | ||
toolkitbookgh: 'ToolKitBookgh', | ||
unigene: 'UniGene' | ||
} | ||
|
||
function printDbs (dbsObject) { | ||
dbsObject = dbsObject || dbs | ||
|
||
var keys = Object.keys(dbsObject) | ||
return keys.reduce((acc, k, i) => { | ||
acc = acc + k + ' (' + dbsObject[k] + ')' | ||
if (i < keys.length - 1) { | ||
acc = acc + '\n' | ||
} | ||
return acc | ||
}, '') | ||
} | ||
|
||
function InvalidDbError (msg) { | ||
this.name = 'InvalidDbError' | ||
this.message = msg | ||
} | ||
|
||
InvalidDbError.prototype = new Error('Invalid database') | ||
|
||
module.exports.dbs = dbs | ||
module.exports.InvalidDbError = InvalidDbError | ||
module.exports.printDbs = printDbs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
var tape = require('tape') | ||
var tapeNock = require('tape-nock') | ||
var validDbs = require('../lib/valid-dbs') | ||
var ncbi = require('../lib/bionode-ncbi') | ||
|
||
var test = tapeNock(tape) | ||
|
||
test('valid-dbs printDbs', t => { | ||
var dummy = {fakedb: 'Fake!', another: 'Another'} | ||
|
||
var expected = 'fakedb (Fake!)\nanother (Another)' | ||
|
||
t.equals(validDbs.printDbs(dummy), expected, 'printDbs returns the expected string') | ||
|
||
t.end() | ||
}) | ||
|
||
// TODO move this test to a suite just for bionode-ncbi search | ||
test('bionode-ncbi search', t => { | ||
t.plan(1) | ||
|
||
try { | ||
ncbi.search('invalid', 'human') | ||
} catch (err) { | ||
t.assert(err instanceof validDbs.InvalidDbError, 'call search with wrong db throws InvalidDbError') | ||
} | ||
}) |