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
70 For a non-existing key XXX, ExPASy returns an HTML Error 404 page.
71
72 This function used to take a cgi option to specify the URL, but that
73 is no longer supported. This is because prior to November 2009 we
74 used to use http://www.expasy.ch/cgi-bin/get-sprot-raw.pl?XXX
75 However, at the time of writting this returns FASTA format instead
76 (probably an ExPASy/UniProt oversight). Under the new URL scheme,
77 we cannot just append "?XXX" to the cgi argument.
78 """
79 if cgi :
80 import warnings
81 import Bio
82 warnings.warn("The cgi argument in get_sprot_raw is not "
83 "supported anymore", Bio.BiopythonDeprecationWarning)
84 return urllib.urlopen("http://www.uniprot.org/uniprot/%s.txt" % id)
85
86 -def sprot_search_ful(text, make_wild=None, swissprot=1, trembl=None,
87 cgi='http://www.expasy.ch/cgi-bin/sprot-search-ful'):
88 """sprot_search_ful(text, make_wild=None, swissprot=1, trembl=None,
89 cgi='http://www.expasy.ch/cgi-bin/sprot-search-ful') -> handle
90
91 Search SwissProt by full text.
92
93 """
94 variables = {'SEARCH' : text}
95 if make_wild:
96 variables['makeWild'] = 'on'
97 if swissprot:
98 variables['S'] = 'on'
99 if trembl:
100 variables['T'] = 'on'
101 options = urllib.urlencode(variables)
102 fullcgi = "%s?%s" % (cgi, options)
103 handle = urllib.urlopen(fullcgi)
104 return handle
105
106 -def sprot_search_de(text, swissprot=1, trembl=None,
107 cgi='http://www.expasy.ch/cgi-bin/sprot-search-de'):
108 """sprot_search_de(text, swissprot=1, trembl=None,
109 cgi='http://www.expasy.ch/cgi-bin/sprot-search-de') -> handle
110
111 Search SwissProt by name, description, gene name, species, or
112 organelle.
113
114 """
115 variables = {'SEARCH' : text}
116 if swissprot:
117 variables['S'] = 'on'
118 if trembl:
119 variables['T'] = 'on'
120 options = urllib.urlencode(variables)
121 fullcgi = "%s?%s" % (cgi, options)
122 handle = urllib.urlopen(fullcgi)
123 return handle
124