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

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

Open
AshtonPooley opened this issue Sep 30, 2024 · 4 comments
Labels
question Further information is requested

Comments

@AshtonPooley
Copy link

AshtonPooley commented Sep 30, 2024

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
Copy link
Owner

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

@althonos althonos added the question Further information is requested label Sep 30, 2024
@AshtonPooley
Copy link
Author

AshtonPooley commented Oct 1, 2024

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
Copy link
Owner

althonos commented Oct 2, 2024

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants