{"id":45074476,"url":"https://github.com/rossmerr/bwt","last_synced_at":"2026-02-19T13:13:03.135Z","repository":{"id":45429965,"uuid":"513636177","full_name":"rossmerr/bwt","owner":"rossmerr","description":"Burrows-Wheeler Transform","archived":false,"fork":false,"pushed_at":"2023-03-05T11:43:11.000Z","size":35,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2023-08-11T23:29:56.288Z","etag":null,"topics":["bwt","bwt-transform","go","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","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/rossmerr.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":"2022-07-13T18:49:31.000Z","updated_at":"2023-03-03T19:06:52.000Z","dependencies_parsed_at":"2023-02-19T10:50:20.650Z","dependency_job_id":null,"html_url":"https://github.com/rossmerr/bwt","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"purl":"pkg:github/rossmerr/bwt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rossmerr%2Fbwt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rossmerr%2Fbwt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rossmerr%2Fbwt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rossmerr%2Fbwt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rossmerr","download_url":"https://codeload.github.com/rossmerr/bwt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rossmerr%2Fbwt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29614642,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T13:04:20.082Z","status":"ssl_error","status_checked_at":"2026-02-19T13:03:33.775Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["bwt","bwt-transform","go","golang"],"created_at":"2026-02-19T13:13:02.364Z","updated_at":"2026-02-19T13:13:03.128Z","avatar_url":"https://github.com/rossmerr.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Burrows-Wheeler Transform (BWT)\n\n[![Go](https://github.com/rossmerr/bwt/actions/workflows/go.yml/badge.svg)](https://github.com/rossmerr/bwt/actions/workflows/go.yml)\n[![Go Report Card](https://goreportcard.com/badge/github.com/rossmerr/bwt)](https://goreportcard.com/report/github.com/rossmerr/bwt)\n[![Read the Docs](https://pkg.go.dev/badge/golang.org/x/pkgsite)](https://pkg.go.dev/github.com/rossmerr/bwt)\n\nRearranges a character string into runs of similar characters. This is useful for compression, since it tends to be easy to compress a string that has runs of repeated characters by techniques such as move-to-front transform and run-length encoding.\n\nGiven the following int `abaaba`\n\nThe Burrows-Wheeler Matrix would look like the this :-\n\n```\n\u0003abaaba\na\u0003abaab\naaba\u0003ab\naba\u0003aba\nabaaba\u0003\nba\u0003abaa\nbaaba\u0003a\n```\n\nThe last column is then `abba\u0003aa`, were the `\u0003` rune is the End-of-Text code.\n\n```go\nmatrix, err := bwt.Matrix(\"abaaba\") // 'matrix' is a [][]rune\n```\n\n```go\nlast, err := bwt.Last(\"abaaba\") // 'last' is a []rune\n\nfmt.Println(string(last)) // abba\u0003aa\n```\n\n```go\nfirst, last, err := bwt.FirstLast(\"abaaba\")  // 'first' is a []rune\n\nfmt.Println(string(first)) // \u0003aaaabb\n\nfmt.Println(string(last)) // abba\u0003aa\n```\n\n```go\nstr := \"abaaba\"\ntext := []rune(str)\n\nfirst, last, sa, err := bwt.FirstLastSuffix(str)  // 'sa' is a suffixarray.Suffix\n\nfmt.Println(string(first)) // \u0003aaaabb\n\nfmt.Println(string(last)) // abba\u0003aa\n\n// You want to find the original offset of the first 'b' in the 'str'\n// 6 is the index of rune 'b' from the first column,\n//\n// you could range over 'first' to find the index\n// as the 'first' column of the BWT has consecutivity\n// so we would know the first 'b' must have been the first 'b' in the 'str'\noffset := sa.Get(6)\n\nfmt.Println(offset) // 1\nfmt.Println(string(text[offset])) // b\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frossmerr%2Fbwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frossmerr%2Fbwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frossmerr%2Fbwt/lists"}