Samtools View - What'S The Purpose Of The -T Option?
1
3
Entering edit mode
12.1 years ago
Applet ▴ 150

Here is what the docs say:

-t FILE This file is TAB-delimited. Each line must contain the reference name and the length of the reference, one line for each distinct reference; additional fields are ignored. This file also defines the order of the reference sequences in sorting. If you run ‘samtools faidx <ref.fa>’, the resultant index file <ref.fa>.fai can be used as this <in.ref_list> file.

I guess that tells me how to use it. But I'm wondering what the purpose is? What do people use this option for exactly? And what does it do?

samtools • 5.2k views
ADD COMMENT
8
Entering edit mode
12.1 years ago
Ryan Dale 5.0k

It's used for when you need to create a BAM out of a SAM, but your SAM file doesn't have a header. BAM files need information about the length of each reference, and this info is stored in the header.

For example, typical conversion of BAM -> SAM might be: [HTML] $ samtools view my.bam > my.sam [HTML] But trying to do the reverse results in an error: [HTML] $ samtools view -S -b my.sam > my.bam [samopen] no @SQ lines in the header. [sam_read1] missing header? Abort! [HTML]

One option is simply to include the header when making the SAM file in the first place: [HTML] $ samtools view -h my.bam > my.sam $ samtools view -S -b my.sam > my.bam.recreated [HTML] But sometimes this simple fix isn't possible (for example, maybe you don't have the original BAM), so the -t option lets you provide the data for the header.

Side note: the -T option lets you provide a FASTA for the same purpose, and the -H option lets you print the header alone from a BAM if you need to make a file for the -t arg.

ADD COMMENT

Login before adding your answer.

Traffic: 3022 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6