Skip to content

Error while trying to set custom matrix #3658

Closed

Description

@StephaneKazmierczak

Setup

3.8.10 (default, Jun 4 2021, 15:09:15)
[GCC 7.5.0]
CPython
Linux-5.10.16.3-microsoft-standard-WSL2-x86_64-with-glibc2.17
1.79

Expected behaviour

this code from the documentation to set a custom matrix return an error

matrix = {('A','A'): 1.0, ('A','B'): -1.0, ('B','B'): 2.0}
aligner.substitution_matrix = matrix
   2245             raise AttributeError("'PairwiseAligner' object has no attribute '%s'" % key)
-> 2246         _aligners.PairwiseAligner.__setattr__(self, key, value)
   2247 
   2248     def align(self, seqA, seqB, strand="+"):

ValueError: expected a matrix

Actual behaviour

should return no error

Steps to reproduce

run the snippet from documentation after installing latest version

Activity

  1. mdehoon commented on Jul 7, 2021

    @mdehoon
    Contributor

    @StephaneKazmierczak Where do you find this in the documentation?

  2. mdehoon commented on Jul 7, 2021

    @mdehoon
    Contributor

    I found it here:

    https://biopython.readthedocs.io/en/latest/chapter_align.html

    However, this is pointing to an outdated version of the documentation. If you follow the "Edit on GitHub" at the top, it will take you to https://github.com/biopython/biopython/blob/sphinx/Doc/chapter_align.rst which apparently was last updated on July 31, 2019 by @peterjc .

  3. peterjc commented on Jul 7, 2021

    @peterjc
    Member
  4. peterjc commented on Jul 7, 2021

    @peterjc
    Member
  5. mdehoon commented on Jul 8, 2021

    @mdehoon
    Contributor

    @StephaneKazmierczak With recent versions of Biopython, you would use

    from Bio.Align import substitution_matrices
    matrix = substitution_matrices.Array(data={('A','A'): 1.0, ('A','B'): -1.0, ('B','B'): 2.0})
    aligner.substitution_matrix = matrix
  6. StephaneKazmierczak commented on Jul 11, 2021

    @StephaneKazmierczak
    Author

    Thank you guys for the explanations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions