{"id":16511234,"url":"https://github.com/pbenner/rustynetics","last_synced_at":"2026-01-26T09:32:55.342Z","repository":{"id":221945409,"uuid":"755840054","full_name":"pbenner/rustynetics","owner":"pbenner","description":"Bioinformatics Library in Rust","archived":false,"fork":false,"pushed_at":"2024-10-30T21:07:15.000Z","size":10013,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-21T03:10:22.172Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pbenner.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2024-02-11T08:25:45.000Z","updated_at":"2024-10-30T21:07:19.000Z","dependencies_parsed_at":"2024-02-20T21:26:47.793Z","dependency_job_id":"c841db48-b4b1-48e6-9d1d-77184a5a97f1","html_url":"https://github.com/pbenner/rustynetics","commit_stats":null,"previous_names":["pbenner/rustynetics"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/pbenner/rustynetics","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pbenner%2Frustynetics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pbenner%2Frustynetics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pbenner%2Frustynetics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pbenner%2Frustynetics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pbenner","download_url":"https://codeload.github.com/pbenner/rustynetics/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pbenner%2Frustynetics/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28772912,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T08:38:24.014Z","status":"ssl_error","status_checked_at":"2026-01-26T08:38:22.080Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-10-11T15:59:24.832Z","updated_at":"2026-01-26T09:32:55.328Z","avatar_url":"https://github.com/pbenner.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n## Rustynetics\n\nRustynetics is a high-performance Rust library designed for bioinformatics applications, offering efficient and scalable handling of common genomic file formats. It supports reading and writing of widely used formats such as bigWig, bedGraph, BED, and GFF, making it an essential tool for genomic data processing pipelines.\n\nThe library excels in computing coverage tracks, summarizing sequence alignments or read counts across the genome, allowing users to generate coverage profiles over specified the genome. In addition, it offers advanced statistical features, such as the calculation of cross-correlations, which can be used to assess relationships between different genomic datasets, for example, in ChIP-seq or RNA-seq analysis.\n\nOne of the library's core strengths is its efficient handling of genomic ranges. It offers a highly optimized data structure for manipulating large genomic intervals, ensuring that operations like querying, merging, or intersecting genomic regions are performed with minimal overhead. Moreover, the library provides a pretty print feature for easily displaying genomic ranges in human-readable formats, facilitating better visualization and interpretation of complex data.\n\nDesigned with performance and usability in mind, this library is ideal for large-scale genomics projects requiring both speed and precision, whether for research in genomics, epigenetics, or other related fields.\n\n## Documentation\n\nPlease find the API documentation [here](https://docs.rs/crate/rustynetics/latest).\n\n### Tools\n\nThe package contains the following command line tools:\n\n| Tool                     | Description                                                              |\n| ------------------------ | ------------------------------------------------------------------------ |\n| bam-check-bin            | check bin records of a bam file                                          |\n| bam-genome               | print the genome (sequence table) of a bam file                          |\n| bam-to-bigwig            | convert bam to bigWig (estimate fragment length if required)             |\n| bam-view                 | print contents of a bam file                                             |\n| bigwig-genome            | print the genome (sequence table) of a bigWig file                       |\n| bigwig-info              | print information about a bigWig file                                    |\n| bigwig-query             | retrieve data from a bigWig file                                         |\n| bigwig-query-sequence    | retrieve sequences from a bigWig file                                    |\n\n\n## Examples\n\n### Import genes from UCSC\n\n```rust\nuse crate::genes::Genes;\n\n// Import from local file\nif let Ok(genes) = Genes::import_genes(\"data/hg19.knownGene.txt.gz\") {\n\n    println!(\"{}\", genes);\n}\n// Retrieve from USCS server\nif let Ok(genes) = Genes::import_genes_from_ucsc(\"hg19\", \"knownGene\") {\n\n    println!(\"{}\", genes);\n}\n```\nThe result is:\n```bash\n       seqnames ranges                 strand |               names                  cds\n     1 chr1     [    11868,     14409) +      | ENST00000456328.2_1       [11868, 11868)\n     2 chr1     [    29553,     31097) +      | ENST00000473358.1_5       [29553, 29553)\n     3 chr1     [    30266,     31109) +      | ENST00000469289.1_1       [30266, 30266)\n     4 chr1     [    34553,     36081) -      | ENST00000417324.1_4       [34553, 34553)\n     5 chr1     [    35244,     36073) -      | ENST00000461467.1_3       [35244, 35244)\n       ...      ...                           |                 ...                  ...\n254531 chrY     [ 59161253,  59162245) -      | ENST00000711258.1_1 [59161253, 59161253)\n254532 chrY     [ 59208304,  59208554) +      | ENST00000711259.1_1 [59208304, 59208304)\n254533 chrY     [ 59311662,  59311996) -      | ENST00000711266.1_1 [59311662, 59311662)\n254534 chrY     [ 59318040,  59318920) -      | ENST00000711267.1_1 [59318040, 59318040)\n254535 chrY     [ 59358334,  59360548) -      | ENST00000711270.1_1 [59358334, 59358334)\n```\n\n### Read GTF files\n\n```rust\n\nuse crate::granges::GRanges;\n\nlet granges = GRanges::import_gtf(\"src/granges_gtf.gtf\",\n    vec![\"gene_id\", \"gene_num\"], // Names of optional fields\n    vec![\"str\"    , \"int\"     ], // Types of optional fields\n    vec![None     , Some(\"0\") ], // Default values, can be an empty vector if omitted\n).unwrap();\n```\nThe result is:\n```bash\n  seqnames ranges         strand |                             source    feature gene_num         gene_id\n1 1        [11869, 14409) +      | transcribed_unprocessed_pseudogene       gene        1 ENSG00000223972\n2 1        [11870, 14410) +      |               processed_transcript transcript        0 ENSG00000223972\n```\n\n### Read a BAM file into a GRanges object\n\n```rust\nuse crate::bam::BamReaderOptions;\nuse crate::granges::GRanges;\n\nlet mut options = BamReaderOptions::default();\n\noptions.read_cigar = true;\noptions.read_qual  = true;\n\nif let Ok(granges) = GRanges::import_bam_single_end(\"tests/test_bam_2.bam\", Some(options)) {\n    println!(\"{}\", granges);\n}\n```\nThe result is:\n```bash\n     seqnames     ranges                 strand | flag mapq cigar                                                qual\n   1 chr15        [ 25969791,  25969842) +      |   99   60   51M @@@DFFFFHHHHGBHIBHHHGGGIHIEEHEIIIIIIGCHGHIGIGIIIIHH\n   2 chr15        [ 25969837,  25969888) -      |  147   60   51M GJJIIIIHIHDIHIIHHEGEEGJIIHFHIHCIHHGEIDHHDDHFDFFD@C@\n   3 chr1         [175925088, 175925139) -      |  153    0   51M IIIIIJJJIJJJJJJJJIJGIJIJHJJJJJJJIIJJJJHHHHHFFFFFBCC\n   4 chrX         [ 71582197,  71582248) -      |   83   60   51M GGDDIIIGJIJJJJJJJJJHGEHGJJJJIHDEIIGIJJGHHFHFFFFFCC@\n   5 chrX         [ 71581965,  71582016) +      |  163   60   51M @CCFFDFFHHDHHJJJIGCHGIGIGIGJJJIGCGCHBFGDBFGFGIJIJGC\n     ...          ...                           |  ...  ...   ...                                                 ...\n4887 chr11        [  9074777,   9074828) +      |  163   29   51M \u003c@:B;DDDFH:CC\u003eCFEAADFFFCDFHIEHIHJEGGEHIJJIIDGGIGHII\n4888 chr7         [  3303179,   3303230) -      |   83   60   51M HIHH@GIIHGHGHCJHGJIIIIIJJJJIJJIIIIIIJJHHGHHFFFFFCCC\n4889 chr7         [  3303050,   3303101) +      |  163   60   51M \u003c@\u003cDADADAAFFFC@\u003eDGEHIICEGH@HCCEGHCCEBGGGFG:BFCGGGBB\n4890 chr11        [  4737838,   4737889) -      |   83   60   51M DB9;HCD?D??:?:):)CCA\u003cC2:@HFAHEEHF@\u003c?\u003c?:ACADB;:BB1@?\n4891 chr11        [  4737786,   4737837) +      |  163   60   51M @@\u003cDDBDDFD+C?A:1CFDHBFHC\u003c?F9+CGGI:49CCGFACE99?DC990\n```\n\n### Reading BigWig files\n\nBigWig files contain data in a binary format optimized for fast random access. In addition to the raw data, bigWig files typically contain several zoom levels for which the data has been summarized. The BigWigReader class allows to query data and it automatically selects an appropriate zoom level for the given binsize:\n```rust\nlet seqname = \"chrY\"; // (can be a regular expression)\nlet from    = 1838100;\nlet to      = 1838600;\nlet binsize = 100;\n\n// The reader accepts either a local file or a file\n// hosted on a HTTP server\nif let Ok(mut reader) = BigWigFile::new_reader(\"tests/test_bigwig_2.bw\") {\n\n    for item in reader.query(seqname, from, to, binsize) {\n        println!(\"{}\", item.unwrap());\n    }\n\n}\n```\nThe result is:\n```bash\n(data=(chrom_id=chrY, from=1838100, to=1838200, statistics=(valid=1, min=1.0000, max=1.0000, sum=1.0000, sum_squares=1.0000)), type=fixed)\n(data=(chrom_id=chrY, from=1838200, to=1838300, statistics=(valid=1, min=1.0000, max=1.0000, sum=1.0000, sum_squares=1.0000)), type=fixed)\n(data=(chrom_id=chrY, from=1838300, to=1838400, statistics=(valid=1, min=0.0000, max=0.0000, sum=0.0000, sum_squares=0.0000)), type=fixed)\n(data=(chrom_id=chrY, from=1838400, to=1838500, statistics=(valid=1, min=0.0000, max=0.0000, sum=0.0000, sum_squares=0.0000)), type=fixed)\n(data=(chrom_id=chrY, from=1838500, to=1838600, statistics=(valid=1, min=0.0000, max=0.0000, sum=0.0000, sum_squares=0.0000)), type=fixed)\n```\n\n### Compute coverage tracks from BAM files\n\nWe download a BAM file from a ChIP-seq experiment in Homo sapiens A549 with FOXS1 as target (ENCFF504WRM) in addition to the control data (ENCFF739ECZ):\n```bash\nwget https://www.encodeproject.org/files/ENCFF504WRM/@@download/ENCFF504WRM.bam\nwget https://www.encodeproject.org/files/ENCFF739ECZ/@@download/ENCFF739ECZ.bam\n```\n\n```rust\n\nuse rustynetics::bam_coverage::bam_coverage;\n\nlet tracks_treatment = vec![\"ENCFF504WRM.bam\"];\nlet tracks_control   = vec![\"ENCFF739ECZ.bam\"];\n\n// Set fragment length to 0, which means that fragments will not be extended.\n// Setting this to None will trigger automatic fragment length estimation\nlet fraglen_treatment = vec![Some(0)];\nlet fraglen_control   = vec![Some(0)];\n\nlet (track, _treatment_fraglen_estimates, _control_fraglen_estimates) = bam_coverage(\n    \u0026tracks_treatment,\n    \u0026tracks_control,\n    \u0026fraglen_treatment,\n    \u0026fraglen_control,\n    vec![]\n).unwrap();\n\nif let Err(e) = track.export_bigwig(\"track.bw\", vec![]) {\n    panic!(\"{}\", e);\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpbenner%2Frustynetics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpbenner%2Frustynetics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpbenner%2Frustynetics/lists"}