{"id":17493462,"url":"https://github.com/ciaranomara/bedgraph.jl","last_synced_at":"2025-04-22T22:27:02.235Z","repository":{"id":61797260,"uuid":"100577685","full_name":"CiaranOMara/Bedgraph.jl","owner":"CiaranOMara","description":"Read and write support for bedGraph file format.","archived":false,"fork":false,"pushed_at":"2024-05-05T09:55:10.000Z","size":129,"stargazers_count":0,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2024-10-19T15:20:06.376Z","etag":null,"topics":["bedgraph","bioinformatics","dna","julia"],"latest_commit_sha":null,"homepage":"","language":"Julia","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/CiaranOMara.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}},"created_at":"2017-08-17T08:00:43.000Z","updated_at":"2024-05-05T06:26:44.000Z","dependencies_parsed_at":"2022-10-21T11:00:39.340Z","dependency_job_id":null,"html_url":"https://github.com/CiaranOMara/Bedgraph.jl","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CiaranOMara%2FBedgraph.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CiaranOMara%2FBedgraph.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CiaranOMara%2FBedgraph.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CiaranOMara%2FBedgraph.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CiaranOMara","download_url":"https://codeload.github.com/CiaranOMara/Bedgraph.jl/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240457958,"owners_count":19804489,"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","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":["bedgraph","bioinformatics","dna","julia"],"created_at":"2024-10-19T12:07:32.333Z","updated_at":"2025-03-04T13:30:40.414Z","avatar_url":"https://github.com/CiaranOMara.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bedgraph.jl\n\n[![Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.](http://www.repostatus.org/badges/latest/wip.svg)](http://www.repostatus.org/#wip)\n![Unit Tests](https://github.com/CiaranOMara/Bedgraph.jl/workflows/Unit%20Tests/badge.svg?branch=master)\n[![codecov](https://codecov.io/gh/CiaranOMara/Bedgraph.jl/branch/master/graph/badge.svg?branch=master)](https://codecov.io/gh/CiaranOMara/Bedgraph.jl?branch=master)\n\n\u003e This project follows the [semver](http://semver.org) pro forma and uses the [git-flow branching model](http://nvie.com/git-model \"original\nblog post\").\n\n## Description\nThis package provides read and write support for [Bedgraph files](https://genome.ucsc.edu/goldenPath/help/bedgraph.html).\n\n\u003e **Note:**  this package does not currently handle bedGraph meta data such as the track definition or browser lines.\n\n## Installation\nYou can install Bedgraph from the [Julia REPL](https://docs.julialang.org/en/v1/manual/getting-started/).\nPress `]` to enter [pkg mode](https://docs.julialang.org/en/v1/stdlib/Pkg/), then enter the following:\n\n```julia\nadd Bedgraph\n```\n\nIf you are interested in the cutting edge of the development, please check out the [develop branch](https://github.com/CiaranOMara/Bedgraph.jl/tree/develop) to try new features before release.\n\n## Usage\n\n### Reading and writing bedGraph files\n\u003e See source for optional `bump_back`, `bump_forward`, and `right_open` key values. These options are included in the pertinent read/write functions to handle quirks of the zero-based and half-open nature of the bedGraph format.\n\n#### Read header/meta\n```julia\nusing Bedgraph\n\nheader = read(file, BedgraphHeader{Vector{String}})\n```\n\n#### Read records\n\nRead all records at once.\n```julia\nusing Bedgraph\n\nrecords = read(file, Vector{Bedgraph.Record})\n```\n\n```julia\nusing Bedgraph\n\nrecords = open(file, \"r\") do io\n    return read(io, Vector{Bedgraph.Record})\nend\n```\n\nAlternatively you may want to read and process records individually.\n```julia\nopen(file, \"r\") do io\n    while !eof(seek(io, Bedgraph.Record))\n        record = read(io, Bedgraph.Record) #Note: no protection.\n        # Process record.\n    end\nend\n```\n\n#### Write a bedGraph file\nBedgraph.jl currently provides two write functions: one for `Bedgraph.BedgraphHeader`, and one for `Bedgraph.Record`, which also accepts `Vector{Bedgraph.Record}`.\n\n```julia\nusing Bedgraph\n\nconst chroms = [\"chr19\", \"chr19\", \"chr19\", \"chr19\", \"chr19\", \"chr19\", \"chr19\", \"chr19\", \"chr19\"]\nconst firsts = [49302000, 49302300, 49302600, 49302900, 49303200, 49303500, 49303800, 49304100, 49304400]\nconst lasts = [49302300, 49302600, 49302900, 49303200, 49303500, 49303800, 49304100, 49304400, 49304700]\nconst values = [-1.0, -0.75, -0.50, -0.25, 0.0, 0.25, 0.50, 0.75, 1.00]\n\nrecords = Bedgraph.Record.(chroms, firsts, lasts, values)\n\nsort!(records)\n\nheader = Bedgraph.generate_basic_header(records)\n\nwrite(\"data.bedgraph\", header, records)\n```\n\n\n```julia\nusing Bedgraph\n\nrecords = [Record(\"chr19\", 49302000, 49302300, -1.0), Record(\"chr19\", 49302300, 49302600, -1.75)]\nheader = Bedgraph.generate_basic_header(\"chr19\", records[1].first, records[end].last, bump_forward=false)\n\nopen(output_file, \"w\") do io\n    write(io, header, records)\nend\n```\n\n#### Converting records\n\nBelow are some examples of `Bedgraph.Record` conversions provided by this package.\n```julia\nusing Bedgraph\n\nrecord = Record(\"chr1\", 10, 20)\n\n# Convert record to NamedTuple.\nnt = convert(NamedTuple, record)\n\n# Convert record to NamedTuple and rename fields.\nnt = convert(NamedTuple{(:chrom, :left, :right, :value)}, record)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fciaranomara%2Fbedgraph.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fciaranomara%2Fbedgraph.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fciaranomara%2Fbedgraph.jl/lists"}