This release is a pre-release and may not be stable for production use.
dinuc_shuf
This Python package provides a minimal and efficient implementation for performing dinucleotide shuffles on one-hot-encoded sequences.
Dinucleotide shuffling preserves the dinucleotide (nucleotide pair) frequencies of the input sequence while randomizing the order of the pairs. This is particularly useful for generating random sequences that match the compositional properties of the original input.
To ensure a uniform random sample from all possible shuffles, the algorithm leverages the rank-one-update Kirchhoff matrix method described by Colburn et al. for sampling random arborescences, combined with a random Eulerian walk on the dinucleotide transition graph. The core algorithm is implemented in Rust for performance, with Python bindings for easy integration.
This package is lightweight, requiring only a single dependency on Numpy.
Installation
To install the package from PyPI, run:
pip install dinuc-shuf
Usage
import numpy as np
from dinuc_shuf import shuffle
SEQ_ALPHABET = np.array(["A","C","G","T"], dtype="S1")
def one_hot_encode(sequence, dtype=np.uint8):
sequence = sequence.upper()
seq_chararray = np.frombuffer(sequence.encode('UTF-8'), dtype='S1')
one_hot = (seq_chararray[:,None] == SEQ_ALPHABET[None,:]).astype(dtype)
return one_hot
def one_hot_decode(one_hot):
return SEQ_ALPHABET[one_hot.argmax(axis=1)].tobytes().decode('UTF-8')
sequence = "ACCCACGATGATG"
one_hot_sequence = one_hot_encode(sequence)
shuffled_one_hot = shuffle(one_hot_sequence[None,:,:])
shuffled = one_hot_decode(shuffled_one_hot[0,:,:])
print(shuffled) # Output: "ACATGATGACCCG"
API Reference
A full API reference is available here.
Metadata
Release files for dinuc-shuf 0.1.0b1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dinuc_shuf-0.1.0b1.tar.gz | 25.7 kB | Details |
Built distributions (wheels)
Total release size: 5.5 MB
Release files / dinuc_shuf-0.1.0b1.tar.gz
| Download URL | dinuc_shuf-0.1.0b1.tar.gz |
|---|---|
| Size | 25.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f66e6227579c662d4b5afe16dd0ebc946f0b5632cd3289f0c2df02455c2b593a
|
|
BLAKE2b-256 checksum How to use checksums |
a21b07fb627832be609e480b94f27202b9119c75fa6951b86621ff5bc903eb27
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.8.1
|
Release files / dinuc_shuf-0.1.0b1-cp38-abi3-win_amd64.whl
| Download URL | dinuc_shuf-0.1.0b1-cp38-abi3-win_amd64.whl |
|---|---|
| Size | 220.3 kB |
| Tags | CPython 3.8 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
5909b83cd36ffd706c2155034aadc18583e25f5f063126781f18bcafec8e1f75
|
|
BLAKE2b-256 checksum How to use checksums |
4a839a286f24241ac8f649df061db899baac4bdb48d2d4d3f7defb9e03ffa1e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.8.1
|
Release files / dinuc_shuf-0.1.0b1-cp38-abi3-win32.whl
| Download URL | dinuc_shuf-0.1.0b1-cp38-abi3-win32.whl |
|---|---|
| Size | 204.2 kB |
| Tags | CPython 3.8 Windows x86-32 abi3 |
|
SHA-256 checksum How to use checksums |
420e65e2753ffb425003cdbb265129052fca600298e7632aea46850a3a4ae754
|
|
BLAKE2b-256 checksum How to use checksums |
06306eaca95f79e43244c745401d87a35cc81bb336ce6ec1061f8a3d8717ccab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.8.1
|
Release files / dinuc_shuf-0.1.0b1-cp38-abi3-musllinux_1_2_x86_64.whl
| Download URL | dinuc_shuf-0.1.0b1-cp38-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 530.9 kB |
| Tags | CPython 3.8 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
1f303ba0226242d87926498343777603c6f1816683c4fa2b82192f861b170d94
|
|
BLAKE2b-256 checksum How to use checksums |
cf88cf17515dadbde6885b1643eb1ebdc8bd06267cd7d47563cfa25c0cc91fa9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.8.1
|
Release files / dinuc_shuf-0.1.0b1-cp38-abi3-musllinux_1_2_i686.whl
| Download URL | dinuc_shuf-0.1.0b1-cp38-abi3-musllinux_1_2_i686.whl |
|---|---|
| Size | 552.6 kB |
| Tags | CPython 3.8 Linux musl 1.2+ x86-32 abi3 |
|
SHA-256 checksum How to use checksums |
7415ad470990d9fa5f2c321a9a942dbb428965f461fefb2212950d92ff3f42b5
|
|
BLAKE2b-256 checksum How to use checksums |
17b43fe4e52a8f3186c68ccf7555ef1fa61f42b970cb25a6c564de47143c8ef1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.8.1
|
Release files / dinuc_shuf-0.1.0b1-cp38-abi3-musllinux_1_2_armv7l.whl
| Download URL | dinuc_shuf-0.1.0b1-cp38-abi3-musllinux_1_2_armv7l.whl |
|---|---|
| Size | 598.9 kB |
| Tags | CPython 3.8 Linux musl 1.2+ ARMv7l abi3 |
|
SHA-256 checksum How to use checksums |
53cd6850b39d3baca67e94e906ad1bb6679f1ae2e1c1bf2b217e15ac104de664
|
|
BLAKE2b-256 checksum How to use checksums |
b084237fd02b3709ca5995edecd9f9ce1e8e7515347170b6b8186ea5783d5d81
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.8.1
|
Release files / dinuc_shuf-0.1.0b1-cp38-abi3-musllinux_1_2_aarch64.whl
| Download URL | dinuc_shuf-0.1.0b1-cp38-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 511.3 kB |
| Tags | CPython 3.8 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
2f33bb3bc1cb07caaafb1114e6641ae1dc694614e4563ffb138718ec340c4913
|
|
BLAKE2b-256 checksum How to use checksums |
6f9c3a50f4a1cd70609db150ae9c0b940a0b1bae38ac84887ebd042329ce9579
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.8.1
|
Release files / dinuc_shuf-0.1.0b1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | dinuc_shuf-0.1.0b1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 368.6 kB |
| Tags | CPython 3.8 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
e0956ad25ccd2c072413e4975b3f58f7a2965d9605e2268cc345d35168f56ed1
|
|
BLAKE2b-256 checksum How to use checksums |
a3e316bd2cc9ab2fe458560f8ef7cef513fb5914c70bfd3432c3454e27ae0018
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.8.1
|
Release files / dinuc_shuf-0.1.0b1-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
| Download URL | dinuc_shuf-0.1.0b1-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl |
|---|---|
| Size | 395.0 kB |
| Tags | CPython 3.8 Linux glibc 2.17+ IBM System/390x abi3 |
|
SHA-256 checksum How to use checksums |
3abeba621a4245b3fd9dd2201870ca65904a6bf655b965f394e478ae31cddd9c
|
|
BLAKE2b-256 checksum How to use checksums |
8b01e346bed2f6e55ef8c340822332d3bdb9bd893e5acc35c42770cab5154e9f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.8.1
|
Release files / dinuc_shuf-0.1.0b1-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
| Download URL | dinuc_shuf-0.1.0b1-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl |
|---|---|
| Size | 432.9 kB |
| Tags | CPython 3.8 Linux glibc 2.17+ PowerPC 64-le abi3 |
|
SHA-256 checksum How to use checksums |
faee4a838d49d2020645b67d93166b6bb47541b2abfe53c9c1fbf1b5bef18064
|
|
BLAKE2b-256 checksum How to use checksums |
17e5773fc64381b9d3a973ac24827e2e529dc8d7764ff78573cd7b4aad7f92c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.8.1
|
Release files / dinuc_shuf-0.1.0b1-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
| Download URL | dinuc_shuf-0.1.0b1-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl |
|---|---|
| Size | 345.0 kB |
| Tags | CPython 3.8 Linux glibc 2.17+ ARMv7l abi3 |
|
SHA-256 checksum How to use checksums |
1b075cc303f6ba0109c5574aab820bac0de9923c70fbdd964603598cbfbda319
|
|
BLAKE2b-256 checksum How to use checksums |
00952fc86582c6dcd414f7edac3010d23bd85f8030a2d6ede154714005bec77f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.8.1
|
Release files / dinuc_shuf-0.1.0b1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | dinuc_shuf-0.1.0b1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 339.0 kB |
| Tags | CPython 3.8 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
361267a8b194c9485dfe080302b7056c51661b9d2a4fc4e4611870f6a153ddd7
|
|
BLAKE2b-256 checksum How to use checksums |
e2406601cbb71d82a82f1d7a91a3156c28162c7915eb9f51adde0ff9cba8a24f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.8.1
|
Release files / dinuc_shuf-0.1.0b1-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl
| Download URL | dinuc_shuf-0.1.0b1-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl |
|---|---|
| Size | 381.7 kB |
| Tags | CPython 3.8 Linux glibc 2.5+ x86-32 abi3 |
|
SHA-256 checksum How to use checksums |
bb7a8cf11cec44fc3a56efeec2c40963c9d2ce0222940ec66184f89a9493d063
|
|
BLAKE2b-256 checksum How to use checksums |
1511176b76aefe2ce605a19db677b3bb0a78b52eb53d993ae1aff0d69d02d486
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.8.1
|
Release files / dinuc_shuf-0.1.0b1-cp38-abi3-macosx_11_0_arm64.whl
| Download URL | dinuc_shuf-0.1.0b1-cp38-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 305.4 kB |
| Tags | CPython 3.8 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
23dad1bc4f0af3daea3d3c9c01596531937dc035381b1782841f8c7578721197
|
|
BLAKE2b-256 checksum How to use checksums |
99e9fc708a83875c1dbf4bbf41d48583c1bba89669d640cacb4bc1a702b32071
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.8.1
|
Release files / dinuc_shuf-0.1.0b1-cp38-abi3-macosx_10_12_x86_64.whl
| Download URL | dinuc_shuf-0.1.0b1-cp38-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 337.6 kB |
| Tags | CPython 3.8 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
af99c3a9057736ca882a1866d6482e31dda90b1937ca100dd53583c72f3093ea
|
|
BLAKE2b-256 checksum How to use checksums |
b75cddf9a9ae9d1467bffbeb2556829b028e6d9ad0afc48a29acda71f7bd05b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.8.1
|