jeffdaily / parasail-python

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

compatibility between parasail and parasail-python? #14

Closed ctanes closed 6 years ago

ctanes commented 6 years ago

I currently have parasail version 2.0.2 and parasail-python version 1.1.7 installed. I copied the libparasail.so file to the same directory as init and ran pip install. I am using a conda environment with python 3.6.3. I have been going through the examples that are on the parasail-python readme file. However I am getting

>>> result = parasail.sw_trace("asdf", "asdf", 10, 1, parasail.blosum62)
>>> cigar = result.cigar
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/tanesc/miniconda3/envs/unassigner/lib/python3.6/site-packages/parasail/bindings_v2.py", line 278, in cigar
    return Cigar(_lib.parasail_result_get_cigar(self.pointer, self.query, self.len_query, self.ref, self.len_ref, self.matrix))
ctypes.ArgumentError: argument 2: <class 'TypeError'>: wrong type

Also I am getting segmentation faults when I try to execute the example code

profile = parasail.profile_create_8("asdf", parasail.blosum62)
result1 = parasail.sw_trace_striped_profile_16(profile, "asdf", 10, 1)

Are there certain versions that of the two pieces of software that are not compatible with each other? Or is it due to a completely different error?

Thank you!

jeffdaily commented 6 years ago

Good questions. Let me try to reproduce. In general, I've tried to keep the parasail-python master up-to-date with the parasail master.

jeffdaily commented 6 years ago

I can at least answer the second half of your question right now:

Also I am getting segmentation faults when I try to execute the example code

profile = parasail.profile_create_8("asdf", parasail.blosum62)
result1 = parasail.sw_trace_striped_profile_16(profile, "asdf", 10, 1)

You created an 8-bit profile and used it with a 16-bit function. Without getting into the details -- and this should have been caught at the Python layer to avoid the seg fault -- the easy solution is to make sure you match the bit sizes. Change the line to

profile = parasail.profile_create_16("asdf", parasail.blosum62)

and you'll avoid the seg fault. I'll look into a more elegant solution/warning in the meantime. Also I haven't had a chance to reproduce your other issue yet.

jeffdaily commented 6 years ago

Looks like I have a bug in my python3 compatibility. The result.cigar statement seems to work in python2. Will try to fix this ASAP. Thanks for the report.

ctanes commented 6 years ago

Thank you for your quick response! I rebuilt a conda environment with python 2.7 and I'm still getting segmentation faults but the result.cigar seems to work fine as you said. It might also help to change the profile code in your tutorial to the correct code. Thank you for working on this software as it is greatly needed.

jeffdaily commented 6 years ago

I updated the example code in the README and added a note that you must match the profile bit size with the alignment function bit size. I hope that helps.

In other news, I fixed a few bugs with the Python3 compatibility. There was a bug in the Profile class that was storing a pointer to a python string that went out of scope and got garbage collected. Let me know if you have any more problems with the profile interface. I closed this issue for now.