[Biopython-dev] New BLAST web page

Brad Chapman chapmanb at arches.uga.edu
Wed Mar 14 18:23:04 EST 2001


Hi Jeff;
Thanks for the SwissProt fixes --
I kind of suspected there might be more changes then what I fixed, but 
I know nothing about SwissProt since I've never used it, so I'm glad
an expert got the chance to look at it!

I was just curious -- have you given any thought to messing around
with the new BLAST page and CGI script? I started with
what you had for the old BLAST and modified it (what I have so far is
below) for the new format and variables, but am pretty stuck. 
What I have right now will just keep giving me the query page.

I didn't know if you had any suggestions or thoughts on this. I'm not
sure if I am missing something fundamental, or if the new pages are
just harder to work with. Thanks!

Brad

def new_blast(program, database, query,
              entrez_query = '(none)',
              filter = 'L',
              expect = '10',
              other_advanced = None,
              show_overview = 'on',
              ncbi_gi = 'on',
              format_object = 'alignment',
              format_type = 'html',
              descriptions = '100',
              alignments = '50',
              alignment_view = 'Pairwise',
              auto_format = 'on',
              cgi='http://www.ncbi.nlm.nih.gov/blast/Blast.cgi',
              timeout = 20):
    """Blast against the NCBI Blast web page.

    This uses the NCBI web page cgi script to BLAST, and returns a handle
    to the results. See:
    
    http://www.ncbi.nlm.nih.gov/blast/html/blastcgihelp.html

    for more descriptions about the options.

    Options:
    o program - The name of the blast program to run (ie. blastn, blastx...)
    o database - The database to search against (ie. nr, dbest...)
    o query - The input for the search, which NCBI tries to autodetermine
    the type of.
    o entrez_query - A query to limit the sequences searched against.
    o filter - Filtering for the input sequence.
    o expect - The expect value cutoff to include.
    """
    params = {'PROGRAM' : program,
              'DATABASE' : database,
              'QUERY' : query,
              'ENTREZ_QUERY' : entrez_query,
              'FILTER' : filter,
              'EXPECT' : expect,
              'OTHER_ADVANCED': other_advanced,
              'SHOW_OVERVIEW' : show_overview,
              'NCBI_GI' : ncbi_gi,
              'FORMAT_OBJECT' : format_object,
              'FORMAT_TYPE' : format_type,
              'DESCRIPTIONS' : descriptions,
              'ALIGNMENTS' : alignments,
              'ALIGNMENT_VIEW' : alignment_view,
              'AUTO_FORMAT' : auto_format}
    variables = {}
    for k in params.keys():
        if params[k] is not None:
            variables[k] = str(params[k])
    # This returns a handle to the HTML file that points to the results.
    handle = NCBI._open(cgi, variables, get = 0)
    # Now parse the HTML from the handle and figure out how to retrieve
    # the results.
    refcgi, params = _parse_blast_ref_page(handle, cgi)

    start = time.time()
    while 1:
        # Sometimes the BLAST results aren't done yet.  Look at the page
        # to see if the results are there.  If not, then try again later.
        handle = NCBI._open(cgi, params, get=0)
        ready, results, refresh_delay = _parse_blast_results_page(handle)
        if ready:
            break
        # Time out if it's not done after timeout minutes.
        if time.time() - start > timeout*60:
            raise IOError, "timed out after %d minutes" % timeout
        # pause and try again.
        time.sleep(refresh_delay)
    return File.UndoHandle(File.StringHandle(results))





More information about the Biopython-dev mailing list