1
2
3
4
5
6 """
7 This module provides code to access resources at ExPASy over the WWW.
8 http://www.expasy.ch/
9
10
11 Functions:
12 get_prodoc_entry Interface to the get-prodoc-entry CGI script.
13 get_prosite_entry Interface to the get-prosite-entry CGI script.
14 get_prosite_raw Interface to the get-prosite-raw CGI script.
15 get_sprot_raw Interface to the get-sprot-raw CGI script.
16 sprot_search_ful Interface to the sprot-search-ful CGI script.
17 sprot_search_de Interface to the sprot-search-de CGI script.
18 """
19
20 import urllib
21
22
23 -def get_prodoc_entry(id, cgi='http://www.expasy.ch/cgi-bin/get-prodoc-entry'):
24 """get_prodoc_entry(id,
25 cgi='http://www.expasy.ch/cgi-bin/get-prodoc-entry') -> handle
26
27 Get a handle to a PRODOC entry at ExPASy in HTML format.
28
29 For a non-existing key XXX, ExPASy returns an HTML-formatted page
30 containing this line:
31 'There is no PROSITE documentation entry XXX. Please try again.'
32 """
33
34 handle = urllib.urlopen("%s?%s" % (cgi, id))
35 return handle
36
37
38 -def get_prosite_entry(id,
39 cgi='http://www.expasy.ch/cgi-bin/get-prosite-entry'):
40 """get_prosite_entry(id,
41 cgi='http://www.expasy.ch/cgi-bin/get-prosite-entry') -> handle
42
43 Get a handle to a PROSITE entry at ExPASy in HTML format.
44
45 For a non-existing key XXX, ExPASy returns an HTML-formatted page
46 containing this line:
47 'There is currently no PROSITE entry for XXX. Please try again.'
48 """
49 handle = urllib.urlopen("%s?%s" % (cgi, id))
50 return handle
51
52
53 -def get_prosite_raw(id, cgi='http://www.expasy.ch/cgi-bin/get-prosite-raw.pl'):
54 """get_prosite_raw(id,
55 cgi='http://www.expasy.ch/cgi-bin/get-prosite-raw.pl')
56 -> handle
57
58 Get a handle to a raw PROSITE or PRODOC entry at ExPASy.
59
60 For a non-existing key, ExPASy returns nothing.
61 """
62 handle = urllib.urlopen("%s?%s" % (cgi, id))
63 return handle
64
65
67 """Get a handle to a raw SwissProt entry at ExPASy.
68
69 For an ID of XXX, fetches http://www.uniprot.org/uniprot/XXX.txt
70 (as per the http://www.expasy.ch/expasy_urls.html documentation).
71 """
72 return urllib.urlopen("http://www.uniprot.org/uniprot/%s.txt" % id)
73
74
75 -def sprot_search_ful(text, make_wild=None, swissprot=1, trembl=None,
76 cgi='http://www.expasy.ch/cgi-bin/sprot-search-ful'):
77 """sprot_search_ful(text, make_wild=None, swissprot=1, trembl=None,
78 cgi='http://www.expasy.ch/cgi-bin/sprot-search-ful') -> handle
79
80 Search SwissProt by full text.
81
82 """
83 variables = {'SEARCH': text}
84 if make_wild:
85 variables['makeWild'] = 'on'
86 if swissprot:
87 variables['S'] = 'on'
88 if trembl:
89 variables['T'] = 'on'
90 options = urllib.urlencode(variables)
91 fullcgi = "%s?%s" % (cgi, options)
92 handle = urllib.urlopen(fullcgi)
93 return handle
94
95
96 -def sprot_search_de(text, swissprot=1, trembl=None,
97 cgi='http://www.expasy.ch/cgi-bin/sprot-search-de'):
98 """sprot_search_de(text, swissprot=1, trembl=None,
99 cgi='http://www.expasy.ch/cgi-bin/sprot-search-de') -> handle
100
101 Search SwissProt by name, description, gene name, species, or
102 organelle.
103
104 """
105 variables = {'SEARCH': text}
106 if swissprot:
107 variables['S'] = 'on'
108 if trembl:
109 variables['T'] = 'on'
110 options = urllib.urlencode(variables)
111 fullcgi = "%s?%s" % (cgi, options)
112 handle = urllib.urlopen(fullcgi)
113 return handle
114