@datagrok/peptides 1.27.10 → 1.28.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.
- package/.auth.json +1 -0
- package/.grokignore +2 -0
- package/.turbo/turbo-build.log +26 -0
- package/.vscode/settings.json +16 -0
- package/CHANGELOG.md +28 -0
- package/CLAUDE.md +69 -5
- package/dist/659.js +2 -0
- package/dist/659.js.map +1 -0
- package/dist/806.js +2 -0
- package/dist/806.js.map +1 -0
- package/dist/package-test.js +396 -1
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +361 -1
- package/dist/package.js.map +1 -1
- package/e2e/.auth.json +1 -0
- package/e2e/.auth.public.json +1 -0
- package/files/aligned_3.csv +6 -6
- package/package.json +32 -58
- package/rspack.config.js +3 -0
- package/src/demo/fasta.ts +0 -1
- package/src/model.ts +245 -131
- package/src/package-api.ts +18 -10
- package/src/package.g.ts +1 -0
- package/src/package.ts +19 -24
- package/src/tests/core.ts +6 -6
- package/src/tests/misc.ts +20 -0
- package/src/tests/model.ts +56 -6
- package/src/tests/table-view.ts +4 -4
- package/src/tests/utils.ts +56 -0
- package/src/tests/viewers.ts +270 -14
- package/src/tests/widgets.ts +13 -12
- package/src/utils/cell-renderer.ts +7 -6
- package/src/utils/constants.ts +10 -0
- package/src/utils/misc.ts +3 -3
- package/src/utils/statistics.ts +2 -2
- package/src/viewers/cluster-max-activity-viewer.ts +44 -11
- package/src/viewers/logo-summary.ts +126 -40
- package/src/viewers/mutation-cliffs-viewer.ts +56 -28
- package/src/viewers/peptide-generation-viewer.ts +7 -0
- package/src/viewers/position-statistics-viewer.ts +26 -4
- package/src/viewers/sar-viewer-status.ts +145 -0
- package/src/viewers/sar-viewer.ts +134 -42
- package/src/viewers/viewer-render-state.ts +68 -0
- package/src/widgets/distribution.ts +1 -1
- package/src/widgets/manual-alignment.ts +9 -22
- package/src/widgets/peptides.ts +101 -100
- package/src/widgets/selection.ts +1 -1
- package/src/widgets/settings.ts +11 -9
- package/test-playwright-report.json +73 -0
- package/test-report-playwright.csv +2 -0
- package/tsconfig.json +15 -69
- package/.eslintrc.json +0 -53
- package/dist/216.js +0 -2
- package/dist/216.js.map +0 -1
- package/dist/682.js +0 -2
- package/dist/682.js.map +0 -1
- package/dist/705.js +0 -2
- package/dist/705.js.map +0 -1
- package/dist/774.js +0 -2
- package/dist/774.js.map +0 -1
- package/dist/8473fcbfb6e85ca6c852.wasm +0 -0
- package/test-console-output-1.log +0 -603
- package/test-record-1.mp4 +0 -0
- package/webpack.config.js +0 -60
- /package/dist/{9a8fbf37666e32487835.wasm → wasmDbscan.wasm} +0 -0
package/src/model.ts
CHANGED
|
@@ -19,7 +19,8 @@ import * as rxjs from 'rxjs';
|
|
|
19
19
|
import $ from 'cash-dom';
|
|
20
20
|
|
|
21
21
|
import * as C from './utils/constants';
|
|
22
|
-
import {COLUMN_NAME, COLUMNS_NAMES} from './utils/constants';
|
|
22
|
+
import {COLUMN_NAME, COLUMNS_NAMES, VIEWER_TYPE} from './utils/constants';
|
|
23
|
+
export {VIEWER_TYPE};
|
|
23
24
|
import * as type from './utils/types';
|
|
24
25
|
import {PeptidesSettings} from './utils/types';
|
|
25
26
|
import {
|
|
@@ -59,16 +60,6 @@ import {PeptideUtils} from './peptideUtils';
|
|
|
59
60
|
import {getGPUAdapterDescription} from '@datagrok-libraries/math/src/webGPU/getGPUDevice';
|
|
60
61
|
import {MCLViewer} from '@datagrok-libraries/ml/src/MCL/mcl-viewer';
|
|
61
62
|
|
|
62
|
-
export enum VIEWER_TYPE {
|
|
63
|
-
SEQUENCE_VARIABILITY_MAP = 'Sequence Variability Map',
|
|
64
|
-
MOST_POTENT_RESIDUES = 'Most Potent Residues',
|
|
65
|
-
LOGO_SUMMARY_TABLE = 'Logo Summary Table',
|
|
66
|
-
DENDROGRAM = 'Dendrogram',
|
|
67
|
-
CLUSTER_MAX_ACTIVITY = 'Active peptide selection',
|
|
68
|
-
MCL = 'MCL',
|
|
69
|
-
SEQUENCE_MUTATION_CLIFFS = 'Sequence Mutation Cliffs',
|
|
70
|
-
}
|
|
71
|
-
|
|
72
63
|
export type CachedWebLogoTooltip = { bar: string, tooltip: HTMLDivElement | null };
|
|
73
64
|
|
|
74
65
|
/**
|
|
@@ -94,6 +85,9 @@ export class PeptidesModel {
|
|
|
94
85
|
webLogoSelectedMonomers: type.SelectionStats = {};
|
|
95
86
|
// WebLogo bounds used for interactivity (e.g. tooltips, selection)
|
|
96
87
|
webLogoBounds: CR.WebLogoBounds = {};
|
|
88
|
+
private webLogoFrameSubscription?: rxjs.Subscription;
|
|
89
|
+
private highlightedRowCount = 0;
|
|
90
|
+
private updatingSequence = false;
|
|
97
91
|
// Cached WebLogo tooltip. Because tooltip is requested for each mouse movement, it is cached unless mouse entered
|
|
98
92
|
// bounds of other monomer in WebLogo
|
|
99
93
|
cachedWebLogoTooltip: CachedWebLogoTooltip = {bar: '', tooltip: null};
|
|
@@ -188,6 +182,11 @@ export class PeptidesModel {
|
|
|
188
182
|
* @param {type.PartialPeptidesSettings} s - Peptides analysis settings
|
|
189
183
|
*/
|
|
190
184
|
set settings(s: type.PartialPeptidesSettings) {
|
|
185
|
+
this.applySettings(s).catch((error) => grok.shell.error(String(error)));
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** Applies settings and waits for the dependent viewers and clustering to finish. */
|
|
189
|
+
async applySettings(s: type.PartialPeptidesSettings): Promise<void> {
|
|
191
190
|
const newSettingsEntries = Object.entries(s) as ([keyof type.PeptidesSettings, never])[];
|
|
192
191
|
// Holds updated settings categories
|
|
193
192
|
const oldSeqSpaceOptions: Partial<type.SequenceSpaceParams> =
|
|
@@ -208,7 +207,7 @@ export class PeptidesModel {
|
|
|
208
207
|
updateVars.add('clusterMaxActivity');
|
|
209
208
|
break;
|
|
210
209
|
case 'showSequenceSpace':
|
|
211
|
-
updateVars.add('
|
|
210
|
+
updateVars.add('sequenceSpace');
|
|
212
211
|
break;
|
|
213
212
|
case 'showLogoSummaryTable':
|
|
214
213
|
updateVars.add('logoSummaryTable');
|
|
@@ -235,7 +234,10 @@ export class PeptidesModel {
|
|
|
235
234
|
if (!this.isInitialized)
|
|
236
235
|
return;
|
|
237
236
|
|
|
238
|
-
|
|
237
|
+
// showing or hiding the viewer takes the params along; unchanged params of a shown viewer only re-cluster
|
|
238
|
+
if (updateVars.has('sequenceSpace'))
|
|
239
|
+
updateVars.delete('sequenceSpaceParams');
|
|
240
|
+
else if (updateVars.has('sequenceSpaceParams')) {
|
|
239
241
|
const newSeqSpaceOptions = this.settings!.sequenceSpaceParams!;
|
|
240
242
|
if (!Object.entries(newSeqSpaceOptions).some(([key, value]) =>
|
|
241
243
|
oldSeqSpaceOptions[key as keyof type.SequenceSpaceParams] !== value && key !== 'epsilon' &&
|
|
@@ -245,8 +247,6 @@ export class PeptidesModel {
|
|
|
245
247
|
updateVars.add('clusterParams');
|
|
246
248
|
}
|
|
247
249
|
}
|
|
248
|
-
if (updateVars.has('sequenceSpaceParams'))
|
|
249
|
-
updateVars.delete('clusterParams');
|
|
250
250
|
|
|
251
251
|
// Apply new settings
|
|
252
252
|
for (const variable of updateVars) {
|
|
@@ -265,22 +265,22 @@ export class PeptidesModel {
|
|
|
265
265
|
this._monomerPositionStats = null;
|
|
266
266
|
break;
|
|
267
267
|
case 'dendrogram':
|
|
268
|
-
this.settings!.showDendrogram ? this.addDendrogram() : this.
|
|
268
|
+
this.settings!.showDendrogram ? await this.addDendrogram() : this.dendrogramCloseButton?.click();
|
|
269
269
|
break;
|
|
270
270
|
case 'clusterMaxActivity':
|
|
271
|
-
this.settings!.showClusterMaxActivity ? this.addClusterMaxActivityViewer() :
|
|
271
|
+
this.settings!.showClusterMaxActivity ? await this.addClusterMaxActivityViewer() :
|
|
272
272
|
this.closeViewer(VIEWER_TYPE.CLUSTER_MAX_ACTIVITY);
|
|
273
273
|
break;
|
|
274
274
|
case 'logoSummaryTable':
|
|
275
|
-
this.settings!.showLogoSummaryTable ? this.addLogoSummaryTable() :
|
|
275
|
+
this.settings!.showLogoSummaryTable ? await this.addLogoSummaryTable() :
|
|
276
276
|
this.closeViewer(VIEWER_TYPE.LOGO_SUMMARY_TABLE);
|
|
277
277
|
break;
|
|
278
278
|
case 'monomerPosition':
|
|
279
|
-
this.settings!.showMonomerPosition ? this.addMonomerPosition() :
|
|
279
|
+
this.settings!.showMonomerPosition ? await this.addMonomerPosition() :
|
|
280
280
|
this.closeViewer(VIEWER_TYPE.SEQUENCE_VARIABILITY_MAP);
|
|
281
281
|
break;
|
|
282
282
|
case 'mostPotentResidues':
|
|
283
|
-
this.settings!.showMostPotentResidues ? this.addMostPotentResidues() :
|
|
283
|
+
this.settings!.showMostPotentResidues ? await this.addMostPotentResidues() :
|
|
284
284
|
this.closeViewer(VIEWER_TYPE.MOST_POTENT_RESIDUES);
|
|
285
285
|
break;
|
|
286
286
|
case 'columns':
|
|
@@ -292,18 +292,24 @@ export class PeptidesModel {
|
|
|
292
292
|
mpr._viewerGrid = null;
|
|
293
293
|
mpr.render();
|
|
294
294
|
break;
|
|
295
|
+
case 'sequenceSpace':
|
|
296
|
+
this.settings!.showSequenceSpace ?
|
|
297
|
+
await this.addSequenceSpace({clusterEmbeddings: this.settings!.sequenceSpaceParams?.clusterEmbeddings}) :
|
|
298
|
+
this.closeSequenceSpace();
|
|
299
|
+
break;
|
|
295
300
|
case 'sequenceSpaceParams':
|
|
296
301
|
if (this.settings!.showSequenceSpace)
|
|
297
|
-
this.addSequenceSpace({clusterEmbeddings: this.settings!.sequenceSpaceParams?.clusterEmbeddings});
|
|
302
|
+
await this.addSequenceSpace({clusterEmbeddings: this.settings!.sequenceSpaceParams?.clusterEmbeddings});
|
|
298
303
|
break;
|
|
299
304
|
case 'clusterParams':
|
|
300
|
-
this.clusterEmbeddings();
|
|
305
|
+
await this.clusterEmbeddings();
|
|
301
306
|
break;
|
|
302
307
|
case 'mclSettings':
|
|
303
|
-
this.addMCLClusters();
|
|
308
|
+
await this.addMCLClusters();
|
|
304
309
|
break;
|
|
305
310
|
}
|
|
306
311
|
}
|
|
312
|
+
grok.events.fireCustomEvent('peptides-sar-ready', {table: this.df.name});
|
|
307
313
|
}
|
|
308
314
|
|
|
309
315
|
// Current Monomer-Position selection that came from WebLogo in header
|
|
@@ -704,6 +710,30 @@ export class PeptidesModel {
|
|
|
704
710
|
this.createScaledCol();
|
|
705
711
|
this.webLogoBounds = {};
|
|
706
712
|
|
|
713
|
+
this.analysisView.grid.removeStatusProvider('peptides-weblogo');
|
|
714
|
+
this.webLogoFrameSubscription?.unsubscribe();
|
|
715
|
+
this.webLogoFrameSubscription = this.analysisView.grid.onBeforeDrawContent.subscribe(() => {
|
|
716
|
+
this.webLogoBounds = {};
|
|
717
|
+
});
|
|
718
|
+
this.analysisView.grid.addStatusProvider('peptides-weblogo', () => {
|
|
719
|
+
const hitAreas: DG.IWidgetStatus['hitAreas'] = {};
|
|
720
|
+
const grid = this.analysisView.grid;
|
|
721
|
+
const width = grid.canvas.clientWidth;
|
|
722
|
+
const height = grid.props.colHeaderHeight;
|
|
723
|
+
for (const [position, monomers] of Object.entries(this.webLogoBounds)) {
|
|
724
|
+
for (const [monomer, rect] of Object.entries(monomers)) {
|
|
725
|
+
const left = Math.max(0, rect.x);
|
|
726
|
+
const right = Math.min(width, rect.x + rect.width);
|
|
727
|
+
const top = Math.max(0, rect.y);
|
|
728
|
+
const bottom = Math.min(height, rect.y + rect.height);
|
|
729
|
+
if (right > left && bottom > top)
|
|
730
|
+
hitAreas[`${monomer} at ${position}`] = {x: left, y: top, width: right - left, height: bottom - top};
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
return {hitAreas, values: {'highlighted rows': this.highlightedRowCount}};
|
|
734
|
+
});
|
|
735
|
+
this.subs.push(this.webLogoFrameSubscription);
|
|
736
|
+
|
|
707
737
|
const cellRendererOptions: CR.WebLogoCellRendererOptions = {
|
|
708
738
|
selectionCallback: (monomerPosition: type.SelectionItem, options: type.SelectionOptions): void =>
|
|
709
739
|
this.modifyWebLogoSelection(monomerPosition, options),
|
|
@@ -712,8 +742,7 @@ export class PeptidesModel {
|
|
|
712
742
|
webLogoBounds: () => this.webLogoBounds,
|
|
713
743
|
cachedWebLogoTooltip: () => this.cachedWebLogoTooltip,
|
|
714
744
|
highlightCallback: (mp: type.SelectionItem, df: DG.DataFrame, mpStats: MonomerPositionStats): void => {
|
|
715
|
-
|
|
716
|
-
this.isHighlighting = true;
|
|
745
|
+
this.highlight(mp, mpStats);
|
|
717
746
|
},
|
|
718
747
|
isSelectionTable: false,
|
|
719
748
|
headerSelectedMonomers: () => this.webLogoSelectedMonomers,
|
|
@@ -722,7 +751,7 @@ export class PeptidesModel {
|
|
|
722
751
|
throw new Error('PeptidesError: Could not updage grid: monomerPositionStats or positionColumns are null');
|
|
723
752
|
|
|
724
753
|
|
|
725
|
-
CR.setWebLogoRenderer(this.analysisView.grid, this.monomerPositionStats
|
|
754
|
+
CR.setWebLogoRenderer(this.analysisView.grid, () => this.monomerPositionStats!, this.positionColumns,
|
|
726
755
|
this.getScaledActivityColumn()!, cellRendererOptions);
|
|
727
756
|
if (!this._layoutEventInitialized) {
|
|
728
757
|
grok.events.onViewLayoutApplied.subscribe((layout) => {
|
|
@@ -740,45 +769,104 @@ export class PeptidesModel {
|
|
|
740
769
|
/**
|
|
741
770
|
* Splits sequences and adds position columns to this.df.
|
|
742
771
|
*/
|
|
743
|
-
joinDataFrames(): void {
|
|
772
|
+
joinDataFrames(refreshValues = false): void {
|
|
744
773
|
// append splitSeqDf columns to source table and make sure columns are not added more than once
|
|
745
774
|
const name = this.df.name;
|
|
746
775
|
const cols = this.df.columns;
|
|
747
776
|
const splitSeqDf = splitAlignedSequences(this.df.getCol(this.settings!.sequenceColumnName), PeptideUtils.getSeqHelper());
|
|
748
|
-
const
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
const newColData = newCol.getRawData();
|
|
768
|
-
col = cols.addNew(newCol.name, newCol.type).init((i) => newColCat[newColData[i]]);
|
|
769
|
-
col.setTag(C.TAGS.ANALYSIS_COL, `${true}`);
|
|
770
|
-
col.setTag(C.TAGS.POSITION_COL, `${true}`);
|
|
771
|
-
// Propagate canonicalizer tag from split columns if present
|
|
772
|
-
const canonTag = newCol.getTag(MONOMER_CANONICALIZER_FUNC_TAG);
|
|
773
|
-
if (canonTag)
|
|
774
|
-
col.setTag(MONOMER_CANONICALIZER_FUNC_TAG, canonTag);
|
|
775
|
-
CR.setMonomerRenderer(col, this.alphabet);
|
|
777
|
+
for (const newCol of splitSeqDf.columns) {
|
|
778
|
+
let col = this.df.col(newCol.name);
|
|
779
|
+
const fill = refreshValues || col === null;
|
|
780
|
+
col ??= cols.addNew(newCol.name, newCol.type);
|
|
781
|
+
if (fill) {
|
|
782
|
+
for (let row = 0; row < this.df.rowCount; row++)
|
|
783
|
+
col.set(row, newCol.get(row), false);
|
|
784
|
+
}
|
|
785
|
+
col.setTag(C.TAGS.ANALYSIS_COL, `${true}`);
|
|
786
|
+
col.setTag(C.TAGS.POSITION_COL, `${true}`);
|
|
787
|
+
const canonTag = newCol.getTag(MONOMER_CANONICALIZER_FUNC_TAG);
|
|
788
|
+
if (canonTag)
|
|
789
|
+
col.setTag(MONOMER_CANONICALIZER_FUNC_TAG, canonTag);
|
|
790
|
+
CR.setMonomerRenderer(col, this.alphabet);
|
|
791
|
+
}
|
|
792
|
+
if (refreshValues) {
|
|
793
|
+
for (const col of this.positionColumns ?? []) {
|
|
794
|
+
if (!splitSeqDf.columns.contains(col.name))
|
|
795
|
+
cols.remove(col.name);
|
|
776
796
|
}
|
|
777
797
|
}
|
|
778
798
|
|
|
779
799
|
this.df.name = name;
|
|
780
800
|
}
|
|
781
801
|
|
|
802
|
+
async updateSequence(rowIndex: number, sequence: string, columnName = this.df.currentCol?.name): Promise<void> {
|
|
803
|
+
const view = this.analysisView;
|
|
804
|
+
const originalContext = grok.shell.o;
|
|
805
|
+
this.updatingSequence = true;
|
|
806
|
+
try {
|
|
807
|
+
const sequenceColumn = this.df.getCol(this.settings!.sequenceColumnName);
|
|
808
|
+
PeptideUtils.getSeqHelper().getSeqHandler(sequenceColumn).splitter(sequence);
|
|
809
|
+
sequenceColumn.set(rowIndex, sequence, false);
|
|
810
|
+
this.joinDataFrames(true);
|
|
811
|
+
this._monomerPositionStats = null;
|
|
812
|
+
this._dm = null;
|
|
813
|
+
this.cachedWebLogoTooltip = {bar: '', tooltip: null};
|
|
814
|
+
this.unhighlight();
|
|
815
|
+
for (const col of this.positionColumns ?? [])
|
|
816
|
+
col.temp[C.TAGS.INVARIANT_MAP_COLOR_CACHE] = null;
|
|
817
|
+
|
|
818
|
+
const viewers = Array.from(this.analysisView.viewers).filter((viewer): viewer is DG.JsViewer =>
|
|
819
|
+
viewer instanceof DG.JsViewer && viewer.getProperty('sequenceColumnName')?.get(viewer) === sequenceColumn.name);
|
|
820
|
+
// Invalidate every shared cache before any viewer can borrow a sibling's statistics.
|
|
821
|
+
for (const viewer of viewers) {
|
|
822
|
+
if (viewer instanceof SARViewer) {
|
|
823
|
+
viewer._positionColumns = null;
|
|
824
|
+
viewer.onFilterChanged(false, true);
|
|
825
|
+
viewer._viewerGrid = null;
|
|
826
|
+
} else if (viewer instanceof LogoSummaryTable) {
|
|
827
|
+
viewer._positionColumns = null;
|
|
828
|
+
viewer._clusterStats = null;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
this.df.fireValuesChanged();
|
|
832
|
+
this.updateGrid();
|
|
833
|
+
for (const viewer of viewers) {
|
|
834
|
+
if (viewer instanceof SARViewer) {
|
|
835
|
+
if (!viewer.mutationCliffs) {
|
|
836
|
+
const result = await viewer.calculateMutationCliffs();
|
|
837
|
+
viewer.mutationCliffs = result.cliffs;
|
|
838
|
+
viewer.cliffStats = result.cliffStats;
|
|
839
|
+
}
|
|
840
|
+
viewer.render();
|
|
841
|
+
} else {
|
|
842
|
+
if (viewer instanceof LogoSummaryTable)
|
|
843
|
+
viewer._clusterStats = null;
|
|
844
|
+
viewer.onPropertyChanged(viewer.getProperty('sequenceColumnName')!);
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
const activePeptides = this.findViewer(VIEWER_TYPE.CLUSTER_MAX_ACTIVITY) as ClusterMaxActivityViewer | null;
|
|
848
|
+
activePeptides?.onPropertyChanged(null);
|
|
849
|
+
this.fireBitsetChanged(null);
|
|
850
|
+
const context = grok.shell.o;
|
|
851
|
+
const sameCell = context instanceof DG.SemanticValue && context.cell?.dataFrame.id === this.df.id &&
|
|
852
|
+
context.cell.column.name === columnName && context.cell.rowIndex === rowIndex;
|
|
853
|
+
const sameTable = context instanceof DG.DataFrame && context.id === this.df.id;
|
|
854
|
+
if (columnName && this.df.col(columnName) && view.root.isConnected && grok.shell.v?.root === view.root &&
|
|
855
|
+
(context === originalContext || sameTable || sameCell)) {
|
|
856
|
+
const cell = this.df.cell(rowIndex, columnName);
|
|
857
|
+
this.df.currentCell = cell;
|
|
858
|
+
const gridRow = view.grid.tableRowToGrid(rowIndex);
|
|
859
|
+
if (gridRow >= 0)
|
|
860
|
+
view.grid.scrollToCell(columnName, gridRow);
|
|
861
|
+
grok.shell.setCurrentObject(gridRow >= 0 ?
|
|
862
|
+
DG.SemanticValue.fromGridCell(view.grid.cell(columnName, gridRow)) : DG.SemanticValue.fromTableCell(cell), false, true);
|
|
863
|
+
}
|
|
864
|
+
} finally {
|
|
865
|
+
this.updatingSequence = false;
|
|
866
|
+
}
|
|
867
|
+
grok.events.fireCustomEvent('peptides-sar-ready', {table: this.df.name});
|
|
868
|
+
}
|
|
869
|
+
|
|
782
870
|
/**
|
|
783
871
|
* Creates scaled activity column
|
|
784
872
|
*/
|
|
@@ -795,12 +883,18 @@ export class PeptidesModel {
|
|
|
795
883
|
/**
|
|
796
884
|
* Resets rows highlighting
|
|
797
885
|
*/
|
|
886
|
+
highlight(monomerPosition: type.SelectionItem, stats: MonomerPositionStats): void {
|
|
887
|
+
this.highlightedRowCount = highlightMonomerPosition(monomerPosition, this.df, stats);
|
|
888
|
+
this.isHighlighting = true;
|
|
889
|
+
}
|
|
890
|
+
|
|
798
891
|
unhighlight(): void {
|
|
799
892
|
if (!this.isHighlighting)
|
|
800
893
|
return;
|
|
801
894
|
|
|
802
895
|
|
|
803
896
|
this.df.rows.highlight(null);
|
|
897
|
+
this.highlightedRowCount = 0;
|
|
804
898
|
this.isHighlighting = false;
|
|
805
899
|
}
|
|
806
900
|
|
|
@@ -895,29 +989,21 @@ export class PeptidesModel {
|
|
|
895
989
|
|
|
896
990
|
const selection = this.df.selection;
|
|
897
991
|
const filter = this.df.filter;
|
|
898
|
-
let prevTimer: any = null;
|
|
899
992
|
const showAccordion = (): void => {
|
|
993
|
+
if (this.updatingSequence || grok.shell.v?.root !== this._analysisView?.root)
|
|
994
|
+
return;
|
|
900
995
|
try {
|
|
901
|
-
if (prevTimer != null) {
|
|
902
|
-
clearTimeout(prevTimer);
|
|
903
|
-
prevTimer = null;
|
|
904
|
-
}
|
|
905
996
|
const acc = this.createAccordion();
|
|
906
997
|
if (acc === null)
|
|
907
998
|
return;
|
|
908
999
|
|
|
909
|
-
|
|
910
|
-
grok.shell.o = acc.root;
|
|
911
|
-
prevTimer = setTimeout(() => {
|
|
912
|
-
if (grok.shell.o != acc.root)
|
|
913
|
-
grok.shell.o = acc.root;
|
|
914
|
-
}, 1500);
|
|
1000
|
+
grok.shell.setCurrentObject(acc.root, false, true);
|
|
915
1001
|
} catch (e) {
|
|
916
1002
|
console.error(e);
|
|
917
1003
|
}
|
|
918
1004
|
};
|
|
919
1005
|
|
|
920
|
-
selection.onChanged.subscribe(() => {
|
|
1006
|
+
this.subs.push(selection.onChanged.subscribe(() => {
|
|
921
1007
|
if (this.controlFire) {
|
|
922
1008
|
this.controlFire = false;
|
|
923
1009
|
return;
|
|
@@ -931,9 +1017,9 @@ export class PeptidesModel {
|
|
|
931
1017
|
} finally {
|
|
932
1018
|
showAccordion();
|
|
933
1019
|
}
|
|
934
|
-
});
|
|
1020
|
+
}));
|
|
935
1021
|
|
|
936
|
-
filter.onChanged.subscribe(() => {
|
|
1022
|
+
this.subs.push(filter.onChanged.subscribe(() => {
|
|
937
1023
|
try {
|
|
938
1024
|
if (this.controlFire) {
|
|
939
1025
|
this.controlFire = false;
|
|
@@ -951,7 +1037,18 @@ export class PeptidesModel {
|
|
|
951
1037
|
} finally {
|
|
952
1038
|
showAccordion();
|
|
953
1039
|
}
|
|
954
|
-
});
|
|
1040
|
+
}));
|
|
1041
|
+
|
|
1042
|
+
const showsOwnRows = (): boolean => {
|
|
1043
|
+
const context = grok.shell.o;
|
|
1044
|
+
const table = context instanceof DG.RowGroup ? context.dataFrame : context instanceof DG.DataFrame ? context : null;
|
|
1045
|
+
return table?.id === this.df.id;
|
|
1046
|
+
};
|
|
1047
|
+
this.subs.push(grok.events.onCurrentObjectChanged.subscribe(() => {
|
|
1048
|
+
// the event bus is synchronous: setting the current object from inside its own dispatch throws
|
|
1049
|
+
if (showsOwnRows())
|
|
1050
|
+
void Promise.resolve().then(() => showsOwnRows() && showAccordion());
|
|
1051
|
+
}));
|
|
955
1052
|
|
|
956
1053
|
this.isBitsetChangedInitialized = true;
|
|
957
1054
|
}
|
|
@@ -1027,16 +1124,13 @@ export class PeptidesModel {
|
|
|
1027
1124
|
gridCol.visible = posCols.includes(gridCol.column.name) || (gridCol.column.name === C.COLUMNS_NAMES.ACTIVITY);
|
|
1028
1125
|
}
|
|
1029
1126
|
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
throw new Error(`PeptidesError: Could not set column width: grid column '${positionCol.name}' is null`);
|
|
1035
|
-
|
|
1127
|
+
for (const positionCol of positionCols) {
|
|
1128
|
+
const gridCol = sourceGrid.col(positionCol.name);
|
|
1129
|
+
if (gridCol === null)
|
|
1130
|
+
throw new Error(`PeptidesError: Could not set column width: grid column '${positionCol.name}' is null`);
|
|
1036
1131
|
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
}, 100);
|
|
1132
|
+
gridCol.width = maxWidth + 15;
|
|
1133
|
+
}
|
|
1040
1134
|
}
|
|
1041
1135
|
|
|
1042
1136
|
/**
|
|
@@ -1049,6 +1143,13 @@ export class PeptidesModel {
|
|
|
1049
1143
|
viewer?.close();
|
|
1050
1144
|
}
|
|
1051
1145
|
|
|
1146
|
+
/** The Dendrogram package attaches its tree beside the analysis grid, not as a viewer; the tree's
|
|
1147
|
+
* own close button is the one handle on it: there while the tree is shown, and a click on it removes
|
|
1148
|
+
* the tree the way the user would. */
|
|
1149
|
+
get dendrogramCloseButton(): HTMLElement | null {
|
|
1150
|
+
return this.analysisView?.root.querySelector('.dendrogram-close-bttn') ?? null;
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1052
1153
|
/**
|
|
1053
1154
|
* Finds viewer node in the analysis view
|
|
1054
1155
|
* @param {VIEWER_TYPE} viewerType - Viewer type to find
|
|
@@ -1118,6 +1219,12 @@ export class PeptidesModel {
|
|
|
1118
1219
|
this.updateGrid();
|
|
1119
1220
|
}
|
|
1120
1221
|
|
|
1222
|
+
// Stats masks are sized to row count, so they get stale and must be recalculated when rows are added or removed
|
|
1223
|
+
this.subs.push(rxjs.merge(this.df.onRowsRemoved, this.df.onRowsAdded).subscribe(() => {
|
|
1224
|
+
this._monomerPositionStats = null;
|
|
1225
|
+
this.cachedWebLogoTooltip = {bar: '', tooltip: null};
|
|
1226
|
+
}));
|
|
1227
|
+
|
|
1121
1228
|
this.subs.push(grok.events.onAccordionConstructed.subscribe((acc) => {
|
|
1122
1229
|
if (!(grok.shell.o instanceof DG.SemanticValue || (grok.shell.o instanceof DG.Column &&
|
|
1123
1230
|
this.df.columns.toList().includes(grok.shell.o))))
|
|
@@ -1384,67 +1491,74 @@ export class PeptidesModel {
|
|
|
1384
1491
|
}
|
|
1385
1492
|
});
|
|
1386
1493
|
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
lstViewer.render();
|
|
1494
|
+
try {
|
|
1495
|
+
const serializedOptions: string = JSON.stringify({
|
|
1496
|
+
cols: [seqCol].map((col) => col.name),
|
|
1497
|
+
metrics: [mclParams!.distanceF],
|
|
1498
|
+
weights: [1],
|
|
1499
|
+
aggregationMethod: DistanceAggregationMethods.MANHATTAN,
|
|
1500
|
+
preprocessingFuncs: ['macromoleculePreprocessingFunction'],
|
|
1501
|
+
preprocessingFuncArgs: [{
|
|
1502
|
+
gapOpen: mclParams!.gapOpen, gapExtend: mclParams!.gapExtend,
|
|
1503
|
+
fingerprintType: mclParams!.fingerprintType,
|
|
1504
|
+
}],
|
|
1505
|
+
threshold: mclParams!.threshold,
|
|
1506
|
+
maxIterations: mclParams!.maxIterations,
|
|
1507
|
+
useWebGPU: mclParams.useWebGPU,
|
|
1508
|
+
inflate: mclParams!.inflation,
|
|
1509
|
+
minClusterSize: mclParams.minClusterSize,
|
|
1510
|
+
} satisfies MCLSerializableOptions);
|
|
1511
|
+
|
|
1512
|
+
const tv = this.analysisView ?? grok.shell.tableView(this.df.name);
|
|
1513
|
+
if (tv) {
|
|
1514
|
+
const func = DG.Func.find({package: 'EDA', name: 'markovClusteringViewer'})[0];
|
|
1515
|
+
if (!func)
|
|
1516
|
+
throw new Error('Markov clustering function is not found');
|
|
1517
|
+
// make sure eda is loaded
|
|
1518
|
+
await func.apply();
|
|
1519
|
+
this._mclViewer = await this.df.plot.fromType(VIEWER_TYPE.MCL, {mclProps: serializedOptions}) as MCLViewer;
|
|
1520
|
+
tv.addViewer(this._mclViewer);
|
|
1521
|
+
await this._mclViewer.initPromise;
|
|
1522
|
+
// after waiting for init promise, it can be resolved by just removing the viewer, so check again
|
|
1523
|
+
this._mclViewer = this.findViewer(VIEWER_TYPE.MCL) as MCLViewer | null;
|
|
1524
|
+
if (!this._mclViewer || this._mclViewer.isDetached) {
|
|
1525
|
+
mclAdditionSub?.unsubscribe();
|
|
1526
|
+
columnAddedSub?.unsubscribe();
|
|
1527
|
+
return;
|
|
1528
|
+
}
|
|
1529
|
+
const lstViewer = this.findViewer(VIEWER_TYPE.LOGO_SUMMARY_TABLE) as LogoSummaryTable | null;
|
|
1530
|
+
if (lstViewer) { // beware, this is accessing private things
|
|
1531
|
+
lstViewer._clusterStats = null;
|
|
1532
|
+
lstViewer._clusterSelection = null;
|
|
1533
|
+
lstViewer._viewerGrid = null;
|
|
1534
|
+
lstViewer._logoSummaryTable = null;
|
|
1535
|
+
lstViewer.render();
|
|
1536
|
+
}
|
|
1431
1537
|
}
|
|
1538
|
+
} finally {
|
|
1539
|
+
mclAdditionSub.unsubscribe();
|
|
1540
|
+
columnAddedSub.unsubscribe();
|
|
1432
1541
|
}
|
|
1433
1542
|
}
|
|
1434
1543
|
|
|
1435
|
-
|
|
1436
|
-
* Adds Sequence Space viewer to the analysis view
|
|
1437
|
-
*/
|
|
1438
|
-
async addSequenceSpace(settings: {clusterEmbeddings?: boolean, clusterCol?: DG.Column | null} = {}): Promise<void> {
|
|
1544
|
+
closeSequenceSpace(): void {
|
|
1439
1545
|
if (this._sequenceSpaceViewer !== null) {
|
|
1440
1546
|
try {
|
|
1441
|
-
this._sequenceSpaceViewer
|
|
1442
|
-
this._sequenceSpaceViewer
|
|
1547
|
+
this._sequenceSpaceViewer.detach();
|
|
1548
|
+
this._sequenceSpaceViewer.close();
|
|
1443
1549
|
} catch (_) {}
|
|
1550
|
+
this._sequenceSpaceViewer = null;
|
|
1444
1551
|
}
|
|
1445
|
-
|
|
1446
|
-
this.
|
|
1552
|
+
for (const col of this._sequenceSpaceCols)
|
|
1553
|
+
this.df.columns.remove(col);
|
|
1447
1554
|
this._sequenceSpaceCols = [];
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
/**
|
|
1558
|
+
* Adds Sequence Space viewer to the analysis view
|
|
1559
|
+
*/
|
|
1560
|
+
async addSequenceSpace(settings: {clusterEmbeddings?: boolean, clusterCol?: DG.Column | null} = {}): Promise<void> {
|
|
1561
|
+
this.closeSequenceSpace();
|
|
1448
1562
|
let seqCol = this.df.getCol(this.settings!.sequenceColumnName!);
|
|
1449
1563
|
const sh = PeptideUtils.getSeqHelper().getSeqHandler(seqCol);
|
|
1450
1564
|
const isHelm = sh.isHelm();
|
package/src/package-api.ts
CHANGED
|
@@ -30,27 +30,31 @@ export namespace funcs {
|
|
|
30
30
|
return await grok.functions.call('Peptides:TestInitFunctionPeptides', { v });
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* @param {DG.Column} col
|
|
35
|
+
* semType: Macromolecule
|
|
36
|
+
*/
|
|
33
37
|
export async function peptidesPanel(col: DG.Column ): Promise<any> {
|
|
34
38
|
return await grok.functions.call('Peptides:PeptidesPanel', { col });
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
/**
|
|
38
|
-
|
|
39
|
-
|
|
42
|
+
* Peptides Sequence Variability Map Viewer
|
|
43
|
+
*/
|
|
40
44
|
export async function monomerPosition(): Promise<any> {
|
|
41
45
|
return await grok.functions.call('Peptides:MonomerPosition', {});
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
/**
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
* Peptides Most Potent Residues Viewer
|
|
50
|
+
*/
|
|
47
51
|
export async function mostPotentResidues(): Promise<any> {
|
|
48
52
|
return await grok.functions.call('Peptides:MostPotentResidues', {});
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
/**
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
* Mutation Cliffs Line Chart
|
|
57
|
+
*/
|
|
54
58
|
export async function mutationCliffs(): Promise<any> {
|
|
55
59
|
return await grok.functions.call('Peptides:MutationCliffs', {});
|
|
56
60
|
}
|
|
@@ -68,19 +72,23 @@ export namespace funcs {
|
|
|
68
72
|
}
|
|
69
73
|
|
|
70
74
|
/**
|
|
71
|
-
|
|
72
|
-
|
|
75
|
+
* Generates new candidate peptides from monomer-position statistics, ranked by predicted activity
|
|
76
|
+
*/
|
|
73
77
|
export async function peptideGeneration(): Promise<any> {
|
|
74
78
|
return await grok.functions.call('Peptides:PeptideGeneration', {});
|
|
75
79
|
}
|
|
76
80
|
|
|
81
|
+
/**
|
|
82
|
+
* @param {string} _monomer
|
|
83
|
+
* semType: Monomer
|
|
84
|
+
*/
|
|
77
85
|
export async function manualAlignment(_monomer: string ): Promise<any> {
|
|
78
86
|
return await grok.functions.call('Peptides:ManualAlignment', { _monomer });
|
|
79
87
|
}
|
|
80
88
|
|
|
81
89
|
/**
|
|
82
|
-
|
|
83
|
-
|
|
90
|
+
* Peptide SAR Analysis demo on peptide sequences in FASTA format
|
|
91
|
+
*/
|
|
84
92
|
export async function macromoleculeSarFastaDemo(): Promise<void> {
|
|
85
93
|
return await grok.functions.call('Peptides:MacromoleculeSarFastaDemo', {});
|
|
86
94
|
}
|
package/src/package.g.ts
CHANGED