.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.engines.pdbe Namespace Reference

Functions

 request (query, params)
 
 construct_body (result)
 
 response (resp)
 

Variables

dict about
 
list categories = ['science']
 
bool hide_obsolete = False
 
list pdb_unpublished_codes = ['HPUB', 'HOLD', 'PROC', 'WAIT', 'AUTH', 'AUCO', 'REPL', 'POLC', 'REFI', 'TRSF', 'WDRN']
 
str pdbe_solr_url = 'https://www.ebi.ac.uk/pdbe/search/pdb/select?'
 
str pdbe_entry_url = 'https://www.ebi.ac.uk/pdbe/entry/pdb/{pdb_id}'
 
str pdbe_preview_url = 'https://www.ebi.ac.uk/pdbe/static/entry/{pdb_id}_deposited_chain_front_image-200x200.png'
 

Detailed Description

 PDBe (Protein Data Bank in Europe)

Function Documentation

◆ construct_body()

searx.engines.pdbe.construct_body ( result)

Definition at line 41 of file pdbe.py.

41def construct_body(result):
42 # set title
43 title = result['title']
44
45 # construct content body
46 content = """{title} - {authors} {journal} ({volume}) {page} ({year})"""
47
48 # replace placeholders with actual content
49 try:
50 if result['journal']:
51 content = content.format(
52 title=result['citation_title'],
53 authors=result['entry_author_list'][0],
54 journal=result['journal'],
55 volume=result['journal_volume'],
56 page=result['journal_page'],
57 year=result['citation_year'],
58 )
59 else:
60 content = content.format(
61 title=result['citation_title'],
62 authors=result['entry_author_list'][0],
63 journal='',
64 volume='',
65 page='',
66 year=result['release_year'],
67 )
68 thumbnail = pdbe_preview_url.format(pdb_id=result['pdb_id'])
69 except KeyError:
70 content = None
71 thumbnail = None
72
73 # construct url for preview image
74 try:
75 thumbnail = pdbe_preview_url.format(pdb_id=result['pdb_id'])
76 except KeyError:
77 thumbnail = None
78
79 return [title, content, thumbnail]
80
81

Referenced by searx.engines.pdbe.response().

+ Here is the caller graph for this function:

◆ request()

searx.engines.pdbe.request ( query,
params )

Definition at line 33 of file pdbe.py.

33def request(query, params):
34
35 params['url'] = pdbe_solr_url
36 params['method'] = 'POST'
37 params['data'] = {'q': query, 'wt': "json"} # request response in parsable format
38 return params
39
40

◆ response()

searx.engines.pdbe.response ( resp)

Definition at line 82 of file pdbe.py.

82def response(resp):
83
84 results = []
85 json = loads(resp.text)['response']['docs']
86
87 # parse results
88 for result in json:
89 # catch obsolete entries and mark them accordingly
90 if result['status'] in pdb_unpublished_codes:
91 continue
92 if hide_obsolete:
93 continue
94 if result['status'] == 'OBS':
95 # expand title to add some sort of warning message
96 title = gettext('{title} (OBSOLETE)').format(title=result['title'])
97 try:
98 superseded_url = pdbe_entry_url.format(pdb_id=result['superseded_by'])
99 except: # pylint: disable=bare-except
100 continue
101
102 # since we can't construct a proper body from the response, we'll make up our own
103 msg_superseded = gettext("This entry has been superseded by")
104 content = '{msg_superseded}: {url} ({pdb_id})'.format(
105 msg_superseded=msg_superseded, url=superseded_url, pdb_id=result['superseded_by']
106 )
107
108 # obsoleted entries don't have preview images
109 thumbnail = None
110 else:
111 title, content, thumbnail = construct_body(result)
112
113 results.append(
114 {
115 'url': pdbe_entry_url.format(pdb_id=result['pdb_id']),
116 'title': title,
117 'content': content,
118 'thumbnail': thumbnail,
119 }
120 )
121
122 return results

References searx.engines.pdbe.construct_body(), and searx.format.

+ Here is the call graph for this function:

Variable Documentation

◆ about

dict searx.engines.pdbe.about
Initial value:
1= {
2 "website": 'https://www.ebi.ac.uk/pdbe',
3 "wikidata_id": 'Q55823905',
4 "official_api_documentation": 'https://www.ebi.ac.uk/pdbe/api/doc/search.html',
5 "use_official_api": True,
6 "require_api_key": False,
7 "results": 'JSON',
8}

Definition at line 10 of file pdbe.py.

◆ categories

list searx.engines.pdbe.categories = ['science']

Definition at line 19 of file pdbe.py.

◆ hide_obsolete

bool searx.engines.pdbe.hide_obsolete = False

Definition at line 21 of file pdbe.py.

◆ pdb_unpublished_codes

list searx.engines.pdbe.pdb_unpublished_codes = ['HPUB', 'HOLD', 'PROC', 'WAIT', 'AUTH', 'AUCO', 'REPL', 'POLC', 'REFI', 'TRSF', 'WDRN']

Definition at line 24 of file pdbe.py.

◆ pdbe_entry_url

str searx.engines.pdbe.pdbe_entry_url = 'https://www.ebi.ac.uk/pdbe/entry/pdb/{pdb_id}'

Definition at line 28 of file pdbe.py.

◆ pdbe_preview_url

str searx.engines.pdbe.pdbe_preview_url = 'https://www.ebi.ac.uk/pdbe/static/entry/{pdb_id}_deposited_chain_front_image-200x200.png'

Definition at line 30 of file pdbe.py.

◆ pdbe_solr_url

str searx.engines.pdbe.pdbe_solr_url = 'https://www.ebi.ac.uk/pdbe/search/pdb/select?'

Definition at line 26 of file pdbe.py.