{"id":15578368,"url":"https://github.com/davep/twobee","last_synced_at":"2025-05-13T16:14:46.976Z","repository":{"id":98844193,"uuid":"603564066","full_name":"davep/twobee","owner":"davep","description":"A 2bit file viewer for the terminal, complete with Python 2bit library","archived":false,"fork":false,"pushed_at":"2024-03-15T16:04:04.000Z","size":769,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-06T18:15:47.508Z","etag":null,"topics":["bioinformatics","python","python3","terminal","textual"],"latest_commit_sha":null,"homepage":"","language":"Python","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/davep.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","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}},"created_at":"2023-02-18T22:17:37.000Z","updated_at":"2025-03-11T01:01:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"6885394d-fda4-499b-a608-aa371bc79cf8","html_url":"https://github.com/davep/twobee","commit_stats":{"total_commits":102,"total_committers":1,"mean_commits":102.0,"dds":0.0,"last_synced_commit":"db540b3e0f03ab4385bd91148c6586ea2f0d44b1"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davep%2Ftwobee","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davep%2Ftwobee/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davep%2Ftwobee/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davep%2Ftwobee/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davep","download_url":"https://codeload.github.com/davep/twobee/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253980059,"owners_count":21994043,"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":["bioinformatics","python","python3","terminal","textual"],"created_at":"2024-10-02T19:09:43.759Z","updated_at":"2025-05-13T16:14:46.947Z","avatar_url":"https://github.com/davep.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# twobee\n\n[![PyPI version](https://badge.fury.io/py/twobee.svg)](https://badge.fury.io/py/twobee)\n\n[![View a YouTube video of twobee in action](https://raw.githubusercontent.com/davep/twobee/main/img/twobee.png)](https://www.youtube.com/watch?v=ccrRB4sDixU)\n\n[View the code in action on YouTube](https://www.youtube.com/watch?v=ccrRB4sDixU)\n\n## Introduction\n\n`twobee` is sort of two things rolled into one: it's a Python-based [2bit\nfile](https://genome.ucsc.edu/FAQ/FAQformat.html#format7) reading library,\nwrapped in a [Textual](https://textual.textualize.io/) UI to provide a (for\nnow anyway) very simple viewer. It is, it has to be said, of very little\nutility. I'm mostly writing it as a proof-of concept and as another way to\ntest some of the performance edges and use cases of Textual.\n\nAlso... I wanted a test project to get to know the Textual [line\nAPI](https://textual.textualize.io/guide/widgets/#line-api) and this seemed\nlike a good fit.\n\n## Installing\n\nThe package can be installed with `pip` or related tools, for example:\n\n```sh\n$ pip install twobee\n```\n\nAs well as the library (which I'll give some minimal documentation for below\n-- hopefully more comprehensive documentation will follow eventually), a\ncommand is also installed called `twobee`. This can be used load up and view\nthe contents of a 2bit file.\n\n## It's early days\n\nThis is a very early release of this code, it's still very much a work in\nprogress. This means things may change and break; it's also sitting atop\nTextual which is, of course, still undergoing rapid development. As much as\npossible I'll try and ensure that it's always working with the latest stable\nrelease of Textual.\n\nAlso, because it's early days... while I love the collaborative aspect of\nFOSS, I'm highly unlikely to be accepting any non-trivial PRs at the moment.\nDeveloping this is a learning exercise for me, it's a hobby project, and\nit's also something to help me further test Textual (disclaimer for those\nwho may not have gathered, I am employed by\n[Textualize](https://www.textualize.io/)).\n\nOn the other hand: I'm *very* open to feedback and suggestions so don't\nhesitate to engage with me in Discussions, or if it's a bug,in Issues. I\ncan't and won't promise that I'll take everything on board (see above about\nhobby project, etc), but helpful input should help make this as useful as\npossible in the longer term.\n\n## The library\n\nWhile I've not written this package to provide a 2bit-reading library, I\nwanted to write one anyway (I've written one in [Common\nLisp](https://github.com/davep/org-davep-2bit), and one in [Emacs\nLisp](https://github.com/davep/2bit.el), it felt only right I should write\none in Python too). So, on the off chance someone else may want to mess with\nthis...\n\nThe library is designed so that there will be different ways of accessing a\n2bit file, but for the moment there is just the option to load from a local\nfile. To do this you want a `TwoBitFileReader`:\n\n```python\n\u003e\u003e\u003e from twobee import TwoBitFileReader\n```\n\nthen it can be used to open a file:\n\n```python\n\u003e\u003e\u003e hg38 = TwoBitFileReader( \"hg38.2bit\" )\n```\n\nThe property `sequences` contains all of the sequences names contained in\nthe file, for example:\n\n```python\n\u003e\u003e\u003e [ seq for seq in hg38.sequences if \"_\" not in seq ]\n[\n    'chr1',\n    'chr10',\n    'chr11',\n    'chr12',\n    'chr13',\n    'chr14',\n    'chr15',\n    'chr16',\n    'chr17',\n    'chr18',\n    'chr19',\n    'chr2',\n    'chr20',\n    'chr21',\n    'chr22',\n    'chr3',\n    'chr4',\n    'chr5',\n    'chr6',\n    'chr7',\n    'chr8',\n    'chr9',\n    'chrM',\n    'chrX',\n    'chrY'\n]\n```\n\nThe reader object itself can be used as an iterator too:\n\n```python\n\u003e\u003e\u003e [ seq for seq in hg38 if \"_\" not in seq ]\n[\n    'chr1',\n    'chr10',\n    'chr11',\n    'chr12',\n    'chr13',\n    'chr14',\n    'chr15',\n    'chr16',\n    'chr17',\n    'chr18',\n    'chr19',\n    'chr2',\n    'chr20',\n    'chr21',\n    'chr22',\n    'chr3',\n    'chr4',\n    'chr5',\n    'chr6',\n    'chr7',\n    'chr8',\n    'chr9',\n    'chrM',\n    'chrX',\n    'chrY'\n]\n```\n\nThe reader can then be used like an array to get a particular sequence, for\nexample:\n\n```python\n\u003e\u003e\u003e chrX = hg38[ \"chrX\" ]\n\u003e\u003e\u003e chrX\nTwoBitSequence('chrX', dna_file_location=781826420, dna_size=156040895, len(n_blocks)=34, len(mask_blocks)=189177)\n```\n\nThe `TwoBitSequence` that is returned can then be used in a similar way to\nget a collection of bases. For example:\n\n```python\n\u003e\u003e\u003e chrX[ 10000:10010 ]\nTwoBitBases('chrX:10000..10010', bases='CTAACCCTAA')\n```\n\nThere are a few convenience methods and the like on `TwoBitBases` to make it\neasy to work with, with a bunch more to come as I get time to tinker.\n\n## TODO\n\nLots. Lots and lots. I will be hacking on this more.\n\n[//]: # (README.md ends here)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavep%2Ftwobee","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavep%2Ftwobee","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavep%2Ftwobee/lists"}