From de29b95e39aa926574a5125ce323988a432c4d55 Mon Sep 17 00:00:00 2001 From: Emmanuel Date: Tue, 12 Jul 2022 04:42:12 +0100 Subject: [PATCH 1/2] only hide notification after timeout for non-mixed sequences --- public/js/query.js | 11 ++++++----- public/sequenceserver-search.min.js | 4 ++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/public/js/query.js b/public/js/query.js index 213197f85..b0326a18d 100644 --- a/public/js/query.js +++ b/public/js/query.js @@ -296,11 +296,12 @@ export class SearchQueryWidget extends Component { if (type) { $('#' + type + '-sequence-notification').show('drop', { direction: 'up' }).addClass('active'); - this.notification_timeout = setTimeout(function () { - $('.notifications .active').hide('drop', { direction: 'up' }).removeClass('active'); - }, 5000); - - if (type === 'mixed') { + //hide notification after 5s only for non-mixed sequences + if (type !== 'mixed') { + this.notification_timeout = setTimeout(function () { + $('.notifications .active').hide('drop', { direction: 'up' }).removeClass('active'); + }, 5000); + } else { this.indicateError(); } } diff --git a/public/sequenceserver-search.min.js b/public/sequenceserver-search.min.js index 7b2efa11b..33acf6744 100644 --- a/public/sequenceserver-search.min.js +++ b/public/sequenceserver-search.min.js @@ -126,7 +126,11 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; +<<<<<<< HEAD eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"ReportQuery\": () => (/* binding */ ReportQuery),\n/* harmony export */ \"SearchQueryWidget\": () => (/* binding */ SearchQueryWidget)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! underscore */ \"./node_modules/underscore/modules/index-all.js\");\n/* harmony import */ var _hits_overview__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./hits_overview */ \"./public/js/hits_overview.js\");\n/* harmony import */ var _length_distribution__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./length_distribution */ \"./public/js/length_distribution.js\");\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils */ \"./public/js/utils.js\");\n/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react/jsx-runtime */ \"./node_modules/react/jsx-runtime.js\");\n/* provided dependency */ var $ = __webpack_require__(/*! jquery */ \"./node_modules/jquery/dist/jquery.js\");\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, \"prototype\", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } else if (call !== void 0) { throw new TypeError(\"Derived constructors may only return object or undefined\"); } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n\n\n\n // length distribution of hits\n\n\n/**\n * Query component displays query defline, graphical overview, length\n * distribution, and hits table.\n */\n\n\n\nvar ReportQuery = /*#__PURE__*/function (_Component) {\n _inherits(ReportQuery, _Component);\n\n var _super = _createSuper(ReportQuery);\n\n function ReportQuery() {\n _classCallCheck(this, ReportQuery);\n\n return _super.apply(this, arguments);\n }\n\n _createClass(ReportQuery, [{\n key: \"shouldComponentUpdate\",\n value: // Each update cycle will cause all previous queries to be re-rendered.\n // We avoid that by implementing shouldComponentUpdate life-cycle hook.\n // The trick is to simply check if the components has recieved props\n // before.\n function shouldComponentUpdate() {\n // If the component has received props before, query property will\n // be set on it. If it is, we return false so that the component\n // is not re-rendered. If the query property is not set, we return\n // true: this must be the first time react is trying to render the\n // component.\n return !this.props.query;\n } // Kind of public API //\n\n /**\n * Returns the id of query.\n */\n\n }, {\n key: \"domID\",\n value: function domID() {\n return 'Query_' + this.props.query.number;\n }\n }, {\n key: \"queryLength\",\n value: function queryLength() {\n return this.props.query.length;\n }\n /**\n * Returns number of hits.\n */\n\n }, {\n key: \"numhits\",\n value: function numhits() {\n return this.props.query.hits.length;\n }\n }, {\n key: \"headerJSX\",\n value: function headerJSX() {\n var meta = \"length: \".concat(this.queryLength().toLocaleString());\n\n if (this.props.showQueryCrumbs) {\n meta = \"query \".concat(this.props.query.number, \", \") + meta;\n }\n\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"section-header\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"h3\", {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"strong\", {\n children: [\"Query=\\xA0\", this.props.query.id]\n }), \"\\xA0\", this.props.query.title]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"span\", {\n className: \"label label-reset pos-label\",\n children: meta\n })]\n });\n }\n }, {\n key: \"hitsListJSX\",\n value: function hitsListJSX() {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"section-content\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_hits_overview__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n query: this.props.query,\n program: this.props.program,\n collapsed: this.props.veryBig\n }, 'GO_' + this.props.query.number), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_length_distribution__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n query: this.props.query,\n algorithm: this.props.program,\n collapsed: \"true\"\n }, 'LD_' + this.props.query.id), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(HitsTable, {\n query: this.props.query,\n imported_xml: this.props.imported_xml\n }, 'HT_' + this.props.query.number)]\n });\n }\n }, {\n key: \"noHitsJSX\",\n value: function noHitsJSX() {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"div\", {\n className: \"section-content\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"strong\", {\n children: \" ****** No hits found ****** \"\n })\n });\n }\n }, {\n key: \"render\",\n value: function render() {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"resultn\",\n id: this.domID(),\n \"data-query-len\": this.props.query.length,\n \"data-algorithm\": this.props.program,\n children: [this.headerJSX(), this.numhits() && this.hitsListJSX() || this.noHitsJSX()]\n });\n }\n }]);\n\n return ReportQuery;\n}(react__WEBPACK_IMPORTED_MODULE_0__.Component);\n/**\n * Query widget for Search component.\n */\n\nvar SearchQueryWidget = /*#__PURE__*/function (_Component2) {\n _inherits(SearchQueryWidget, _Component2);\n\n var _super2 = _createSuper(SearchQueryWidget);\n\n function SearchQueryWidget(props) {\n var _this;\n\n _classCallCheck(this, SearchQueryWidget);\n\n _this = _super2.call(this, props);\n _this.state = {\n value: $('input#input_sequence').val() || ''\n };\n _this.value = _this.value.bind(_assertThisInitialized(_this));\n _this.clear = _this.clear.bind(_assertThisInitialized(_this));\n _this.focus = _this.focus.bind(_assertThisInitialized(_this));\n _this.isEmpty = _this.isEmpty.bind(_assertThisInitialized(_this));\n _this.textarea = _this.textarea.bind(_assertThisInitialized(_this));\n _this.controls = _this.controls.bind(_assertThisInitialized(_this));\n _this.handleInput = _this.handleInput.bind(_assertThisInitialized(_this));\n _this.hideShowButton = _this.hideShowButton.bind(_assertThisInitialized(_this));\n _this.indicateError = _this.indicateError.bind(_assertThisInitialized(_this));\n _this.indicateNormal = _this.indicateNormal.bind(_assertThisInitialized(_this));\n _this.type = _this.type.bind(_assertThisInitialized(_this));\n _this.guessSequenceType = _this.guessSequenceType.bind(_assertThisInitialized(_this));\n _this.notify = _this.notify.bind(_assertThisInitialized(_this));\n _this.textareaRef = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createRef)();\n _this.controlsRef = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createRef)();\n return _this;\n } // LIFECYCLE Methods\n\n\n _createClass(SearchQueryWidget, [{\n key: \"componentDidMount\",\n value: function componentDidMount() {\n $('body').click(function () {\n $('.notifications .active').hide('drop', {\n direction: 'up'\n }).removeClass('active');\n });\n }\n }, {\n key: \"componentDidUpdate\",\n value: function componentDidUpdate() {\n this.hideShowButton();\n var type = this.type();\n\n if (!type || type !== this._type) {\n this._type = type;\n this.notify(type);\n this.props.onSequenceTypeChanged(type);\n }\n } // Kind of public API. //\n\n /**\n * Returns query sequence if no argument is provided (or null or undefined\n * is provided as argument). Otherwise, sets query sequenced to the given\n * value and returns `this`.\n *\n * Default/initial state of query sequence is an empty string. Caller must\n * explicitly provide empty string as argument to \"reset\" query sequence.\n */\n\n }, {\n key: \"value\",\n value: function value(val) {\n if (val == null) {\n // i.e., val is null or undefined\n return this.state.value;\n } else {\n this.setState({\n value: val\n });\n return this;\n }\n }\n /**\n * Clears textarea. Returns `this`.\n *\n * Clearing textarea also causes it to be focussed.\n */\n\n }, {\n key: \"clear\",\n value: function clear() {\n return this.value('').focus();\n }\n /**\n * Focuses textarea. Returns `this`.\n */\n\n }, {\n key: \"focus\",\n value: function focus() {\n this.textarea().focus();\n return this;\n }\n /**\n * Returns true if query is absent ('', undefined, null), false otherwise.\n */\n\n }, {\n key: \"isEmpty\",\n value: function isEmpty() {\n return !this.value();\n } // Internal helpers. //\n\n }, {\n key: \"textarea\",\n value: function textarea() {\n return $(this.textareaRef.current);\n }\n }, {\n key: \"controls\",\n value: function controls() {\n return $(this.controlsRef.current);\n }\n }, {\n key: \"handleInput\",\n value: function handleInput(evt) {\n this.value(evt.target.value);\n }\n /**\n * Hides or shows 'clear sequence' button.\n *\n * Rendering the 'clear sequence' button takes into account presence or\n * absence of a scrollbar.\n *\n * Called by `componentDidUpdate`.\n */\n\n }, {\n key: \"hideShowButton\",\n value: function hideShowButton() {\n if (!this.isEmpty()) {\n // Calculation below is based on -\n // http://chris-spittles.co.uk/jquery-calculate-scrollbar-width/\n // FIXME: can reflow be avoided here?\n var textareaNode = this.textarea()[0];\n var sequenceControlsRight = textareaNode.offsetWidth - textareaNode.clientWidth;\n this.controls().css('right', sequenceControlsRight + 17);\n this.controls().removeClass('hidden');\n } else {\n // FIXME: what are lines 1, 2, & 3 doing here?\n this.textarea().parent().removeClass('has-error');\n this.$sequenceFile = $('#sequence-file');\n this.$sequenceFile.empty();\n this.controls().addClass('hidden');\n }\n }\n /**\n * Put red border around textarea.\n */\n\n }, {\n key: \"indicateError\",\n value: function indicateError() {\n this.textarea().parent().addClass('has-error');\n }\n /**\n * Put normal blue border around textarea.\n */\n\n }, {\n key: \"indicateNormal\",\n value: function indicateNormal() {\n this.textarea().parent().removeClass('has-error');\n }\n /**\n * Returns type of the query sequence (nucleotide, protein, mixed).\n *\n * Query widget supports executing a callback when the query type changes.\n * Components interested in query type should register a callback instead\n * of directly calling this method.\n */\n\n }, {\n key: \"type\",\n value: function type() {\n var sequences = this.value().split(/>.*/);\n var type, tmp;\n\n for (var i = 0; i < sequences.length; i++) {\n tmp = this.guessSequenceType(sequences[i]); // could not guess the sequence type; try the next sequence\n\n if (!tmp) {\n continue;\n }\n\n if (!type) {\n // successfully guessed the type of atleast one sequence\n type = tmp;\n } else if (tmp !== type) {\n // user has mixed different type of sequences\n return 'mixed';\n }\n }\n\n return type;\n }\n /**\n * Guesses and returns the type of the given sequence (nucleotide,\n * protein).\n */\n\n }, {\n key: \"guessSequenceType\",\n value: function guessSequenceType(sequence) {\n // remove 'noisy' characters\n sequence = sequence.replace(/[^A-Z]/gi, ''); // non-letter characters\n\n sequence = sequence.replace(/[NX]/gi, ''); // ambiguous characters\n // can't determine the type of ultrashort queries\n\n if (sequence.length < 10) {\n return undefined;\n } // count the number of putative NA\n\n\n var putative_NA_count = 0;\n\n for (var i = 0; i < sequence.length; i++) {\n if (sequence[i].match(/[ACGTU]/i)) {\n putative_NA_count += 1;\n }\n }\n\n var threshold = 0.9 * sequence.length;\n return putative_NA_count > threshold ? 'nucleotide' : 'protein';\n }\n }, {\n key: \"notify\",\n value: function notify(type) {\n clearTimeout(this.notification_timeout);\n this.indicateNormal();\n $('.notifications .active').hide().removeClass('active');\n\n if (type) {\n $('#' + type + '-sequence-notification').show('drop', {\n direction: 'up'\n }).addClass('active');\n this.notification_timeout = setTimeout(function () {\n $('.notifications .active').hide('drop', {\n direction: 'up'\n }).removeClass('active');\n }, 5000);\n\n if (type === 'mixed') {\n this.indicateError();\n }\n }\n }\n }, {\n key: \"render\",\n value: function render() {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"col-md-12\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"div\", {\n className: \"sequence\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"textarea\", {\n id: \"sequence\",\n ref: this.textareaRef,\n className: \"form-control text-monospace\",\n name: \"sequence\",\n value: this.state.value,\n placeholder: \"Paste query sequence(s) or drag file containing query sequence(s) in FASTA format here ...\",\n spellCheck: \"false\",\n autoFocus: true,\n onChange: this.handleInput\n })\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"div\", {\n className: \"hidden\",\n style: {\n position: 'absolute',\n top: '4px',\n right: '19px'\n },\n ref: this.controlsRef,\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"button\", {\n type: \"button\",\n className: \"btn btn-sm btn-default\",\n id: \"btn-sequence-clear\",\n title: \"Clear query sequence(s).\",\n onClick: this.clear,\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"span\", {\n id: \"sequence-file\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"i\", {\n className: \"fa fa-times\"\n })]\n })\n })]\n });\n }\n }]);\n\n return SearchQueryWidget;\n}(react__WEBPACK_IMPORTED_MODULE_0__.Component);\n/**\n * Renders summary of all hits per query in a tabular form.\n */\n\nvar HitsTable = /*#__PURE__*/function (_Component3) {\n _inherits(HitsTable, _Component3);\n\n var _super3 = _createSuper(HitsTable);\n\n function HitsTable(props) {\n _classCallCheck(this, HitsTable);\n\n return _super3.call(this, props);\n }\n\n _createClass(HitsTable, [{\n key: \"render\",\n value: function render() {\n var hasName = underscore__WEBPACK_IMPORTED_MODULE_1__[\"default\"].every(this.props.query.hits, function (hit) {\n return hit.sciname !== '';\n }); // Width of sequence column is 55% when species name is not shown and\n // query coverage is.\n\n\n var seqwidth = 55; // If we are going to show species name, then reduce the width of\n // sequence column by the width of species column.\n\n if (hasName) seqwidth -= 15; // If we are not going to show query coverage (i.e. for imported XML),\n // then increase the width of sequence column by the width of coverage\n // column.\n\n if (this.props.imported_xml) seqwidth += 15;\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"table-hit-overview\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"h4\", {\n className: \"caption\",\n \"data-toggle\": \"collapse\",\n \"data-target\": '#Query_' + this.props.query.number + 'HT_' + this.props.query.number,\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"i\", {\n className: \"fa fa-minus-square-o\"\n }), \"\\xA0\", /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"span\", {\n children: \"Sequences producing significant alignments\"\n })]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"div\", {\n className: \"collapsed in\",\n id: 'Query_' + this.props.query.number + 'HT_' + this.props.query.number,\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"table\", {\n className: \"table table-hover table-condensed tabular-view \",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"thead\", {\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"tr\", {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n className: \"text-left\",\n children: \"#\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"\".concat(seqwidth, \"%\"),\n children: \"Similar sequences\"\n }), hasName && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"15%\",\n className: \"text-left\",\n children: \"Species\"\n }), !this.props.imported_xml && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"15%\",\n className: \"text-right\",\n children: \"Query coverage (%)\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"10%\",\n className: \"text-right\",\n children: \"Total score\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"10%\",\n className: \"text-right\",\n children: \"E value\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"10%\",\n className: \"text-right\",\n children: \"Identity (%)\"\n })]\n })\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"tbody\", {\n children: underscore__WEBPACK_IMPORTED_MODULE_1__[\"default\"].map(this.props.query.hits, underscore__WEBPACK_IMPORTED_MODULE_1__[\"default\"].bind(function (hit) {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"tr\", {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-left\",\n children: hit.number + '.'\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"nowrap-ellipsis\",\n title: \"\".concat(hit.id, \" \").concat(hit.title),\n \"data-toggle\": \"tooltip\",\n \"data-placement\": \"left\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"a\", {\n href: '#Query_' + this.props.query.number + '_hit_' + hit.number,\n className: \"btn-link\",\n children: [hit.id, \" \", hit.title]\n })\n }), hasName && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"nowrap-ellipsis\",\n title: hit.sciname,\n \"data-toggle\": \"tooltip\",\n \"data-placement\": \"top\",\n children: hit.sciname\n }), !this.props.imported_xml && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-right\",\n children: hit.qcovs\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-right\",\n children: hit.total_score\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-right\",\n children: _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].inExponential(hit.hsps[0].evalue)\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-right\",\n children: _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].inPercentage(hit.hsps[0].identity, hit.hsps[0].length)\n })]\n }, hit.number);\n }, this))\n })]\n })\n })]\n });\n }\n }]);\n\n return HitsTable;\n}(react__WEBPACK_IMPORTED_MODULE_0__.Component);\n\n//# sourceURL=webpack://SequenceServer/./public/js/query.js?"); +======= +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"ReportQuery\": () => (/* binding */ ReportQuery),\n/* harmony export */ \"SearchQueryWidget\": () => (/* binding */ SearchQueryWidget)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! underscore */ \"./node_modules/underscore/modules/index-all.js\");\n/* harmony import */ var _hits_overview__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./hits_overview */ \"./public/js/hits_overview.js\");\n/* harmony import */ var _length_distribution__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./length_distribution */ \"./public/js/length_distribution.js\");\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils */ \"./public/js/utils.js\");\n/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react/jsx-runtime */ \"./node_modules/react/jsx-runtime.js\");\n/* provided dependency */ var $ = __webpack_require__(/*! jquery */ \"./node_modules/jquery/dist/jquery.js\");\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, \"prototype\", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } else if (call !== void 0) { throw new TypeError(\"Derived constructors may only return object or undefined\"); } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n\n\n\n // length distribution of hits\n\n\n/**\n * Query component displays query defline, graphical overview, length\n * distribution, and hits table.\n */\n\n\n\nvar ReportQuery = /*#__PURE__*/function (_Component) {\n _inherits(ReportQuery, _Component);\n\n var _super = _createSuper(ReportQuery);\n\n function ReportQuery() {\n _classCallCheck(this, ReportQuery);\n\n return _super.apply(this, arguments);\n }\n\n _createClass(ReportQuery, [{\n key: \"shouldComponentUpdate\",\n value: // Each update cycle will cause all previous queries to be re-rendered.\n // We avoid that by implementing shouldComponentUpdate life-cycle hook.\n // The trick is to simply check if the components has recieved props\n // before.\n function shouldComponentUpdate() {\n // If the component has received props before, query property will\n // be set on it. If it is, we return false so that the component\n // is not re-rendered. If the query property is not set, we return\n // true: this must be the first time react is trying to render the\n // component.\n return !this.props.query;\n } // Kind of public API //\n\n /**\n * Returns the id of query.\n */\n\n }, {\n key: \"domID\",\n value: function domID() {\n return 'Query_' + this.props.query.number;\n }\n }, {\n key: \"queryLength\",\n value: function queryLength() {\n return this.props.query.length;\n }\n /**\n * Returns number of hits.\n */\n\n }, {\n key: \"numhits\",\n value: function numhits() {\n return this.props.query.hits.length;\n }\n }, {\n key: \"headerJSX\",\n value: function headerJSX() {\n var meta = \"length: \".concat(this.queryLength().toLocaleString());\n\n if (this.props.showQueryCrumbs) {\n meta = \"query \".concat(this.props.query.number, \", \") + meta;\n }\n\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"section-header\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"h3\", {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"strong\", {\n children: [\"Query=\\xA0\", this.props.query.id]\n }), \"\\xA0\", this.props.query.title]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"span\", {\n className: \"label label-reset pos-label\",\n children: meta\n })]\n });\n }\n }, {\n key: \"hitsListJSX\",\n value: function hitsListJSX() {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"section-content\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_hits_overview__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n query: this.props.query,\n program: this.props.program,\n collapsed: this.props.veryBig\n }, 'GO_' + this.props.query.number), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_length_distribution__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n query: this.props.query,\n algorithm: this.props.program,\n collapsed: \"true\"\n }, 'LD_' + this.props.query.id), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(HitsTable, {\n query: this.props.query,\n imported_xml: this.props.imported_xml\n }, 'HT_' + this.props.query.number)]\n });\n }\n }, {\n key: \"noHitsJSX\",\n value: function noHitsJSX() {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"div\", {\n className: \"section-content\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"strong\", {\n children: \" ****** No hits found ****** \"\n })\n });\n }\n }, {\n key: \"render\",\n value: function render() {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"resultn\",\n id: this.domID(),\n \"data-query-len\": this.props.query.length,\n \"data-algorithm\": this.props.program,\n children: [this.headerJSX(), this.numhits() && this.hitsListJSX() || this.noHitsJSX()]\n });\n }\n }]);\n\n return ReportQuery;\n}(react__WEBPACK_IMPORTED_MODULE_0__.Component);\n/**\n * Query widget for Search component.\n */\n\nvar SearchQueryWidget = /*#__PURE__*/function (_Component2) {\n _inherits(SearchQueryWidget, _Component2);\n\n var _super2 = _createSuper(SearchQueryWidget);\n\n function SearchQueryWidget(props) {\n var _this;\n\n _classCallCheck(this, SearchQueryWidget);\n\n _this = _super2.call(this, props);\n _this.state = {\n value: $('input#input_sequence').val() || ''\n };\n _this.value = _this.value.bind(_assertThisInitialized(_this));\n _this.clear = _this.clear.bind(_assertThisInitialized(_this));\n _this.focus = _this.focus.bind(_assertThisInitialized(_this));\n _this.isEmpty = _this.isEmpty.bind(_assertThisInitialized(_this));\n _this.textarea = _this.textarea.bind(_assertThisInitialized(_this));\n _this.controls = _this.controls.bind(_assertThisInitialized(_this));\n _this.handleInput = _this.handleInput.bind(_assertThisInitialized(_this));\n _this.hideShowButton = _this.hideShowButton.bind(_assertThisInitialized(_this));\n _this.indicateError = _this.indicateError.bind(_assertThisInitialized(_this));\n _this.indicateNormal = _this.indicateNormal.bind(_assertThisInitialized(_this));\n _this.type = _this.type.bind(_assertThisInitialized(_this));\n _this.guessSequenceType = _this.guessSequenceType.bind(_assertThisInitialized(_this));\n _this.notify = _this.notify.bind(_assertThisInitialized(_this));\n _this.textareaRef = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createRef)();\n _this.controlsRef = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createRef)();\n return _this;\n } // LIFECYCLE Methods\n\n\n _createClass(SearchQueryWidget, [{\n key: \"componentDidMount\",\n value: function componentDidMount() {\n $('body').click(function () {\n $('.notifications .active').hide('drop', {\n direction: 'up'\n }).removeClass('active');\n });\n }\n }, {\n key: \"componentDidUpdate\",\n value: function componentDidUpdate() {\n this.hideShowButton();\n var type = this.type();\n\n if (!type || type !== this._type) {\n this._type = type;\n this.notify(type);\n this.props.onSequenceTypeChanged(type);\n }\n } // Kind of public API. //\n\n /**\n * Returns query sequence if no argument is provided (or null or undefined\n * is provided as argument). Otherwise, sets query sequenced to the given\n * value and returns `this`.\n *\n * Default/initial state of query sequence is an empty string. Caller must\n * explicitly provide empty string as argument to \"reset\" query sequence.\n */\n\n }, {\n key: \"value\",\n value: function value(val) {\n if (val == null) {\n // i.e., val is null or undefined\n return this.state.value;\n } else {\n this.setState({\n value: val\n });\n return this;\n }\n }\n /**\n * Clears textarea. Returns `this`.\n *\n * Clearing textarea also causes it to be focussed.\n */\n\n }, {\n key: \"clear\",\n value: function clear() {\n return this.value('').focus();\n }\n /**\n * Focuses textarea. Returns `this`.\n */\n\n }, {\n key: \"focus\",\n value: function focus() {\n this.textarea().focus();\n return this;\n }\n /**\n * Returns true if query is absent ('', undefined, null), false otherwise.\n */\n\n }, {\n key: \"isEmpty\",\n value: function isEmpty() {\n return !this.value();\n } // Internal helpers. //\n\n }, {\n key: \"textarea\",\n value: function textarea() {\n return $(this.textareaRef.current);\n }\n }, {\n key: \"controls\",\n value: function controls() {\n return $(this.controlsRef.current);\n }\n }, {\n key: \"handleInput\",\n value: function handleInput(evt) {\n this.value(evt.target.value);\n }\n /**\n * Hides or shows 'clear sequence' button.\n *\n * Rendering the 'clear sequence' button takes into account presence or\n * absence of a scrollbar.\n *\n * Called by `componentDidUpdate`.\n */\n\n }, {\n key: \"hideShowButton\",\n value: function hideShowButton() {\n if (!this.isEmpty()) {\n // Calculation below is based on -\n // http://chris-spittles.co.uk/jquery-calculate-scrollbar-width/\n // FIXME: can reflow be avoided here?\n var textareaNode = this.textarea()[0];\n var sequenceControlsRight = textareaNode.offsetWidth - textareaNode.clientWidth;\n this.controls().css('right', sequenceControlsRight + 17);\n this.controls().removeClass('hidden');\n } else {\n // FIXME: what are lines 1, 2, & 3 doing here?\n this.textarea().parent().removeClass('has-error');\n this.$sequenceFile = $('#sequence-file');\n this.$sequenceFile.empty();\n this.controls().addClass('hidden');\n }\n }\n /**\n * Put red border around textarea.\n */\n\n }, {\n key: \"indicateError\",\n value: function indicateError() {\n this.textarea().parent().addClass('has-error');\n }\n /**\n * Put normal blue border around textarea.\n */\n\n }, {\n key: \"indicateNormal\",\n value: function indicateNormal() {\n this.textarea().parent().removeClass('has-error');\n }\n /**\n * Returns type of the query sequence (nucleotide, protein, mixed).\n *\n * Query widget supports executing a callback when the query type changes.\n * Components interested in query type should register a callback instead\n * of directly calling this method.\n */\n\n }, {\n key: \"type\",\n value: function type() {\n var sequences = this.value().split(/>.*/);\n var type, tmp;\n\n for (var i = 0; i < sequences.length; i++) {\n tmp = this.guessSequenceType(sequences[i]); // could not guess the sequence type; try the next sequence\n\n if (!tmp) {\n continue;\n }\n\n if (!type) {\n // successfully guessed the type of atleast one sequence\n type = tmp;\n } else if (tmp !== type) {\n // user has mixed different type of sequences\n return 'mixed';\n }\n }\n\n return type;\n }\n /**\n * Guesses and returns the type of the given sequence (nucleotide,\n * protein).\n */\n\n }, {\n key: \"guessSequenceType\",\n value: function guessSequenceType(sequence) {\n // remove 'noisy' characters\n sequence = sequence.replace(/[^A-Z]/gi, ''); // non-letter characters\n\n sequence = sequence.replace(/[NX]/gi, ''); // ambiguous characters\n // can't determine the type of ultrashort queries\n\n if (sequence.length < 10) {\n return undefined;\n } // count the number of putative NA\n\n\n var putative_NA_count = 0;\n\n for (var i = 0; i < sequence.length; i++) {\n if (sequence[i].match(/[ACGTU]/i)) {\n putative_NA_count += 1;\n }\n }\n\n var threshold = 0.9 * sequence.length;\n return putative_NA_count > threshold ? 'nucleotide' : 'protein';\n }\n }, {\n key: \"notify\",\n value: function notify(type) {\n clearTimeout(this.notification_timeout);\n this.indicateNormal();\n $('.notifications .active').hide().removeClass('active');\n\n if (type) {\n $('#' + type + '-sequence-notification').show('drop', {\n direction: 'up'\n }).addClass('active'); //hide notification after 5s only for non-mixed sequences\n\n if (type !== 'mixed') {\n this.notification_timeout = setTimeout(function () {\n $('.notifications .active').hide('drop', {\n direction: 'up'\n }).removeClass('active');\n }, 5000);\n } else {\n this.indicateError();\n }\n }\n }\n }, {\n key: \"render\",\n value: function render() {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"col-md-12\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"div\", {\n className: \"sequence\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"textarea\", {\n id: \"sequence\",\n ref: this.textareaRef,\n className: \"form-control text-monospace\",\n name: \"sequence\",\n value: this.state.value,\n placeholder: \"Paste query sequence(s) or drag file containing query sequence(s) in FASTA format here ...\",\n spellCheck: \"false\",\n autoFocus: true,\n onChange: this.handleInput\n })\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"div\", {\n className: \"hidden\",\n style: {\n position: 'absolute',\n top: '4px',\n right: '19px'\n },\n ref: this.controlsRef,\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"button\", {\n type: \"button\",\n className: \"btn btn-sm btn-default\",\n id: \"btn-sequence-clear\",\n title: \"Clear query sequence(s).\",\n onClick: this.clear,\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"span\", {\n id: \"sequence-file\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"i\", {\n className: \"fa fa-times\"\n })]\n })\n })]\n });\n }\n }]);\n\n return SearchQueryWidget;\n}(react__WEBPACK_IMPORTED_MODULE_0__.Component);\n/**\n * Renders summary of all hits per query in a tabular form.\n */\n\nvar HitsTable = /*#__PURE__*/function (_Component3) {\n _inherits(HitsTable, _Component3);\n\n var _super3 = _createSuper(HitsTable);\n\n function HitsTable(props) {\n _classCallCheck(this, HitsTable);\n\n return _super3.call(this, props);\n }\n\n _createClass(HitsTable, [{\n key: \"render\",\n value: function render() {\n var hasName = underscore__WEBPACK_IMPORTED_MODULE_1__[\"default\"].every(this.props.query.hits, function (hit) {\n return hit.sciname !== '';\n }); // Width of sequence column is 55% when species name is not shown and\n // query coverage is.\n\n\n var seqwidth = 55; // If we are going to show species name, then reduce the width of\n // sequence column by the width of species column.\n\n if (hasName) seqwidth -= 15; // If we are not going to show query coverage (i.e. for imported XML),\n // then increase the width of sequence column by the width of coverage\n // column.\n\n if (this.props.imported_xml) seqwidth += 15;\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"table-hit-overview\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"h4\", {\n className: \"caption\",\n \"data-toggle\": \"collapse\",\n \"data-target\": '#Query_' + this.props.query.number + 'HT_' + this.props.query.number,\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"i\", {\n className: \"fa fa-minus-square-o\"\n }), \"\\xA0\", /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"span\", {\n children: \"Sequences producing significant alignments\"\n })]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"div\", {\n className: \"collapsed in\",\n id: 'Query_' + this.props.query.number + 'HT_' + this.props.query.number,\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"table\", {\n className: \"table table-hover table-condensed tabular-view \",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"thead\", {\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"tr\", {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n className: \"text-left\",\n children: \"#\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"\".concat(seqwidth, \"%\"),\n children: \"Similar sequences\"\n }), hasName && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"15%\",\n className: \"text-left\",\n children: \"Species\"\n }), !this.props.imported_xml && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"15%\",\n className: \"text-right\",\n children: \"Query coverage (%)\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"10%\",\n className: \"text-right\",\n children: \"Total score\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"10%\",\n className: \"text-right\",\n children: \"E value\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"10%\",\n className: \"text-right\",\n children: \"Identity (%)\"\n })]\n })\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"tbody\", {\n children: underscore__WEBPACK_IMPORTED_MODULE_1__[\"default\"].map(this.props.query.hits, underscore__WEBPACK_IMPORTED_MODULE_1__[\"default\"].bind(function (hit) {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"tr\", {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-left\",\n children: hit.number + '.'\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"nowrap-ellipsis\",\n title: \"\".concat(hit.id, \" \").concat(hit.title),\n \"data-toggle\": \"tooltip\",\n \"data-placement\": \"left\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"a\", {\n href: '#Query_' + this.props.query.number + '_hit_' + hit.number,\n className: \"btn-link\",\n children: [hit.id, \" \", hit.title]\n })\n }), hasName && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"nowrap-ellipsis\",\n title: hit.sciname,\n \"data-toggle\": \"tooltip\",\n \"data-placement\": \"top\",\n children: hit.sciname\n }), !this.props.imported_xml && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-right\",\n children: hit.qcovs\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-right\",\n children: hit.total_score\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-right\",\n children: _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].inExponential(hit.hsps[0].evalue)\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-right\",\n children: _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].inPercentage(hit.hsps[0].identity, hit.hsps[0].length)\n })]\n }, hit.number);\n }, this))\n })]\n })\n })]\n });\n }\n }]);\n\n return HitsTable;\n}(react__WEBPACK_IMPORTED_MODULE_0__.Component);\n\n//# sourceURL=webpack://SequenceServer/./public/js/query.js?"); +>>>>>>> d800bb4 (only hide notification after timeout for non-mixed sequences) /***/ }), From e67929a221bb167d31688a301c3640982ae2dde1 Mon Sep 17 00:00:00 2001 From: Emmanuel Date: Fri, 9 Sep 2022 19:03:21 +0100 Subject: [PATCH 2/2] preserve sticky notification on click of any part of the window --- public/js/query.js | 6 ------ public/sequenceserver-report.min.js | 2 +- public/sequenceserver-search.min.js | 6 +----- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/public/js/query.js b/public/js/query.js index b0326a18d..f614fc8f3 100644 --- a/public/js/query.js +++ b/public/js/query.js @@ -111,12 +111,6 @@ export class SearchQueryWidget extends Component { // LIFECYCLE Methods - componentDidMount() { - $('body').click(function () { - $('.notifications .active').hide('drop', { direction: 'up' }).removeClass('active'); - }); - } - componentDidUpdate() { this.hideShowButton(); var type = this.type(); diff --git a/public/sequenceserver-report.min.js b/public/sequenceserver-report.min.js index 2ae538910..29898dee0 100644 --- a/public/sequenceserver-report.min.js +++ b/public/sequenceserver-report.min.js @@ -170,7 +170,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"ReportQuery\": () => (/* binding */ ReportQuery),\n/* harmony export */ \"SearchQueryWidget\": () => (/* binding */ SearchQueryWidget)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! underscore */ \"./node_modules/underscore/modules/index-all.js\");\n/* harmony import */ var _hits_overview__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./hits_overview */ \"./public/js/hits_overview.js\");\n/* harmony import */ var _length_distribution__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./length_distribution */ \"./public/js/length_distribution.js\");\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils */ \"./public/js/utils.js\");\n/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react/jsx-runtime */ \"./node_modules/react/jsx-runtime.js\");\n/* provided dependency */ var $ = __webpack_require__(/*! jquery */ \"./node_modules/jquery/dist/jquery.js\");\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, \"prototype\", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } else if (call !== void 0) { throw new TypeError(\"Derived constructors may only return object or undefined\"); } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n\n\n\n // length distribution of hits\n\n\n/**\n * Query component displays query defline, graphical overview, length\n * distribution, and hits table.\n */\n\n\n\nvar ReportQuery = /*#__PURE__*/function (_Component) {\n _inherits(ReportQuery, _Component);\n\n var _super = _createSuper(ReportQuery);\n\n function ReportQuery() {\n _classCallCheck(this, ReportQuery);\n\n return _super.apply(this, arguments);\n }\n\n _createClass(ReportQuery, [{\n key: \"shouldComponentUpdate\",\n value: // Each update cycle will cause all previous queries to be re-rendered.\n // We avoid that by implementing shouldComponentUpdate life-cycle hook.\n // The trick is to simply check if the components has recieved props\n // before.\n function shouldComponentUpdate() {\n // If the component has received props before, query property will\n // be set on it. If it is, we return false so that the component\n // is not re-rendered. If the query property is not set, we return\n // true: this must be the first time react is trying to render the\n // component.\n return !this.props.query;\n } // Kind of public API //\n\n /**\n * Returns the id of query.\n */\n\n }, {\n key: \"domID\",\n value: function domID() {\n return 'Query_' + this.props.query.number;\n }\n }, {\n key: \"queryLength\",\n value: function queryLength() {\n return this.props.query.length;\n }\n /**\n * Returns number of hits.\n */\n\n }, {\n key: \"numhits\",\n value: function numhits() {\n return this.props.query.hits.length;\n }\n }, {\n key: \"headerJSX\",\n value: function headerJSX() {\n var meta = \"length: \".concat(this.queryLength().toLocaleString());\n\n if (this.props.showQueryCrumbs) {\n meta = \"query \".concat(this.props.query.number, \", \") + meta;\n }\n\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"section-header\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"h3\", {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"strong\", {\n children: [\"Query=\\xA0\", this.props.query.id]\n }), \"\\xA0\", this.props.query.title]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"span\", {\n className: \"label label-reset pos-label\",\n children: meta\n })]\n });\n }\n }, {\n key: \"hitsListJSX\",\n value: function hitsListJSX() {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"section-content\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_hits_overview__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n query: this.props.query,\n program: this.props.program,\n collapsed: this.props.veryBig\n }, 'GO_' + this.props.query.number), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_length_distribution__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n query: this.props.query,\n algorithm: this.props.program,\n collapsed: \"true\"\n }, 'LD_' + this.props.query.id), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(HitsTable, {\n query: this.props.query,\n imported_xml: this.props.imported_xml\n }, 'HT_' + this.props.query.number)]\n });\n }\n }, {\n key: \"noHitsJSX\",\n value: function noHitsJSX() {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"div\", {\n className: \"section-content\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"strong\", {\n children: \" ****** No hits found ****** \"\n })\n });\n }\n }, {\n key: \"render\",\n value: function render() {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"resultn\",\n id: this.domID(),\n \"data-query-len\": this.props.query.length,\n \"data-algorithm\": this.props.program,\n children: [this.headerJSX(), this.numhits() && this.hitsListJSX() || this.noHitsJSX()]\n });\n }\n }]);\n\n return ReportQuery;\n}(react__WEBPACK_IMPORTED_MODULE_0__.Component);\n/**\n * Query widget for Search component.\n */\n\nvar SearchQueryWidget = /*#__PURE__*/function (_Component2) {\n _inherits(SearchQueryWidget, _Component2);\n\n var _super2 = _createSuper(SearchQueryWidget);\n\n function SearchQueryWidget(props) {\n var _this;\n\n _classCallCheck(this, SearchQueryWidget);\n\n _this = _super2.call(this, props);\n _this.state = {\n value: $('input#input_sequence').val() || ''\n };\n _this.value = _this.value.bind(_assertThisInitialized(_this));\n _this.clear = _this.clear.bind(_assertThisInitialized(_this));\n _this.focus = _this.focus.bind(_assertThisInitialized(_this));\n _this.isEmpty = _this.isEmpty.bind(_assertThisInitialized(_this));\n _this.textarea = _this.textarea.bind(_assertThisInitialized(_this));\n _this.controls = _this.controls.bind(_assertThisInitialized(_this));\n _this.handleInput = _this.handleInput.bind(_assertThisInitialized(_this));\n _this.hideShowButton = _this.hideShowButton.bind(_assertThisInitialized(_this));\n _this.indicateError = _this.indicateError.bind(_assertThisInitialized(_this));\n _this.indicateNormal = _this.indicateNormal.bind(_assertThisInitialized(_this));\n _this.type = _this.type.bind(_assertThisInitialized(_this));\n _this.guessSequenceType = _this.guessSequenceType.bind(_assertThisInitialized(_this));\n _this.notify = _this.notify.bind(_assertThisInitialized(_this));\n _this.textareaRef = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createRef)();\n _this.controlsRef = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createRef)();\n return _this;\n } // LIFECYCLE Methods\n\n\n _createClass(SearchQueryWidget, [{\n key: \"componentDidMount\",\n value: function componentDidMount() {\n $('body').click(function () {\n $('.notifications .active').hide('drop', {\n direction: 'up'\n }).removeClass('active');\n });\n }\n }, {\n key: \"componentDidUpdate\",\n value: function componentDidUpdate() {\n this.hideShowButton();\n var type = this.type();\n\n if (!type || type !== this._type) {\n this._type = type;\n this.notify(type);\n this.props.onSequenceTypeChanged(type);\n }\n } // Kind of public API. //\n\n /**\n * Returns query sequence if no argument is provided (or null or undefined\n * is provided as argument). Otherwise, sets query sequenced to the given\n * value and returns `this`.\n *\n * Default/initial state of query sequence is an empty string. Caller must\n * explicitly provide empty string as argument to \"reset\" query sequence.\n */\n\n }, {\n key: \"value\",\n value: function value(val) {\n if (val == null) {\n // i.e., val is null or undefined\n return this.state.value;\n } else {\n this.setState({\n value: val\n });\n return this;\n }\n }\n /**\n * Clears textarea. Returns `this`.\n *\n * Clearing textarea also causes it to be focussed.\n */\n\n }, {\n key: \"clear\",\n value: function clear() {\n return this.value('').focus();\n }\n /**\n * Focuses textarea. Returns `this`.\n */\n\n }, {\n key: \"focus\",\n value: function focus() {\n this.textarea().focus();\n return this;\n }\n /**\n * Returns true if query is absent ('', undefined, null), false otherwise.\n */\n\n }, {\n key: \"isEmpty\",\n value: function isEmpty() {\n return !this.value();\n } // Internal helpers. //\n\n }, {\n key: \"textarea\",\n value: function textarea() {\n return $(this.textareaRef.current);\n }\n }, {\n key: \"controls\",\n value: function controls() {\n return $(this.controlsRef.current);\n }\n }, {\n key: \"handleInput\",\n value: function handleInput(evt) {\n this.value(evt.target.value);\n }\n /**\n * Hides or shows 'clear sequence' button.\n *\n * Rendering the 'clear sequence' button takes into account presence or\n * absence of a scrollbar.\n *\n * Called by `componentDidUpdate`.\n */\n\n }, {\n key: \"hideShowButton\",\n value: function hideShowButton() {\n if (!this.isEmpty()) {\n // Calculation below is based on -\n // http://chris-spittles.co.uk/jquery-calculate-scrollbar-width/\n // FIXME: can reflow be avoided here?\n var textareaNode = this.textarea()[0];\n var sequenceControlsRight = textareaNode.offsetWidth - textareaNode.clientWidth;\n this.controls().css('right', sequenceControlsRight + 17);\n this.controls().removeClass('hidden');\n } else {\n // FIXME: what are lines 1, 2, & 3 doing here?\n this.textarea().parent().removeClass('has-error');\n this.$sequenceFile = $('#sequence-file');\n this.$sequenceFile.empty();\n this.controls().addClass('hidden');\n }\n }\n /**\n * Put red border around textarea.\n */\n\n }, {\n key: \"indicateError\",\n value: function indicateError() {\n this.textarea().parent().addClass('has-error');\n }\n /**\n * Put normal blue border around textarea.\n */\n\n }, {\n key: \"indicateNormal\",\n value: function indicateNormal() {\n this.textarea().parent().removeClass('has-error');\n }\n /**\n * Returns type of the query sequence (nucleotide, protein, mixed).\n *\n * Query widget supports executing a callback when the query type changes.\n * Components interested in query type should register a callback instead\n * of directly calling this method.\n */\n\n }, {\n key: \"type\",\n value: function type() {\n var sequences = this.value().split(/>.*/);\n var type, tmp;\n\n for (var i = 0; i < sequences.length; i++) {\n tmp = this.guessSequenceType(sequences[i]); // could not guess the sequence type; try the next sequence\n\n if (!tmp) {\n continue;\n }\n\n if (!type) {\n // successfully guessed the type of atleast one sequence\n type = tmp;\n } else if (tmp !== type) {\n // user has mixed different type of sequences\n return 'mixed';\n }\n }\n\n return type;\n }\n /**\n * Guesses and returns the type of the given sequence (nucleotide,\n * protein).\n */\n\n }, {\n key: \"guessSequenceType\",\n value: function guessSequenceType(sequence) {\n // remove 'noisy' characters\n sequence = sequence.replace(/[^A-Z]/gi, ''); // non-letter characters\n\n sequence = sequence.replace(/[NX]/gi, ''); // ambiguous characters\n // can't determine the type of ultrashort queries\n\n if (sequence.length < 10) {\n return undefined;\n } // count the number of putative NA\n\n\n var putative_NA_count = 0;\n\n for (var i = 0; i < sequence.length; i++) {\n if (sequence[i].match(/[ACGTU]/i)) {\n putative_NA_count += 1;\n }\n }\n\n var threshold = 0.9 * sequence.length;\n return putative_NA_count > threshold ? 'nucleotide' : 'protein';\n }\n }, {\n key: \"notify\",\n value: function notify(type) {\n clearTimeout(this.notification_timeout);\n this.indicateNormal();\n $('.notifications .active').hide().removeClass('active');\n\n if (type) {\n $('#' + type + '-sequence-notification').show('drop', {\n direction: 'up'\n }).addClass('active');\n this.notification_timeout = setTimeout(function () {\n $('.notifications .active').hide('drop', {\n direction: 'up'\n }).removeClass('active');\n }, 5000);\n\n if (type === 'mixed') {\n this.indicateError();\n }\n }\n }\n }, {\n key: \"render\",\n value: function render() {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"col-md-12\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"div\", {\n className: \"sequence\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"textarea\", {\n id: \"sequence\",\n ref: this.textareaRef,\n className: \"form-control text-monospace\",\n name: \"sequence\",\n value: this.state.value,\n placeholder: \"Paste query sequence(s) or drag file containing query sequence(s) in FASTA format here ...\",\n spellCheck: \"false\",\n autoFocus: true,\n onChange: this.handleInput\n })\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"div\", {\n className: \"hidden\",\n style: {\n position: 'absolute',\n top: '4px',\n right: '19px'\n },\n ref: this.controlsRef,\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"button\", {\n type: \"button\",\n className: \"btn btn-sm btn-default\",\n id: \"btn-sequence-clear\",\n title: \"Clear query sequence(s).\",\n onClick: this.clear,\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"span\", {\n id: \"sequence-file\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"i\", {\n className: \"fa fa-times\"\n })]\n })\n })]\n });\n }\n }]);\n\n return SearchQueryWidget;\n}(react__WEBPACK_IMPORTED_MODULE_0__.Component);\n/**\n * Renders summary of all hits per query in a tabular form.\n */\n\nvar HitsTable = /*#__PURE__*/function (_Component3) {\n _inherits(HitsTable, _Component3);\n\n var _super3 = _createSuper(HitsTable);\n\n function HitsTable(props) {\n _classCallCheck(this, HitsTable);\n\n return _super3.call(this, props);\n }\n\n _createClass(HitsTable, [{\n key: \"render\",\n value: function render() {\n var hasName = underscore__WEBPACK_IMPORTED_MODULE_1__[\"default\"].every(this.props.query.hits, function (hit) {\n return hit.sciname !== '';\n }); // Width of sequence column is 55% when species name is not shown and\n // query coverage is.\n\n\n var seqwidth = 55; // If we are going to show species name, then reduce the width of\n // sequence column by the width of species column.\n\n if (hasName) seqwidth -= 15; // If we are not going to show query coverage (i.e. for imported XML),\n // then increase the width of sequence column by the width of coverage\n // column.\n\n if (this.props.imported_xml) seqwidth += 15;\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"table-hit-overview\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"h4\", {\n className: \"caption\",\n \"data-toggle\": \"collapse\",\n \"data-target\": '#Query_' + this.props.query.number + 'HT_' + this.props.query.number,\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"i\", {\n className: \"fa fa-minus-square-o\"\n }), \"\\xA0\", /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"span\", {\n children: \"Sequences producing significant alignments\"\n })]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"div\", {\n className: \"collapsed in\",\n id: 'Query_' + this.props.query.number + 'HT_' + this.props.query.number,\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"table\", {\n className: \"table table-hover table-condensed tabular-view \",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"thead\", {\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"tr\", {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n className: \"text-left\",\n children: \"#\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"\".concat(seqwidth, \"%\"),\n children: \"Similar sequences\"\n }), hasName && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"15%\",\n className: \"text-left\",\n children: \"Species\"\n }), !this.props.imported_xml && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"15%\",\n className: \"text-right\",\n children: \"Query coverage (%)\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"10%\",\n className: \"text-right\",\n children: \"Total score\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"10%\",\n className: \"text-right\",\n children: \"E value\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"10%\",\n className: \"text-right\",\n children: \"Identity (%)\"\n })]\n })\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"tbody\", {\n children: underscore__WEBPACK_IMPORTED_MODULE_1__[\"default\"].map(this.props.query.hits, underscore__WEBPACK_IMPORTED_MODULE_1__[\"default\"].bind(function (hit) {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"tr\", {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-left\",\n children: hit.number + '.'\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"nowrap-ellipsis\",\n title: \"\".concat(hit.id, \" \").concat(hit.title),\n \"data-toggle\": \"tooltip\",\n \"data-placement\": \"left\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"a\", {\n href: '#Query_' + this.props.query.number + '_hit_' + hit.number,\n className: \"btn-link\",\n children: [hit.id, \" \", hit.title]\n })\n }), hasName && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"nowrap-ellipsis\",\n title: hit.sciname,\n \"data-toggle\": \"tooltip\",\n \"data-placement\": \"top\",\n children: hit.sciname\n }), !this.props.imported_xml && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-right\",\n children: hit.qcovs\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-right\",\n children: hit.total_score\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-right\",\n children: _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].inExponential(hit.hsps[0].evalue)\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-right\",\n children: _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].inPercentage(hit.hsps[0].identity, hit.hsps[0].length)\n })]\n }, hit.number);\n }, this))\n })]\n })\n })]\n });\n }\n }]);\n\n return HitsTable;\n}(react__WEBPACK_IMPORTED_MODULE_0__.Component);\n\n//# sourceURL=webpack://SequenceServer/./public/js/query.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"ReportQuery\": () => (/* binding */ ReportQuery),\n/* harmony export */ \"SearchQueryWidget\": () => (/* binding */ SearchQueryWidget)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! underscore */ \"./node_modules/underscore/modules/index-all.js\");\n/* harmony import */ var _hits_overview__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./hits_overview */ \"./public/js/hits_overview.js\");\n/* harmony import */ var _length_distribution__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./length_distribution */ \"./public/js/length_distribution.js\");\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils */ \"./public/js/utils.js\");\n/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react/jsx-runtime */ \"./node_modules/react/jsx-runtime.js\");\n/* provided dependency */ var $ = __webpack_require__(/*! jquery */ \"./node_modules/jquery/dist/jquery.js\");\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, \"prototype\", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } else if (call !== void 0) { throw new TypeError(\"Derived constructors may only return object or undefined\"); } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n\n\n\n // length distribution of hits\n\n\n/**\n * Query component displays query defline, graphical overview, length\n * distribution, and hits table.\n */\n\n\n\nvar ReportQuery = /*#__PURE__*/function (_Component) {\n _inherits(ReportQuery, _Component);\n\n var _super = _createSuper(ReportQuery);\n\n function ReportQuery() {\n _classCallCheck(this, ReportQuery);\n\n return _super.apply(this, arguments);\n }\n\n _createClass(ReportQuery, [{\n key: \"shouldComponentUpdate\",\n value: // Each update cycle will cause all previous queries to be re-rendered.\n // We avoid that by implementing shouldComponentUpdate life-cycle hook.\n // The trick is to simply check if the components has recieved props\n // before.\n function shouldComponentUpdate() {\n // If the component has received props before, query property will\n // be set on it. If it is, we return false so that the component\n // is not re-rendered. If the query property is not set, we return\n // true: this must be the first time react is trying to render the\n // component.\n return !this.props.query;\n } // Kind of public API //\n\n /**\n * Returns the id of query.\n */\n\n }, {\n key: \"domID\",\n value: function domID() {\n return 'Query_' + this.props.query.number;\n }\n }, {\n key: \"queryLength\",\n value: function queryLength() {\n return this.props.query.length;\n }\n /**\n * Returns number of hits.\n */\n\n }, {\n key: \"numhits\",\n value: function numhits() {\n return this.props.query.hits.length;\n }\n }, {\n key: \"headerJSX\",\n value: function headerJSX() {\n var meta = \"length: \".concat(this.queryLength().toLocaleString());\n\n if (this.props.showQueryCrumbs) {\n meta = \"query \".concat(this.props.query.number, \", \") + meta;\n }\n\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"section-header\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"h3\", {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"strong\", {\n children: [\"Query=\\xA0\", this.props.query.id]\n }), \"\\xA0\", this.props.query.title]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"span\", {\n className: \"label label-reset pos-label\",\n children: meta\n })]\n });\n }\n }, {\n key: \"hitsListJSX\",\n value: function hitsListJSX() {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"section-content\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_hits_overview__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n query: this.props.query,\n program: this.props.program,\n collapsed: this.props.veryBig\n }, 'GO_' + this.props.query.number), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_length_distribution__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n query: this.props.query,\n algorithm: this.props.program,\n collapsed: \"true\"\n }, 'LD_' + this.props.query.id), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(HitsTable, {\n query: this.props.query,\n imported_xml: this.props.imported_xml\n }, 'HT_' + this.props.query.number)]\n });\n }\n }, {\n key: \"noHitsJSX\",\n value: function noHitsJSX() {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"div\", {\n className: \"section-content\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"strong\", {\n children: \" ****** No hits found ****** \"\n })\n });\n }\n }, {\n key: \"render\",\n value: function render() {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"resultn\",\n id: this.domID(),\n \"data-query-len\": this.props.query.length,\n \"data-algorithm\": this.props.program,\n children: [this.headerJSX(), this.numhits() && this.hitsListJSX() || this.noHitsJSX()]\n });\n }\n }]);\n\n return ReportQuery;\n}(react__WEBPACK_IMPORTED_MODULE_0__.Component);\n/**\n * Query widget for Search component.\n */\n\nvar SearchQueryWidget = /*#__PURE__*/function (_Component2) {\n _inherits(SearchQueryWidget, _Component2);\n\n var _super2 = _createSuper(SearchQueryWidget);\n\n function SearchQueryWidget(props) {\n var _this;\n\n _classCallCheck(this, SearchQueryWidget);\n\n _this = _super2.call(this, props);\n _this.state = {\n value: $('input#input_sequence').val() || ''\n };\n _this.value = _this.value.bind(_assertThisInitialized(_this));\n _this.clear = _this.clear.bind(_assertThisInitialized(_this));\n _this.focus = _this.focus.bind(_assertThisInitialized(_this));\n _this.isEmpty = _this.isEmpty.bind(_assertThisInitialized(_this));\n _this.textarea = _this.textarea.bind(_assertThisInitialized(_this));\n _this.controls = _this.controls.bind(_assertThisInitialized(_this));\n _this.handleInput = _this.handleInput.bind(_assertThisInitialized(_this));\n _this.hideShowButton = _this.hideShowButton.bind(_assertThisInitialized(_this));\n _this.indicateError = _this.indicateError.bind(_assertThisInitialized(_this));\n _this.indicateNormal = _this.indicateNormal.bind(_assertThisInitialized(_this));\n _this.type = _this.type.bind(_assertThisInitialized(_this));\n _this.guessSequenceType = _this.guessSequenceType.bind(_assertThisInitialized(_this));\n _this.notify = _this.notify.bind(_assertThisInitialized(_this));\n _this.textareaRef = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createRef)();\n _this.controlsRef = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createRef)();\n return _this;\n } // LIFECYCLE Methods\n\n\n _createClass(SearchQueryWidget, [{\n key: \"componentDidUpdate\",\n value: function componentDidUpdate() {\n this.hideShowButton();\n var type = this.type();\n\n if (!type || type !== this._type) {\n this._type = type;\n this.notify(type);\n this.props.onSequenceTypeChanged(type);\n }\n } // Kind of public API. //\n\n /**\n * Returns query sequence if no argument is provided (or null or undefined\n * is provided as argument). Otherwise, sets query sequenced to the given\n * value and returns `this`.\n *\n * Default/initial state of query sequence is an empty string. Caller must\n * explicitly provide empty string as argument to \"reset\" query sequence.\n */\n\n }, {\n key: \"value\",\n value: function value(val) {\n if (val == null) {\n // i.e., val is null or undefined\n return this.state.value;\n } else {\n this.setState({\n value: val\n });\n return this;\n }\n }\n /**\n * Clears textarea. Returns `this`.\n *\n * Clearing textarea also causes it to be focussed.\n */\n\n }, {\n key: \"clear\",\n value: function clear() {\n return this.value('').focus();\n }\n /**\n * Focuses textarea. Returns `this`.\n */\n\n }, {\n key: \"focus\",\n value: function focus() {\n this.textarea().focus();\n return this;\n }\n /**\n * Returns true if query is absent ('', undefined, null), false otherwise.\n */\n\n }, {\n key: \"isEmpty\",\n value: function isEmpty() {\n return !this.value();\n } // Internal helpers. //\n\n }, {\n key: \"textarea\",\n value: function textarea() {\n return $(this.textareaRef.current);\n }\n }, {\n key: \"controls\",\n value: function controls() {\n return $(this.controlsRef.current);\n }\n }, {\n key: \"handleInput\",\n value: function handleInput(evt) {\n this.value(evt.target.value);\n }\n /**\n * Hides or shows 'clear sequence' button.\n *\n * Rendering the 'clear sequence' button takes into account presence or\n * absence of a scrollbar.\n *\n * Called by `componentDidUpdate`.\n */\n\n }, {\n key: \"hideShowButton\",\n value: function hideShowButton() {\n if (!this.isEmpty()) {\n // Calculation below is based on -\n // http://chris-spittles.co.uk/jquery-calculate-scrollbar-width/\n // FIXME: can reflow be avoided here?\n var textareaNode = this.textarea()[0];\n var sequenceControlsRight = textareaNode.offsetWidth - textareaNode.clientWidth;\n this.controls().css('right', sequenceControlsRight + 17);\n this.controls().removeClass('hidden');\n } else {\n // FIXME: what are lines 1, 2, & 3 doing here?\n this.textarea().parent().removeClass('has-error');\n this.$sequenceFile = $('#sequence-file');\n this.$sequenceFile.empty();\n this.controls().addClass('hidden');\n }\n }\n /**\n * Put red border around textarea.\n */\n\n }, {\n key: \"indicateError\",\n value: function indicateError() {\n this.textarea().parent().addClass('has-error');\n }\n /**\n * Put normal blue border around textarea.\n */\n\n }, {\n key: \"indicateNormal\",\n value: function indicateNormal() {\n this.textarea().parent().removeClass('has-error');\n }\n /**\n * Returns type of the query sequence (nucleotide, protein, mixed).\n *\n * Query widget supports executing a callback when the query type changes.\n * Components interested in query type should register a callback instead\n * of directly calling this method.\n */\n\n }, {\n key: \"type\",\n value: function type() {\n var sequences = this.value().split(/>.*/);\n var type, tmp;\n\n for (var i = 0; i < sequences.length; i++) {\n tmp = this.guessSequenceType(sequences[i]); // could not guess the sequence type; try the next sequence\n\n if (!tmp) {\n continue;\n }\n\n if (!type) {\n // successfully guessed the type of atleast one sequence\n type = tmp;\n } else if (tmp !== type) {\n // user has mixed different type of sequences\n return 'mixed';\n }\n }\n\n return type;\n }\n /**\n * Guesses and returns the type of the given sequence (nucleotide,\n * protein).\n */\n\n }, {\n key: \"guessSequenceType\",\n value: function guessSequenceType(sequence) {\n // remove 'noisy' characters\n sequence = sequence.replace(/[^A-Z]/gi, ''); // non-letter characters\n\n sequence = sequence.replace(/[NX]/gi, ''); // ambiguous characters\n // can't determine the type of ultrashort queries\n\n if (sequence.length < 10) {\n return undefined;\n } // count the number of putative NA\n\n\n var putative_NA_count = 0;\n\n for (var i = 0; i < sequence.length; i++) {\n if (sequence[i].match(/[ACGTU]/i)) {\n putative_NA_count += 1;\n }\n }\n\n var threshold = 0.9 * sequence.length;\n return putative_NA_count > threshold ? 'nucleotide' : 'protein';\n }\n }, {\n key: \"notify\",\n value: function notify(type) {\n clearTimeout(this.notification_timeout);\n this.indicateNormal();\n $('.notifications .active').hide().removeClass('active');\n\n if (type) {\n $('#' + type + '-sequence-notification').show('drop', {\n direction: 'up'\n }).addClass('active'); //hide notification after 5s only for non-mixed sequences\n\n if (type !== 'mixed') {\n this.notification_timeout = setTimeout(function () {\n $('.notifications .active').hide('drop', {\n direction: 'up'\n }).removeClass('active');\n }, 5000);\n } else {\n this.indicateError();\n }\n }\n }\n }, {\n key: \"render\",\n value: function render() {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"col-md-12\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"div\", {\n className: \"sequence\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"textarea\", {\n id: \"sequence\",\n ref: this.textareaRef,\n className: \"form-control text-monospace\",\n name: \"sequence\",\n value: this.state.value,\n placeholder: \"Paste query sequence(s) or drag file containing query sequence(s) in FASTA format here ...\",\n spellCheck: \"false\",\n autoFocus: true,\n onChange: this.handleInput\n })\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"div\", {\n className: \"hidden\",\n style: {\n position: 'absolute',\n top: '4px',\n right: '19px'\n },\n ref: this.controlsRef,\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"button\", {\n type: \"button\",\n className: \"btn btn-sm btn-default\",\n id: \"btn-sequence-clear\",\n title: \"Clear query sequence(s).\",\n onClick: this.clear,\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"span\", {\n id: \"sequence-file\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"i\", {\n className: \"fa fa-times\"\n })]\n })\n })]\n });\n }\n }]);\n\n return SearchQueryWidget;\n}(react__WEBPACK_IMPORTED_MODULE_0__.Component);\n/**\n * Renders summary of all hits per query in a tabular form.\n */\n\nvar HitsTable = /*#__PURE__*/function (_Component3) {\n _inherits(HitsTable, _Component3);\n\n var _super3 = _createSuper(HitsTable);\n\n function HitsTable(props) {\n _classCallCheck(this, HitsTable);\n\n return _super3.call(this, props);\n }\n\n _createClass(HitsTable, [{\n key: \"render\",\n value: function render() {\n var hasName = underscore__WEBPACK_IMPORTED_MODULE_1__[\"default\"].every(this.props.query.hits, function (hit) {\n return hit.sciname !== '';\n }); // Width of sequence column is 55% when species name is not shown and\n // query coverage is.\n\n\n var seqwidth = 55; // If we are going to show species name, then reduce the width of\n // sequence column by the width of species column.\n\n if (hasName) seqwidth -= 15; // If we are not going to show query coverage (i.e. for imported XML),\n // then increase the width of sequence column by the width of coverage\n // column.\n\n if (this.props.imported_xml) seqwidth += 15;\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"table-hit-overview\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"h4\", {\n className: \"caption\",\n \"data-toggle\": \"collapse\",\n \"data-target\": '#Query_' + this.props.query.number + 'HT_' + this.props.query.number,\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"i\", {\n className: \"fa fa-minus-square-o\"\n }), \"\\xA0\", /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"span\", {\n children: \"Sequences producing significant alignments\"\n })]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"div\", {\n className: \"collapsed in\",\n id: 'Query_' + this.props.query.number + 'HT_' + this.props.query.number,\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"table\", {\n className: \"table table-hover table-condensed tabular-view \",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"thead\", {\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"tr\", {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n className: \"text-left\",\n children: \"#\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"\".concat(seqwidth, \"%\"),\n children: \"Similar sequences\"\n }), hasName && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"15%\",\n className: \"text-left\",\n children: \"Species\"\n }), !this.props.imported_xml && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"15%\",\n className: \"text-right\",\n children: \"Query coverage (%)\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"10%\",\n className: \"text-right\",\n children: \"Total score\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"10%\",\n className: \"text-right\",\n children: \"E value\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"10%\",\n className: \"text-right\",\n children: \"Identity (%)\"\n })]\n })\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"tbody\", {\n children: underscore__WEBPACK_IMPORTED_MODULE_1__[\"default\"].map(this.props.query.hits, underscore__WEBPACK_IMPORTED_MODULE_1__[\"default\"].bind(function (hit) {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"tr\", {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-left\",\n children: hit.number + '.'\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"nowrap-ellipsis\",\n title: \"\".concat(hit.id, \" \").concat(hit.title),\n \"data-toggle\": \"tooltip\",\n \"data-placement\": \"left\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"a\", {\n href: '#Query_' + this.props.query.number + '_hit_' + hit.number,\n className: \"btn-link\",\n children: [hit.id, \" \", hit.title]\n })\n }), hasName && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"nowrap-ellipsis\",\n title: hit.sciname,\n \"data-toggle\": \"tooltip\",\n \"data-placement\": \"top\",\n children: hit.sciname\n }), !this.props.imported_xml && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-right\",\n children: hit.qcovs\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-right\",\n children: hit.total_score\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-right\",\n children: _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].inExponential(hit.hsps[0].evalue)\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-right\",\n children: _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].inPercentage(hit.hsps[0].identity, hit.hsps[0].length)\n })]\n }, hit.number);\n }, this))\n })]\n })\n })]\n });\n }\n }]);\n\n return HitsTable;\n}(react__WEBPACK_IMPORTED_MODULE_0__.Component);\n\n//# sourceURL=webpack://SequenceServer/./public/js/query.js?"); /***/ }), diff --git a/public/sequenceserver-search.min.js b/public/sequenceserver-search.min.js index 33acf6744..e5f4efe09 100644 --- a/public/sequenceserver-search.min.js +++ b/public/sequenceserver-search.min.js @@ -126,11 +126,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; -<<<<<<< HEAD -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"ReportQuery\": () => (/* binding */ ReportQuery),\n/* harmony export */ \"SearchQueryWidget\": () => (/* binding */ SearchQueryWidget)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! underscore */ \"./node_modules/underscore/modules/index-all.js\");\n/* harmony import */ var _hits_overview__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./hits_overview */ \"./public/js/hits_overview.js\");\n/* harmony import */ var _length_distribution__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./length_distribution */ \"./public/js/length_distribution.js\");\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils */ \"./public/js/utils.js\");\n/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react/jsx-runtime */ \"./node_modules/react/jsx-runtime.js\");\n/* provided dependency */ var $ = __webpack_require__(/*! jquery */ \"./node_modules/jquery/dist/jquery.js\");\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, \"prototype\", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } else if (call !== void 0) { throw new TypeError(\"Derived constructors may only return object or undefined\"); } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n\n\n\n // length distribution of hits\n\n\n/**\n * Query component displays query defline, graphical overview, length\n * distribution, and hits table.\n */\n\n\n\nvar ReportQuery = /*#__PURE__*/function (_Component) {\n _inherits(ReportQuery, _Component);\n\n var _super = _createSuper(ReportQuery);\n\n function ReportQuery() {\n _classCallCheck(this, ReportQuery);\n\n return _super.apply(this, arguments);\n }\n\n _createClass(ReportQuery, [{\n key: \"shouldComponentUpdate\",\n value: // Each update cycle will cause all previous queries to be re-rendered.\n // We avoid that by implementing shouldComponentUpdate life-cycle hook.\n // The trick is to simply check if the components has recieved props\n // before.\n function shouldComponentUpdate() {\n // If the component has received props before, query property will\n // be set on it. If it is, we return false so that the component\n // is not re-rendered. If the query property is not set, we return\n // true: this must be the first time react is trying to render the\n // component.\n return !this.props.query;\n } // Kind of public API //\n\n /**\n * Returns the id of query.\n */\n\n }, {\n key: \"domID\",\n value: function domID() {\n return 'Query_' + this.props.query.number;\n }\n }, {\n key: \"queryLength\",\n value: function queryLength() {\n return this.props.query.length;\n }\n /**\n * Returns number of hits.\n */\n\n }, {\n key: \"numhits\",\n value: function numhits() {\n return this.props.query.hits.length;\n }\n }, {\n key: \"headerJSX\",\n value: function headerJSX() {\n var meta = \"length: \".concat(this.queryLength().toLocaleString());\n\n if (this.props.showQueryCrumbs) {\n meta = \"query \".concat(this.props.query.number, \", \") + meta;\n }\n\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"section-header\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"h3\", {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"strong\", {\n children: [\"Query=\\xA0\", this.props.query.id]\n }), \"\\xA0\", this.props.query.title]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"span\", {\n className: \"label label-reset pos-label\",\n children: meta\n })]\n });\n }\n }, {\n key: \"hitsListJSX\",\n value: function hitsListJSX() {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"section-content\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_hits_overview__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n query: this.props.query,\n program: this.props.program,\n collapsed: this.props.veryBig\n }, 'GO_' + this.props.query.number), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_length_distribution__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n query: this.props.query,\n algorithm: this.props.program,\n collapsed: \"true\"\n }, 'LD_' + this.props.query.id), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(HitsTable, {\n query: this.props.query,\n imported_xml: this.props.imported_xml\n }, 'HT_' + this.props.query.number)]\n });\n }\n }, {\n key: \"noHitsJSX\",\n value: function noHitsJSX() {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"div\", {\n className: \"section-content\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"strong\", {\n children: \" ****** No hits found ****** \"\n })\n });\n }\n }, {\n key: \"render\",\n value: function render() {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"resultn\",\n id: this.domID(),\n \"data-query-len\": this.props.query.length,\n \"data-algorithm\": this.props.program,\n children: [this.headerJSX(), this.numhits() && this.hitsListJSX() || this.noHitsJSX()]\n });\n }\n }]);\n\n return ReportQuery;\n}(react__WEBPACK_IMPORTED_MODULE_0__.Component);\n/**\n * Query widget for Search component.\n */\n\nvar SearchQueryWidget = /*#__PURE__*/function (_Component2) {\n _inherits(SearchQueryWidget, _Component2);\n\n var _super2 = _createSuper(SearchQueryWidget);\n\n function SearchQueryWidget(props) {\n var _this;\n\n _classCallCheck(this, SearchQueryWidget);\n\n _this = _super2.call(this, props);\n _this.state = {\n value: $('input#input_sequence').val() || ''\n };\n _this.value = _this.value.bind(_assertThisInitialized(_this));\n _this.clear = _this.clear.bind(_assertThisInitialized(_this));\n _this.focus = _this.focus.bind(_assertThisInitialized(_this));\n _this.isEmpty = _this.isEmpty.bind(_assertThisInitialized(_this));\n _this.textarea = _this.textarea.bind(_assertThisInitialized(_this));\n _this.controls = _this.controls.bind(_assertThisInitialized(_this));\n _this.handleInput = _this.handleInput.bind(_assertThisInitialized(_this));\n _this.hideShowButton = _this.hideShowButton.bind(_assertThisInitialized(_this));\n _this.indicateError = _this.indicateError.bind(_assertThisInitialized(_this));\n _this.indicateNormal = _this.indicateNormal.bind(_assertThisInitialized(_this));\n _this.type = _this.type.bind(_assertThisInitialized(_this));\n _this.guessSequenceType = _this.guessSequenceType.bind(_assertThisInitialized(_this));\n _this.notify = _this.notify.bind(_assertThisInitialized(_this));\n _this.textareaRef = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createRef)();\n _this.controlsRef = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createRef)();\n return _this;\n } // LIFECYCLE Methods\n\n\n _createClass(SearchQueryWidget, [{\n key: \"componentDidMount\",\n value: function componentDidMount() {\n $('body').click(function () {\n $('.notifications .active').hide('drop', {\n direction: 'up'\n }).removeClass('active');\n });\n }\n }, {\n key: \"componentDidUpdate\",\n value: function componentDidUpdate() {\n this.hideShowButton();\n var type = this.type();\n\n if (!type || type !== this._type) {\n this._type = type;\n this.notify(type);\n this.props.onSequenceTypeChanged(type);\n }\n } // Kind of public API. //\n\n /**\n * Returns query sequence if no argument is provided (or null or undefined\n * is provided as argument). Otherwise, sets query sequenced to the given\n * value and returns `this`.\n *\n * Default/initial state of query sequence is an empty string. Caller must\n * explicitly provide empty string as argument to \"reset\" query sequence.\n */\n\n }, {\n key: \"value\",\n value: function value(val) {\n if (val == null) {\n // i.e., val is null or undefined\n return this.state.value;\n } else {\n this.setState({\n value: val\n });\n return this;\n }\n }\n /**\n * Clears textarea. Returns `this`.\n *\n * Clearing textarea also causes it to be focussed.\n */\n\n }, {\n key: \"clear\",\n value: function clear() {\n return this.value('').focus();\n }\n /**\n * Focuses textarea. Returns `this`.\n */\n\n }, {\n key: \"focus\",\n value: function focus() {\n this.textarea().focus();\n return this;\n }\n /**\n * Returns true if query is absent ('', undefined, null), false otherwise.\n */\n\n }, {\n key: \"isEmpty\",\n value: function isEmpty() {\n return !this.value();\n } // Internal helpers. //\n\n }, {\n key: \"textarea\",\n value: function textarea() {\n return $(this.textareaRef.current);\n }\n }, {\n key: \"controls\",\n value: function controls() {\n return $(this.controlsRef.current);\n }\n }, {\n key: \"handleInput\",\n value: function handleInput(evt) {\n this.value(evt.target.value);\n }\n /**\n * Hides or shows 'clear sequence' button.\n *\n * Rendering the 'clear sequence' button takes into account presence or\n * absence of a scrollbar.\n *\n * Called by `componentDidUpdate`.\n */\n\n }, {\n key: \"hideShowButton\",\n value: function hideShowButton() {\n if (!this.isEmpty()) {\n // Calculation below is based on -\n // http://chris-spittles.co.uk/jquery-calculate-scrollbar-width/\n // FIXME: can reflow be avoided here?\n var textareaNode = this.textarea()[0];\n var sequenceControlsRight = textareaNode.offsetWidth - textareaNode.clientWidth;\n this.controls().css('right', sequenceControlsRight + 17);\n this.controls().removeClass('hidden');\n } else {\n // FIXME: what are lines 1, 2, & 3 doing here?\n this.textarea().parent().removeClass('has-error');\n this.$sequenceFile = $('#sequence-file');\n this.$sequenceFile.empty();\n this.controls().addClass('hidden');\n }\n }\n /**\n * Put red border around textarea.\n */\n\n }, {\n key: \"indicateError\",\n value: function indicateError() {\n this.textarea().parent().addClass('has-error');\n }\n /**\n * Put normal blue border around textarea.\n */\n\n }, {\n key: \"indicateNormal\",\n value: function indicateNormal() {\n this.textarea().parent().removeClass('has-error');\n }\n /**\n * Returns type of the query sequence (nucleotide, protein, mixed).\n *\n * Query widget supports executing a callback when the query type changes.\n * Components interested in query type should register a callback instead\n * of directly calling this method.\n */\n\n }, {\n key: \"type\",\n value: function type() {\n var sequences = this.value().split(/>.*/);\n var type, tmp;\n\n for (var i = 0; i < sequences.length; i++) {\n tmp = this.guessSequenceType(sequences[i]); // could not guess the sequence type; try the next sequence\n\n if (!tmp) {\n continue;\n }\n\n if (!type) {\n // successfully guessed the type of atleast one sequence\n type = tmp;\n } else if (tmp !== type) {\n // user has mixed different type of sequences\n return 'mixed';\n }\n }\n\n return type;\n }\n /**\n * Guesses and returns the type of the given sequence (nucleotide,\n * protein).\n */\n\n }, {\n key: \"guessSequenceType\",\n value: function guessSequenceType(sequence) {\n // remove 'noisy' characters\n sequence = sequence.replace(/[^A-Z]/gi, ''); // non-letter characters\n\n sequence = sequence.replace(/[NX]/gi, ''); // ambiguous characters\n // can't determine the type of ultrashort queries\n\n if (sequence.length < 10) {\n return undefined;\n } // count the number of putative NA\n\n\n var putative_NA_count = 0;\n\n for (var i = 0; i < sequence.length; i++) {\n if (sequence[i].match(/[ACGTU]/i)) {\n putative_NA_count += 1;\n }\n }\n\n var threshold = 0.9 * sequence.length;\n return putative_NA_count > threshold ? 'nucleotide' : 'protein';\n }\n }, {\n key: \"notify\",\n value: function notify(type) {\n clearTimeout(this.notification_timeout);\n this.indicateNormal();\n $('.notifications .active').hide().removeClass('active');\n\n if (type) {\n $('#' + type + '-sequence-notification').show('drop', {\n direction: 'up'\n }).addClass('active');\n this.notification_timeout = setTimeout(function () {\n $('.notifications .active').hide('drop', {\n direction: 'up'\n }).removeClass('active');\n }, 5000);\n\n if (type === 'mixed') {\n this.indicateError();\n }\n }\n }\n }, {\n key: \"render\",\n value: function render() {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"col-md-12\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"div\", {\n className: \"sequence\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"textarea\", {\n id: \"sequence\",\n ref: this.textareaRef,\n className: \"form-control text-monospace\",\n name: \"sequence\",\n value: this.state.value,\n placeholder: \"Paste query sequence(s) or drag file containing query sequence(s) in FASTA format here ...\",\n spellCheck: \"false\",\n autoFocus: true,\n onChange: this.handleInput\n })\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"div\", {\n className: \"hidden\",\n style: {\n position: 'absolute',\n top: '4px',\n right: '19px'\n },\n ref: this.controlsRef,\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"button\", {\n type: \"button\",\n className: \"btn btn-sm btn-default\",\n id: \"btn-sequence-clear\",\n title: \"Clear query sequence(s).\",\n onClick: this.clear,\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"span\", {\n id: \"sequence-file\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"i\", {\n className: \"fa fa-times\"\n })]\n })\n })]\n });\n }\n }]);\n\n return SearchQueryWidget;\n}(react__WEBPACK_IMPORTED_MODULE_0__.Component);\n/**\n * Renders summary of all hits per query in a tabular form.\n */\n\nvar HitsTable = /*#__PURE__*/function (_Component3) {\n _inherits(HitsTable, _Component3);\n\n var _super3 = _createSuper(HitsTable);\n\n function HitsTable(props) {\n _classCallCheck(this, HitsTable);\n\n return _super3.call(this, props);\n }\n\n _createClass(HitsTable, [{\n key: \"render\",\n value: function render() {\n var hasName = underscore__WEBPACK_IMPORTED_MODULE_1__[\"default\"].every(this.props.query.hits, function (hit) {\n return hit.sciname !== '';\n }); // Width of sequence column is 55% when species name is not shown and\n // query coverage is.\n\n\n var seqwidth = 55; // If we are going to show species name, then reduce the width of\n // sequence column by the width of species column.\n\n if (hasName) seqwidth -= 15; // If we are not going to show query coverage (i.e. for imported XML),\n // then increase the width of sequence column by the width of coverage\n // column.\n\n if (this.props.imported_xml) seqwidth += 15;\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"table-hit-overview\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"h4\", {\n className: \"caption\",\n \"data-toggle\": \"collapse\",\n \"data-target\": '#Query_' + this.props.query.number + 'HT_' + this.props.query.number,\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"i\", {\n className: \"fa fa-minus-square-o\"\n }), \"\\xA0\", /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"span\", {\n children: \"Sequences producing significant alignments\"\n })]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"div\", {\n className: \"collapsed in\",\n id: 'Query_' + this.props.query.number + 'HT_' + this.props.query.number,\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"table\", {\n className: \"table table-hover table-condensed tabular-view \",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"thead\", {\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"tr\", {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n className: \"text-left\",\n children: \"#\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"\".concat(seqwidth, \"%\"),\n children: \"Similar sequences\"\n }), hasName && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"15%\",\n className: \"text-left\",\n children: \"Species\"\n }), !this.props.imported_xml && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"15%\",\n className: \"text-right\",\n children: \"Query coverage (%)\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"10%\",\n className: \"text-right\",\n children: \"Total score\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"10%\",\n className: \"text-right\",\n children: \"E value\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"10%\",\n className: \"text-right\",\n children: \"Identity (%)\"\n })]\n })\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"tbody\", {\n children: underscore__WEBPACK_IMPORTED_MODULE_1__[\"default\"].map(this.props.query.hits, underscore__WEBPACK_IMPORTED_MODULE_1__[\"default\"].bind(function (hit) {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"tr\", {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-left\",\n children: hit.number + '.'\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"nowrap-ellipsis\",\n title: \"\".concat(hit.id, \" \").concat(hit.title),\n \"data-toggle\": \"tooltip\",\n \"data-placement\": \"left\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"a\", {\n href: '#Query_' + this.props.query.number + '_hit_' + hit.number,\n className: \"btn-link\",\n children: [hit.id, \" \", hit.title]\n })\n }), hasName && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"nowrap-ellipsis\",\n title: hit.sciname,\n \"data-toggle\": \"tooltip\",\n \"data-placement\": \"top\",\n children: hit.sciname\n }), !this.props.imported_xml && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-right\",\n children: hit.qcovs\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-right\",\n children: hit.total_score\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-right\",\n children: _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].inExponential(hit.hsps[0].evalue)\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-right\",\n children: _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].inPercentage(hit.hsps[0].identity, hit.hsps[0].length)\n })]\n }, hit.number);\n }, this))\n })]\n })\n })]\n });\n }\n }]);\n\n return HitsTable;\n}(react__WEBPACK_IMPORTED_MODULE_0__.Component);\n\n//# sourceURL=webpack://SequenceServer/./public/js/query.js?"); -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"ReportQuery\": () => (/* binding */ ReportQuery),\n/* harmony export */ \"SearchQueryWidget\": () => (/* binding */ SearchQueryWidget)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! underscore */ \"./node_modules/underscore/modules/index-all.js\");\n/* harmony import */ var _hits_overview__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./hits_overview */ \"./public/js/hits_overview.js\");\n/* harmony import */ var _length_distribution__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./length_distribution */ \"./public/js/length_distribution.js\");\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils */ \"./public/js/utils.js\");\n/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react/jsx-runtime */ \"./node_modules/react/jsx-runtime.js\");\n/* provided dependency */ var $ = __webpack_require__(/*! jquery */ \"./node_modules/jquery/dist/jquery.js\");\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, \"prototype\", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } else if (call !== void 0) { throw new TypeError(\"Derived constructors may only return object or undefined\"); } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n\n\n\n // length distribution of hits\n\n\n/**\n * Query component displays query defline, graphical overview, length\n * distribution, and hits table.\n */\n\n\n\nvar ReportQuery = /*#__PURE__*/function (_Component) {\n _inherits(ReportQuery, _Component);\n\n var _super = _createSuper(ReportQuery);\n\n function ReportQuery() {\n _classCallCheck(this, ReportQuery);\n\n return _super.apply(this, arguments);\n }\n\n _createClass(ReportQuery, [{\n key: \"shouldComponentUpdate\",\n value: // Each update cycle will cause all previous queries to be re-rendered.\n // We avoid that by implementing shouldComponentUpdate life-cycle hook.\n // The trick is to simply check if the components has recieved props\n // before.\n function shouldComponentUpdate() {\n // If the component has received props before, query property will\n // be set on it. If it is, we return false so that the component\n // is not re-rendered. If the query property is not set, we return\n // true: this must be the first time react is trying to render the\n // component.\n return !this.props.query;\n } // Kind of public API //\n\n /**\n * Returns the id of query.\n */\n\n }, {\n key: \"domID\",\n value: function domID() {\n return 'Query_' + this.props.query.number;\n }\n }, {\n key: \"queryLength\",\n value: function queryLength() {\n return this.props.query.length;\n }\n /**\n * Returns number of hits.\n */\n\n }, {\n key: \"numhits\",\n value: function numhits() {\n return this.props.query.hits.length;\n }\n }, {\n key: \"headerJSX\",\n value: function headerJSX() {\n var meta = \"length: \".concat(this.queryLength().toLocaleString());\n\n if (this.props.showQueryCrumbs) {\n meta = \"query \".concat(this.props.query.number, \", \") + meta;\n }\n\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"section-header\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"h3\", {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"strong\", {\n children: [\"Query=\\xA0\", this.props.query.id]\n }), \"\\xA0\", this.props.query.title]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"span\", {\n className: \"label label-reset pos-label\",\n children: meta\n })]\n });\n }\n }, {\n key: \"hitsListJSX\",\n value: function hitsListJSX() {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"section-content\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_hits_overview__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n query: this.props.query,\n program: this.props.program,\n collapsed: this.props.veryBig\n }, 'GO_' + this.props.query.number), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_length_distribution__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n query: this.props.query,\n algorithm: this.props.program,\n collapsed: \"true\"\n }, 'LD_' + this.props.query.id), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(HitsTable, {\n query: this.props.query,\n imported_xml: this.props.imported_xml\n }, 'HT_' + this.props.query.number)]\n });\n }\n }, {\n key: \"noHitsJSX\",\n value: function noHitsJSX() {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"div\", {\n className: \"section-content\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"strong\", {\n children: \" ****** No hits found ****** \"\n })\n });\n }\n }, {\n key: \"render\",\n value: function render() {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"resultn\",\n id: this.domID(),\n \"data-query-len\": this.props.query.length,\n \"data-algorithm\": this.props.program,\n children: [this.headerJSX(), this.numhits() && this.hitsListJSX() || this.noHitsJSX()]\n });\n }\n }]);\n\n return ReportQuery;\n}(react__WEBPACK_IMPORTED_MODULE_0__.Component);\n/**\n * Query widget for Search component.\n */\n\nvar SearchQueryWidget = /*#__PURE__*/function (_Component2) {\n _inherits(SearchQueryWidget, _Component2);\n\n var _super2 = _createSuper(SearchQueryWidget);\n\n function SearchQueryWidget(props) {\n var _this;\n\n _classCallCheck(this, SearchQueryWidget);\n\n _this = _super2.call(this, props);\n _this.state = {\n value: $('input#input_sequence').val() || ''\n };\n _this.value = _this.value.bind(_assertThisInitialized(_this));\n _this.clear = _this.clear.bind(_assertThisInitialized(_this));\n _this.focus = _this.focus.bind(_assertThisInitialized(_this));\n _this.isEmpty = _this.isEmpty.bind(_assertThisInitialized(_this));\n _this.textarea = _this.textarea.bind(_assertThisInitialized(_this));\n _this.controls = _this.controls.bind(_assertThisInitialized(_this));\n _this.handleInput = _this.handleInput.bind(_assertThisInitialized(_this));\n _this.hideShowButton = _this.hideShowButton.bind(_assertThisInitialized(_this));\n _this.indicateError = _this.indicateError.bind(_assertThisInitialized(_this));\n _this.indicateNormal = _this.indicateNormal.bind(_assertThisInitialized(_this));\n _this.type = _this.type.bind(_assertThisInitialized(_this));\n _this.guessSequenceType = _this.guessSequenceType.bind(_assertThisInitialized(_this));\n _this.notify = _this.notify.bind(_assertThisInitialized(_this));\n _this.textareaRef = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createRef)();\n _this.controlsRef = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createRef)();\n return _this;\n } // LIFECYCLE Methods\n\n\n _createClass(SearchQueryWidget, [{\n key: \"componentDidMount\",\n value: function componentDidMount() {\n $('body').click(function () {\n $('.notifications .active').hide('drop', {\n direction: 'up'\n }).removeClass('active');\n });\n }\n }, {\n key: \"componentDidUpdate\",\n value: function componentDidUpdate() {\n this.hideShowButton();\n var type = this.type();\n\n if (!type || type !== this._type) {\n this._type = type;\n this.notify(type);\n this.props.onSequenceTypeChanged(type);\n }\n } // Kind of public API. //\n\n /**\n * Returns query sequence if no argument is provided (or null or undefined\n * is provided as argument). Otherwise, sets query sequenced to the given\n * value and returns `this`.\n *\n * Default/initial state of query sequence is an empty string. Caller must\n * explicitly provide empty string as argument to \"reset\" query sequence.\n */\n\n }, {\n key: \"value\",\n value: function value(val) {\n if (val == null) {\n // i.e., val is null or undefined\n return this.state.value;\n } else {\n this.setState({\n value: val\n });\n return this;\n }\n }\n /**\n * Clears textarea. Returns `this`.\n *\n * Clearing textarea also causes it to be focussed.\n */\n\n }, {\n key: \"clear\",\n value: function clear() {\n return this.value('').focus();\n }\n /**\n * Focuses textarea. Returns `this`.\n */\n\n }, {\n key: \"focus\",\n value: function focus() {\n this.textarea().focus();\n return this;\n }\n /**\n * Returns true if query is absent ('', undefined, null), false otherwise.\n */\n\n }, {\n key: \"isEmpty\",\n value: function isEmpty() {\n return !this.value();\n } // Internal helpers. //\n\n }, {\n key: \"textarea\",\n value: function textarea() {\n return $(this.textareaRef.current);\n }\n }, {\n key: \"controls\",\n value: function controls() {\n return $(this.controlsRef.current);\n }\n }, {\n key: \"handleInput\",\n value: function handleInput(evt) {\n this.value(evt.target.value);\n }\n /**\n * Hides or shows 'clear sequence' button.\n *\n * Rendering the 'clear sequence' button takes into account presence or\n * absence of a scrollbar.\n *\n * Called by `componentDidUpdate`.\n */\n\n }, {\n key: \"hideShowButton\",\n value: function hideShowButton() {\n if (!this.isEmpty()) {\n // Calculation below is based on -\n // http://chris-spittles.co.uk/jquery-calculate-scrollbar-width/\n // FIXME: can reflow be avoided here?\n var textareaNode = this.textarea()[0];\n var sequenceControlsRight = textareaNode.offsetWidth - textareaNode.clientWidth;\n this.controls().css('right', sequenceControlsRight + 17);\n this.controls().removeClass('hidden');\n } else {\n // FIXME: what are lines 1, 2, & 3 doing here?\n this.textarea().parent().removeClass('has-error');\n this.$sequenceFile = $('#sequence-file');\n this.$sequenceFile.empty();\n this.controls().addClass('hidden');\n }\n }\n /**\n * Put red border around textarea.\n */\n\n }, {\n key: \"indicateError\",\n value: function indicateError() {\n this.textarea().parent().addClass('has-error');\n }\n /**\n * Put normal blue border around textarea.\n */\n\n }, {\n key: \"indicateNormal\",\n value: function indicateNormal() {\n this.textarea().parent().removeClass('has-error');\n }\n /**\n * Returns type of the query sequence (nucleotide, protein, mixed).\n *\n * Query widget supports executing a callback when the query type changes.\n * Components interested in query type should register a callback instead\n * of directly calling this method.\n */\n\n }, {\n key: \"type\",\n value: function type() {\n var sequences = this.value().split(/>.*/);\n var type, tmp;\n\n for (var i = 0; i < sequences.length; i++) {\n tmp = this.guessSequenceType(sequences[i]); // could not guess the sequence type; try the next sequence\n\n if (!tmp) {\n continue;\n }\n\n if (!type) {\n // successfully guessed the type of atleast one sequence\n type = tmp;\n } else if (tmp !== type) {\n // user has mixed different type of sequences\n return 'mixed';\n }\n }\n\n return type;\n }\n /**\n * Guesses and returns the type of the given sequence (nucleotide,\n * protein).\n */\n\n }, {\n key: \"guessSequenceType\",\n value: function guessSequenceType(sequence) {\n // remove 'noisy' characters\n sequence = sequence.replace(/[^A-Z]/gi, ''); // non-letter characters\n\n sequence = sequence.replace(/[NX]/gi, ''); // ambiguous characters\n // can't determine the type of ultrashort queries\n\n if (sequence.length < 10) {\n return undefined;\n } // count the number of putative NA\n\n\n var putative_NA_count = 0;\n\n for (var i = 0; i < sequence.length; i++) {\n if (sequence[i].match(/[ACGTU]/i)) {\n putative_NA_count += 1;\n }\n }\n\n var threshold = 0.9 * sequence.length;\n return putative_NA_count > threshold ? 'nucleotide' : 'protein';\n }\n }, {\n key: \"notify\",\n value: function notify(type) {\n clearTimeout(this.notification_timeout);\n this.indicateNormal();\n $('.notifications .active').hide().removeClass('active');\n\n if (type) {\n $('#' + type + '-sequence-notification').show('drop', {\n direction: 'up'\n }).addClass('active'); //hide notification after 5s only for non-mixed sequences\n\n if (type !== 'mixed') {\n this.notification_timeout = setTimeout(function () {\n $('.notifications .active').hide('drop', {\n direction: 'up'\n }).removeClass('active');\n }, 5000);\n } else {\n this.indicateError();\n }\n }\n }\n }, {\n key: \"render\",\n value: function render() {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"col-md-12\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"div\", {\n className: \"sequence\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"textarea\", {\n id: \"sequence\",\n ref: this.textareaRef,\n className: \"form-control text-monospace\",\n name: \"sequence\",\n value: this.state.value,\n placeholder: \"Paste query sequence(s) or drag file containing query sequence(s) in FASTA format here ...\",\n spellCheck: \"false\",\n autoFocus: true,\n onChange: this.handleInput\n })\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"div\", {\n className: \"hidden\",\n style: {\n position: 'absolute',\n top: '4px',\n right: '19px'\n },\n ref: this.controlsRef,\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"button\", {\n type: \"button\",\n className: \"btn btn-sm btn-default\",\n id: \"btn-sequence-clear\",\n title: \"Clear query sequence(s).\",\n onClick: this.clear,\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"span\", {\n id: \"sequence-file\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"i\", {\n className: \"fa fa-times\"\n })]\n })\n })]\n });\n }\n }]);\n\n return SearchQueryWidget;\n}(react__WEBPACK_IMPORTED_MODULE_0__.Component);\n/**\n * Renders summary of all hits per query in a tabular form.\n */\n\nvar HitsTable = /*#__PURE__*/function (_Component3) {\n _inherits(HitsTable, _Component3);\n\n var _super3 = _createSuper(HitsTable);\n\n function HitsTable(props) {\n _classCallCheck(this, HitsTable);\n\n return _super3.call(this, props);\n }\n\n _createClass(HitsTable, [{\n key: \"render\",\n value: function render() {\n var hasName = underscore__WEBPACK_IMPORTED_MODULE_1__[\"default\"].every(this.props.query.hits, function (hit) {\n return hit.sciname !== '';\n }); // Width of sequence column is 55% when species name is not shown and\n // query coverage is.\n\n\n var seqwidth = 55; // If we are going to show species name, then reduce the width of\n // sequence column by the width of species column.\n\n if (hasName) seqwidth -= 15; // If we are not going to show query coverage (i.e. for imported XML),\n // then increase the width of sequence column by the width of coverage\n // column.\n\n if (this.props.imported_xml) seqwidth += 15;\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"table-hit-overview\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"h4\", {\n className: \"caption\",\n \"data-toggle\": \"collapse\",\n \"data-target\": '#Query_' + this.props.query.number + 'HT_' + this.props.query.number,\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"i\", {\n className: \"fa fa-minus-square-o\"\n }), \"\\xA0\", /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"span\", {\n children: \"Sequences producing significant alignments\"\n })]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"div\", {\n className: \"collapsed in\",\n id: 'Query_' + this.props.query.number + 'HT_' + this.props.query.number,\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"table\", {\n className: \"table table-hover table-condensed tabular-view \",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"thead\", {\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"tr\", {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n className: \"text-left\",\n children: \"#\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"\".concat(seqwidth, \"%\"),\n children: \"Similar sequences\"\n }), hasName && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"15%\",\n className: \"text-left\",\n children: \"Species\"\n }), !this.props.imported_xml && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"15%\",\n className: \"text-right\",\n children: \"Query coverage (%)\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"10%\",\n className: \"text-right\",\n children: \"Total score\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"10%\",\n className: \"text-right\",\n children: \"E value\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"10%\",\n className: \"text-right\",\n children: \"Identity (%)\"\n })]\n })\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"tbody\", {\n children: underscore__WEBPACK_IMPORTED_MODULE_1__[\"default\"].map(this.props.query.hits, underscore__WEBPACK_IMPORTED_MODULE_1__[\"default\"].bind(function (hit) {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"tr\", {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-left\",\n children: hit.number + '.'\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"nowrap-ellipsis\",\n title: \"\".concat(hit.id, \" \").concat(hit.title),\n \"data-toggle\": \"tooltip\",\n \"data-placement\": \"left\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"a\", {\n href: '#Query_' + this.props.query.number + '_hit_' + hit.number,\n className: \"btn-link\",\n children: [hit.id, \" \", hit.title]\n })\n }), hasName && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"nowrap-ellipsis\",\n title: hit.sciname,\n \"data-toggle\": \"tooltip\",\n \"data-placement\": \"top\",\n children: hit.sciname\n }), !this.props.imported_xml && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-right\",\n children: hit.qcovs\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-right\",\n children: hit.total_score\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-right\",\n children: _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].inExponential(hit.hsps[0].evalue)\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-right\",\n children: _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].inPercentage(hit.hsps[0].identity, hit.hsps[0].length)\n })]\n }, hit.number);\n }, this))\n })]\n })\n })]\n });\n }\n }]);\n\n return HitsTable;\n}(react__WEBPACK_IMPORTED_MODULE_0__.Component);\n\n//# sourceURL=webpack://SequenceServer/./public/js/query.js?"); ->>>>>>> d800bb4 (only hide notification after timeout for non-mixed sequences) +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"ReportQuery\": () => (/* binding */ ReportQuery),\n/* harmony export */ \"SearchQueryWidget\": () => (/* binding */ SearchQueryWidget)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! underscore */ \"./node_modules/underscore/modules/index-all.js\");\n/* harmony import */ var _hits_overview__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./hits_overview */ \"./public/js/hits_overview.js\");\n/* harmony import */ var _length_distribution__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./length_distribution */ \"./public/js/length_distribution.js\");\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils */ \"./public/js/utils.js\");\n/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react/jsx-runtime */ \"./node_modules/react/jsx-runtime.js\");\n/* provided dependency */ var $ = __webpack_require__(/*! jquery */ \"./node_modules/jquery/dist/jquery.js\");\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, \"prototype\", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } else if (call !== void 0) { throw new TypeError(\"Derived constructors may only return object or undefined\"); } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n\n\n\n // length distribution of hits\n\n\n/**\n * Query component displays query defline, graphical overview, length\n * distribution, and hits table.\n */\n\n\n\nvar ReportQuery = /*#__PURE__*/function (_Component) {\n _inherits(ReportQuery, _Component);\n\n var _super = _createSuper(ReportQuery);\n\n function ReportQuery() {\n _classCallCheck(this, ReportQuery);\n\n return _super.apply(this, arguments);\n }\n\n _createClass(ReportQuery, [{\n key: \"shouldComponentUpdate\",\n value: // Each update cycle will cause all previous queries to be re-rendered.\n // We avoid that by implementing shouldComponentUpdate life-cycle hook.\n // The trick is to simply check if the components has recieved props\n // before.\n function shouldComponentUpdate() {\n // If the component has received props before, query property will\n // be set on it. If it is, we return false so that the component\n // is not re-rendered. If the query property is not set, we return\n // true: this must be the first time react is trying to render the\n // component.\n return !this.props.query;\n } // Kind of public API //\n\n /**\n * Returns the id of query.\n */\n\n }, {\n key: \"domID\",\n value: function domID() {\n return 'Query_' + this.props.query.number;\n }\n }, {\n key: \"queryLength\",\n value: function queryLength() {\n return this.props.query.length;\n }\n /**\n * Returns number of hits.\n */\n\n }, {\n key: \"numhits\",\n value: function numhits() {\n return this.props.query.hits.length;\n }\n }, {\n key: \"headerJSX\",\n value: function headerJSX() {\n var meta = \"length: \".concat(this.queryLength().toLocaleString());\n\n if (this.props.showQueryCrumbs) {\n meta = \"query \".concat(this.props.query.number, \", \") + meta;\n }\n\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"section-header\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"h3\", {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"strong\", {\n children: [\"Query=\\xA0\", this.props.query.id]\n }), \"\\xA0\", this.props.query.title]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"span\", {\n className: \"label label-reset pos-label\",\n children: meta\n })]\n });\n }\n }, {\n key: \"hitsListJSX\",\n value: function hitsListJSX() {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"section-content\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_hits_overview__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n query: this.props.query,\n program: this.props.program,\n collapsed: this.props.veryBig\n }, 'GO_' + this.props.query.number), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_length_distribution__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n query: this.props.query,\n algorithm: this.props.program,\n collapsed: \"true\"\n }, 'LD_' + this.props.query.id), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(HitsTable, {\n query: this.props.query,\n imported_xml: this.props.imported_xml\n }, 'HT_' + this.props.query.number)]\n });\n }\n }, {\n key: \"noHitsJSX\",\n value: function noHitsJSX() {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"div\", {\n className: \"section-content\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"strong\", {\n children: \" ****** No hits found ****** \"\n })\n });\n }\n }, {\n key: \"render\",\n value: function render() {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"resultn\",\n id: this.domID(),\n \"data-query-len\": this.props.query.length,\n \"data-algorithm\": this.props.program,\n children: [this.headerJSX(), this.numhits() && this.hitsListJSX() || this.noHitsJSX()]\n });\n }\n }]);\n\n return ReportQuery;\n}(react__WEBPACK_IMPORTED_MODULE_0__.Component);\n/**\n * Query widget for Search component.\n */\n\nvar SearchQueryWidget = /*#__PURE__*/function (_Component2) {\n _inherits(SearchQueryWidget, _Component2);\n\n var _super2 = _createSuper(SearchQueryWidget);\n\n function SearchQueryWidget(props) {\n var _this;\n\n _classCallCheck(this, SearchQueryWidget);\n\n _this = _super2.call(this, props);\n _this.state = {\n value: $('input#input_sequence').val() || ''\n };\n _this.value = _this.value.bind(_assertThisInitialized(_this));\n _this.clear = _this.clear.bind(_assertThisInitialized(_this));\n _this.focus = _this.focus.bind(_assertThisInitialized(_this));\n _this.isEmpty = _this.isEmpty.bind(_assertThisInitialized(_this));\n _this.textarea = _this.textarea.bind(_assertThisInitialized(_this));\n _this.controls = _this.controls.bind(_assertThisInitialized(_this));\n _this.handleInput = _this.handleInput.bind(_assertThisInitialized(_this));\n _this.hideShowButton = _this.hideShowButton.bind(_assertThisInitialized(_this));\n _this.indicateError = _this.indicateError.bind(_assertThisInitialized(_this));\n _this.indicateNormal = _this.indicateNormal.bind(_assertThisInitialized(_this));\n _this.type = _this.type.bind(_assertThisInitialized(_this));\n _this.guessSequenceType = _this.guessSequenceType.bind(_assertThisInitialized(_this));\n _this.notify = _this.notify.bind(_assertThisInitialized(_this));\n _this.textareaRef = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createRef)();\n _this.controlsRef = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createRef)();\n return _this;\n } // LIFECYCLE Methods\n\n\n _createClass(SearchQueryWidget, [{\n key: \"componentDidUpdate\",\n value: function componentDidUpdate() {\n this.hideShowButton();\n var type = this.type();\n\n if (!type || type !== this._type) {\n this._type = type;\n this.notify(type);\n this.props.onSequenceTypeChanged(type);\n }\n } // Kind of public API. //\n\n /**\n * Returns query sequence if no argument is provided (or null or undefined\n * is provided as argument). Otherwise, sets query sequenced to the given\n * value and returns `this`.\n *\n * Default/initial state of query sequence is an empty string. Caller must\n * explicitly provide empty string as argument to \"reset\" query sequence.\n */\n\n }, {\n key: \"value\",\n value: function value(val) {\n if (val == null) {\n // i.e., val is null or undefined\n return this.state.value;\n } else {\n this.setState({\n value: val\n });\n return this;\n }\n }\n /**\n * Clears textarea. Returns `this`.\n *\n * Clearing textarea also causes it to be focussed.\n */\n\n }, {\n key: \"clear\",\n value: function clear() {\n return this.value('').focus();\n }\n /**\n * Focuses textarea. Returns `this`.\n */\n\n }, {\n key: \"focus\",\n value: function focus() {\n this.textarea().focus();\n return this;\n }\n /**\n * Returns true if query is absent ('', undefined, null), false otherwise.\n */\n\n }, {\n key: \"isEmpty\",\n value: function isEmpty() {\n return !this.value();\n } // Internal helpers. //\n\n }, {\n key: \"textarea\",\n value: function textarea() {\n return $(this.textareaRef.current);\n }\n }, {\n key: \"controls\",\n value: function controls() {\n return $(this.controlsRef.current);\n }\n }, {\n key: \"handleInput\",\n value: function handleInput(evt) {\n this.value(evt.target.value);\n }\n /**\n * Hides or shows 'clear sequence' button.\n *\n * Rendering the 'clear sequence' button takes into account presence or\n * absence of a scrollbar.\n *\n * Called by `componentDidUpdate`.\n */\n\n }, {\n key: \"hideShowButton\",\n value: function hideShowButton() {\n if (!this.isEmpty()) {\n // Calculation below is based on -\n // http://chris-spittles.co.uk/jquery-calculate-scrollbar-width/\n // FIXME: can reflow be avoided here?\n var textareaNode = this.textarea()[0];\n var sequenceControlsRight = textareaNode.offsetWidth - textareaNode.clientWidth;\n this.controls().css('right', sequenceControlsRight + 17);\n this.controls().removeClass('hidden');\n } else {\n // FIXME: what are lines 1, 2, & 3 doing here?\n this.textarea().parent().removeClass('has-error');\n this.$sequenceFile = $('#sequence-file');\n this.$sequenceFile.empty();\n this.controls().addClass('hidden');\n }\n }\n /**\n * Put red border around textarea.\n */\n\n }, {\n key: \"indicateError\",\n value: function indicateError() {\n this.textarea().parent().addClass('has-error');\n }\n /**\n * Put normal blue border around textarea.\n */\n\n }, {\n key: \"indicateNormal\",\n value: function indicateNormal() {\n this.textarea().parent().removeClass('has-error');\n }\n /**\n * Returns type of the query sequence (nucleotide, protein, mixed).\n *\n * Query widget supports executing a callback when the query type changes.\n * Components interested in query type should register a callback instead\n * of directly calling this method.\n */\n\n }, {\n key: \"type\",\n value: function type() {\n var sequences = this.value().split(/>.*/);\n var type, tmp;\n\n for (var i = 0; i < sequences.length; i++) {\n tmp = this.guessSequenceType(sequences[i]); // could not guess the sequence type; try the next sequence\n\n if (!tmp) {\n continue;\n }\n\n if (!type) {\n // successfully guessed the type of atleast one sequence\n type = tmp;\n } else if (tmp !== type) {\n // user has mixed different type of sequences\n return 'mixed';\n }\n }\n\n return type;\n }\n /**\n * Guesses and returns the type of the given sequence (nucleotide,\n * protein).\n */\n\n }, {\n key: \"guessSequenceType\",\n value: function guessSequenceType(sequence) {\n // remove 'noisy' characters\n sequence = sequence.replace(/[^A-Z]/gi, ''); // non-letter characters\n\n sequence = sequence.replace(/[NX]/gi, ''); // ambiguous characters\n // can't determine the type of ultrashort queries\n\n if (sequence.length < 10) {\n return undefined;\n } // count the number of putative NA\n\n\n var putative_NA_count = 0;\n\n for (var i = 0; i < sequence.length; i++) {\n if (sequence[i].match(/[ACGTU]/i)) {\n putative_NA_count += 1;\n }\n }\n\n var threshold = 0.9 * sequence.length;\n return putative_NA_count > threshold ? 'nucleotide' : 'protein';\n }\n }, {\n key: \"notify\",\n value: function notify(type) {\n clearTimeout(this.notification_timeout);\n this.indicateNormal();\n $('.notifications .active').hide().removeClass('active');\n\n if (type) {\n $('#' + type + '-sequence-notification').show('drop', {\n direction: 'up'\n }).addClass('active'); //hide notification after 5s only for non-mixed sequences\n\n if (type !== 'mixed') {\n this.notification_timeout = setTimeout(function () {\n $('.notifications .active').hide('drop', {\n direction: 'up'\n }).removeClass('active');\n }, 5000);\n } else {\n this.indicateError();\n }\n }\n }\n }, {\n key: \"render\",\n value: function render() {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"col-md-12\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"div\", {\n className: \"sequence\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"textarea\", {\n id: \"sequence\",\n ref: this.textareaRef,\n className: \"form-control text-monospace\",\n name: \"sequence\",\n value: this.state.value,\n placeholder: \"Paste query sequence(s) or drag file containing query sequence(s) in FASTA format here ...\",\n spellCheck: \"false\",\n autoFocus: true,\n onChange: this.handleInput\n })\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"div\", {\n className: \"hidden\",\n style: {\n position: 'absolute',\n top: '4px',\n right: '19px'\n },\n ref: this.controlsRef,\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"button\", {\n type: \"button\",\n className: \"btn btn-sm btn-default\",\n id: \"btn-sequence-clear\",\n title: \"Clear query sequence(s).\",\n onClick: this.clear,\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"span\", {\n id: \"sequence-file\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"i\", {\n className: \"fa fa-times\"\n })]\n })\n })]\n });\n }\n }]);\n\n return SearchQueryWidget;\n}(react__WEBPACK_IMPORTED_MODULE_0__.Component);\n/**\n * Renders summary of all hits per query in a tabular form.\n */\n\nvar HitsTable = /*#__PURE__*/function (_Component3) {\n _inherits(HitsTable, _Component3);\n\n var _super3 = _createSuper(HitsTable);\n\n function HitsTable(props) {\n _classCallCheck(this, HitsTable);\n\n return _super3.call(this, props);\n }\n\n _createClass(HitsTable, [{\n key: \"render\",\n value: function render() {\n var hasName = underscore__WEBPACK_IMPORTED_MODULE_1__[\"default\"].every(this.props.query.hits, function (hit) {\n return hit.sciname !== '';\n }); // Width of sequence column is 55% when species name is not shown and\n // query coverage is.\n\n\n var seqwidth = 55; // If we are going to show species name, then reduce the width of\n // sequence column by the width of species column.\n\n if (hasName) seqwidth -= 15; // If we are not going to show query coverage (i.e. for imported XML),\n // then increase the width of sequence column by the width of coverage\n // column.\n\n if (this.props.imported_xml) seqwidth += 15;\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"table-hit-overview\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"h4\", {\n className: \"caption\",\n \"data-toggle\": \"collapse\",\n \"data-target\": '#Query_' + this.props.query.number + 'HT_' + this.props.query.number,\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"i\", {\n className: \"fa fa-minus-square-o\"\n }), \"\\xA0\", /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"span\", {\n children: \"Sequences producing significant alignments\"\n })]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"div\", {\n className: \"collapsed in\",\n id: 'Query_' + this.props.query.number + 'HT_' + this.props.query.number,\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"table\", {\n className: \"table table-hover table-condensed tabular-view \",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"thead\", {\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"tr\", {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n className: \"text-left\",\n children: \"#\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"\".concat(seqwidth, \"%\"),\n children: \"Similar sequences\"\n }), hasName && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"15%\",\n className: \"text-left\",\n children: \"Species\"\n }), !this.props.imported_xml && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"15%\",\n className: \"text-right\",\n children: \"Query coverage (%)\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"10%\",\n className: \"text-right\",\n children: \"Total score\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"10%\",\n className: \"text-right\",\n children: \"E value\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"th\", {\n width: \"10%\",\n className: \"text-right\",\n children: \"Identity (%)\"\n })]\n })\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"tbody\", {\n children: underscore__WEBPACK_IMPORTED_MODULE_1__[\"default\"].map(this.props.query.hits, underscore__WEBPACK_IMPORTED_MODULE_1__[\"default\"].bind(function (hit) {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"tr\", {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-left\",\n children: hit.number + '.'\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"nowrap-ellipsis\",\n title: \"\".concat(hit.id, \" \").concat(hit.title),\n \"data-toggle\": \"tooltip\",\n \"data-placement\": \"left\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"a\", {\n href: '#Query_' + this.props.query.number + '_hit_' + hit.number,\n className: \"btn-link\",\n children: [hit.id, \" \", hit.title]\n })\n }), hasName && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"nowrap-ellipsis\",\n title: hit.sciname,\n \"data-toggle\": \"tooltip\",\n \"data-placement\": \"top\",\n children: hit.sciname\n }), !this.props.imported_xml && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-right\",\n children: hit.qcovs\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-right\",\n children: hit.total_score\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-right\",\n children: _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].inExponential(hit.hsps[0].evalue)\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"td\", {\n className: \"text-right\",\n children: _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].inPercentage(hit.hsps[0].identity, hit.hsps[0].length)\n })]\n }, hit.number);\n }, this))\n })]\n })\n })]\n });\n }\n }]);\n\n return HitsTable;\n}(react__WEBPACK_IMPORTED_MODULE_0__.Component);\n\n//# sourceURL=webpack://SequenceServer/./public/js/query.js?"); /***/ }),