@datagrok/hit-triage 1.10.8 → 1.11.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 (129) hide show
  1. package/.grokignore +2 -0
  2. package/.turbo/turbo-build.log +24 -6
  3. package/.vscode/settings.json +16 -0
  4. package/CHANGELOG.md +80 -1
  5. package/CLAUDE.md +87 -10
  6. package/README_HD.md +14 -14
  7. package/README_HT.md +6 -6
  8. package/README_PH.md +110 -0
  9. package/bdd/bdd.config.json +3 -0
  10. package/bdd/bindings/campaign.ts +626 -0
  11. package/bdd/bindings/hit-design.ts +93 -0
  12. package/bdd/bindings/landing.ts +839 -0
  13. package/bdd/bindings/pepti-hit.ts +35 -0
  14. package/bdd/features/campaign/crumbs.feature +22 -0
  15. package/bdd/features/campaign/grid.feature +56 -0
  16. package/bdd/features/campaign/merge.feature +105 -0
  17. package/bdd/features/campaign/molecule-vid.feature +40 -0
  18. package/bdd/features/campaign/permissions.feature +46 -0
  19. package/bdd/features/campaign/progress-tracker.feature +89 -0
  20. package/bdd/features/campaign/refresh-hint.feature +33 -0
  21. package/bdd/features/campaign/ribbon.feature +49 -0
  22. package/bdd/features/campaign/stage-choices.feature +39 -0
  23. package/bdd/features/campaign/submit.feature +135 -0
  24. package/bdd/features/campaign/tracker-cards.feature +46 -0
  25. package/bdd/features/campaign/view-only.feature +37 -0
  26. package/bdd/features/hit-design/campaign-column-metadata.feature +61 -0
  27. package/bdd/features/landing/campaign-deep-links.feature +61 -0
  28. package/bdd/features/landing/hit-design-campaigns-fixes.feature +116 -0
  29. package/bdd/features/landing/hit-design-campaigns.feature +153 -0
  30. package/bdd/features/landing/hit-triage-campaigns.feature +99 -0
  31. package/bdd/features/landing/new-campaign.feature +69 -0
  32. package/bdd/features/landing/pep-triage-campaigns.feature +41 -0
  33. package/bdd/features/landing/pepti-hit-landing.feature +132 -0
  34. package/bdd/features/pepti-hit/helm-edit.feature +47 -0
  35. package/bdd/features/templates/template-editor.feature +130 -0
  36. package/bdd/features/templates/template-picker.feature +112 -0
  37. package/bdd/features/templates/triage-forms.feature +59 -0
  38. package/bdd/fixtures/bar-chart.layout +1 -0
  39. package/bdd/fixtures/merge-local.csv +2 -0
  40. package/bdd/generated/campaign/crumbs.test.ts +33 -0
  41. package/bdd/generated/campaign/grid.test.ts +79 -0
  42. package/bdd/generated/campaign/merge.test.ts +134 -0
  43. package/bdd/generated/campaign/molecule-vid.test.ts +52 -0
  44. package/bdd/generated/campaign/permissions.test.ts +58 -0
  45. package/bdd/generated/campaign/progress-tracker.test.ts +129 -0
  46. package/bdd/generated/campaign/refresh-hint.test.ts +44 -0
  47. package/bdd/generated/campaign/ribbon.test.ts +65 -0
  48. package/bdd/generated/campaign/stage-choices.test.ts +55 -0
  49. package/bdd/generated/campaign/submit.test.ts +167 -0
  50. package/bdd/generated/campaign/tracker-cards.test.ts +49 -0
  51. package/bdd/generated/campaign/view-only.test.ts +51 -0
  52. package/bdd/generated/hit-design/campaign-column-metadata.test.ts +76 -0
  53. package/bdd/generated/landing/campaign-deep-links.test.ts +68 -0
  54. package/bdd/generated/landing/hit-design-campaigns-fixes.test.ts +99 -0
  55. package/bdd/generated/landing/hit-design-campaigns.test.ts +160 -0
  56. package/bdd/generated/landing/hit-triage-campaigns.test.ts +107 -0
  57. package/bdd/generated/landing/new-campaign.test.ts +78 -0
  58. package/bdd/generated/landing/pep-triage-campaigns.test.ts +52 -0
  59. package/bdd/generated/landing/pepti-hit-landing.test.ts +130 -0
  60. package/bdd/generated/pepti-hit/helm-edit.test.ts +64 -0
  61. package/bdd/generated/templates/template-editor.test.ts +137 -0
  62. package/bdd/generated/templates/template-picker.test.ts +119 -0
  63. package/bdd/generated/templates/triage-forms.test.ts +68 -0
  64. package/bdd/package.json +1 -0
  65. package/bdd/tsconfig.json +13 -0
  66. package/css/hit-triage.css +27 -23
  67. package/dist/package-test.js +690 -4
  68. package/dist/package-test.js.map +1 -1
  69. package/dist/package.js +318 -73
  70. package/dist/package.js.map +1 -1
  71. package/package.json +15 -8
  72. package/queries/locks.sql +37 -0
  73. package/src/app/accordeons/layout-input.ts +52 -44
  74. package/src/app/accordeons/new-campaign-accordeon.ts +91 -54
  75. package/src/app/accordeons/new-hit-design-campaign-accordeon.ts +3 -67
  76. package/src/app/accordeons/new-pep-triage-template-accordeon.ts +39 -41
  77. package/src/app/accordeons/new-template-accordeon.ts +41 -24
  78. package/src/app/ai/view-functions.ts +22 -19
  79. package/src/app/base-view.ts +99 -8
  80. package/src/app/consts.ts +8 -5
  81. package/src/app/dialogs/functions-dialog.ts +14 -9
  82. package/src/app/dialogs/merge-table-dialog.ts +181 -325
  83. package/src/app/hit-app-base.ts +61 -90
  84. package/src/app/hit-design-app.ts +492 -882
  85. package/src/app/hit-design-views/info-view.ts +57 -407
  86. package/src/app/hit-design-views/submit-view.ts +216 -111
  87. package/src/app/hit-design-views/tiles-view.ts +168 -123
  88. package/src/app/hit-design-views/utils.css +0 -8
  89. package/src/app/hit-triage-app.ts +69 -38
  90. package/src/app/hit-triage-views/info-view.ts +70 -371
  91. package/src/app/pep-triage-app.ts +2 -2
  92. package/src/app/pep-triage-views/info-view.ts +42 -83
  93. package/src/app/pepti-hit-app.ts +32 -183
  94. package/src/app/pepti-hits-views/info-view.ts +15 -37
  95. package/src/app/shared/campaign-catalog.ts +408 -0
  96. package/src/app/shared/campaign-session.ts +557 -0
  97. package/src/app/shared/compute-editor.ts +274 -0
  98. package/src/app/shared/hit-home.ts +45 -0
  99. package/src/app/shared/new-campaign-form.ts +90 -0
  100. package/src/app/shared/permissions-editor.ts +93 -0
  101. package/src/app/shared/template-editor.ts +331 -0
  102. package/src/app/shared/template-picker.ts +154 -0
  103. package/src/app/types.ts +2 -0
  104. package/src/app/utils/merge-table.ts +183 -78
  105. package/src/app/utils.ts +34 -325
  106. package/src/package-api.ts +29 -8
  107. package/src/package-test.ts +17 -2
  108. package/src/package.g.ts +12 -8
  109. package/src/package.ts +19 -7
  110. package/src/tests/ai.ts +244 -0
  111. package/src/tests/campaign-layout.ts +82 -0
  112. package/src/tests/campaign-session.ts +168 -0
  113. package/src/tests/campaigns.ts +23 -0
  114. package/src/tests/catalog.ts +156 -0
  115. package/src/tests/compat.ts +482 -0
  116. package/src/tests/compute.ts +165 -0
  117. package/src/tests/fixtures.ts +359 -0
  118. package/src/tests/merge.ts +149 -0
  119. package/src/tests/owners.ts +11 -0
  120. package/src/tests/save-lock.ts +932 -0
  121. package/src/tests/storage.ts +106 -0
  122. package/src/tests/template-editor.ts +538 -0
  123. package/src/tests/templates.ts +143 -0
  124. package/src/tests/triage-start.ts +81 -0
  125. package/src/tests/u2-guards.ts +384 -0
  126. package/src/tests/vid.ts +77 -0
  127. package/tsconfig.json +3 -0
  128. package/src/app/accordeons/new-hit-design-template-accordeon.ts +0 -238
  129. package/src/app/dialogs/permissions-dialog.ts +0 -66
