@abi-software/flatmapvuer 1.6.2-beta.6 → 1.6.2-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/flatmapvuer",
3
- "version": "1.6.2-beta.6",
3
+ "version": "1.6.2-beta.8",
4
4
  "license": "Apache-2.0",
5
5
  "files": [
6
6
  "dist/*",
@@ -614,7 +614,7 @@ Please use `const` to assign meaningful names to them...
614
614
  <Tooltip
615
615
  ref="tooltip"
616
616
  class="tooltip"
617
- v-show="tooltipDisplay"
617
+ v-if="tooltipDisplay"
618
618
  :annotationEntry="annotationEntry"
619
619
  :tooltipEntry="tooltipEntry"
620
620
  :annotationDisplay="viewingMode === 'Annotation'"
@@ -82,8 +82,6 @@ let FlatmapQueries = function () {
82
82
  this.origins = []
83
83
  this.components = []
84
84
  this.rawURLs = []
85
- this.pubMedURLs = []
86
- this.openLibraryURLs = []
87
85
  this.controller = undefined
88
86
  this.uberons = []
89
87
  this.lookUp = []
@@ -97,21 +95,6 @@ let FlatmapQueries = function () {
97
95
  ) {
98
96
  hyperlinks = eventData.feature.hyperlinks
99
97
  } else {
100
- // TODO: move to externalresourcecard
101
- // const pubMedHyperlinks = this.pubMedURLs.map((url) => ({
102
- // url: url.link,
103
- // dataId: url.id,
104
- // id: 'pubmed'
105
- // }))
106
- // const openLibHyperlinks = this.openLibraryURLs.map((url) => ({
107
- // url: url.link,
108
- // dataId: url.id,
109
- // id: url.type || 'openlib'
110
- // }))
111
- // hyperlinks = [
112
- // ...pubMedHyperlinks,
113
- // ...openLibHyperlinks
114
- // ];
115
98
  hyperlinks = this.rawURLs;
116
99
  }
117
100
  let taxonomyLabel = undefined
@@ -263,12 +246,9 @@ let FlatmapQueries = function () {
263
246
  this.origins = []
264
247
  this.components = []
265
248
  this.rawURLs = []
266
- this.pubMedURLs = []
267
- this.openLibraryURLs = []
268
249
  if (!keastIds || keastIds.length == 0 || !keastIds[0]) return
269
250
 
270
251
  let prom1 = this.queryForConnectivityNew(mapImp, keastIds, signal) // This on returns a promise so dont need 'await'
271
- // let prom2 = await this.pubmedQueryOnIds(eventData)
272
252
  let results = await Promise.all([prom1])
273
253
  return results
274
254
  }
@@ -286,15 +266,6 @@ let FlatmapQueries = function () {
286
266
  // with publications from both PubMed and Others
287
267
  this.rawURLs = [...response.references];
288
268
  resolve(processedConnectivity)
289
- // TODO: move to externalResourceCard
290
- // Promise.all([
291
- // this.getOpenLibraryURLs(response.references),
292
- // this.getURLsForPubMed(response.references)
293
- // ]).then((urls) => {
294
- // this.openLibraryURLs = urls[0];
295
- // this.pubMedURLs = urls[1];
296
- // resolve(processedConnectivity)
297
- // })
298
269
  } else {
299
270
  // without publications
300
271
  resolve(processedConnectivity)
@@ -492,207 +463,6 @@ let FlatmapQueries = function () {
492
463
  return found.flat()
493
464
  }
494
465
 
495
- this.stripPMIDPrefix = function (pubmedId) {
496
- return pubmedId.split(':')[1]
497
- }
498
-
499
- this.getPMID = function(idsList) {
500
- return new Promise((resolve) => {
501
- if (idsList.length > 0) {
502
- //Muliple term search does not work well,
503
- //DOIs term get splitted unexpectedly
504
- //
505
- const promises = []
506
- const results = []
507
- let wrapped = ''
508
- idsList.forEach((id, i) => {
509
- wrapped += i > 0 ? 'OR"' + id + '"' : '"' + id + '"'
510
- })
511
-
512
- const params = new URLSearchParams({
513
- db: 'pubmed',
514
- term: wrapped,
515
- format: 'json'
516
- })
517
- const promise = fetch(`https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?${params}`, {
518
- method: 'GET',
519
- })
520
- .then((response) => response.json())
521
- .then((data) => {
522
- const newIds = data.esearchresult ? data.esearchresult.idlist : []
523
- results.push(...newIds)
524
- })
525
- promises.push(promise)
526
-
527
- Promise.all(promises).then(() => {
528
- resolve(results)
529
- }).catch(() => {
530
- resolve(results)
531
- })
532
- } else {
533
- resolve([])
534
- }
535
- })
536
- }
537
-
538
- this.convertPublicationIds = function (ids) {
539
- return new Promise((resolve) => {
540
- const pmids = []
541
- const toBeConverted = []
542
- ids.forEach((id) => {
543
- if (id.type === "pmid") {
544
- pmids.push(id.id)
545
- } else if (id.type === "doi" || id.type === "pmc") {
546
- toBeConverted.push(id.id)
547
- }
548
- })
549
- this.getPMID(toBeConverted).then((idList) => {
550
- pmids.push(...idList)
551
- resolve(pmids)
552
- })
553
- .catch(() => {
554
- resolve(pmids)
555
- })
556
- })
557
- }
558
-
559
- this.getPubMedDomains = function () {
560
- const names = [
561
- 'doi.org/',
562
- 'nih.gov/pubmed/',
563
- 'pmc/articles/',
564
- 'pubmed.ncbi.nlm.nih.gov/',
565
- ]
566
-
567
- return names;
568
- }
569
-
570
- this.extractPublicationIdFromURLString = function (urlStr) {
571
- if (!urlStr) return
572
-
573
- const str = decodeURIComponent(urlStr)
574
-
575
- let term = {id: '', type: ''}
576
-
577
- const names = this.getPubMedDomains()
578
-
579
- names.forEach((name) => {
580
- const lastIndex = str.lastIndexOf(name)
581
- if (lastIndex !== -1) {
582
- term.id = str.slice(lastIndex + name.length)
583
- if (name === 'doi.org/') {
584
- term.type = "doi"
585
- } else if (name === 'pmc/articles/') {
586
- term.type = "pmc"
587
- } else {
588
- term.type = "pmid"
589
- }
590
- }
591
- })
592
-
593
- //Backward compatability with doi: and PMID:
594
- if (term.id === '') {
595
- if (urlStr.includes("doi:")) {
596
- term.id = this.stripPMIDPrefix(urlStr)
597
- term.type = "doi"
598
- } else if (urlStr.includes("PMID:")) {
599
- term.id = this.stripPMIDPrefix(urlStr)
600
- term.type = "pmid"
601
- }
602
- }
603
-
604
- if (term.id.endsWith('/')) {
605
- term.id = term.id.slice(0, -1)
606
- }
607
-
608
- return term
609
- }
610
-
611
- this.extractNonPubMedURLs = function (urls) {
612
- const extractedURLs = [];
613
- const names = this.getPubMedDomains();
614
-
615
- urls.forEach((url) => {
616
- let count = 0;
617
- names.forEach((name) => {
618
- if (url.includes(name)) {
619
- count++;
620
- }
621
- });
622
- if (!count) {
623
- extractedURLs.push(url);
624
- }
625
- });
626
-
627
- return extractedURLs;
628
- }
629
-
630
- this.getOpenLibraryURLs = async function (urls) {
631
- const transformedURLs = [];
632
- const nonPubMedURLs = this.extractNonPubMedURLs(urls);
633
- const openLibraryURLs = nonPubMedURLs.filter((url) => url.indexOf('isbn') !== -1);
634
-
635
- const isbnIDs = openLibraryURLs.map((url) => {
636
- const isbnId = url.split('/').pop();
637
- return 'ISBN:' + isbnId;
638
- });
639
- const isbnIDsKey = isbnIDs.join(',');
640
- const failedIDs = isbnIDs.slice();
641
-
642
- const openlibAPI = `https://openlibrary.org/api/books?bibkeys=${isbnIDsKey}&format=json`;
643
- const response = await fetch(openlibAPI);
644
- const data = await response.json();
645
-
646
- for (const key in data) {
647
- const successKeyIndex = failedIDs.indexOf(key);
648
- failedIDs.splice(successKeyIndex, 1);
649
-
650
- transformedURLs.push({
651
- id: key.split(':')[1], // Key => "ISBN:1234"
652
- link: data[key].info_url,
653
- });
654
- }
655
-
656
- failedIDs.forEach((failedID) => {
657
- const id = failedID.split(':')[1];
658
- // TODO: to replace ISBN DB ?
659
- // Data does not exist in OpenLibrary
660
- // Provide ISBN DB link
661
- const link = `https://isbndb.com/book/${id}`;
662
- transformedURLs.push({
663
- id: id,
664
- link: link,
665
- type: 'isbndb'
666
- });
667
- });
668
-
669
- return transformedURLs;
670
- }
671
-
672
- this.getURLsForPubMed = function (data) {
673
- return new Promise((resolve) => {
674
- const ids = data.map((id) =>
675
- (typeof id === 'object') ?
676
- this.extractPublicationIdFromURLString(id[0]) :
677
- this.extractPublicationIdFromURLString(id)
678
- )
679
- this.convertPublicationIds(ids).then((pmids) => {
680
- if (pmids.length > 0) {
681
- const transformedIDs = [];
682
- pmids.forEach(pmid => {
683
- transformedIDs.push({
684
- id: pmid,
685
- link: this.pubmedSearchUrl(pmid),
686
- })
687
- })
688
- resolve(transformedIDs)
689
- } else {
690
- resolve([])
691
- }
692
- })
693
- })
694
- }
695
-
696
466
  this.buildPubmedSqlStatement = function (keastIds) {
697
467
  let sql = 'select distinct publication from publications where entity in ('
698
468
  if (keastIds.length === 1) {
@@ -723,64 +493,6 @@ let FlatmapQueries = function () {
723
493
  console.error('Error:', error)
724
494
  })
725
495
  }
726
- // Note that this functin WILL run to the end, as it doesn not catch the second level of promises
727
- this.pubmedQueryOnIds = function (eventData) {
728
- return new Promise((resolve) => {
729
- const keastIds = eventData.resource
730
- const source = eventData.feature.source
731
- if (!keastIds || keastIds.length === 0) return
732
- const sql = this.buildPubmedSqlStatement(keastIds)
733
- this.flatmapQuery(sql).then((data) => {
734
- // Create pubmed url on paths if we have them
735
- if (data.values.length > 0) {
736
- this.getURLsForPubMed(data.values).then((urls) => {
737
- this.pubMedURLs = urls
738
- if (urls.length) {
739
- resolve(true)
740
- } else {
741
- resolve(false)
742
- }
743
- })
744
- .catch(() => {
745
- this.pubMedURLs = []
746
- resolve(false)
747
- })
748
- } else {
749
- // Create pubmed url on models
750
- this.pubmedQueryOnModels(source).then((result) => {
751
- resolve(result)
752
- })
753
- }
754
- })
755
- })
756
- }
757
-
758
- this.pubmedQueryOnModels = function (source) {
759
- return this.flatmapQuery(
760
- this.buildPubmedSqlStatementForModels(source)
761
- ).then((data) => {
762
- if (Array.isArray(data.values) && data.values.length > 0) {
763
- this.getURLsForPubMed(data.values).then((urls) => {
764
- this.pubMedURLs = urls
765
- return true
766
- })
767
- .catch(() => {
768
- this.pubMedURLs = []
769
- return false
770
- })
771
- } else {
772
- this.pubMedURLs = [] // Clears the pubmed search button
773
- }
774
- return false
775
- })
776
- }
777
-
778
- this.pubmedSearchUrl = function (ids) {
779
- let url = 'https://pubmed.ncbi.nlm.nih.gov/?'
780
- let params = new URLSearchParams()
781
- params.append('term', ids)
782
- return url + params.toString()
783
- }
784
496
  }
785
497
 
786
498
  export { FlatmapQueries, findTaxonomyLabel, findTaxonomyLabels }