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.
/not-a-feature/blosum /project/blosum
Installation
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:
Custom matrix
In addition, own matrices can be loaded. For this, the path is given as an argument.
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:
To get a defaultdict of the row with a given key use:
If the key cannot be found, the default value float("-inf")
is returned.
It is possible to set a custom default score: