An HTS-specs compliant BED toolkit.
Project description
bedspec
An HTS-specs compliant BED toolkit.
Installation
The package can be installed with pip
:
pip install bedspec
Quickstart
Building a BED Feature
>>> from bedspec import Bed3
>>>
>>> bed = Bed3("chr1", start=2, end=8)
Writing
>>> from bedspec import BedWriter
>>> from tempfile import NamedTemporaryFile
>>>
>>> temp_file = NamedTemporaryFile(mode="w+t", suffix=".txt")
>>>
>>> with BedWriter.from_path(temp_file.name, Bed3) as writer:
... writer.write(bed)
Reading
>>> from bedspec import BedReader
>>>
>>> with BedReader.from_path(temp_file.name, Bed3) as reader:
... for bed in reader:
... print(bed)
Bed3(refname='chr1', start=2, end=8)
BED Types
This package provides builtin classes for the following BED formats:
>>> from bedspec import Bed2
>>> from bedspec import Bed3
>>> from bedspec import Bed4
>>> from bedspec import Bed5
>>> from bedspec import Bed6
>>> from bedspec import Bed12
>>> from bedspec import BedGraph
>>> from bedspec import BedPE
Overlap Detection
Use a fast overlap detector for any collection of interval types, including third-party:
>>> from bedspec import Bed3, Bed4
>>> from bedspec.overlap import OverlapDetector
>>>
>>> bed1 = Bed3("chr1", start=1, end=4)
>>> bed2 = Bed3("chr1", start=5, end=9)
>>>
>>> detector = OverlapDetector[Bed3]([bed1, bed2])
>>>
>>> my_feature = Bed4("chr1", start=2, end=3, name="hi-mom")
>>> detector.overlaps(my_feature)
True
The overlap detector supports the following operations:
overlapping
: return all overlapping featuresoverlaps
: test if any overlapping features existenclosed_by
: return those enclosed by the input featureenclosing
: return those enclosing the input feature
Custom BED Types
To create a custom BED record, inherit from the relevant BED-type (PointBed
, SimpleBed
, PairBed
).
For example, to create a custom BED3+1 class:
>>> from dataclasses import dataclass
>>>
>>> from bedspec import SimpleBed
>>>
>>> @dataclass(eq=True)
... class Bed3Plus1(SimpleBed):
... refname: str
... start: int
... end: int
... my_custom_field: float | None
Development and Testing
See the contributing guide for more information.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file bedspec-0.3.0.tar.gz
.
File metadata
- Download URL: bedspec-0.3.0.tar.gz
- Upload date:
- Size: 125.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0d59dce40f65f9d2e37b28544c73bd1b092856286525296ea0cf33ad60d8c54 |
|
MD5 | c0b8a0eeccea5f7c93dd9ac6237e616e |
|
BLAKE2b-256 | 0c8a3ec1f72c23baa95bac66b7a85cbceb281eca12a134a939a43908a30b3439 |
Provenance
The following attestation bundles were made for bedspec-0.3.0.tar.gz
:
Publisher:
publish_bedspec.yml
on clintval/bedspec
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
bedspec-0.3.0.tar.gz
- Subject digest:
b0d59dce40f65f9d2e37b28544c73bd1b092856286525296ea0cf33ad60d8c54
- Sigstore transparency entry: 147695211
- Sigstore integration time:
- Predicate type:
File details
Details for the file bedspec-0.3.0-cp312-cp312-musllinux_1_1_x86_64.whl
.
File metadata
- Download URL: bedspec-0.3.0-cp312-cp312-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 336.8 kB
- Tags: CPython 3.12, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 088254a9fb6abb16d17570f987e5b488c89242b0fc37e6cf48c95d48bee764d1 |
|
MD5 | 61dff861dc18aeb5de5a621b1eb22da3 |
|
BLAKE2b-256 | b337ea8722769749646e088f075cbbc856593a77cb2085c97abecf34f8f73464 |
Provenance
The following attestation bundles were made for bedspec-0.3.0-cp312-cp312-musllinux_1_1_x86_64.whl
:
Publisher:
publish_bedspec.yml
on clintval/bedspec
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
bedspec-0.3.0-cp312-cp312-musllinux_1_1_x86_64.whl
- Subject digest:
088254a9fb6abb16d17570f987e5b488c89242b0fc37e6cf48c95d48bee764d1
- Sigstore transparency entry: 147695212
- Sigstore integration time:
- Predicate type:
File details
Details for the file bedspec-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux_2_5_x86_64.manylinux1_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: bedspec-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux_2_5_x86_64.manylinux1_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 331.6 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e7c6a1a6b1ae6c23d5d8f1c7e6ef0b72372b594c4b769966541676ceaabed75 |
|
MD5 | ea02d16f24b37e69b03997446b5bec59 |
|
BLAKE2b-256 | 68e2169469c042b628d1d8fd855a32c9854c435285103833a6cd1128a377915d |
Provenance
The following attestation bundles were made for bedspec-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux_2_5_x86_64.manylinux1_x86_64.manylinux2014_x86_64.whl
:
Publisher:
publish_bedspec.yml
on clintval/bedspec
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
bedspec-0.3.0-cp312-cp312-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl
- Subject digest:
4e7c6a1a6b1ae6c23d5d8f1c7e6ef0b72372b594c4b769966541676ceaabed75
- Sigstore transparency entry: 147695213
- Sigstore integration time:
- Predicate type:
File details
Details for the file bedspec-0.3.0-cp312-cp312-macosx_14_0_arm64.whl
.
File metadata
- Download URL: bedspec-0.3.0-cp312-cp312-macosx_14_0_arm64.whl
- Upload date:
- Size: 113.9 kB
- Tags: CPython 3.12, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eee524cffab5bc8f3451fa5c9f55296510278ad3513b019cbd05eb30da592a15 |
|
MD5 | 7404732b887bd603289cb83bc5b70d48 |
|
BLAKE2b-256 | ce9a21d5e2d8e1508136a1e7cff76d6e902caa0cf5aca18d8a45dffbc586628b |
Provenance
The following attestation bundles were made for bedspec-0.3.0-cp312-cp312-macosx_14_0_arm64.whl
:
Publisher:
publish_bedspec.yml
on clintval/bedspec
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
bedspec-0.3.0-cp312-cp312-macosx_14_0_arm64.whl
- Subject digest:
eee524cffab5bc8f3451fa5c9f55296510278ad3513b019cbd05eb30da592a15
- Sigstore transparency entry: 147695215
- Sigstore integration time:
- Predicate type: