Skip to main content

No project description provided

Project description

Vizibridge

This module is a maturin bridge between the rust crate vizicomp containing compiled code for efficient genomic data manipulation in the Python module Vizitig

How to install vizibridge

The simplest way is to use pip as vizibridge is deploy in Pypi:

pip install vizibridge

Alternative, download the wheel from the latest release obtained from gitlab

In the case where your architecture/systems is not presents, it is possible to compile it locally as well as follows.

First install the rust tool chain and then run

cargo install maturin
maturin build --release

To install the module in your python then run

pip install target/wheels/vizibridge**.whl

replacing ** by the appropriate name generated in the folder.

How-to modifiate this https://gitlab.inria.fr/cpaperma/vizibridge/-/releases/permalink/latestmodule

The CI/CD takes care to compiling everything so you can simply push the content to create a new compiled module. To publish to Pypi, simply push a release tag:

git tag -d vx -m "Some description of the release to broadcast
git push origin vx 

Here vx is the version number that should be sync with the version declared in the Cargo.toml.

What should be here

The actual computing content should never been performed within this repo but always either in vizicomp repo or through another repo that we would like to have exposed in the Python ecosystem. This repo is solely dedicated to performing the bridge without polluting efficient standalone Rust tooling.

Quick documentation of Python API

The Python Interface is composed of several component:

Base type

DNA type (vizibridge.DNA)

DNA is a Python class wrapper around vizibrdge.rust_DNA which is an encoding of DNA-string in rust. The underlying data-layout is simply using 2bits per nucleotid. The buildup of a DNA type from a string is roughly 1 Gbyte/s.

Its main purpose is to provide a way to enumerate Kmer efficiently through enum_kmer and enum_canonical_kmer methods. It can also be convert back to a string.

from vizibridge import DNA
dna = DNA("ACGT"*10)
print(dna)
# display: ACGTACGTACGTACGTACGTACGTACGTACGTACGTACGT
print(repr(next(dna.enum_canonical_kmer(4))))
# display: 4-mer(ACGT)

Kmer types (vizibridge.Kmers)

Two kind of type are defined in the rust code: ShortKmer and LongKmer. ShortKmer encode Kmer on 64bits integers while LongKmer uses 128bit integer. Each type came with its own compile code, so we have 64 different rust based KmerType.

The Python module help with a class wrapper that provide a common interface: vizibridge.Kmer. The building of a Kmer must go through DNA class.

from vizibridge import Kmer, DNA
kmer = Kmer.from_DNA(DNA("ACGT")) # a 4-Kmer
print(repr(kmer))
# display: 4-mer(ACGT)

The underlying integer can be found in the data field which is used to compute hash value for the Kmer.

print(kmer.data)
# display: 27 

Carefull, the hash is based uniquely on the integer content, so two kmer of distinct size can have the same integer encoding and thus the same hash.

kmer2 = Kmer.from_DNA(DNA("AAACGT"))
assert hash(kmer) == hash(kmer2)

Kmers can be convert to string, are hashable, and we can build another Kmer by appending left or right nucleotid.

