igv-rails 1.0.9.3 → 1.0.9.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e41e71ec86fc4750c6e787e26956d1d377bb5c53
4
- data.tar.gz: 67e4aa36df01edd7e27bf9a30a2b636d430c8eff
3
+ metadata.gz: 29352d7b5d9079761a44b147b06d2788f0b6f4e1
4
+ data.tar.gz: 81c8923667cd449fdec6c7cf0168c949b6dc1129
5
5
  SHA512:
6
- metadata.gz: 1ef0d543d13439794623a3c1309e00f91ded938e4e869750aa4115479101b0f9a288b92e77594aefcb18bf087db3411b76717ee6afdab3744e78267f1ba0ea93
7
- data.tar.gz: d37f2aa24171507dd7d6ea336541c78441436a31d490a6bce3a22dec739fd2aabacbc595fe6c322f361e2f9a003d3e5188ee9d68c896ee9bbf2061c92414fa97
6
+ metadata.gz: 442e9a0be1368f8a24ed5ae25c0f1dbe2bcb830a0fbefbdfaaeebb45d7b5e0db799d1875f929b9e923b088fec702c514c607abd39f42da3c4ed110f76a0a6a09
7
+ data.tar.gz: c361d01bb4214931223482c47aa50c0aba221076c1918fb302ff5895792650dacc46c616cf2c3dd43b88950b7a98c35160ffeb112da9e94783870b9bc356ce7c
@@ -1,5 +1,5 @@
1
1
  module Igv
2
2
  module Rails
3
- VERSION = "1.0.9.3"
3
+ VERSION = "1.0.9.4"
4
4
  end
5
5
  end
