Skip to main content

blosum

A small module for easy access to BLOSUM matrices without dependencies.

DOI Test Badge Code style: black
Download Badge Python Version Badge install with bioconda

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.

Dependencies

In addition to packages included in Python 3, this piece of software uses 3rd-party software packages for development purposes that are not required in the published version. Go to DEPENDENCIES.md to see all dependencies and licenses.

Download files

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

Source Distribution

blosum-2.0.2.tar.gz (23.6 kB view details)

Uploaded Source

Built Distribution

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

blosum-2.0.2-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file blosum-2.0.2.tar.gz.

File metadata

  • Download URL: blosum-2.0.2.tar.gz
  • Upload date:
  • Size: 23.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for blosum-2.0.2.tar.gz
Algorithm Hash digest
SHA256 57ef60144432c15bbf96cf2d868d2025298cea791630e6b85697f7bf5cb8dfca
MD5 cdfd517c5f28ee9987b26e5337e65326
BLAKE2b-256 f7781eaa60e1f2b3bba0f22bb35c74a437dfc413a3e5077049b80a14746049a7

See more details on using hashes here.

File details

Details for the file blosum-2.0.2-py3-none-any.whl.

File metadata

  • Download URL: blosum-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for blosum-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 93301ad76f979736f86738fb27ba955c1604db64d93c4cc1b968ad95e32029c3
MD5 29506b122cf543e2a50f0d9740dbf0f4
BLAKE2b-256 3bc3fc1b010cd0d6914f35047f28521aac708f73489ed3cf204d7630852e2939

See more details on using hashes here.

Release history Release notifications | RSS feed

2.2.0

2 files

2.0.3

2 files

This release

2.0.2 This release

2 files

2.0.1

2 files

1.2.2

2 files

1.2.0

2 files

1.1.3

2 files

1.1.2

2 files

1.1.1

2 files

1.1.0

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page