Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "unkown Bio" error in MotifPssmPattern #90

Merged
merged 3 commits into from
Nov 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions dnachisel/SequencePattern/MotifPssmPattern.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from Bio.Seq import Seq
from Bio import motifs
from Bio.Align.AlignInfo import PSSM
from .SequencePattern import SequencePattern
import numpy as np

Expand Down Expand Up @@ -29,10 +28,8 @@ class MotifPssmPattern(SequencePattern):
sequence(s) with the absolute highest possible score".
"""

def __init__(
self, pssm, threshold=None, relative_threshold=None,
):
if not isinstance(pssm, Bio.motifs.Motif):
def __init__(self, pssm, threshold=None, relative_threshold=None):
if not isinstance(pssm, motifs.Motif):
raise ValueError(
f"Expected PSSM type of `Bio.motifs.Motif`, but {type(pssm)} was passed"
)
Expand Down Expand Up @@ -70,7 +67,7 @@ def find_matches_in_string(self, sequence):
# sequence, threshold=self.threshold, both=False
# )
indices = find_pssm_matches_with_numpy(
pssm_matrix=self.pssm_matrix, sequence=sequence, threshold=self.threshold,
pssm_matrix=self.pssm_matrix, sequence=sequence, threshold=self.threshold
)
return [(i, i + self.size, 1) for i in indices]

Expand Down Expand Up @@ -115,7 +112,7 @@ def from_sequences(
motif.name = name
pssm = motif
return MotifPssmPattern(
pssm=pssm, threshold=threshold, relative_threshold=relative_threshold,
pssm=pssm, threshold=threshold, relative_threshold=relative_threshold
)

@classmethod
Expand Down Expand Up @@ -164,7 +161,7 @@ def list_from_file(

return [
MotifPssmPattern(
pssm, threshold=threshold, relative_threshold=relative_threshold,
pssm, threshold=threshold, relative_threshold=relative_threshold
)
for pssm in motifs_list
]
Expand Down
Loading