@jbrowse/plugin-blat 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/LICENSE +201 -0
  2. package/esm/BlatDialog.d.ts +6 -0
  3. package/esm/BlatDialog.js +93 -0
  4. package/esm/IsPcrDialog.d.ts +6 -0
  5. package/esm/IsPcrDialog.js +101 -0
  6. package/esm/MonospaceTextField.d.ts +2 -0
  7. package/esm/MonospaceTextField.js +8 -0
  8. package/esm/UcscQueryActions.d.ts +8 -0
  9. package/esm/UcscQueryActions.js +19 -0
  10. package/esm/UcscQueryFields.d.ts +8 -0
  11. package/esm/UcscQueryFields.js +31 -0
  12. package/esm/UcscQueryStatus.d.ts +5 -0
  13. package/esm/UcscQueryStatus.js +15 -0
  14. package/esm/UcscResultsWidget/UcscResultsWidget.d.ts +5 -0
  15. package/esm/UcscResultsWidget/UcscResultsWidget.js +23 -0
  16. package/esm/UcscResultsWidget/configSchema.d.ts +1 -0
  17. package/esm/UcscResultsWidget/configSchema.js +2 -0
  18. package/esm/UcscResultsWidget/hitSummary.d.ts +9 -0
  19. package/esm/UcscResultsWidget/hitSummary.js +31 -0
  20. package/esm/UcscResultsWidget/index.d.ts +2 -0
  21. package/esm/UcscResultsWidget/index.js +13 -0
  22. package/esm/UcscResultsWidget/stateModel.d.ts +42 -0
  23. package/esm/UcscResultsWidget/stateModel.js +41 -0
  24. package/esm/blatQuery.d.ts +75 -0
  25. package/esm/blatQuery.js +245 -0
  26. package/esm/desktopBlat.d.ts +9 -0
  27. package/esm/desktopBlat.js +22 -0
  28. package/esm/index.d.ts +7 -0
  29. package/esm/index.js +37 -0
  30. package/esm/ispcrQuery.d.ts +59 -0
  31. package/esm/ispcrQuery.js +160 -0
  32. package/esm/ispcrToSam.d.ts +9 -0
  33. package/esm/ispcrToSam.js +86 -0
  34. package/esm/pslToSam.d.ts +54 -0
  35. package/esm/pslToSam.js +153 -0
  36. package/esm/ucscDbMap.d.ts +2 -0
  37. package/esm/ucscDbMap.js +25 -0
  38. package/esm/ucscShared.d.ts +40 -0
  39. package/esm/ucscShared.js +116 -0
  40. package/esm/useUcscQuery.d.ts +40 -0
  41. package/esm/useUcscQuery.js +199 -0
  42. package/package.json +54 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [2020] [Evolutionary Software Foundation]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,6 @@
