[Biopython] hsp.identities

Mike Williams dmikewilliams at gmail.com
Mon Aug 10 16:59:03 UTC 2009


Hi there.  Been using perl since 1996, but I am new to python.  I am
working on some python code that was last modified in March of 2007.

The code used to use NCBIStandalone, I've modified it to use NCBIXML
because the Standalone package died with an exception, which I assumed
was due to changes in the blast report format since the code was
originally written.

<snippet>
blastToleranceNT = 2
blast_out = open(blast_report, "r")
b_parse = NCBIXML.parse(blast_out, debug)
for b_record in b_parse :
    for al in b_record.alignments:
        al.hsps = filter (lambda x:
abs(x.identities[0]-x.identities[1]) <= blastToleranceNT,
                                  al.hsps)
</snippet>

This code generates the following error:
TypeError: 'int' object is unsubscriptable

Tried using some (slightly modified) code from:
http://biobanner.org/cgi-bin/cvsweb.cgi/biopy-pgml/Bio/PGML/Arabidopsis/ArabComp/LocateOligos.py?rev=1.3
for hsp in al.hsps:
          identities, length = hsp.identities
which gives the following error:
identity, length = hsp.identities
TypeError: 'int' object is not iterable

using blast-2.2.17, python 2.6, and biopython version 1.49 on a fedora 11 system
also tried on a fedora 10 system with python 2.5.2 and biopython 1.48
- similar results

according to the docs at:
http://www.biopython.org/DIST/docs/api/Bio.Blast.Record.HSP-class.html
hsp.identities is a tuple:
identities      Number of identities/total aligned.  tuple of (int, int)

I've looked at various sites with examples of how to deal with tuples,
but nothing seems to work, and
the error messages always imply that identities is an int.

I'm hoping my spinning my wheels on this is just the result of being
new to python.  I know the original version of the code *used* to
work, and the rest of the program seems to work fine, if I comment out
the filter line.

Any help would be appreciated, this one line of code is a show stopper
and I have multiple deadlines this week which depend on getting this
working.

Thanks,

Mike



More information about the Biopython mailing list