igv 2.12.4 → 2.12.5

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/README.md CHANGED
@@ -12,19 +12,19 @@ Below are examples and a quickstart guide. See the [Wiki](https://github.com/ig
12
12
 
13
13
  # Examples
14
14
 
15
- ***[Alignments](https://igv.org/web/release/2.12.4/examples/cram-vcf.html)***
15
+ ***[Alignments](https://igv.org/web/release/2.12.5/examples/cram-vcf.html)***
16
16
 
17
- ***[Interactions](https://igv.org/web/release/2.12.4/examples/interact.html)***
17
+ ***[Interactions](https://igv.org/web/release/2.12.5/examples/interact.html)***
18
18
 
19
- ***[Copy number](https://igv.org/web/release/2.12.4/examples/copyNumber.html)***
19
+ ***[Copy number](https://igv.org/web/release/2.12.5/examples/copyNumber.html)***
20
20
 
21
- ***[Multiple regions](https://igv.org/web/release/2.12.4/examples/multi-locus.html)***
21
+ ***[Multiple regions](https://igv.org/web/release/2.12.5/examples/multi-locus.html)***
22
22
 
23
- ***[Mutation Annotation Format (MAF)](https://igv.org/web/release/2.12.4/examples/maf-tcga.html)***
23
+ ***[Mutation Annotation Format (MAF)](https://igv.org/web/release/2.12.5/examples/maf-tcga.html)***
24
24
 
25
- ***[Variant color options](https://igv.org/web/release/2.12.4/examples/variant-colors.html)***
25
+ ***[Variant color options](https://igv.org/web/release/2.12.5/examples/variant-colors.html)***
26
26
 
27
- ***[More](https://igv.org/web/release/2.12.4/examples/)***
27
+ ***[More](https://igv.org/web/release/2.12.5/examples/)***
28
28
 
29
29
 
30
30
  # Quickstart
@@ -33,18 +33,18 @@ Below are examples and a quickstart guide. See the [Wiki](https://github.com/ig
33
33
  igv.js consists of a single javascript file with no external dependencies.
34
34
 
35
35
  Pre-built files for ES5 (igv.min.js) and ES6 (igv.esm.min.js)
36
- can be downloaded from [https://cdn.jsdelivr.net/npm/igv@2.12.4/dist/](https://cdn.jsdelivr.net/npm/igv@2.12.4/dist/).
36
+ can be downloaded from [https://cdn.jsdelivr.net/npm/igv@2.12.5/dist/](https://cdn.jsdelivr.net/npm/igv@2.12.5/dist/).
37
37
 
38
38
  To import igv as an ES6 module
39
39
 
40
40
  ```javascript
41
- import igv from "https://cdn.jsdelivr.net/npm/igv@2.12.4/dist/igv.esm.min.js"
41
+ import igv from "https://cdn.jsdelivr.net/npm/igv@2.12.5/dist/igv.esm.min.js"
42
42
  ```
43
43
 
44
44
  Or as a script include (defines the "igv" global)
45
45
 
46
46
  ```html
47
- <script src="https://cdn.jsdelivr.net/npm/igv@2.12.4/dist/igv.min.js"></script>
47
+ <script src="https://cdn.jsdelivr.net/npm/igv@2.12.5/dist/igv.min.js"></script>
48
48
  ```
49
49
 
50
50
  Alternatively you can install with npm
package/dist/igv.esm.js CHANGED
@@ -16468,8 +16468,12 @@ const IGVColor = {
16468
16468
 
16469
16469
  let dragData$1; // Its assumed we are only dragging one element at a time.
16470
16470
 
16471
+ let bbox = undefined;
16471
16472
 
16472
- function makeDraggable$1(target, handle) {
16473
+ function makeDraggable$1(target, handle, constraint) {
16474
+ if (constraint) {
16475
+ bbox = Object.assign({}, constraint);
16476
+ }
16473
16477
  handle.addEventListener('mousedown', dragStart$1.bind(target));
16474
16478
  }
16475
16479
 
@@ -16512,8 +16516,13 @@ function drag$1(event) {
16512
16516
  event.preventDefault();
16513
16517
  const dx = event.screenX - dragData$1.screenX;
16514
16518
  const dy = event.screenY - dragData$1.screenY;
16515
- this.style.left = `${dragData$1.left + dx}px`;
16516
- this.style.top = `${dragData$1.top + dy}px`;
16519
+
16520
+ // const left = bbox ? Math.max(bbox.minX, dragData.left + dx) : dragData.left + dx
16521
+ const left = dragData$1.left + dx;
16522
+ const top = bbox ? Math.max(bbox.minY, dragData$1.top + dy) : dragData$1.top + dy;
16523
+
16524
+ this.style.left = `${ left }px`;
16525
+ this.style.top = `${ top }px`;
16517
16526
  }
16518
16527
 
16519
16528
  function dragEnd$1(event) {
@@ -16801,9 +16810,9 @@ const igvxhr = {
16801
16810
  options.responseType = "arraybuffer";
16802
16811
  }
16803
16812
  if (isFile(url)) {
16804
- return loadFileSlice(url, options);
16813
+ return loadFileSlice(url, options)
16805
16814
  } else {
16806
- return load(url, options);
16815
+ return load(url, options)
16807
16816
  }
16808
16817
  },
16809
16818
 
@@ -16815,18 +16824,18 @@ const igvxhr = {
16815
16824
  }
16816
16825
  const result = await this.loadString(url, options);
16817
16826
  if (result) {
16818
- return JSON.parse(result);
16827
+ return JSON.parse(result)
16819
16828
  } else {
16820
- return result;
16829
+ return result
16821
16830
  }
16822
16831
  },
16823
16832
 
16824
16833
  loadString: async function (path, options) {
16825
16834
  options = options || {};
16826
16835
  if (path instanceof File) {
16827
- return loadStringFromFile(path, options);
16836
+ return loadStringFromFile(path, options)
16828
16837
  } else {
16829
- return loadStringFromUrl(path, options);
16838
+ return loadStringFromUrl(path, options)
16830
16839
  }
16831
16840
  }
16832
16841
  };
@@ -16840,15 +16849,15 @@ async function load(url, options) {
16840
16849
  url = await (typeof url === 'function' ? url() : url);
16841
16850
 
16842
16851
  if (isFile(url)) {
16843
- return loadFileSlice(url, options);
16852
+ return loadFileSlice(url, options)
16844
16853
  } else if (typeof url.startsWith === 'function') { // Test for string
16845
16854
  if (url.startsWith("data:")) {
16846
16855
  const buffer = decodeDataURI$1(url).buffer;
16847
- if(options.range) {
16856
+ if (options.range) {
16848
16857
  const rangeEnd = options.range.size ? options.range.start + options.range.size : buffer.byteLength;
16849
- return buffer.slice(options.range.start, rangeEnd);
16858
+ return buffer.slice(options.range.start, rangeEnd)
16850
16859
  } else {
16851
- return buffer;
16860
+ return buffer
16852
16861
  }
16853
16862
  } else {
16854
16863
  if (url.startsWith("https://drive.google.com")) {
@@ -16859,11 +16868,11 @@ async function load(url, options) {
16859
16868
  return loadURL(url, options)
16860
16869
  })
16861
16870
  } else {
16862
- return loadURL(url, options);
16871
+ return loadURL(url, options)
16863
16872
  }
16864
16873
  }
16865
16874
  } else {
16866
- throw Error(`url must be either a 'File', 'string', 'function', or 'Promise'. Actual type: ${urlType}`);
16875
+ throw Error(`url must be either a 'File', 'string', 'function', or 'Promise'. Actual type: ${urlType}`)
16867
16876
  }
16868
16877
  }
16869
16878
 
@@ -16882,7 +16891,7 @@ async function loadURL(url, options) {
16882
16891
  return new Promise(function (resolve, reject) {
16883
16892
 
16884
16893
  // Various Google tansformations
16885
- if (isGoogleURL(url)) {
16894
+ if (isGoogleURL(url) && !isGoogleStorageSigned(url)) {
16886
16895
  if (isGoogleStorageURL(url)) {
16887
16896
  url = translateGoogleCloudURL(url);
16888
16897
  }
@@ -16906,7 +16915,7 @@ async function loadURL(url, options) {
16906
16915
  const isChrome = navigator.userAgent.indexOf('Chrome') > -1;
16907
16916
  navigator.vendor.indexOf("Apple") === 0 && /\sSafari\//.test(navigator.userAgent);
16908
16917
 
16909
- if (range && isChrome && !isAmazonV4Signed(url)) {
16918
+ if (range && isChrome && !isAmazonV4Signed(url) && !isGoogleStorageSigned(url)) {
16910
16919
  // Hack to prevent caching for byte-ranges. Attempt to fix net:err-cache errors in Chrome
16911
16920
  url += url.includes("?") ? "&" : "?";
16912
16921
  url += "someRandomSeed=" + Math.random().toString(36);
@@ -17011,7 +17020,7 @@ async function loadURL(url, options) {
17011
17020
  if (reject) {
17012
17021
  reject(error);
17013
17022
  } else {
17014
- throw error;
17023
+ throw error
17015
17024
  }
17016
17025
  }
17017
17026
 
@@ -17043,60 +17052,38 @@ async function loadFileSlice(localfile, options) {
17043
17052
  localfile.slice(options.range.start, options.range.start + options.range.size) :
17044
17053
  localfile;
17045
17054
 
17055
+ const arrayBuffer = await blob.arrayBuffer();
17056
+
17046
17057
  if ("arraybuffer" === options.responseType) {
17047
- return blobToArrayBuffer(blob);
17058
+ return arrayBuffer
17048
17059
  } else {
17049
- // binary string format, shouldn't be used anymore
17050
- return new Promise(function (resolve, reject) {
17051
- const fileReader = new FileReader();
17052
- fileReader.onload = function (e) {
17053
- resolve(fileReader.result);
17054
- };
17055
- fileReader.onerror = function (e) {
17056
- console.error("reject uploading local file " + localfile.name);
17057
- reject(null, fileReader);
17058
- };
17059
- fileReader.readAsBinaryString(blob);
17060
- console.warn("Deprecated method used: readAsBinaryString");
17061
- })
17060
+ return arrayBufferToString(arrayBuffer)
17062
17061
  }
17063
17062
  }
17064
17063
 
17065
17064
  async function loadStringFromFile(localfile, options) {
17066
17065
 
17067
17066
  const blob = options.range ? localfile.slice(options.range.start, options.range.start + options.range.size) : localfile;
17068
- const arrayBuffer = await blobToArrayBuffer(blob);
17069
- return arrayBufferToString(arrayBuffer);
17067
+ const arrayBuffer = await blob.arrayBuffer();
17068
+ return arrayBufferToString(arrayBuffer)
17070
17069
  }
17071
17070
 
17072
- async function blobToArrayBuffer(blob) {
17073
- if (typeof blob.arrayBuffer === 'function') {
17074
- return blob.arrayBuffer();
17075
- }
17076
- return new Promise(function (resolve, reject) {
17077
- const fileReader = new FileReader();
17078
- fileReader.onload = function (e) {
17079
- resolve(fileReader.result);
17080
- };
17081
- fileReader.onerror = function (e) {
17082
- console.error("reject uploading local file " + localfile.name);
17083
- reject(null, fileReader);
17084
- };
17085
- fileReader.readAsArrayBuffer(blob);
17086
- })
17087
- }
17088
17071
 
17089
17072
  async function loadStringFromUrl(url, options) {
17090
17073
 
17091
17074
  options = options || {};
17092
17075
  options.responseType = "arraybuffer";
17093
17076
  const data = await igvxhr.load(url, options);
17094
- return arrayBufferToString(data);
17077
+ return arrayBufferToString(data)
17095
17078
  }
17096
17079
 
17097
17080
 
17098
17081
  function isAmazonV4Signed(url) {
17099
- return url.indexOf("X-Amz-Signature") > -1;
17082
+ return url.indexOf("X-Amz-Signature") > -1
17083
+ }
17084
+
17085
+ function isGoogleStorageSigned(url) {
17086
+ return url.indexOf("X-Goog-Signature") > -1
17100
17087
  }
17101
17088
 
17102
17089
  function getOauthToken(url) {
@@ -17107,11 +17094,11 @@ function getOauthToken(url) {
17107
17094
  parseUri(url).host;
17108
17095
  let token = oauth.getToken(host);
17109
17096
  if (token) {
17110
- return token;
17097
+ return token
17111
17098
  } else if (host === undefined) {
17112
17099
  const googleToken = getCurrentGoogleAccessToken();
17113
17100
  if (googleToken && googleToken.expires_at > Date.now()) {
17114
- return googleToken.access_token;
17101
+ return googleToken.access_token
17115
17102
  }
17116
17103
  }
17117
17104
  }
@@ -17127,7 +17114,7 @@ async function fetchGoogleAccessToken(url) {
17127
17114
  if (isInitialized()) {
17128
17115
  const scope = getScopeForURL(url);
17129
17116
  const googleToken = await getAccessToken(scope);
17130
- return googleToken ? googleToken.access_token : undefined;
17117
+ return googleToken ? googleToken.access_token : undefined
17131
17118
  } else {
17132
17119
  throw Error(
17133
17120
  `Authorization is required, but Google oAuth has not been initalized. Contact your site administrator for assistance.`)
@@ -17141,9 +17128,9 @@ async function fetchGoogleAccessToken(url) {
17141
17128
  function getCurrentGoogleAccessToken() {
17142
17129
  if (isInitialized()) {
17143
17130
  const googleToken = getCurrentAccessToken();
17144
- return googleToken ? googleToken.access_token : undefined;
17131
+ return googleToken ? googleToken.access_token : undefined
17145
17132
  } else {
17146
- return undefined;
17133
+ return undefined
17147
17134
  }
17148
17135
  }
17149
17136
 
@@ -17152,7 +17139,7 @@ function addOauthHeaders(headers, acToken) {
17152
17139
  headers["Cache-Control"] = "no-cache";
17153
17140
  headers["Authorization"] = "Bearer " + acToken;
17154
17141
  }
17155
- return headers;
17142
+ return headers
17156
17143
  }
17157
17144
 
17158
17145
 
@@ -17165,12 +17152,12 @@ function addApiKey(url) {
17165
17152
  const paramSeparator = url.includes("?") ? "&" : "?";
17166
17153
  url = url + paramSeparator + "key=" + apiKey;
17167
17154
  }
17168
- return url;
17155
+ return url
17169
17156
  }
17170
17157
 
17171
17158
  function addTeamDrive(url) {
17172
17159
  if (url.includes("supportsTeamDrive")) {
17173
- return url;
17160
+ return url
17174
17161
  } else {
17175
17162
  const paramSeparator = url.includes("?") ? "&" : "?";
17176
17163
  url = url + paramSeparator + "supportsTeamDrive=true";
@@ -17184,17 +17171,17 @@ function addTeamDrive(url) {
17184
17171
  function mapUrl(url) {
17185
17172
 
17186
17173
  if (url.includes("//www.dropbox.com")) {
17187
- return url.replace("//www.dropbox.com", "//dl.dropboxusercontent.com");
17174
+ return url.replace("//www.dropbox.com", "//dl.dropboxusercontent.com")
17188
17175
  } else if (url.includes("//drive.google.com")) {
17189
- return driveDownloadURL(url);
17176
+ return driveDownloadURL(url)
17190
17177
  } else if (url.includes("//www.broadinstitute.org/igvdata")) {
17191
- return url.replace("//www.broadinstitute.org/igvdata", "//data.broadinstitute.org/igvdata");
17178
+ return url.replace("//www.broadinstitute.org/igvdata", "//data.broadinstitute.org/igvdata")
17192
17179
  } else if (url.includes("//igvdata.broadinstitute.org")) {
17193
17180
  return url.replace("//igvdata.broadinstitute.org", "https://dn7ywbm9isq8j.cloudfront.net")
17194
17181
  } else if (url.startsWith("ftp://ftp.ncbi.nlm.nih.gov/geo")) {
17195
17182
  return url.replace("ftp://", "https://")
17196
17183
  } else {
17197
- return url;
17184
+ return url
17198
17185
  }
17199
17186
  }
17200
17187
 
@@ -17209,9 +17196,9 @@ function arrayBufferToString(arraybuffer) {
17209
17196
  }
17210
17197
 
17211
17198
  if ('TextDecoder' in getGlobalObject()) {
17212
- return new TextDecoder().decode(plain);
17199
+ return new TextDecoder().decode(plain)
17213
17200
  } else {
17214
- return decodeUTF8(plain);
17201
+ return decodeUTF8(plain)
17215
17202
  }
17216
17203
  }
17217
17204
 
@@ -17263,12 +17250,12 @@ function decodeUTF8(octets) {
17263
17250
 
17264
17251
  function getGlobalObject() {
17265
17252
  if (typeof self !== 'undefined') {
17266
- return self;
17253
+ return self
17267
17254
  }
17268
17255
  if (typeof global !== 'undefined') {
17269
- return global;
17256
+ return global
17270
17257
  } else {
17271
- return window;
17258
+ return window
17272
17259
  }
17273
17260
  }
17274
17261
 
@@ -22814,7 +22801,7 @@ const Cytoband = function (start, end, name, typestain) {
22814
22801
  }
22815
22802
  };
22816
22803
 
22817
- const _version = "2.12.4";
22804
+ const _version = "2.12.5";
22818
22805
  function version() {
22819
22806
  return _version
22820
22807
  }
@@ -29053,8 +29040,12 @@ class BamSource {
29053
29040
  */
29054
29041
 
29055
29042
  const fixColor = (colorString) => {
29056
- return (colorString.indexOf(",") > 0 && !colorString.startsWith("rgb")) ?
29057
- `rgb(${colorString})` : colorString
29043
+ if(isString$3(colorString)) {
29044
+ return (colorString.indexOf(",") > 0 && !colorString.startsWith("rgb(")) ?
29045
+ `rgb(${colorString})` : colorString
29046
+ } else {
29047
+ return colorString;
29048
+ }
29058
29049
  };
29059
29050
 
29060
29051
  /**
@@ -44545,6 +44536,8 @@ const isString = isString$3;
44545
44536
 
44546
44537
  const DEFAULT_VISIBILITY_WINDOW = 1000000;
44547
44538
  const TOP_MARGIN = 10;
44539
+ const STANDARD_FIELDS = new Map([["REF", "referenceBases"], ["ALT", "alternateBases"], ["QUAL", "quality"], ["FILTER", "filter"]]);
44540
+
44548
44541
 
44549
44542
  class VariantTrack extends TrackBase {
44550
44543
 
@@ -44586,7 +44579,6 @@ class VariantTrack extends TrackBase {
44586
44579
  this.colorTables = new Map();
44587
44580
  this.colorTables.set(config.colorBy, new ColorTable(config.colorTable));
44588
44581
  }
44589
- this._color = config.color;
44590
44582
 
44591
44583
  this.showGenotypes = config.showGenotypes === undefined ? true : config.showGenotypes;
44592
44584
 
@@ -44797,14 +44789,21 @@ class VariantTrack extends TrackBase {
44797
44789
  let variantColor;
44798
44790
 
44799
44791
  if (this.colorBy) {
44800
- const value = v.info[this.colorBy];
44801
- variantColor = this.getVariantColorTable(this.colorBy).getColor(value);
44792
+ const colorBy = this.colorBy;
44793
+ let value;
44794
+ if (v.info.hasOwnProperty(colorBy)) {
44795
+ value = v.info[colorBy];
44796
+ } else if (STANDARD_FIELDS.has(colorBy)) {
44797
+ const key = STANDARD_FIELDS.get(colorBy);
44798
+ value = v[key];
44799
+ }
44800
+ variantColor = this.getVariantColorTable(colorBy).getColor(value);
44802
44801
  if (!variantColor) {
44803
44802
  variantColor = "gray";
44804
44803
  }
44805
44804
 
44806
44805
  } else if (this._color) {
44807
- variantColor = this.color;
44806
+ variantColor = (typeof this._color === "function") ? this._color(variant) : this._color;
44808
44807
  } else if ("NONVARIANT" === v.type) {
44809
44808
  variantColor = this.nonRefColor;
44810
44809
  } else if ("MIXED" === v.type) {
@@ -44815,9 +44814,6 @@ class VariantTrack extends TrackBase {
44815
44814
  return variantColor
44816
44815
  }
44817
44816
 
44818
- get color() {
44819
- return this._color ? ((typeof this._color === "function") ? this._color(v) : this._color) : this.defaultColor
44820
- }
44821
44817
 
44822
44818
  clickedFeatures(clickState, features) {
44823
44819
 
@@ -44831,7 +44827,7 @@ class VariantTrack extends TrackBase {
44831
44827
  // Variant
44832
44828
  const variantHeight = ("SQUISHED" === this.displayMode) ? this.squishedVariantHeight : this.expandedVariantHeight;
44833
44829
  const variantRow = Math.floor((yOffset - TOP_MARGIN) / (variantHeight + vGap));
44834
- if("COLLAPSED" !== this.displayMode) {
44830
+ if ("COLLAPSED" !== this.displayMode) {
44835
44831
  featureList = featureList.filter(f => f.row === variantRow);
44836
44832
  }
44837
44833
  } else if (this.callSets) {
@@ -45054,7 +45050,7 @@ class VariantTrack extends TrackBase {
45054
45050
  label: 'Add SVs to circular view',
45055
45051
  click: () => {
45056
45052
  for (let viewport of this.trackView.viewports) {
45057
- this.sendChordsForViewport(viewport);
45053
+ this.sendChordsForViewport(viewport);
45058
45054
  }
45059
45055
  }
45060
45056
  });