*ë
tE_:c       s     d  Z    d k Z  d k Z  d k l Z ! d d  Z 1 e e d d  Z D e d d  Z W d	 d
  Z	 l h  d d  Z
 d S(   s  NCBI.py

Provides code to access NCBI over the WWW.

The main Entrez web page is available at:
http://www.ncbi.nlm.nih.gov/Entrez/

A list of the Entrez utilities is available at:
http://www.ncbi.nlm.nih.gov/entrez/utils/utils_index.html

The main Blast web page is available at:
http://www.ncbi.nlm.nih.gov/BLAST/


Functions:
query        Query Entrez.
pmfetch      Retrieve results using a unique identifier.
pmqty        Search PubMed.
pmneighbor   Return a list of related articles for a PubMed entry.
_open

N(   s   Files-   http://www.ncbi.nlm.nih.gov/entrez/query.fcgic    sE   ! , - h  |  d <| d <} . | i |  / t | |  Sd S(   s]  query(cmd, db, cgi='http://www.ncbi.nlm.nih.gov/entrez/query.fcgi',
    **keywds) -> handle

    Query Entrez and return a handle to the results.  See the online
    documentation for an explanation of the parameters:
    http://www.ncbi.nlm.nih.gov/entrez/query/static/linking.html

    Raises an IOError exception if there's a network error.

    s   cmds   dbN(   s   cmds   dbs	   variabless   updates   keywdss   _opens   cgi(   s   cmds   dbs   cgis   keywdss	   variables(    (    s%   /mit/seven/lib/python/Bio/WWW/NCBI.pys   query! s   s5   http://www.ncbi.nlm.nih.gov/entrez/utils/pmfetch.fcgic    sw   1 < = h  |  d <| d <} > | t j	 o ? | | d <n @ | t j	 o A | | d <n B t | |  Sd S(   sq  pmfetch(db, id, report=None, mode=None,
    cgi="http://www.ncbi.nlm.nih.gov/entrez/utils/pmfetch.fcgi")

    Query PmFetch and return a handle to the results.  See the
    online documentation for an explanation of the parameters:
    http://www.ncbi.nlm.nih.gov/entrez/utils/pmfetch_help.html
    
    Raises an IOError exception if there's a network error.
    
    s   dbs   ids   reports   modeN(   s   dbs   ids	   variabless   reports   Nones   modes   _opens   cgi(   s   dbs   ids   reports   modes   cgis	   variables(    (    s%   /mit/seven/lib/python/Bio/WWW/NCBI.pys   pmfetch1 s   s3   http://www.ncbi.nlm.nih.gov/entrez/utils/pmqty.fcgic    sf   D P Q h  |  d <| d <} R | t j	 o S | | d <n T | i |  U t | |  Sd S(   sh  pmqty(db, term, dopt=None,
    cgi='http://www.ncbi.nlm.nih.gov/entrez/utils/pmqty.fcgi') -> handle

    Query PmQty and return a handle to the results.  See the
    online documentation for an explanation of the parameters:
    http://www.ncbi.nlm.nih.gov/entrez/utils/pmqty_help.html
    
    Raises an IOError exception if there's a network error.
    
    s   dbs   terms   doptN(	   s   dbs   terms	   variabless   dopts   Nones   updates   keywdss   _opens   cgi(   s   dbs   terms   dopts   cgis   keywdss	   variables(    (    s%   /mit/seven/lib/python/Bio/WWW/NCBI.pys   pmqtyD s   s8   http://www.ncbi.nlm.nih.gov/entrez/utils/pmneighbor.fcgic    s-   W b i d | |  | f } j t |  Sd S(   sv  pmneighbor(pmid, display,
    cgi='http://www.ncbi.nlm.nih.gov/entrez/utils/pmneighbor.fcgi') -> handle

    Query PMNeighbor and return a handle to the results.  See the
    online documentation for an explanation of the parameters:
    http://www.ncbi.nlm.nih.gov/entrez/utils/pmneighbor_help.html
    
    Raises an IOError exception if there's a network error.
    
    s   %s?pmid=%s&%sN(   s   cgis   pmids   displays   fullcgis   _open(   s   pmids   displays   cgis   fullcgi(    (    s%   /mit/seven/lib/python/Bio/WWW/NCBI.pys
   pmneighborW s   i   c 
   sĘ  l t v t  i |  } w | o@ x |  }	 y | o z d |  | f }	 n { t  i |	  } n } t  i |  |  }  t	 i
 |  }  g  }  x/ t d  d  r }  | i | i    qĪ W x5 t d d d  d  r }  | i | |  qá W t i | d  }  t i | d  d j o  t d  n}  t i | d	  d j o  t d
  nQ  t i | d  d j o  t d  n%  | d  d j o  t d  n  | Sd S(   sP  _open(cgi, params={}, get=1) -> UndoHandle

    Open a handle to Entrez.  cgi is the URL for the cgi script to access.
    params is a dictionary with the options to pass to it.  get is a boolean
    that describes whether a GET should be used.  Does some
    simple error checking, and will raise an IOError if it encounters one.

    s   %s?%si   i    i   i   s    s   500 Proxy Errors   500 Proxy Error (NCBI busy?)s   502 Proxy Errors   502 Proxy Error (NCBI busy?)s   WWW Error 500 Diagnostics%   WWW Error 500 Diagnostic (NCBI busy?)s   ERRORs)   ERROR, possibly because id not available?N(   s   urllibs	   urlencodes   paramss   optionss   gets   cgis   fullcgis   urlopens   handles   Files
   UndoHandles   uhandles   liness   ranges   is   appends   readlines   savelines   strings   joins   datas   finds   IOError(
   s   cgis   paramss   gets   optionss   uhandles   datas   liness   is   handles   fullcgi(    (    s%   /mit/seven/lib/python/Bio/WWW/NCBI.pys   _openl s4   
	
	 	 	(   s   __doc__s   strings   urllibs   Bios   Files   querys   Nones   pmfetchs   pmqtys
   pmneighbors   _open(   s   urllibs   pmfetchs   querys   pmqtys   Files   strings   _opens
   pmneighbor(    (    s%   /mit/seven/lib/python/Bio/WWW/NCBI.pys   ? s   