Pairwise2 Index Error
2
0
Entering edit mode
12.4 years ago
T ▴ 20

Hi,

why does this python script always give an index out of range error, when pairwise2 is supposed to output a 5 element tuple? e.g. (seqA, seqB, score, begin, end)

Thanks,

Theo

code:

from Bio import pairwise2

a = 'AGCTGTA'
b = 'GCTCTA'

c = pairwise2.align.localxx(a,b)

print c[2]
biopython • 1.9k views
ADD COMMENT
5
Entering edit mode
12.4 years ago

If you just print out C by itself, you get:

[('AGCTGTA', '-GCTCTA', 5.0, 1, 7)]

So it looks like it's outputting an array of possible alignments. Each alignment is a tuple of the data you described. In this case, just one alignment.

So to get that one alignment you would need to:

print c[0][2]

Or if there are multiple alignments:

for alignment in c:
   #do stuff
ADD COMMENT
0
Entering edit mode
12.4 years ago
T ▴ 20

Brilliant, thanks, that solved it.

All of the documentation and examples for pairwise2 (not very many I could find) show the output as a tuple only and show code like c[3], don't know what's gone wrong there!

Thanks again,

Theo

ADD COMMENT
0
Entering edit mode

If you liked Dk's answer, could you mark it as accepted?

Regarding misleading documentation, got any links/specifics?

ADD REPLY

Login before adding your answer.

Traffic: 1693 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