jeffdaily / parasail-python

Python bindings for the parasail C library.
Other
87 stars 17 forks source link

TypeError: __init__() missing 1 required positional argument: 's1b' #54

Closed N-damo closed 3 years ago

N-damo commented 3 years ago

SSW Library Emulation import parasail score_size = 1 # 0, use 8-bit align; 1, use 16-bit; 2, try both profile = parasail.ssw_init("asdf", parasail.blosum62, score_size) result = parasail.ssw_profile(profile, "asdf", 10, 1) print(result.score1) print(result.cigar) print(result.ref_begin1) print(result.ref_end1) print(result.read_begin1) print(result.read_end1)

error output: TypeError: init() missing 1 required positional argument: 's1b'

possible solution: class Profile:

def init(self, pointer, matrix,s1b):

def __init__(self, pointer, matrix):
    self.pointer = pointer
    self.matrix_ = matrix
    self._as_parameter_ = pointer
    #self.s1b = s1b

is it right?

jeffdaily commented 3 years ago

Bug in ssw_init. This is the correct fix. Will push this.

diff --git a/parasail/bindings_v2.py b/parasail/bindings_v2.py
index 5994d70..b43867f 100644
--- a/parasail/bindings_v2.py
+++ b/parasail/bindings_v2.py
@@ -973,7 +973,8 @@ def ssw_profile(profile, s2, open, extend):
         return None

 def ssw_init(s1, matrix, score_size):
-    return Profile(_lib.parasail_ssw_init(b(s1), len(s1), matrix, score_size), matrix)
+    s1b = b(s1)
+    return Profile(_lib.parasail_ssw_init(s1b, len(s1), matrix, score_size), matrix, s1b)

 _lib.parasail_sequences_from_file.argtype = [ctypes.c_char_p]
 _lib.parasail_sequences_from_file.restype = c_sequences_p
jeffdaily commented 3 years ago

It's been a long time since I pushed a tagged release. Not sure how well CI will go, creating a new pypi etc, but at least if you grab the latest sources it will have this fix.

jeffdaily commented 3 years ago

Release 1.2.1 is now available with this fixed. Thanks for reporting.