{"id":38910502,"url":"https://github.com/deeptools/py2bit","last_synced_at":"2026-01-17T15:17:34.776Z","repository":{"id":12270458,"uuid":"64464103","full_name":"deeptools/py2bit","owner":"deeptools","description":"A python library for accessing 2bit files","archived":false,"fork":false,"pushed_at":"2025-01-21T15:41:54.000Z","size":61,"stargazers_count":21,"open_issues_count":0,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-10T18:52:34.106Z","etag":null,"topics":["bioinformatics","twobit"],"latest_commit_sha":null,"homepage":null,"language":"C","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/deeptools.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2016-07-29T08:24:12.000Z","updated_at":"2025-10-09T19:08:06.000Z","dependencies_parsed_at":"2025-09-08T14:57:45.895Z","dependency_job_id":"36950f52-48e7-44c0-8ce4-59c8edd4afa8","html_url":"https://github.com/deeptools/py2bit","commit_stats":{"total_commits":32,"total_committers":3,"mean_commits":"10.666666666666666","dds":0.1875,"last_synced_commit":"697884f1c0b0bf4d3c9b82c4fa6a4445a2453c6c"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/deeptools/py2bit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deeptools%2Fpy2bit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deeptools%2Fpy2bit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deeptools%2Fpy2bit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deeptools%2Fpy2bit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deeptools","download_url":"https://codeload.github.com/deeptools/py2bit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deeptools%2Fpy2bit/sbom","scorecard":{"id":332272,"data":{"date":"2025-08-11","repo":{"name":"github.com/deeptools/py2bit","commit":"4ad501c74dfa04caa6953ed34dc2e716474522a9"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.6,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pypi.yml:8: update your workflow using https://app.stepsecurity.io/secureworkflow/deeptools/py2bit/pypi.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pypi.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/deeptools/py2bit/pypi.yml/master?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/pypi.yml:18","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":2,"reason":"Found 2/9 approved changesets -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/pypi.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.txt:0","Info: FSF or OSI recognized license: MIT License: LICENSE.txt:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 29 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-18T03:54:31.678Z","repository_id":12270458,"created_at":"2025-08-18T03:54:31.687Z","updated_at":"2025-08-18T03:54:31.687Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28511150,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T13:38:16.342Z","status":"ssl_error","status_checked_at":"2026-01-17T13:37:44.060Z","response_time":85,"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":["bioinformatics","twobit"],"created_at":"2026-01-17T15:17:34.062Z","updated_at":"2026-01-17T15:17:34.756Z","avatar_url":"https://github.com/deeptools.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/dpryan79/py2bit.svg?branch=master)](https://travis-ci.org/dpryan79/py2bit)\n\n# py2bit\n\nA python extension, written in C, for quick access to [2bit](https://genome.ucsc.edu/FAQ/FAQformat.html#format7) files. The extension uses [lib2bit](https://github.com/dpryan79/lib2bit) for file access.\n\nTable of Contents\n=================\n\n * [Installation](#installation)\n * [Usage](#usage)\n   * [Load the extension](#load-the-extension)\n   * [Open a 2bit file](#open-a-2bit-file)\n   * [Access the list of chromosomes and their lengths](#access-the-list-of-chromosomes-and-their-lengths)\n   * [Print file information](#print-file-information)\n   * [Fetch a sequence](#fetch-a-sequence)\n   * [Fetch per-base statistics](#fetch-per-base-statistics)\n   * [Fetch masked blocks](#fetch-masked-blocks)\n   * [Close a file](#close-a-file)\n * [A note on coordinates](#a-note-on-coordinates)\n\n# Installation\n\nYou can install the extension directly from github with:\n\n    pip install git+https://github.com/dpryan79/py2bit\n\n# Usage\n\nBasic usage is as follows:\n\n## Load the extension\n\n    \u003e\u003e\u003e import py2bit\n\n## Open a 2bit file\n\nThis will work if your working directory is the py2bit source code directory.\n\n    \u003e\u003e\u003e tb = py2bit.open(\"test/foo.2bit\")\n\nNote that if you would like to include information about soft-masked bases, you need to manually specify that:\n\n    \u003e\u003e\u003e tb = py2bit.open(\"test/foo.2bit\", True)\n\n## Access the list of chromosomes and the lengths\n\n`TwoBit` objects contain a dictionary holding the chromosome/contig lengths, which can be accessed with the `chroms()` method.\n\n    \u003e\u003e\u003e tb.chroms()\n    {'chr1': 150L, 'chr2': 100L}\n\nYou can directly access a particular chromosome by specifying its name.\n\n    \u003e\u003e\u003e tb.chroms('chr1')\n    150L\n\nThe lengths are stored as a \"long\" integer type, which is why there's an `L` suffix. If you specify a nonexistent chromosome then nothing is output.\n\n    \u003e\u003e\u003e tb.chroms(\"foo\")\n    \u003e\u003e\u003e\n\n## Print file information\n\nThe following information about and contained within a 2bit file can be accessed with the `info()` method:\n\n * file size, in bytes (`file size`)\n * number of chromosomes/contigs (`nChroms`)\n * total sequence length, in bases (`sequence length`)\n * total number of hard-masked (N) bases (`hard-masked length`)\n * total number of soft-masked (lower case) bases(`soft-masked length`).\n\nNote that `soft-masked length` will only be present if `open(\"file.2bit\", True)` is used, since handling soft-masking increases memory requirements and decreases perfomance.\n\n    \u003e\u003e\u003e tb.info()\n    {'file size': 161, 'nChroms': 2, 'sequence length': 250, 'hard-masked length': 150, 'soft-masked length': 8}\n\n## Fetch a sequence\n\nThe sequence of a full or partial chromosome/contig can be fetched with the `sequence()` method.\n\n    \u003e\u003e\u003e tb.sequence(\"chr1\")\n    'NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNACGTACGTACGTagctagctGATCGATCGTAGCTAGCTAGCTAGCTGATCNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN'\n\nBy default, the whole chromosome/contig is returned. A specific range can also be requested.\n\n    \u003e\u003e\u003e tb.sequence(\"chr1\", 24, 74)\n    NNNNNNNNNNNNNNNNNNNNNNNNNNACGTACGTACGTagctagctGATC\n\nThe first number is the (0-based) position on the chromosome/contig where the sequence should begin. The second number is the (1-based) position on the chromosome where the sequence should end.\n\nIf it was requested during file opening that soft-masking information be stored, then lower case bases may be present. If a nonexistent chromosome/contig is specified then a runtime error occurs.\n\n## Fetch per-base statistics\n\nIt's often required to compute the percentage of 1 or more bases in a chromosome. This can be done with the `bases()` method.\n\n    \u003e\u003e\u003e tb.bases(\"chr1\")\n    {'A': 0.08, 'C': 0.08, 'T': 0.08666666666666667, 'G': 0.08666666666666667}\n\nThis returns a dictionary with bases as keys and the fraction of the sequence composed of them as values. Note that this will not sum to 1 if there are any hard-masked bases (the chromosome is 2/3 `N` in this case). One can also request this information over a particular region.\n\n    \u003e\u003e\u003e tb.bases(\"chr1\", 24, 74)\n    {'A': 0.12, 'C': 0.12, 'T': 0.12, 'G': 0.12}\n\nThe start and end position are as with the `sequence()` method described above.\n\nIf integer counts are preferred, then they can instead be returned.\n\n    \u003e\u003e\u003e tb.bases(\"chr1\", 24, 74, False)\n    {'A': 6, 'C': 6, 'T': 6, 'G': 6}\n\n## Fetch masked blocks\n\nThere are two kinds of masking blocks that can be present in 2bit files: hard-masked and soft-masked. Hard-masked blocks are stretches of NNNN, as are commonly found near telomeres and centromeres. Soft-masked blocks are runs of lowercase A/C/T/G, typically indicating repeat elements or low-complexity stretches. In can sometimes be useful to query this information from 2bit files:\n\n    \u003e\u003e\u003e tb.hardMaskedBlocks(\"chr1\")\n    [(0, 50), (100, 150)]\n\nIn this (small) example, there are two stretches of hard-masked sequence, from 0 to 50 and again from 100 to 150 (see the note below about coordinates). If you would instead like to query all blocks overlapping with a specific region, you can specify the region bounds:\n\n    \u003e\u003e\u003e tb.hardMaskedBlocks(\"chr1\", 75, 101)\n    [(100, 150)]\n\nIf there are no overlapping regions, then an empty list is returned:\n\n    \u003e\u003e\u003e tb.hardMaskedBlocks(\"chr1\", 75, 100)\n    []\n\nInstead of `hardMaskedBlocks()`, one can use `softMaskedBlocks()` in an identical manner:\n\n    \u003e\u003e\u003e tb = py2bit.open(\"foo.2bit\", storeMasked=True)\n    \u003e\u003e\u003e tb.softMaskedBlocks(\"chr1\")\n    [(62, 70)]\n\nAs shown, you **must** specify `storeMasked=True` or you will receive a run time error.\n\n## Close a file\n\nA `TwoBit` object can be closed with the `close()` method.\n\n    \u003e\u003e\u003e tb.close()\n\n# A note on coordinates\n\n0-based half-open coordinates are used by this python module. So to access the value for the first base on `chr1`, one would specify the starting position as `0` and the end position as `1`. Similarly, bases 100 to 115 would have a start of `99` and an end of `115`. This is simply for the sake of consistency with most other bioinformatics packages.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeeptools%2Fpy2bit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeeptools%2Fpy2bit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeeptools%2Fpy2bit/lists"}