forked from oncokb/oncokb-public
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGeneAdditionalInfoTable.tsx
209 lines (206 loc) · 5.55 KB
/
GeneAdditionalInfoTable.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
import React from 'react';
import { Table } from 'react-bootstrap';
import { EnsemblGene, Gene } from 'app/shared/api/generated/OncoKbPrivateAPI';
import { Linkout } from 'app/shared/links/Linkout';
import { REFERENCE_GENOME } from 'app/config/constants';
import ExternalLinkIcon from 'app/shared/icons/ExternalLinkIcon';
const EnsemblIdLinkout: React.FunctionComponent<{
ensemblId: string;
referenceGenome: REFERENCE_GENOME;
className?: string;
}> = props => {
return (
<ExternalLinkIcon
link={`https://${
props.referenceGenome === REFERENCE_GENOME.GRCh37 ? 'grch37' : 'www'
}.ensembl.org/id/${props.ensemblId}`}
className={props.className}
>
{props.children ? props.children : props.ensemblId}
</ExternalLinkIcon>
);
};
const getEnsemblText = (grch37: string, grch38: string) => {
if (grch37 === grch38) {
return (
<span className={'d-flex'}>
{grch37} (
<EnsemblIdLinkout
ensemblId={grch37}
referenceGenome={REFERENCE_GENOME.GRCh37}
>
{REFERENCE_GENOME.GRCh37}
</EnsemblIdLinkout>
/
<EnsemblIdLinkout
ensemblId={grch38}
referenceGenome={REFERENCE_GENOME.GRCh38}
>
{REFERENCE_GENOME.GRCh38}
</EnsemblIdLinkout>
)
</span>
);
} else {
return (
<div className={'d-flex flex-column'}>
{grch37 && (
<div className={'d-flex'}>
{grch37} (
<EnsemblIdLinkout
ensemblId={grch37}
referenceGenome={REFERENCE_GENOME.GRCh37}
>
{REFERENCE_GENOME.GRCh37}
</EnsemblIdLinkout>
)
</div>
)}
{grch38 && (
<div className={'d-flex'}>
{grch38} (
<EnsemblIdLinkout
ensemblId={grch38}
referenceGenome={REFERENCE_GENOME.GRCh38}
>
{REFERENCE_GENOME.GRCh38}
</EnsemblIdLinkout>
)
</div>
)}
</div>
);
}
};
const RefSeqLinkout: React.FunctionComponent<{
refSeq: string;
referenceGenome: REFERENCE_GENOME;
}> = props => {
return (
<ExternalLinkIcon
link={`https://www.ncbi.nlm.nih.gov/nuccore/${props.refSeq}`}
>
{props.children ? props.children : props.refSeq}
</ExternalLinkIcon>
);
};
const getRefSeqText = (grch37: string, grch38: string) => {
if (grch37 === grch38) {
return (
<span className={'d-flex'}>
{grch37} (
<RefSeqLinkout
refSeq={grch37}
referenceGenome={REFERENCE_GENOME.GRCh37}
>
{REFERENCE_GENOME.GRCh37}
</RefSeqLinkout>
/
<RefSeqLinkout
refSeq={grch38}
referenceGenome={REFERENCE_GENOME.GRCh38}
>
{REFERENCE_GENOME.GRCh38}
</RefSeqLinkout>
)
</span>
);
} else {
return (
<div>
{grch37 && (
<div className="d-flex">
<RefSeqLinkout
refSeq={grch37}
referenceGenome={REFERENCE_GENOME.GRCh37}
/>
<span className="ml-1">({REFERENCE_GENOME.GRCh37})</span>
</div>
)}
{grch38 && (
<div className="d-flex">
<RefSeqLinkout
refSeq={grch38}
referenceGenome={REFERENCE_GENOME.GRCh38}
/>
<span className="ml-1">({REFERENCE_GENOME.GRCh38})</span>
</div>
)}
</div>
);
}
};
const getTableDataStyle = (row: number, col: number) => {
const style: Partial<React.CSSProperties> = {};
if (row === 0) {
style.borderTop = 0;
}
if (col === 0) {
style.width = 160;
}
return style;
};
const GeneAdditionalInfoTable: React.FunctionComponent<{
gene: Gene;
grch37ensemblGene?: EnsemblGene;
grch38ensemblGene?: EnsemblGene;
}> = props => {
const content = [];
if (props.gene.entrezGeneId > 0) {
content.push([
'NCBI Gene',
<Linkout
link={`https://www.ncbi.nlm.nih.gov/gene/${props.gene.entrezGeneId}`}
>
{props.gene.entrezGeneId}
</Linkout>,
]);
}
if (props.grch37ensemblGene || props.grch38ensemblGene) {
content.push([
'Ensembl Gene',
getEnsemblText(
props.grch37ensemblGene?.ensemblGeneId || '',
props.grch38ensemblGene?.ensemblGeneId || ''
),
]);
content.push([
'Location',
<div>
{props.grch37ensemblGene && (
<div>{`Chr${props.grch37ensemblGene?.chromosome}:${props.grch37ensemblGene?.start}-${props.grch37ensemblGene?.end} (GRCh37)`}</div>
)}
{props.grch38ensemblGene && (
<div>{`Chr${props.grch38ensemblGene?.chromosome}:${props.grch38ensemblGene?.start}-${props.grch38ensemblGene?.end} (GRCh38)`}</div>
)}
</div>,
]);
}
if (props.gene.grch37Isoform || props.gene.grch38Isoform) {
content.push([
'Ensembl Transcript',
getEnsemblText(props.gene.grch37Isoform, props.gene.grch38Isoform),
]);
}
if (props.gene.grch37RefSeq || props.gene.grch38RefSeq) {
content.push([
'RefSeq',
getRefSeqText(props.gene.grch37RefSeq, props.gene.grch38RefSeq),
]);
}
return (
<Table size={'sm'}>
<tbody>
{content.map((item, index) => (
<tr key={`key-${item[0]}`}>
<td style={getTableDataStyle(index, 0)}>
<b>{item[0]}</b>
</td>
<td style={getTableDataStyle(index, 1)}>{item[1]}</td>
</tr>
))}
</tbody>
</Table>
);
};
export default GeneAdditionalInfoTable;