A Python library for sequence search and analysis.
Project description
PySeqr
PySeqr is a Python library for sequence search and analysis.
Installation
pip install pyseqr
Usage
Basic Example
from pyseqr import find_in_list
# Basic: Find all occurrences of [1, 2] in a target list
occurrences = find_in_list([1, 2], [1, 3, 2, 1, 2])
print(occurrences)
# Example output: [[0, 2], [3, 4]]
# Using flags for gap logic:
# occurrence_gap = "any" or "non-negative"
# element_gap = "any" or "non-negative"
occurrences_with_flags = find_in_list(
sublist=[1, 2],
target=[1, 3, 1, 7, 2],
occurrence_gap="any",
element_gap="non-negative"
)
print(occurrences_with_flags)
# Example output: [[0, 4], [2, 4]]
Handling Unhashable Objects
from pyseqr.core import find_in_list
# If your sublist contains lists or dictionaries (normally unhashable),
# enable the "ensure_hashable" flag to convert them internally:
sublist = [1, [2, 3], 4]
target = [1, [2, 3], 4]
occurrences = find_in_list(
sublist, target,
ensure_hashable=True
)
print(occurrences)
# Example output: [[0, 1, 2]]
Handling Custom Objects
class CustomStrObject:
def __init__(self, value):
self.value = value
def __str__(self):
return f"CustomStrObject({self.value})"
from pyseqr.core import find_in_list
obj1 = CustomStrObject(1)
obj2 = CustomStrObject(2)
result = find_in_list(
sublist=[obj1, obj2],
target=[obj1, obj2, obj1],
use_custom_str=True
)
print(result)
# Example output: [[0, 1]]
Float Precision Matching
from pyseqr.core import find_in_list
# If you have floating-point numbers and want to match them at a certain precision:
sublist = [1.111, 2.222, 3.333]
target = [1.1111, 2.2222, 3.3333]
occurrences = find_in_list(
sublist, target,
float_precision=3
)
print(occurrences)
# Example output: [[0, 1, 2]]
Development Setup
Use pipenv to install dependencies:
pipenv install --dev
pipenv shell
Then you can run tests using pytest:
pytest
Contributing
- Fork and clone this repository.
- Create a feature branch for your changes.
- Install dependencies using Pipenv.
- Run tests (pytest) and ensure everything passes.
- Submit a Pull Request describing your changes.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyseqr-1.0.0.dev1.tar.gz
(13.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyseqr-1.0.0.dev1.tar.gz.
File metadata
- Download URL: pyseqr-1.0.0.dev1.tar.gz
- Upload date:
- Size: 13.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9e58def8c821717f9adba10c885b921b6c029730d7417b6ceec21a6579bbe9e
|
|
| MD5 |
580f7877cc78c5afbbb9546052c10c6d
|
|
| BLAKE2b-256 |
7c075bf7d32058622f068be6fe29de817602fac2ce41d8594e17c56cfacae1fe
|
File details
Details for the file pyseqr-1.0.0.dev1-py3-none-any.whl.
File metadata
- Download URL: pyseqr-1.0.0.dev1-py3-none-any.whl
- Upload date:
- Size: 14.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60a33a689fe6ff9f79be2e1975f002503f9b1aea8a6fd7d50e112787521e81d2
|
|
| MD5 |
17b13b070657d419e86b0b33d6f090ae
|
|
| BLAKE2b-256 |
d8a2412391a73d93410d9ff6a72d50543418054d66c3161a02a013b994b25b7a
|