Question: Samtools View - What'S The Purpose Of The -T Option?
3
gravatar for Applet
7.4 years ago by
Applet130
Applet130 wrote:

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 • 3.6k views
ADD COMMENTlink written 7.4 years ago by Applet130
8
gravatar for Ryan Dale
7.4 years ago by
Ryan Dale4.8k
Bethesda, MD
Ryan Dale4.8k wrote:

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 COMMENTlink written 7.4 years ago by Ryan Dale4.8k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1598 users visited in the last hour