diff --git a/src/js/services/services.js b/src/js/services/services.js index 61159ef0..0cba7a64 100644 --- a/src/js/services/services.js +++ b/src/js/services/services.js @@ -1,4 +1,4 @@ -import {d3, hasGenBankAssembly} from '../lib'; +import {d3} from '../lib'; import { esearch, esummary, elink, getAssemblySearchUrl } from './eutils-config.js'; @@ -11,41 +11,31 @@ function getNuccoreLink(asmUid, ideo) { // Get a list of IDs for the chromosomes in this genome. // - // If assembly is GenBank-only or if a GenBank assembly was explicitly - // requested (GCA_), then query chromosomes sequences in Nucleotide DB via - // INSDC link. (GenBank is the American INSDC repository.) - // Otherwise, query RefSeq chromosomes in Nucleotide DB. - if (hasGenBankAssembly(ideo)) { - // TODO: account for GenBank-only - qs = '&db=nuccore&linkname=assembly_nuccore_insdc&from_uid=' + asmUid; - return ideo.elink + qs; - } else { - qs = ('&db=nuccore&dbfrom=assembly&linkname=assembly_nuccore_refseq&' + - 'cmd=neighbor_history&from_uid=' + asmUid); - return d3.json(ideo.elink + qs) - .then(function(data) { - var webenv = data.linksets[0].webenv; - qs = - '&db=nuccore' + - '&term=%231+AND+%28' + - 'sequence_from_chromosome[Properties]+OR+' + - 'sequence_from_plastid[Properties]+OR+' + - 'sequence_from_mitochondrion[Properties]%29' + - '&WebEnv=' + webenv + '&usehistory=y&retmax=1000'; - return ideo.esearch + qs; - }); - } + // Query chromosomes sequences in Nucleotide DB (nuccore) via + // Assembly DB E-Utils link. + qs = ('&db=nuccore&dbfrom=assembly&linkname=assembly_nuccore&' + + 'cmd=neighbor_history&from_uid=' + asmUid); + + return d3.json(ideo.elink + qs) + .then(function(data) { + var webenv = data.linksets[0].webenv; + qs = + '&db=nuccore' + + '&term=%231+AND+%28' + + 'sequence_from_chromosome[Properties]+OR+' + + 'sequence_from_plastid[Properties]+OR+' + + 'sequence_from_mitochondrion[Properties]%29' + + '&WebEnv=' + webenv + '&usehistory=y&retmax=1000'; + return ideo.esearch + qs; + }); } function fetchNucleotideSummary(data, ideo) { - var links, ntSummary; + var ids, ntSummary; - if ('esearchresult' in data) { - links = data.esearchresult.idlist.join(','); - } else { - links = data.linksets[0].linksetdbs[0].links.join(','); - } - ntSummary = ideo.esummary + '&db=nucleotide&id=' + links; + ids = data.esearchresult.idlist.join(','); + + ntSummary = ideo.esummary + '&db=nucleotide&id=' + ids; return d3.json(ntSummary); } diff --git a/test/web-test.js b/test/web-test.js index 61697701..a580299a 100644 --- a/test/web-test.js +++ b/test/web-test.js @@ -1,3 +1,4 @@ +/* eslint-disable no-new */ /* eslint-disable spaced-comment */ /* eslint-disable no-use-before-define */ /* eslint-disable no-unused-vars */ @@ -1570,23 +1571,23 @@ describe('Ideogram', function() { // These tests fail due to an upstream breaking change in NCBI E-Utils. // Specifically, the Entrez GenColl database was retired without notice. // - // it('should support GenBank accessions in "assembly" parameter', function(done) { - // // Tests use case for non-default assemblies. - // // GCA_000002125.2 is commonly called HuRef - // // https://www.ncbi.nlm.nih.gov/assembly/GCA_000002125.2 + it('should support GenBank accessions in "assembly" parameter', function(done) { + // Tests use case for non-default assemblies. + // GCA_000002125.2 is commonly called HuRef + // https://www.ncbi.nlm.nih.gov/assembly/GCA_000002125.2 - // function callback() { - // var chr1Length = ideogram.chromosomes['9606']['1'].length; - // // For reference, see length section of LOCUS field in GenBank record at - // // https://www.ncbi.nlm.nih.gov/nuccore/CM001609.2 - // assert.equal(chr1Length, 219475005); - // done(); - // } + function callback() { + var chr1Length = ideogram.chromosomes['9606']['1'].length; + // For reference, see length section of LOCUS field in GenBank record at + // https://www.ncbi.nlm.nih.gov/nuccore/CM001609.2 + assert.equal(chr1Length, 219475005); + done(); + } - // config.assembly = 'GCA_000002125.2'; - // config.onLoad = callback; - // var ideogram = new Ideogram(config); - // }); + config.assembly = 'GCA_000002125.2'; + config.onLoad = callback; + var ideogram = new Ideogram(config); + }); // it('should recover chromosomes when given scaffolds', function(done) { // // Tests use case from ../examples/vanilla/human.html @@ -1627,10 +1628,9 @@ describe('Ideogram', function() { // var numHumanChromosomes = 24; // (22,X,Y) // var numChromosomes = ideo.chromosomesArray.length; - // if(numTimesOnLoadHasBeenCalled === 1) { + // if (numTimesOnLoadHasBeenCalled === 1) { // assert.equal(numChromosomes, numChimpChromosomes); - // } - // else if(numTimesOnLoadHasBeenCalled === 2) { + // } else if (numTimesOnLoadHasBeenCalled === 2) { // assert.equal(numChromosomes, numHumanChromosomes); // done(); // }