{"id":32589286,"url":"https://github.com/telatin/covtobed","last_synced_at":"2026-02-26T05:54:15.804Z","repository":{"id":109729228,"uuid":"226902217","full_name":"telatin/covtobed","owner":"telatin","description":"⛰ covtobed | Convert the coverage track from a BAM file into a BED file","archived":false,"fork":false,"pushed_at":"2025-11-06T11:54:33.000Z","size":50463,"stargazers_count":44,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-11T19:57:01.055Z","etag":null,"topics":["alignments","bam-files","bed","bioconda","bioinformatics","bioinformatics-tool","sequence-coverage"],"latest_commit_sha":null,"homepage":"","language":"Makefile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/telatin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-12-09T15:18:58.000Z","updated_at":"2025-09-09T09:14:05.000Z","dependencies_parsed_at":"2025-07-08T01:55:58.747Z","dependency_job_id":null,"html_url":"https://github.com/telatin/covtobed","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/telatin/covtobed","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telatin%2Fcovtobed","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telatin%2Fcovtobed/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telatin%2Fcovtobed/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telatin%2Fcovtobed/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/telatin","download_url":"https://codeload.github.com/telatin/covtobed/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telatin%2Fcovtobed/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29849811,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-25T22:37:40.667Z","status":"online","status_checked_at":"2026-02-26T02:00:06.774Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alignments","bam-files","bed","bioconda","bioinformatics","bioinformatics-tool","sequence-coverage"],"created_at":"2025-10-30T00:54:13.912Z","updated_at":"2026-02-26T05:54:15.799Z","avatar_url":"https://github.com/telatin.png","language":"Makefile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# covtobed\n\n\n[![install with bioconda](https://img.shields.io/conda/vn/bioconda/covtobed?label=install%20from%20bioconda)](http://bioconda.github.io/recipes/covtobed/README.html)\n[![Bioconda installs](https://img.shields.io/conda/dn/bioconda/covtobed)](https://anaconda.org/bioconda/covtobed)\n[![covtobed](https://github.com/telatin/covtobed/actions/workflows/c-cpp.yml/badge.svg)](https://github.com/telatin/covtobed/actions/workflows/c-cpp.yml)\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/36944efb0d2b44cca850964e96c036a4)](https://www.codacy.com/manual/telatin/covtobed?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=telatin/covtobed\u0026amp;utm_campaign=Badge_Grade)\n\n[![status](https://joss.theoj.org/papers/0ed74df9f40a58a852bf3fff512acd2b/status.svg)](https://joss.theoj.org/papers/0ed74df9f40a58a852bf3fff512acd2b)\n[![License](https://img.shields.io/github/license/telatin/covtobed?color=blue)](https://github.com/telatin/covtobed/blob/master/LICENSE)\n\n### a tool to generate BED coverage tracks from BAM files\n\nReads one (or more) [alignment](https://en.wikipedia.org/wiki/Sequence_alignment) files\n(sorted [BAM](https://en.wikipedia.org/wiki/SAM_(file_format))) and prints a [BED](https://en.wikipedia.org/wiki/BED_(file_format)) with the [coverage](https://en.wikipedia.org/wiki/Coverage_(genetics)). It will join consecutive bases with the same coverage, and can be used to only print a BED file with the regions having a specific coverage range. \n\n:book:  **[Read more in the wiki](https://github.com/telatin/covtobed/wiki)** - this is the **main** documentation source\n\nFeatures:\n* Can read (sorted) BAMs from stream (like `bwa mem .. | samtools view -b | samtools sort - | covtobed`)\n* Can print _strand specific_ coverage to check for strand imbalance\n* Can print the _physical coverage_ (with paired-end or mate-paired libraries)\n\n:information_source: For more features, check the [**BamToCov**](https://github.com/telatin/bamtocov) suite.\n\n[![covtobed example](img/covtobed-vignette.png)](https://github.com/telatin/covtobed/wiki)\n\n\n## Usage\n\n:book: **The complete documentation is available in the [GitHub wiki](https://github.com/telatin/covtobed/wiki).**\n\nSynopsis:\n```\nUsage: covtobed [options] [BAM]...\n\nComputes coverage from alignments\n\nOptions:\n  -h, --help            show this help message and exit\n  --version             show program's version number and exit\n  --physical-coverage   compute physical coverage (needs paired alignments in input)\n  -q MINQ, --min-mapq=MINQ\n                        skip alignments whose mapping quality is less than MINQ\n                        (default: 0)\n  -m MINCOV, --min-cov=MINCOV\n                        print BED feature only if the coverage is bigger than\n                        (or equal to) MINCOV (default: 0)\n  -x MAXCOV, --max-cov=MAXCOV\n                        print BED feature only if the coverage is lower than\n                        MAXCOV (default: 100000)\n  -l MINLEN, --min-len=MINLEN\n                        print BED feature only if its length is bigger (or equal\n                        to) than MINLELN (default: 1)\n  -z MINCTG, --min-ctg-len=MINCTG\n                        skip reference sequences having size less or equal to MINCTG\n  -d, --discard-invalid-alignments\n                        skip duplicates, failed QC, and non primary alignment,\n                        minq\u003e0 (or user-defined if higher) (default: enabled)\n  --keep-invalid-alignments\n                        Keep duplicates, failed QC, and non primary alignment,\n                        min=0 (or user-defined if higher) - reverts to legacy behavior\n  --output-strands      output coverage and stats separately for each strand\n  --format=CHOICE       output format\n```\n## Example\n\nCommand (with new default filtering):\n```\ncovtobed -m 0 -x 5 test/demo.bam\n```\n\nTo use legacy behavior (no filtering):\n```\ncovtobed --keep-invalid-alignments -m 0 -x 5 test/demo.bam\n```\nOutput:\n```text\n[...]\nNC_001416.1     0       2       0\nNC_001416.1     2       6       1\nNC_001416.1     6       7       2\nNC_001416.1     7       12      3\nNC_001416.1     12      18      4\nNC_001416.1     169     170     4\nNC_001416.1     201     206     4\n[...]\n```\n\nSee the full example output from different tools [:open_file_folder: here](https://github.com/telatin/covtobed/blob/master/test/output/README.md)\n\n## Install\n\n* To install with Miniconda:\n\n```bash\nconda install -c bioconda covtobed\n```\n\n* Both **covtobed**, and the legacy program [**coverage**](https://github.com/telatin/covtobed/wiki/Using-coverage) are available as a single Docker container available from Docker Hub [![Docker build](https://img.shields.io/docker/cloud/build/andreatelatin/covtobed)](https://hub.docker.com/r/andreatelatin/covtobed):\n\n```bash\nsudo docker pull andreatelatin/covtobed\nsudo docker run --rm -ti andreatelatin/covtobed coverage -h\n```\n\n * Download Singularity image by `singularity pull docker://andreatelatin/covtobed`, then:\n\n```bash\nsingularity exec covtobed.simg coverage -h\n```\n\n## Important Changes in v1.4.0\n\n**Default Behavior Change**: Starting with version 1.4.0, `covtobed` now **filters invalid alignments by default** (duplicates, failed QC, non-primary alignments). This provides higher quality results out of the box.\n\n- **New default**: Invalid alignments are discarded (equivalent to using `--discard-invalid-alignments`)\n- **Legacy behavior**: Use `--keep-invalid-alignments` to revert to the old behavior\n- **Conflicting flags**: Using both `--discard-invalid-alignments` and `--keep-invalid-alignments` will result in an error\n\n## Startup message\n\nWhen invoked without arguments, covtobed will print a message to inform the user that it\nis waiting for input from STDIN.\nTo suppress this message, set the environment variable `COVTOBED_QUIET` to `1`.\n\n## Performance\n\n*covtobed* is generally faster than *bedtools*. More details are in the [benchmark](benchmark) page.\n\n## Requirements and compiling\n\nThis tool requires **libbamtools** and **zlib**.\n\nTo manually compile:\n```\nc++ -std=c++17 *.cpp -I/path/to/bamtools/ -L${HOME}/path/to/lib/ -lbamtools -o covtobed\n```\n\n## Issues, Limitations and how to contribute\n\n* This program will read the coverage from *sorted BAM* files. The *CRAM* format is not supported at the moment.\n* If you find a problem feel free to [raise an issue](https://github.com/telatin/covtobed/issues), we will try to address it as soon as possible\n* [Contributions](CONTRIBUTING.md) are welcome via PR.\n\n## Acknowledgements\n\nThis tools uses [libbamtools](https://github.com/pezmaster31/bamtools) by Derek Barnett, Erik Garrison, Gabor Marth and Michael Stromberg, and [cpp-optparse](https://github.com/weisslj/cpp-optparse) by Johannes Weißl. Both tools and this program are released with MIT license.\n\n## Authors\n\nGiovanni Birolo ([@gbirolo](https://github.com/gbirolo)), University of Turin, and Andrea Telatin ([@telatin](https://github.com/telatin)), Quadram Institute Bioscience. \n\nThis program was finalized with a Flexible Talent Mobility Award funded by BBSRC through the [Quadram Institute](https://quadram.ac.uk).\n\n## Citation\n\nIf you use this tool, we would really appreciate if you will cite its paper:\n\nReleases after 1.3 (inclusive):\n\n\u003e Giovanni Birolo, Andrea Telatin, \n[BamToCov: an efficient toolkit for sequence coverage calculations](https://academic.oup.com/bioinformatics/advance-article/doi/10.1093/bioinformatics/btac125/6535233), Bioinformatics, 2022\n\nReleases up to 1.2:\n\n\u003e Birolo et al., (2020). covtobed: a simple and fast tool to extract coverage tracks from BAM files. Journal of Open Source Software, 5(47), 2119, https://doi.org/10.21105/joss.02119\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelatin%2Fcovtobed","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftelatin%2Fcovtobed","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelatin%2Fcovtobed/lists"}