brentp/combined-pvalues — Issue #2: sidak correction in region simulations.
Author: brentp
Created: 2011-11-02 18:45:31+00:00
State: open

There is no multiple-testing correction on the p-values for the regions.
rpsim can do the sidak correction correctly because it knows
the entire region length (sum of coverage in -p argument)

so sidak is

```
sidak_p = 1-(1 - p)^k
```

where k is the number of possible regions of that length:

```
k = total_coverage_bp / region_length_bp
```
total_coverage_bp is the total number of bases covered by region to -p.
region_length_bp is simply the `end - start` for the region.
Probably do this as:

```python
coverage = collections.defaultdict(set)

for chrom, start, end in regions:
coverage[chrom].update(range(start, end))

total_coverage_bp = sum(len(rset) for rset in coverage.itervalues())
```

Since they are sorted, can also use less memory using groupby on chrom
and calculating the coverage per-chrom...