Skip to content

Library might not be working properly when debugging #19

@Bornlex

Description

@Bornlex

When debugging using Pycharm, the objects in the current context are displayed in the debugger window, which calls their str method.

The thing is the str method itself calls the align method, filling the _alseq1 and _alseq2 attributes.

So when we call the self.align manually, both attributes are filled a second time, which creates a bug.

We could make sure the attributes are empty by assigning them to empty lists at the beginning of the _trace_back_alignment method:

def _trace_back_alignment(self, irow: int, jcol: int) -> None:

        # FIX
        self._alseq1, self._alseq2 = [], []
        # !FIX

        while True:
            if self._pmatrix[irow][jcol] == "diag":
                self._alseq1.append(self.seq1[jcol - 1])
                self._alseq2.append(self.seq2[irow - 1])
                if self.seq1[jcol - 1] == self.seq2[irow - 1]:
                    self._identity += 1
                irow -= 1
                jcol -= 1
            elif self._pmatrix[irow][jcol] == "up":
                self._alseq1.append(Gap(self._gap_character))
                self._alseq2.append(self.seq2[irow - 1])
                irow -= 1
            elif self._pmatrix[irow][jcol] == "left":
                self._alseq1.append(self.seq1[jcol - 1])
                self._alseq2.append(Gap(self._gap_character))
                jcol -= 1
            else:
                break
        self._alseq1 = list(reversed(self._alseq1))
        self._alseq2 = list(reversed(self._alseq2))
        self._identity = (self._identity / len(self._alseq1)) * 100

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions