src/app/store/tree.state.ts
Methods |
|
discrepencyId | |||||||
discrepencyId(undefined: StateContext<TreeStateModel>, undefined: DiscrepencyLabel)
|
|||||||
Decorators :
@Action(DiscrepencyId)
|
|||||||
Defined in src/app/store/tree.state.ts:305
|
|||||||
Updates the discrepency ids list
Parameters :
Returns :
void
|
discrepencyLabel | |||||||
discrepencyLabel(undefined: StateContext<TreeStateModel>, undefined: DiscrepencyLabel)
|
|||||||
Decorators :
@Action(DiscrepencyLabel)
|
|||||||
Defined in src/app/store/tree.state.ts:293
|
|||||||
Updates the discrepency labels list
Parameters :
Returns :
void
|
doSearch | |||||||
doSearch(undefined: StateContext<TreeStateModel>, undefined: DoSearch)
|
|||||||
Decorators :
@Action(DoSearch)
|
|||||||
Defined in src/app/store/tree.state.ts:277
|
|||||||
Updates the search list
Parameters :
Returns :
void
|
duplicateId | |||||||
duplicateId(undefined: StateContext<TreeStateModel>, undefined: DiscrepencyLabel)
|
|||||||
Decorators :
@Action(DuplicateId)
|
|||||||
Defined in src/app/store/tree.state.ts:317
|
|||||||
Updates the duplicate ids list
Parameters :
Returns :
void
|
Static getBimodal | ||||||
getBimodal(state: TreeStateModel)
|
||||||
Decorators :
@Selector()
|
||||||
Defined in src/app/store/tree.state.ts:172
|
||||||
Select the bimodal data. Contains the nodes, links and the bimodal config
Parameters :
Returns :
{ nodes: {}; links: {}; config: BimodalConfig; }
|
Static getBimodalConfig | ||||||
getBimodalConfig(state: TreeStateModel)
|
||||||
Decorators :
@Selector()
|
||||||
Defined in src/app/store/tree.state.ts:140
|
||||||
Select the bimodal config (for sorting and sizing)
Parameters :
Returns :
BimodalConfig
|
Static getBiomarkerType | ||||||
getBiomarkerType(state: TreeStateModel)
|
||||||
Decorators :
@Selector()
|
||||||
Defined in src/app/store/tree.state.ts:132
|
||||||
Select the bimodal config (for sorting and sizing)
Parameters :
Returns :
any
|
Static getBottomSheetData | ||||||
getBottomSheetData(state: TreeStateModel)
|
||||||
Decorators :
@Selector()
|
||||||
Defined in src/app/store/tree.state.ts:180
|
||||||
Select the bottom sheet data
Parameters :
Returns :
Record<string, never>
|
Static getLatestSearchStructure | ||||||
getLatestSearchStructure(state: TreeStateModel)
|
||||||
Decorators :
@Selector()
|
||||||
Defined in src/app/store/tree.state.ts:196
|
||||||
Select the most recently chosen search option
Parameters :
Returns :
SearchStructure
|
Static getLinksData | ||||||
getLinksData(state: TreeStateModel)
|
||||||
Decorators :
@Selector()
|
||||||
Defined in src/app/store/tree.state.ts:188
|
||||||
Select the links data to show in the report
Parameters :
Returns :
{ AS_CT: number; CT_B: number; AS_AS: number; AS_CT_organWise: Record<string, number>; CT_B_organWise: Record<string, number>; AS_AS_organWise: Record<string, number>; }
|
Static getOmapConfig | ||||||
getOmapConfig(state: TreeStateModel)
|
||||||
Decorators :
@Selector()
|
||||||
Defined in src/app/store/tree.state.ts:204
|
||||||
Select the config for OMAPS
Parameters :
Returns :
OmapConfig
|
Static getTreeData | ||||||
getTreeData(state: TreeStateModel)
|
||||||
Decorators :
@Selector()
|
||||||
Defined in src/app/store/tree.state.ts:156
|
||||||
Select the tree data (only anatomical structures)
Parameters :
Returns :
{}
|
Static getVegaSpec | ||||||
getVegaSpec(state: TreeStateModel)
|
||||||
Decorators :
@Selector()
|
||||||
Defined in src/app/store/tree.state.ts:148
|
||||||
Select the vega specification
Parameters :
Returns :
Spec
|
Static getVegaView | ||||||
getVegaView(state: TreeStateModel)
|
||||||
Decorators :
@Selector()
|
||||||
Defined in src/app/store/tree.state.ts:164
|
||||||
Select the Vega View to use the Vega View API
Parameters :
Returns :
View
|
updateBimodal | |||||||
updateBimodal(undefined: StateContext<TreeStateModel>, undefined: UpdateBimodal)
|
|||||||
Decorators :
@Action(UpdateBimodal)
|
|||||||
Defined in src/app/store/tree.state.ts:212
|
|||||||
Updates the bimodal data
Parameters :
Returns :
void
|
updateBimodalConfig | |||||||
updateBimodalConfig(undefined: StateContext<TreeStateModel>, undefined: UpdateBimodalConfig)
|
|||||||
Decorators :
@Action(UpdateBimodalConfig)
|
|||||||
Defined in src/app/store/tree.state.ts:250
|
|||||||
Updates the bimodal config
Parameters :
Returns :
void
|
updateBottomSheetData | |||||||
updateBottomSheetData(undefined: StateContext<TreeStateModel>, undefined: UpdateBottomSheetData)
|
|||||||
Decorators :
@Action(UpdateBottomSheetData)
|
|||||||
Defined in src/app/store/tree.state.ts:329
|
|||||||
Updates the bottom sheet data
Parameters :
Returns :
void
|
updateLinksData | |||||||
updateLinksData(undefined: StateContext<TreeStateModel>, undefined: UpdateLinksData)
|
|||||||
Decorators :
@Action(UpdateLinksData)
|
|||||||
Defined in src/app/store/tree.state.ts:341
|
|||||||
Updates the links data that is displayed in the report
Parameters :
Returns :
void
|
updateOmapConfig | |||||||
updateOmapConfig(undefined: StateContext<TreeStateModel>, undefined: UpdateOmapConfig)
|
|||||||
Decorators :
@Action(UpdateOmapConfig)
|
|||||||
Defined in src/app/store/tree.state.ts:266
|
|||||||
Parameters :
Returns :
void
|
updateVegaSpec | |||||||
updateVegaSpec(undefined: StateContext<TreeStateModel>, undefined: UpdateVegaSpec)
|
|||||||
Decorators :
@Action(UpdateVegaSpec)
|
|||||||
Defined in src/app/store/tree.state.ts:238
|
|||||||
Updates te vega spec
Parameters :
Returns :
void
|
updateVegaView | |||||||
updateVegaView(undefined: StateContext<TreeStateModel>, undefined: UpdateVegaView)
|
|||||||
Decorators :
@Action(UpdateVegaView)
|
|||||||
Defined in src/app/store/tree.state.ts:226
|
|||||||
Updates the vega view Updates the tree data with the anatomical structures Updates the width of the visualization
Parameters :
Returns :
void
|
import { Injectable } from '@angular/core';
import { Action, Selector, State, StateContext } from '@ngxs/store';
import { Spec, View } from 'vega';
import {
DiscrepencyId,
DiscrepencyLabel,
DoSearch,
DuplicateId,
UpdateBimodal,
UpdateBimodalConfig,
UpdateBottomSheetData,
UpdateLinksData,
UpdateOmapConfig,
UpdateVegaSpec,
UpdateVegaView,
} from '../actions/tree.actions';
import { BMNode, BimodalConfig, Link } from '../models/bimodal.model';
import { OmapConfig } from '../models/omap.model';
import { DiscrepencyStructure, SearchStructure, TNode } from '../models/tree.model';
/** Class to keep track of all data and events related to the visualization */
export interface TreeStateModel {
/**
* Stores the Vega Specification
*/
spec: Spec;
/**
* Store the data from the Tree
*/
treeData: TNode[];
/**
* Store the Vega view object which enables us to use the Vega API
*/
view: View;
/**
* Store the width of the visualization
*/
width: number;
/**
* Store the height of the visualization
*/
height: number;
/**
* Store bimodal data - nodes, links and config (for sorting and sizing)
*/
bimodal: {
nodes: BMNode[];
links: Link[];
config: BimodalConfig;
};
/**
* Store the search data
*/
search: SearchStructure[];
/**
* Store the last clicked node in the search field
*/
lastSearch: SearchStructure;
/**
* Store data for the bottom sheet to display information
*/
bottomSheetData: Record<string, never>;
/**
* Store data of links between nodes to show in the report
*/
links: {
AS_CT: number;
CT_B: number;
AS_AS: number;
AS_CT_organWise: Record<string, number>;
CT_B_organWise: Record<string, number>;
AS_AS_organWise: Record<string, number>;
};
/**
* Store the discrepency label data
*/
discrepencyLabel: DiscrepencyStructure[];
/**
* Store the discrepency id data
*/
discrepencyId: DiscrepencyStructure[];
/**
* Store the discrepency id data
*/
duplicateId: DiscrepencyStructure[];
/**
* Store the OMAP Config
*/
omapConfig: OmapConfig;
}
@State<TreeStateModel>({
name: 'treeState',
defaults: {
spec: {},
treeData: [],
view: {} as View,
width: 0,
height: document.getElementsByTagName('body')[0].clientHeight,
bimodal: {
nodes: [],
links: [],
config: {
BM: { sort: 'Alphabetically', size: 'None', type: 'All' },
CT: { sort: 'Alphabetically', size: 'None' },
},
},
search: [],
lastSearch: null as unknown as SearchStructure,
bottomSheetData: {},
links: {
AS_CT: 0,
CT_B: 0,
AS_AS: 0,
AS_CT_organWise: {},
CT_B_organWise: {},
AS_AS_organWise: {},
},
discrepencyLabel: [],
discrepencyId: [],
duplicateId: [],
omapConfig: { organsOnly: false, proteinsOnly: false },
},
})
@Injectable()
export class TreeState {
/**
* Select the bimodal config (for sorting and sizing)
*/
@Selector()
static getBiomarkerType(state: TreeStateModel) {
return state.bimodal.config.BM.type;
}
/**
* Select the bimodal config (for sorting and sizing)
*/
@Selector()
static getBimodalConfig(state: TreeStateModel) {
return state.bimodal.config;
}
/**
* Select the vega specification
*/
@Selector()
static getVegaSpec(state: TreeStateModel) {
return state.spec;
}
/**
* Select the tree data (only anatomical structures)
*/
@Selector()
static getTreeData(state: TreeStateModel) {
return state.treeData;
}
/**
* Select the Vega View to use the Vega View API
*/
@Selector()
static getVegaView(state: TreeStateModel) {
return state.view;
}
/**
* Select the bimodal data. Contains the nodes, links and the bimodal config
*/
@Selector()
static getBimodal(state: TreeStateModel) {
return state.bimodal;
}
/**
* Select the bottom sheet data
*/
@Selector()
static getBottomSheetData(state: TreeStateModel) {
return state.bottomSheetData;
}
/**
* Select the links data to show in the report
*/
@Selector()
static getLinksData(state: TreeStateModel) {
return state.links;
}
/**
* Select the most recently chosen search option
*/
@Selector()
static getLatestSearchStructure(state: TreeStateModel) {
return state.lastSearch;
}
/**
* Select the config for OMAPS
*/
@Selector()
static getOmapConfig(state: TreeStateModel) {
return state.omapConfig;
}
/**
* Updates the bimodal data
*/
@Action(UpdateBimodal)
updateBimodal({ getState, setState }: StateContext<TreeStateModel>, { nodes, links }: UpdateBimodal) {
const state = getState();
setState({
...state,
bimodal: { nodes, links, config: state.bimodal.config },
});
}
/**
* Updates the vega view
* Updates the tree data with the anatomical structures
* Updates the width of the visualization
*/
@Action(UpdateVegaView)
updateVegaView({ patchState }: StateContext<TreeStateModel>, { view }: UpdateVegaView) {
patchState({
view,
treeData: view.data('tree'),
width: view._viewWidth,
});
}
/**
* Updates te vega spec
*/
@Action(UpdateVegaSpec)
updateVegaSpec({ setState, getState }: StateContext<TreeStateModel>, { spec }: UpdateVegaSpec) {
const state = getState();
setState({
...state,
spec,
});
}
/**
* Updates the bimodal config
*/
@Action(UpdateBimodalConfig)
updateBimodalConfig({ getState, setState }: StateContext<TreeStateModel>, { config }: UpdateBimodalConfig) {
const state = getState();
const nodes = state.bimodal.nodes;
const links = state.bimodal.links;
setState({
...state,
bimodal: {
nodes,
links,
config,
},
});
}
@Action(UpdateOmapConfig)
updateOmapConfig({ getState, setState }: StateContext<TreeStateModel>, { config }: UpdateOmapConfig) {
setState({
...getState(),
omapConfig: config,
});
}
/**
* Updates the search list
*/
@Action(DoSearch)
doSearch(
{ getState, setState }: StateContext<TreeStateModel>,
{ searchStructures, lastClickedOption: lastClickedStructure }: DoSearch,
) {
const state = getState();
setState({
...state,
search: searchStructures,
lastSearch: lastClickedStructure,
});
}
/**
* Updates the discrepency labels list
*/
@Action(DiscrepencyLabel)
discrepencyLabel({ getState, setState }: StateContext<TreeStateModel>, { discrepencyStructures }: DiscrepencyLabel) {
const state = getState();
setState({
...state,
discrepencyLabel: discrepencyStructures,
});
}
/**
* Updates the discrepency ids list
*/
@Action(DiscrepencyId)
discrepencyId({ getState, setState }: StateContext<TreeStateModel>, { discrepencyStructures }: DiscrepencyLabel) {
const state = getState();
setState({
...state,
discrepencyId: discrepencyStructures,
});
}
/**
* Updates the duplicate ids list
*/
@Action(DuplicateId)
duplicateId({ getState, setState }: StateContext<TreeStateModel>, { discrepencyStructures }: DiscrepencyLabel) {
const state = getState();
setState({
...state,
duplicateId: discrepencyStructures,
});
}
/**
* Updates the bottom sheet data
*/
@Action(UpdateBottomSheetData)
updateBottomSheetData({ getState, setState }: StateContext<TreeStateModel>, { data }: UpdateBottomSheetData) {
const state = getState();
setState({
...state,
bottomSheetData: data,
});
}
/**
* Updates the links data that is displayed in the report
*/
@Action(UpdateLinksData)
updateLinksData(
{ getState, setState }: StateContext<TreeStateModel>,
{ AS_CT, CT_B, AS_CT_organWise, CT_B_organWise, AS_AS, AS_AS_organWise, allOrgans }: UpdateLinksData,
) {
const state = getState();
if (AS_AS) {
setState({
...state,
links: { ...state.links, AS_AS },
});
} else if (AS_AS_organWise) {
setState({
...state,
links: {
...state.links,
AS_AS_organWise: {
...state.links.AS_AS_organWise,
...AS_AS_organWise,
},
},
});
} else {
setState({
...state,
links: {
AS_CT: allOrgans ? state.links.AS_CT : AS_CT,
CT_B: allOrgans ? state.links.CT_B : CT_B,
CT_B_organWise: { ...state.links.CT_B_organWise, ...CT_B_organWise },
AS_CT_organWise: {
...state.links.AS_CT_organWise,
...AS_CT_organWise,
},
AS_AS: state.links.AS_AS,
AS_AS_organWise: state.links.AS_AS_organWise,
},
});
}
}
}