1
+ import type { UcscHost } from './ucscShared.ts';
2
+ declare const BlatDialog: ({ session, handleClose, }: {
3
+ session: UcscHost;
4
+ handleClose: () => void;
5
+ }) => import("react").JSX.Element;
6
+ export default BlatDialog;
@@ -0,0 +1,93 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import { Dialog } from '@jbrowse/core/ui';
4
+ import { DialogContent } from '@mui/material';
5
+ import { observer } from 'mobx-react';
6
+ import MonospaceTextField from './MonospaceTextField.js';
7
+ import UcscQueryActions from './UcscQueryActions.js';
8
+ import UcscQueryFields from './UcscQueryFields.js';
9
+ import UcscQueryStatus from './UcscQueryStatus.js';
10
+ import { DEFAULT_BLAT_URL, UCSC_BLAT_URL, MAXIMUM_BLAT_LENGTH, MAXIMUM_BLAT_QUERIES, MINIMUM_BLAT_LENGTH, buildBlatBody, fastaRecordCount, parseBlatResponse, pslToFeatures, queryLabel, stripFasta, } from './blatQuery.js';
11
+ import { parseQuerySequences, pslToSam } from './pslToSam.js';
12
+ import { canRenderAlignments } from './ucscShared.js';
13
+ import { runUcscFetch, useUcscQuery } from './useUcscQuery.js';
14
+ const BlatDialog = observer(function BlatDialog({ session, handleClose, }) {
15
+ const query = useUcscQuery({
16
+ session,
17
+ handleClose,
18
+ defaultUrl: DEFAULT_BLAT_URL,
19
+ directUrl: UCSC_BLAT_URL,
20
+ });
21
+ const { db, urlBase, fallbackUrl, apiKey } = query;
22
+ const [seq, setSeq] = useState('');
23
+ const residues = stripFasta(seq);
24
+ const queryCount = fastaRecordCount(seq);
25
+ const tooShort = residues.length < MINIMUM_BLAT_LENGTH;
26
+ const tooLong = residues.length > MAXIMUM_BLAT_LENGTH;
27
+ const tooMany = queryCount > MAXIMUM_BLAT_QUERIES;
28
+ const seqError = tooLong
29
+ ? `Sequence is ${residues.length.toLocaleString()} bp; UCSC BLAT is limited to ${MAXIMUM_BLAT_LENGTH.toLocaleString()} bp`
30
+ : tooMany
31
+ ? `${queryCount} sequences; UCSC BLAT is limited to ${MAXIMUM_BLAT_QUERIES} per query`
32
+ : tooShort && residues
33
+ ? `Sequence must be at least ${MINIMUM_BLAT_LENGTH} bp`
34
+ : '';
35
+ async function handleSubmit() {
36
+ const label = queryLabel(seq);
37
+ await query.runQuery({
38
+ // PSL states each hit as aligned blocks in query and target coordinates,
39
+ // which is a CIGAR alignment: converting to SAM and showing it in an
40
+ // alignments track draws the hit's exon-like blocks, its indels, the
41
+ // unaligned ends of the query as soft clips, and — since the submitted
42
+ // sequence is right here — its mismatches against the reference.
43
+ fetchResult: async () => {
44
+ const rows = await runUcscFetch({
45
+ urlBase,
46
+ fallbackUrl,
47
+ body: buildBlatBody({ db, seq: seq.trim(), apiKey }),
48
+ parse: parseBlatResponse,
49
+ });
50
+ return {
51
+ features: pslToFeatures(rows),
52
+ // an older host has no SamAdapter; addResultTrack then falls back to
53
+ // drawing the hits' block structure as a plain feature track
54
+ trackConf: canRenderAlignments(session)
55
+ ? {
56
+ type: 'AlignmentsTrack',
57
+ adapter: {
58
+ type: 'SamAdapter',
59
+ samText: pslToSam(rows, parseQuerySequences(seq)),
60
+ },
61
+ // A handful of hits has no depth to read, so the coverage band is 45
62
+ // pixels saying "1" over the one place the query landed. The hits
63
+ // themselves are the answer here, unlike a sequencing pileup.
64
+ //
65
+ // heightMode 'grow' would also be the natural fit (the content is a
66
+ // few hits of known size, so the fixed lane is mostly empty), but a
67
+ // single-hit track grown to its content comes out with the read
68
+ // clipped by the bottom edge of the view. Left off until that is
69
+ // understood.
70
+ displayDefaults: { showCoverage: false },
71
+ }
72
+ : undefined,
73
+ };
74
+ },
75
+ trackIdPrefix: 'blat',
76
+ trackName: queryCount > 1 ? `BLAT ${label} +${queryCount - 1}` : `BLAT ${label}`,
77
+ emptyMessage: `No BLAT hits found in ${db}`,
78
+ });
79
+ }
80
+ return (_jsxs(Dialog, { open: true,
81
+ // the sequence box is the dialog, and a pasted read or FASTA line wraps
82
+ // every 40-odd bases at the default 600px — wide enough to read a
83
+ // sequence without horizontal hunting
84
+ maxWidth: "md", fullWidth: true, title: "BLAT search (UCSC)", onClose: () => {
85
+ handleClose();
86
+ }, children: [_jsxs(DialogContent, { style: { display: 'flex', flexDirection: 'column', gap: 12 }, children: [_jsx(MonospaceTextField, { label: "Sequence", value: seq, onChange: event => {
87
+ setSeq(event.target.value);
88
+ }, multiline: true, minRows: 6, maxRows: 14, autoFocus: true, placeholder: "Paste a DNA sequence or FASTA to locate it in the genome", error: !!seqError, helperText: seqError ||
89
+ 'DNA, or FASTA with up to 25 records, 25 kb total. Hits are added as a track, and listed best-first in a panel where each one is a link.' }), _jsx(UcscQueryFields, { session: session, query: query, urlLabel: "BLAT server URL" }), _jsx(UcscQueryStatus, { query: query })] }), _jsx(UcscQueryActions, { query: query, submitDisabled: tooShort || tooLong || tooMany || !db, onSubmit: () => void handleSubmit(), onCancel: () => {
90
+ handleClose();
91
+ } })] }));
92
+ });
93
+ export default BlatDialog;
@@ -0,0 +1,6 @@
1
+ import type { UcscHost } from './ucscShared.ts';
2
+ declare const IsPcrDialog: ({ session, handleClose, }: {
3
+ session: UcscHost;
4
+ handleClose: () => void;
5
+ }) => import("react").JSX.Element;
6
+ export default IsPcrDialog;
@@ -0,0 +1,101 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import { Dialog, NumberTextField } from '@jbrowse/core/ui';
4
+ import { DialogContent, Typography } from '@mui/material';
5
+ import { observer } from 'mobx-react';
6
+ import MonospaceTextField from './MonospaceTextField.js';
7
+ import UcscQueryActions from './UcscQueryActions.js';
8
+ import UcscQueryFields from './UcscQueryFields.js';
9
+ import UcscQueryStatus from './UcscQueryStatus.js';
10
+ import { DEFAULT_ISPCR_URL, UCSC_ISPCR_URL, DEFAULT_MAX_PRODUCT_SIZE, MINIMUM_PRIMER_LENGTH, buildIsPcrBody, parseIsPcrProducts, pcrProductsToFeatures, } from './ispcrQuery.js';
11
+ import { ispcrToSam } from './ispcrToSam.js';
12
+ import { canRenderAlignments } from './ucscShared.js';
13
+ import { runUcscFetch, useUcscQuery } from './useUcscQuery.js';
14
+ function cleanPrimer(seq) {
15
+ return seq.replaceAll(/\s/g, '').toUpperCase();
16
+ }
17
+ const IsPcrDialog = observer(function IsPcrDialog({ session, handleClose, }) {
18
+ const query = useUcscQuery({
19
+ session,
20
+ handleClose,
21
+ defaultUrl: DEFAULT_ISPCR_URL,
22
+ directUrl: UCSC_ISPCR_URL,
23
+ });
24
+ const { db, urlBase, fallbackUrl, apiKey } = query;
25
+ const [forwardPrimer, setForwardPrimer] = useState('');
26
+ const [reversePrimer, setReversePrimer] = useState('');
27
+ // NumberTextField emits undefined for an empty or out-of-bounds entry, which
28
+ // is what gates submit — no local parse/validate needed
29
+ const [maxProductSize, setMaxProductSize] = useState(DEFAULT_MAX_PRODUCT_SIZE);
30
+ const fwd = cleanPrimer(forwardPrimer);
31
+ const rev = cleanPrimer(reversePrimer);
32
+ const tooShort = fwd.length < MINIMUM_PRIMER_LENGTH || rev.length < MINIMUM_PRIMER_LENGTH;
33
+ async function handleSubmit() {
34
+ // submit is disabled while the size is undefined, so this only narrows the
35
+ // type rather than guarding a reachable state
36
+ if (maxProductSize !== undefined) {
37
+ await query.runQuery({
38
+ // A product is a primer pair with an insert between them, which is a read
39
+ // pair: shown as an alignments track with view-as-pairs on, each product
40
+ // draws as the two primers facing inward joined by the amplicon. The
41
+ // primers' own bases come along, so a base where one disagrees with the
42
+ // template draws as a mismatch rather than being assumed away. The size,
43
+ // which is the band on a gel, is TLEN and is reported by the results panel
44
+ // — the pair glyph itself carries no size label.
45
+ fetchResult: async () => {
46
+ const products = await runUcscFetch({
47
+ urlBase,
48
+ fallbackUrl,
49
+ body: buildIsPcrBody({
50
+ db,
51
+ forwardPrimer: fwd,
52
+ reversePrimer: rev,
53
+ maxProductSize,
54
+ apiKey,
55
+ }),
56
+ parse: parseIsPcrProducts,
57
+ });
58
+ return {
59
+ features: pcrProductsToFeatures(products),
60
+ // an older host has no SamAdapter; the products then draw as plain
61
+ // features rather than as the read pairs this configures
62
+ trackConf: canRenderAlignments(session)
63
+ ? {
64
+ type: 'AlignmentsTrack',
65
+ adapter: {
66
+ type: 'SamAdapter',
67
+ samText: ispcrToSam(products),
68
+ },
69
+ // a handful of products has no depth to read, and the pair glyph is
70
+ // the whole point, so it is on rather than a menu step away
71
+ displayDefaults: {
72
+ showCoverage: false,
73
+ linkedReads: 'normal',
74
+ },
75
+ }
76
+ : undefined,
77
+ };
78
+ },
79
+ trackIdPrefix: 'ispcr',
80
+ trackName: `PCR ${fwd.slice(0, 10)}…/${rev.slice(0, 10)}…`,
81
+ emptyMessage: `No PCR products found in ${db}`,
82
+ resultNoun: 'product',
83
+ });
84
+ }
85
+ }
86
+ return (_jsxs(Dialog, { open: true,
87
+ // matches BlatDialog: wide enough that the two primers sit side by side on
88
+ // one row instead of stacking down a narrow column
89
+ maxWidth: "md", fullWidth: true, title: "In-silico PCR (UCSC)", onClose: () => {
90
+ handleClose();
91
+ }, children: [_jsxs(DialogContent, { style: { display: 'flex', flexDirection: 'column', gap: 8 }, children: [_jsx(Typography, { variant: "body2", children: "Primer pairs are queried against the UCSC in-silico PCR server; products are added as a new track." }), _jsxs("div", { style: { display: 'flex', gap: 8 }, children: [_jsx(MonospaceTextField, { label: "Forward primer", value: forwardPrimer, onChange: event => {
92
+ setForwardPrimer(event.target.value);
93
+ }, placeholder: "e.g. GTGACGTCGTGACCTAGG", fullWidth: true, error: fwd.length > 0 && fwd.length < MINIMUM_PRIMER_LENGTH }), _jsx(MonospaceTextField, { label: "Reverse primer", value: reversePrimer, onChange: event => {
94
+ setReversePrimer(event.target.value);
95
+ }, placeholder: "e.g. CCTAGGTTGACGTCACGA", fullWidth: true, error: rev.length > 0 && rev.length < MINIMUM_PRIMER_LENGTH })] }), _jsx(NumberTextField, { label: "Max product size (bp)", variant: "outlined", size: "small", style: { alignSelf: 'flex-start', width: 200 }, defaultValue: DEFAULT_MAX_PRODUCT_SIZE, min: 1, onValueChange: value => {
96
+ setMaxProductSize(value);
97
+ }, errorText: "Enter a positive number" }), tooShort && (fwd || rev) ? (_jsx(Typography, { color: "error", variant: "body2", children: `Primers must be at least ${MINIMUM_PRIMER_LENGTH} bp` })) : null, _jsx(UcscQueryFields, { session: session, query: query, urlLabel: "In-silico PCR server URL" }), _jsx(UcscQueryStatus, { query: query })] }), _jsx(UcscQueryActions, { query: query, submitDisabled: tooShort || maxProductSize === undefined || !db, onSubmit: () => void handleSubmit(), onCancel: () => {
98
+ handleClose();
99
+ } })] }));
100
+ });
101
+ export default IsPcrDialog;
@@ -0,0 +1,2 @@
1
+ import type { TextFieldProps } from '@mui/material';
2
+ export default function MonospaceTextField(props: TextFieldProps): import("react").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { TextField } from '@mui/material';
3
+ // Outlined + monospace: the sequence/primer inputs that are the point of these
4
+ // dialogs, kept visually distinct from the standard-variant UCSC override fields
5
+ // (db/url/apiKey) that most users never touch.
6
+ export default function MonospaceTextField(props) {
7
+ return (_jsx(TextField, { variant: "outlined", ...props, slotProps: { htmlInput: { style: { fontFamily: 'monospace' } } } }));
8
+ }
@@ -0,0 +1,8 @@
1
+ import type { UcscQuery } from './useUcscQuery.ts';
2
+ declare const UcscQueryActions: ({ query, submitDisabled, onSubmit, onCancel, }: {
3
+ query: UcscQuery;
4
+ submitDisabled: boolean;
5
+ onSubmit: () => void;
6
+ onCancel: () => void;
7
+ }) => import("react").JSX.Element;
8
+ export default UcscQueryActions;
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { isElectron } from '@jbrowse/core/util';
3
+ import { Button, DialogActions } from '@mui/material';
4
+ import { observer } from 'mobx-react';
5
+ // The Cancel / Solve CAPTCHA / Submit footer shared by the BLAT and in-silico
6
+ // PCR dialogs. Each dialog supplies its own submit-disabled predicate; the
7
+ // challenge-solve affordance only appears on desktop, where a window can be
8
+ // opened to clear the Cloudflare Turnstile.
9
+ const UcscQueryActions = observer(function UcscQueryActions({ query, submitDisabled, onSubmit, onCancel, }) {
10
+ const { loading, challenged } = query;
11
+ return (_jsxs(DialogActions, { children: [_jsx(Button, { variant: "contained", color: "secondary", onClick: () => {
12
+ onCancel();
13
+ }, children: "Cancel" }), challenged && isElectron ? (_jsx(Button, { variant: "outlined", disabled: loading, onClick: () => void query.solveChallenge(() => {
14
+ onSubmit();
15
+ }), children: "Solve CAPTCHA" })) : null, _jsx(Button, { variant: "contained", disabled: loading || submitDisabled, onClick: () => {
16
+ onSubmit();
17
+ }, children: loading ? 'Searching…' : 'Submit' })] }));
18
+ });
19
+ export default UcscQueryActions;
@@ -0,0 +1,8 @@
1
+ import type { UcscHost } from './ucscShared.ts';
2
+ import type { UcscQuery } from './useUcscQuery.ts';
3
+ declare const UcscQueryFields: ({ session, query, urlLabel, }: {
4
+ session: UcscHost;
5
+ query: UcscQuery;
6
+ urlLabel: string;
7
+ }) => import("react").JSX.Element;
8
+ export default UcscQueryFields;
@@ -0,0 +1,31 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import { AssemblySelector } from '@jbrowse/core/ui';
4
+ import ExpandLessIcon from '@mui/icons-material/ExpandLess';
5
+ import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
6
+ import { Alert, Button, TextField } from '@mui/material';
7
+ import { observer } from 'mobx-react';
8
+ import { looksLikeUcscDb } from './ucscDbMap.js';
9
+ import { ucscDbStamp } from './ucscShared.js';
10
+ // The UCSC connection fields shared by the BLAT and in-silico PCR dialogs. The
11
+ // assembly picker is the only thing most users touch, so it stays visible; the
12
+ // resolved db id, server URL, and apiKey collapse behind a toggle.
13
+ const UcscQueryFields = observer(function UcscQueryFields({ session, query, urlLabel, }) {
14
+ const { assembly, db, urlBase, apiKey } = query;
15
+ const [showAdvanced, setShowAdvanced] = useState(false);
16
+ // the query is only as good as the db behind it, and nothing about a locally
17
+ // opened genome says UCSC has never heard of it until the request comes back
18
+ const searchable = !!ucscDbStamp(session, assembly) || looksLikeUcscDb(db);
19
+ return (_jsxs(_Fragment, { children: [_jsx("div", { style: { alignSelf: 'flex-start', minWidth: 260 }, children: _jsx(AssemblySelector, { session: session, selected: assembly, onChange: arg => {
20
+ query.changeAssembly(arg);
21
+ }, fullWidth: true }) }), searchable ? null : (_jsx(Alert, { severity: "warning", children: `${assembly} has no UCSC database, so this would search "${db}". A genome opened from your own files is not hosted at UCSC; set the database under advanced settings if one exists.` })), _jsxs(Button, { size: "small", style: { alignSelf: 'flex-start' }, startIcon: showAdvanced ? _jsx(ExpandLessIcon, {}) : _jsx(ExpandMoreIcon, {}), onClick: () => {
22
+ setShowAdvanced(!showAdvanced);
23
+ }, children: [showAdvanced ? 'Hide' : 'Show', " advanced settings"] }), showAdvanced ? (_jsxs(_Fragment, { children: [_jsx(TextField, { label: "UCSC database", value: db, onChange: event => {
24
+ query.setDb(event.target.value);
25
+ }, helperText: "UCSC db or GenArk accession to query (e.g. hg38 or GCF_000001405.40)" }), _jsx(TextField, { label: urlLabel, value: urlBase, onChange: event => {
26
+ query.setUrlBase(event.target.value);
27
+ }, helperText: "Point at a mirror or self-hosted proxy if the default is unavailable" }), _jsx(TextField, { label: "UCSC apiKey (optional)", value: apiKey, onChange: event => {
28
+ query.changeApiKey(event.target.value);
29
+ }, helperText: "Bypasses the UCSC CAPTCHA. Generate one at a UCSC Genome Browser account \u2192 Hub Development \u2192 API key. Not needed when the server URL is a proxy that injects a key." })] })) : null] }));
30
+ });
31
+ export default UcscQueryFields;
@@ -0,0 +1,5 @@
1
+ import type { UcscQuery } from './useUcscQuery.ts';
2
+ declare const UcscQueryStatus: ({ query, }: {
3
+ query: UcscQuery;
4
+ }) => import("react").JSX.Element;
5
+ export default UcscQueryStatus;
@@ -0,0 +1,15 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ErrorMessage } from '@jbrowse/core/ui';
3
+ import { isElectron } from '@jbrowse/core/util';
4
+ import { Typography } from '@mui/material';
5
+ import { observer } from 'mobx-react';
6
+ // Error and CAPTCHA-challenge feedback shared by the BLAT and in-silico PCR
7
+ // dialogs, driven by the shared query state. The solve-in-a-window affordance
8
+ // only exists on desktop, so the browser build points at the apiKey path only.
9
+ const UcscQueryStatus = observer(function UcscQueryStatus({ query, }) {
10
+ const { error, challenged, notFound } = query;
11
+ return (_jsxs(_Fragment, { children: [notFound ? (_jsx(Typography, { color: "textSecondary", children: notFound })) : null, error && !challenged ? _jsx(ErrorMessage, { error: error }) : null, challenged ? (_jsx(Typography, { children: isElectron
12
+ ? 'The UCSC server requires solving a CAPTCHA. Either paste a UCSC apiKey above to avoid it, or click "Solve CAPTCHA", complete it in the window that opens, and the search will retry automatically.'
13
+ : 'The UCSC server requires solving a CAPTCHA. Paste a UCSC apiKey above to avoid it.' })) : null] }));
14
+ });
15
+ export default UcscQueryStatus;
@@ -0,0 +1,5 @@
1
+ import type { UcscResultsWidgetModel } from './stateModel.ts';
2
+ declare const UcscResultsWidget: ({ model, }: {
3
+ model: UcscResultsWidgetModel;
4
+ }) => import("react").JSX.Element;
5
+ export default UcscResultsWidget;
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { getSession } from '@jbrowse/core/util';
3
+ import { Link, List, ListItem, Typography } from '@mui/material';
4
+ import { observer } from 'mobx-react';
5
+ import { featureLocString, navToFeature } from '../ucscShared.js';
6
+ import { hitSummary } from './hitSummary.js';
7
+ // The hit list for a BLAT / in-silico PCR query. The query deliberately does not
8
+ // navigate (see addResultTrack), so this is where the results become reachable:
9
+ // every hit is a link that takes the open view there, best-first, and going to
10
+ // one is a click rather than a re-run. A list rather than a table because the
11
+ // drawer is narrow and a hit's numbers read fine on one line under its
12
+ // coordinates.
13
+ const UcscResultsWidget = observer(function UcscResultsWidget({ model, }) {
14
+ const { features, assembly, trackName, resultNoun } = model;
15
+ const session = getSession(model);
16
+ const count = features.length;
17
+ const noun = count === 1 ? resultNoun : `${resultNoun}s`;
18
+ return (_jsxs("div", { style: { margin: 12 }, children: [_jsx(Typography, { children: `${count} ${noun} on ${assembly}, added as the track "${trackName}"` }), resultNoun === 'product' && count > 1 ? (_jsx(Typography, { variant: "body2", color: "warning.main", children: "These primers amplify more than once, so expect a band per product." })) : null, _jsx(List, { dense: true, children: features.map(feature => (_jsxs(ListItem, { disableGutters: true, style: { display: 'block' }, children: [_jsxs(Link, { href: "#", onClick: event => {
19
+ event.preventDefault();
20
+ void navToFeature(session, assembly, feature);
21
+ }, children: [featureLocString(feature), feature.strand === -1 ? ' (-)' : ' (+)'] }), _jsx(Typography, { variant: "body2", color: "textSecondary", children: hitSummary(feature) })] }, feature.uniqueId))) })] }));
22
+ });
23
+ export default UcscResultsWidget;
@@ -0,0 +1 @@
1
+ export declare const configSchema: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
@@ -0,0 +1,2 @@
1
+ import { ConfigurationSchema } from '@jbrowse/core/configuration';
2
+ export const configSchema = ConfigurationSchema('UcscResultsWidget', {});
@@ -0,0 +1,9 @@
1
+ import type { SimpleFeatureSerialized } from '@jbrowse/core/util';
2
+ /**
3
+ * The one line under a hit's location. A BLAT hit is judged on identity and on
4
+ * how much of the query it accounts for (a 99% hit over a tenth of the query is
5
+ * not the locus you searched for), an hgPcr product on its size and the primer
6
+ * pair that made it. Built from the fields the feature actually carries, so it
7
+ * can't claim a number the hit doesn't have.
8
+ */
9
+ export declare function hitSummary(feature: SimpleFeatureSerialized): string;
@@ -0,0 +1,31 @@
1
+ // feature fields are `unknown` off the serialized feature's index signature
2
+ function num(value) {
3
+ return typeof value === 'number' ? value : undefined;
4
+ }
5
+ function text(value) {
6
+ return typeof value === 'string' ? value : '';
7
+ }
8
+ /**
9
+ * The one line under a hit's location. A BLAT hit is judged on identity and on
10
+ * how much of the query it accounts for (a 99% hit over a tenth of the query is
11
+ * not the locus you searched for), an hgPcr product on its size and the primer
12
+ * pair that made it. Built from the fields the feature actually carries, so it
13
+ * can't claim a number the hit doesn't have.
14
+ */
15
+ export function hitSummary(feature) {
16
+ const identity = num(feature.identity);
17
+ const coverage = num(feature.coverage);
18
+ const forward = text(feature.forwardPrimer);
19
+ const reverse = text(feature.reversePrimer);
20
+ return identity === undefined
21
+ ? [text(feature.name), forward && reverse ? `${forward} / ${reverse}` : '']
22
+ .filter(Boolean)
23
+ .join(', ')
24
+ : [
25
+ text(feature.queryName),
26
+ `${identity}% identity`,
27
+ coverage === undefined ? '' : `${coverage}% of query`,
28
+ ]
29
+ .filter(Boolean)
30
+ .join(', ');
31
+ }
@@ -0,0 +1,2 @@
1
+ import type PluginManager from '@jbrowse/core/PluginManager';
2
+ export default function UcscResultsWidgetF(pluginManager: PluginManager): void;
@@ -0,0 +1,13 @@
1
+ import { lazy } from 'react';
2
+ import WidgetType from '@jbrowse/core/pluggableElementTypes/WidgetType';
3
+ import { configSchema } from './configSchema.js';
4
+ import { stateModelFactory } from './stateModel.js';
5
+ export default function UcscResultsWidgetF(pluginManager) {
6
+ pluginManager.addWidgetType(() => new WidgetType({
7
+ name: 'UcscResultsWidget',
8
+ heading: 'Search results',
9
+ configSchema,
10
+ stateModel: stateModelFactory(),
11
+ ReactComponent: lazy(() => import('./UcscResultsWidget.js')),
12
+ }));
13
+ }