| samtools-cat(1) | Bioinformatics tools | samtools-cat(1) |
samtools-cat - concatenate files together
samtools cat [-b list] [-h header.sam] [-o out.bam] in1.bam in2.bam [ ... ]
Concatenate BAMs or CRAMs. Although this works on either BAM or CRAM, all input files must be the same format as each other. The sequence dictionary of each input file must be identical, although this command does not check this. This command uses a similar trick to reheader which enables fast BAM concatenation.
Note this works in conjunction with the -r RANGE option, in which case the 3rd and 4th columns become useful for identifying which containers span the requested range.
If the range is of the form "#:start-end" then the start and end coordinates are interpreted as inclusive CRAM container numbers, starting at 0 and ending 1 less than the number of containers reported by -q. For example -r "#:0-9" is the first 10 CRAM containers of data.
All range types filter data in as fast a manner as possible, using operating system read/write loops where appropriate.
This can also be combined with the range option above to operate of parts of that range. For example -r chr2 -p 1/10 returns the first 1/10th of data aligned against chromosome 2.
samtools cat -o chr10.cram -r chr10 in.cram
set -- $(samtools cat -q in.cram); nc=$2; s=0 while [ $s -lt $nc ] do
e=`expr $s + 123`
if [ $e -ge $nc ]
then
e=$nc
fi
r="$s-`expr $e - 1`"; echo $r
fn=/tmp/_part-`printf "%08d" $s`.cram
samtools cat -o $fn in.cram -r "#:$r"
s=$e done
for i in `seq 1 10` do
samtools cat in.cram -r "*" -p $i/10 -o part-`printf "%02d" $i`.cram done
Written by Heng Li from the Sanger Institute. Updated for CRAM by James Bonfield (also Sanger Institute).
Samtools website: <http://www.htslib.org/>
| 12 September 2024 | samtools-1.21 |