@datagrok/bio 2.21.7 → 2.21.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "name": "Leonid Stolbov",
6
6
  "email": "lstolbov@datagrok.ai"
7
7
  },
8
- "version": "2.21.7",
8
+ "version": "2.21.8",
9
9
  "description": "Bioinformatics support (import/export of sequences, conversion, visualization, analysis). [See more](https://github.com/datagrok-ai/public/blob/master/packages/Bio/README.md) for details.",
10
10
  "repository": {
11
11
  "type": "git",
@@ -44,7 +44,7 @@
44
44
  ],
45
45
  "dependencies": {
46
46
  "@biowasm/aioli": "^3.1.0",
47
- "@datagrok-libraries/bio": "^5.52.2",
47
+ "@datagrok-libraries/bio": "^5.53.0",
48
48
  "@datagrok-libraries/chem-meta": "^1.2.7",
49
49
  "@datagrok-libraries/math": "^1.2.4",
50
50
  "@datagrok-libraries/ml": "^6.10.0",
@@ -30,20 +30,26 @@ export function handleSequenceHeaderRendering() {
30
30
  if (!gCol)
31
31
  continue;
32
32
 
33
- let positionStatsViewerAddedOnce = false;
34
-
33
+ let positionStatsViewerAddedOnce = !!grid.tableView && Array.from(grid.tableView.viewers).some((v) => v.type === 'Sequence Position Statistics');
34
+ const isMSA = sh.isMsa();
35
35
  const ifNan = (a: number, els: number) => (Number.isNaN(a) ? els : a);
36
36
  const getStart = () => ifNan(Math.max(Number.parseInt(seqCol.getTag(bioTAGS.positionShift) ?? '0'), 0), 0) + 1;
37
37
  const getCurrent = () => ifNan(Number.parseInt(seqCol.getTag(bioTAGS.selectedPosition) ?? '-2'), -2);
38
38
  const getFontSize = () => MonomerPlacer.getFontSettings(seqCol).fontWidth;
39
- // get the maximum length of sequences by randomly taking 10 sequences;
40
- let maxSeqLen = 0;
41
- for (let i = 0; i < Math.min(30, seqCol.categories.length); i++) {
42
- const row = Math.floor(Math.random() * seqCol.categories.length - 1);
43
- const seq = sh.splitter(seqCol.categories[row]);
44
- if (seq)
45
- maxSeqLen = Math.max(maxSeqLen, seq.length);
39
+ // get the maximum length of seqs by getting the primitive length first and then splitting it with correct splitter;
40
+ let pseudoMaxLenIndex = 0;
41
+ let pseudoMaxLength = 0;
42
+ const cats = seqCol.categories;
43
+ for (let i = 0; i < cats.length; i++) {
44
+ const seq = cats[i];
45
+ if (seq && seq.length > pseudoMaxLength) {
46
+ pseudoMaxLength = seq.length;
47
+ pseudoMaxLenIndex = i;
48
+ }
46
49
  }
50
+ const seq = cats[pseudoMaxLenIndex];
51
+ const split = sh.splitter(seq);
52
+ const maxSeqLen = split ? split.length : 30;
47
53
 
48
54
  // makes no sense to have scroller if we have shorter than 50 positions
49
55
  if (maxSeqLen < 50)
@@ -114,11 +120,10 @@ export function handleSequenceHeaderRendering() {
114
120
 
115
121
  const titleShift = Math.max(0, availableTitleSpace ?? 0) > headerTitleSpace ? headerTitleSpace : 0;
116
122
  const font = getFontSize();
117
- scroller.positionWidth = font + 8;
123
+ scroller.positionWidth = font + (isMSA ? 8 : 0);
118
124
  const start = getStart();
119
- //const positionXShift = start > 1 ? font + 8 : 0;
120
- // pass in the event to the scroller so it can internally preventDefault if all is well
121
- scroller.draw(cellBounds.x, cellBounds.y + titleShift, cellBounds.width, cellBounds.height - titleShift, getCurrent(), start, e);
125
+ const startPadding = isMSA ? 0 : 4;
126
+ scroller.draw(cellBounds.x + startPadding, cellBounds.y + titleShift, cellBounds.width - startPadding, cellBounds.height - titleShift, getCurrent(), start, e);
122
127
  }));
123
128
  }
124
129
  }, 1000);