dict_to_amino_acid_matrix sizes by len(d), so blosum62_matrix is 25×25 with zero padding

Open Beginner friendly
#60 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
numpy, python

Research direction

Start from dict_to_amino_acid_matrix in pepdata, where np.zeros is sized by len(d) while the fill loop iterates over alphabet. Check the shapes of blosum62_matrix and blosum30_matrix against blosum50_matrix and pmbec_matrix to confirm the padding. Change the allocation to len(alphabet), then verify the shapes and that the filled values are unchanged. Note that this changes two public array shapes, so a release note is needed.

Written by the indexing model from the issue text.

Description

def dict_to_amino_acid_matrix(d, alphabet=canonical_amino_acids):
    n_aa = len(d)
    result_matrix = np.zeros((n_aa, n_aa), dtype="float32")
    for i, aa_row in enumerate(alphabet):
        ...

The function sizes the matrix by the number of rows in d, but fills only len(alphabet) rows and columns (20 by default). BLOSUM62 has 25 rows (the 20 canonical residues plus B, J, Z, X and *) and BLOSUM30 has 24. On master a5dffe3:

array shape filled
blosum62_matrix (25, 25) rows/cols 20-24 are all 0
blosum30_matrix (24, 24) rows/cols 20-23 are all 0
blosum50_matrix (20, 20) all
pmbec_matrix (20, 20) all

The padding doesn't correspond to any residue, and 0 is a real BLOSUM score, so it reads like data. The shapes also differ between matrices that callers would expect to be interchangeable, for example as embeddings indexed by letter_to_index.

Fix. Size the matrix by len(alphabet). That changes the shape of two public arrays, so it is a behavior change and needs a release note. pirl-unc/weirdo has the same helper in weirdo/amino_acid_alphabet.py.

https://claude.ai/code/session_01JHJhwj29oDqoeu7TYd34Pi

Dominant language
Python
Stars
58
Forks
16
Avg merge
2d 12h
Merged PRs (30d)
3

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from openvax/pepdata

All issues in openvax/pepdata

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.