samtools/samtools — pull request #140 by lindenb (2014-02-11 18:01:50+00:00)
Title: Streamstatsbasic

Hi,
I added some new features to `samtools flagstat`.

(Same push request as https://github.com/samtools/samtools/pull/115 but I removed the two formats as requested by @vsbuffalo and @peterjc )

- setting the qual for diffchrhigh
- more that one BAM file
- ouput name for report. If set, one use pipelining

## Examples:

## standard
```
$ curl -s "ftp://ftp.1000genomes.ebi.ac.uk/vol1/ftp/phase1/data/NA12273/alignment/NA12273.mapped.ILLUMINA.bwa.CEU.low_coverage.20101123.bam" |
./samtools view -h - | head -n 10000 |
./samtools view -Sb - |
./samtools flagstat -

File: -
9907 + 0 in total (QC-passed reads + QC-failed reads)
661 + 0 duplicates
9523 + 0 mapped (96.12%:-nan%)
9874 + 0 paired in sequencing
4903 + 0 read1
4971 + 0 read2
8135 + 0 properly paired (82.39%:-nan%)
9106 + 0 with itself and mate mapped
384 + 0 singletons (3.89%:-nan%)
804 + 0 with mate mapped to a different chr
345 + 0 with mate mapped to a different chr (mapQ>=5)
```
## Streaming
```
$ curl -s "ftp://ftp.1000genomes.ebi.ac.uk/vol1/ftp/phase1/data/NA12273/alignment/NA12273.mapped.ILLUMINA.bwa.CEU.low_coverage.20101123.bam" |
./samtools view -h - | head -n 10000 |
./samtools view -Sb - | ./samtools flagstat -s -o report1.txt - |
./samtools view -b -f4 - | ./samtools flagstat -o report2.txt -
```

```
$ cat report1.txt report2.txt
File: -
9907 + 0 in total (QC-passed reads + QC-failed reads)
661 + 0 duplicates
9523 + 0 mapped (96.12%:-nan%)
9874 + 0 paired in sequencing
4903 + 0 read1
4971 + 0 read2
8135 + 0 properly paired (82.39%:-nan%)
9106 + 0 with itself and mate mapped
384 + 0 singletons (3.89%:-nan%)
804 + 0 with mate mapped to a different chr
345 + 0 with mate mapped to a different chr (mapQ>=5)

File: -
384 + 0 in total (QC-passed reads + QC-failed reads)
0 + 0 duplicates
0 + 0 mapped (0.00%:-nan%)
384 + 0 paired in sequencing
89 + 0 read1
295 + 0 read2
0 + 0 properly paired (0.00%:-nan%)
0 + 0 with itself and mate mapped
0 + 0 singletons (0.00%:-nan%)
0 + 0 with mate mapped to a different chr
0 + 0 with mate mapped to a different chr (mapQ>=5)
```

## multiple bam
```
$ ./samtools flagstat /home/lindenb/samtools-0.1.18/examples/ex1a.bam /home/lindenb/samtools-0.1.18/examples/toy.bam

File: /home/lindenb/samtools-0.1.18/examples/ex1a.bam
3307 + 0 in total (QC-passed reads + QC-failed reads)
0 + 0 duplicates
3271 + 0 mapped (98.91%:-nan%)
3307 + 0 paired in sequencing
1654 + 0 read1
1653 + 0 read2
3144 + 0 properly paired (95.07%:-nan%)
3144 + 0 with itself and mate mapped
127 + 0 singletons (3.84%:-nan%)
0 + 0 with mate mapped to a different chr
0 + 0 with mate mapped to a different chr (mapQ>=5)

File: /home/lindenb/samtools-0.1.18/examples/toy.bam
12 + 0 in total (QC-passed reads + QC-failed reads)
0 + 0 duplicates
12 + 0 mapped (100.00%:-nan%)
2 + 0 paired in sequencing
1 + 0 read1
1 + 0 read2
2 + 0 properly paired (100.00%:-nan%)
2 + 0 with itself and mate mapped
0 + 0 singletons (0.00%:-nan%)
0 + 0 with mate mapped to a different chr
0 + 0 with mate mapped to a different chr (mapQ>=5)
```

Pierre