{"id":31913475,"url":"https://github.com/alejandrogzi/bed2gtf","last_synced_at":"2025-10-13T18:50:15.597Z","repository":{"id":185760294,"uuid":"674060870","full_name":"alejandrogzi/bed2gtf","owner":"alejandrogzi","description":"high-performance BED-to-GTF converter written in Rust","archived":false,"fork":false,"pushed_at":"2024-11-20T14:01:44.000Z","size":169,"stargazers_count":15,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-09T03:12:23.139Z","etag":null,"topics":["bed","bioinformatics","gene-annotation","genes","genome-annotation","gtf"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/alejandrogzi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-08-03T03:56:56.000Z","updated_at":"2025-04-16T02:38:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"2e656b45-bb32-485b-9b57-d07e6053e05c","html_url":"https://github.com/alejandrogzi/bed2gtf","commit_stats":null,"previous_names":["alejandrogzi/bed2gtf"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/alejandrogzi/bed2gtf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alejandrogzi%2Fbed2gtf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alejandrogzi%2Fbed2gtf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alejandrogzi%2Fbed2gtf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alejandrogzi%2Fbed2gtf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alejandrogzi","download_url":"https://codeload.github.com/alejandrogzi/bed2gtf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alejandrogzi%2Fbed2gtf/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279016623,"owners_count":26085853,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"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":["bed","bioinformatics","gene-annotation","genes","genome-annotation","gtf"],"created_at":"2025-10-13T18:49:33.557Z","updated_at":"2025-10-13T18:50:15.591Z","avatar_url":"https://github.com/alejandrogzi.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ch1 align=\"center\"\u003e\n  bed2gtf\n  \u003c/h1\u003e\n\n  \u003cp align=\"center\"\u003e\n    \u003ca href=\"https://img.shields.io/badge/version-0.1.0dev-green\" target=\"_blank\"\u003e\n      \u003cimg alt=\"Version Badge\" src=\"https://img.shields.io/badge/version-1.9.3-green\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://crates.io/crates/gxf2bed\" target=\"_blank\"\u003e\n      \u003cimg alt=\"Crates.io Version\" src=\"https://img.shields.io/crates/v/bed2gtf?color=green\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/alejandrogzi/gxf2bed\" target=\"_blank\"\u003e\n      \u003cimg alt=\"GitHub License\" src=\"https://img.shields.io/github/license/alejandrogzi/bed2gtf?color=blue\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://crates.io/crates/gxf2bed\" target=\"_blank\"\u003e\n      \u003cimg alt=\"Crates.io Total Downloads\" src=\"https://img.shields.io/crates/d/bed2gtf\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://anaconda.org/bioconda/gxf2bed\" target=\"_blank\"\u003e\n      \u003cimg alt=\"Conda Platform\" src=\"https://img.shields.io/conda/pn/bioconda/bed2gtf\"\u003e\n    \u003c/a\u003e\n  \u003c/p\u003e\n\n\n  \u003cp align=\"center\"\u003e\n    A high-performance bed-to-gtf converter written in Rust.\n\n    // translates\n\n    chr27 17266469 17281218 ENST00000541931.8 1000 + 17266469 17281218 0,0,200 2 103,74, 0,14675,\n\n    // into\n\n    chr27 bed2gtf gene 17266470 17285418 . + . gene_id \"ENSG00000151743\";\n\n    chr27 bed2gtf transcript 17266470 17281218 . + . gene_id \"ENSG00000151743\"; transcript_id \"ENST00000541931.8\";\n\n    chr27 bed2gtf exon 17266470 17266572 . + . gene_id \"ENSG00000151743\"; transcript_id \"ENST00000541931.8\"; exon_number \"1\"; exon_id \"ENST00000541931.8.1\";\n\n    ...\n  \u003c/p\u003e\n\n\u003c/p\u003e\n\n\nConverts\n- *Homo sapiens* GRCh38 GENCODE 44 (252,835 transcripts) in 3.25 seconds.\n- *Mus musculus* GRCm39 GENCODE 44 (149,547 transcritps) in 1.99 seconds.\n- *Canis lupus familiaris* ROS_Cfam_1.0 Ensembl 110 (55,335 transcripts) in 1.20 seconds.\n- *Gallus galus* bGalGal1 Ensembl 110 (72,689 transcripts) in 1.36 seconds.\n\n\u003e What's new on v.1.9.3\n\u003e\n\u003e - Fixes a bug with .gz decoder\n\u003e - Implements reading .bed.gz files!\n\u003e - Fixes bug described in issue #11 with versioning\n\n## Usage\n``` rust\nUsage: bed2gtf[EXE] --bed/-b \u003cBED\u003e --isoforms/-i \u003cISOFORMS\u003e --output/-o \u003cOUTPUT\u003e\n\nArguments:\n    -b, --bed \u003cBED\u003e: a .bed file\n    -i, --isoforms \u003cISOFORMS\u003e: a tab-delimited file\n    -o, --output \u003cOUTPUT\u003e: path to output file\n    -g, --gz[=\u003cFLAG\u003e]          Compress output file [default: false] [possible values: true, false]\n    -n, --no-gene[=\u003cFLAG\u003e]     Flag to disable gene_id feature [default: false] [possible values: true, false]\n\nOptions:\n    --help: print help\n    --version: print version\n    --threads/-t: number of threads (default: max ncpus)\n    --gz: compress output .gtf\n```\n\n\u003e [!WARNING]\n\u003e\n\u003e All the transcripts in .bed file should appear in the isoforms file.\n\n\n\u003e [!TIP]\n\u003e\n\u003e Here are some commands to get you started:\n\u003e ```bash\n\u003e # convert a .bed file to .gtf (if you have an isoforms file [gene -\u003e transcript names] and want gene_ids in the output .gtf)\n\u003e bed2gtf -b file.bed -i isoforms.txt -o file.gtf\n\u003e\n\u003e # convert a ,.bed file to .gtf without isoforms [same things as UCSC bedToGtf]\n\u003e bed2gtf -b file.bed -o file.gtf --no-gene\n\u003e\n\u003e # convert a .bed.gz file to a .gtf [with or without isoforms]\n\u003e bed2gtf -b file.bed.gz -i isoforms.txt -o file.gtf --gz\n\u003e bed2gtf -b file.bed.gz -o file.gtf --gz --no-gene\n\u003e\n\u003e # convert a .bed.gz to a .gtf.gz [with or without isoforms]\n\u003e bed2gtf -b file.bed.gz -i isoforms.txt -o file.gtf --gz\n\u003e bed2gtf -b file.bed.gz -o file.gtf --gz --no-gene\n\u003e\n\n#### crate: [https://crates.io/crates/bed2gtf](https://crates.io/crates/bed2gtf)\n\n\u003cdetails\u003e\n\u003csummary\u003eclick for detailed formats\u003c/summary\u003e\n\u003cp\u003e\nbed2gtf just needs two files:\n\n1. a .bed file\n\n    tab-delimited files with 3 required and 9 optional fields:\n\n    ```\n    chrom   chromStart  chromEnd      name    ...\n      |         |           |           |\n    chr20   50222035    50222038    ENST00000595977    ...\n    ```\n\n    see [BED format](https://genome.ucsc.edu/FAQ/FAQformat.html#format1) for more information\n\n2. a tab-delimited .txt/.tsv/.csv/... file with genes/isoforms (all the transcripts in .bed file should appear in the isoforms file):\n\n    ```\n    \u003e cat isoforms.txt\n\n    ENSG00000198888 ENST00000361390\n    ENSG00000198763 ENST00000361453\n    ENSG00000198804 ENST00000361624\n    ENSG00000188868 ENST00000595977\n    ```\n\n    you can build a custom file for your preferred species using [Ensembl BioMart](https://www.ensembl.org/biomart/martview).\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n## Installation\nto install bed2gtf on your system follow this steps:\n1. get rust: `curl https://sh.rustup.rs -sSf | sh` on unix, or go [here](https://www.rust-lang.org/tools/install) for other options\n2. run `cargo install bed2gtf` (make sure `~/.cargo/bin` is in your `$PATH` before running it)\n4. use `bed2gtf` with the required arguments\n5. enjoy!\n\n## Build\nto build bed2gtf from this repo, do:\n\n1. get rust (as described above)\n2. run `git clone https://github.com/alejandrogzi/bed2gtf.git \u0026\u0026 cd bed2gtf`\n3. run `cargo run --release -- -b \u003cBED\u003e -i \u003cISOFORMS\u003e -o \u003cOUTPUT\u003e`\n\n## Container image\nto build the development container image:\n1. run `git clone https://github.com/alejandrogzi/bed2gtf.git \u0026\u0026 cd bed2gtf`\n2. initialize docker with `start docker` or `systemctl start docker`\n3. build the image `docker image build --tag bed2gtf .`\n4. run `docker run --rm -v \"[dir_where_your_gtf_is]:/dir\" bed2gtf -b /dir/\u003cBED\u003e -i /dir/\u003cISOFORMS\u003e -o /dir/\u003cOUTPUT\u003e`\n\n## Conda\nto use bed2gtf through Conda just:\n1. `conda install bed2gtf -c bioconda` or `conda create -n bed2gtf -c bioconda gtfsort`\n\n## Output\n\nbed2gtf will send the output directly to the same .bed file path if you specify so\n\n```\nbed2gtf annotation.bed isoforms.txt output.gtf\n\n.\n├── ...\n├── isoforms.txt\n├── annotation.bed\n└── output.gtf\n```\nwhere `output.gtf` is the result.\n\n## FAQ\n### Why?\nUCSC offers a fast way to convert BED into GTF files through KentUtils or specific binaries (1) + several other bioinformaticians have shared scripts trying to replicate a similar solution (2,3,4).\n\nA GTF file is a 9-column tab-delimited file that holds gene annotation data for a specific assembly (5). The 9th column defines the attributes of each entry. This field is important, as some post-processing tools that handle GTF files need them to extract gene information (e.g. STAR, arriba, etc). An incomplete GTF attribute field would probably lead to annotation-related errors in these software.\n\nOf the available tools/scripts mentioned above, none produce a fully functional attribute GTF file conversion. (1) uses a two-step approach (bedToGenePred | genePredToGtf) written in C, which is extremely fast. Since a .bed file does not preserve any gene-related information, this approach fails to a) include correct gene_id attributes (duplicated transcript_ids) if no refTable is included b) append 3rd column gene features.\n\nThis is an example:\n\n```\nchr27 stdin transcript 17266470 17281218 . + . gene_id \"ENST00000541931.8\"; transcript_id \"ENST00000541931.8\";\n\nchr27 stdin exon 17266470 17266572 . + . gene_id \"ENST00000541931.8\"; transcript_id \"ENST00000541931.8\"; exon_number \"1\"; exon_id \"ENST00000541931.8.1\";\n```\n\n\nOn the other hand, available scripts (2,3,4) fall into bad-formatted outputs unable to be used as input to other tools. Some of them show a very customed format, far from a complete GTF file (2):\n\n```\nchr20 ---- peak 50222035 50222038 . + . peak_id \"chr20_50222035_50222038\";\n\nchr20 ---- peak 50188548 50189130 . + . peak_id \"chr20_50188548_50189130\";\n```\nand others (4) just provide exon-related information:\n\n```\nchr20 ensembl exon 50222035 50222038 . + . gene_id \"ENST00000595977.1735\"; transcript_id \"ENST00000595977.1735\"; exon_number \"0\n\nchr20 ensembl exon 50188548 50188930 . + . gene_id \"ENST00000595977.3403\"; transcript_id \"ENST00000595977.3403\"; exon_number \"0\n```\n\nThis is where bed2gtf comes in: a fast and memory efficient BED-to-GTF converter written in Rust. In ~4 seconds this tool produces a fully functional GTF converted file with all the needed features needed for post-processing tools.\n\n### How?\nbed2gtf is basically the reimplementation of C binaries merged in 1 step. This tool evaluates the position of k exons in j transcript, calculates start/stop/codon/UTR positions preserving reading frames and adjust the index + 1 (to be compatible with GTF convention). The isoforms file works as the refTable in C binaries to map each transcript to their respective gene; however, bed2gtf takes advantage of this and adds an additional \"gene\" line (to be compatible with other tools).\n\n## References\n\n1. http://hgdownload.soe.ucsc.edu/admin/exe/\n2. https://github.com/pfurio/bed2gtf\n3. https://rdrr.io/github/wyguo/RTDBox/src/R/gtf2bed.R\n4. https://github.com/MikeDacre/mike_tools/blob/master/bin/bed2gtf.py\n5. https://www.ensembl.org/info/website/upload/gff.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falejandrogzi%2Fbed2gtf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falejandrogzi%2Fbed2gtf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falejandrogzi%2Fbed2gtf/lists"}