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 -def get_prosite_entry(id,
38 cgi='http://www.expasy.ch/cgi-bin/get-prosite-entry'):
39 """get_prosite_entry(id,
40 cgi='http://www.expasy.ch/cgi-bin/get-prosite-entry') -> handle
41
42 Get a handle to a PROSITE entry at ExPASy in HTML format.
43
44 For a non-existing key XXX, ExPASy returns an HTML-formatted page
45 containing this line:
46 'There is currently no PROSITE entry for XXX. Please try again.'
47 """
48 handle = urllib.urlopen("%s?%s" % (cgi, id))
49 return handle
50
51 -def get_prosite_raw(id, cgi='http://www.expasy.ch/cgi-bin/get-prosite-raw.pl'):
52 """get_prosite_raw(id,
53 cgi='http://www.expasy.ch/cgi-bin/get-prosite-raw.pl')
54 -> handle
55
56 Get a handle to a raw PROSITE or PRODOC entry at ExPASy.
57
58 For a non-existing key, ExPASy returns nothing.
59 """
60 handle = urllib.urlopen("%s?%s" % (cgi, id))
61 return handle
62
64 """Get a handle to a raw SwissProt entry at ExPASy.
65
66 For an ID of XXX, fetches http://www.uniprot.org/uniprot/XXX.txt
67 (as per the http://www.expasy.ch/expasy_urls.html documentation).
68 """
69 return urllib.urlopen("http://www.uniprot.org/uniprot/%s.txt" % id)
70
71 -def sprot_search_ful(text, make_wild=None, swissprot=1, trembl=None,
72 cgi='http://www.expasy.ch/cgi-bin/sprot-search-ful'):
73 """sprot_search_ful(text, make_wild=None, swissprot=1, trembl=None,
74 cgi='http://www.expasy.ch/cgi-bin/sprot-search-ful') -> handle
75
76 Search SwissProt by full text.
77
78 """
79 variables = {'SEARCH' : text}
80 if make_wild:
81 variables['makeWild'] = 'on'
82 if swissprot:
83 variables['S'] = 'on'
84 if trembl:
85 variables['T'] = 'on'
86 options = urllib.urlencode(variables)
87 fullcgi = "%s?%s" % (cgi, options)
88 handle = urllib.urlopen(fullcgi)
89 return handle
90
91 -def sprot_search_de(text, swissprot=1, trembl=None,
92 cgi='http://www.expasy.ch/cgi-bin/sprot-search-de'):
93 """sprot_search_de(text, swissprot=1, trembl=None,
94 cgi='http://www.expasy.ch/cgi-bin/sprot-search-de') -> handle
95
96 Search SwissProt by name, description, gene name, species, or
97 organelle.
98
99 """
100 variables = {'SEARCH' : text}
101 if swissprot:
102 variables['S'] = 'on'
103 if trembl:
104 variables['T'] = 'on'
105 options = urllib.urlencode(variables)
106 fullcgi = "%s?%s" % (cgi, options)
107 handle = urllib.urlopen(fullcgi)
108 return handle
109