@@ -11611,10 +11611,14 @@ var igv = (function (igv) {
11611
11611
  this.render = renderFusionJuncSpan;
11612
11612
  this.height = config.height || 50;
11613
11613
  this.autoHeight = false;
11614
- } else if ("snp" === config.type) {
11615
- // TODO -- snp specific render function
11616
- this.render = renderFeature;
11617
- } else {
11614
+ }
11615
+ else if ('snp' === config.type) {
11616
+ this.render = renderSnp;
11617
+ // colors ordered based on priority least to greatest
11618
+ this.snpColors = ['rgb(0,0,0)', 'rgb(0,0,255)', 'rgb(0,255,0)', 'rgb(255,0,0)'];
11619
+ this.colorBy = 'function';
11620
+ }
11621
+ else {
11618
11622
  this.render = renderFeature;
11619
11623
  this.arrowSpacing = 30;
11620
11624
 
@@ -12216,6 +12220,104 @@ var igv = (function (igv) {
12216
12220
 
12217
12221
  }
12218
12222
 
12223
+ /**
12224
+ *
12225
+ * @param snp
12226
+ * @param bpStart genomic location of the left edge of the current canvas
12227
+ * @param xScale scale in base-pairs per pixel
12228
+ * @param pixelHeight pixel height of the current canvas
12229
+ * @param ctx the canvas 2d context
12230
+ */
12231
+ function renderSnp(snp, bpStart, xScale, pixelHeight, ctx) {
12232
+
12233
+ var coord = calculateFeatureCoordinates(snp, bpStart, xScale),
12234
+ py = 20,
12235
+ h = 10,
12236
+ colorArrLength = this.snpColors.length,
12237
+ colorPriority;
12238
+
12239
+ switch(this.colorBy) {
12240
+ case 'function':
12241
+ colorPriority = colorByFunc(snp.func);
12242
+ break;
12243
+ case 'class':
12244
+ colorPriority = colorByClass(snp['class']);
12245
+ }
12246
+
12247
+ ctx.fillStyle = this.snpColors[colorPriority];
12248
+ ctx.fillRect(coord.px, py, coord.pw, h);
12249
+
12250
+ // Coloring functions, convert a value to a priority
12251
+
12252
+ function colorByFunc(theFunc) {
12253
+ var funcArray = theFunc.split(',');
12254
+ // possible func values
12255
+ var codingNonSynonSet = new Set(['nonsense', 'missense', 'stop-loss', 'frameshift', 'cds-indel']),
12256
+ codingSynonSet = new Set(['coding-synon']),
12257
+ spliceSiteSet = new Set(['splice-3', 'splice-5']),
12258
+ untranslatedSet = new Set(['untranslated-5', 'untranslated-3']),
12259
+ priorities;
12260
+ // locusSet = new Set(['near-gene-3', 'near-gene-5']);
12261
+ // intronSet = new Set(['intron']);
12262
+
12263
+ priorities = funcArray.map(function(func) {
12264
+ if (codingNonSynonSet.has(func) || spliceSiteSet.has(func)) {
12265
+ return colorArrLength - 1;
12266
+ } else if (codingSynonSet.has(func)) {
12267
+ return colorArrLength - 2;
12268
+ } else if (untranslatedSet.has(func)) {
12269
+ return colorArrLength - 3;
12270
+ } else { // locusSet.has(func) || intronSet.has(func)
12271
+ return 0;
12272
+ }
12273
+ });
12274
+
12275
+ return priorities.reduce(function(a,b) {
12276
+ return Math.max(a,b);
12277
+ });
12278
+ }
12279
+
12280
+ function colorByClass(cls) {
12281
+ if (cls === 'deletion') {
12282
+ return colorArrLength - 1;
12283
+ } else if (cls === 'mnp') {
12284
+ return colorArrLength - 2;
12285
+ } else if (cls === 'microsatellite' || cls === 'named') {
12286
+ return colorArrLength - 3;
12287
+ } else { // cls === 'single' || cls === 'in-del' || cls === 'insertion'
12288
+ return 0;
12289
+ }
12290
+ }
12291
+ }
12292
+
12293
+ igv.FeatureTrack.prototype.popupMenuItemList = function(config) {
12294
+ if (this.render === renderSnp) {
12295
+
12296
+ var menuItems = [], self = this;
12297
+
12298
+ menuItems.push({
12299
+ name: 'Color by function',
12300
+ click: function() {
12301
+ setColorBy('function');
12302
+ }
12303
+ });
12304
+ menuItems.push({
12305
+ name: 'Color by class',
12306
+ click: function() {
12307
+ setColorBy('class');
12308
+ }
12309
+ });
12310
+
12311
+ return menuItems;
12312
+
12313
+ function setColorBy(value) {
12314
+ self.colorBy = value;
12315
+ self.trackView.update();
12316
+ config.popover.hide();
12317
+ }
12318
+ }
12319
+ };
12320
+
12219
12321
 
12220
12322
  return igv;
12221
12323
 
@@ -13403,9 +13505,6 @@ var igv = (function (igv) {
13403
13505
  igv.xhr.loadJson(url, self.config)
13404
13506
  .then(function (data) {
13405
13507
  if (data) {
13406
- data.forEach(function (json) {
13407
- decodeJson(json);
13408
- });
13409
13508
  fulfill(data);
13410
13509
  } else {
13411
13510
  fulfill(null);
@@ -13417,11 +13516,6 @@ var igv = (function (igv) {
13417
13516
  });
13418
13517
  };
13419
13518
 
13420
- // TODO -- generalize
13421
- function decodeJson(feature) {
13422
- if(feature.start) feature.start = Number.parseInt(feature.start);
13423
- if(feature.end) feature.end = Number.parseInt(feature.end);
13424
- }
13425
13519
 
13426
13520
  return igv;
13427
13521
  })(igv || {});
@@ -14818,12 +14912,12 @@ var igv = (function (igv) {
14818
14912
  },
14819
14913
  decode: function (json) {
14820
14914
  // If specific callSetIds are specified filter to those
14821
- if (self.callSetIds) {
14915
+ if (self.callSetIds) {
14822
14916
  var filteredCallSets = [],
14823
14917
  csIdSet = new Set();
14824
14918
 
14825
14919
  self.callSetIds.forEach(function (csid) {
14826
- csIdSet.add(m);
14920
+ csIdSet.add(csid);
14827
14921
  })
14828
14922
  json.callSets.forEach(function (cs) {
14829
14923
  if (csIdSet.has(cs.id)) {
@@ -23460,6 +23554,7 @@ var igv = (function (igv) {
23460
23554
  case "snp":
23461
23555
  case "genes":
23462
23556
  case "fusionjuncspan":
23557
+ case "snp":
23463
23558
  return new igv.FeatureTrack(conf);
23464
23559
  break;
23465
23560
 
@@ -27031,11 +27126,11 @@ var igv = (function (igv) {
27031
27126
 
27032
27127
  function calcHeterozygosity(ac, an) {
27033
27128
  var sum = 0,
27034
- altFreqs = ac.split(','),
27129
+ altFreqs = Array.isArray(ac) ? ac : ac.split(','),
27035
27130
  altCount = 0,
27036
27131
  refFrac;
27037
27132
 
27038
- an = parseInt(an);
27133
+ an = Array.isArray(an) ? parseInt(an[0]) : parseInt(an);
27039
27134
  altFreqs.forEach(function (altFreq) {
27040
27135
  var a = parseInt(altFreq),
27041
27136
  altFrac = a / an;
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: igv-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.9.3
4
+ version: 1.0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Van Etten, PhD
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-26 00:00:00.000000000 Z
11
+ date: 2017-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties