//>>built
require({cache:{"JBrowse/Plugin":function(){define(["dojo/_base/declare","JBrowse/Component"],function(h,b){return h(b,{constructor:function(b){this.name=b.name;this.cssLoaded=b.cssLoaded;this._finalizeConfig(b.config)},_defaultConfig:function(){return{baseUrl:"/plugins/"+this.name}}})})},"RegexSequenceSearch/View/SearchSeqDialog":function(){define("dojo/_base/declare dojo/dom-construct dojo/aspect dijit/focus dijit/form/Button dijit/form/RadioButton dijit/form/CheckBox dijit/form/TextBox JBrowse/View/Dialog/WithActionBar".split(" "),
function(h,b,r,l,q,n,f,k,a){return h(a,{constructor:function(){var m=this;r.after(this,"hide",function(){l.curNode&&l.curNode.blur();setTimeout(function(){m.destroyRecursive()},500)})},_dialogContent:function(){function m(c,a){var m=b.create("label",{},a),d=(new n(c)).placeAt(m);b.create("span",{innerHTML:c.label},m);return d}var c=this.content={},a=b.create("div",{className:"search-dialog"});b.create("div",{className:"search-dialog intro",innerHTML:"This tool creates tracks showing regions of the reference sequence (or its translations) that match a given DNA or amino acid sequence."},
a);var e=b.create("div",{className:"section"},a);b.create("span",{className:"header",innerHTML:"Search for"},e);var d=b.create("div",{className:"translateContainer"},e);m({name:"translate",value:"no",label:"DNA",checked:!0},d);c.translate=m({name:"translate",value:"yes",label:"AA"},d);c.searchBox=(new k({})).placeAt(e);e=b.create("div",{className:"section"},a);d=b.create("div",{className:"checkboxdiv"},e);c.caseIgnore=new f({label:"Ignore case",id:"search_ignore_case",checked:!0});d.appendChild(c.caseIgnore.domNode);
b.create("label",{"for":"search_ignore_case",innerHTML:"Ignore Case"},d);e=b.create("div",{className:"checkboxdiv"},e);c.regex=(new f({label:"Treat as regular expression",id:"search_as_regex"})).placeAt(e);b.create("label",{"for":"search_as_regex",innerHTML:"Treat as regular expression"},e);e=b.create("div",{className:"section"},a);b.create("span",{className:"header",innerHTML:"Search strands"},e);d=b.create("div",{className:"checkboxdiv"});c.fwdStrand=new f({id:"search_fwdstrand",checked:!0});var g=
b.create("div",{className:"checkboxdiv"});c.revStrand=new f({id:"search_revstrand",checked:!0});d.appendChild(c.fwdStrand.domNode);b.create("label",{"for":"search_fwdstrand",innerHTML:"Forward"},d);g.appendChild(c.revStrand.domNode);b.create("label",{"for":"search_revstrand",innerHTML:"Reverse"},g);e.appendChild(d);e.appendChild(g);return a},_getSearchParams:function(){var a=this.content;return{expr:a.searchBox.get("value"),regex:a.regex.checked,caseIgnore:a.caseIgnore.checked,translate:a.translate.checked,
fwdStrand:a.fwdStrand.checked,revStrand:a.revStrand.checked,maxLen:100}},_fillActionBar:function(a){var c=this;(new q({label:"Search",iconClass:"dijitIconBookmark",onClick:function(){var a=c._getSearchParams();c.callback(a);c.hide()}})).placeAt(a);(new q({label:"Cancel",iconClass:"dijitIconDelete",onClick:function(){c.callback(!1);c.hide()}})).placeAt(a)},show:function(a){this.callback=a||function(){};this.set("title","Add sequence search track");this.set("content",this._dialogContent());this.inherited(arguments);
l.focus(this.closeButtonNode)}})})},"RegexSequenceSearch/Store/SeqFeature/RegexSearch":function(){define("dojo/_base/declare dojo/_base/array dojo/_base/lang JBrowse/Store/SeqFeature JBrowse/Model/SimpleFeature JBrowse/Errors JBrowse/Util JBrowse/CodonTable".split(" "),function(h,b,r,l,q,n,f,k){return h(l,{constructor:function(a){this.searchParams=a.searchParams},_defaultConfig:function(){return f.deepUpdate(dojo.clone(this.inherited(arguments)),{regionSizeLimit:2E5})},getFeatures:function(a,b,c,
f){var e=r.mixin({orig:{start:a.start,end:a.end}},this.searchParams,a.searchParams);if(a.end-a.start>this.config.regionSizeLimit)throw new n.DataOverflow("Region too large to search");var d=this;this.browser.getStore("refseqs",function(g){g?g.getReferenceSequence(a,function(g){d.doSearch(a,g,e,b);c()},f):c()})},doSearch:function(a,m,c,k){var e=RegExp(c.regex?c.expr:this.escapeString(c.expr),c.caseIgnore?"gi":"g"),d=[];c.fwdStrand&&d.push([m,1]);c.revStrand&&d.push([f.revcom(m),-1]);b.forEach(d,function(d){if(c.translate)for(var b=
0;3>b;b++)this._searchSequence(a,d[0],e,d[1],k,!0,b);else this._searchSequence(a,d[0],e,d[1],k)},this)},_searchSequence:function(a,b,c,f,e,d,g){d&&(b=this.translateSequence(b,g));g=g||0;d=d?3:1;var k=a.start;a=a.end;for(var p;null!==(p=c.exec(b))&&p.length;){c.lastIndex=p.index+1;var h=p[0],l=0<f?k+g+d*p.index:a-g-d*(p.index+h.length),n=0<f?k+g+d*(p.index+h.length):a-g-d*p.index,h=new q({data:{type:"SEARCH",start:l,end:n,searchMatch:h,strand:f},id:[l,n,h].join()});e(h)}},translateSequence:function(a,
b){for(var c=a.slice(b),c=c.slice(0,3*Math.floor(c.length/3)),f="",e=new k,e=e.generateCodonTable(e.defaultCodonTable),d=0;d<c.length;d+=3)var g=c.slice(d,d+3),f=f+e[g];return f},escapeString:function(a){return(a+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")},saveStore:function(){return{searchParams:this.config.searchParams,regionSizeLimit:this.config.regionSizeLimit}}})})}}});
define("RegexSequenceSearch/main","dojo/_base/declare dojo/_base/lang dojo/Deferred dijit/MenuItem JBrowse/Plugin ./View/SearchSeqDialog".split(" "),function(h,b,r,l,q,n){return h(q,{constructor:function(f){this._searchTrackCount=0;this.browser.afterMilestone("initView",function(){this.browser.addGlobalMenuItem("file",new l({label:"Add sequence search track",iconClass:"dijitIconSearch",onClick:b.hitch(this,"createSearchTrack")}))},this)},createSearchTrack:function(){var b=this;(new n).show(function(k){if(k){var a=
{browser:b.browser,refSeq:b.browser.refSeq,type:"RegexSequenceSearch/Store/SeqFeature/RegexSearch",searchParams:k},h=b.browser.addStoreConfig(void 0,a);a.name=h;k={type:"JBrowse/View/Track/CanvasFeatures",label:"search_track_"+b._searchTrackCount++,key:"Search reference sequence for '"+k.expr+"'",metadata:{category:"Local tracks",Description:"Contains all matches of the text string/regular expression '"+a.searchExpr+"'"},store:h};b.browser.publish("/jbrowse/v1/v/tracks/new",[k]);b.browser.publish("/jbrowse/v1/v/tracks/show",
[k])}})}})});
//# sourceMappingURL=main.js.map