Skip to content

Commit

Permalink
fix(FOROME-573): fix locus for variant without gene
Browse files Browse the repository at this point in the history
  • Loading branch information
YaroslavTrefilovBraveDevelopers authored and AndreyUstyumenko committed Feb 17, 2022
1 parent d8b9371 commit 91b2d35
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 15 deletions.
13 changes: 12 additions & 1 deletion src/components/variant/ui/igv-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ import variantStore from '@store/variant'
import { Routes } from '@router/routes.enum'
import { Button } from '@ui/button'

//TODO: Delete interface when merge service providers
interface IAttributeDescriptors {
name: string
title: string
cells: [content: string, cellClassName: string][]
tooltip: string | undefined
render: string | undefined
}

export const IgvButton = observer((): ReactElement => {
const variant = toJS(variantStore.variant)

Expand All @@ -24,7 +33,9 @@ export const IgvButton = observer((): ReactElement => {
return sampleName
})

const locus: string = get(variant, '[0].rows[2].cells[0][0]', '')
const rows: IAttributeDescriptors[] = get(variant, '[0].rows', [])
const hg38Row = rows.find(element => element.name === 'hg38')
const locus = hg38Row?.cells[0][0] ?? ''

const fixedLocus = locus.split(' ')[0]

Expand Down
18 changes: 17 additions & 1 deletion src/store/dataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@ import { getFilteredAttrsList } from '@utils/getFilteredAttrsList'
import dirinfoStore from './dirinfo'
import operations from './operations'

//TODO: Delete interfaces when merge service providers
enum TableColorCodes {
GREY = 'grey',
GREEN = 'green',
YELLOW = 'yellow',
YELLOW_CROSS = 'yellow-cross',
RED = 'red',
RED_CROSS = 'red-cross',
}
interface IRecordDescriptor {
cl: TableColorCodes
lb: string
no: number
dt?: string
}

const INCREASE_INDEX = 50

export type Condition = [string, string, unknown, string[]?, unknown?]
Expand All @@ -34,7 +50,7 @@ export class DatasetStore {
samples: string[] = []
selectedVariantNumber?: number

wsRecords: { no: number; cl: string; dt: string; lb: string }[] = []
wsRecords: IRecordDescriptor[] = []
offset = 0
filteredNo: number[] = []

Expand Down
44 changes: 31 additions & 13 deletions src/store/variant.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { get } from 'lodash'
import { makeAutoObservable, runInAction } from 'mobx'
import { makeAutoObservable, runInAction, toJS } from 'mobx'

import { IGridLayout, ReccntCommon, ReccntDisplayItem } from '@declarations'
import { getApiUrl } from '@core/get-api-url'
import { IReccntArguments } from '@service-providers/dataset-level/dataset-level.interface'
import datasetStore from './dataset'

const DRAWER_DEFAULT_WIDTH = 6
Expand Down Expand Up @@ -126,21 +127,38 @@ export class VariantStore {
async fetchVarinatInfoAsync() {
if (datasetStore.isXL) return

const details = datasetStore.wsRecords.find(
record => record.no === this.index,
const details = toJS(
datasetStore.wsRecords.find(record => record.no === this.index),
)

const label = details?.lb
const geneNameInBrackets = label?.split(' ')[0] ?? ''
const geneName = geneNameInBrackets.slice(1, geneNameInBrackets.length - 1)

const isVariantWithoutGene = geneName === 'None'

// create reccntBody with URLSearchParams
const reccntArguments: IReccntArguments = {
ds: this.dsName,
rec: String(this.index),
}

if (!isVariantWithoutGene) {
reccntArguments.details = details?.dt
}

const reccntArgumentsList = Object.entries(reccntArguments)
const reccntBody = new URLSearchParams()

reccntArgumentsList.forEach(element => {
reccntBody.append(element[0], element[1])
})

const [variantResponse, tagsResponse] = await Promise.all([
fetch(
getApiUrl(
`reccnt?ds=${this.dsName}&rec=${this.index}&details=${
details ? details.dt : ''
}`,
),
{
method: 'POST',
},
),
fetch(getApiUrl('reccnt'), {
method: 'POST',
body: reccntBody,
}),
fetch(getApiUrl(`ws_tags?ds=${this.dsName}&rec=${this.index}`)),
])

Expand Down

0 comments on commit 91b2d35

Please sign in to comment.