Skip to main content

An HTS-specs compliant BED toolkit.

Project description

bedspec

PyPi Release CI Python Versions MyPy Checked Poetry Ruff

An HTS-specs compliant BED toolkit.

Installation

The package can be installed with pip:

pip install bedspec

Quickstart

Writing

from bedspec import BedWriter, Bed3

bed = Bed3("chr1", start=2, end=8)

with BedWriter(open("test.bed", "w")) as writer:
    writer.write(bed)

Reading

from bedspec import BedReader, Bed3

with BedReader[Bed3](open("test.bed")) as reader:
    for bed in reader:
        print(bed)
Bed3(contig="chr1", start=2, start=8)

BED Types

This package provides pre-defined 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 BedPE

Custom BED Types

To create a custom BED record, inherit from the relevent BED-type:

Type Description
PointBed BED records that are a single point (1-length) only.
SimpleBed BED records that are a single interval.
PairBed BED records that are a pair of intervals.

For example, to create a custom BED3+1 class:

from dataclasses import dataclass

from bedspec import SimpleBed

@dataclass
class MyCustomBed(SimpleBed):
    contig: str
    start: int
    end: int
    my_custom_field: float

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

bedspec-0.2.0.tar.gz (122.1 kB view hashes)

Uploaded Source

Built Distributions

bedspec-0.2.0-cp312-cp312-musllinux_1_1_x86_64.whl (333.2 kB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.1+ x86-64

bedspec-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux_2_5_x86_64.manylinux1_x86_64.manylinux2014_x86_64.whl (328.0 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

bedspec-0.2.0-cp312-cp312-macosx_12_0_x86_64.whl (110.0 kB view hashes)

Uploaded CPython 3.12 macOS 12.0+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page