jbrowse-plugin-protein3d 0.4.6 → 0.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,21 +19,18 @@ export default function TranscriptSelector({ val, setVal, isoforms, isoformSeque
19
19
  nonMatches.push(f);
20
20
  }
21
21
  }
22
- matches.sort((a, b) => isoformSequences[b.id()].seq.length -
23
- isoformSequences[a.id()].seq.length);
24
- nonMatches.sort((a, b) => isoformSequences[b.id()].seq.length -
25
- isoformSequences[a.id()].seq.length);
22
+ const byLengthDesc = (a, b) => isoformSequences[b.id()].seq.length - isoformSequences[a.id()].seq.length;
26
23
  return (React.createElement(TextField, { value: val ?? '', onChange: event => {
27
24
  setVal(event.target.value);
28
25
  }, label: "Choose transcript isoform", select: true, disabled: disabled },
29
- matches.map(f => (React.createElement(MenuItem, { value: f.id(), key: f.id() },
26
+ matches.toSorted(byLengthDesc).map(f => (React.createElement(MenuItem, { value: f.id(), key: f.id() },
30
27
  geneName,
31
28
  " - ",
32
29
  getTranscriptDisplayName(f),
33
30
  " (",
34
31
  isoformSequences[f.id()].seq.length,
35
32
  "aa) (matches structure residues)"))),
36
- nonMatches.map(f => (React.createElement(MenuItem, { value: f.id(), key: f.id() },
33
+ nonMatches.toSorted(byLengthDesc).map(f => (React.createElement(MenuItem, { value: f.id(), key: f.id() },
37
34
  geneName,
38
35
  " - ",
39
36
  getTranscriptDisplayName(f),
@@ -81,8 +81,7 @@ export async function pollFoldseekStatus(ticketId) {
81
81
  return result;
82
82
  }
83
83
  export async function getFoldseekResults(ticketId) {
84
- const result = await jsonfetch(`https://search.foldseek.com/api/result/${ticketId}/0`);
85
- return result;
84
+ return jsonfetch(`https://search.foldseek.com/api/result/${ticketId}/0`);
86
85
  }
87
86
  export async function waitForFoldseekResults(ticketId, onStatusChange) {
88
87
  const maxAttempts = 180;
@@ -32,7 +32,7 @@ function buildXrefQuery(id) {
32
32
  }
33
33
  async function searchUniProt(query, size = 10) {
34
34
  const url = `https://rest.uniprot.org/uniprotkb/search?query=${encodeURIComponent(query)}&fields=${UNIPROT_FIELDS}&size=${size}`;
35
- const data = (await jsonfetch(url));
35
+ const data = await jsonfetch(url);
36
36
  return data.results.map(mapApiResultToEntry);
37
37
  }
38
38
  async function searchByXref(id) {
@@ -30,20 +30,20 @@ export function dedupe(list) {
30
30
  return list.filter((item, pos, ary) => !pos || getItemId(item) !== getItemId(ary[pos - 1]));
31
31
  }
32
32
  export function getProteinSequence({ feature, seq, }) {
33
- // @ts-expect-error
34
- const f = feature.toJSON();
35
- const subfeatures = f.subfeatures;
33
+ const featureStart = feature.get('start');
34
+ const strand = feature.get('strand');
35
+ const subfeatures = feature.get('subfeatures') ?? [];
36
36
  const cds = dedupe(subfeatures
37
- .toSorted((a, b) => a.start - b.start)
37
+ .toSorted((a, b) => a.get('start') - b.get('start'))
38
38
  .map(sub => ({
39
- ...sub,
40
- start: sub.start - f.start,
41
- end: sub.end - f.start,
39
+ start: sub.get('start') - featureStart,
40
+ end: sub.get('end') - featureStart,
41
+ type: sub.get('type'),
42
42
  }))
43
43
  .filter(f => f.type === 'CDS'));
44
44
  return calculateProteinSequence({
45
- cds: f.strand === -1 ? revlist(cds, seq.length) : cds,
46
- sequence: f.strand === -1 ? revcom(seq) : seq,
45
+ cds: strand === -1 ? revlist(cds, seq.length) : cds,
46
+ sequence: strand === -1 ? revcom(seq) : seq,
47
47
  codonTable: generateCodonTable(defaultCodonTable),
48
48
  });
49
49
  }
@@ -1,9 +1,22 @@
1
1
  import loadMolstar from './loadMolstar';
2
2
  import { getMolstarStructureSelection } from './util';
3
- export async function applyLociInteractivityMultiple({ structure, residues, plugin, mode, }) {
4
- if (mode === 'clear' || residues.length === 0) {
3
+ function clearLoci(plugin) {
4
+ plugin.managers.interactivity.lociHighlights.clearHighlights();
5
+ plugin.managers.interactivity.lociSelects.deselectAll();
6
+ }
7
+ function applyLoci(plugin, loci, mode) {
8
+ if (mode === 'highlight') {
5
9
  plugin.managers.interactivity.lociHighlights.clearHighlights();
10
+ plugin.managers.interactivity.lociHighlights.highlight({ loci });
11
+ }
12
+ else {
6
13
  plugin.managers.interactivity.lociSelects.deselectAll();
14
+ plugin.managers.interactivity.lociSelects.select({ loci });
15
+ }
16
+ }
17
+ export async function applyLociInteractivityMultiple({ structure, residues, plugin, mode, }) {
18
+ if (mode === 'clear' || residues.length === 0) {
19
+ clearLoci(plugin);
7
20
  return;
8
21
  }
9
22
  const { StructureSelection, Script } = await loadMolstar();
@@ -15,18 +28,11 @@ export async function applyLociInteractivityMultiple({ structure, residues, plug
15
28
  'group-by': Q.struct.atomProperty.macromolecular.residueKey(),
16
29
  }), structure);
17
30
  const loci = StructureSelection.toLociWithSourceUnits(sel);
18
- if (mode === 'highlight') {
19
- plugin.managers.interactivity.lociHighlights.clearHighlights();
20
- plugin.managers.interactivity.lociHighlights.highlight({ loci });
21
- }
22
- else {
23
- plugin.managers.interactivity.lociSelects.deselectAll();
24
- plugin.managers.interactivity.lociSelects.select({ loci });
25
- }
31
+ applyLoci(plugin, loci, mode);
26
32
  }
27
33
  export async function applyLociInteractivity({ structure, startResidue, endResidue, plugin, mode, }) {
28
34
  if (mode === 'clear') {
29
- plugin.managers.interactivity.lociHighlights.clearHighlights();
35
+ clearLoci(plugin);
30
36
  return;
31
37
  }
32
38
  const { StructureSelection, Script } = await loadMolstar();
@@ -44,18 +50,11 @@ export async function applyLociInteractivity({ structure, startResidue, endResid
44
50
  'group-by': Q.struct.atomProperty.macromolecular.residueKey(),
45
51
  }), structure);
46
52
  const loci = StructureSelection.toLociWithSourceUnits(sel);
47
- if (mode === 'highlight') {
48
- plugin.managers.interactivity.lociHighlights.clearHighlights();
49
- plugin.managers.interactivity.lociHighlights.highlight({ loci });
50
- }
51
- else {
52
- plugin.managers.interactivity.lociSelects.deselectAll();
53
- plugin.managers.interactivity.lociSelects.select({ loci });
54
- }
53
+ applyLoci(plugin, loci, mode);
55
54
  }
56
55
  export async function applyLociInteractivitySingle({ structure, selectedResidue, plugin, mode, }) {
57
56
  if (mode === 'clear') {
58
- plugin.managers.interactivity.lociHighlights.clearHighlights();
57
+ clearLoci(plugin);
59
58
  return;
60
59
  }
61
60
  const { StructureSelection } = await loadMolstar();
@@ -64,12 +63,5 @@ export async function applyLociInteractivitySingle({ structure, selectedResidue,
64
63
  selectedResidue: selectedResidue + 1,
65
64
  });
66
65
  const loci = StructureSelection.toLociWithSourceUnits(sel);
67
- if (mode === 'highlight') {
68
- plugin.managers.interactivity.lociHighlights.clearHighlights();
69
- plugin.managers.interactivity.lociHighlights.highlight({ loci });
70
- }
71
- else {
72
- plugin.managers.interactivity.lociSelects.deselectAll();
73
- plugin.managers.interactivity.lociSelects.select({ loci });
74
- }
66
+ applyLoci(plugin, loci, mode);
75
67
  }
@@ -1,3 +1,3 @@
1
1
  export declare function myfetch(url: string, args?: RequestInit): Promise<Response>;
2
- export declare function jsonfetch(url: string, args?: RequestInit): Promise<any>;
2
+ export declare function jsonfetch<T = unknown>(url: string, args?: RequestInit): Promise<T>;
3
3
  export declare function timeout(time: number): Promise<unknown>;