[Biopython-dev] [Bug 2812] Adding read method to NCBIXML (just like SeqIO and SwissProt).

bugzilla-daemon at portal.open-bio.org bugzilla-daemon at portal.open-bio.org
Wed Apr 15 21:58:15 UTC 2009


http://bugzilla.open-bio.org/show_bug.cgi?id=2812





------- Comment #1 from biopython-bugzilla at maubp.freeserve.co.uk  2009-04-15 17:58 EST -------
Adding this should do the trick (based on the SeqIO.read function):

def read(handle, debug=0) :
    """Returns a single Blast record (assumes just one query).

    Use the Bio.Blast.NCBIXML.read() function if you expect more than
    one BLAST record (i.e. if you have more than one query sequence).
    This function is for use when there is one and only one BLAST
    result.
    """
    iterator = parse(handle, debug)
    try :
        first = iterator.next()
    except StopIteration :
        first = None
    if first is None :
        raise ValueError("No records found in handle")
    try :
        second = iterator.next()
    except StopIteration :
        second = None
    if second is not None :
        raise ValueError("More than one record found in handle")
    return first

However, on reflection this needs some special testing for when there is a
single query giving NO hits.  I suspect that means the BLAST XML file will
contain no records (at least that's my guess from recent versions - I haven't
tried 2.2.20 yet).  Would raising a ValueError in this situation reasonable?


-- 
Configure bugmail: http://bugzilla.open-bio.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the Biopython-dev mailing list