@jbrowse/plugin-variants 1.6.4 → 1.6.7
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/dist/LinearVariantDisplay/configSchema.d.ts +1 -1
- package/dist/LinearVariantDisplay/model.d.ts +1 -1
- package/dist/VariantFeatureWidget/index.d.ts +1 -1
- package/dist/VcfAdapter/configSchema.d.ts +1 -1
- package/dist/VcfTabixAdapter/configSchema.d.ts +1 -1
- package/dist/plugin-variants.cjs.development.js +30 -20
- package/dist/plugin-variants.cjs.development.js.map +1 -1
- package/dist/plugin-variants.cjs.production.min.js +1 -1
- package/dist/plugin-variants.cjs.production.min.js.map +1 -1
- package/dist/plugin-variants.esm.js +30 -20
- package/dist/plugin-variants.esm.js.map +1 -1
- package/package.json +3 -3
- package/src/VariantFeatureWidget/BreakendOptionDialog.tsx +21 -23
- package/src/VariantFeatureWidget/VariantFeatureWidget.tsx +11 -7
- package/src/index.ts +4 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),r=e(t),n=require("@jbrowse/core/configuration"),a=e(require("@jbrowse/core/pluggableElementTypes/AdapterType")),i=e(require("@jbrowse/core/pluggableElementTypes/DisplayType")),o=require("@jbrowse/core/pluggableElementTypes/models"),c=e(require("@jbrowse/core/pluggableElementTypes/TrackType")),u=e(require("@jbrowse/core/pluggableElementTypes/WidgetType")),s=e(require("@jbrowse/core/Plugin")),l=require("@jbrowse/plugin-linear-genome-view"),f=require("@jbrowse/plugin-circular-view"),p=require("@jbrowse/core/util/tracks"),d=require("@jbrowse/core/util"),h=require("mobx-state-tree"),v=e(require("@jbrowse/core/pluggableElementTypes/renderers/CircularChordRendererType")),y=require("mobx-react"),g=require("@jbrowse/core/util/types/mst"),m=require("@gmod/vcf"),b=e(m),w=e(require("prop-types")),k=require("@jbrowse/core/data_adapters/BaseAdapter"),x=require("@jbrowse/core/util/io"),T=require("@jbrowse/core/util/rxjs"),C=require("@gmod/tabix"),O=e(require("@flatten-js/interval-tree")),S=require("@gmod/bgzf-filehandle"),E=require("@material-ui/core"),j=e(require("@jbrowse/core/util/simpleFeature")),D=require("@mui/x-data-grid"),F=require("@jbrowse/core/BaseFeatureWidget/BaseFeatureDetail"),L=require("@material-ui/core/styles"),P=e(require("@material-ui/icons/Close"));function R(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?R(Object(r),!0).forEach((function(t){q(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):R(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function V(e,t,r,n,a,i,o){try{var c=e[i](o),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,a)}function N(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var i=e.apply(t,r);function o(e){V(i,n,a,o,c,"next",e)}function c(e){V(i,n,a,o,c,"throw",e)}o(void 0)}))}}function A(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function M(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function I(e,t,r){return t&&M(e.prototype,t),r&&M(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function q(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function B(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&(Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function z(e){return(z=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function G(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function W(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=z(e);if(t){var a=z(this).constructor;r=Reflect.construct(n,arguments,a)}else r=n.apply(this,arguments);return G(this,r)}}function H(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=z(e)););return e}function U(){return(U="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=H(e,t);if(n){var a=Object.getOwnPropertyDescriptor(n,t);return a.get?a.get.call(arguments.length<3?e:r):a.value}}).apply(this,arguments)}function J(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,i=[],o=!0,c=!1;try{for(r=r.call(e);!(o=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);o=!0);}catch(e){c=!0,a=e}finally{try{o||null==r.return||r.return()}finally{if(c)throw a}}return i}}(e,t)||$(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Y(e){return function(e){if(Array.isArray(e))return Q(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||$(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function $(e,t){if(e){if("string"==typeof e)return Q(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Q(e,t):void 0}}function Q(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var K=function(e){var t=e.jbrequire,r=t("mobx-state-tree").types,n=t("@jbrowse/core/configuration"),a=n.ConfigurationSchema,i=n.ConfigurationReference,o=t("@jbrowse/core/util").getContainingView,c=t("@jbrowse/core/util/tracks").getParentRenderProps,u=a("ChordVariantDisplay",{renderer:r.optional(e.pluggableConfigSchemaType("renderer"),{type:"StructuralVariantChordRenderer"})},{baseConfiguration:f.baseChordDisplayConfig,explicitlyTyped:!0});return{stateModel:r.compose("ChordVariantDisplay",f.BaseChordDisplayModel,r.model({type:r.literal("ChordVariantDisplay"),configuration:i(u)})).views((function(e){return{get rendererTypeName(){return e.configuration.renderer.type},renderProps:function(){var t=o(e);return _(_({},c(e)),{},{rpcDriverName:e.rpcDriverName,displayModel:e,bezierRadius:t.radiusPx*e.bezierRadiusRatio,radius:t.radiusPx,blockDefinitions:this.blockDefinitions,config:e.configuration.renderer,onChordClick:e.onChordClick})}}})),configSchema:u}},X=function(e){var t=e.lib["@jbrowse/core/pluggableElementTypes/DisplayType"],r=(0,e.load)(K);return new t({name:"ChordVariantDisplay",configSchema:r.configSchema,stateModel:r.stateModel,trackType:"VariantTrack",viewType:"CircularView",ReactComponent:f.BaseChordDisplayComponentFactory(e)})};function Z(e,t){return e(t={exports:{}},t.exports),t.exports}var ee=Z((function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},a=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",o=n.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var a=Object.create((t&&t.prototype instanceof f?t:f).prototype),i=new T(n||[]);return a._invoke=function(e,t,r){var n="suspendedStart";return function(a,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===a)throw i;return{value:void 0,done:!0}}for(r.method=a,r.arg=i;;){var o=r.delegate;if(o){var c=w(o,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,i),a}function s(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var l={};function f(){}function p(){}function d(){}var h={};c(h,a,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(C([])));y&&y!==t&&r.call(y,a)&&(h=y);var g=d.prototype=f.prototype=Object.create(h);function m(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){var n;this._invoke=function(a,i){function o(){return new t((function(n,o){!function n(a,i,o,c){var u=s(e[a],e,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==typeof f&&r.call(f,"__await")?t.resolve(f.__await).then((function(e){n("next",e,o,c)}),(function(e){n("throw",e,o,c)})):t.resolve(f).then((function(e){l.value=e,o(l)}),(function(e){return n("throw",e,o,c)}))}c(u.arg)}(a,i,n,o)}))}return n=n?n.then(o,o):o()}}function w(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,l;var a=n.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function k(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function C(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:O}}function O(){return{value:void 0,done:!0}}return p.prototype=d,c(g,"constructor",d),c(d,"constructor",p),p.displayName=c(d,o,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,c(e,o,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},m(b.prototype),c(b.prototype,i,(function(){return this})),e.AsyncIterator=b,e.async=function(t,r,n,a,i){void 0===i&&(i=Promise);var o=new b(u(t,r,n,a),i);return e.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},m(g),c(g,o,"Generator"),c(g,a,(function(){return this})),c(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=C,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return o.type="throw",o.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],o=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var i=a;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),x(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;x(r)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:C(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}));function te(e){return h.types.compose("LinearVariantDisplay",l.linearBasicDisplayModelFactory(e),h.types.model({type:h.types.literal("LinearVariantDisplay"),configuration:n.ConfigurationReference(e)})).actions((function(e){return{selectFeature:function(t){return N(ee.mark((function r(){var a,i,o,c,u,s,l;return ee.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(a=d.getSession(e),!d.isSessionModelWithWidgets(a)){r.next=11;break}return i=a.rpcManager,o=p.getRpcSessionId(e),c=d.getContainingTrack(e),u=n.getConf(c,"adapter"),r.next=8,i.call(o,"CoreGetMetadata",{adapterConfig:u});case 8:s=r.sent,l=a.addWidget("VariantFeatureWidget","variantFeature",{featureData:t.toJSON(),view:d.getContainingView(e),descriptions:s}),a.showWidget(l);case 11:a.setSelection(t);case 12:case"end":return r.stop()}}),r)})))()}}}))}function re(e,t){return(e.flipped?(e.region.elided?0:e.region.end)-t:t-(e.region.elided?0:e.region.start))/e.bpPerRadian+e.startRadians}var ne=y.observer((function(e){var t,a,i,o,c=e.feature,u=e.blocksForRefs,s=e.radius,l=e.config,f=e.bezierRadius,p=e.selected,h=e.onClick,v=u[c.get("refName")];if(!v)return null;c.get("INFO")?a=J(c.get("INFO").SVTYPE||[],1)[0]:c.get("mate")&&(a="mate");var y=null===(t=c.get("ALT"))||void 0===t?void 0:t[0],g=y&&m.parseBreakend(y);if(g){var b=g.MatePosition.split(":");i=+b[1],o=u[b[0]]}else if("<TRA>"===y){var w,k,x,T,C=null===(w=c.get("INFO"))||void 0===w||null===(k=w.CHR2)||void 0===k?void 0:k[0],O=null===(x=c.get("INFO"))||void 0===x||null===(T=x.END)||void 0===T?void 0:T[0];i=parseInt(O,10),o=u[C]}else if("mate"===a){var S=c.get("mate");i=S.start,o=u[S.refName]}if(o){var E=c.get("start"),j=re(v,E),D=re(o,i),F=d.polarToCartesian(s,j),L=d.polarToCartesian(s,D),P=d.polarToCartesian(f,(D+j)/2),R=n.readConfObject(l,p?"strokeColorSelected":"strokeColor",{feature:c}),_=n.readConfObject(l,"strokeColorHover",{feature:c});return r.createElement("path",{"data-testid":"chord-".concat(c.id()),d:["M"].concat(Y(F),["Q"],Y(P),Y(L)).join(" "),style:{stroke:R},onClick:function(e){return h(c,v.region,o.region,e)},onMouseOver:function(e){p||(e.target.style.stroke=_,e.target.style.strokeWidth=3)},onMouseOut:function(e){p||(e.target.style.stroke=R,e.target.style.strokeWidth=1)}})}return null}));function ae(e){var n,a=e.features,i=e.config,o=e.displayModel,c=e.blockDefinitions,u=e.radius,s=e.bezierRadius,l=e.displayModel.selectedFeatureId,f=e.onChordClick,p=t.useMemo((function(){var e={};return c.forEach((function(t){(t.region.elided?t.region.regions:[t.region]).forEach((function(r){e[r.refName]=t}))})),e}),[c]),d=[],h=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=$(e))){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,c=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){c=!0,i=e},f:function(){try{o||null==r.return||r.return()}finally{if(c)throw i}}}}(a);try{for(h.s();!(n=h.n()).done;){var v=J(n.value,2),y=v[0],g=v[1],m=String(l)===String(g.id());d.push(r.createElement(ne,{key:y,feature:g,config:i,displayModel:o,radius:u,bezierRadius:s,blocksForRefs:p,selected:m,onClick:f}))}}catch(e){h.e(e)}finally{h.f()}var b="chords-".concat(o.id);return r.createElement("g",{id:b,"data-testid":"structuralVariantChordRenderer"},r.createElement("style",{dangerouslySetInnerHTML:{__html:"\n #".concat(b," > path {\n cursor: crosshair;\n fill: none;\n }\n")}}),d)}ae.propTypes={features:w.instanceOf(Map).isRequired,config:g.PropTypes.ConfigSchema.isRequired,displayModel:y.PropTypes.objectOrObservableObject,blockDefinitions:w.arrayOf(y.PropTypes.objectOrObservableObject).isRequired,radius:w.number.isRequired,bezierRadius:w.number.isRequired,selectedFeatureId:w.string,onChordClick:w.oneOfType([w.func,w.string])},ae.defaultProps={displayModel:void 0,selectedFeatureId:"",onChordClick:void 0};var ie=y.observer(ae),oe=function(e){var t=n.ConfigurationSchema("StructuralVariantChordRenderer",{strokeColor:{type:"color",description:"the line color of each arc",defaultValue:"rgba(255,133,0,0.32)",contextVariable:["feature"]},strokeColorSelected:{type:"color",description:"the line color of an arc that has been selected",defaultValue:"black",contextVariable:["feature"]},strokeColorHover:{type:"color",description:"the line color of an arc that is being hovered over with the mouse",defaultValue:"#555",contextVariable:["feature"]}},{explicitlyTyped:!0});return new v({name:"StructuralVariantChordRenderer",ReactComponent:ie,configSchema:t,pluginManager:e})},ce=n.ConfigurationSchema("VariantFeatureWidget",{});function ue(e){return h.types.model("VariantFeatureWidget",{id:g.ElementId,type:h.types.literal("VariantFeatureWidget"),view:h.types.safeReference(e.pluggableMstType("view","stateModel")),featureData:h.types.frozen(),descriptions:h.types.frozen()}).actions((function(e){return{setFeatureData:function(t){e.featureData=t},clearFeatureData:function(){e.featureData=void 0}}}))}var se=n.ConfigurationSchema("VcfTabixAdapter",{vcfGzLocation:{type:"fileLocation",defaultValue:{uri:"/path/to/my.vcf.gz",locationType:"UriLocation"}},index:n.ConfigurationSchema("VcfIndex",{indexType:{model:h.types.enumeration("IndexType",["TBI","CSI"]),type:"stringEnum",defaultValue:"TBI"},location:{type:"fileLocation",defaultValue:{uri:"/path/to/my.vcf.gz.tbi",locationType:"UriLocation"}}})},{explicitlyTyped:!0}),le=n.ConfigurationSchema("VcfAdapter",{vcfLocation:{type:"fileLocation",defaultValue:{uri:"/path/to/my.vcf",locationType:"UriLocation"}}},{explicitlyTyped:!0}),fe=function(){function e(t){A(this,e),this.variant=t.variant,this.parser=t.parser,this.data=this.dataFromVariant(this.variant),this._id=t.id}return I(e,[{key:"get",value:function(e){return"samples"===e?this.variant.SAMPLES:this.data[e]||this.variant[e]}},{key:"set",value:function(){}},{key:"parent",value:function(){}},{key:"children",value:function(){}},{key:"tags",value:function(){return[].concat(Y(Object.keys(this.data)),Y(Object.keys(this.variant)),["samples"])}},{key:"id",value:function(){return this._id}},{key:"dataFromVariant",value:function(e){var t=e.REF,r=e.ALT,n=e.CHROM,a=e.INFO,i=e.ID,o=e.POS-1,c=J(this._getSOTermAndDescription(t,r),2),u=c[0],s=c[1],l=null==r?void 0:r.some((function(e){return"<TRA>"===e}));return{refName:n,start:o,end:(null==r?void 0:r.some((function(e){return-1!==e.indexOf("<")})))&&a.END&&!l?+a.END[0]:o+t.length,description:s,type:u,name:null==i?void 0:i.join(","),aliases:i&&i.length>1?e.ID.slice(1):void 0}}},{key:"_getSOTermAndDescription",value:function(e,t){var r=this;if(!t||t===[])return["remark","no alternative alleles"];var n=new Set,a=new Set;if(t.forEach((function(t){var i=J(r._getSOAndDescFromAltDefs(e,t),2),o=i[0],c=i[1];if(!o){var u=J(r._getSOAndDescByExamination(e,t),2);o=u[0],c=u[1]}o&&c&&(n.add(o),a.add(c))})),a.size>1){var i=new Set(Y(a).map((function(e){var t=e.split("->");return t[1]?t[0]:e}))),o=Y(i).map((function(e){var t=Y(a).map((function(t){var r=t.split("-> ");return r[1]&&r[0]===e?r[1]:""})).filter((function(e){return!!e}));return t.length?e+"-> "+t.join(","):Y(a).join(",")}));a=new Set(o)}return n.size?[Y(n).join(","),Y(a).join(",")]:[void 0,void 0]}},{key:"_getSOAndDescFromAltDefs",value:function(t,r){if("string"==typeof r&&!r.startsWith("<"))return[void 0,void 0];var n=e._altTypeToSO[r];if(!n&&this.parser.getMetadata("ALT",r)&&(n="sequence_variant"),n)return[n,r];var a=r.split(":");return a.length>1?this._getSOAndDescFromAltDefs(t,"<".concat(a.slice(0,a.length-1).join(":"),">")):[void 0,void 0]}},{key:"_getSOAndDescByExamination",value:function(e,t){return m.parseBreakend(t)?["breakend",t]:1===e.length&&1===t.length?["SNV",this._makeDescriptionString("SNV",e,t)]:"<INS>"===t?["insertion",t]:"<DEL>"===t||"<INV>"===t?["deletion",t]:"<TRA>"===t?["translocation",t]:t.includes("<")?["sv",t]:e.length===t.length?e.split("").reverse().join("")===t?["inversion",this._makeDescriptionString("inversion",e,t)]:["substitution",this._makeDescriptionString("substitution",e,t)]:e.length<=t.length?["insertion",this._makeDescriptionString("insertion",e,t)]:e.length>t.length?["deletion",this._makeDescriptionString("deletion",e,t)]:["indel",this._makeDescriptionString("indel",e,t)]}},{key:"_makeDescriptionString",value:function(e,t,r){return"".concat(e," ").concat(t," -> ").concat(r)}},{key:"toJSON",value:function(){return _(_(_({uniqueId:this._id},this.variant),this.data),{},{samples:this.variant.SAMPLES})}}]),e}();fe._altTypeToSO={DEL:"deletion",INS:"insertion",DUP:"duplication",INV:"inversion",INVDUP:"inverted duplication",CNV:"copy_number_variation",TRA:"translocation","DUP:TANDEM":"tandem_duplication",NON_REF:"sequence_variant","*":"sequence_variant"};var pe=function(e){B(f,s);var r=W(f);function f(){var e;return A(this,f),(e=r.apply(this,arguments)).name="VariantsPlugin",e}return I(f,[{key:"install",value:function(e){e.addAdapterType((function(){return new a({name:"VcfTabixAdapter",configSchema:se,getAdapterClass:function(){return Promise.resolve().then((function(){return de})).then((function(e){return e.default}))}})})),e.addToExtensionPoint("Core-guessAdapterForLocation",(function(e){return function(t,r,n){var a=p.getFileName(t),i=r&&p.getFileName(r),o={type:"VcfTabixAdapter",vcfGzLocation:t,index:{location:r||p.makeIndex(t,".tbi"),indexType:p.makeIndexType(i,"CSI","TBI")}};return/\.vcf\.b?gz$/i.test(a)&&!n||"VcfTabixAdapter"===n?o:e(t,r,n)}})),e.addToExtensionPoint("Core-guessTrackTypeForLocation",(function(e){return function(t){return"VcfTabixAdapter"===t?"VariantTrack":e(t)}})),e.addAdapterType((function(){return new a({name:"VcfAdapter",configSchema:le,getAdapterClass:function(){return Promise.resolve().then((function(){return ge})).then((function(e){return e.default}))}})})),e.addToExtensionPoint("Core-guessAdapterForLocation",(function(e){return function(t,r,n){var a=p.getFileName(t);return/\.vcf$/i.test(a)||"VcfAdapter"===n?{type:"VcfAdapter",vcfLocation:t}:e(t,r,n)}})),e.addRendererType((function(){return e.jbrequire(oe)})),e.addTrackType((function(){var t=n.ConfigurationSchema("VariantTrack",{},{baseConfiguration:o.createBaseTrackConfig(e)});return new c({name:"VariantTrack",configSchema:t,stateModel:o.createBaseTrackModel(e,"VariantTrack",t)})})),e.addDisplayType((function(){return e.jbrequire(X)})),e.addDisplayType((function(){var t=function(e){var t=l.linearBasicDisplayConfigSchemaFactory(e);return n.ConfigurationSchema("LinearVariantDisplay",{},{baseConfiguration:t,explicitlyTyped:!0})}(e);return new i({name:"LinearVariantDisplay",configSchema:t,stateModel:te(t),trackType:"VariantTrack",viewType:"LinearGenomeView",ReactComponent:l.BaseLinearDisplayComponent})})),e.addWidgetType((function(){return new u({name:"VariantFeatureWidget",heading:"Feature details",configSchema:ce,stateModel:ue(e),ReactComponent:t.lazy((function(){return Promise.resolve().then((function(){return Oe}))}))})}))}}]),f}(),de={__proto__:null,default:function(e){B(u,k.BaseFeatureDataAdapter);var t,r,a,i,o,c=W(u);function u(){return A(this,u),c.apply(this,arguments)}return I(u,[{key:"configurePre",value:(o=N(ee.mark((function e(){var t,r,a,i,o,c;return ee.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=n.readConfObject(this.config,"vcfGzLocation"),r=n.readConfObject(this.config,["index","location"]),a=n.readConfObject(this.config,["index","indexType"]),i=x.openLocation(t,this.pluginManager),c=new C.TabixIndexedFile({filehandle:i,csiFilehandle:(o="CSI"===a)?x.openLocation(r,this.pluginManager):void 0,tbiFilehandle:o?void 0:x.openLocation(r,this.pluginManager),chunkCacheSize:50*Math.pow(2,20),chunkSizeLimit:1e9}),e.next=8,c.getHeader();case 8:return e.abrupt("return",{filehandle:i,vcf:c,parser:new b({header:e.sent})});case 10:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"configure",value:(i=N(ee.mark((function e(){var t=this;return ee.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.configured||(this.configured=this.configurePre().catch((function(e){throw t.configured=void 0,e}))),e.abrupt("return",this.configured);case 2:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"getRefNames",value:(a=N(ee.mark((function e(){var t,r=arguments;return ee.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]?r[0]:{},e.next=3,this.configure();case 3:return e.abrupt("return",e.sent.vcf.getReferenceSequenceNames(t));case 6:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"getHeader",value:(r=N(ee.mark((function e(){return ee.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.configure();case 2:return e.abrupt("return",e.sent.vcf.getHeader());case 5:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getMetadata",value:(t=N(ee.mark((function e(){return ee.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.configure();case 2:return e.abrupt("return",e.sent.parser.getMetadata());case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"getFeatures",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T.ObservableCreate(function(){var n=N(ee.mark((function n(a){var i,o,c,u,s,l;return ee.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return i=e.refName,o=e.start,c=e.end,n.next=3,t.configure();case 3:return s=(u=n.sent).vcf,l=u.parser,n.next=8,s.getLines(i,o,c,_({lineCallback:function(e,r){a.next(new fe({variant:l.parseLine(e),parser:l,id:"".concat(t.id,"-vcf-").concat(r)}))}},r));case 8:a.complete();case 9:case"end":return n.stop()}}),n)})));return function(e){return n.apply(this,arguments)}}(),r.signal)}},{key:"getFeaturesInMultipleRegions",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=U(z(u.prototype),"getFeaturesInMultipleRegions",this);return T.ObservableCreate(function(){var a=N(ee.mark((function a(i){var o,c,u,s;return ee.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,t.configure();case 2:return o=a.sent.vcf,a.next=6,d.bytesForRegions(e,o.index);case 6:return c=a.sent,a.next=9,t.configure();case 9:return u=a.sent.filehandle,a.next=13,u.stat();case 13:(s=Math.round(c/a.sent.size*100))>100&&(s=100),s>60&&console.warn("getFeaturesInMultipleRegions fetching ".concat(s,"% of VCF file, but whole-file streaming not yet implemented")),n.call(t,e,r).subscribe(i);case 18:case"end":return a.stop()}}),a)})));return function(e){return a.apply(this,arguments)}}())}},{key:"freeResources",value:function(){}}]),u}()},he=function(e){var t=e.split("\n"),r=[],n=[];return t.forEach((function(e){e.startsWith("#")?r.push(e):e&&n.push(e)})),{header:r.join("\n"),lines:n}};function ve(e){return 31===e[0]&&139===e[1]&&8===e[2]}var ye=function(e){B(u,k.BaseFeatureDataAdapter);var t,r,a,i,o,c=W(u);function u(){return A(this,u),c.apply(this,arguments)}return I(u,[{key:"getHeader",value:(o=N(ee.mark((function e(){return ee.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.setup();case 2:return e.abrupt("return",e.sent.header);case 5:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"getMetadata",value:(i=N(ee.mark((function e(){var t;return ee.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.setup();case 2:return t=new b({header:e.sent.header}),e.abrupt("return",t.getMetadata());case 6:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"setupP",value:(a=N(ee.mark((function e(){var t,r,a,i,o,c;return ee.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,x.openLocation(n.readConfObject(this.config,"vcfLocation"),this.pluginManager).readFile();case 2:if(!ve(t=e.sent)){e.next=9;break}return e.next=6,S.unzip(t);case 6:e.t0=e.sent,e.next=10;break;case 9:e.t0=t;case 10:if(!((r=e.t0).length>536870888)){e.next=13;break}throw new Error("Data exceeds maximum string length (512MB)");case 13:return a=(new TextDecoder).decode(r),i=he(a),o=i.header,c=i.lines.map((function(e,t){var r,n=J(e.split("\t"),8),a=n[3],i=+n[1]-1;return{line:e,refName:n[0],start:i,end:+((null===(r=n[7].match(/END=(\d+)/))||void 0===r?void 0:r[1].trim())||i+a.length),id:t}})).reduce((function(e,t){var r=t.refName;return e[r]||(e[r]=new O),e[r].insert([t.start,t.end],t),e}),{}),e.abrupt("return",{header:o,intervalTree:c});case 17:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"setup",value:(r=N(ee.mark((function e(){var t=this;return ee.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.vcfFeatures||(this.vcfFeatures=this.setupP().catch((function(e){throw t.vcfFeatures=void 0,e}))),e.abrupt("return",this.vcfFeatures);case 2:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getRefNames",value:(t=N(ee.mark((function e(){return ee.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=3,this.setup();case 3:return e.abrupt("return",Object.keys(e.sent.intervalTree));case 6:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"getFeatures",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T.ObservableCreate(function(){var r=N(ee.mark((function r(n){var a,i,o,c,u,s,l;return ee.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,i=e.start,o=e.end,c=e.refName,r.next=4,t.setup();case 4:s=(u=r.sent).intervalTree,l=new b({header:u.header}),null===(a=s[c])||void 0===a||a.search([i,o]).forEach((function(e){return n.next(new fe({variant:l.parseLine(e.line),parser:l,id:"".concat(t.id,"-").concat(e.id)}))})),n.complete(),r.next=15;break;case 12:r.prev=12,r.t0=r.catch(0),n.error(r.t0);case 15:case"end":return r.stop()}}),r,null,[[0,12]])})));return function(e){return r.apply(this,arguments)}}(),r.signal)}},{key:"freeResources",value:function(){}}]),u}();ye.capabilities=["getFeatures","getRefNames"];var ge={__proto__:null,default:ye},me=L.makeStyles((function(e){return{closeButton:{position:"absolute",right:e.spacing(1),top:e.spacing(1),color:e.palette.grey[500]},block:{display:"block"}}}));function be(e){var n=e.model,a=e.handleClose,i=e.feature,o=e.viewType,c=me(),u=J(t.useState(!0),2),s=u[0],l=u[1],f=J(t.useState(!0),2),p=f[0],v=f[1];return r.createElement(E.Dialog,{open:!0,onClose:a},r.createElement(E.DialogTitle,null,"Breakpoint split view options",a?r.createElement(E.IconButton,{className:c.closeButton,onClick:function(){a()}},r.createElement(P,null)):null),r.createElement(E.Divider,null),r.createElement(E.DialogContent,null,r.createElement(E.FormControlLabel,{className:c.block,control:r.createElement(E.Checkbox,{checked:s,onChange:function(){return l((function(e){return!e}))}}),label:"Copy tracks into the new view"}),r.createElement(E.FormControlLabel,{className:c.block,control:r.createElement(E.Checkbox,{checked:p,onChange:function(){return v((function(e){return!e}))}}),label:"Mirror tracks vertically in vertically stacked view"})),r.createElement(E.DialogActions,null,r.createElement(E.Button,{onClick:function(){var e=n.view,t=d.getSession(n),r=o.snapshotFromBreakendFeature(i,e);r.views[0].offsetPx-=e.width/2+100,r.views[1].offsetPx-=e.width/2+100,r.featureData=i;var c=h.getSnapshot(e.tracks);r.views[0].tracks=c,r.views[1].tracks=p?c.slice().reverse():c,t.addView("BreakpointSplitView",r),a()},variant:"contained",color:"primary",autoFocus:!0},"OK"),r.createElement(E.Button,{onClick:function(){a()},color:"secondary",variant:"contained",autoFocus:!0},"Cancel")))}var we=y.observer(be),ke=["samples"];function xe(e){var n=J(t.useState({}),2),a=n[0],i=n[1],o=J(t.useState(!1),2),c=o[0],u=o[1],s=e.feature.samples,l=Object.entries(void 0===s?{}:s);if(!l.length)return null;var f,p=["sample"].concat(Y(Object.keys(l[0][1]))).map((function(e){return{field:e}})),d=[],h=Object.keys(a);try{d=l.map((function(e){return _(_({},Object.fromEntries(Object.entries(e[1]).map((function(e){return[e[0],String(e[1])]})))),{},{sample:e[0],id:e[0]})})).filter((function(e){return!h.length||h.every((function(t){var r=a[t];return!r||e[t].match(new RegExp(r,"i"))}))}))}catch(e){f=e}return r.createElement(F.BaseCard,Object.assign({},e,{title:"Samples"}),f?r.createElement(E.Typography,{color:"error"},"".concat(f)):null,r.createElement(E.FormControlLabel,{control:r.createElement(E.Checkbox,{checked:c,onChange:function(){return u((function(e){return!e}))}}),label:"Show sample filters"}),c?r.createElement(r.Fragment,null,r.createElement(E.Typography,null,"These filters can use a plain text search or regex style query, e.g. in the genotype field, entering 1 will query for all genotypes that include the first alternate allele e.g. 0|1 or 1|1, entering [1-9]\\d* will find any non-zero allele e.g. 0|2 or 2/33"),p.map((function(e){var t=e.field;return r.createElement(E.TextField,{key:"filter-".concat(t),placeholder:"Filter ".concat(t),value:a[t]||"",onChange:function(e){return i(_(_({},a),{},q({},t,e.target.value)))}})}))):null,r.createElement("div",{style:{height:600,width:"100%",overflow:"auto"}},r.createElement(D.DataGrid,{rows:d,columns:p,rowHeight:20,headerHeight:25,disableSelectionOnClick:!0,disableColumnMenu:!0})))}function Te(e){var n,a=e.model,i=e.locStrings,o=e.feature,c=d.getSession(a),u=h.getEnv(c).pluginManager,s=J(t.useState(!1),2),l=s[0],f=s[1];try{n=u.getViewType("BreakpointSplitView")}catch(e){}var p=new j(o);return r.createElement(F.BaseCard,Object.assign({},e,{title:"Breakends"}),r.createElement(E.Typography,null,"Link to linear view of breakend endpoints"),r.createElement("ul",null,i.map((function(e){return r.createElement("li",{key:"".concat(JSON.stringify(e))},r.createElement(E.Link,{href:"#",onClick:function(t){t.preventDefault();var r,n=a.view;n?null===(r=n.navToLocString)||void 0===r||r.call(n,e):c.notify("No view associated with this feature detail panel anymore","warning")}},"LGV - ".concat(e)))}))),n?r.createElement("div",null,r.createElement(E.Typography,null,"Launch split views with breakend source and target"),r.createElement("ul",null,i.map((function(e){return r.createElement("li",{key:"".concat(JSON.stringify(e))},r.createElement(E.Link,{href:"#",onClick:function(e){e.preventDefault(),f(!0)}},"".concat(o.refName,":").concat(o.start," // ").concat(e," (split view)")))}))),l?r.createElement(we,{model:a,feature:p,viewType:n,handleClose:function(){f(!1)}}):null):null)}function Ce(e){var t=e.model,n=t.descriptions,a=JSON.parse(JSON.stringify(t.featureData)),i=function(e,t){if(null==e)return{};var r,n,a=function(e,t){if(null==e)return{};var r,n,a={},i=Object.keys(e);for(n=0;n<i.length;n++)t.indexOf(r=i[n])>=0||(a[r]=e[r]);return a}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)t.indexOf(r=i[n])>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}(a,ke);return r.createElement(E.Paper,{"data-testid":"variant-side-drawer"},r.createElement(F.FeatureDetails,Object.assign({feature:i,descriptions:_(_({},{CHROM:"chromosome: An identifier from the reference genome",POS:"position: The reference position, with the 1st base having position 1",ID:"identifier: Semi-colon separated list of unique identifiers where available",REF:"reference base(s): Each base must be one of A,C,G,T,N (case insensitive).",ALT:"alternate base(s): Comma-separated list of alternate non-reference alleles",QUAL:"quality: Phred-scaled quality score for the assertion made in ALT",FILTER:"filter status: PASS if this position has passed all filters, otherwise a semicolon-separated list of codes for filters that fail"}),n)},e)),r.createElement(E.Divider,null),"breakend"===a.type?r.createElement(Te,{feature:a,locStrings:a.ALT.map((function(e){var t;return(null===(t=m.parseBreakend(e))||void 0===t?void 0:t.MatePosition)||""})),model:t}):null,"translocation"===a.type?r.createElement(Te,{feature:a,model:t,locStrings:["".concat(a.INFO.CHR2[0],":").concat(a.INFO.END)]}):null,r.createElement(xe,Object.assign({feature:a},e)))}var Oe={__proto__:null,default:y.observer(Ce)};exports.VcfFeature=fe,exports.default=pe;
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),r=e(t),n=require("@jbrowse/core/configuration"),a=e(require("@jbrowse/core/pluggableElementTypes/AdapterType")),i=e(require("@jbrowse/core/pluggableElementTypes/DisplayType")),o=require("@jbrowse/core/pluggableElementTypes/models"),c=e(require("@jbrowse/core/pluggableElementTypes/TrackType")),u=e(require("@jbrowse/core/pluggableElementTypes/WidgetType")),s=e(require("@jbrowse/core/Plugin")),l=require("@jbrowse/plugin-linear-genome-view"),f=require("@jbrowse/plugin-circular-view"),p=require("@jbrowse/core/util/tracks"),d=require("@jbrowse/core/util"),h=require("mobx-state-tree"),v=e(require("@jbrowse/core/pluggableElementTypes/renderers/CircularChordRendererType")),y=require("mobx-react"),g=require("@jbrowse/core/util/types/mst"),m=require("@gmod/vcf"),b=e(m),w=e(require("prop-types")),k=require("@jbrowse/core/data_adapters/BaseAdapter"),x=require("@jbrowse/core/util/io"),T=require("@jbrowse/core/util/rxjs"),C=require("@gmod/tabix"),O=e(require("@flatten-js/interval-tree")),S=require("@gmod/bgzf-filehandle"),E=require("@material-ui/core"),j=e(require("@jbrowse/core/util/simpleFeature")),D=require("@mui/x-data-grid"),L=require("@jbrowse/core/BaseFeatureWidget/BaseFeatureDetail"),F=e(require("@material-ui/icons/Close"));function P(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function R(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?P(Object(r),!0).forEach((function(t){I(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):P(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _(e,t,r,n,a,i,o){try{var c=e[i](o),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,a)}function V(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var i=e.apply(t,r);function o(e){_(i,n,a,o,c,"next",e)}function c(e){_(i,n,a,o,c,"throw",e)}o(void 0)}))}}function A(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function N(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function M(e,t,r){return t&&N(e.prototype,t),r&&N(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function I(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function q(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&(Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function B(e){return(B=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function z(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function G(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=B(e);if(t){var a=B(this).constructor;r=Reflect.construct(n,arguments,a)}else r=n.apply(this,arguments);return z(this,r)}}function W(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=B(e)););return e}function H(){return(H="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=W(e,t);if(n){var a=Object.getOwnPropertyDescriptor(n,t);return a.get?a.get.call(arguments.length<3?e:r):a.value}}).apply(this,arguments)}function U(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,i=[],o=!0,c=!1;try{for(r=r.call(e);!(o=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);o=!0);}catch(e){c=!0,a=e}finally{try{o||null==r.return||r.return()}finally{if(c)throw a}}return i}}(e,t)||Y(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function J(e){return function(e){if(Array.isArray(e))return $(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Y(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Y(e,t){if(e){if("string"==typeof e)return $(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?$(e,t):void 0}}function $(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var Q=function(e){var t=e.jbrequire,r=t("mobx-state-tree").types,n=t("@jbrowse/core/configuration"),a=n.ConfigurationSchema,i=n.ConfigurationReference,o=t("@jbrowse/core/util").getContainingView,c=t("@jbrowse/core/util/tracks").getParentRenderProps,u=a("ChordVariantDisplay",{renderer:r.optional(e.pluggableConfigSchemaType("renderer"),{type:"StructuralVariantChordRenderer"})},{baseConfiguration:f.baseChordDisplayConfig,explicitlyTyped:!0});return{stateModel:r.compose("ChordVariantDisplay",f.BaseChordDisplayModel,r.model({type:r.literal("ChordVariantDisplay"),configuration:i(u)})).views((function(e){return{get rendererTypeName(){return e.configuration.renderer.type},renderProps:function(){var t=o(e);return R(R({},c(e)),{},{rpcDriverName:e.rpcDriverName,displayModel:e,bezierRadius:t.radiusPx*e.bezierRadiusRatio,radius:t.radiusPx,blockDefinitions:this.blockDefinitions,config:e.configuration.renderer,onChordClick:e.onChordClick})}}})),configSchema:u}},K=function(e){var t=e.lib["@jbrowse/core/pluggableElementTypes/DisplayType"],r=(0,e.load)(Q);return new t({name:"ChordVariantDisplay",configSchema:r.configSchema,stateModel:r.stateModel,trackType:"VariantTrack",viewType:"CircularView",ReactComponent:f.BaseChordDisplayComponentFactory(e)})};function X(e,t){return e(t={exports:{}},t.exports),t.exports}var Z=X((function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},a=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",o=n.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var a=Object.create((t&&t.prototype instanceof f?t:f).prototype),i=new T(n||[]);return a._invoke=function(e,t,r){var n="suspendedStart";return function(a,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===a)throw i;return{value:void 0,done:!0}}for(r.method=a,r.arg=i;;){var o=r.delegate;if(o){var c=w(o,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,i),a}function s(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var l={};function f(){}function p(){}function d(){}var h={};c(h,a,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(C([])));y&&y!==t&&r.call(y,a)&&(h=y);var g=d.prototype=f.prototype=Object.create(h);function m(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){var n;this._invoke=function(a,i){function o(){return new t((function(n,o){!function n(a,i,o,c){var u=s(e[a],e,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==typeof f&&r.call(f,"__await")?t.resolve(f.__await).then((function(e){n("next",e,o,c)}),(function(e){n("throw",e,o,c)})):t.resolve(f).then((function(e){l.value=e,o(l)}),(function(e){return n("throw",e,o,c)}))}c(u.arg)}(a,i,n,o)}))}return n=n?n.then(o,o):o()}}function w(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,l;var a=n.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function k(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function C(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:O}}function O(){return{value:void 0,done:!0}}return p.prototype=d,c(g,"constructor",d),c(d,"constructor",p),p.displayName=c(d,o,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,c(e,o,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},m(b.prototype),c(b.prototype,i,(function(){return this})),e.AsyncIterator=b,e.async=function(t,r,n,a,i){void 0===i&&(i=Promise);var o=new b(u(t,r,n,a),i);return e.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},m(g),c(g,o,"Generator"),c(g,a,(function(){return this})),c(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=C,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return o.type="throw",o.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],o=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var i=a;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),x(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;x(r)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:C(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}));function ee(e){return h.types.compose("LinearVariantDisplay",l.linearBasicDisplayModelFactory(e),h.types.model({type:h.types.literal("LinearVariantDisplay"),configuration:n.ConfigurationReference(e)})).actions((function(e){return{selectFeature:function(t){return V(Z.mark((function r(){var a,i,o,c,u,s,l;return Z.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(a=d.getSession(e),!d.isSessionModelWithWidgets(a)){r.next=11;break}return i=a.rpcManager,o=p.getRpcSessionId(e),c=d.getContainingTrack(e),u=n.getConf(c,"adapter"),r.next=8,i.call(o,"CoreGetMetadata",{adapterConfig:u});case 8:s=r.sent,l=a.addWidget("VariantFeatureWidget","variantFeature",{featureData:t.toJSON(),view:d.getContainingView(e),descriptions:s}),a.showWidget(l);case 11:a.setSelection(t);case 12:case"end":return r.stop()}}),r)})))()}}}))}function te(e,t){return(e.flipped?(e.region.elided?0:e.region.end)-t:t-(e.region.elided?0:e.region.start))/e.bpPerRadian+e.startRadians}var re=y.observer((function(e){var t,a,i,o,c=e.feature,u=e.blocksForRefs,s=e.radius,l=e.config,f=e.bezierRadius,p=e.selected,h=e.onClick,v=u[c.get("refName")];if(!v)return null;c.get("INFO")?a=U(c.get("INFO").SVTYPE||[],1)[0]:c.get("mate")&&(a="mate");var y=null===(t=c.get("ALT"))||void 0===t?void 0:t[0],g=y&&m.parseBreakend(y);if(g){var b=g.MatePosition.split(":");i=+b[1],o=u[b[0]]}else if("<TRA>"===y){var w,k,x,T,C=null===(w=c.get("INFO"))||void 0===w||null===(k=w.CHR2)||void 0===k?void 0:k[0],O=null===(x=c.get("INFO"))||void 0===x||null===(T=x.END)||void 0===T?void 0:T[0];i=parseInt(O,10),o=u[C]}else if("mate"===a){var S=c.get("mate");i=S.start,o=u[S.refName]}if(o){var E=c.get("start"),j=te(v,E),D=te(o,i),L=d.polarToCartesian(s,j),F=d.polarToCartesian(s,D),P=d.polarToCartesian(f,(D+j)/2),R=n.readConfObject(l,p?"strokeColorSelected":"strokeColor",{feature:c}),_=n.readConfObject(l,"strokeColorHover",{feature:c});return r.createElement("path",{"data-testid":"chord-".concat(c.id()),d:["M"].concat(J(L),["Q"],J(P),J(F)).join(" "),style:{stroke:R},onClick:function(e){return h(c,v.region,o.region,e)},onMouseOver:function(e){p||(e.target.style.stroke=_,e.target.style.strokeWidth=3)},onMouseOut:function(e){p||(e.target.style.stroke=R,e.target.style.strokeWidth=1)}})}return null}));function ne(e){var n,a=e.features,i=e.config,o=e.displayModel,c=e.blockDefinitions,u=e.radius,s=e.bezierRadius,l=e.displayModel.selectedFeatureId,f=e.onChordClick,p=t.useMemo((function(){var e={};return c.forEach((function(t){(t.region.elided?t.region.regions:[t.region]).forEach((function(r){e[r.refName]=t}))})),e}),[c]),d=[],h=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=Y(e))){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,c=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){c=!0,i=e},f:function(){try{o||null==r.return||r.return()}finally{if(c)throw i}}}}(a);try{for(h.s();!(n=h.n()).done;){var v=U(n.value,2),y=v[0],g=v[1],m=String(l)===String(g.id());d.push(r.createElement(re,{key:y,feature:g,config:i,displayModel:o,radius:u,bezierRadius:s,blocksForRefs:p,selected:m,onClick:f}))}}catch(e){h.e(e)}finally{h.f()}var b="chords-".concat(o.id);return r.createElement("g",{id:b,"data-testid":"structuralVariantChordRenderer"},r.createElement("style",{dangerouslySetInnerHTML:{__html:"\n #".concat(b," > path {\n cursor: crosshair;\n fill: none;\n }\n")}}),d)}ne.propTypes={features:w.instanceOf(Map).isRequired,config:g.PropTypes.ConfigSchema.isRequired,displayModel:y.PropTypes.objectOrObservableObject,blockDefinitions:w.arrayOf(y.PropTypes.objectOrObservableObject).isRequired,radius:w.number.isRequired,bezierRadius:w.number.isRequired,selectedFeatureId:w.string,onChordClick:w.oneOfType([w.func,w.string])},ne.defaultProps={displayModel:void 0,selectedFeatureId:"",onChordClick:void 0};var ae=y.observer(ne),ie=function(e){var t=n.ConfigurationSchema("StructuralVariantChordRenderer",{strokeColor:{type:"color",description:"the line color of each arc",defaultValue:"rgba(255,133,0,0.32)",contextVariable:["feature"]},strokeColorSelected:{type:"color",description:"the line color of an arc that has been selected",defaultValue:"black",contextVariable:["feature"]},strokeColorHover:{type:"color",description:"the line color of an arc that is being hovered over with the mouse",defaultValue:"#555",contextVariable:["feature"]}},{explicitlyTyped:!0});return new v({name:"StructuralVariantChordRenderer",ReactComponent:ae,configSchema:t,pluginManager:e})},oe=n.ConfigurationSchema("VariantFeatureWidget",{});function ce(e){return h.types.model("VariantFeatureWidget",{id:g.ElementId,type:h.types.literal("VariantFeatureWidget"),view:h.types.safeReference(e.pluggableMstType("view","stateModel")),featureData:h.types.frozen(),descriptions:h.types.frozen()}).actions((function(e){return{setFeatureData:function(t){e.featureData=t},clearFeatureData:function(){e.featureData=void 0}}}))}var ue=n.ConfigurationSchema("VcfTabixAdapter",{vcfGzLocation:{type:"fileLocation",defaultValue:{uri:"/path/to/my.vcf.gz",locationType:"UriLocation"}},index:n.ConfigurationSchema("VcfIndex",{indexType:{model:h.types.enumeration("IndexType",["TBI","CSI"]),type:"stringEnum",defaultValue:"TBI"},location:{type:"fileLocation",defaultValue:{uri:"/path/to/my.vcf.gz.tbi",locationType:"UriLocation"}}})},{explicitlyTyped:!0}),se=n.ConfigurationSchema("VcfAdapter",{vcfLocation:{type:"fileLocation",defaultValue:{uri:"/path/to/my.vcf",locationType:"UriLocation"}}},{explicitlyTyped:!0}),le=function(){function e(t){A(this,e),this.variant=t.variant,this.parser=t.parser,this.data=this.dataFromVariant(this.variant),this._id=t.id}return M(e,[{key:"get",value:function(e){return"samples"===e?this.variant.SAMPLES:this.data[e]||this.variant[e]}},{key:"set",value:function(){}},{key:"parent",value:function(){}},{key:"children",value:function(){}},{key:"tags",value:function(){return[].concat(J(Object.keys(this.data)),J(Object.keys(this.variant)),["samples"])}},{key:"id",value:function(){return this._id}},{key:"dataFromVariant",value:function(e){var t=e.REF,r=e.ALT,n=e.CHROM,a=e.INFO,i=e.ID,o=e.POS-1,c=U(this._getSOTermAndDescription(t,r),2),u=c[0],s=c[1],l=null==r?void 0:r.some((function(e){return"<TRA>"===e}));return{refName:n,start:o,end:(null==r?void 0:r.some((function(e){return-1!==e.indexOf("<")})))&&a.END&&!l?+a.END[0]:o+t.length,description:s,type:u,name:null==i?void 0:i.join(","),aliases:i&&i.length>1?e.ID.slice(1):void 0}}},{key:"_getSOTermAndDescription",value:function(e,t){var r=this;if(!t||t===[])return["remark","no alternative alleles"];var n=new Set,a=new Set;if(t.forEach((function(t){var i=U(r._getSOAndDescFromAltDefs(e,t),2),o=i[0],c=i[1];if(!o){var u=U(r._getSOAndDescByExamination(e,t),2);o=u[0],c=u[1]}o&&c&&(n.add(o),a.add(c))})),a.size>1){var i=new Set(J(a).map((function(e){var t=e.split("->");return t[1]?t[0]:e}))),o=J(i).map((function(e){var t=J(a).map((function(t){var r=t.split("-> ");return r[1]&&r[0]===e?r[1]:""})).filter((function(e){return!!e}));return t.length?e+"-> "+t.join(","):J(a).join(",")}));a=new Set(o)}return n.size?[J(n).join(","),J(a).join(",")]:[void 0,void 0]}},{key:"_getSOAndDescFromAltDefs",value:function(t,r){if("string"==typeof r&&!r.startsWith("<"))return[void 0,void 0];var n=e._altTypeToSO[r];if(!n&&this.parser.getMetadata("ALT",r)&&(n="sequence_variant"),n)return[n,r];var a=r.split(":");return a.length>1?this._getSOAndDescFromAltDefs(t,"<".concat(a.slice(0,a.length-1).join(":"),">")):[void 0,void 0]}},{key:"_getSOAndDescByExamination",value:function(e,t){return m.parseBreakend(t)?["breakend",t]:1===e.length&&1===t.length?["SNV",this._makeDescriptionString("SNV",e,t)]:"<INS>"===t?["insertion",t]:"<DEL>"===t||"<INV>"===t?["deletion",t]:"<TRA>"===t?["translocation",t]:t.includes("<")?["sv",t]:e.length===t.length?e.split("").reverse().join("")===t?["inversion",this._makeDescriptionString("inversion",e,t)]:["substitution",this._makeDescriptionString("substitution",e,t)]:e.length<=t.length?["insertion",this._makeDescriptionString("insertion",e,t)]:e.length>t.length?["deletion",this._makeDescriptionString("deletion",e,t)]:["indel",this._makeDescriptionString("indel",e,t)]}},{key:"_makeDescriptionString",value:function(e,t,r){return"".concat(e," ").concat(t," -> ").concat(r)}},{key:"toJSON",value:function(){return R(R(R({uniqueId:this._id},this.variant),this.data),{},{samples:this.variant.SAMPLES})}}]),e}();le._altTypeToSO={DEL:"deletion",INS:"insertion",DUP:"duplication",INV:"inversion",INVDUP:"inverted duplication",CNV:"copy_number_variation",TRA:"translocation","DUP:TANDEM":"tandem_duplication",NON_REF:"sequence_variant","*":"sequence_variant"};var fe=function(e){q(f,s);var r=G(f);function f(){var e;return A(this,f),(e=r.apply(this,arguments)).name="VariantsPlugin",e}return M(f,[{key:"install",value:function(e){e.addAdapterType((function(){return new a({name:"VcfTabixAdapter",configSchema:ue,getAdapterClass:function(){return Promise.resolve().then((function(){return pe})).then((function(e){return e.default}))}})})),e.addToExtensionPoint("Core-guessAdapterForLocation",(function(e){return function(t,r,n){var a=p.getFileName(t),i=r&&p.getFileName(r),o={type:"VcfTabixAdapter",vcfGzLocation:t,index:{location:r||p.makeIndex(t,".tbi"),indexType:p.makeIndexType(i,"CSI","TBI")}};return/\.vcf\.b?gz$/i.test(a)&&!n||"VcfTabixAdapter"===n?o:e(t,r,n)}})),e.addToExtensionPoint("Core-guessTrackTypeForLocation",(function(e){return function(t){return"VcfTabixAdapter"===t||"VcfAdapter"===t?"VariantTrack":e(t)}})),e.addAdapterType((function(){return new a({name:"VcfAdapter",configSchema:se,getAdapterClass:function(){return Promise.resolve().then((function(){return ye})).then((function(e){return e.default}))}})})),e.addToExtensionPoint("Core-guessAdapterForLocation",(function(e){return function(t,r,n){var a=p.getFileName(t);return/\.vcf$/i.test(a)||"VcfAdapter"===n?{type:"VcfAdapter",vcfLocation:t}:e(t,r,n)}})),e.addRendererType((function(){return e.jbrequire(ie)})),e.addTrackType((function(){var t=n.ConfigurationSchema("VariantTrack",{},{baseConfiguration:o.createBaseTrackConfig(e)});return new c({name:"VariantTrack",configSchema:t,stateModel:o.createBaseTrackModel(e,"VariantTrack",t)})})),e.addDisplayType((function(){return e.jbrequire(K)})),e.addDisplayType((function(){var t=function(e){var t=l.linearBasicDisplayConfigSchemaFactory(e);return n.ConfigurationSchema("LinearVariantDisplay",{},{baseConfiguration:t,explicitlyTyped:!0})}(e);return new i({name:"LinearVariantDisplay",configSchema:t,stateModel:ee(t),trackType:"VariantTrack",viewType:"LinearGenomeView",ReactComponent:l.BaseLinearDisplayComponent})})),e.addWidgetType((function(){return new u({name:"VariantFeatureWidget",heading:"Feature details",configSchema:oe,stateModel:ce(e),ReactComponent:t.lazy((function(){return Promise.resolve().then((function(){return Ce}))}))})}))}}]),f}(),pe={__proto__:null,default:function(e){q(u,k.BaseFeatureDataAdapter);var t,r,a,i,o,c=G(u);function u(){return A(this,u),c.apply(this,arguments)}return M(u,[{key:"configurePre",value:(o=V(Z.mark((function e(){var t,r,a,i,o,c;return Z.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=n.readConfObject(this.config,"vcfGzLocation"),r=n.readConfObject(this.config,["index","location"]),a=n.readConfObject(this.config,["index","indexType"]),i=x.openLocation(t,this.pluginManager),c=new C.TabixIndexedFile({filehandle:i,csiFilehandle:(o="CSI"===a)?x.openLocation(r,this.pluginManager):void 0,tbiFilehandle:o?void 0:x.openLocation(r,this.pluginManager),chunkCacheSize:50*Math.pow(2,20),chunkSizeLimit:1e9}),e.next=8,c.getHeader();case 8:return e.abrupt("return",{filehandle:i,vcf:c,parser:new b({header:e.sent})});case 10:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"configure",value:(i=V(Z.mark((function e(){var t=this;return Z.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.configured||(this.configured=this.configurePre().catch((function(e){throw t.configured=void 0,e}))),e.abrupt("return",this.configured);case 2:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"getRefNames",value:(a=V(Z.mark((function e(){var t,r=arguments;return Z.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]?r[0]:{},e.next=3,this.configure();case 3:return e.abrupt("return",e.sent.vcf.getReferenceSequenceNames(t));case 6:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"getHeader",value:(r=V(Z.mark((function e(){return Z.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.configure();case 2:return e.abrupt("return",e.sent.vcf.getHeader());case 5:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getMetadata",value:(t=V(Z.mark((function e(){return Z.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.configure();case 2:return e.abrupt("return",e.sent.parser.getMetadata());case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"getFeatures",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T.ObservableCreate(function(){var n=V(Z.mark((function n(a){var i,o,c,u,s,l;return Z.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return i=e.refName,o=e.start,c=e.end,n.next=3,t.configure();case 3:return s=(u=n.sent).vcf,l=u.parser,n.next=8,s.getLines(i,o,c,R({lineCallback:function(e,r){a.next(new le({variant:l.parseLine(e),parser:l,id:"".concat(t.id,"-vcf-").concat(r)}))}},r));case 8:a.complete();case 9:case"end":return n.stop()}}),n)})));return function(e){return n.apply(this,arguments)}}(),r.signal)}},{key:"getFeaturesInMultipleRegions",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=H(B(u.prototype),"getFeaturesInMultipleRegions",this);return T.ObservableCreate(function(){var a=V(Z.mark((function a(i){var o,c,u,s;return Z.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,t.configure();case 2:return o=a.sent.vcf,a.next=6,d.bytesForRegions(e,o.index);case 6:return c=a.sent,a.next=9,t.configure();case 9:return u=a.sent.filehandle,a.next=13,u.stat();case 13:(s=Math.round(c/a.sent.size*100))>100&&(s=100),s>60&&console.warn("getFeaturesInMultipleRegions fetching ".concat(s,"% of VCF file, but whole-file streaming not yet implemented")),n.call(t,e,r).subscribe(i);case 18:case"end":return a.stop()}}),a)})));return function(e){return a.apply(this,arguments)}}())}},{key:"freeResources",value:function(){}}]),u}()},de=function(e){var t=e.split("\n"),r=[],n=[];return t.forEach((function(e){e.startsWith("#")?r.push(e):e&&n.push(e)})),{header:r.join("\n"),lines:n}};function he(e){return 31===e[0]&&139===e[1]&&8===e[2]}var ve=function(e){q(u,k.BaseFeatureDataAdapter);var t,r,a,i,o,c=G(u);function u(){return A(this,u),c.apply(this,arguments)}return M(u,[{key:"getHeader",value:(o=V(Z.mark((function e(){return Z.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.setup();case 2:return e.abrupt("return",e.sent.header);case 5:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"getMetadata",value:(i=V(Z.mark((function e(){var t;return Z.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.setup();case 2:return t=new b({header:e.sent.header}),e.abrupt("return",t.getMetadata());case 6:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"setupP",value:(a=V(Z.mark((function e(){var t,r,a,i,o,c;return Z.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,x.openLocation(n.readConfObject(this.config,"vcfLocation"),this.pluginManager).readFile();case 2:if(!he(t=e.sent)){e.next=9;break}return e.next=6,S.unzip(t);case 6:e.t0=e.sent,e.next=10;break;case 9:e.t0=t;case 10:if(!((r=e.t0).length>536870888)){e.next=13;break}throw new Error("Data exceeds maximum string length (512MB)");case 13:return a=(new TextDecoder).decode(r),i=de(a),o=i.header,c=i.lines.map((function(e,t){var r,n=U(e.split("\t"),8),a=n[3],i=+n[1]-1;return{line:e,refName:n[0],start:i,end:+((null===(r=n[7].match(/END=(\d+)/))||void 0===r?void 0:r[1].trim())||i+a.length),id:t}})).reduce((function(e,t){var r=t.refName;return e[r]||(e[r]=new O),e[r].insert([t.start,t.end],t),e}),{}),e.abrupt("return",{header:o,intervalTree:c});case 17:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"setup",value:(r=V(Z.mark((function e(){var t=this;return Z.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.vcfFeatures||(this.vcfFeatures=this.setupP().catch((function(e){throw t.vcfFeatures=void 0,e}))),e.abrupt("return",this.vcfFeatures);case 2:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getRefNames",value:(t=V(Z.mark((function e(){return Z.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=3,this.setup();case 3:return e.abrupt("return",Object.keys(e.sent.intervalTree));case 6:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"getFeatures",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T.ObservableCreate(function(){var r=V(Z.mark((function r(n){var a,i,o,c,u,s,l;return Z.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,i=e.start,o=e.end,c=e.refName,r.next=4,t.setup();case 4:s=(u=r.sent).intervalTree,l=new b({header:u.header}),null===(a=s[c])||void 0===a||a.search([i,o]).forEach((function(e){return n.next(new le({variant:l.parseLine(e.line),parser:l,id:"".concat(t.id,"-").concat(e.id)}))})),n.complete(),r.next=15;break;case 12:r.prev=12,r.t0=r.catch(0),n.error(r.t0);case 15:case"end":return r.stop()}}),r,null,[[0,12]])})));return function(e){return r.apply(this,arguments)}}(),r.signal)}},{key:"freeResources",value:function(){}}]),u}();ve.capabilities=["getFeatures","getRefNames"];var ye={__proto__:null,default:ve},ge=E.makeStyles((function(e){return{closeButton:{position:"absolute",right:e.spacing(1),top:e.spacing(1),color:e.palette.grey[500]},block:{display:"block"}}}));function me(e){var n=e.model,a=e.handleClose,i=e.feature,o=e.viewType,c=ge(),u=U(t.useState(!0),2),s=u[0],l=u[1],f=U(t.useState(!0),2),p=f[0],v=f[1];return r.createElement(E.Dialog,{open:!0,onClose:a},r.createElement(E.DialogTitle,null,"Breakpoint split view options",a?r.createElement(E.IconButton,{className:c.closeButton,onClick:function(){return a()}},r.createElement(F,null)):null),r.createElement(E.Divider,null),r.createElement(E.DialogContent,null,r.createElement(E.FormControlLabel,{className:c.block,control:r.createElement(E.Checkbox,{checked:s,onChange:function(){return l((function(e){return!e}))}}),label:"Copy tracks into the new view"}),r.createElement(E.FormControlLabel,{className:c.block,control:r.createElement(E.Checkbox,{checked:p,onChange:function(){return v((function(e){return!e}))}}),label:"Mirror tracks vertically in vertically stacked view"})),r.createElement(E.DialogActions,null,r.createElement(E.Button,{onClick:function(){var e=n.view,t=d.getSession(n);try{var r=o.snapshotFromBreakendFeature(i,e);r.views[0].offsetPx-=e.width/2+100,r.views[1].offsetPx-=e.width/2+100,r.featureData=i;var c=h.getSnapshot(e.tracks);r.views[0].tracks=c,r.views[1].tracks=p?c.slice().reverse():c,t.addView("BreakpointSplitView",r)}catch(e){console.error(e),t.notify("".concat(e))}a()},variant:"contained",color:"primary",autoFocus:!0},"OK"),r.createElement(E.Button,{onClick:function(){return a()},color:"secondary",variant:"contained"},"Cancel")))}var be=y.observer(me),we=["samples"];function ke(e){var n=U(t.useState({}),2),a=n[0],i=n[1],o=U(t.useState(!1),2),c=o[0],u=o[1],s=e.feature.samples,l=Object.entries(void 0===s?{}:s);if(!l.length)return null;var f,p=["sample"].concat(J(Object.keys(l[0][1]))).map((function(e){return{field:e}})),d=[],h=Object.keys(a);try{d=l.map((function(e){return R(R({},Object.fromEntries(Object.entries(e[1]).map((function(e){return[e[0],String(e[1])]})))),{},{sample:e[0],id:e[0]})})).filter((function(e){return!h.length||h.every((function(t){var r=a[t];return!r||e[t].match(new RegExp(r,"i"))}))}))}catch(e){f=e}return r.createElement(L.BaseCard,Object.assign({},e,{title:"Samples"}),f?r.createElement(E.Typography,{color:"error"},"".concat(f)):null,r.createElement(E.FormControlLabel,{control:r.createElement(E.Checkbox,{checked:c,onChange:function(){return u((function(e){return!e}))}}),label:"Show sample filters"}),c?r.createElement(r.Fragment,null,r.createElement(E.Typography,null,"These filters can use a plain text search or regex style query, e.g. in the genotype field, entering 1 will query for all genotypes that include the first alternate allele e.g. 0|1 or 1|1, entering [1-9]\\d* will find any non-zero allele e.g. 0|2 or 2/33"),p.map((function(e){var t=e.field;return r.createElement(E.TextField,{key:"filter-".concat(t),placeholder:"Filter ".concat(t),value:a[t]||"",onChange:function(e){return i(R(R({},a),{},I({},t,e.target.value)))}})}))):null,r.createElement("div",{style:{height:600,width:"100%",overflow:"auto"}},r.createElement(D.DataGrid,{rows:d,columns:p,rowHeight:20,headerHeight:25,disableSelectionOnClick:!0,disableColumnMenu:!0})))}function xe(e){var n,a=e.model,i=e.locStrings,o=e.feature,c=d.getSession(a),u=h.getEnv(c).pluginManager,s=U(t.useState(!1),2),l=s[0],f=s[1];try{n=u.getViewType("BreakpointSplitView")}catch(e){}var p=new j(o);return r.createElement(L.BaseCard,Object.assign({},e,{title:"Breakends"}),r.createElement(E.Typography,null,"Link to linear view of breakend endpoints"),r.createElement("ul",null,i.map((function(e){return r.createElement("li",{key:"".concat(JSON.stringify(e))},r.createElement(E.Link,{href:"#",onClick:function(t){t.preventDefault();var r=a.view;try{if(!r)throw new Error("No view associated with this feature detail panel anymore");var n;null===(n=r.navToLocString)||void 0===n||n.call(r,e)}catch(e){console.error(e),c.notify("".concat(e))}}},"LGV - ".concat(e)))}))),n?r.createElement("div",null,r.createElement(E.Typography,null,"Launch split views with breakend source and target"),r.createElement("ul",null,i.map((function(e){return r.createElement("li",{key:"".concat(JSON.stringify(e))},r.createElement(E.Link,{href:"#",onClick:function(e){e.preventDefault(),f(!0)}},"".concat(o.refName,":").concat(o.start," // ").concat(e," (split view)")))}))),l?r.createElement(be,{model:a,feature:p,viewType:n,handleClose:function(){f(!1)}}):null):null)}function Te(e){var t=e.model,n=t.descriptions,a=JSON.parse(JSON.stringify(t.featureData)),i=function(e,t){if(null==e)return{};var r,n,a=function(e,t){if(null==e)return{};var r,n,a={},i=Object.keys(e);for(n=0;n<i.length;n++)t.indexOf(r=i[n])>=0||(a[r]=e[r]);return a}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)t.indexOf(r=i[n])>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}(a,we);return r.createElement(E.Paper,{"data-testid":"variant-side-drawer"},r.createElement(L.FeatureDetails,Object.assign({feature:i,descriptions:R(R({},{CHROM:"chromosome: An identifier from the reference genome",POS:"position: The reference position, with the 1st base having position 1",ID:"identifier: Semi-colon separated list of unique identifiers where available",REF:"reference base(s): Each base must be one of A,C,G,T,N (case insensitive).",ALT:"alternate base(s): Comma-separated list of alternate non-reference alleles",QUAL:"quality: Phred-scaled quality score for the assertion made in ALT",FILTER:"filter status: PASS if this position has passed all filters, otherwise a semicolon-separated list of codes for filters that fail"}),n)},e)),r.createElement(E.Divider,null),"breakend"===a.type?r.createElement(xe,{feature:a,locStrings:a.ALT.map((function(e){var t;return(null===(t=m.parseBreakend(e))||void 0===t?void 0:t.MatePosition)||""})),model:t}):null,"translocation"===a.type?r.createElement(xe,{feature:a,model:t,locStrings:["".concat(a.INFO.CHR2[0],":").concat(a.INFO.END)]}):null,r.createElement(ke,Object.assign({feature:a},e)))}var Ce={__proto__:null,default:y.observer(Te)};exports.VcfFeature=le,exports.default=fe;
|
|
2
2
|
//# sourceMappingURL=plugin-variants.cjs.production.min.js.map
|