Skip to content

Commit

Permalink
docs: use vcf in READMEs
Browse files Browse the repository at this point in the history
  • Loading branch information
MalinAhlberg committed May 8, 2024
1 parent b0cdf53 commit c0a0456
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 35 deletions.
51 changes: 18 additions & 33 deletions docs/htsget.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,55 +28,49 @@ pubkey=$(base64 -w0 keys/c4gh.pub.pem)
# macOS: pubkey=$(base64 -i keys/c4gh.pub.pem)
```
Now you should be able make the requests to the htsget server. To request the (byte range of) chromosome 11 of the file `htsnexus_test_NA12878.bam` run:
(Notes: find a better example, chr19=all of case7. Case1 has invalid header, says htsget)
Now you should be able make the requests to the htsget server. To request the (byte range of) chromosome 19 of the file `Case7_IC.reg.vcf` run:
```sh
curl -v -H "Client-Public-Key: $pubkey" -H "Authorization: Bearer $token" -H -k "http://localhost:8088/reads/DATASET0001/htsnexus_test_NA12878?referenceName=11"
curl -v -H "Client-Public-Key: $pubkey" -H "Authorization: Bearer $token" -H -k "http://localhost:8088/variants/DATASET0001/region_vcfs/Case7_IC.reg?referenceName=19"
```
The request will return a ticket of how to download the requested partial file:
```sh
{
{
"htsget": {
"format": "BAM",
"format": "VCF",
"urls": [
{
"url": "data:;base64,Y3J5cHQ0Z2gBAAAAAgAAAA=="
},
{
"url": "http://localhost:8443/s3-encrypted/DATASET0001/htsnexus_test_NA12878.bam.c4gh",
"url": "http://localhost:8443/s3-encrypted/DATASET0001/region_vcfs/Case7_IC.reg.vcf.gz.c4gh",
"headers": {
"Range": "bytes=16-123",
...
}
},
{
"url": "data:;base64,ZAAAAAAAAACxHxjMhagEVY+4bVEZYuqYGK5Ph3jrffrMhXpc3wYWenp2ofohEUwSBOuZF3kH6TEiQsjSPGaE1bvdMQ2uUuuHLWicplUneE77G079sTW8rJIJJ1VgZecPi9cTfQ=="
"url": "data:;base64,XAAAAAAAAADdBAAsr/QmZ+JJxvR2AK+FnvgrpRJ9AzCTbGyPXkIeUpnPwcaoMZYJVI6Mormjh621jT+POJGlZCbAWIu49DRp4HERxt05FvlWE3v3XScFtb/J6u0="
},
{
"url": "http://localhost:8443/s3-encrypted/DATASET0001/htsnexus_test_NA12878.bam.c4gh",
"url": "http://localhost:8443/s3-encrypted/DATASET0001/region_vcfs/Case7_IC.reg.vcf.gz.c4gh",
"headers": {
"Range": "bytes=124-1049147",
"Range": "bytes=124-151945",
...
}
},
{
"url": "http://localhost:8443/s3-encrypted/DATASET0001/htsnexus_test_NA12878.bam.c4gh",
"headers": {
"Range": "bytes=2557120-2598042",
"accept": "*/*",
...
}
]
}
}
```
This repsonse contains byte ranges (eg. `"Range": "bytes=124-1049147"`) as parts of url requests.
This should point you to doing requests to `http://localhost:8443/s3-encrypted` (`sda-download`, from `storage-and-interfaces`) that gets you data for chromosome 11 of the file:
This repsonse contains byte ranges (eg. `"Range": "bytes=124-151945"`) as parts of url requests.
This should point you to doing requests to `http://localhost:8443/s3-encrypted` (`sda-download`, from `storage-and-interfaces`) that gets you data for chromosome 19 of the file:
```sh
curl 'http://localhost:8443/s3-encrypted/DATASET0001/htsnexus_test_NA12878.bam' -H "Authorization: Bearer $token" -H "Client-Public-Key: $pubkey" -H "Range: bytes=16-123" -o p11-00.bam.c4gh
curl 'http://localhost:8443/s3-encrypted/DATASET0001/htsnexus_test_NA12878.bam' -H "Authorization: Bearer $token" -H "Client-Public-Key: $pubkey" -H "Range: bytes=124-1049147" -o p11-01.bam.c4gh
curl 'http://localhost:8443/s3-encrypted/DATASET0001/htsnexus_test_NA12878.bam' -H "Authorization: Bearer $token" -H "Client-Public-Key: $pubkey" -H "Range: bytes=2557120-2598042" -o p11-02.bam.c4gh
curl 'http://localhost:8443/s3-encrypted/DATASET0001/region_vcfs/Case7_IC.reg.vcf.gz.c4gh' -H "Authorization: Bearer $token" -H "Client-Public-Key: $pubkey" -H "Range: bytes=16-123" -o p19-00.vcf.gz.c4gh
curl 'http://localhost:8443/s3-encrypted/DATASET0001/region_vcfs/Case7_IC.reg.vcf.gz.c4gh' -H "Authorization: Bearer $token" -H "Client-Public-Key: $pubkey" -H "Range: bytes=124-151945" -o p19-01.vcf.gz.c4gh
```
The response from hstget also lists two data sections:
Expand All @@ -85,22 +79,13 @@ The response from hstget also lists two data sections:
```
and
```sh
"url": "data:;base64,ZAAAAAAAAACxHxjMhagEVY+4bVEZYuqYGK5Ph3jrffrMhXpc3wYWenp2ofohEUwSBOuZF3kH6TEiQsjSPGaE1bvdMQ2uUuuHLWicplUneE77G079sTW8rJIJJ1VgZecPi9cTfQ==
"url": "data:;base64,XAAAAAAAAADdBAAsr/QmZ+JJxvR2AK+FnvgrpRJ9AzCTbGyPXkIeUpnPwcaoMZYJVI6Mormjh621jT+POJGlZCbAWIu49DRp4HERxt05FvlWE3v3XScFtb/J6u0=
```
These segments are part of the requested data. Save the data (eg. `Y3J5cHQ0Z2gBAAAAAgAAAA==`) to files, `start.b64` and `mid.b64`, respectively. Then concatenate all segments:
```sh
{ <start.b64 base64 --decode && cat p11-00.bam.c4gh && <mid.b64 base64 --decode && cat p11-01.bam.c4gh && cat p11-02.bam.c4gh ;} > htsnexus_11.bam.c4gh
{ <start.b64 base64 --decode && cat p19-00.vcf.gz.c4gh && <mid.b64 base64 --decode && cat p19-01.vcf.gz.c4gh ;} > case7.vcf.gz.c4gh
```
Make sure that the file can be decrypted with your private key:
```sh
crypt4gh decrypt -s keys/c4gh.sec.pem -f htsnexus_11.bam.c4gh
```
Finally, check that samtools can open the new file:
```sh
samtools view htsnexus_11.bam
```
or, if you don't have samtools installed
```sh
docker run -it --rm -v $(pwd):/tmp staphb/samtools /bin/bash
```
crypt4gh decrypt -s keys/c4gh.sec.pem -f case7.vcf.gz.c4gh
```
4 changes: 2 additions & 2 deletions docs/storage-and-interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ curl -s -H "Authorization: Bearer $token" "http://localhost:8443/metadata/datase

```shell
fileID=$(curl -s -H "Authorization: Bearer $token" "http://localhost:8443/metadata/datasets/$datasetID/files" | jq -r '.[0].fileId')
filename=$(curl -s -H "Authorization: Bearer $token" "http://localhost:8443/metadata/datasets/$datasetID/files" | jq -r '.[0].displayFileName' | cut -d '.' -f 1,2 )
filename=$(curl -s -H "Authorization: Bearer $token" "http://localhost:8443/metadata/datasets/$datasetID/files" | jq -r '.[0].displayFileName' | cut -d '.' -f 1,2,3 )
curl -s -H "Authorization: Bearer $token" http://localhost:8443/files/$fileID -o "$filename"
```
Check that the file `$filename` (`htsnexus_test_NA12878.bam`) has been created, and that it contains (binary) data.
Check that the file `$filename` (eg `Case1_IC.reg.vcf`) has been created, and that it contains data.

0 comments on commit c0a0456

Please sign in to comment.