[BioPython] clustalw

Brad Chapman chapmanb at uga.edu
Sun Feb 29 17:22:44 EST 2004


Hello Ky;

> when I loading a clusalw file containg a msa, like following...
> 
> %
> import Bio.Clustalw
> from Bio.Alphabet import IUPAC
> from sys import *
> 
> align = Bio.Clustalw.parse_file(argv[1], alphabet=IUPAC.protein)
> 
> for seq in align.get_all_seqs():
>     print seq.description
> %
> it show an error about 'out of range' in line 5.

Although it would be really useful if you posted a full traceback of
the error (it makes it much easier for us to guess what the problem
could be), I think I know what your issue is here.

You are getting the 'out of range' error from line 5:

align = Bio.Clustalw.parse_file(argv[1], alphabet=IUPAC.protein)

The most likely cause of that error is trying to get an item from a
list using an index, and using an index number that is off the end
of the list:

>>> b = [1, 2, 3]
>>> b[1]
2
>>> b[4]
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
IndexError: list index out of range

In this case the list item being indexed in that line is argv (from
sys.argv). This is a list of the arguments passed when running the
script and argv[1] indicates that you should be passing the script
the name of the file to parse.

So, likely you are calling the script like:

python my_script.py

when you should be doing:

python my_script.py file_to_parser.aln

So, it's not a Biopython problem but hopefully this explanation
helps!
Brad


More information about the BioPython mailing list