Back to index

python-biopython  1.60
__init__.py
Go to the documentation of this file.
00001 # Copyright 2000 by Jeffrey Chang.  All rights reserved.
00002 # This code is part of the Biopython distribution and governed by its
00003 # license.  Please see the LICENSE file that should have been included
00004 # as part of this package.
00005 
00006 """
00007 This module provides code to access resources at ExPASy over the WWW.
00008 http://www.expasy.ch/
00009 
00010 
00011 Functions:
00012 get_prodoc_entry  Interface to the get-prodoc-entry CGI script.
00013 get_prosite_entry Interface to the get-prosite-entry CGI script.
00014 get_prosite_raw   Interface to the get-prosite-raw CGI script.
00015 get_sprot_raw     Interface to the get-sprot-raw CGI script.
00016 sprot_search_ful  Interface to the sprot-search-ful CGI script.
00017 sprot_search_de   Interface to the sprot-search-de CGI script.
00018 """
00019 
00020 import urllib
00021 
00022 
00023 def get_prodoc_entry(id, cgi='http://www.expasy.ch/cgi-bin/get-prodoc-entry'):
00024     """get_prodoc_entry(id,
00025     cgi='http://www.expasy.ch/cgi-bin/get-prodoc-entry') -> handle
00026 
00027     Get a handle to a PRODOC entry at ExPASy in HTML format. 
00028 
00029     For a non-existing key XXX, ExPASy returns an HTML-formatted page
00030     containing this line:
00031     'There is no PROSITE documentation entry XXX. Please try again.'
00032     """
00033     # Open a handle to ExPASy.
00034     handle = urllib.urlopen("%s?%s" % (cgi, id))
00035     return handle
00036 
00037 def get_prosite_entry(id,
00038                       cgi='http://www.expasy.ch/cgi-bin/get-prosite-entry'):
00039     """get_prosite_entry(id,
00040     cgi='http://www.expasy.ch/cgi-bin/get-prosite-entry') -> handle
00041 
00042     Get a handle to a PROSITE entry at ExPASy in HTML format.
00043 
00044     For a non-existing key XXX, ExPASy returns an HTML-formatted page
00045     containing this line:
00046     'There is currently no PROSITE entry for XXX. Please try again.'
00047     """
00048     handle = urllib.urlopen("%s?%s" % (cgi, id))
00049     return handle
00050 
00051 def get_prosite_raw(id, cgi='http://www.expasy.ch/cgi-bin/get-prosite-raw.pl'):
00052     """get_prosite_raw(id,
00053                        cgi='http://www.expasy.ch/cgi-bin/get-prosite-raw.pl')
00054     -> handle
00055 
00056     Get a handle to a raw PROSITE or PRODOC entry at ExPASy.
00057 
00058     For a non-existing key, ExPASy returns nothing.
00059     """
00060     handle = urllib.urlopen("%s?%s" % (cgi, id))
00061     return handle
00062 
00063 def get_sprot_raw(id):
00064     """Get a handle to a raw SwissProt entry at ExPASy.
00065 
00066     For an ID of XXX, fetches http://www.uniprot.org/uniprot/XXX.txt
00067     (as per the http://www.expasy.ch/expasy_urls.html documentation).
00068     """
00069     return urllib.urlopen("http://www.uniprot.org/uniprot/%s.txt" % id)
00070 
00071 def sprot_search_ful(text, make_wild=None, swissprot=1, trembl=None,
00072                      cgi='http://www.expasy.ch/cgi-bin/sprot-search-ful'):
00073     """sprot_search_ful(text, make_wild=None, swissprot=1, trembl=None,
00074     cgi='http://www.expasy.ch/cgi-bin/sprot-search-ful') -> handle
00075 
00076     Search SwissProt by full text.
00077 
00078     """
00079     variables = {'SEARCH' : text}
00080     if make_wild:
00081         variables['makeWild'] = 'on'
00082     if swissprot:
00083         variables['S'] = 'on'
00084     if trembl:
00085         variables['T'] = 'on'
00086     options = urllib.urlencode(variables)
00087     fullcgi = "%s?%s" % (cgi, options)
00088     handle = urllib.urlopen(fullcgi)
00089     return handle
00090 
00091 def sprot_search_de(text, swissprot=1, trembl=None,
00092                     cgi='http://www.expasy.ch/cgi-bin/sprot-search-de'):
00093     """sprot_search_de(text, swissprot=1, trembl=None,
00094     cgi='http://www.expasy.ch/cgi-bin/sprot-search-de') -> handle
00095 
00096     Search SwissProt by name, description, gene name, species, or
00097     organelle.
00098 
00099     """
00100     variables = {'SEARCH' : text}
00101     if swissprot:
00102         variables['S'] = 'on'
00103     if trembl:
00104         variables['T'] = 'on'
00105     options = urllib.urlencode(variables)
00106     fullcgi = "%s?%s" % (cgi, options)
00107     handle = urllib.urlopen(fullcgi)
00108     return handle