Great. Fantastic that samtools supports streaming remote files!
For a study of VNTR copies I'm looking for high-coverage public-accessible WGS data such as 1KG,HGDP and SGDP. Since downloading the whole cram file if one just needs one chromosome can take a long time, I wonder if it is possible to subset the cram file to a single-chromosome bam file and just download this part of the data. If that is not possible I would like to ask for the fastest way to achieve this. Worst case would be download the whole file and subset locally but I would like to avoid this.
Best, Bernd
1 answer
bernd:~$ samtools view -h ftp://ftp.1000genomes.ebi.ac.uk/vol1/ftp/phase1/data/HG00154/alignment/HG00154.mapped.ILLUMINA.bwa.GBR.low_coverage.20101123.bam 17:7512445-7513455
[E::hts_open_format] Failed to open file "ftp://ftp.1000genomes.ebi.ac.uk/vol1/ftp/phase1/data/HG00154/alignment/HG00154.mapped.ILLUMINA.bwa.GBR.low_coverage.20101123.bam" : Protocol not supported
samtools view: failed to open "ftp://ftp.1000genomes.ebi.ac.uk/vol1/ftp/phase1/data/HG00154/alignment/HG00154.mapped.ILLUMINA.bwa.GBR.low_coverage.20101123.bam" for reading: Protocol not supported
bernd:~$ samtools --help
Program: samtools (Tools for alignments in the SAM format)
Version: 1.13 (using htslib 1.13+ds)
Usage: samtools <command> [options]
When I try to run the example from their webpage it fails with "Protocol not supported"
Make sure you are using a newer version of samtools. Works with v.1.21 which is the latest. Your samtools is from 2021.
So it looks like it was just the samtools version. Thanks for the hint.
Subsetting a streamed cram file still seems to take a very long time on my end.
I do this: samtools view ftp://ftp.sra.ebi.ac.uk/vol1/run/ERR323/ERR3239482/NA12775.final.cram -r chrX --reference GRCh38_full_analysis_set_plus_decoy_hla.fa
This already runs for roughly 20 minutes. I would assume this should be done in less than 10?
`
wrong parameter.
-r, --read-group STR ...are in read group STR
you want
samtools view ftp://ftp.sra.ebi.ac.uk/vol1/run/ERR323/ERR3239482/NA12775.final.cram chrX --reference GRCh38_full_analysis_set_plus_decoy_hla.fa
use 'https://' instead of 'ftp://'
Log in to answer this question.