Skip to content

Commit

Permalink
Clean up ValidGetDataResponse type; rm duplicate documentation in `…
Browse files Browse the repository at this point in the history
…server/src/termdb.matrix/js`
  • Loading branch information
creilly8 committed Jan 15, 2025
1 parent dc327f6 commit 48fdac5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 48 deletions.
2 changes: 1 addition & 1 deletion server/routes/termdb.boxplot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function init({ genomes }) {
)

const plots: any = []
for (const [key, values] of sortKey2values(data, key2values, overlayTerm)) {
for (const [key, values] of sortKey2values(data as ValidGetDataResponse, key2values, overlayTerm)) {
const sortedValues = values.sort((a, b) => a - b)

const vs = sortedValues.map((v: number) => {
Expand Down
30 changes: 4 additions & 26 deletions server/src/termdb.matrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,32 +37,10 @@ genome{}
server-side genome object
Returns:
{
samples{}
key: stringified integer sample id
value: {
sample: integerId,
<termid>: {key, value},
<more terms...>
<geneName>:{
key, label, // these two are both gene names. useless?? FIXME
values:[]
{gene/isoform/chr/pos/ref/alt/class/mname/dt}
}
}
byTermId{}
metadata about terms
<term id>:
bins: CTE.bins
events: CTE.events
these info are not available in term object and is computed during run time, and
bySampleId{}
metadata about samples (e.g. print names). avoid duplicating such in sample data elements (e.g. mutations)
[sample integer id]: {label: [string sample name for display], ...}
}
- see ValidGetDataResponse type in shared/types/src/termdb.matrix.ts
for documentation
- please update types in shared/types/src/termdb.matrix.ts if
the return object is changed
*/

export async function getData(q, ds, genome, onlyChildren = false) {
Expand Down
39 changes: 18 additions & 21 deletions shared/types/src/termdb.matrix.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/******* termdb.matrix.js is ~not~ a route *****
/******* server/src/termdb.matrix.js is ~not~ a route *****
* getData() is used frequently in other routes or typescript files.
* Although the original file is 1) not ts and 2) not a route, a type
* is still needed when func used in other ts files.
Expand All @@ -14,33 +14,30 @@ export type ValidGetDataResponse = {
key: number
/** value: {
sample: integerId,
<termid>: {key, value},
<tw.$id>: {key, value},
<more terms...>
<geneName>:{
key, label, // these two are both gene names. useless?? FIXME
values:[]
{gene/isoform/chr/pos/ref/alt/class/mname/dt}
}
} */
value: number
}
>
/** Metadata */
refs: {
/** metadata about terms
* <tw.$id>:
bins: CTE.bins
events: CTE.events
these info are not available in term object and is computed during run time, and
*/
byTermId: Record<string, { keyOrder?: any; bins: any }>
/** metadata about terms
* Index is <tw.$id> */
byTermId: Record<
string,
{
keyOrder?: any
/** CTE.bins */
bins?: any
/** CTE.events. These info are not available in term object and is computed during run time. */
events?: any
}
>
/** metadata about samples (e.g. print names). avoid duplicating such in sample data elements (e.g. mutations)
[sample integer id]: {label: [string sample name for display], ...} */
bySampleId: any
//{
// [key: string]: {
// label: string
// }
// }
[sample integer id]: {label: [string sample name for display], ...}
May return as an empty object. */
bySampleId: Record<string, { label: string }> | object
}
sampleType?: any
}
Expand Down

0 comments on commit 48fdac5

Please sign in to comment.