Biopython problem again
1
0
Entering edit mode
5.6 years ago
psschlogl ▴ 50

I am trying to use this tutorial and I got a problem with it:

from Bio import pairwise2
from Bio import SeqIO
from Bio.pairwise2 import format_alignment

seq1 = SeqIO.read("data/alpha.faa", "fasta")
seq2 = SeqIO.read("data/beta.faa", "fasta")
alignments = pairwise2.align.globalxx(seq1.seq, seq2.seq)
print(pairwise2.format_alignment(*alignment[0]))

But I am got this error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-144-da7cdbf0f1b6> in <module>
      1 from Bio.pairwise2 import format_alignment
      2 
----> 3 print(pairwise2.format_alignment(*alignment[0]))

TypeError: format_alignment() takes 5 positional arguments but 52 were given

I am just folliwing along with the biopython tutorial. Looks like in my code the function is receiving more args than due, but it looks works with the tutorial.

Some of you had a alike issue?

Thanks

biopython • 1.3k views
ADD COMMENT
2
Entering edit mode
5.6 years ago
AK ★ 2.2k

Hi psschlogl,

How many sequences are there in your alpha.faa and beta.faa? If both contain one, it works for me:

$ cat data/alpha.faa
>seq1
MLLPLRRVLLKAVRQHNFFSESHATSINTRKGLVLGVYEKQSDDEGILLTEAAASFDSSISGKLSEML
PTEFANTIEQKLSPFAHKVTVHKRPQSWIESEQMGAFLSVSKGSEEPPVFLELHYKGSLDSAQP
$ cat data/beta.faa
>seq2
MLLPLRRVLLQHNFFSESHATSINTRKGLVLGVYEKQSDDEGILLTEAAASFDSSISGKLSEMLHKR
PTEFANTIEQKLSPFAHKVTVHKRPQSWIESEQMGAFLSVSKGSEEPPVFL

$ cat test.py
#!/usr/bin/env python

from Bio import pairwise2
from Bio import SeqIO
from Bio.pairwise2 import format_alignment

seq1 = SeqIO.read("data/alpha.faa", "fasta")
seq2 = SeqIO.read("data/beta.faa", "fasta")
alignments = pairwise2.align.globalxx(seq1.seq, seq2.seq)

print(pairwise2.format_alignment(*alignments[0]))

$ python test.py
MLLPLRRVLLKAVRQHNFFSESHATSINTRKGLVLGVYEKQSDDEGILLTEAAASFDSSISGKLSEML---PTEFANTIEQKLSPFAHKVTVHKRPQSWIESEQMGAFLSVSKGSEEPPVFLELHYKGSLDSAQP
||||||||||    ||||||||||||||||||||||||||||||||||||||||||||||||||||||   ||||||||||||||||||||||||||||||||||||||||||||||||||        |
MLLPLRRVLL----QHNFFSESHATSINTRKGLVLGVYEKQSDDEGILLTEAAASFDSSISGKLSEMLHKRPTEFANTIEQKLSPFAHKVTVHKRPQSWIESEQMGAFLSVSKGSEEPPVF--------L-----
  Score=115
ADD COMMENT
0
Entering edit mode

Hey bro,

you got it done!

Thank you for your time and kindness.

Paulo

ADD REPLY
1
Entering edit mode

You're welcome, good luck!

ADD REPLY

Login before adding your answer.

Traffic: 2152 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6