# running a samtools command for multiple bam files from 1000 genomes project

I want to compute the depth of coverage only for specific intervals in phase 3, 1000 genomes project.I have not worked with 1000 genomes project before, so a bit unfamiliar with it. I do not want to download all of the bam files for the entire genomic region, just those intervals which I am interested in them. I guess I can use this (I found from biostars forum)

samtools -bu view 'http://ftp.1000genomes.ebi.ac.uk/vol1/ftp/phase3/data/HG01375/alignment/HG01375.mapped.ILLUMINA.bwa.CLM.low_coverage.20120522.bam' "2:1000000-2000000" | (...)


However, I am just a bit confused. First of all, when I try the code above directly from the command line, I get an error message "No such file or directory"! Am I doing something wrong? or should I provide a specific path? Second, I want to run it for the mapped files for all individuals: *.bam”. through a loop.

Can anyone help me to solve my problem?

The command you're looking for is:

samtools view -c http://ftp.1000genomes.ebi.ac.uk/vol1/ftp/phase3/data/HG01375/alignment/HG01375.mapped.ILLUMINA.bwa.CLM.low_coverage.20120522.bam 2:1000000-2000000


For a series of intervals, you'd be better off scripting something with pysam:

import pysam
bam = pysam.AlignmentFile("some file.bam")

• You can do for loops in bash. It can be pretty painful to script anything complicated in bash, though. Apr 23 '18 at 21:20