samtools tview type consensus sequence to stdout
1
1
Entering edit mode
6.5 years ago
timmak ▴ 10

Hi,

I found samtools tview quite amazing in that on the third line from the top, it produces a kind of consensus sequence using only what's available in the sorted .bam file. It does not require a reference sequence, and moreover, can identify regions with variation and mark these accordingly (e.g. with the appropriate nucleic acid notation such as Y, K, R, etc.). However, it's designed for interactive use and not so useful for batch queries.

Are there tools out there that can give me a consensus sequence for a particular region that is command-line friendly (i.e output to stdout)? I know samtools tview has a -d T option, but it only outputs 80 columns or so.

I have tried bcftools consensus and GATK FastaAlternateReferenceMaker but these tend to only give one consensus sequence masking the variation that may exist.

Many thanks for your help,

Tim

samtools sequencing • 2.3k views
ADD COMMENT
2
Entering edit mode
6.5 years ago

I know samtools tview has a -d T option, but it only outputs 80 columns or so.

you can override the ${COLUMNS} shell's variable.

$ COLUMNS=1000  samtools tview -d T in.bam

but beware for the memory required to print a large matrix.

ADD COMMENT
0
Entering edit mode

samtools apparently resets the COLUMNS variable to 110 every time I run it. Which version are you using? I tried both 1.3.1 and 1.6, and it's the same.

$ COLUMNS=1000
[statgenpro ~/WORK/DCM/For Carol]
$ echo $COLUMNS
1000
[statgenpro ~/WORK/DCM/For Carol]
$ $samtoolsdir/samtools tview -p chr14:23898059 -d T $dir/$samp.sorted.dedup.realign.recal.bam | sed -n '3p'
CCACTGCCTTCCCATGTCTGGTCCACAGCTGGCTCTAAGCAAATAGCTGTTGAATGTGGGAGCGAGTGAGTGATTGTTCT
[statgenpro ~/WORK/DCM/For Carol]
$ echo $COLUMNS
110
ADD REPLY
0
Entering edit mode

this is not my cmd-line: I redefine/override COLUMNS each time I run samtools:

 $ COLUMNS=1000  samtools tview -d  ...
ADD REPLY
0
Entering edit mode

Thanks! That worked.

ADD REPLY

Login before adding your answer.

Traffic: 2566 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