@@ -2,14 +2,14 @@
2
2
  import * as grok from 'datagrok-api/grok';
3
3
  import * as ui from 'datagrok-api/ui';
4
4
  import * as DG from 'datagrok-api/dg';
5
- import {u2} from '@datagrok-libraries/utils/src/u2';
5
+ import type {AppHeaderOptions} from '@datagrok-libraries/u2';
6
+ import type {TemplateFormContext} from '../shared/template-picker';
6
7
  import {_package} from '../../package';
7
8
  import {PepTriageTemplate, HitTriageTemplate} from '../types';
8
- import {PepTriageDataSourceTag, i18n} from '../consts';
9
+ import {PepTriageDataSourceTag} from '../consts';
9
10
  import {InfoView} from '../hit-triage-views/info-view';
10
11
  import {PepTriageApp} from '../pep-triage-app';
11
- import {addBreadCrumbsToRibbons, popRibbonPannels} from '../utils';
12
- import {newCampaignAccordeon} from '../accordeons/new-campaign-accordeon';
12
+ import {INewCampaignResult, newCampaignAccordeon} from '../accordeons/new-campaign-accordeon';
13
13
  import {createPepTriageTemplateAccordeon} from '../accordeons/new-pep-triage-template-accordeon';
14
14
 
15
15
  export class PepTriageInfoView extends InfoView {
@@ -18,31 +18,21 @@ export class PepTriageInfoView extends InfoView {
18
18
  constructor(app: PepTriageApp) {
19
19
  super(app);
20
20
  this.name = 'PepTriage';
21
- grok.shell.windows.showHelp = true;
22
- grok.shell.windows.help.showHelp(_package.webRoot + 'README_HT.md');
23
21
  }
24
22
 
25
- override onActivated(): void {
26
- grok.shell.windows.showHelp = true;
27
- grok.shell.windows.help.showHelp(_package.webRoot + 'README_HT.md');
28
- }
29
-
30
- protected override getAppHeader() {
31
- return u2.appHeader({
32
- iconPath: _package.webRoot + '/images/icons/hit-triage-icon.png',
33
- learnMoreUrl: 'https://github.com/datagrok-ai/public/blob/master/packages/HitTriage/README_HT.md',
34
- description:
35
- '- Configure your own workflow using the template editor\n' +
36
- '- Load sequence datasets and auto-convert to molecules\n' +
37
- '- Calculate different molecular properties\n' +
38
- '- Filter sequences using different criteria\n' +
39
- '- Save campaigns and continue any time from where you left off\n' +
40
- '- Submit final selection to the function of your choice',
41
- });
42
- }
43
-
44
- protected override getTemplatesFolder(): string {
45
- return `${this.app.appName}/templates`;
23
+ protected override header(): AppHeaderOptions {
24
+ return {
25
+ icon: _package.webRoot + '/images/icons/hit-triage-icon.png',
26
+ learnMore: 'https://github.com/datagrok-ai/public/blob/master/packages/HitTriage/README_HT.md',
27
+ items: [
28
+ 'Configure your own workflow using the template editor',
29
+ 'Load sequence datasets and auto-convert to molecules',
30
+ 'Calculate different molecular properties',
31
+ 'Filter sequences using different criteria',
32
+ 'Save campaigns and continue any time from where you left off',
33
+ 'Submit final selection to the function of your choice',
34
+ ],
35
+ };
46
36
  }
47
37
 
48
38
  protected override getDataSourceTag(): string {
@@ -53,71 +43,40 @@ export class PepTriageInfoView extends InfoView {
53
43
  return this.pepTriageDataSourceFunctionsMap;
54
44
  }
55
45
 
56
- protected override async getNewCampaignAccordeon(template: HitTriageTemplate, campaignDetailsDiv: HTMLElement) {
46
+ protected override getNewCampaignForm(template: HitTriageTemplate, {owner, column}: TemplateFormContext): Promise<HTMLElement> {
57
47
  const ptTemplate = template as PepTriageTemplate;
58
48
  const seqColInput = ui.input.string('Sequence Column', {value: ptTemplate.sequenceColumnName ?? '', nullable: false});
59
49
  seqColInput.setTooltip('Name of the sequence column in the dataset');
60
50
  const molColInput = ui.input.string('Molecule Column', {value: ptTemplate.moleculeColumnName ?? '', nullable: true});
61
51
  molColInput.setTooltip('Name of the molecule column (leave empty to auto-convert from sequences)');
62
-
63
- ui.setUpdateIndicator(campaignDetailsDiv, true);
64
- const {root, promise, cancelPromise} = await newCampaignAccordeon(
65
- template, this.getDataSourceFunctionsMap(), this.getDataSourceTag(), {
66
- extraFormElements: [seqColInput.root, molColInput.root],
67
- getExtraData: () => ({
68
- sequenceColumnName: seqColInput.value?.trim() || ptTemplate.sequenceColumnName,
69
- moleculeColumnName: molColInput.value?.trim() || undefined,
70
- }),
71
- });
72
- ui.setUpdateIndicator(campaignDetailsDiv, false);
73
- promise.then(async (camp) => {
74
- // Override template column names with user-specified values
75
- const modifiedTemplate = {...ptTemplate,
76
- sequenceColumnName: camp.extraData?.sequenceColumnName ?? ptTemplate.sequenceColumnName,
77
- moleculeColumnName: camp.extraData?.moleculeColumnName ?? ptTemplate.moleculeColumnName,
78
- };
79
- this.app.dataFrame = camp.df;
80
- this.app._fileInputType = camp.type;
81
- await this.app.setTemplate(modifiedTemplate, undefined, undefined, undefined, camp.friendlyName);
82
- this.app.campaignProps = camp.campaignProps;
83
- await this.app.saveCampaign(undefined, false);
84
- if (modifiedTemplate.layoutViewState && this.app.campaign)
85
- this.app.campaign.layout = modifiedTemplate.layoutViewState;
52
+ return newCampaignAccordeon(template, this.getDataSourceFunctionsMap(), this.getDataSourceTag(), {
53
+ owner,
54
+ column,
55
+ start: (camp) => this.startCampaign(template, camp),
56
+ extraFormElements: [seqColInput.root, molColInput.root],
57
+ getExtraData: () => ({
58
+ sequenceColumnName: seqColInput.value?.trim() || ptTemplate.sequenceColumnName,
59
+ moleculeColumnName: molColInput.value?.trim() || undefined,
60
+ }),
86
61
  });
62
+ }
87
63
 
88
- cancelPromise.then(() => {
89
- this.init();
90
- });
91
- return root;
64
+ /** The template, with the sequence and molecule columns the user named. */
65
+ protected override startCampaign(template: HitTriageTemplate, camp: INewCampaignResult) {
66
+ const ptTemplate = template as PepTriageTemplate;
67
+ return super.startCampaign({...ptTemplate,
68
+ sequenceColumnName: camp.extraData?.sequenceColumnName ?? ptTemplate.sequenceColumnName,
69
+ moleculeColumnName: camp.extraData?.moleculeColumnName ?? ptTemplate.moleculeColumnName,
70
+ } as PepTriageTemplate, camp);
92
71
  }
93
72
 
94
73
  protected override async createNewTemplate(preset?: HitTriageTemplate): Promise<void> {
95
- const newTemplateAccordeon = await createPepTriageTemplateAccordeon(this.app, this.getDataSourceFunctionsMap(), preset as PepTriageTemplate);
96
-
97
- const newView = new DG.ViewBase();
98
- const curView = grok.shell.v;
99
- newView.name = 'New Template';
100
- newView.root.appendChild(newTemplateAccordeon.root);
101
- newView.parentCall = this.app.parentCall;
102
- grok.shell.addView(newView);
103
- newView.path = new URL(this.app.baseUrl).pathname + '/new-template';
104
- newView.parentView = curView;
105
- const {sub} = addBreadCrumbsToRibbons(grok.shell.v, this.app.appName, i18n.createNewTemplate, () => {
106
- grok.shell.v = curView;
107
- newView.close();
108
- });
109
-
110
- newTemplateAccordeon.template.then(async (t) => {
111
- await this.init(t as any);
112
- newView.close();
113
- popRibbonPannels(newView);
114
- grok.shell.v = curView;
115
- sub.unsubscribe();
116
- });
117
- newTemplateAccordeon.cancelPromise.then(() => {
118
- sub.unsubscribe();
119
- newView.close();
120
- grok.shell.v = curView;
121
- });
74
+ ui.setUpdateIndicator(this.root, true);
75
+ try {
76
+ this.showTemplateEditor(await createPepTriageTemplateAccordeon(this.app, this.getDataSourceFunctionsMap(),
77
+ preset as PepTriageTemplate));
78
+ } finally {
79
+ ui.setUpdateIndicator(this.root, false);
80
+ }
122
81
  }
123
82
  }
@@ -1,27 +1,42 @@
1
1
  /* eslint-disable max-len */
2
2
  import * as grok from 'datagrok-api/grok';
3
- import * as ui from 'datagrok-api/ui';
4
3
  import * as DG from 'datagrok-api/dg';
5
4
  import {PeptiHitTemplate} from './types';
6
- import {PeptiHitHelmColName, TileCategoriesColName, ViDColName, ViDSemType} from './consts';
7
- import {_package} from '../package';
8
- import {Subscription} from 'rxjs';
9
- import {filter} from 'rxjs/operators';
5
+ import {PeptiHitHelmColName} from './consts';
10
6
  import {HitDesignApp} from './hit-design-app';
11
7
  import {PeptiHitInfoView} from './pepti-hits-views/info-view';
12
- // @ts-ignore
13
- import '../../css/hit-triage.css';
14
- import {registerMol} from './utils/molreg';
8
+ import {createNewHitDesignDataFrame} from './accordeons/new-hit-design-campaign-accordeon';
9
+ import type {CampaignSessionOptions} from './shared/campaign-session';
15
10
 
11
+ /** Hit Design for peptides: a design is a HELM sequence, converted to the molecule the compute and the V-iD are of. */
16
12
  export class PeptiHitApp extends HitDesignApp<PeptiHitTemplate> {
17
13
  _helmColName: string = PeptiHitHelmColName;
18
14
  constructor(c: DG.FuncCall) {
19
15
  super(c, 'PeptiHit', (app) => new PeptiHitInfoView(app as PeptiHitApp));
20
16
  }
21
17
 
22
- public async setTemplate(template: PeptiHitTemplate, campaignId?: string): Promise<void> {
23
- await super.setTemplate(template, campaignId);
24
- this._helmColName = this.dataFrame!.columns.bySemType(DG.SEMTYPE.MACROMOLECULE)?.name ?? PeptiHitHelmColName;
18
+ protected override newCampaignFrame(template: PeptiHitTemplate): DG.DataFrame {
19
+ return createNewHitDesignDataFrame(template, true);
20
+ }
21
+
22
+ /** The Helm column, tagged as HELM for its renderer and editor. */
23
+ protected override prepareTable(df: DG.DataFrame): void {
24
+ this._helmColName = df.columns.bySemType(DG.SEMTYPE.MACROMOLECULE)?.name ?? PeptiHitHelmColName;
25
+ const helmCol = df.col(this._helmColName);
26
+ if (!helmCol)
27
+ throw new Error('No helm column found');
28
+ helmCol.semType = DG.SEMTYPE.MACROMOLECULE;
29
+ helmCol.setTag('units', 'helm');
30
+ helmCol.setTag('.alphabetIsMultichar', 'true');
31
+ helmCol.setTag('cell.renderer', 'helm');
32
+ }
33
+
34
+ /** Hit Design's, with the HELM editor on the Helm column, the V-iD registered after the conversion, no designer,
35
+ * and the template's layout for any campaign without its own. */
36
+ protected override sessionOptions(): CampaignSessionOptions {
37
+ const layout = this.campaign?.layout ?? this.template?.layoutViewState;
38
+ return {entryColumn: this.helmColName, editor: 'Helm:editMoleculeCell', duplicateLabel: 'Duplicate Sequence',
39
+ registerFirst: false, designer: false, layout};
25
40
  }
26
41
 
27
42
  get helmColName(): string {
@@ -29,195 +44,29 @@ export class PeptiHitApp extends HitDesignApp<PeptiHitTemplate> {
29
44
  this.dataFrame!.columns.bySemType(DG.SEMTYPE.MACROMOLECULE)?.name;
30
45
  }
31
46
 
47
+ /** The sequence converted to the molecule (Bio's toAtomicLevel) in the row, then Hit Design's calculation of it. */
32
48
  async performSingleCellCalculations(cellIndex: number, cellValue?: string) {
33
49
  try {
34
50
  if (!cellValue)
35
51
  throw new Error('No cell value provided');
52
+ const df = this.dataFrame!;
53
+ const run = this.nextRun(cellIndex);
36
54
  const col = DG.Column.fromStrings(this.helmColName, [cellValue]);
37
55
  const table = DG.DataFrame.fromColumns([col]);
38
56
  col.semType = DG.SEMTYPE.MACROMOLECULE;
39
57
  col.setTag('units', 'helm');
40
58
  col.setTag('.alphabetIsMultichar', 'true');
41
59
  await grok.functions.call('Bio:toAtomicLevel', {table: table, seqCol: col, nonlinear: true});
60
+ if (!this.isLatestRun(cellIndex, run) || this.dataFrame !== df)
61
+ return;
42
62
  const molCol = table.columns.names().find((c) => c.toLowerCase() !== this.helmColName.toLowerCase());
43
63
  const mol = molCol ? table.col(molCol)?.get(0) : null;
44
64
  if (!mol)
45
65
  throw new Error('Failed to convert sequence to atomic level');
46
- this.dataFrame!.set(this.molColName, cellIndex, mol);
66
+ df.set(this.molColName, cellIndex, mol);
47
67
  await super.performSingleCellCalculations(cellIndex, mol);
48
68
  } catch (e) {
49
69
  console.error(e);
50
70
  }
51
71
  }
52
-
53
- protected override getDesignView(): DG.TableView {
54
- const subs: Subscription[] = [];
55
- const isNew = this.dataFrame!.col(this.helmColName)?.toList().every((m) => !m && m === '');
56
- const helmCol = this.dataFrame!.col(this.helmColName);
57
- if (!helmCol)
58
- throw new Error('No helm column found');
59
- helmCol.semType = DG.SEMTYPE.MACROMOLECULE;
60
- helmCol.setTag('units', 'helm');
61
- helmCol.setTag('.alphabetIsMultichar', 'true');
62
- helmCol.setTag('cell.renderer', 'helm');
63
-
64
- const view = grok.shell.addTableView(this.dataFrame!);
65
- this._designViewName = this.campaign?.name ?? this._designViewName;
66
- view.name = this._designViewName;
67
- view._onAdded();
68
- const layoutViewState = this._campaign?.layout ?? this.template?.layoutViewState;
69
- if (layoutViewState) {
70
- try {
71
- const layout = DG.ViewLayout.fromViewState(layoutViewState);
72
- view.loadLayout(layout);
73
- } catch (e) {
74
- grok.shell.error('Failed to apply layout. Falling back to default layout.');
75
- console.error(e);
76
- }
77
- }
78
-
79
- const vidGridCol = view.grid?.col(ViDColName);
80
- if (vidGridCol)
81
- vidGridCol.editable = false;
82
-
83
- // set the semType of vidCol
84
- const vidCol = this.dataFrame!.col(ViDColName);
85
- if (vidCol) {
86
- vidCol.semType = ViDSemType;
87
- vidCol.valueComparer = (a: string | null, b: string | null) => {
88
- if (a === b) return 0;
89
- if (a === null) return -1;
90
- if (b === null) return 1;
91
- // column is in string format of V######, but at some point it might go beyond 1 million, so remove the 'V' and compare as numbers
92
- const aNum = parseInt(a.substring(1));
93
- const bNum = parseInt(b.substring(1));
94
- return aNum - bNum;
95
- };
96
- }
97
-
98
- if (isNew)
99
- grok.functions.call('Helm:editMoleculeCell', {cell: view.grid.cell(this.helmColName, 0)});
100
-
101
- subs.push(this.dataFrame!.onRowsAdded.pipe(filter(() => !this.isJoining))
102
- .subscribe(() => { // TODO, insertion of rows in the middle
103
- try {
104
- if (this.stages.length > 0) {
105
- for (let i = 0; i < this.dataFrame!.rowCount; i++) {
106
- const colVal = this.dataFrame!.col(TileCategoriesColName)!.get(i);
107
- if (!colVal || colVal === '' || this.dataFrame!.col(TileCategoriesColName)?.isNone(i))
108
- this.dataFrame!.set(TileCategoriesColName, i, this.stages[0]);
109
- }
110
- }
111
- let lastAddedCell: DG.GridCell | null = null;
112
- for (let i = 0; i < this.dataFrame!.rowCount; i++) {
113
- const cell = view.grid.cell(this.helmColName, i);
114
- if (!cell)
115
- continue;
116
- if (cell.cell.value === '' || cell.cell.value === null)
117
- lastAddedCell = cell;
118
- }
119
- if (lastAddedCell)
120
- grok.functions.call('Helm:editMoleculeCell', {cell: lastAddedCell});
121
- } catch (e) {
122
- console.error(e);
123
- }
124
- }));
125
-
126
- subs.push(grok.events.onContextMenu.subscribe((args) => {
127
- try {
128
- const viewer: DG.Viewer = args?.args?.context;
129
- if (!viewer)
130
- return;
131
- if (viewer?.type !== DG.VIEWER.GRID)
132
- return;
133
- if (!viewer.tableView || viewer.tableView.id !== view.id)
134
- return;
135
- if (args?.args?.item?.tableColumn?.name !== this.helmColName || !args?.args?.item?.isTableCell)
136
- return;
137
- const menu: DG.Menu = args?.args?.menu;
138
- if (!menu)
139
- return;
140
- menu.item('Add new row', () => {
141
- this.dataFrame!.rows.addNew(null, true);
142
- });
143
- menu.item('Duplicate Sequence', () => {
144
- try {
145
- const row = this.dataFrame!.rows.addNew(null, true);
146
- const cell = row.get(this.helmColName);
147
- if (cell != null && row.idx > -1)
148
- this.dataFrame!.cell(row.idx, this.helmColName).value = args?.args?.item?.cell?.value ?? '';
149
- } catch (e) {
150
- console.error(e);
151
- }
152
- });
153
-
154
- const cellIndex = args?.args?.item?.tableRowIndex;
155
- const cellValue = args?.args?.item?.cell?.value;
156
- if (cellValue && (cellIndex ?? -1) > -1) {
157
- menu.item('Re-Run Calculations', async () => {
158
- try {
159
- await this.performSingleCellCalculations(cellIndex, cellValue);
160
- } catch (e) {
161
- console.error(e);
162
- }
163
- });
164
- }
165
- } catch (e: any) {
166
- grok.log.error(e);
167
- }
168
- }));
169
-
170
- if (!view?.grid) {
171
- grok.shell.error('Applied layout created view without grid. Resetting layout.');
172
- view.resetLayout();
173
- }
174
-
175
- view?.grid && subs.push(view.grid.onCellValueEdited.subscribe(async (gc) => {
176
- try {
177
- if (gc.tableColumn?.name === TileCategoriesColName) {
178
- await this.saveCampaign(false);
179
- return;
180
- }
181
- if (gc.tableColumn?.name !== this.helmColName)
182
- return;
183
- const newValue = gc.cell.value;
184
- const newValueIdx = gc.tableRowIndex!;
185
-
186
- await this.performSingleCellCalculations(newValueIdx, newValue);
187
- // conversion happens in performSingleCellCalculations, now we need to register molecule and set V-iD
188
- try {
189
- const molValue: string = this.dataFrame!.col(this.molColName)!.get(newValueIdx);
190
- const newVid = await registerMol(molValue ?? '', this.campaignId!, this.appName);
191
- if (newVid)
192
- this.dataFrame!.col(ViDColName)!.set(newValueIdx, newVid, true);
193
- } catch (e) {
194
- console.error('Error updating V-iD column:', e);
195
- }
196
- } catch (e) {
197
- grok.shell.error('Error performing cell calculations: ' + e);
198
- console.error(e);
199
- }
200
- }));
201
-
202
- view?.grid && subs.push(view.grid.onCellRender.subscribe((args) => {
203
- try {
204
- // color duplicate vid values
205
- const dvCache = this.duplicateVidCache;
206
- const cell = args.cell;
207
- if (!cell || !cell.isTableCell || !cell.tableColumn || !dvCache ||
208
- cell.tableColumn.name !== ViDColName || (cell.tableRowIndex ?? -1) < 0)
209
- return;
210
-
211
- if (dvCache.valueCounts[dvCache.indexes[cell.tableRowIndex!]] > 1) {
212
- args.cell.style.backColor =
213
- DG.Color.setAlpha(DG.Color.getCategoricalColor(dvCache.indexes[cell.tableRowIndex!])
214
- , 150);
215
- }
216
- } catch (e) {}
217
- }));
218
-
219
- this.initDesignViewRibbons(view, subs);
220
- view.parentCall = this.parentCall;
221
- return view;
222
- }
223
72
  }
@@ -1,49 +1,27 @@
1
- import * as grok from 'datagrok-api/grok';
2
- import * as ui from 'datagrok-api/ui';
3
- import * as DG from 'datagrok-api/dg';
4
- import {u2} from '@datagrok-libraries/utils/src/u2';
1
+ import type {AppHeaderOptions} from '@datagrok-libraries/u2';
5
2
  import {_package} from '../../package';
6
3
  import {PeptiHitTemplate} from '../types';
7
- import {newHitDesignCampaignAccordeon} from '../accordeons/new-hit-design-campaign-accordeon';
8
4
  import {HitDesignInfoView} from '../hit-design-views/info-view';
9
5
  import {PeptiHitApp} from '../pepti-hit-app';
10
6
 
11
7
  export class PeptiHitInfoView extends HitDesignInfoView<PeptiHitTemplate, PeptiHitApp> {
12
8
  constructor(app: PeptiHitApp) {
13
- super(app);
9
+ super(app, 'README_PH.md');
14
10
  this.name = 'PeptiHit';
15
- grok.shell.windows.showHelp = true;
16
- grok.shell.windows.help.showHelp(_package.webRoot + 'README_HD.md');
17
11
  }
18
12
 
19
- override async getNewCampaignAccordeon(template: PeptiHitTemplate) {
20
- const {root, promise, cancelPromise} = newHitDesignCampaignAccordeon(template, true);
21
- promise.then(async (camp) => {
22
- this.app.dataFrame = camp.df;
23
- await this.app.setTemplate(template);
24
- this.app.campaignProps = camp.campaignProps;
25
- await this.app.saveCampaign(false);
26
- if (template.layoutViewState && this.app.campaign)
27
- this.app.campaign.layout = template.layoutViewState;
28
- });
29
-
30
- cancelPromise.then(() => {
31
- this.init();
32
- });
33
- return root;
34
- }
35
-
36
- override getAppHeader() {
37
- return u2.appHeader({
38
- iconPath: _package.webRoot + '/images/icons/pepti-hit-icon.png',
39
- learnMoreUrl: 'https://github.com/datagrok-ai/public/blob/master/packages/HitTriage/README_HD.md',
40
- description:
41
- '- Configure your own workflow using the template editor\n' +
42
- '- Sketch Helm sequences in the spreadsheet\n' +
43
- '- Annotate and share ideas with the team\n' +
44
- '- Convert to molecular form and calculate different properties\n' +
45
- '- Save campaigns and continue from where you left off\n' +
46
- '- Submit final selection to the function of your choice',
47
- });
13
+ protected override header(): AppHeaderOptions {
14
+ return {
15
+ icon: _package.webRoot + '/images/icons/pepti-hit-icon.png',
16
+ learnMore: 'https://github.com/datagrok-ai/public/blob/master/packages/HitTriage/README_PH.md',
17
+ items: [
18
+ 'Configure your own workflow using the template editor',
19
+ 'Sketch Helm sequences in the spreadsheet',
20
+ 'Annotate and share ideas with the team',
21
+ 'Convert to molecular form and calculate different properties',
22
+ 'Save campaigns and continue from where you left off',
23
+ 'Submit final selection to the function of your choice',
24
+ ],
25
+ };
48
26
  }
49
27
  }