-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindividual.js
168 lines (151 loc) · 4.19 KB
/
individual.js
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
import {
useDataItemDelivery,
NoResultsHelp,
urlRetrieveIds
} from "../hooks/api"
import { ReferenceLink, InternalLink, ExternalLink } from "../components/helpersShared/linkHelpers"
import { AncestryData } from "../components/AncestryData"
import { WithData } from "../components/Loader"
import { withUrlQuery } from "../hooks/url-query"
import { Layout } from "../site-specific/Layout"
import { ShowJSON } from "../components/RawData"
const itemColl = "individuals"
// const exampleId = "pgxind-kftx266l"
const IndividualDetailsPage = withUrlQuery(({ urlQuery }) => {
const { id, datasetIds, hasAllParams } = urlRetrieveIds(urlQuery)
return (
<Layout title="Individual Details">
{!hasAllParams ? (
NoResultsHelp(itemColl)
) : (
<IndividualLoader id={id} datasetIds={datasetIds} />
)}
</Layout>
)
})
export default IndividualDetailsPage
function IndividualLoader({ id, datasetIds }) {
const apiReply = useDataItemDelivery(id, itemColl, datasetIds)
return (
<WithData
apiReply={apiReply}
background
render={(response) => (
<IndividualResponse
response={response}
id={id}
datasetIds={datasetIds}
/>
)}
/>
)
}
function IndividualResponse({ response, datasetIds }) {
if (!response.response.resultSets[0].results) {
return NoResultsHelp(itemColl)
}
return <Individual individual={response.response.resultSets[0].results[0]} datasetIds={datasetIds} />
}
function Individual({ individual, datasetIds }) {
return (
<section className="content">
<h2 className="mb-6">
Individual Details <i>{individual.id}</i>
</h2>
{individual.description && (
<>
<h5>Description</h5>
<p>{individual.description}</p>
</>
)}
{individual.sex && (
<>
<h5>Genotypic Sex</h5>
<ul>
<li>{individual.sex?.label} ({individual.sex.id})</li>
</ul>
</>
)}
{individual.onset &&
<p>
Age at Collection: {individual.onset?.age}
</p>
}
{individual.diseaseCode &&
<>
<h5>Diagnosis</h5>
<p>{individual.diseaseCode?.label}</p>
</>
}
{individual.cellLines &&
<>
<h5>Cell Lines</h5>
<ul>
{individual.cellLines.map((cl, i) => (
<li key={i}>
{cl.description && (cl.description)}
<ExternalLink
href={ReferenceLink(cl)}
label={`: ${cl.id}`}
/>
</li>
))}
</ul>
</>
}
{individual?.genomeAncestry && individual?.genomeAncestry?.length > 0 && (
<>
<h5>Genomic Ancestry</h5>
<AncestryData individual={individual} />
</>
)}
{individual.biosamples && individual.biosamples.length > 0 &&
<>
<h5>Biosamples</h5>
{individual.biosamples.map((bs, i) => (
<li key={i}>
<InternalLink
href={`/biosample/?id=${bs}&datasetIds=${ datasetIds }`}
label={bs}
/>
</li>
))}
</>
}
<h5>Download</h5>
<ul>
<li>Subject data as{" "}
<InternalLink
href={`/beacon/individuals/${individual.id}`}
label="Beacon JSON"
/>
</li>
<li>Sample data as{" "}
<InternalLink
href={`/beacon/individuals/${individual.id}/phenopackets`}
label="Beacon Phenopacket JSON"
/>
</li>
<li>Variants as{" "}
<InternalLink
href={`/beacon/individuals/${individual.id}/genomicVariations`}
label="Beacon JSON"
/>
</li>
<li>Variants as{" "}
<InternalLink
href={`/services/pgxsegvariants?individual_ids=${individual.id}`}
label="Progenetix .pgxseg file"
/>
</li>
<li>Variants as{" "}
<InternalLink
href={`/services/vcfvariants?individual_ids=${individual.id}`}
label="(experimental) VCF 4.4 file"
/>
</li>
</ul>
<ShowJSON data={individual} />
</section>
)
}