Skip to main content

A hashtable based counter implemented in CUDA for high throughput.

Project description

CuCounter: A Python kmer frequency counter object based on a massively parallel CUDA hash table

Installation

CuCounter requires NumPy and CuPy. It also currently only supports Nvidia GPUs with CUDA.

Cucounter can be installed using pip:

pip install kage-cucounter

.. or via manual installation:

  • clone the CuCounter repository
  • use pip to install all necessary dependencies as well as CuCounter from inside the cloned repository
git clone https://github.com/jorgenwh/cucounter.git
cd cucounter
pip install -r requirements.txt
pip install .

Usage

All of CuCounter's methods (including its constructor) will accept either NumPy or CuPy arrays. CuPy arrays are preferred as it circumvents having to copy memory back and fourth between the host and device. NumPy is used in the example below, but the same code would work if NumPy had been replaced with CuPy.

from cucounter import Counter
import numpy as np

# Create a static set of 100 million unique 64-bit encoded kmers as keys for the counter
unique_kmers = np.arange(100000000, dtype=np.uint64)

# Create counter object
counter = Counter(keys=unique_kmers)

# Create a chunk of 200 million kmers to count
kmers = np.random.randint(low=0, high=0xFFFFFFFFFFFFFFFF, size=(200000000,), dtype=np.uint64)

# Count the observed kmer frequencies. Kmers not present in the original key set are ignored
counter.count(kmers)

# Fetch the observed frequencies for the original key set
counts = counter[unique_kmers] 

counts.dtype # np.uint32
counts.shape # (100000000,)

CuCounter also supports counting the reverse complements of kmers aswell as the original kmer.

counter.count(kmers, count_revcomps=True)

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

kage-cucounter-1.0.1.tar.gz (9.7 kB view details)

Uploaded Source

File details

Details for the file kage-cucounter-1.0.1.tar.gz.

File metadata

  • Download URL: kage-cucounter-1.0.1.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.8.3 requests/2.28.1 setuptools/63.2.0 requests-toolbelt/0.10.1 tqdm/4.64.1 CPython/3.10.8

File hashes

Hashes for kage-cucounter-1.0.1.tar.gz
Algorithm Hash digest
SHA256 dfb717d07fe4bf66f0abd2252243d97cf9022177d6beb1cc862e90dc77342a1e
MD5 520346778c1c9c24a3d1742a420a3efa
BLAKE2b-256 03a7358922745d731df354f31cd32bbb6c18c980efe5590e0bedd5a84ca35fff

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