Skip to content

Commit 73d230c

Browse files
authored
Merge pull request #263 from umccr/feat/crypt4gh-storage
docs: add example on how to use Crypt4GH with the htsget-rs server
2 parents 7a2023e + c42ed30 commit 73d230c

File tree

1 file changed

+68
-1
lines changed

1 file changed

+68
-1
lines changed

htsget-axum/README.md

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,67 @@ curl --header "Content-Type: application/json" -d '{"format": "VCF", "regions":
100100
curl '127.0.0.1:8080/variants/service-info'
101101
```
102102

103+
### Crypt4GH
104+
105+
The htsget-rs server experimentally supports serving [Crypt4GH][c4gh] encrypted files to clients. See the [Crypt4GH section][config-c4gh] in the configuration
106+
for more details on how to configure this.
107+
108+
Run the server with the following to enable Crypt4GH support using the [example config][example-config]:
109+
110+
```sh
111+
cargo run -p htsget-axum --features c4gh-experimental -- --config htsget-config/examples/config-files/c4gh.toml
112+
```
113+
114+
Crypt4GH encrypted byte ranges can be queried:
115+
116+
```sh
117+
curl 'http://localhost:8080/reads/data/c4gh/htsnexus_test_NA12878?referenceName=11&start=5000000&end=5050000'
118+
```
119+
120+
The output consists of the Crypt4GH header, which includes the original header, the edit lists, and the re-encrypted header that
121+
the recipient can use to decrypt bytes:
122+
```json
123+
{
124+
"htsget": {
125+
"format": "BAM",
126+
"urls": [
127+
{
128+
"url": "data:;base64,Y3J5cHQ0Z2gBAAAAAwAAAA=="
129+
},
130+
{
131+
"url": "http://127.0.0.1:8081/data/c4gh/htsnexus_test_NA12878.bam.c4gh",
132+
"headers": {
133+
"Range": "bytes=16-123"
134+
}
135+
},
136+
{
137+
"url": "data:;base64,bAAAAAAAAABPIoRdk+d+ifp2PWRFeXoe6Z9kPOj+HrREhzxZ3QiDa2SYh+0Gy8aKpFic4MtTa+ywMpkHziJgojVbcmbvBAr3G7o01lDubsBW98aQ/U1AcalIUCp0fGNkrtdTBN4NaVNIdtQmbAAAAAAAAABPIoRdk+d+ifp2PWRFeXoe6Z9kPOj+HrREhzxZ3QiDa+xJ+yh+52zHvw8qQXMyCtqT6jTFvaYhRPw/6ZzvOdt98YPQgCcTIut58VeTGmR3ien0TdcQFxmfE10MH4qapF2blgjX"
138+
},
139+
{
140+
"url": "http://127.0.0.1:8081/data/c4gh/htsnexus_test_NA12878.bam.c4gh",
141+
"headers": {
142+
"Range": "bytes=124-1114711"
143+
}
144+
},
145+
{
146+
"url": "http://127.0.0.1:8081/data/c4gh/htsnexus_test_NA12878.bam.c4gh",
147+
"headers": {
148+
"Range": "bytes=2557120-2598042"
149+
}
150+
}
151+
]
152+
}
153+
}
154+
```
155+
156+
For example, using a [htsget client][htsget-client], the data can be concatenated, and then decrypted using the [Crypt4GH CLI][crypt4gh-cli]:
157+
158+
```sh
159+
htsget 'http://localhost:8080/reads/data/c4gh/htsnexus_test_NA12878?referenceName=11&start=5000000&end=5050000' > out.c4gh
160+
crypt4gh decrypt --sk data/c4gh/keys/alice.sec < out.c4gh > out.bam
161+
samtools view out.bam
162+
```
163+
103164
### As a library
104165

105166
This crates has some components which may be useful to other crates. Namely, in contains Axum routing functions for
@@ -116,4 +177,10 @@ This crate has the following features:
116177

117178
This project is licensed under the [MIT license][license].
118179

119-
[license]: LICENSE
180+
[license]: LICENSE
181+
[config-c4gh]: ../htsget-config/README.md#crypt4gh
182+
[data-c4gh]: ../data/c4gh
183+
[c4gh]: https://samtools.github.io/hts-specs/crypt4gh.pdf
184+
[htsget-client]: https://htsget.readthedocs.io/en/stable/installation.html
185+
[crypt4gh-cli]: https://github.com/ega-archive/crypt4gh-rust
186+
[example-config]: ../htsget-config/examples/config-files/c4gh.toml

0 commit comments

Comments
 (0)