Skip to content

Commit 6d624d3

Browse files
committed
fix(BipEx2): appease eslint
1 parent 41eb9c9 commit 6d624d3

File tree

2 files changed

+39
-73
lines changed

2 files changed

+39
-73
lines changed

src/browsers/bipex2/BipEx2GeneResults.js

Lines changed: 38 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import PropTypes from 'prop-types'
22
import React from 'react'
33
import styled from 'styled-components'
44

5-
import { BaseTable, ExternalLink, Tabs } from '@gnomad/ui'
5+
import { BaseTable, ExternalLink } from '@gnomad/ui'
66

77
import HelpButton from '../base/HelpButton'
88

@@ -23,6 +23,22 @@ const renderOddsRatio = (value) => {
2323
return value.toPrecision(3)
2424
}
2525

26+
const safeReturnValue = (object, fieldName) => {
27+
return object[fieldName] === null ? '-' : object[fieldName]
28+
}
29+
30+
const createGeneTableRow = (object, category, categoryAbbrev) => {
31+
return (
32+
<tr>
33+
<th scope="row">{category}</th>
34+
<td>{safeReturnValue(object, `${categoryAbbrev}_case_carrier`)}</td>
35+
<td>{safeReturnValue(object, `${categoryAbbrev}_ctrl_carrier`)}</td>
36+
<td>{safeReturnValue(object, `${categoryAbbrev}_p_value`)}</td>
37+
<td>{renderOddsRatio(object[`${categoryAbbrev}_odds_ratio`])}</td>
38+
</tr>
39+
)
40+
}
41+
2642
const BipExGeneResult = ({ result }) => (
2743
<div>
2844
<Table>
@@ -36,69 +52,42 @@ const BipExGeneResult = ({ result }) => (
3652
</tr>
3753
</thead>
3854
<tbody>
39-
<tr>
40-
<th scope="row">Protein-truncating</th>
41-
<td>{result.ptv_case_carrier === null ? '-' : result.ptv_case_carrier}</td>
42-
<td>{result.ptv_ctrl_carrier === null ? '-' : result.ptv_ctrl_carrier}</td>
43-
<td>{result.ptv_p_value === null ? '-' : result.ptv_p_value}</td>
44-
<td>{result.ptv_odds_ratio === null ? '-' : result.ptv_odds_ratio}</td>
45-
</tr>
46-
<tr>
47-
<th scope="row">Missense</th>
48-
<td>{result.mis_case_carrier === null ? '-' : result.mis_case_carrier}</td>
49-
<td>{result.mis_ctrl_carrier === null ? '-' : result.mis_ctrl_carrier}</td>
50-
<td>{result.mis_p_value === null ? '-' : result.mis_p_value}</td>
51-
<td>{result.mis_odds_ratio === null ? '-' : result.mis_odds_ratio}</td>
52-
</tr>
53-
<tr>
54-
<th scope="row">Missense + Protein-truncating</th>
55-
<td>{result.ptv_mis_case_carrier === null ? '-' : result.ptv_mis_case_carrier}</td>
56-
<td>{result.ptv_mis_ctrl_carrier === null ? '-' : result.ptv_mis_ctrl_carrier}</td>
57-
<td>{result.ptv_mis_p_value === null ? '-' : result.ptv_mis_p_value}</td>
58-
<td>{result.ptv_mis_odds_ratio === null ? '-' : result.ptv_mis_odds_ratio}</td>
59-
</tr>
60-
<tr>
61-
<th scope="row">Synonymous</th>
62-
<td>{result.syn_case_carrier === null ? '-' : result.syn_case_carrier}</td>
63-
<td>{result.syn_ctrl_carrier === null ? '-' : result.syn_ctrl_carrier}</td>
64-
<td>{result.syn_p_value === null ? '-' : result.syn_p_value}</td>
65-
<td>{result.syn_odds_ratio === null ? '-' : result.syn_odds_ratio}</td>
66-
</tr>
55+
{createGeneTableRow(result, 'Protein-truncating', 'ptv')}
56+
{createGeneTableRow(result, 'Missense', 'mis')}
57+
{createGeneTableRow(result, 'Missense + Protein-truncating', 'ptv_mis')}
58+
{createGeneTableRow(result, 'Synonmymous', 'syn')}
6759
</tbody>
6860
</Table>
6961

70-
7162
<p style={{ marginTop: '2em' }}>
7263
<strong>Total cases: {result.n_cases}</strong>
7364
</p>
7465
<p>
7566
<strong>Total controls: {result.n_controls}</strong>
7667
</p>
77-
7868
</div>
7969
)
8070

8171
BipExGeneResult.propTypes = {
8272
result: PropTypes.shape({
8373
n_cases: PropTypes.number,
8474
n_controls: PropTypes.number,
85-
ptv_case_count: PropTypes.number,
86-
ptv_control_count: PropTypes.number,
87-
ptv_fisher_gnom_non_psych_case_count: PropTypes.number,
88-
ptv_fisher_gnom_non_psych_control_count: PropTypes.number,
89-
ptv_fisher_gnom_non_psych_pval: PropTypes.number,
90-
// Odds ratio values may be a string 'inf' or a number
91-
ptv_fisher_gnom_non_psych_OR: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
92-
damaging_missense_case_count: PropTypes.number,
93-
damaging_missense_control_count: PropTypes.number,
94-
damaging_missense_fisher_gnom_non_psych_case_count: PropTypes.number,
95-
damaging_missense_fisher_gnom_non_psych_control_count: PropTypes.number,
96-
damaging_missense_fisher_gnom_non_psych_pval: PropTypes.number,
97-
// Odds ratio values may be a string 'inf' or a number
98-
damaging_missense_fisher_gnom_non_psych_OR: PropTypes.oneOfType([
99-
PropTypes.number,
100-
PropTypes.string,
101-
]),
75+
ptv_case_carrier: PropTypes.number,
76+
ptv_ctrl_carrier: PropTypes.number,
77+
ptv_p_value: PropTypes.number,
78+
ptv_odds_ratio: PropTypes.number,
79+
mis_case_carrier: PropTypes.number,
80+
mis_ctrl_carrier: PropTypes.number,
81+
mis_p_value: PropTypes.number,
82+
mis_odds_ratio: PropTypes.number,
83+
ptv_mis_case_carrier: PropTypes.number,
84+
ptv_mis_ctrl_carrier: PropTypes.number,
85+
ptv_mis_p_value: PropTypes.number,
86+
ptv_mis_odds_ratio: PropTypes.number,
87+
syn_case_carrier: PropTypes.number,
88+
syn_ctrl_carrier: PropTypes.number,
89+
syn_p_value: PropTypes.number,
90+
syn_odds_ratio: PropTypes.number,
10291
}).isRequired,
10392
}
10493

@@ -148,30 +137,7 @@ const BipExGeneResults = ({ results }) => (
148137
/>
149138
</h2>
150139

151-
{/*
152-
<Tabs
153-
tabs={[
154-
'Bipolar Disorder',
155-
'Bipolar Disorder 1',
156-
'Bipolar Disorder 2',
157-
'Bipolar Disorder with Psychosis',
158-
'Bipolar Disorder without Psychosis',
159-
'Bipolar Disorder (including Schizoaffective)',
160-
].map((group) => ({
161-
id: group,
162-
label: group,
163-
render: () =>
164-
results[group] ? (
165-
<BipExGeneResult result={results[group]} />
166-
) : (
167-
<p>No result for {group} in this gene.</p>
168-
),
169-
}))}
170-
/>
171-
*/}
172-
173-
<BipExGeneResult result={results["meta"]} />
174-
140+
<BipExGeneResult result={results.meta} />
175141
</>
176142
)
177143

src/browsers/bipex2/BipEx2HomePage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
22
import styled from 'styled-components'
33

4-
import { ExternalLink, Page, PageHeading } from '@gnomad/ui'
4+
import { Page, PageHeading } from '@gnomad/ui'
55

66
import DocumentTitle from '../base/DocumentTitle'
77
import Link from '../base/Link'

0 commit comments

Comments
 (0)