Skip to main content

Stage and load genomic ranges from disk.

Project description

Project generated with PyScaffold PyPI-Server Unit tests

Save and load genomic ranges objects to file

This package implements methods for saving and loading GenomicRanges and GenomicRangesList objects. It provides a language-agnostic method for serializing genomic coordinates in these objects, as well as data in related objects like sequence information. To get started, install the package from PyPI:

pip install dolomite-ranges

We can then save a GenomicRanges to a file, preserving its metadata and mcols:

import os
from tempfile import mkdtemp

from dolomite_base import read_object, save_object
from genomicranges import GenomicRanges
from iranges import IRanges
import dolomite_ranges

gr = GenomicRanges(
     seqnames=["chrA", "chrB", "chrC"],
     ranges=IRanges([10, 30, 2200], [20, 50, 30]),
     strand=["*", "+", "-"],
)

dir = os.path.join(mkdtemp(), "granges")
save_object(gr, dir)

roundtrip = read_object(dir)

Similarly save and load a GenomicRangesList to a file,

import os
from tempfile import mkdtemp

from dolomite_base import read_object, save_object
from genomicranges import GenomicRanges, SeqInfo
from iranges import IRanges
import dolomite_ranges

a = GenomicRanges(
     seqnames=["chr1", "chr2", "chr1", "chr3"],
     ranges=IRanges([1, 3, 2, 4], [10, 30, 50, 60]),
     strand=["-", "+", "*", "+"],
     mcols=BiocFrame({"score": [1, 2, 3, 4]}),
)

b = GenomicRanges(
     seqnames=["chr2", "chr4", "chr5"],
     ranges=IRanges([3, 6, 4], [30, 50, 60]),
     strand=["-", "+", "*"],
     mcols=BiocFrame({"score": [2, 3, 4]}),
)

grl = GenomicRangesList(ranges=[a, b], names=["a", "b"])

dir = os.path.join(mkdtemp(), "granges_list")
save_object(gr, dir)

roundtrip = read_object(dir)

Note

This project has been set up using PyScaffold 4.5. For details and usage information on PyScaffold see https://pyscaffold.org/.

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

dolomite-ranges-0.0.1a0.tar.gz (23.3 kB view details)

Uploaded Source

Built Distribution

dolomite_ranges-0.0.1a0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file dolomite-ranges-0.0.1a0.tar.gz.

File metadata

  • Download URL: dolomite-ranges-0.0.1a0.tar.gz
  • Upload date:
  • Size: 23.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for dolomite-ranges-0.0.1a0.tar.gz
Algorithm Hash digest
SHA256 1a65aeec5b6190a6bfa444470c5d80aad8ef5082477f3a9ab96ca768f30fc23d
MD5 e64769ab753b07be601d6c729cff2894
BLAKE2b-256 ea2f9c0815c54e37cf2aac8b5fca23e4e4e9d5302a85f0b29866867bb4c71983

See more details on using hashes here.

File details

Details for the file dolomite_ranges-0.0.1a0-py3-none-any.whl.

File metadata

File hashes

Hashes for dolomite_ranges-0.0.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 bf94d11a3bad29cb079cfa6acae4d1af1322d2d4a3bee599b312ce26044d1262
MD5 1d6acab935f05c61db31b0f6913dca4d
BLAKE2b-256 00f725a22b8e6aabd54d7e7d92aa3df8f40822419840d669b5b55cffe2810fcb

See more details on using hashes here.

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