A simple BLOSUM toolbox without dependencies.
Project description
A small module for easy access to BLOSUM matrices without dependencies.
The BLOcks SUbstitution Matrices (BLOSUM) are used to score alignments between protein sequences and are therefore mainly used in bioinformatics.
Reading such matrices is not particularly difficult, yet most off the shelf packages are overloaded with strange dependencies. And why do we need to implement the same reader again if there is a simple module for that.
blosum
offers a robust and easy-to-expand implementation without relying on third-party libraries.
Installation
Using pip / pip3:
pip install blosum
Or by source:
git clone git@github.com:not-a-feature/blosum.git
cd blosum
pip install .
Or by conda:
conda install blosum
How to use
Default BLOSUM
This package provides the most commonly used BLOSUM matrices. You can choose from BLOSUM 45, 50, 62, 80 and 90.
To load a matrix:
import blosum as bl
matrix = bl.BLOSUM(62)
val = matrix["A"]["Y"]
Custom matrix
In addition, own matrices can be loaded. For this, the path is given as an argument.
import blosum as bl
matrix = bl.BLOSUM("path/to/blosum.file")
val = matrix["A"]["Y"]
The matrices are required to have following format:
# Comments should start with #
# Each value should be seperated by one or many whitespace
A R N D
A 5 -2 -1 -2
R -2 7 0 -1
N -1 0 6 2
D -2 -1 2 7
Getting values:
Once loaded the matrix
behaves like a defaultdict
.
To get a value use:
val = matrix["A"]["Y"]
To get a defaultdict of the row with a given key use:
val_dict = matrix["A"]
If the key cannot be found, the default value float("-inf")
is returned.
It is possible to set a custom default score:
matrix = bl.BLOSUM(62, default=0)
License
Copyright (C) 2023 by Jules Kreuer - @not_a_feature
This piece of software is published unter the GNU General Public License v3.0 TLDR:
Permissions | Conditions | Limitations |
---|---|---|
✓ Commercial use | Disclose source | ✕ Liability |
✓ Distribution | License and copyright notice | ✕ Warranty |
✓ Modification | Same license | |
✓ Patent use | State changes | |
✓ Private use |
Go to LICENSE.md to see the full version.
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
Built Distribution
File details
Details for the file blosum-2.0.3.tar.gz
.
File metadata
- Download URL: blosum-2.0.3.tar.gz
- Upload date:
- Size: 23.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6fee68975c04211fc7c298f58cbf1e5b021ea2879e51456d934238e89ea2ae9b |
|
MD5 | 07a2db02dfb918c8b2003cf03c8af94a |
|
BLAKE2b-256 | 0256fd0a8887506b1d28662c240c589fbc143c6c0fb9c90bd118d1b7c5211c70 |
File details
Details for the file blosum-2.0.3-py3-none-any.whl
.
File metadata
- Download URL: blosum-2.0.3-py3-none-any.whl
- Upload date:
- Size: 21.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2903425cdc67424c65290d0a9b6c466ecb8df7e89b6a2a2530a9001164a3cbae |
|
MD5 | 075f37a9743165a46c5cab5c5f045d1b |
|
BLAKE2b-256 | 27dab7507be8843f88164fe7e24e18ccd9065fbc65135290f3434261c0057e37 |