Revision 50035
Added by Sandro La Bruzzo over 6 years ago
DLI.py | ||
---|---|---|
32 | 32 |
|
33 | 33 |
base_dnet_url = "http://aggregator-dli.openaire.eu/dli/" |
34 | 34 |
|
35 |
pid_resolver = { |
|
36 |
"pdb": "http://www.rcsb.org/pdb/explore/explore.do?structureId=%s", |
|
37 |
"ncbi-n": "http://www.ncbi.nlm.nih.gov/gquery/?term=%s", |
|
38 |
"pmid": "http://www.ncbi.nlm.nih.gov/pubmed/%s", |
|
39 |
"pmcid": "http://www.ncbi.nlm.nih.gov/pmc/articles/%s", |
|
40 |
"pubmedid": "http://www.ncbi.nlm.nih.gov/pubmed/%s", |
|
41 |
"doi": "http://dx.doi.org/%s", |
|
42 |
"genbank": "http://www.ncbi.nlm.nih.gov/nucest/%s?report=genbank", |
|
43 |
"nuccore": "http://www.ncbi.nlm.nih.gov/nucest/%s?report=genbank", |
|
44 |
"swiss-prot": "http://www.ncbi.nlm.nih.gov/nucest/%s?report=genbank", |
|
45 |
"arrayexpress": "http://www.ncbi.nlm.nih.gov/nucest/%s?report=genbank", |
|
46 |
"biomodels": "http://www.ncbi.nlm.nih.gov/nucest/%s?report=genbank", |
|
47 |
"bmrb": "http://www.ncbi.nlm.nih.gov/nucest/%s?report=genbank", |
|
48 |
"ena": "http://www.ncbi.nlm.nih.gov/nucest/%s?report=genbank", |
|
49 |
"geo": "http://www.ncbi.nlm.nih.gov/nucest/%s?report=genbank", |
|
50 |
"ensembl": "http://www.ncbi.nlm.nih.gov/nucest/%s?report=genbank", |
|
51 |
"mgi": "http://www.ncbi.nlm.nih.gov/nucest/%s?report=genbank", |
|
52 |
"bind": "http://www.ncbi.nlm.nih.gov/nucest/%s?report=genbank", |
|
53 |
"pride": "http://www.ncbi.nlm.nih.gov/nucest/%s?report=genbank", |
|
54 |
"ddbj": "http://www.ncbi.nlm.nih.gov/nucest/%s?report=genbank", |
|
55 |
"bioproject": "http://www.ncbi.nlm.nih.gov/nucest/%s?report=genbank", |
|
56 |
"embl": "http://www.ncbi.nlm.nih.gov/nucest/%s?report=genbank", |
|
57 |
"sra": "http://www.ncbi.nlm.nih.gov/nucest/%s?report=genbank", |
|
58 |
} |
|
35 | 59 |
|
60 |
|
|
36 | 61 |
class InvalidUsage(Exception): |
37 | 62 |
status_code = 400 |
38 | 63 |
|
... | ... | |
95 | 120 |
return "" |
96 | 121 |
|
97 | 122 |
|
123 |
@app.route('/api/resolveId', methods=['get']) |
|
124 |
def resolveIdentifier(): |
|
125 |
pid = request.form.get('pid') |
|
126 |
pid_type = request.form.get('pid_type') |
|
127 |
if pid_type!= None: |
|
128 |
if pid_type.lower() in pid_resolver: |
|
129 |
return pid_resolver[pid_type.lower()] % pid |
|
130 |
else: |
|
131 |
return "http://identifiers.org/%s:%s" % (pid_type, pid) |
|
132 |
return "" |
|
133 |
|
|
134 |
|
|
135 |
|
|
98 | 136 |
@app.route('/api/post/', methods=['post', 'get']) |
99 | 137 |
def query_post(): |
100 | 138 |
action = None |
... | ... | |
108 | 146 |
if 'query' in request.form: |
109 | 147 |
query = request.form['query'] |
110 | 148 |
if 'start' in request.form: |
111 |
start = int(request.form['start']) |
|
149 |
start = 0 |
|
150 |
try: |
|
151 |
start = int(request.form.get('start',0)) |
|
152 |
except: |
|
153 |
pass |
|
112 | 154 |
if 'filter' in request.form: |
113 | 155 |
filter_key = request.form['filter'] |
114 | 156 |
|
... | ... | |
128 | 170 |
app.logger.addHandler(dlilogger) |
129 | 171 |
monitor(app, port=8000) |
130 | 172 |
app.run() |
173 |
# app.run(host="0.0.0.0") |
Also available in: Unified diff
made a new look