protvista-sequence
Advanced tools
Comparing version 3.0.0 to 3.2.13
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("d3"),require("ProtvistaZoomable")):"function"==typeof define&&define.amd?define(["d3","ProtvistaZoomable"],e):"object"==typeof exports?exports.ProtvistaSequence=e(require("d3"),require("ProtvistaZoomable")):t.ProtvistaSequence=e(t.d3,t.ProtvistaZoomable)}(window,(function(t,e){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=10)}([function(t,e){function n(e){return t.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},n(e)}t.exports=n},function(t,e,n){var r=n(4);function i(e,n,o){return"undefined"!=typeof Reflect&&Reflect.get?t.exports=i=Reflect.get:t.exports=i=function(t,e,n){var i=r(t,e);if(i){var o=Object.getOwnPropertyDescriptor(i,e);return o.get?o.get.call(n):o.value}},i(e,n,o||e)}t.exports=i},function(e,n){e.exports=t},function(t,n){t.exports=e},function(t,e,n){var r=n(0);t.exports=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=r(t)););return t}},function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){function n(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}t.exports=function(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),t}},function(t,e,n){var r=n(4),i=n(11);function o(t,e,n,s){return(o="undefined"!=typeof Reflect&&Reflect.set?Reflect.set:function(t,e,n,o){var s,a=r(t,e);if(a){if((s=Object.getOwnPropertyDescriptor(a,e)).set)return s.set.call(o,n),!0;if(!s.writable)return!1}if(s=Object.getOwnPropertyDescriptor(o,e)){if(!s.writable)return!1;s.value=n,Object.defineProperty(o,e,s)}else i(o,e,n);return!0})(t,e,n,s)}t.exports=function(t,e,n,r,i){if(!o(t,e,n,r||t)&&i)throw new Error("failed to set property");return n}},function(t,e,n){var r=n(12);t.exports=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&r(t,e)}},function(t,e,n){var r=n(13),i=n(14);t.exports=function(t,e){return!e||"object"!==r(e)&&"function"!=typeof e?i(t):e}},function(t,e,n){t.exports=n(15)},function(t,e){t.exports=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}},function(t,e){function n(e,r){return t.exports=n=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},n(e,r)}t.exports=n},function(t,e){function n(e){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?t.exports=n=function(t){return typeof t}:t.exports=n=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(e)}t.exports=n},function(t,e){t.exports=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}},function(t,e,n){"use strict";n.r(e);var r=n(5),i=n.n(r),o=n(6),s=n.n(o),a=n(7),c=n.n(a),u=n(1),f=n.n(u),l=n(8),h=n.n(l),p=n(9),d=n.n(p),g=n(0),b=n.n(g),y=n(2),v=n(3),x=n.n(v);function m(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=b()(t);if(e){var i=b()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return d()(this,n)}}var _=function(t){h()(n,t);var e=m(n);function n(){return i()(this,n),e.apply(this,arguments)}return s()(n,[{key:"connectedCallback",value:function(){var t=this;f()(b()(n.prototype),"connectedCallback",this).call(this),this.sequence=this.getAttribute("sequence"),this.sequence&&this._createSequence(),this.addEventListener("load",(function(e){t.data=e.detail.payload}))}},{key:"_getCharSize",value:function(){if(this.seq_g){var t=this.seq_g.select("text.base").node();if(t)this.chWidth=.8*t.getBBox().width,this.chHeight=1.6*t.getBBox().height;else{var e=this.seq_g.append("text").attr("class","base").text("T");this.chWidth=.8*e.node().getBBox().width,this.chHeight=1.6*e.node().getBBox().height,e.remove()}}}},{key:"_createSequence",value:function(){c()(b()(n.prototype),"svg",Object(y.select)(this).append("div").attr("class","").append("svg").attr("id","").attr("width",this.width).attr("height",this._height),this,!0),this.seq_bg=f()(b()(n.prototype),"svg",this).append("g").attr("class","background"),this.axis=f()(b()(n.prototype),"svg",this).append("g").attr("class","x axis"),this.seq_g=f()(b()(n.prototype),"svg",this).append("g").attr("class","sequence").attr("transform","translate(0,".concat(.75*this._height,")")),this.trackHighlighter.appendHighlightTo(this.svg),this.refresh()}},{key:"refresh",value:function(){var t=this;if(this._getCharSize(),this.axis){var e=this.getSingleBaseWidth(),n=e-this.chWidth,r=e/2,i=Math.round(Math.max(0,this._displaystart-2)),o=Math.round(Math.min(this.sequence.length,this._displayend+1)),s=n<0?[]:this.sequence.slice(i,o).split("").map((function(t,e){return{start:1+i+e,end:1+i+e,aa:t}}));this.height>this.chHeight&&(this.xAxis=Object(y.axisBottom)(this.xScale).tickFormat((function(t){return Number.isInteger(t)?t:""})).ticks(3,"s"),this.axis.call(this.xAxis)),this.axis.attr("transform","translate(".concat(this.margin.left+r,",0)")),this.axis.select(".domain").remove(),this.axis.selectAll(".tick line").remove(),this.bases=this.seq_g.selectAll("text.base").data(s,(function(t){return t.start})),this.bases.enter().append("text").attr("class","base").attr("text-anchor","middle").attr("x",(function(e){return t.getXFromSeqPosition(e.start)+r})).text((function(t){return t.aa})).style("pointer-events","none").style("font-family","monospace"),this.bases.exit().remove(),this.bases.attr("x",(function(e){return t.getXFromSeqPosition(e.start)+r})),this.background=this.seq_bg.selectAll("rect.base_bg").data(s,(function(t){return t.start})),this.background.enter().append("rect").attr("class","base_bg feature").attr("height",this._height).merge(this.background).attr("width",e).attr("fill",(function(t){return Math.round(t.start)%2?"#ccc":"#eee"})).attr("x",(function(e){return t.getXFromSeqPosition(e.start)})).call(this.bindEvents,this),this.background.exit().remove(),this.seq_g.style("opacity",Math.min(1,n)),this.background.style("opacity",Math.min(1,n)),this._updateHighlight()}}},{key:"_updateHighlight",value:function(){this.trackHighlighter.updateHighlight()}},{key:"data",get:function(){return this.sequence},set:function(t){"string"==typeof t?this.sequence=t:"sequence"in t&&(this.sequence=t.sequence),this.sequence&&!f()(b()(n.prototype),"svg",this)?this._createSequence():this.refresh()}}],[{key:"observedAttributes",get:function(){return x.a.observedAttributes.concat("highlightstart","highlightend")}}]),n}(x.a),q=function(){customElements.define("protvista-sequence",_)};window.customElements?q():document.addEventListener("WebComponentsReady",(function(){q()}))}])})); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("d3"),require("ProtvistaZoomable")):"function"==typeof define&&define.amd?define(["d3","ProtvistaZoomable"],e):"object"==typeof exports?exports.ProtvistaSequence=e(require("d3"),require("ProtvistaZoomable")):t.ProtvistaSequence=e(t.d3,t.ProtvistaZoomable)}(window,(function(t,e){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=10)}([function(t,e){function n(e){return t.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},n(e)}t.exports=n},function(t,e,n){var r=n(4);function i(e,n,o){return"undefined"!=typeof Reflect&&Reflect.get?t.exports=i=Reflect.get:t.exports=i=function(t,e,n){var i=r(t,e);if(i){var o=Object.getOwnPropertyDescriptor(i,e);return o.get?o.get.call(n):o.value}},i(e,n,o||e)}t.exports=i},function(e,n){e.exports=t},function(t,n){t.exports=e},function(t,e,n){var r=n(0);t.exports=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=r(t)););return t}},function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){function n(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}t.exports=function(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),t}},function(t,e,n){var r=n(4),i=n(11);function o(t,e,n,s){return(o="undefined"!=typeof Reflect&&Reflect.set?Reflect.set:function(t,e,n,o){var s,a=r(t,e);if(a){if((s=Object.getOwnPropertyDescriptor(a,e)).set)return s.set.call(o,n),!0;if(!s.writable)return!1}if(s=Object.getOwnPropertyDescriptor(o,e)){if(!s.writable)return!1;s.value=n,Object.defineProperty(o,e,s)}else i(o,e,n);return!0})(t,e,n,s)}t.exports=function(t,e,n,r,i){if(!o(t,e,n,r||t)&&i)throw new Error("failed to set property");return n}},function(t,e,n){var r=n(12);t.exports=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&r(t,e)}},function(t,e,n){var r=n(13),i=n(14);t.exports=function(t,e){return!e||"object"!==r(e)&&"function"!=typeof e?i(t):e}},function(t,e,n){t.exports=n(15)},function(t,e){t.exports=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}},function(t,e){function n(e,r){return t.exports=n=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},n(e,r)}t.exports=n},function(t,e){function n(e){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?t.exports=n=function(t){return typeof t}:t.exports=n=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(e)}t.exports=n},function(t,e){t.exports=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}},function(t,e,n){"use strict";n.r(e);var r=n(5),i=n.n(r),o=n(6),s=n.n(o),a=n(7),c=n.n(a),u=n(1),f=n.n(u),h=n(8),l=n.n(h),p=n(9),d=n.n(p),g=n(0),b=n.n(g),y=n(2),v=n(3),x=n.n(v);function m(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=b()(t);if(e){var i=b()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return d()(this,n)}}var _=function(t){l()(n,t);var e=m(n);function n(){return i()(this,n),e.apply(this,arguments)}return s()(n,[{key:"connectedCallback",value:function(){var t=this;f()(b()(n.prototype),"connectedCallback",this).call(this),this.sequence=this.getAttribute("sequence");var e=this.getAttribute("numberofticks");this.numberOfTicks=Number.isInteger(parseInt(e,10))?e:3,this.sequence&&this._createSequence(),this.addEventListener("load",(function(e){t.data=e.detail.payload}))}},{key:"_getCharSize",value:function(){if(this.seq_g){var t=this.seq_g.select("text.base").node();if(t)this.chWidth=.8*t.getBBox().width,this.chHeight=1.6*t.getBBox().height;else{var e=this.seq_g.append("text").attr("class","base").text("T");this.chWidth=.8*e.node().getBBox().width,this.chHeight=1.6*e.node().getBBox().height,e.remove()}}}},{key:"_createSequence",value:function(){c()(b()(n.prototype),"svg",Object(y.select)(this).append("div").attr("class","").append("svg").attr("id","").attr("width",this.width).attr("height",this._height),this,!0),this.seq_bg=f()(b()(n.prototype),"svg",this).append("g").attr("class","background"),this.axis=f()(b()(n.prototype),"svg",this).append("g").attr("class","x axis"),this.seq_g=f()(b()(n.prototype),"svg",this).append("g").attr("class","sequence").attr("transform","translate(0,".concat(.75*this._height,")")),this.trackHighlighter.appendHighlightTo(this.svg),this.refresh()}},{key:"refresh",value:function(){var t=this;if(this._getCharSize(),this.axis){var e=this.getSingleBaseWidth(),n=e-this.chWidth,r=e/2,i=Math.round(Math.max(0,this._displaystart-2)),o=Math.round(Math.min(this.sequence.length,this._displayend+1)),s=n<0?[]:this.sequence.slice(i,o).split("").map((function(t,e){return{start:1+i+e,end:1+i+e,aa:t}}));this.height>this.chHeight&&(this.xAxis=Object(y.axisBottom)(this.xScale).tickFormat((function(t){return Number.isInteger(t)?t:""})).ticks(this.numberOfTicks,"s"),this.axis.call(this.xAxis)),this.axis.attr("transform","translate(".concat(this.margin.left+r,",0)")),this.axis.select(".domain").remove(),this.axis.selectAll(".tick line").remove(),this.bases=this.seq_g.selectAll("text.base").data(s,(function(t){return t.start})),this.bases.enter().append("text").attr("class","base").attr("text-anchor","middle").attr("x",(function(e){return t.getXFromSeqPosition(e.start)+r})).text((function(t){return t.aa})).style("pointer-events","none").style("font-family","monospace"),this.bases.exit().remove(),this.bases.attr("x",(function(e){return t.getXFromSeqPosition(e.start)+r})),this.background=this.seq_bg.selectAll("rect.base_bg").data(s,(function(t){return t.start})),this.background.enter().append("rect").attr("class","base_bg feature").attr("height",this._height).merge(this.background).attr("width",e).attr("fill",(function(t){return Math.round(t.start)%2?"#ccc":"#eee"})).attr("x",(function(e){return t.getXFromSeqPosition(e.start)})).call(this.bindEvents,this),this.background.exit().remove(),this.seq_g.style("opacity",Math.min(1,n)),this.background.style("opacity",Math.min(1,n)),this._updateHighlight()}}},{key:"_updateHighlight",value:function(){this.trackHighlighter.updateHighlight()}},{key:"data",get:function(){return this.sequence},set:function(t){"string"==typeof t?this.sequence=t:"sequence"in t&&(this.sequence=t.sequence),this.sequence&&!f()(b()(n.prototype),"svg",this)?this._createSequence():this.refresh()}}],[{key:"observedAttributes",get:function(){return x.a.observedAttributes.concat("highlightstart","highlightend")}}]),n}(x.a),q=function(){customElements.define("protvista-sequence",_)};window.customElements?q():document.addEventListener("WebComponentsReady",(function(){q()}))}])})); | ||
//# sourceMappingURL=protvista-sequence.js.map |
{ | ||
"name": "protvista-sequence", | ||
"version": "3.0.0", | ||
"version": "3.2.13", | ||
"description": "Sequence component for the ProtVista tool", | ||
@@ -26,6 +26,6 @@ "files": [ | ||
"homepage": "https://ebi-webcomponents.github.io/nightingale/", | ||
"gitHead": "750856a787e184ab73d6677d5cef2d64fbf918e1", | ||
"gitHead": "563f7872ea6e92d7dc343cadcc7c4ed887c39d80", | ||
"dependencies": { | ||
"lodash-es": "^4.17.11", | ||
"protvista-zoomable": "^3.0.0" | ||
"protvista-zoomable": "^3.2.13" | ||
}, | ||
@@ -32,0 +32,0 @@ "devDependencies": { |
@@ -40,2 +40,6 @@ # protvista-sequence | ||
#### `numberofticks: number` | ||
The number of ticks in the displayed sequence. | ||
#### also see [protvista-zoomable](https://github.com/ebi-webcomponents/nightingale/blob/master/packages/protvista-zoomable/README.md#properties) |
@@ -5,3 +5,3 @@ import { axisBottom, select } from "d3"; | ||
const NUMBER_OF_TICKS = 3; | ||
const DEFAULT_NUMBER_OF_TICKS = 3; | ||
@@ -12,6 +12,10 @@ class ProtVistaSequence extends ProtvistaZoomable { | ||
this.sequence = this.getAttribute("sequence"); | ||
const ticks = this.getAttribute("numberofticks"); | ||
this.numberOfTicks = Number.isInteger(parseInt(ticks, 10)) | ||
? ticks | ||
: DEFAULT_NUMBER_OF_TICKS; | ||
if (this.sequence) { | ||
this._createSequence(); | ||
} | ||
this.addEventListener("load", e => { | ||
this.addEventListener("load", (e) => { | ||
this.data = e.detail.payload; | ||
@@ -107,4 +111,4 @@ }); | ||
this.xAxis = axisBottom(this.xScale) | ||
.tickFormat(d => (Number.isInteger(d) ? d : "")) | ||
.ticks(NUMBER_OF_TICKS, "s"); | ||
.tickFormat((d) => (Number.isInteger(d) ? d : "")) | ||
.ticks(this.numberOfTicks, "s"); | ||
this.axis.call(this.xAxis); | ||
@@ -117,3 +121,5 @@ } | ||
this.bases = this.seq_g.selectAll("text.base").data(bases, d => d.start); | ||
this.bases = this.seq_g | ||
.selectAll("text.base") | ||
.data(bases, (d) => d.start); | ||
this.bases | ||
@@ -124,4 +130,4 @@ .enter() | ||
.attr("text-anchor", "middle") | ||
.attr("x", d => this.getXFromSeqPosition(d.start) + half) | ||
.text(d => d.aa) | ||
.attr("x", (d) => this.getXFromSeqPosition(d.start) + half) | ||
.text((d) => d.aa) | ||
.style("pointer-events", "none") | ||
@@ -132,7 +138,7 @@ .style("font-family", "monospace"); | ||
this.bases.attr("x", d => this.getXFromSeqPosition(d.start) + half); | ||
this.bases.attr("x", (d) => this.getXFromSeqPosition(d.start) + half); | ||
this.background = this.seq_bg | ||
.selectAll("rect.base_bg") | ||
.data(bases, d => d.start); | ||
.data(bases, (d) => d.start); | ||
this.background | ||
@@ -145,6 +151,6 @@ .enter() | ||
.attr("width", ftWidth) | ||
.attr("fill", d => { | ||
.attr("fill", (d) => { | ||
return Math.round(d.start) % 2 ? "#ccc" : "#eee"; | ||
}) | ||
.attr("x", d => this.getXFromSeqPosition(d.start)) | ||
.attr("x", (d) => this.getXFromSeqPosition(d.start)) | ||
.call(this.bindEvents, this); | ||
@@ -151,0 +157,0 @@ this.background.exit().remove(); |
Sorry, the diff of this file is not supported yet
41667
185
45
Updatedprotvista-zoomable@^3.2.13