@datagrok/peptides 1.21.0 → 1.21.1

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@datagrok/peptides",
3
3
  "friendlyName": "Peptides",
4
- "version": "1.21.0",
4
+ "version": "1.21.1",
5
5
  "author": {
6
6
  "name": "Davit Rizhinashvili",
7
7
  "email": "drizhinashvili@datagrok.ai"
@@ -602,7 +602,16 @@ export class LogoSummaryTable extends DG.JsViewer implements ILogoSummaryTable {
602
602
  grid.props.rowHeight = 55;
603
603
 
604
604
  const webLogoCache = new DG.LruCache<number, DG.Viewer & IWebLogoViewer>();
605
- // @ts-ignore TODO: fix after api update
605
+ const webLogoPromiseCache = new Map<number, boolean>();// this map will keep the promises for weblogo creation
606
+
607
+ let invalidateTimeout: any = null;
608
+
609
+ const debouncedInvalidate = (): void => {
610
+ if (invalidateTimeout)
611
+ clearTimeout(invalidateTimeout);
612
+ invalidateTimeout = setTimeout(() => grid.invalidate(), 200);
613
+ };
614
+
606
615
  const distCache = new DG.LruCache<number, DG.Viewer<DG.IHistogramSettings>>();
607
616
  const maxSequenceLen = this.positionColumns.length;
608
617
  const webLogoGridCol = grid.columns.byName(C.LST_COLUMN_NAMES.WEB_LOGO)!;
@@ -611,7 +620,7 @@ export class LogoSummaryTable extends DG.JsViewer implements ILogoSummaryTable {
611
620
  const activityCol = this.getScaledActivityColumn(isDfFiltered);
612
621
  const pepCol: DG.Column<string> = filteredDf.getCol(this.sequenceColumnName);
613
622
 
614
- grid.onCellRender.subscribe(async (gridCellArgs) => {
623
+ grid.onCellRender.subscribe((gridCellArgs) => {
615
624
  const gridCell = gridCellArgs.cell;
616
625
  const currentRowIdx = gridCell.tableRowIndex;
617
626
  if (!gridCell.isTableCell || currentRowIdx == null || currentRowIdx === -1)
@@ -633,9 +642,14 @@ export class LogoSummaryTable extends DG.JsViewer implements ILogoSummaryTable {
633
642
  CR.renderLogoSummaryCell(canvasContext, gridCell.cell.value, this.clusterSelection, bound);
634
643
  gridCellArgs.preventDefault();
635
644
  } else if (gridCell.tableColumn?.name === C.LST_COLUMN_NAMES.WEB_LOGO) {
645
+ // if current weblogo is being created, prevent the creation of another one
646
+ if (webLogoPromiseCache.get(currentRowIdx) === true) {
647
+ gridCellArgs.preventDefault();
648
+ return;
649
+ }
636
650
  const positionWidth = Math.floor((gridCell.bounds.width - 2 - (4 * (maxSequenceLen - 1))) / maxSequenceLen);
637
651
 
638
- let viewer = webLogoCache.get(currentRowIdx);
652
+ const viewer = webLogoCache.get(currentRowIdx);
639
653
  if (viewer !== undefined) {
640
654
  const viewerProps = viewer.getProperties();
641
655
 
@@ -649,9 +663,13 @@ export class LogoSummaryTable extends DG.JsViewer implements ILogoSummaryTable {
649
663
  }
650
664
  const viewerRoot = $(viewer.root).css('height', `${height}px`);//;
651
665
  viewerRoot.children().first().css('overflow-y', 'hidden !important');
666
+ viewer.root.style.height = `${height}px`;
667
+ gridCell.element = viewer.root;
668
+ gridCellArgs.preventDefault();
652
669
  } else {
653
670
  const webLogoTable = this.createWebLogoDf(pepCol, clusterBitSet);
654
- viewer = await webLogoTable.plot
671
+ webLogoPromiseCache.set(currentRowIdx, true);
672
+ webLogoTable.plot
655
673
  .fromType('WebLogo', {
656
674
  positionHeight: this.webLogoMode,
657
675
  horizontalAlignment: HorizontalAlignments.LEFT,
@@ -659,12 +677,13 @@ export class LogoSummaryTable extends DG.JsViewer implements ILogoSummaryTable {
659
677
  minHeight: height,
660
678
  positionWidth: positionWidth,
661
679
  showPositionLabels: false,
680
+ }).then((v) => {
681
+ webLogoCache.set(currentRowIdx, v);
682
+ webLogoPromiseCache.delete(currentRowIdx);
683
+ debouncedInvalidate();
662
684
  });
663
- webLogoCache.set(currentRowIdx, viewer);
685
+ gridCellArgs.preventDefault();
664
686
  }
665
- viewer.root.style.height = `${height}px`;
666
- gridCell.element = viewer.root;
667
- gridCellArgs.preventDefault();
668
687
  } else if (gridCell.tableColumn?.name === C.LST_COLUMN_NAMES.DISTRIBUTION) {
669
688
  let viewer = distCache.get(currentRowIdx);
670
689
  if (viewer === undefined) {