Hi - I am obtaining from a RNA-seq bam file the BCF output from samtools mpileup in order to corroborate variants seen in the exome.

Thus, for corroborating one single SNP, my command looks like this:

```
samtools mpileup -ug -t DP -t DV -t DP4 --min-MQ 40 --min-BQ 35 -f GRCh37.fa --region "22:29907105-29907105" RNAsample.bam  | bcftools view --min-alleles 3

#CHROM    POS    ID    REF    ALT    QUAL    FILTER    INFO    FORMAT    RNAsample
22    29907105    .    G    A,<X>    0    .    DP=47;I16=14,12,6,7,974,36674,484,18098,520,10400,260,5200,488,11274,261,5927;QS=0.666667,0.333333,0;VDB=0.280567;SGB=-0.683931;RPB=0.814533;MQB=1;MQSB=1;BQB=0.956592;MQ0F=0    PL:DP:DV:DP4    82,0,143,160,182,243:39:13:14,12,6,7
```

Because, samtools is always outputting "*an non-ref base 'X' represents an base has not been seen from the alignment data*" I need to filter for minimum 3 alleles (one ref, one alt and the X). I find this all counter-intuitive and would like to omit the non-ref base 'X' in the output from samtools mpileup as in this case it will not be needed for anything.

Does anybody know how to do this properly (excluding sed, awk and the like ;))

EDIT:

The pileup itself for this position looks as follows:

```
$ samtools mpileup -t DP -t DV -t DP4 --min-MQ 40 --min-BQ 35 -f /home/mpschr/bin/bcbionextgen/data/genomes/Hsapiens/GRCh37/seq/GRCh37.fa --region "22:29907105-29907105" RNAsample.bam
22    29907105    G    39    .,...AAA..A,,a,a..a,a,,A..aA,,a,.,..a,.    DDDDDDDDDDDDJFJJEGHIIJJIJJEJDEDDJDJHDDF
```
Ok, after a lot of experimenting I have found a solution with which I am satisfied - I only use the `bcftools view`, since I already did the variant calling, and then pipe it to `bcftools norm`, where norm shortens the representation of the indels and with the option '-m-both' splits up multiple alleles to a line each. 

Thus the command looks like this 

    samtools mpileup -ug -t DP -t DV -t DP4 --min-MQ 40 --min-BQ 35 -f GRCh37.fa --region "22:29907105-29907105" sample.bam | bcftools view | bcftools norm -m-both -f GRCh37.fa

and gives this output:

```
#CHROM    POS    ID    REF    ALT    QUAL    FILTER    INFO    FORMAT    Sample.bam
22    29907105    .    G    A    0    .    DP=95;I16=35,6,18,2,2110,121546,1123,68521,2460,147600,1200,72000,869,19919,428,10158;QS=0.651934,0.348066;VDB=0.12166;SGB=-0.692067;RPB=0.998114;MQB=1;MQSB=1;BQB=0.426273;MQ0F=0    PL:DP:DV:DP4    255,0,255:61:20:35,6,18,2
22    29907105    .    G    <X>    0    .    DP=95;I16=35,6,18,2,2110,121546,1123,68521,2460,147600,1200,72000,869,19919,428,10158;QS=0.651934,0;VDB=0.12166;SGB=-0.692067;RPB=0.998114;MQB=1;MQSB=1;BQB=0.426273;MQ0F=0    PL:DP:DV:DP4    255,255,255:61:20:35,6,18,2
Lines total/modified/skipped:    1/0/0
```

By piping it through `grep -v '<X>'` the non reference bases are removed from the output.

In any case, thanks for all the help Devon