print(repr(kmer))
# display: 4-mer(ACGT)
kmer3 = kmer.add_left_nucleotid('A')
print(repr(kmer3)
# display: 4-mer(AACG)
kmer4 = kmer3.add_left_nucleotid('A')
print(repr(kmer4)
# display: 4-mer(AAAG)

Index types

Index are either:

  • KmerIndex: sorted arrays of pairs (Kmer, integer) where the integers are 32bits unsigned integers.
  • KmerSet: sorted arrays of Kmer.

The filter out dupplicate, KmerSet have a set semantic and KmerIndex have a mapping semantic. They must be provided with a path toward a file for storing the index. Underthehood, the index are simply sorted array and memory map file. Carefull, memory map are not always portable (to check carefully on Windows).

Two method exists to build an KmerIndex:

  • build: take an iterate over a KmerIndexEntry (a dataclass with two field, kmer and value)
  • build_dna: take an iterate over a DNAIndexEntry (a dataclass with two fields, dna and value).

The build_dna unfold each DNA-value into kmer through enum_canonical_kmer methods. It is more efficient to use when you can associate all Kmer of a DNA sequence to one value. On the top of that, build_dna take two integer to filter-out some kmer with respect to their value modulo something. This is usefull when dispatching Kmer amongs several Shard.

Here a small example of usage.

from vizibridge import DNA
some_kmer = list(DNA("ACGT").enum_canonical_kmer(2))
d = { kmer: i for i, kmer in enumerate(some_kmer) }
print(d)
# display: {2-mer(AC): 2, 2-mer(CG): 1}
# We have only two kmer because AC occurs twice, in position 0 and 2

from vizibridge import KmerIndex, KmerIndexEntry
from pathlib import Path
index = KmerIndex.build((KmerIndexEntry(kmer=k, val=i) for i,k in enumerate(some_kmer)), Path("/tmp/some_path"), 2) # 2 is the kmer-size
print(index[some_kmer[1]])
# display: 1

print(dict(index))
# display: {2-mer(AC): 2, 2-mer(CG): 1}

KmerSet follows the same principle, except it have a Set semantic (hence no value associated to Kmer)

s = set(some_kmer)
print(s)
# display: {2-mer(AC), 2-mer(CG)}

from vizibridge import KmerSet
from pathlib import Path
index = KmerSet.build(iter(some_kmer), Path("/tmp/some_other_path"), 2) # 2 is the kmer-size
print(some_kmer[1] in index)
# display: True

print(set(index))
# display: {2-mer(AC), 2-mer(CG)}

TODO

  • Add in the CI/CD windows and MacOS compilations
  • Integrate ggcat binding
  • Other tools?

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

vizibridge-0.4.5-cp313-cp313-manylinux_2_34_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

vizibridge-0.4.5-cp312-cp312-manylinux_2_34_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

vizibridge-0.4.5-cp311-cp311-manylinux_2_34_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

vizibridge-0.4.5-cp310-cp310-manylinux_2_34_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

vizibridge-0.4.5-cp39-cp39-manylinux_2_34_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

File details

Details for the file vizibridge-0.4.5-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for vizibridge-0.4.5-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 70fe0624dd0f69e5e2b9abac1a89e8c1a242e9620e89cca3bf30fe09e78955c5
MD5 0c6bb47d5081a4d634b7919000625e99
BLAKE2b-256 046cd0b1bf6de4b40951fc847ca15625c428ea35dea64c824f49b306a07fce62

See more details on using hashes here.

File details

Details for the file vizibridge-0.4.5-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for vizibridge-0.4.5-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 c0174b63639fcda51f78e412375838f03ef7f1028d8dc801e8ec02bd97bb018e
MD5 2aa42cd358e116d3105a7df609cae3b0
BLAKE2b-256 89089c2705060f055456a3b7e315c411cd934aa1890e11e54c354f696f13eb10

See more details on using hashes here.

File details

Details for the file vizibridge-0.4.5-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for vizibridge-0.4.5-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 1b4eb69ff3c68b02ec9f005b1f57b88cb92f83ef4f104b043e473f02c3470efa
MD5 cb68fe715722ae547efe5fffe475f655
BLAKE2b-256 7c2d1f46b912bb4f20ab27e4fe0a9ddb3d18d549e78b62dd3fe0ca8d2d65da50

See more details on using hashes here.

File details

Details for the file vizibridge-0.4.5-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for vizibridge-0.4.5-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 be0081b2333ea64b6108c771b0a712c5b53415e50c018c224acd423dd7de62d0
MD5 2248c7a53caed83c718502bdca08e293
BLAKE2b-256 c945552f4d49b09842868f183cab8c6984497d7b3684b08891ddb14ed9499fd0

See more details on using hashes here.

File details

Details for the file vizibridge-0.4.5-cp39-cp39-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for vizibridge-0.4.5-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 3c2a22f588c6f8541e723da5dbaddd71fe58e916f8b02ec9b755af5f1646dbe7
MD5 e835e4f2b119c9439585a16c3874d3b9
BLAKE2b-256 a0b45fe621a78edd4297ed02625c7a5d19ce7cfe1ebd0b3fac3654f9baf39512

See more details on using hashes here.

Supported by

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