-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi_doc.php
More file actions
542 lines (482 loc) · 13.9 KB
/
api_doc.php
File metadata and controls
542 lines (482 loc) · 13.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
<!DOCTYPE html>
<html>
<head>
<title>POGO API</title>
<link rel="stylesheet" type="text/css" href="default.css">
<link rel="stylesheet" type="text/css" href="doc.css">
</head>
<?php include 'noscript.php'; ?>
<div id=container>
<?php include 'header.php'; ?>
<div class=main>
<h1>API Documentation</h1>
<p>
This page contains documentation and examples for our API. This API can
be used to query the Pogo database directly.
</p>
<div class=toc>
<ol>
<li><a href="#introduction">Introduction</a></li>
<li><a href="#organization">Organization</a></li>
<li><a href="#query_basics">Query basics</a></li>
<li><a href="#methods">Methods</a></li>
<ol type="a">
<li><a href="#type">Type</a></li>
<li><a href="#select">Select</a></li>
<li><a href="#where">Where</a></li>
<li><a href="#limit">Limit</a></li>
<li><a href="#output">Output</a></li>
<li><a href="#array">Array</a></li>
</ol>
<li><a href="#properties">Properties</a></li>
<ol type="a">
<li><a href="#taxonomy">Taxonomy</a></li>
<li><a href="#data">Comparison Data</a></li>
<li><a href="#download">Blast Files</a></li>
</ol>
<li><a href="#examples">Examples</a></li>
</ol>
</div>
<h2 id="introduction" style="border:0">Introduction</h2>
<p>
A key feature of POGO is the ability for users to be able to mass query
our database. Our web interface has a certain use-case, and we recognize that
users may have different needs than our website provides. They might have a
different workflow, need to feed our data through a pipeline, or download
large sets of data.
</p>
<p>
In order to remedy this, we provide users not only with the ability to <a
href="download.php">download</a> our entire database, but also with the ability
to directly query the database for information they are interested in.
</p>
<h2 id="organization">Organization</h2>
<p>
POGO's database is internally represented by two tables. The data table
contains comparison data between two genomes, and the taxonomy table
containing taxonomic information about the genomes.
</p>
<p>
Our database's API returns JSON formatted arrays or CSV files, and uses REST's
"GET" mechanism to work. POGO's database API is loosely based around SQL select
statements, since we use MySQL as our database backend.
</p>
<h2 id="query_basics">Query Basics</h2>
Users can query the website using this url:
<code>
http://pogo.ece.drexel.edu/query.php
</code>
<p>
Queries are done by specifying certain GET variables in the URL. An example of
this can be seen below, where we query the taxonomy table for all rows with the
columns species, genome, and family.
</p>
<code>
http://pogo.ece.drexel.edu/query.php?type=taxonomy&select=species,genome,family&limit=10
</code>
<p>To get more specific results we need to tell the database to return only rows
that fit what we are interested in. As you saw above, we can tell the database what
columns we are interested in, but we now need to tell it what columns we are
interested in</p>
<p>
The 'methods' section below explains how we can do just that.
</p>
<h1 id="methods">Methods</h1>
There are three main methods that our API accepts. Type, Select, and Where.
There are also other arguments including and Array, and Limit and Output.
<h2 id="type">Type</h2>
<p>
The Type argument tells the API which table you are querying, and is
always required when using the API. There are only two options,
"data" and "taxonomy".
</p>
<p> The taxonomy table contains information about the different
genomes that were compared.
</p>
<p>Taxonomy Example:
<code>
http://pogo.ece.drexel.edu/query.php?type=taxonomy&limit=10
</code>
</p>
<p> The data table contains data from the comparisons.
</p>
<p>Data Example:
<code>
http://pogo.ece.drexel.edu/query.php?type=data&limit=10
</code>
<p>
<h2 id="select">Select</h2>
<p>
The Select argument allows you to choose which columns you are interested in.
To know what columns are available please refer to the Properties section of
this document.
</p>
<p>
If no results are returned, then all rows in the selected table are returned
</p>
<p>
This example returns the columns genus, species, ord, and superkingdom
from the taxonomy table:
<code>
http://pogo.ece.drexel.edu/query.php?type=taxonomy&select=genus,species,ord,superkingdom&limit=10
</code>
</p>
<p>
This example returns the columns id from data
from the data table:
<code>
http://pogo.ece.drexel.edu/query.php?type=data&select=id&limit=10
</code>
</p>
<h2 id="where">Where</h2>
<p>
The Where argument allows you to filter the rows based upon a statement.
These operators and statements should be familiar to anyone with rudimentary
knowledge of logic or programming.
</p>
<p>
At the bottom of this document are examples for different where statements
</p>
<p>
The operators we support are listed below
</p>
<table class="doc_table" style="display:inline-block">
<thead>
<tr>
<th>Equality Operator</th>
<th>Explanation</th>
</tr>
</thead>
<tbody>
<tr>
<td>=</td>
<td>equal</td>
</tr>
<tr>
<td><</td>
<td>less than</td>
</tr>
<tr>
<td>></td>
<td>greater than</td>
</tr>
<tr>
<td>!</td>
<td>not. this operator proceeds others, like !=</td>
</tr>
<tr>
<td>and</td>
<td>AND operator instead of &&</td>
</tr>
<tr>
<td>or</td>
<td>OR operator</td>
</tr>
<tr>
<td>xor</td>
<td>Exclusive OR operator</td>
</tr>
</tbody>
</table>
<p>We also support other statements that allow users to do string comparisons.
<table class="doc_table" style="display:inline-block">
<thead>
<tr>
<th>String Comparison</th>
<th>Explanation</th>
<th>Usage</th>
</tr>
</thead>
<tbody>
<tr>
<td>like(string)</td>
<td>wrapper for MySQL LIKE</td>
<td>genus like('Chlamy')</td>
</tr>
</tbody>
</table>
<h3>Examples</h3>
<p>
Select all columns from rows where the genus is Bacillus
<code>
http://pogo.ece.drexel.edu/query.php?type=taxonomy&where=genus='Bacillus'
</code>
</p>
<p>
Select all taxonomy where the genus contains 'Actino'
<code>
http://pogo.ece.drexel.edu/query.php?type=taxonomy&where=genus like('Actino')
</code>
</p>
<p>
Select all data where the Genomic_Fluidity is over 90%
<code>
http://pogo.ece.drexel.edu/query.php?type=data&where=Genomic_Fluidity>.90
</code>
</p>
<p>
Select all data where the Genomic_Fluidity is over 90% or less than 20%
<code>
http://pogo.ece.drexel.edu/query.php?type=data&where=Genomic_Fluidity>.90 OR Genomic_Fluidity<.20
</code>
</p>
<h3>Warning: Order of Operations</h3>
<p>
Consider that the following statement could have multiple meanings: Select all
taxonomy where the Genomic_Fluidity is over 90% or less than 20% and Average
Amino Acid Identity is over 90%.</p>
<p>
Using parentheses we can control the order of evaluation in a statement. This
is the same as with math, inside to outside. It also follows the same style
as most programming languages.
</p>
<p>
Here we have a statement where we select where Genomic_Fluidity is either over 90%, or is less than 20% and has an AAAI over 90%.
<code>
http://pogo.ece.drexel.edu/query.php?type=data&where=(Genomic_Fluidity > .90) or (Genomic_Fluidity < .20 AND Average_Amino_Acid_Identity > .90 )
</code>
</p>
<h2 id="limit">Limit</h2>
<p> The Limit argument allows the user to specify how many results you want to return at maximum</p>
<code>
http://pogo.ece.drexel.edu/query.php?type=data&limit=1000
</code>
<h2 id="output">Output</h2>
<p>The Output argument allows you to specify if you want CSV or JSON output. By default a JSON array will be returned.
</p>
<code>
http://pogo.ece.drexel.edu/query.php?type=data&limit=1000&output=csv
</code>
<h2 id="array">Array</h2>
<p>The Array argument allows you to specify if you want either a JSON
Associative Array, or a Indexed Array, if you are using JSON as your output
type. For more information read this <a
href="http://w3schools.com/php/php_arrays.asp">link</a>.</p>
<p>
This argument is optional, and the POGO database will return numerical arrays
by default.
</p>
<table class="doc_table" style="display:inline-block">
<thead>
<tr>
<th>Option</th>
<th>Explanation</th>
</tr>
</thead>
<tbody>
<tr>
<td>ASSOC</td>
<td>Associative Array</td>
</tr>
<tr>
<td>NUM</td>
<td>Numerical Array</td>
</tr>
</tbody>
</table>
<p>This is an example of returning an associative array in the data table</p>
<code>
http://pogo.ece.drexel.edu/query.php?type=data&output=JSON&array=ASSOC&limit=10
</code>
<h1 id="properties">Properties</h1>
<p>
This section details the columns available in our data and taxonomy tables. Each
column can be used in where statements, and in the select arguments.
</p>
<h2 id="taxonomy">Taxonomy Table</h2>
<p>
Our taxonomy table is collected from NCBI with some small changes.
</p>
<table class="doc_table">
<thead>
<tr>
<th>Column Name</th>
<th>Description</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>id</td>
<td>This is a unique identifier for the genome. genome_id1 and genome_id2 in
the data table correspond to these values.</td>
<td>integer</td>
</tr>
<tr>
<td>genome</td>
<td>The name of the genome, which also is also a unique identifier.
</td>
<td>string</td>
</tr>
<tr>
<td>phylum</td>
<td>Phylum of genome.</td>
<td>string</td>
</tr>
<tr>
<td>class</td>
<td>Class of genome.</td>
<td>string</td>
</tr>
<tr>
<td>ord</td>
<td>Order of genome.</td>
<td>string</td>
</tr>
<tr>
<td>family</td>
<td>Family of genome.</td>
<td>string</td>
</tr>
<tr>
<td>genus</td>
<td>Genus of genome.</td>
<td>string</td>
</tr>
<tr>
<td>species</td>
<td>Species of genome.</td>
<td>string</td>
</tr>
<tr>
<td>superkingdom</td>
<td>Superkingdom of genome.</td>
<td>string</td>
</tr>
</tbody>
</table>
<h2 id="data">Comparison Data</h2>
<p>
The comparison table contains all the information you see on the regular
webpage, like orthologs, 16S_rRNA, and other marker genes.
</p>
<table class="doc_table">
<thead>
<th>Column Name</th>
<th>Description</th>
<th>Type</th>
</thead>
<tbody>
<tr>
<td>id</td>
<td>This is a unique identifier for the genome comparison.</td>
<td>integer</td>
</tr>
<tr>
<td>genome_id1, genome_id2</td>
<td>An id of one of the two genomes in the comparison.
</td>
<td>string</td>
</tr>
<tr>
<td>number_of_genes1, number_of_genes2</td>
<td>Number of genes from respective genome in comparison.</td>
<td>integer</td>
</tr>
<tr>
<td>orthologs_criterion1, orthologs_criterion2</td>
<td>See the about page for more about ortholog criterions.</td>
<td>integer</td>
</tr>
<tr>
<td>Average_Amino_Acid_Identity</td>
<td>The Average Amino Acid Identity. See the about page for more.</td>
<td>float</td>
</tr>
<tr>
<td>Genomic_Fluidity</td>
<td>See about page for more about Genomic Fluidity</td>
<td>float</td>
</tr>
<tr>
<td>16S_rRNA</td>
<td>16S_rRNA identity</td>
<td>float</td>
</tr>
<tr>
<td>ArgS, CdsA, CoaE, etc.</td>
<td>other (besides 16S rRNA) marker gene identities</td>
<td>float</td>
</tr>
<tr>
<td>genome1_name, genome2_name</td>
<td>the name of the genome.</td>
<td>string</td>
</tr>
<tr>
<td>genome1_phylum, genome2_phylum</td>
<td>the phylum of the genome.</td>
<td>string</td>
</tr>
<tr>
<td>genome1_class, genome2_class</td>
<td>the class of the genome.</td>
<td>string</td>
</tr>
<tr>
<td>genome1_genus, genome2_genus</td>
<td>the genus of the genome.</td>
<td>string</td>
</tr>
<tr>
<td>genome1_species, genome2_species</td>
<td>the species of the genome.</td>
<td>string</td>
</tr>
<tr>
<td>genome1_superkingdom, genome2_superkingdom</td>
<td>the superkingdom of the genome.</td>
<td>string</td>
</tr>
</tbody>
</table>
<h2 id="download">Blast files</h2>
<p>
In order to get a tarball of blast files from our database, you need to
query our download url. This is done in the same method as the regular
query.
</p>
<p>
The ids variable corresponds to the "id" column in the comparison table.
</p>
<p>
This example requests a tarball containing blast files from comparisons with
the id's 2354, 19201, and 623719.
</p>
<code>
http://pogo.ece.drexel.edu/download.php?ids=2354,19201,623719
</code>
<h1 id="examples">Examples</h1>
<h2>Taxonomy Comparisons</h2>
Comparing genus's and other taxonomy is slightly more complicated because there
are two different genomes in each comparison, but we aren't ever sure if which
one is categorized as genome1 or genome2. Therefore you need to have slightly
more complex statements to properly select based upon taxonomy.
here's a pseudo-code where statement on how to correctly ask for all A vs B:
<code><pre>
if (genome1_genus is A and genome2_genus is B)
OR
if (genome1_genus is B and genome2_genus is A)
>>> Then show me the results
</pre></code>
<h3>One Genus vs Another</h3>
<code>
http://pogo.ece.drexel.edu/query.php?type=data&where=(genome1_genus='Bacillus' and genome2_genus='Chlamydia') or (genome1_genus='Chlamydia' and genome2_genus='Bacillus')
</code>
<h3>One Genus vs Itself</h3>
<code>
http://pogo.ece.drexel.edu/query.php?type=data&where=genome1_genus='Bacillus' and genome2_genus='Bacillus'
</code>
<h3>One Species vs All Others</h3>
<code>
http://pogo.ece.drexel.edu/query.php?type=data&where=genome1_species='Haemophilus influenzae' or genome2_species='Haemophilus influenzae'
</code>
<h3>One Species vs Itself</h3>
<code>
http://pogo.ece.drexel.edu/query.php?type=data&where=genome1_species='Haemophilus influenzae' and genome2_species='Haemophilus influenzae'
</code>
</div>
<?php include 'footer.php'; ?>
</div>
</body>
</html>