This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Imitate Pileup Format

Hi, I am fixing a script that uses an older version of samtools. I just want to fix the system calls to samtools. In the script, they call samtools pileup, which produces this format (first 50 lines below). How do I imitate the output with samtools mpileup? The original command was

samtools pileup -cf tmp.fasta tmp.sorted.bam

Thank you!

1  1   A  N      0    0    0   17  ^W,^W.^W,^W.^W.^W.^W.^W,^W.^W,^W.^W.^W.^W.^W,^W.^W.                    !!!!!!!!!!!!!!!!!
1  2   C  C      39   0    54  17  ,.,....,.,....,..                                                      !!11!5!!!!!!!/!!!
1  3   A  A      39   0    54  17  ,.,....,.,....,..                                                      !!==!>!!!!!!!=!!!
1  4   T  T      39   0    54  17  ,.,....,.,....,..                                                      !!AA!A!!!!!!!A!!!
1  5   T  T      42   0    54  18  ,.,....,.,....,..^W.                                                   !!IH!I!!!!!!!I!!!E
1  6   C  C      42   0    54  18  ,.,....,.,....,...                                                     !!HH!I!!!!!!!I!!!I
1  7   T  T      42   0    54  18  ,.,....,.,....,...                                                     !!GH!I!!!!!!!I!!!I
1  8   T  T      42   0    54  18  ,.,....,.,....,...                                                     !!HH!I!!!!!!!I!!!I
1  9   T  T      42   0    54  18  ,.,....,.,....,...                                                     !!IH!I!!!!!!!I!!!I
1  10  G  G      42   0    54  18  ,.,....,.,....,...                                                     !!IH!I!!!!!!!I!!!I
1  11  T  T      45   0    54  19  ,.,....,.,....,...^W.                                                  !!IH!I!!!!!!!I!!!IE
1  12  A  A      45   0    54  19  ,.,....,.,....,....                                                    !!HH!I!!!!!!!I!!!II
1  13  A  A      48   0    54  20  ,.,....,.,....,....^W.                                                 !!IH!I!!!!!!!I!!!IIE
1  14  T  T      48   0    54  20  ,.,....,.,....,.....                                                   !!IH!I!!!!!!!I!!!III
1  15  A  A      51   0    54  21  ,.,....,.,....,.....^W,                                                !!IH!I!!!!!!!I!!!IIID
1  16  T  T      54   0    54  22  ,.,....,.,....,.....,^W,                                               !!IH!I!!!!!!!H!!!IIIIE
1  17  G  G      54   0    54  22  ,.,....,.,....,.....,,                                                 !!IH!I!!!!!!!G!!!IIIII
1  18  A  A      54   0    54  22  ,.,....,.,....,.....,,                                                 !!IH!I!!!!!!!I!!!IIIII
1  19  A  A      57   0    54  23  ,.,....,.,....,.....,,^W.                                              !!IH!H!!!!!!!I!!!IIIII>
1  20  A  A      57   0    54  23  ,.,....,.,....,.....,,.                                                !!IH!H!!!!!!!I!!!IIIII>
1  21  G  G      57   0    54  23  ,.,....,.,....,.....,,.                                                !!IH!I!!!!!!!I!!!IIIIII
1  22  A  A      60   0    54  24  ,.,....,.,....,.....,,.^W,                                             !!IH!B!!!!!!!I!!!IIIIIIE
1  23  T  T      60   0    54  24  ,.,....,.,....,.....,,.,                                               !!IH!I!!!!!!!I!!!IIIHIII
1  24  T  T      60   0    54  24  ,.,....,.,....,.....,,.,                                               !!IH!I!!!!!!!I!!!IIIIIII
1  25  G  G      60   0    54  24  ,.,....,.,....,.....,,.,                                               !!IH!I!!!!!!!G!!!IIIIIII
1  26  T  T      63   0    54  25  ,.,....,.,....,.....,,.,^W.                                            !!IH!I!!!!!!!I!!!IIIIIII
1  27  G  G      66   0    54  26  ,.,....$,.,....,.....,,.,.^W.                                          !!IH!I!!!!!!!I!!!IIIIIII
1  28  A  A      66   0    54  25  ,.,...,.,....,$..$...,,.,..                                            !!IH!I!!!!!!I!!!IIIIIIII
1  29  A  A      66   0    54  23  ,.,...,.,........,,.,..                                                !!IG!I!!!!!!D!IIIIIIIII
1  30  G  G      66   0    54  23  ,+1t.,+1t...,+1t.,+1t...$.....,+1t,+1t.,+1t..                          !!IH!G!!!!!!H!IIIIIIIII
1  30  *  +T/+T  107  799  54  23  +T                                                                     *
samtools mpileup pileup

I don't find your question clear. What do you mean by 'imitate'?

I would like to run "samtools mpileup" instead of "samtools pileup." However, the output format differs. My question is, how can I use mpileup options to generate the same format?

Maybe there are options in the other tools like bcftools or vcfutils.pl to generate this format.

1 answer

I think the best option is to build an old version of samtools that has pileup still function.

From the samtools repository on github:

Beta Release 0.1.17 (6 July, 2011)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

With the maturity of `mpileup' and the lack of update in the `pileup' command,
the `pileup' command is now formally dropped. Most of the pileup functionality,
such as outputting mapping quality and read positions, have been added
`mpileup'.

I would, therefore, suggest that you download and install version 0.1.16 then generate your pileup from that.

this is actually a great solution - one that is obvious once stated - but easily overlooked while looking for an answer

Annoying, but true. I will try this when I get into work tomorrow (yay for Labor Day!)

Log in to answer this question.