{"id":51587948,"url":"https://github.com/kojix2/ruby-biosyntax","last_synced_at":"2026-07-11T12:30:47.770Z","repository":{"id":364957490,"uuid":"1269890086","full_name":"kojix2/ruby-biosyntax","owner":"kojix2","description":"🧬 bioSyntax - Syntax highlighting for biological data formats - for Ruby","archived":false,"fork":false,"pushed_at":"2026-07-03T12:18:36.000Z","size":183,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-07-03T14:18:41.471Z","etag":null,"topics":["bioinformatics","ruby"],"latest_commit_sha":null,"homepage":"https://kojix2.github.io/ruby-biosyntax/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kojix2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2026-06-15T07:35:53.000Z","updated_at":"2026-07-03T12:17:21.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/kojix2/ruby-biosyntax","commit_stats":null,"previous_names":["kojix2/ruby-biosyntax"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/kojix2/ruby-biosyntax","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kojix2%2Fruby-biosyntax","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kojix2%2Fruby-biosyntax/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kojix2%2Fruby-biosyntax/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kojix2%2Fruby-biosyntax/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kojix2","download_url":"https://codeload.github.com/kojix2/ruby-biosyntax/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kojix2%2Fruby-biosyntax/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35362871,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-11T02:00:05.354Z","response_time":104,"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":["bioinformatics","ruby"],"created_at":"2026-07-11T12:30:47.515Z","updated_at":"2026-07-11T12:30:47.756Z","avatar_url":"https://github.com/kojix2.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ruby-biosyntax\n\n[![CI](https://github.com/kojix2/ruby-biosyntax/actions/workflows/ci.yml/badge.svg)](https://github.com/kojix2/ruby-biosyntax/actions/workflows/ci.yml)\n[![Gem Version](https://badge.fury.io/rb/biosyntax.svg)](https://badge.fury.io/rb/biosyntax)\n[![Lines of Code](https://img.shields.io/endpoint?url=https%3A%2F%2Ftokei.kojix2.net%2Fbadge%2Fgithub%2Fkojix2%2Fruby-biosyntax%2Flines)](https://tokei.kojix2.net/github/kojix2/ruby-biosyntax)\n[![DOI](https://zenodo.org/badge/1269890086.svg)](https://doi.org/10.5281/zenodo.20698478)\n\n\n\n:dna: [bioSyntax](https://github.com/bioSyntax/bioSyntax) - Syntax highlighting for biological data formats - for Ruby.\n\nPowered by [libbiosyntax](https://github.com/kojix2/libbiosyntax).\n\n## Installation\n\n```sh\ngem install biosyntax\n```\n\n## ANSI coloring\n\n```ruby\nrequire \"biosyntax\"\n\nhl = BioSyntax.fastq\n\nFile.foreach(\"reads.fastq\", chomp: false) do |line|\n  print hl.colorize(line)\nend\n```\n\n`colorize` returns a string with ANSI SGR escape sequences using the built-in\n`libbiosyntax` colors.\n\n`Highlighter` is stateful. Reuse one highlighter for one input stream,\nespecially for FASTQ and WIG. Use `reset` before starting another stream with\nthe same object.\n\n```ruby\nhl = BioSyntax.fastq\n# process one file...\nhl.reset\n# process another file...\n```\n\n## Highlight spans\n\n```ruby\nrequire \"biosyntax\"\n\nhl = BioSyntax.vcf\nline = \"chr1\\t42\\trs1\\tA\\tT\\t99\\tPASS\\tDP=10;AF=0.5\\n\"\n\nspans = hl.highlight(line)\n\nspans.each do |span|\n  puts [span.start, span.end, span.kind.name, span.scope].join(\"\\t\")\nend\n```\n\nA span uses byte offsets into the input line:\n\n```ruby\nspan.start   # byte offset at the start of the highlighted range\nspan.end     # byte offset just after the highlighted range\nspan.length  # byte length\nspan.kind    # BioSyntax::Kind\nspan.scope   # e.g. \"biosyntax.chrom\"\n```\n\n## Formats and metadata\n\nCreate highlighters with `BioSyntax.\u003cformat\u003e` or `BioSyntax[format]`.\nHyphenated format names use underscores for factory methods.\n\n```ruby\nBioSyntax.vcf\nBioSyntax.fastq\nBioSyntax.fasta_nt\nBioSyntax[:\"fasta-nt\"]\nBioSyntax[\"bam\"]       # canonical format is :sam\n```\n\nUseful metadata:\n\n```ruby\nBioSyntax::FORMAT_NAMES # array of canonical format names\nBioSyntax::FORMATS      # { name =\u003e BioSyntax::Format }\nBioSyntax::KIND_NAMES   # array of kind names\nBioSyntax::KINDS        # { name =\u003e BioSyntax::Kind }\nBioSyntax::SCOPES       # { scope =\u003e [BioSyntax::Kind, ...] }\n\nBioSyntax::Format::VCF\nBioSyntax::Kind::CHROM\n\nBioSyntax.format_supported?(:vcf)  # true\nBioSyntax.format_name(:bam)        # :sam\nBioSyntax.guess_format(\"a.vcf.gz\") # :vcf\n```\n\nThe metadata is generated from `libbiosyntax` at load time. The Ruby side does\nnot maintain a separate hand-written table of formats or kinds.\n\n## Command line\n\nInstalling the gem also installs `biocat`:\n\n```sh\nbiocat sample.vcf\nbiocat --format fastq reads.fastq\nbiocat -l\n```\n\n`.gz`/`.bgz` are decompressed automatically. BAM/CRAM/BCF require optional\n`ruby-htslib` (`gem install htslib`).\n\n## Development tasks\n\n```sh\nbundle exec rake -T\nbundle exec rake test\nbundle exec rake build\nbundle exec yard doc\n```\n\nThe native extension is built with `rake-compiler`. Temporary build products\nare written under `tmp/`, and the compiled extension is copied to\n`lib/biosyntax/`.\n\n## Updating vendored libbiosyntax\n\nThis gem vendors the C source of `libbiosyntax` and builds it into the Ruby extension.\nIt does not require a system `libbiosyntax` shared library.\nThe vendored C source lives under:\n\n```text\next/biosyntax/biosyntax.c\next/biosyntax/biosyntax.h\n```\n\nWhen `libbiosyntax` is updated, refresh the vendored files and run the test suite:\n\n```sh\nbundle exec rake update:libbiosyntax\nbundle exec rake\n```\n\n## License\n\n`biosyntax` vendors `libbiosyntax`, which is licensed under the GNU General\nPublic License version 3 only. This gem is therefore distributed under\n`GPL-3.0-only`. See `LICENSE.md`.\n\nThis project is inspired by the original bioSyntax project:\n\u003chttps://github.com/bioSyntax/bioSyntax\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkojix2%2Fruby-biosyntax","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkojix2%2Fruby-biosyntax","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkojix2%2Fruby-biosyntax/lists"}