Skip to content

Commit

Permalink
feat(FOROME-1322): add macro tagging (#945)
Browse files Browse the repository at this point in the history
  • Loading branch information
QSdmitrioul authored Sep 14, 2022
1 parent 481af74 commit ddd964c
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export enum ZoneName {
Symbol = 'Symbol',
GeneLists = 'Gene_Lists',
HasVariant = 'Has_Variant',
Tags = '_tags',
}
50 changes: 50 additions & 0 deletions src/pages/ws/ui/control-panel/macro-tagging/macro-tagging.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import { makeAutoObservable } from 'mobx'

import { t } from '@i18n'
import { datasetStore } from '@store/dataset'
import dtreeStore from '@store/dtree'
import filterStore from '@store/filter'
import filterPresetsStore from '@store/filter-presets'
import mainTableStore from '@store/ws/main-table.store'
import zoneStore from '@store/ws/zone.store'
import { ZoneName } from '@pages/ws/ui/control-panel/macro-tagging/macro-tagging.interfaces'
import { TZoneSetting } from '@service-providers/common'
import operationsProvider from '@service-providers/operations/operations.provider'
import {
IMacroTaggingArgumentsAsync,
Expand All @@ -18,13 +24,57 @@ class MacroTaggingStore {
public isConfirmOpen: boolean = false
public action?: MacroTaggingActions

private get zone(): undefined | TZoneSetting[] {
const result: TZoneSetting[] = []

if (zoneStore.selectedGenes.length) {
result.push([ZoneName.Symbol, zoneStore.selectedGenes])
}

if (zoneStore.selectedGenesList.length) {
result.push([ZoneName.GeneLists, zoneStore.selectedGenesList])
}

if (zoneStore.selectedSamples.length) {
result.push([ZoneName.HasVariant, zoneStore.selectedSamples])
}

if (zoneStore.selectedTags.length) {
result.push([ZoneName.Tags, zoneStore.selectedTags])

if (zoneStore.isModeNOT) {
result.slice(-1)[0].push(false)
}
}

return result.length ? result : undefined
}

private get params() {
const filter =
filterPresetsStore.activePreset || dtreeStore.currentDtreeName

const zone = this.zone
const conditions = filterStore.conditions

const params: IMacroTaggingArgumentsAsync = {
ds: datasetStore.datasetName,
tag: this.tag,
delay: true,
}

if (filter) {
params.filter = filter
}

if (zone) {
params.zone = zone
}

if (conditions && conditions.length) {
params.conditions = conditions
}

if (this.action === MacroTaggingActions.Remove) {
params.off = true
}
Expand Down
3 changes: 2 additions & 1 deletion src/service-providers/common/common.interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ApproxValueTypes } from '@core/enum/approxValueTypes'
import { ZoneName } from '@pages/ws/ui/control-panel/macro-tagging/macro-tagging.interfaces'

export enum DatasetKinds {
WS = 'ws',
Expand Down Expand Up @@ -254,7 +255,7 @@ export interface ISolutionEntryDescription {
}

export type TZoneSetting = [
zoneName: string,
zoneName: ZoneName,
variants: string[],
isNegationRequired?: false,
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export interface IMacroTaggingArguments {
off?: true | any
filter?: string
conditions?: ReadonlyArray<TCondition>
zone?: TZoneSetting[]
dtree?: string
code?: string
no?: string
Expand Down
2 changes: 1 addition & 1 deletion src/store/filter-presets/filter-presets.store.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { makeAutoObservable, reaction, toJS } from 'mobx'

import { TGenomeOptionsKeys } from '@core/enum/explore-genome-types-enum'
import { t } from '@i18n'
import { createHistoryObserver } from '@store/common'
import {
Expand All @@ -11,7 +12,6 @@ import { filterPresetsData } from '@utils/filter-presets'
import { showToast } from '@utils/notifications/showToast'
import { validatePresetName } from '@utils/validation/validatePresetName'
import datasetStore from '../dataset/dataset'
import { TGenomeOptionsKeys } from './../../core/enum/explore-genome-types-enum'
import { AvailablePresetsAsyncStore } from './available-presets.async.store'

export class FilterPresetsStore {
Expand Down

0 comments on commit ddd964c

Please sign in to comment.