Entering edit mode
8.0 years ago
ariel.balter
▴
260
I have a bam file sample.bam
. I would like to create a smaller version for testing my pipeline. I tried this:
samtools view sample.bam > temp.sam
head -1000000 temp.sam > temp1e6.sam
samtools -bT temp1e6.sam > short.bam
Now short.bam looks like:
$ cat short.bam
Usage: samtools view [options] <in.bam>|<in.sam>|<in.cram> [region ...]
Options:
-b output BAM
-C output CRAM (requires -T)
-1 use fast BAM compression (implies -b)
-u uncompressed BAM output (implies -b)
-h include header in SAM output
-H print SAM header only (no alignments)
-c print only the count of matching records
-o FILE output file name [stdout]
-U FILE output reads not selected by filters to FILE [null]
-t FILE FILE listing reference names and lengths (see long help) [null]
-L FILE only include reads overlapping this BED FILE [null]
-r STR only include reads in read group STR [null]
...
...
...
Didn't you miss a samtools
view
in your last command? Can you check if temp.sam and temp1e6.sam look okay? Why the-T
flag?It looks like you are getting the help function from the first samtools view command. Does the first file look OK?
You probably want to add the -h option on to keep the header as well.
Like WouterDeCoster says - looks like you are missing the "view" after samtools on the last command - although would of thought that would give you the samtools help, or an unrecognised -bT, rather than the samtools view help
I think the command he showed us here is different from the one he actually executed, hence the samtools view help info. (Although I'm a bit surprised it went to stdout)