althonos / pyfamsa

Cython bindings and Python interface to FAMSA, an algorithm for ultra-scale multiple sequence alignments.
GNU General Public License v3.0
28 stars 3 forks source link

TypeError when trying to initialise Alignment object using positional argument. #6

Open AshtonPooley opened 1 week ago

AshtonPooley commented 1 week ago

Hello,

I'm attempting to run a profile alignment using two sub alignments stored as string in memory. In order to do so I am initialising a new Alignment object using an iterable of GappedSequence objects. This is resulting in a TypeError crash. It is easily repeatable by following the example in the docs `

from pyfamsa import * s1 = GappedSequence(b"seq1", b"MA-WMRLLPL") s2 = GappedSequence(b"seq2", b"MALWTR-RPL") alignment = Alignment([s1, s2]) ` Traceback (most recent call last): File "", line 1, in TypeError: init() takes exactly 0 positional arguments (1 given)

Regards, Ashton

althonos commented 1 week ago

Hi Ashton, are you using the latest version of PyFAMSA? This only works in v0.5.0 and later.

AshtonPooley commented 1 week ago

Hi, thank you for your quick reply. Indeed I got too excited to test the new features and forgot to update. However I'm now encountering some memory errors in C.

famsa_msa = pyfamsa.Alignment(sequences = [pyfamsa.GappedSequence(header.encode(), seq.encode()) for header, seq in raw_seqs])
aligner = pyfamsa.Aligner(threads=1)
print(famsa_msa)
print(list(famsa_msa))
print(tmp_aln)
print(list(tmp_aln))    
profile_alignment = aligner.align_profiles(famsa_msa, tmp_aln)`
<pyfamsa._famsa.Alignment object at 0x7f62a220a280>
[GappedSequence(b'101287at33392|Hermetia_illucens|JSM_8601_S5_L001|NODE_1049032|-3|1', b'-MKVCINSGVHFAKRYLKYLTKKYLKKNSCRDWIRIVANKKESYELRYFRISSNDDDEEDAE'), GappedSequence(b'101287at33392|Bradysia_coprophila|JSM_8601_S5_L001|NODE_1908414|-1|1', b'KMKVCINSGVHFPKRYLKYWTKKYLKKNSFRHWIRIVSNKKESYELRYIRISSNDDD-----')]
<pyfamsa._famsa.Alignment object at 0x7f62a220a0d0>
[GappedSequence(b'59916_0:002321', b'LKAVKPQRKSVSAAAATAA-GKVTKKNVLRGKGLKKKKVSLRFGIDCTNIAEDNIMDVADFEKYIKARLKVNGKVNNLGNNVTFERLKMKLYVNSDVHFSKAYLKYLTKRYLKKNSLRDWIRVVSNDKDSYELRYFRISSNDDEDEDAE'), GappedSequence(b'7370_0:00035f', b'-PAAAKPKKSVTAAAAAAT-GKVGKKAVLRGKGLKKKKVSLRYAIDCTNIAEDNILDVVDFEKYIKSRMKVNDKVNNLGNNVTFERVKMKLYVNSDVHFSKAYLKYLTKKYLKKNSLRDWIRVVANDKDSYELRYFRINSNDDEDEDAE'), GappedSequence(b'35570_0:00138e', b'-PAAAKPKKSVTAAAATAT-GKVGKKTVLRGKGLKKKKVSLRYGIDCTNIAEDNILDVVDFEKYVKSRMKVNDKVNNLGNNVTFERVKMKLYVNSDVHFSKAYLKYLTKKYLKKNSLRDWIRVVANEKDSYELRYFRINSNDDEDEDAE'), GappedSequence(b'28588_0:002388', b'VKAAKPQRKSVSAAAAAAS-GKVGKKNVLRGKGLKKKKVSLRFGIDCTNIAEDNIMDVADFEKYIKARLKVNGKVNNLGNNVTFERLKMKLYVNSDVHFSKAYLKYLTKRYLKKNSLRDWIRVVSNDKDSYELRYFRISSNDDEDEDAE'), GappedSequence(b'27457_0:002e39', b'LKAVKPQRKSVSAAAATAA-GKVTKKNVLRGKGLKKKKVSLRFGIDCTNIAEDNIMDVADFEKYIKARLKVNGKVNNLGNNVTFERLKMKLYVNSDVHFSKAYLKYLTKRYLKKNSLRDWIRVVSNDKDSYELRYFRISSNDDEDEDAE'), GappedSequence(b'13632_0:00176a', b'-PAAAKPKK-----AAVAS-GKVGKKAVLRGKGLKKKKVSLRYAIDCTNIAEDNILDVADFEKYVKARMKVNGKVNNLGNNVTFERVKMKLYVNSDVHFSKAYLKYLTKKYLKKNSLRDWIRVVANDKDSYELRYFRISSNDDEDEDAE'), GappedSequence(b'7396_0:0001ed', b'-PVAAKPKKSVTASAAAAT-GKVGKKVILRGKSLKKKKVSLRFGIDCTNIAEDNIMDVADFEKYVKARLKVNGKVNNLGNNVTFERVKMKLYVNSDVHFSKAYLKYLTKKYLKKNSLRDWIRVVADDKDSYELRYFRISSNDDEDEDAE'), GappedSequence(b'7375_0:000c18', b'-PAAAKPKK-----AAVAS-GKVGKKAVLRGKGLKKKKVSLRYAIDCTNIAEDNILDVADFEKYVKARMKVNGKVNNLGNNVTFERVKMKLYVNSDVHFSKAYLKYLTKKYLKKNSLRDWIRVVANDKDSYELRYFRISSNDDEDEDAE')]
double free or corruption (!prev)
Aborted

Edit: tmp_aln is an Alignment object of a reference profile that the famsa_msa is to be aligned against. I've tried creating a new tmp_aln for each iteration assuming the double free was because of reusing the same variable but the error still occurs. During iterations of testing I also encountered "malloc(): mismatching next->prev_size (unsorted)" using tmp_aln.copy()

althonos commented 6 days ago

I cannot reproduce on my end, so it doesn't look like an issue with the sequences. Can I get some information about your Python version, Operating System, etc. ?

AshtonPooley commented 3 days ago

Hi, sorry for the delay in replying. I had a play around with it on some different machines and eventually I was able to get it running.

Unfortunately It still crashes on my WSL install: Ubuntu 22.04.3 LTS Python 3.10.12

Except I was able to get it running on windows, so it must be an OS specific error.

Let me know how else I can help, Ashton