Skip to main content

A small example package

Project description

XT-neighbor-cpu

Description

This is a wrapper Python package for calling SymDel algorithm which is used in finding nearest neighbors of AIRR sequence used in immunological applications. It is mentioned in XTNeighbor paper and has its actual implementation in Pyrepseq package.

Installation

pip install xt-neighbor-cpu

Quick Usage

from xt_neighbor_cpu import nearest_neighbor

seqs = ['CAA', 'CAD', 'CDA', 'CKK']
distance_threshold = 1
result = nearest_neighbor(seqs, distance_threshold)
# return [ (0,1,1), (0,2,1) ]
# where each triplet (i,j,d) represents the sequence index i,j and their edit distance d.

Documentation

"""
    List all neighboring sequences efficiently within the given distance using SymDel algorithm.
    That is, given a list of AIRR sequences and edit distance threshold, find all pairs of sequences that have their edit distance smaller or equal to the threshold.

    If seqs2 is not provided, every sequences are compared against every other sequences resulting in N(seqs)**2 combinations.
    Otherwise, seqs are compared against seqs2 resulting in N(seqs)*N(seqs2) combinations.

    For more information, see https://arxiv.org/abs/2403.09010.

    Parameters
    ----------
    seqs : iterable of strings
        list of CDR3B sequences
    max_edits : int
        maximum edit distance defining the neighbors
    max_returns : int or None
        maximum neighbor size
    custom_distance : Function(str1, str2) or "hamming"
        custom distance function to use, must statisfy 4 properties of distance (https://en.wikipedia.org/wiki/Distance#Mathematical_formalization)
    max_custom_distance : float
        maximum distance to include in the result, ignored if custom distance is not supplied
    output_type: string
        format of returns, can be "triplets", "coo_matrix", "ndarray"
    seq2 : iterable of strings or None
        another list of CDR3B sequences to compare against
    progress : bool
        show progress bar

    Returns
    -------
    neighbors : array of 3D-tuples, sparse matrix, or dense matrix
        neigbors along with their edit distances according to the given output_type
        if "triplets" returns are [(x_index, y_index, edit_distance)]
        if "coo_matrix" returns are scipy's sparse matrix where C[i,j] = distance(X_i, X_j) or 0 if not neighbor
        if "ndarray" returns numpy's 2d array representing dense matrix
    """

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

xt_neighbor_cpu-0.0.3.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

xt_neighbor_cpu-0.0.3-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file xt_neighbor_cpu-0.0.3.tar.gz.

File metadata

  • Download URL: xt_neighbor_cpu-0.0.3.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.7

File hashes

Hashes for xt_neighbor_cpu-0.0.3.tar.gz
Algorithm Hash digest
SHA256 a374438e5867cc3aaf4cd1735e3c30acf06e9ece51ae9697497221b6f489e93b
MD5 3701bfcc33c3ad1464bad466fb95fa4f
BLAKE2b-256 18038c5c1e9d2aeeb0d60f463bc390602a7e85b7c7cc59b99810eb18169b2450

See more details on using hashes here.

File details

Details for the file xt_neighbor_cpu-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for xt_neighbor_cpu-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2e185015b62414e99d2f606b45656644e4f9c26353dfa80c894a33640bbeac9c
MD5 5f2714fe860fde330ff7bdb2f9b14c38
BLAKE2b-256 678d98a32856b35ae1c10119f197ed260ee7ba03a8d322bb5b25fca0654deb0f

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