Skip to content

Commit 68ed9b0

Browse files
committed
build with refc
1 parent e065a5f commit 68ed9b0

File tree

3 files changed

+41
-10
lines changed

3 files changed

+41
-10
lines changed

README.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
fast BAM/CRAM depth calculation for **WGS**, **exome**, or **targeted sequencing**.
22
[![install with bioconda](https://img.shields.io/badge/install%20with-bioconda-brightgreen.svg?style=flat-square)](http://bioconda.github.io/recipes/mosdepth/README.html)
33

4-
54
![logo](https://user-images.githubusercontent.com/1739/29678184-da1f384c-88ba-11e7-9d98-df4fe3a59924.png "logo")
65

76
[![Build](https://github.com/brentp/mosdepth/actions/workflows/build.yml/badge.svg)](https://github.com/brentp/mosdepth/actions/workflows/build.yml) [![citation](https://img.shields.io/badge/cite-open%20access-orange.svg)](https://academic.oup.com/bioinformatics/article/doi/10.1093/bioinformatics/btx699/4583630?guestAccessKey=35b55064-4566-4ab3-a769-32916fa1c6e6)
87

8+
> **Note:**
9+
> `mosdepth` must be built with the `--mm:refc` flag for optimal performance and correct operation.
10+
11+
```
12+
13+
914
`mosdepth` can output:
1015
1116
+ per-base depth about 2x as fast `samtools depth`--about 25 minutes of CPU time for a 30X genome.
@@ -23,6 +28,7 @@ when appropriate, the output files are bgzipped and indexed for ease of use.
2328
## usage
2429
2530
```
31+
2632
mosdepth 0.3.11
2733

2834
Usage: mosdepth [options] <prefix> <BAM-or-CRAM>
@@ -63,6 +69,7 @@ Other options:
6369
-m --use-median output median of each region (in --by) instead of mean.
6470
-R --read-groups <string> only calculate depth for these comma-separated read groups IDs.
6571
-h --help show help
72+
6673
```
6774
If you use mosdepth please cite [the publication in bioinformatics](https://academic.oup.com/bioinformatics/article/doi/10.1093/bioinformatics/btx699/4583630?guestAccessKey=35b55064-4566-4ab3-a769-32916fa1c6e6)
6875
@@ -77,7 +84,9 @@ If you don't want this behavior, simply send a bed file with 3 columns.
7784
7885
To calculate the coverage in each exome capture region:
7986
```
87+
8088
mosdepth --by capture.bed sample-output sample.exome.bam
89+
8190
```
8291
For a 5.5GB exome BAM and all 1,195,764 ensembl exons as the regions,
8392
this completes in 1 minute 38 seconds with a single CPU.
@@ -93,7 +102,9 @@ The distribution of depths will go to `sample-output.mosdepth.dist.txt`
93102
For 500-base windows
94103
95104
```
105+
96106
mosdepth -n --fast-mode --by 500 sample.wgs $sample.wgs.cram
107+
97108
```
98109
99110
`-n` means don't output per-base data, this will make `mosdepth`
@@ -108,12 +119,15 @@ improvement.
108119
To create a set of "callable" regions as in [GATK's callable loci tool](https://software.broadinstitute.org/gatk/documentation/tooldocs/current/org_broadinstitute_gatk_tools_walkers_coverage_CallableLoci.php):
109120
110121
```
122+
111123
# by setting these ENV vars, we can control the output labels (4th column)
124+
112125
export MOSDEPTH_Q0=NO_COVERAGE # 0 -- defined by the arguments to --quantize
113126
export MOSDEPTH_Q1=LOW_COVERAGE # 1..4
114127
export MOSDEPTH_Q2=CALLABLE # 5..149
115128
export MOSDEPTH_Q3=HIGH_COVERAGE # 150 ...
116129
mosdepth -n --quantize 0:1:5:150: $sample.quantized $sample.wgs.bam
130+
117131
```
118132
119133
For this case. A regions with depth of 0 are labelled as "NO_COVERAGE", those with
@@ -128,7 +142,9 @@ bin are merged into a single region with the 4th column indicating the label.
128142
To get only the distribution value, without the depth file or the per-base and using 3 threads:
129143
130144
```
145+
131146
MOSDEPTH_PRECISION=5 mosdepth -n -t 3 $sample $bam
147+
132148
```
133149
134150
Output will go to `$sample.mosdepth.dist.txt`
@@ -153,8 +169,10 @@ Another quick way is to [![install with bioconda](https://img.shields.io/badge/i
153169
154170
It can also be installed with `brew` as `brew install brewsci/bio/mosdepth` or used via docker with quay:
155171
```
172+
156173
docker pull quay.io/biocontainers/mosdepth:0.3.3--h37c5b7d_2
157174
docker run -v /hostpath/:/opt/mount quay.io/biocontainers/mosdepth:0.2.4--he527e40_0 mosdepth -n --fast-mode -t 4 --by 1000 /opt/mount/sample /opt/mount/$bam
175+
158176
```
159177
160178
The binary from releases is static, with no dependencies. If you build it yourself,
@@ -211,18 +229,22 @@ more details.
211229
given a set of regions to the `--by` argment, `mosdepth` can report the number of bases in each region that
212230
are covered at or above each threshold value given to `--thresholds`. e.g:
213231
```
232+
214233
mosdepth --by exons.bed --thresholds 1,10,20,30 $prefix $bam
234+
215235
```
216236
217237
will create a file $prefix.thresholds.bed.gz with an extra column for each requested threshold.
218238
An example output for the above command (assuming exons.bed had a 4th column with gene names) would look like (including the header):
219239
220240
```
221-
#chrom start end region 1X 10X 20X 30X
241+
242+
# chrom start end region 1X 10X 20X 30X
222243
1 11869 12227 ENSE00002234944 358 157 110 0
223244
1 11874 12227 ENSE00002269724 353 127 10 0
224245
1 12010 12057 ENSE00001948541 47 8 0 0
225246
1 12613 12721 ENSE00003582793 108 0 0 0
247+
226248
```
227249
228250
If there is no name (4th) column in the bed file send to `--by` then that column will contain "unknown"
@@ -240,7 +262,9 @@ It also allows outputting regions of low, high, and "callable" coverage as in [G
240262
241263
An example of quantize arguments:
242264
```
265+
243266
--quantize 0:1:4:100:200: # ... arbitary number of quantize bins.
267+
244268
```
245269
246270
indicates bins of: 0:1, 1:4, 4:100, 100:200, 200:infinity
@@ -251,10 +275,12 @@ The default for `mosdepth` is to output labels as above (0:1, 1:4, 4:100... etc.
251275
To change what is reported as the bin number, a user can set environment variables e.g.:
252276
253277
```
278+
254279
export MOSDEPTH_Q0=NO_COVERAGE
255280
export MOSDEPTH_Q1=LOW_COVERAGE
256281
export MOSDEPTH_Q2=CALLABLE
257282
export MOSDEPTH_Q3=HIGH_COVERAGE
283+
258284
```
259285
260286
In this case, the bin label is replaced by the text in the appropriate environment variable.

mosdepth.nim

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type
3434
stop*: uint32
3535
name*: string
3636

37-
coverage_t = seq[int32]
37+
coverage_t {.shallow.} = seq[int32]
3838

3939
proc `$`*(r: region_t): string =
4040
if r == nil:
@@ -325,7 +325,7 @@ proc coverage(bam: hts.Bam, arr: var coverage_t, region: var region_t,
325325
last_pos = p.pos
326326
if pair_depth != 0: echo $rec.qname & ":" & $rec & " " &
327327
$mate.qname & ":" & $mate & " " & $pair_depth
328-
328+
329329
if fast_mode:
330330
arr[rec.start] += 1
331331
arr[rec.stop] -= 1
@@ -334,11 +334,11 @@ proc coverage(bam: hts.Bam, arr: var coverage_t, region: var region_t,
334334
# only count read1 from proper pairs
335335
if rec.flag.read2 or (not rec.flag.proper_pair) or rec.flag.supplementary:
336336
continue
337-
337+
338338
var fragment_start = min(rec.start, rec.matepos)
339339
arr[fragment_start] += 1
340340
arr[fragment_start + abs(rec.isize)] -= 1
341-
341+
342342
else:
343343
inc_coverage(rec.cigar, rec.start.int, arr)
344344

@@ -574,7 +574,9 @@ proc to_tuples(targets: seq[Target]): seq[tuple[name: string, length: int]] =
574574
result[i] = (t.name, t.length.int)
575575

576576
proc main(bam: hts.Bam, chrom: region_t, mapq: int, min_len: int, max_len: int, eflag: uint16, iflag: uint16, region: string, thresholds: seq[int],
577-
fast_mode: bool, args: Table[string, docopt.Value], use_median: bool = false, fragment_mode: bool = false, use_d4: bool = false) =
577+
fast_mode: bool, args: Table[string, docopt.Value],
578+
use_median: bool = false, fragment_mode: bool = false,
579+
use_d4: bool = false) =
578580
# windows are either from regions, or fixed-length windows.
579581
# we assume the input is sorted by chrom.
580582
var
@@ -686,7 +688,8 @@ proc main(bam: hts.Bam, chrom: region_t, mapq: int, min_len: int, max_len: int,
686688
continue
687689
rchrom = region_t(chrom: target.name)
688690
var tid = coverage(bam, arr, rchrom, targets, mapq, min_len, max_len, eflag,
689-
iflag, read_groups = read_groups, fast_mode = fast_mode, fragment_mode = fragment_mode,
691+
iflag, read_groups = read_groups, fast_mode = fast_mode,
692+
fragment_mode = fragment_mode,
690693
last_tid = last_tid)
691694
if tid == -1: continue # -1 means that chrom is not even in the bam
692695
if tid != -2: # -2 means there were no reads in the bam
@@ -964,5 +967,6 @@ Other options:
964967
check_chrom(chrom, bam.hdr.targets)
965968

966969
main(bam, chrom, mapq, min_len, max_len, eflag, iflag, region, thresholds,
967-
fast_mode, args, use_median = use_median, fragment_mode = fragment_mode, use_d4 = use_d4)
968-
970+
fast_mode, args, use_median = use_median, fragment_mode = fragment_mode,
971+
use_d4 = use_d4)
972+

nim.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# in htslib: ./configure --with-libdeflate --disable-libcurl
22
# nim c -a -d:static -d:release mosdepth.nim
3+
mm:refc
34
@if static:
45
passC:"-static"
56
passl:"-static"

0 commit comments

Comments
 (0)