@weng-lab/genomebrowser-ui 0.2.2 → 0.2.3
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/.env.local +1 -1
- package/dist/TrackSelect/Folders/biosamples/data/human.json.d.ts +57141 -57141
- package/dist/TrackSelect/Folders/biosamples/data/mouse.json.d.ts +10394 -10394
- package/dist/TrackSelect/Folders/genes/data/human.json.d.ts +7 -7
- package/dist/TrackSelect/Folders/genes/data/mouse.json.d.ts +7 -7
- package/dist/genomebrowser-ui.es.js +9 -5
- package/dist/genomebrowser-ui.es.js.map +1 -1
- package/eslint.config.js +30 -30
- package/index.html +14 -14
- package/package.json +1 -1
- package/src/TrackSelect/DataGrid/DataGridWrapper.tsx +137 -137
- package/src/TrackSelect/DataGrid/DefaultGroupingCell.tsx +64 -64
- package/src/TrackSelect/Dialogs/ClearDialog.tsx +63 -63
- package/src/TrackSelect/Dialogs/LimitDialog.tsx +33 -33
- package/src/TrackSelect/Dialogs/ResetDialog.tsx +43 -43
- package/src/TrackSelect/FolderList/Breadcrumb.tsx +38 -38
- package/src/TrackSelect/FolderList/FolderCard.tsx +51 -51
- package/src/TrackSelect/FolderList/FolderList.tsx +47 -47
- package/src/TrackSelect/Folders/NEW.md +929 -929
- package/src/TrackSelect/Folders/biosamples/data/formatBiosamples.go +254 -254
- package/src/TrackSelect/Folders/biosamples/data/human.json +57141 -57141
- package/src/TrackSelect/Folders/biosamples/data/mouse.json +10394 -10394
- package/src/TrackSelect/Folders/biosamples/human.ts +17 -17
- package/src/TrackSelect/Folders/biosamples/mouse.ts +17 -17
- package/src/TrackSelect/Folders/biosamples/shared/AssayToggle.tsx +78 -78
- package/src/TrackSelect/Folders/biosamples/shared/BiosampleGroupingCell.tsx +146 -146
- package/src/TrackSelect/Folders/biosamples/shared/BiosampleTreeItem.tsx +15 -15
- package/src/TrackSelect/Folders/biosamples/shared/columns.tsx +165 -165
- package/src/TrackSelect/Folders/biosamples/shared/constants.tsx +116 -116
- package/src/TrackSelect/Folders/biosamples/shared/createFolder.ts +116 -116
- package/src/TrackSelect/Folders/biosamples/shared/treeBuilder.ts +224 -224
- package/src/TrackSelect/Folders/biosamples/shared/types.ts +48 -48
- package/src/TrackSelect/Folders/genes/data/human.json +7 -7
- package/src/TrackSelect/Folders/genes/data/mouse.json +7 -7
- package/src/TrackSelect/Folders/genes/human.ts +16 -16
- package/src/TrackSelect/Folders/genes/mouse.ts +16 -16
- package/src/TrackSelect/Folders/genes/shared/columns.tsx +42 -42
- package/src/TrackSelect/Folders/genes/shared/createFolder.ts +68 -68
- package/src/TrackSelect/Folders/genes/shared/treeBuilder.ts +45 -45
- package/src/TrackSelect/Folders/genes/shared/types.ts +29 -29
- package/src/TrackSelect/Folders/index.ts +30 -30
- package/src/TrackSelect/Folders/types.ts +106 -106
- package/src/TrackSelect/TrackSelect.tsx +11 -7
- package/src/TrackSelect/TreeView/CustomTreeItem.tsx +214 -214
- package/src/TrackSelect/TreeView/TreeViewWrapper.tsx +145 -145
- package/src/TrackSelect/store.ts +117 -117
- package/src/TrackSelect/types.ts +121 -121
- package/src/lib.ts +13 -13
- package/src/vite-env.d.ts +1 -1
- package/test/main.tsx +369 -369
- package/tsconfig.app.json +25 -25
- package/tsconfig.json +7 -7
- package/tsconfig.node.json +25 -25
- package/vite.config.ts +66 -66
|
@@ -1,224 +1,224 @@
|
|
|
1
|
-
import { TreeViewBaseItem } from "@mui/x-tree-view";
|
|
2
|
-
import { ExtendedTreeItemProps } from "../../../types";
|
|
3
|
-
import { BiosampleRowInfo } from "./types";
|
|
4
|
-
import { assayTypes, ontologyTypes, formatAssayType } from "./constants";
|
|
5
|
-
|
|
6
|
-
/** Format an ID like "h3k27ac-ENCFF922YMQ" or "folder::h3k27ac-ENCFF922YMQ" to "H3K27ac - ENCFF922YMQ" */
|
|
7
|
-
function formatIdLabel(id: string): string {
|
|
8
|
-
// Remove folder prefix if present (e.g., "FolderName::h3k27ac-ENCFF922YMQ" -> "h3k27ac-ENCFF922YMQ")
|
|
9
|
-
const rawId = id.includes("::") ? id.split("::").pop()! : id;
|
|
10
|
-
|
|
11
|
-
const hyphenIndex = rawId.indexOf("-");
|
|
12
|
-
if (hyphenIndex === -1) return rawId;
|
|
13
|
-
|
|
14
|
-
const assayPart = rawId.substring(0, hyphenIndex);
|
|
15
|
-
const accessionPart = rawId.substring(hyphenIndex + 1);
|
|
16
|
-
|
|
17
|
-
return `${formatAssayType(assayPart)} - ${accessionPart}`;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Creates the root node for the tree view
|
|
22
|
-
*/
|
|
23
|
-
function createRootNode(
|
|
24
|
-
label: string,
|
|
25
|
-
folderId: string,
|
|
26
|
-
): TreeViewBaseItem<ExtendedTreeItemProps> {
|
|
27
|
-
return {
|
|
28
|
-
id: `${folderId}::root`,
|
|
29
|
-
label,
|
|
30
|
-
icon: "folder",
|
|
31
|
-
children: [],
|
|
32
|
-
allExpAccessions: [],
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Builds tree in the sorted by assay view
|
|
38
|
-
* Hierarchy: Assay -> Ontology -> DisplayName (leaf)
|
|
39
|
-
*
|
|
40
|
-
* This is the reverse of the default view - instead of grouping by sample first,
|
|
41
|
-
* we group by assay first, making displayName the leaf node.
|
|
42
|
-
*
|
|
43
|
-
* @param selectedIds - list of selected row IDs
|
|
44
|
-
* @param rowById - Mapping between an id and its BiosampleRowInfo object
|
|
45
|
-
* @param rootLabel - Label for the root node
|
|
46
|
-
* @param folderId - Folder ID to prefix tree item IDs with
|
|
47
|
-
* @returns tree items for the RichTreeView
|
|
48
|
-
*/
|
|
49
|
-
export function buildSortedAssayTreeView(
|
|
50
|
-
selectedIds: string[],
|
|
51
|
-
rowById: Map<string, BiosampleRowInfo>,
|
|
52
|
-
rootLabel: string = "Biosamples",
|
|
53
|
-
folderId: string = "",
|
|
54
|
-
): TreeViewBaseItem<ExtendedTreeItemProps>[] {
|
|
55
|
-
const root = createRootNode(rootLabel, folderId);
|
|
56
|
-
const assayMap = new Map<string, TreeViewBaseItem<ExtendedTreeItemProps>>();
|
|
57
|
-
const ontologyMap = new Map<
|
|
58
|
-
string,
|
|
59
|
-
TreeViewBaseItem<ExtendedTreeItemProps>
|
|
60
|
-
>();
|
|
61
|
-
// Track which displayName nodes exist per assay+ontology combination
|
|
62
|
-
// and which experiment IDs they contain
|
|
63
|
-
const displayNameMap = new Map<
|
|
64
|
-
string,
|
|
65
|
-
TreeViewBaseItem<ExtendedTreeItemProps>
|
|
66
|
-
>();
|
|
67
|
-
|
|
68
|
-
const selectedRows = selectedIds.reduce<BiosampleRowInfo[]>((acc, id) => {
|
|
69
|
-
const row = rowById.get(id);
|
|
70
|
-
if (row) acc.push(row);
|
|
71
|
-
return acc;
|
|
72
|
-
}, []);
|
|
73
|
-
|
|
74
|
-
selectedRows.forEach((row) => {
|
|
75
|
-
const assayKey = `${folderId}::${row.assay}`;
|
|
76
|
-
let assayNode = assayMap.get(assayKey);
|
|
77
|
-
if (!assayNode) {
|
|
78
|
-
assayNode = {
|
|
79
|
-
id: assayKey,
|
|
80
|
-
isAssayItem: true,
|
|
81
|
-
label: row.assay,
|
|
82
|
-
icon: "removeable",
|
|
83
|
-
assayName: row.assay, // Add assayName so the icon renders correctly
|
|
84
|
-
children: [],
|
|
85
|
-
allExpAccessions: [],
|
|
86
|
-
};
|
|
87
|
-
assayMap.set(assayKey, assayNode);
|
|
88
|
-
root.children!.push(assayNode);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const ontologyKey = `${folderId}::${row.assay}-${row.ontology}`;
|
|
92
|
-
let ontologyNode = ontologyMap.get(ontologyKey);
|
|
93
|
-
if (!ontologyNode) {
|
|
94
|
-
ontologyNode = {
|
|
95
|
-
id: ontologyKey,
|
|
96
|
-
isAssayItem: false,
|
|
97
|
-
label: row.ontology,
|
|
98
|
-
icon: "removeable",
|
|
99
|
-
children: [],
|
|
100
|
-
allExpAccessions: [],
|
|
101
|
-
};
|
|
102
|
-
assayNode.children!.push(ontologyNode);
|
|
103
|
-
ontologyMap.set(ontologyKey, ontologyNode);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// DisplayName is now the leaf node (no children, no assay icon)
|
|
107
|
-
const displayNameKey = `${folderId}::${row.assay}-${row.ontology}-${row.displayName}`;
|
|
108
|
-
let displayNameNode = displayNameMap.get(displayNameKey);
|
|
109
|
-
if (!displayNameNode) {
|
|
110
|
-
displayNameNode = {
|
|
111
|
-
id: displayNameKey,
|
|
112
|
-
isAssayItem: false,
|
|
113
|
-
label: row.displayName,
|
|
114
|
-
icon: "removeable",
|
|
115
|
-
children: [],
|
|
116
|
-
allExpAccessions: [],
|
|
117
|
-
};
|
|
118
|
-
ontologyNode.children!.push(displayNameNode);
|
|
119
|
-
displayNameMap.set(displayNameKey, displayNameNode);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// Add this experiment ID to all parent nodes' allExpAccessions
|
|
123
|
-
assayNode.allExpAccessions!.push(row.id);
|
|
124
|
-
ontologyNode.allExpAccessions!.push(row.id);
|
|
125
|
-
displayNameNode.allExpAccessions!.push(row.id);
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
// standardize the order of the assay folders
|
|
129
|
-
root.children!.sort((a, b): number => {
|
|
130
|
-
const aAssay = a.id.split("::")[1] ?? a.id;
|
|
131
|
-
const bAssay = b.id.split("::")[1] ?? b.id;
|
|
132
|
-
return assayTypes.indexOf(aAssay) - assayTypes.indexOf(bAssay);
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
return [root];
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Builds tree in the default view (sorted by ontology)
|
|
140
|
-
* Hierarchy: Ontology -> DisplayName -> Experiment
|
|
141
|
-
*
|
|
142
|
-
* @param selectedIds - list of selected row IDs
|
|
143
|
-
* @param rowById - Mapping between an id and its BiosampleRowInfo object
|
|
144
|
-
* @param rootLabel - Label for the root node
|
|
145
|
-
* @param folderId - Folder ID to prefix tree item IDs with
|
|
146
|
-
* @returns tree items for the RichTreeView
|
|
147
|
-
*/
|
|
148
|
-
export function buildTreeView(
|
|
149
|
-
selectedIds: string[],
|
|
150
|
-
rowById: Map<string, BiosampleRowInfo>,
|
|
151
|
-
rootLabel: string = "Biosamples",
|
|
152
|
-
folderId: string = "",
|
|
153
|
-
): TreeViewBaseItem<ExtendedTreeItemProps>[] {
|
|
154
|
-
const root = createRootNode(rootLabel, folderId);
|
|
155
|
-
const ontologyMap = new Map<
|
|
156
|
-
string,
|
|
157
|
-
TreeViewBaseItem<ExtendedTreeItemProps>
|
|
158
|
-
>();
|
|
159
|
-
const displayNameMap = new Map<
|
|
160
|
-
string,
|
|
161
|
-
TreeViewBaseItem<ExtendedTreeItemProps>
|
|
162
|
-
>();
|
|
163
|
-
|
|
164
|
-
const selectedRows = selectedIds.reduce<BiosampleRowInfo[]>((acc, id) => {
|
|
165
|
-
const row = rowById.get(id);
|
|
166
|
-
if (row) acc.push(row);
|
|
167
|
-
return acc;
|
|
168
|
-
}, []);
|
|
169
|
-
|
|
170
|
-
selectedRows.forEach((row) => {
|
|
171
|
-
if (!row) {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
const ontologyKey = `${folderId}::${row.ontology}`;
|
|
175
|
-
let ontologyNode = ontologyMap.get(ontologyKey);
|
|
176
|
-
if (!ontologyNode) {
|
|
177
|
-
ontologyNode = {
|
|
178
|
-
id: ontologyKey,
|
|
179
|
-
label: row.ontology,
|
|
180
|
-
icon: "removeable",
|
|
181
|
-
children: [],
|
|
182
|
-
allExpAccessions: [],
|
|
183
|
-
};
|
|
184
|
-
ontologyMap.set(ontologyKey, ontologyNode);
|
|
185
|
-
root.children!.push(ontologyNode);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
const displayNameKey = `${folderId}::${row.ontology}-${row.displayName}`;
|
|
189
|
-
let displayNameNode = displayNameMap.get(displayNameKey);
|
|
190
|
-
if (!displayNameNode) {
|
|
191
|
-
displayNameNode = {
|
|
192
|
-
id: displayNameKey,
|
|
193
|
-
label: row.displayName,
|
|
194
|
-
icon: "removeable",
|
|
195
|
-
children: [],
|
|
196
|
-
allExpAccessions: [],
|
|
197
|
-
};
|
|
198
|
-
ontologyNode.children!.push(displayNameNode);
|
|
199
|
-
displayNameMap.set(displayNameKey, displayNameNode);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
const expNode: TreeViewBaseItem<ExtendedTreeItemProps> = {
|
|
203
|
-
id: row.id,
|
|
204
|
-
label: formatIdLabel(row.id),
|
|
205
|
-
icon: "removeable",
|
|
206
|
-
assayName: row.assay,
|
|
207
|
-
children: [],
|
|
208
|
-
allExpAccessions: [row.id],
|
|
209
|
-
};
|
|
210
|
-
displayNameNode.children!.push(expNode);
|
|
211
|
-
|
|
212
|
-
ontologyNode.allExpAccessions!.push(row.id);
|
|
213
|
-
displayNameNode.allExpAccessions!.push(row.id);
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
// standardize the order of the ontology folders
|
|
217
|
-
root.children!.sort((a, b): number => {
|
|
218
|
-
const aOntology = a.id.split("::")[1] ?? a.id;
|
|
219
|
-
const bOntology = b.id.split("::")[1] ?? b.id;
|
|
220
|
-
return ontologyTypes.indexOf(aOntology) - ontologyTypes.indexOf(bOntology);
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
return [root];
|
|
224
|
-
}
|
|
1
|
+
import { TreeViewBaseItem } from "@mui/x-tree-view";
|
|
2
|
+
import { ExtendedTreeItemProps } from "../../../types";
|
|
3
|
+
import { BiosampleRowInfo } from "./types";
|
|
4
|
+
import { assayTypes, ontologyTypes, formatAssayType } from "./constants";
|
|
5
|
+
|
|
6
|
+
/** Format an ID like "h3k27ac-ENCFF922YMQ" or "folder::h3k27ac-ENCFF922YMQ" to "H3K27ac - ENCFF922YMQ" */
|
|
7
|
+
function formatIdLabel(id: string): string {
|
|
8
|
+
// Remove folder prefix if present (e.g., "FolderName::h3k27ac-ENCFF922YMQ" -> "h3k27ac-ENCFF922YMQ")
|
|
9
|
+
const rawId = id.includes("::") ? id.split("::").pop()! : id;
|
|
10
|
+
|
|
11
|
+
const hyphenIndex = rawId.indexOf("-");
|
|
12
|
+
if (hyphenIndex === -1) return rawId;
|
|
13
|
+
|
|
14
|
+
const assayPart = rawId.substring(0, hyphenIndex);
|
|
15
|
+
const accessionPart = rawId.substring(hyphenIndex + 1);
|
|
16
|
+
|
|
17
|
+
return `${formatAssayType(assayPart)} - ${accessionPart}`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Creates the root node for the tree view
|
|
22
|
+
*/
|
|
23
|
+
function createRootNode(
|
|
24
|
+
label: string,
|
|
25
|
+
folderId: string,
|
|
26
|
+
): TreeViewBaseItem<ExtendedTreeItemProps> {
|
|
27
|
+
return {
|
|
28
|
+
id: `${folderId}::root`,
|
|
29
|
+
label,
|
|
30
|
+
icon: "folder",
|
|
31
|
+
children: [],
|
|
32
|
+
allExpAccessions: [],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Builds tree in the sorted by assay view
|
|
38
|
+
* Hierarchy: Assay -> Ontology -> DisplayName (leaf)
|
|
39
|
+
*
|
|
40
|
+
* This is the reverse of the default view - instead of grouping by sample first,
|
|
41
|
+
* we group by assay first, making displayName the leaf node.
|
|
42
|
+
*
|
|
43
|
+
* @param selectedIds - list of selected row IDs
|
|
44
|
+
* @param rowById - Mapping between an id and its BiosampleRowInfo object
|
|
45
|
+
* @param rootLabel - Label for the root node
|
|
46
|
+
* @param folderId - Folder ID to prefix tree item IDs with
|
|
47
|
+
* @returns tree items for the RichTreeView
|
|
48
|
+
*/
|
|
49
|
+
export function buildSortedAssayTreeView(
|
|
50
|
+
selectedIds: string[],
|
|
51
|
+
rowById: Map<string, BiosampleRowInfo>,
|
|
52
|
+
rootLabel: string = "Biosamples",
|
|
53
|
+
folderId: string = "",
|
|
54
|
+
): TreeViewBaseItem<ExtendedTreeItemProps>[] {
|
|
55
|
+
const root = createRootNode(rootLabel, folderId);
|
|
56
|
+
const assayMap = new Map<string, TreeViewBaseItem<ExtendedTreeItemProps>>();
|
|
57
|
+
const ontologyMap = new Map<
|
|
58
|
+
string,
|
|
59
|
+
TreeViewBaseItem<ExtendedTreeItemProps>
|
|
60
|
+
>();
|
|
61
|
+
// Track which displayName nodes exist per assay+ontology combination
|
|
62
|
+
// and which experiment IDs they contain
|
|
63
|
+
const displayNameMap = new Map<
|
|
64
|
+
string,
|
|
65
|
+
TreeViewBaseItem<ExtendedTreeItemProps>
|
|
66
|
+
>();
|
|
67
|
+
|
|
68
|
+
const selectedRows = selectedIds.reduce<BiosampleRowInfo[]>((acc, id) => {
|
|
69
|
+
const row = rowById.get(id);
|
|
70
|
+
if (row) acc.push(row);
|
|
71
|
+
return acc;
|
|
72
|
+
}, []);
|
|
73
|
+
|
|
74
|
+
selectedRows.forEach((row) => {
|
|
75
|
+
const assayKey = `${folderId}::${row.assay}`;
|
|
76
|
+
let assayNode = assayMap.get(assayKey);
|
|
77
|
+
if (!assayNode) {
|
|
78
|
+
assayNode = {
|
|
79
|
+
id: assayKey,
|
|
80
|
+
isAssayItem: true,
|
|
81
|
+
label: row.assay,
|
|
82
|
+
icon: "removeable",
|
|
83
|
+
assayName: row.assay, // Add assayName so the icon renders correctly
|
|
84
|
+
children: [],
|
|
85
|
+
allExpAccessions: [],
|
|
86
|
+
};
|
|
87
|
+
assayMap.set(assayKey, assayNode);
|
|
88
|
+
root.children!.push(assayNode);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const ontologyKey = `${folderId}::${row.assay}-${row.ontology}`;
|
|
92
|
+
let ontologyNode = ontologyMap.get(ontologyKey);
|
|
93
|
+
if (!ontologyNode) {
|
|
94
|
+
ontologyNode = {
|
|
95
|
+
id: ontologyKey,
|
|
96
|
+
isAssayItem: false,
|
|
97
|
+
label: row.ontology,
|
|
98
|
+
icon: "removeable",
|
|
99
|
+
children: [],
|
|
100
|
+
allExpAccessions: [],
|
|
101
|
+
};
|
|
102
|
+
assayNode.children!.push(ontologyNode);
|
|
103
|
+
ontologyMap.set(ontologyKey, ontologyNode);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// DisplayName is now the leaf node (no children, no assay icon)
|
|
107
|
+
const displayNameKey = `${folderId}::${row.assay}-${row.ontology}-${row.displayName}`;
|
|
108
|
+
let displayNameNode = displayNameMap.get(displayNameKey);
|
|
109
|
+
if (!displayNameNode) {
|
|
110
|
+
displayNameNode = {
|
|
111
|
+
id: displayNameKey,
|
|
112
|
+
isAssayItem: false,
|
|
113
|
+
label: row.displayName,
|
|
114
|
+
icon: "removeable",
|
|
115
|
+
children: [],
|
|
116
|
+
allExpAccessions: [],
|
|
117
|
+
};
|
|
118
|
+
ontologyNode.children!.push(displayNameNode);
|
|
119
|
+
displayNameMap.set(displayNameKey, displayNameNode);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Add this experiment ID to all parent nodes' allExpAccessions
|
|
123
|
+
assayNode.allExpAccessions!.push(row.id);
|
|
124
|
+
ontologyNode.allExpAccessions!.push(row.id);
|
|
125
|
+
displayNameNode.allExpAccessions!.push(row.id);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// standardize the order of the assay folders
|
|
129
|
+
root.children!.sort((a, b): number => {
|
|
130
|
+
const aAssay = a.id.split("::")[1] ?? a.id;
|
|
131
|
+
const bAssay = b.id.split("::")[1] ?? b.id;
|
|
132
|
+
return assayTypes.indexOf(aAssay) - assayTypes.indexOf(bAssay);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
return [root];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Builds tree in the default view (sorted by ontology)
|
|
140
|
+
* Hierarchy: Ontology -> DisplayName -> Experiment
|
|
141
|
+
*
|
|
142
|
+
* @param selectedIds - list of selected row IDs
|
|
143
|
+
* @param rowById - Mapping between an id and its BiosampleRowInfo object
|
|
144
|
+
* @param rootLabel - Label for the root node
|
|
145
|
+
* @param folderId - Folder ID to prefix tree item IDs with
|
|
146
|
+
* @returns tree items for the RichTreeView
|
|
147
|
+
*/
|
|
148
|
+
export function buildTreeView(
|
|
149
|
+
selectedIds: string[],
|
|
150
|
+
rowById: Map<string, BiosampleRowInfo>,
|
|
151
|
+
rootLabel: string = "Biosamples",
|
|
152
|
+
folderId: string = "",
|
|
153
|
+
): TreeViewBaseItem<ExtendedTreeItemProps>[] {
|
|
154
|
+
const root = createRootNode(rootLabel, folderId);
|
|
155
|
+
const ontologyMap = new Map<
|
|
156
|
+
string,
|
|
157
|
+
TreeViewBaseItem<ExtendedTreeItemProps>
|
|
158
|
+
>();
|
|
159
|
+
const displayNameMap = new Map<
|
|
160
|
+
string,
|
|
161
|
+
TreeViewBaseItem<ExtendedTreeItemProps>
|
|
162
|
+
>();
|
|
163
|
+
|
|
164
|
+
const selectedRows = selectedIds.reduce<BiosampleRowInfo[]>((acc, id) => {
|
|
165
|
+
const row = rowById.get(id);
|
|
166
|
+
if (row) acc.push(row);
|
|
167
|
+
return acc;
|
|
168
|
+
}, []);
|
|
169
|
+
|
|
170
|
+
selectedRows.forEach((row) => {
|
|
171
|
+
if (!row) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
const ontologyKey = `${folderId}::${row.ontology}`;
|
|
175
|
+
let ontologyNode = ontologyMap.get(ontologyKey);
|
|
176
|
+
if (!ontologyNode) {
|
|
177
|
+
ontologyNode = {
|
|
178
|
+
id: ontologyKey,
|
|
179
|
+
label: row.ontology,
|
|
180
|
+
icon: "removeable",
|
|
181
|
+
children: [],
|
|
182
|
+
allExpAccessions: [],
|
|
183
|
+
};
|
|
184
|
+
ontologyMap.set(ontologyKey, ontologyNode);
|
|
185
|
+
root.children!.push(ontologyNode);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const displayNameKey = `${folderId}::${row.ontology}-${row.displayName}`;
|
|
189
|
+
let displayNameNode = displayNameMap.get(displayNameKey);
|
|
190
|
+
if (!displayNameNode) {
|
|
191
|
+
displayNameNode = {
|
|
192
|
+
id: displayNameKey,
|
|
193
|
+
label: row.displayName,
|
|
194
|
+
icon: "removeable",
|
|
195
|
+
children: [],
|
|
196
|
+
allExpAccessions: [],
|
|
197
|
+
};
|
|
198
|
+
ontologyNode.children!.push(displayNameNode);
|
|
199
|
+
displayNameMap.set(displayNameKey, displayNameNode);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const expNode: TreeViewBaseItem<ExtendedTreeItemProps> = {
|
|
203
|
+
id: row.id,
|
|
204
|
+
label: formatIdLabel(row.id),
|
|
205
|
+
icon: "removeable",
|
|
206
|
+
assayName: row.assay,
|
|
207
|
+
children: [],
|
|
208
|
+
allExpAccessions: [row.id],
|
|
209
|
+
};
|
|
210
|
+
displayNameNode.children!.push(expNode);
|
|
211
|
+
|
|
212
|
+
ontologyNode.allExpAccessions!.push(row.id);
|
|
213
|
+
displayNameNode.allExpAccessions!.push(row.id);
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
// standardize the order of the ontology folders
|
|
217
|
+
root.children!.sort((a, b): number => {
|
|
218
|
+
const aOntology = a.id.split("::")[1] ?? a.id;
|
|
219
|
+
const bOntology = b.id.split("::")[1] ?? b.id;
|
|
220
|
+
return ontologyTypes.indexOf(aOntology) - ontologyTypes.indexOf(bOntology);
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
return [root];
|
|
224
|
+
}
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Types for biosample folder data
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Assay information from the JSON data
|
|
7
|
-
*/
|
|
8
|
-
export type BiosampleAssayInfo = {
|
|
9
|
-
id: string;
|
|
10
|
-
assay: string;
|
|
11
|
-
url: string;
|
|
12
|
-
experimentAccession: string;
|
|
13
|
-
fileAccession: string;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Track information from the JSON data
|
|
18
|
-
*/
|
|
19
|
-
export type BiosampleTrackInfo = {
|
|
20
|
-
name: string;
|
|
21
|
-
ontology: string;
|
|
22
|
-
lifeStage: string;
|
|
23
|
-
sampleType: string;
|
|
24
|
-
displayName: string;
|
|
25
|
-
assays: BiosampleAssayInfo[];
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Row format for DataGrid (flattened from TrackInfo)
|
|
30
|
-
*/
|
|
31
|
-
export type BiosampleRowInfo = {
|
|
32
|
-
id: string;
|
|
33
|
-
ontology: string;
|
|
34
|
-
lifeStage: string;
|
|
35
|
-
sampleType: string;
|
|
36
|
-
displayName: string;
|
|
37
|
-
assay: string;
|
|
38
|
-
experimentAccession: string;
|
|
39
|
-
fileAccession: string;
|
|
40
|
-
url: string;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Structure of the biosample JSON data files
|
|
45
|
-
*/
|
|
46
|
-
export type BiosampleDataFile = {
|
|
47
|
-
tracks: BiosampleTrackInfo[];
|
|
48
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Types for biosample folder data
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Assay information from the JSON data
|
|
7
|
+
*/
|
|
8
|
+
export type BiosampleAssayInfo = {
|
|
9
|
+
id: string;
|
|
10
|
+
assay: string;
|
|
11
|
+
url: string;
|
|
12
|
+
experimentAccession: string;
|
|
13
|
+
fileAccession: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Track information from the JSON data
|
|
18
|
+
*/
|
|
19
|
+
export type BiosampleTrackInfo = {
|
|
20
|
+
name: string;
|
|
21
|
+
ontology: string;
|
|
22
|
+
lifeStage: string;
|
|
23
|
+
sampleType: string;
|
|
24
|
+
displayName: string;
|
|
25
|
+
assays: BiosampleAssayInfo[];
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Row format for DataGrid (flattened from TrackInfo)
|
|
30
|
+
*/
|
|
31
|
+
export type BiosampleRowInfo = {
|
|
32
|
+
id: string;
|
|
33
|
+
ontology: string;
|
|
34
|
+
lifeStage: string;
|
|
35
|
+
sampleType: string;
|
|
36
|
+
displayName: string;
|
|
37
|
+
assay: string;
|
|
38
|
+
experimentAccession: string;
|
|
39
|
+
fileAccession: string;
|
|
40
|
+
url: string;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Structure of the biosample JSON data files
|
|
45
|
+
*/
|
|
46
|
+
export type BiosampleDataFile = {
|
|
47
|
+
tracks: BiosampleTrackInfo[];
|
|
48
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"id": "gencode-basic",
|
|
4
|
-
"displayName": "GENCODE Basic Genes",
|
|
5
|
-
"versions": [29, 40]
|
|
6
|
-
}
|
|
7
|
-
]
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "gencode-basic",
|
|
4
|
+
"displayName": "GENCODE Basic Genes",
|
|
5
|
+
"versions": [29, 40]
|
|
6
|
+
}
|
|
7
|
+
]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"id": "gencode-basic",
|
|
4
|
-
"displayName": "GENCODE Basic Genes",
|
|
5
|
-
"versions": [21, 25]
|
|
6
|
-
}
|
|
7
|
-
]
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "gencode-basic",
|
|
4
|
+
"displayName": "GENCODE Basic Genes",
|
|
5
|
+
"versions": [21, 25]
|
|
6
|
+
}
|
|
7
|
+
]
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { createGeneFolder } from "./shared/createFolder";
|
|
2
|
-
import humanData from "./data/human.json";
|
|
3
|
-
import { GeneDataFile } from "./shared/types";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Gene annotations folder for human (GRCh38 assembly)
|
|
7
|
-
*
|
|
8
|
-
* Contains gene annotation tracks like GENCODE that users can
|
|
9
|
-
* select to display in the genome browser.
|
|
10
|
-
*/
|
|
11
|
-
export const humanGenesFolder = createGeneFolder({
|
|
12
|
-
id: "human-genes",
|
|
13
|
-
label: "Genes",
|
|
14
|
-
description: "Gene annotation tracks",
|
|
15
|
-
data: humanData as GeneDataFile,
|
|
16
|
-
});
|
|
1
|
+
import { createGeneFolder } from "./shared/createFolder";
|
|
2
|
+
import humanData from "./data/human.json";
|
|
3
|
+
import { GeneDataFile } from "./shared/types";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Gene annotations folder for human (GRCh38 assembly)
|
|
7
|
+
*
|
|
8
|
+
* Contains gene annotation tracks like GENCODE that users can
|
|
9
|
+
* select to display in the genome browser.
|
|
10
|
+
*/
|
|
11
|
+
export const humanGenesFolder = createGeneFolder({
|
|
12
|
+
id: "human-genes",
|
|
13
|
+
label: "Genes",
|
|
14
|
+
description: "Gene annotation tracks",
|
|
15
|
+
data: humanData as GeneDataFile,
|
|
16
|
+
});
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { createGeneFolder } from "./shared/createFolder";
|
|
2
|
-
import mouseData from "./data/mouse.json";
|
|
3
|
-
import { GeneDataFile } from "./shared/types";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Gene annotations folder for human (GRCh38 assembly)
|
|
7
|
-
*
|
|
8
|
-
* Contains gene annotation tracks like GENCODE that users can
|
|
9
|
-
* select to display in the genome browser.
|
|
10
|
-
*/
|
|
11
|
-
export const mouseGenesFolder = createGeneFolder({
|
|
12
|
-
id: "mouse-genes",
|
|
13
|
-
label: "Genes",
|
|
14
|
-
description: "Gene annotation tracks",
|
|
15
|
-
data: mouseData as GeneDataFile,
|
|
16
|
-
});
|
|
1
|
+
import { createGeneFolder } from "./shared/createFolder";
|
|
2
|
+
import mouseData from "./data/mouse.json";
|
|
3
|
+
import { GeneDataFile } from "./shared/types";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Gene annotations folder for human (GRCh38 assembly)
|
|
7
|
+
*
|
|
8
|
+
* Contains gene annotation tracks like GENCODE that users can
|
|
9
|
+
* select to display in the genome browser.
|
|
10
|
+
*/
|
|
11
|
+
export const mouseGenesFolder = createGeneFolder({
|
|
12
|
+
id: "mouse-genes",
|
|
13
|
+
label: "Genes",
|
|
14
|
+
description: "Gene annotation tracks",
|
|
15
|
+
data: mouseData as GeneDataFile,
|
|
16
|
+
});
|