Sorry works for me but your command was missing the ftp:// protocol:
samtools view -bh ftp://ftp-mouse.sanger.ac.uk/current_bams/PWK_PhJ.bam chr11 > chr11.bam
It started to happily print the content of the bam file, it is not finished yet, but if I understood correctly, the segfault occurred immediately? I bet there is something wrong with your installation of samtools. How did you build samtools? Get the sysadmin to build the latest version from scratch. My server has 128GB RAM and that is more than sufficient.
Version: 0.1.18 (r982:295)
$ uname -a
Linux mybas 2.6.18-274.18.1.el5 #1 SMP Thu Feb 9 12:45:44 EST 2012 x86_64 x86_64 x86_64 GNU/Linux
Update: process finished without complaints yielding a 5.3GB bam file.
Edit: for the sake of completeness I would like to cross post my solution from samtools-help,
apart from the segfault, there seems to be a slight glitch in the documentation or the program:
I checked a bit more and there are in fact several aspects to this.
- There is a slight discrepancy between the documentation and how it really works. From the documentation:
"A region can be presented, for example, in the following format: ‘chr2’ (the whole chr2)"
a) However, what happens in my version is that the whole bam file is written without filtering, that is
why I have gotten that 5.3GB bam file.
I used this specifier 'chr11:', note extra ':', then my version works as expected. That means in particular
b) for 'chr11:' which is not contained in the original file, a BAM file is created which contains only header lines,
(weird characters)
plus a warning is given on standard error:
[bam_parse_region] fail to determine the sequence name.
[main_samview] region "chr11:" specifies an unknown reference name. Continue anyway.
c) for using '11:' which is actually the only correct way, I get the filtered bam file as output
which are the binary data you pasted below.
Thus the difference between our builds is only that your version crashes when the
sequence name is entered in the 'wrong' format AND the unfiltered BAM file would
be returned without warning in my build.
As a result please try the following commands:
- open the terminal application
- into a new window type:
cd /Users/leandro/Desktop/SAMTOOLS/
./samtools view -bh ftp://ftp-mouse.sanger.ac.uk/current_bams/PWK_PhJ.bam 11: > chr11.bam
you should be able to view the resulting file with:
samtools view chr11.bam
That way, you can check that the chromosome filter actually worked.
Hi Leandro, please add the following information for completeness: the version of samtools, and in a terminal type uname -a and paste the output.