| 1 |
<HTML> |
| 2 |
|
| 3 |
<HEAD> |
| 4 |
<TITLE>AQL examples - C.elegans Genome Database</TITLE> |
| 5 |
<LINK REL="stylesheet" TYPE="text/css" HREF="./aql.css" TITLE="Style sheet for AQL docs"> |
| 6 |
<STYLE type="text/css"> |
| 7 |
<!-- |
| 8 |
code { white-space: pre; margin-top: 15; margin-bottom: 2; } |
| 9 |
--> |
| 10 |
</STYLE> |
| 11 |
</HEAD> |
| 12 |
<BODY> |
| 13 |
|
| 14 |
<H2>AQL examples - C.elegans Genome Database </H2> |
| 15 |
|
| 16 |
<P>These queries work on the full-sized |
| 17 |
<A HREF="http://wormsrv1.sanger.ac.uk"><I>C. elegans</I> Genome Database</A> |
| 18 |
and most will work on the sequence-less smaller version, |
| 19 |
the mini version used in acedb courses and on other genomic |
| 20 |
databases, with only minor alterations.</P> |
| 21 |
|
| 22 |
|
| 23 |
<P>The queries were originally designed to utilise all the operators |
| 24 |
or keywords provided in the old query lvanguage. |
| 25 |
The old language is still functional, but the queries have been |
| 26 |
converted to AQL. These examples make use of recent AQL features |
| 27 |
which are available in version 4.8b and above. |
| 28 |
<BR> |
| 29 |
Some queries have been formatted over multiple lines for readability. |
| 30 |
When typing multi-line queries in the standard acedb command-shell <B>tace</B>, |
| 31 |
the backslash character has to be appended to the end of each line, |
| 32 |
which will allow one command to be continued over more than one input line. |
| 33 |
<BR> |
| 34 |
Multiline queries can be typed in the AQL test-program <B>taql</B>. |
| 35 |
The query is executed after entering a blank line. |
| 36 |
</P> |
| 37 |
|
| 38 |
|
| 39 |
<P>Only a small subset of classes are used in order to simplify matters. It is |
| 40 |
essential to know the class model of any class before writing a query. |
| 41 |
<BR> |
| 42 |
On an active database you can select a list of all the Class models, |
| 43 |
then open the relevant one. Or you can open the models file using |
| 44 |
a text editor. This file is in the wspec directory as models.wrm.</P> |
| 45 |
|
| 46 |
<P>There are several different ways of writing each query, |
| 47 |
only some of which are ilustrated below.</P> |
| 48 |
|
| 49 |
<P>Questions 1 to 5 give answers in the form of tables, at their simplest |
| 50 |
1 column tables, which therefore resemble a list. Question 6 requires |
| 51 |
a numerical answer having counted the number of objects which satisfy |
| 52 |
a condition. In question 7, the query jumps from one class to another |
| 53 |
and back again For simplicity this is hown in two stages.</P> |
| 54 |
|
| 55 |
<P>Question 8 demonstrates the power of AQL to move along a horizontal |
| 56 |
line in a model from primary tag to secondary or along several |
| 57 |
consecutive data-fields.</P> |
| 58 |
|
| 59 |
<H3>Listing objects using conditions on tags and object names</H3> |
| 60 |
|
| 61 |
<DL> |
| 62 |
<DT><H4>1a. Find all Loci starting with the letters dp</H4></DT> |
| 63 |
|
| 64 |
<DD><CODE>select l from l in class locus where l.name like "dp*"</CODE></DD> |
| 65 |
<DD><CODE>select all from class locus where .name like "dp*"</CODE></DD> |
| 66 |
<DD><CODE>select all from class locus."dp*"</CODE> |
| 67 |
This notation is reminiscent of the <TT>Find Locus dp*</TT> notation |
| 68 |
of the old query-language. It may run marginally quicker than |
| 69 |
the first two queries. |
| 70 |
</DD> |
| 71 |
<DD><CODE>select l from l in class locus."dp*"</CODE> |
| 72 |
The query, but using a named iterator "l". |
| 73 |
</DD> |
| 74 |
</DL> |
| 75 |
|
| 76 |
<DL> |
| 77 |
<DT><H4>1b. Find all Authors starting with the letters Ba</H4></DT> |
| 78 |
|
| 79 |
<DD><CODE>select all class author where .name like "ba*"</CODE> |
| 80 |
Same as 1a. All the variations also apply. |
| 81 |
</DD> |
| 82 |
</DL> |
| 83 |
|
| 84 |
<DL> |
| 85 |
<DT><H4>2a. Find all Authors with email addresses</H4></DT> |
| 86 |
|
| 87 |
<DD><CODE>select all class Author where exists_tag ->E_mail</CODE> |
| 88 |
The <B>exists_tag</B> keyword is a boolean expression, which |
| 89 |
causes the where-clause to succeed or fail depending on |
| 90 |
whether the iterator succeeds to find the tag.<BR> |
| 91 |
The expression ->E_mail would normally be expanded to ->E_mail[1] |
| 92 |
(i.e. return the first data-field to the right of the tag), but |
| 93 |
<B>exists_tag</B> will inhibit this particular behaviour |
| 94 |
for the expression that follows. |
| 95 |
</DD> |
| 96 |
<DD><CODE>select all from class Author where exists_tag ->E_mail</CODE></DD> |
| 97 |
<DD><CODE>select a from a in class Author where exists a->E_mail[0]</CODE> |
| 98 |
When using the keyword <B>exists</B> the normal behaviour on |
| 99 |
tag-expressions applies. In order to refer to the existence |
| 100 |
of the tag E_mail, we specify the 0'th position from the tag, i.e. |
| 101 |
the tag itself. This is the long-hand version of the first query, |
| 102 |
which will internally be converted to this query anyway before |
| 103 |
execution. Both versions are therefore identical. |
| 104 |
</DD> |
| 105 |
</DL> |
| 106 |
|
| 107 |
<H3>Use of logical operators : and or xor not</H3> |
| 108 |
|
| 109 |
|
| 110 |
<DL> |
| 111 |
<DT><H4>2b. Find all Authors whose name begins with C, and who have email addresses</H4></DT> |
| 112 |
|
| 113 |
<DD><CODE>select a from a in class Author |
| 114 |
where a.name like "C*" and exists_tag a->E_mail</CODE> |
| 115 |
</DD> |
| 116 |
</DL> |
| 117 |
|
| 118 |
<DL> |
| 119 |
<DT><H4>2c. find all the authors whose object_name (surname) starts with 'a' and contains 'o'.</H4></DT> |
| 120 |
|
| 121 |
<DD><CODE>select all class Author where .name like "a*" and .name like "*o*"</CODE></DD> |
| 122 |
</DL> |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
<DL> |
| 127 |
<DT><H4>3a. Find all Authors that have either an address OR a published paper.</H4></DT> |
| 128 |
|
| 129 |
<DD><CODE>select all class Author |
| 130 |
where exists_tag ->Address or exists_tag ->Paper</CODE></DD> |
| 131 |
</DL> |
| 132 |
|
| 133 |
|
| 134 |
<DL> |
| 135 |
<DT><H4>3b. Find all Authors starting with C, with an address OR a paper.</H4></DT> |
| 136 |
|
| 137 |
<DD><CODE>select all class Author where .name like "C*" |
| 138 |
and |
| 139 |
(exists_tag ->Address or exists_tag ->Paper)</CODE></DD> |
| 140 |
</DL> |
| 141 |
|
| 142 |
<DL> |
| 143 |
<DT><H4>3c. Find all Authors starting with C, with address AND a Paper</H4></DT> |
| 144 |
|
| 145 |
<DD><CODE>select all class Author where .name like "C*" and |
| 146 |
exists_tag ->Address and |
| 147 |
exists_tag ->Paper</CODE></DD> |
| 148 |
</DL> |
| 149 |
|
| 150 |
<DL> |
| 151 |
<DT><H4>3d.Find all Authors starting with c, with either an address or a Paper but NOT both.</H4></DT> |
| 152 |
|
| 153 |
<DD><CODE>select all class Author where .name like "C*" |
| 154 |
and |
| 155 |
(exists_tag ->Address xor exists_tag ->Paper)</CODE></DD> |
| 156 |
</DL> |
| 157 |
|
| 158 |
<DL> |
| 159 |
<DT><H4>3e. Find all Authors starting with c, with NO address</H4></DT> |
| 160 |
|
| 161 |
<DD><CODE>select all class Author where not exists_tag ->Address</CODE></DD> |
| 162 |
</DL> |
| 163 |
|
| 164 |
|
| 165 |
<H3>Conditions on tags and their values</H3> |
| 166 |
|
| 167 |
|
| 168 |
<DL> |
| 169 |
<DT><H4>4a. Find authors who live in California OR Japan.</H4></DT> |
| 170 |
|
| 171 |
<DD><CODE>select all class Author |
| 172 |
where ->Mail like "*Calif*" or ->Mail like "*Japan"</CODE></DD> |
| 173 |
<DD><CODE>select a, a->mail from a in class Author |
| 174 |
where a->Mail like "*Calif*" or a->Mail like "*Japan"</CODE></DD> |
| 175 |
</DL> |
| 176 |
|
| 177 |
<DL> |
| 178 |
<DT><H4>4b. Find authors who live in USA and work in an American University.</H4></DT> |
| 179 |
|
| 180 |
<DD><CODE>select all class Author where ->E_Mail like "*edu"</CODE></DD> |
| 181 |
<DD><CODE>select a, a->E_mail from a in class Author where a->E_Mail like "*edu"</CODE></DD> |
| 182 |
<DD><CODE>select a, a->E_mail from a in class Author where a->E_Mail like "*edu" order</CODE></DD> |
| 183 |
<DD><CODE>select a, a->E_mail from a in class Author |
| 184 |
where a->E_Mail like "*edu" order by :1 asc, :2 asc</CODE></DD> |
| 185 |
<DD><CODE>select a, a->E_mail from a in class Author |
| 186 |
where a->E_Mail like "*edu" order by :E_mail</CODE></DD> |
| 187 |
</DL> |
| 188 |
|
| 189 |
<DL> |
| 190 |
<DT><H4>5. Find the Authors who have more than 5 papers published.</H4></DT> |
| 191 |
|
| 192 |
<DD><CODE>select all class author where count (select ->Paper) > 5</CODE></DD> |
| 193 |
<DD><CODE>select a, count (select a->Paper) from a in class author |
| 194 |
where count (select a->Paper) > 5</CODE></DD> |
| 195 |
<DD><CODE>select a,c from a in class author, c in count (select a->Paper) where c > 5</CODE> |
| 196 |
Here the iterator c is declared upoin the value of the <B>count</B> expression. |
| 197 |
We can now refer to <B>c</B> in various places in the query without having |
| 198 |
to repeat the <B>count</B> function like in the previous query. |
| 199 |
</DD> |
| 200 |
</DL> |
| 201 |
|
| 202 |
<H3>Crossing between classes</H3> |
| 203 |
|
| 204 |
<DL> |
| 205 |
<DT><H4>6a. Find papers published by Ian Hope.</H4></DT> |
| 206 |
|
| 207 |
<DD><CODE>select ->paper from class Author."hope*"</CODE></DD> |
| 208 |
<DD><CODE>select a, a->paper from a in class Author where a.name like "*hope*"</CODE> |
| 209 |
We find the author by matching every auhtor's name against the |
| 210 |
template "*hope*". The iterator <B>a</B> will therefore loop over all |
| 211 |
authors, just to find one single entry. |
| 212 |
</DD> |
| 213 |
<DD><CODE>select hope->paper from hope in object("Author", "Hope IA")</CODE> |
| 214 |
The <B>object</B>-constructor is perfect for situations where we know the exact |
| 215 |
class and object-name. Rather than the class-based declaration <B>a in class Author</B> |
| 216 |
which return multiple entries, the object constructor will only return |
| 217 |
one single entry and is very quick to execute. No wildcards are allowed |
| 218 |
in the class or object-name text. |
| 219 |
</DD> |
| 220 |
<DD><CODE>select object("Author", "Hope IA")->paper</CODE> |
| 221 |
The same query but shorter. The return value from the <B>object</B>-constructor |
| 222 |
can be dereferenced directly. and without an explicit from-clause, this |
| 223 |
query forms a complete table-expression. |
| 224 |
</DD> |
| 225 |
</DL> |
| 226 |
|
| 227 |
<DL> |
| 228 |
<DT><H4>6b. Find the co-authors of papers published by Ian Hope.</H4></DT> |
| 229 |
|
| 230 |
<DD><CODE>select a->paper->author from a in class Author where a.name like "*hope*"</CODE> |
| 231 |
Any expression, such as <B>a->paper</B> which returns another object-value |
| 232 |
can be further dereferenced to any tag in the model of that object. |
| 233 |
</DD> |
| 234 |
<DD><CODE>select ca from a in class Author where a.name like "*hope*", ca in a->paper->author</CODE></DD> |
| 235 |
<DD><CODE>select ca from a in class Author."*hope*", ca in a->paper->author</CODE></DD> |
| 236 |
<DD><CODE>select hope->Paper->Author from hope in object ("Author", "Hope IA")</CODE> - fastest</DD> |
| 237 |
<DD><CODE>select hope->paper, hope->paper->Author from hope in object ("Author", "Hope IA")</CODE></DD> |
| 238 |
</DL> |
| 239 |
|
| 240 |
<H3>Moving along a line in a model</h3> |
| 241 |
|
| 242 |
<DL> |
| 243 |
<DT><H4>7. Find Sequences from DDBJ whose Accession number contains *269*</H4></DT> |
| 244 |
|
| 245 |
<DD><P>Looking at the relevant part of the Sequence model before starting this complex query :</P> |
| 246 |
|
| 247 |
<PRE> |
| 248 |
?Sequence |
| 249 |
.. |
| 250 |
DB_info Database ?Database Text Text |
| 251 |
.. |
| 252 |
</PRE> |
| 253 |
<P>where DB_info is a major tag similar to Address, Database is a sub-tag like Town and |
| 254 |
takes the name of the database, the text fields take the Identity name followed by the |
| 255 |
Accession number.</P> |
| 256 |
</DD> |
| 257 |
|
| 258 |
<DD><CODE>select s from s in class Sequence, |
| 259 |
db in s->Database |
| 260 |
where db = "DDBJ" and |
| 261 |
db[2] like "*269*"</CODE> |
| 262 |
We have already learned that the default position of a tag-expression |
| 263 |
will refer to the first data-field along from that tag. <B>s->Database</B> |
| 264 |
is therefore automatically treated as <B>s->Database[1]</B> in the above |
| 265 |
declaration of <B>db</B>. The notation <B>db[2]</B> will now move two |
| 266 |
position further along from <B>s->Database[1]</B> to return the last |
| 267 |
<I>Text</I>-element in the model. Moving along the model is incremental, |
| 268 |
to the last <I>Text</I>-element is in fact <B>s->Database[1][2]</B> |
| 269 |
or can also be written as <B>s->Database[3]</B> directly. |
| 270 |
</DD> |
| 271 |
<DD><CODE>select s, t from s in class Sequence, |
| 272 |
db in s->Database |
| 273 |
where db = "DDBJ", |
| 274 |
t in db[2] |
| 275 |
where t like "*269*"</CODE> |
| 276 |
Same query, but this time using two iterator declarations. |
| 277 |
</DD> |
| 278 |
</DL> |
| 279 |
|
| 280 |
<DL> |
| 281 |
<DT><H4>8a. Find genes on chromosome IV which have been sequenced.</H4></DT> |
| 282 |
|
| 283 |
<DD><CODE> |
| 284 |
select l from l in class locus |
| 285 |
where l->Map = "IV" and exists_tag l->Sequence</CODE></DD> |
| 286 |
<DD><CODE> |
| 287 |
select l, m, s from l in class locus, |
| 288 |
m in l->Map where m = "IV", |
| 289 |
s in l->Sequence</CODE></DD> |
| 290 |
<DD><CODE> |
| 291 |
select l, m, s from l in class locus, |
| 292 |
m in l->Map where m = "IV", |
| 293 |
s in l->Sequence where s</CODE> |
| 294 |
The last where-clause is treating the iterator <B>s</B> as a boolean |
| 295 |
expression. <B>s</B> is declared on <B>l->Sequence</B> and the where-clause |
| 296 |
whill be TRUE if there is a data attached to that tag, and FALSE |
| 297 |
when there is no data.</DD> |
| 298 |
<DD><CODE>select l, m, iss from l in class locus, |
| 299 |
m in l->Map where m = "IV", |
| 300 |
iss in exists_tag l->Sequence where iss</CODE> |
| 301 |
In this query the variable <B>iss</B> is a boolean variable which is |
| 302 |
declared upon the result of the exists_tag function.</DD> |
| 303 |
</DL> |
| 304 |
|
| 305 |
<DL> |
| 306 |
<DT><H4>8b. Variations on 8a.</H4></DT> |
| 307 |
|
| 308 |
<DD><P>try another chromosome such as III, use OR, |
| 309 |
find those NOT sequenced, any other variations.</P></DD> |
| 310 |
</DL> |
| 311 |
|
| 312 |
<DL> |
| 313 |
<DT><H4>9. List objects mapped on chromosome III with their map position</H4></DT> |
| 314 |
|
| 315 |
<DD><CODE>select g, gm[Position] |
| 316 |
from g in object("Map","III")->Contains[2], gm in g->Map |
| 317 |
where gm = "III"</CODE> |
| 318 |
The construction ->Contains[2] will find the items that are |
| 319 |
2 positions away from the tag Contains , i.e. its |
| 320 |
grandchildren, rather than its children. |
| 321 |
<BR> |
| 322 |
Next note that we must require that <B>gm = "III" </B>because <B>g</B> |
| 323 |
may have positions on multiple maps. Finally, note that we have |
| 324 |
written <B>gm[Position]</B>in the select-clause, because we do not |
| 325 |
want to dereference <B>gm</B> as an object pointer; instead we want |
| 326 |
to look at the attribute following <B>gm</B> in the <B>g</B> object. |
| 327 |
The positioning inside the same object is done here by name |
| 328 |
rather than by tag-position. |
| 329 |
</DD> |
| 330 |
</DL> |
| 331 |
|
| 332 |
|
| 333 |
<H3>Queries on objects containing hash structures.</H3> |
| 334 |
|
| 335 |
|
| 336 |
<DL> |
| 337 |
<DT><H4>10. Find loci between positions 5 and 10 on chromosome IV</H4></DT> |
| 338 |
|
| 339 |
<DD><P>Hash structures are inlined model-definition with their own name-space. |
| 340 |
They are defined using the # (hash) character in the model.wrm file. |
| 341 |
The use of those hash structures is totally transparent in AQL, and when |
| 342 |
constructing a query it is best to think of the hash-model to be inlined at the |
| 343 |
given position.</P> |
| 344 |
|
| 345 |
<P>Class Locus contains the following line where Map_position |
| 346 |
is a # (hash) structure :</P> |
| 347 |
<PRE> |
| 348 |
?Locus ... |
| 349 |
... |
| 350 |
Map ?Map XREF Locus #Map_position |
| 351 |
... |
| 352 |
|
| 353 |
?Map_position UNIQUE Position UNIQUE Float |
| 354 |
Ends Left UNIQUE Float |
| 355 |
Right UNIQUE Float |
| 356 |
</PRE> |
| 357 |
|
| 358 |
<P>Loci have point positions (see Position) on the genetic maps.</P> |
| 359 |
</DD> |
| 360 |
|
| 361 |
<DD><CODE>select l, pos from l in class Locus, |
| 362 |
map in l->Map where map = "IV", |
| 363 |
pos in map[Position] where pos > 5.0 and pos < 10.0</CODE></DD> |
| 364 |
</DL> |
| 365 |
|
| 366 |
<DL> |
| 367 |
<DT><H4>11a. Find Rearrangements with a right ends beyond position 5 on chromosome IV</H4></DT> |
| 368 |
|
| 369 |
<DD><P>Class Rearrangment has the following tags where Map_position |
| 370 |
is a hash structure</P> |
| 371 |
<PRE> |
| 372 |
?Rearrangement ... |
| 373 |
... |
| 374 |
Map ?Map XREF Rearrangement #Map_position |
| 375 |
... |
| 376 |
|
| 377 |
?Map_position UNIQUE Position UNIQUE Float |
| 378 |
Ends Left UNIQUE Float |
| 379 |
Right UNIQUE Float |
| 380 |
</PRE> |
| 381 |
|
| 382 |
<P>Rearrangements are deletions or duplications of a linear chunk of the chromosome |
| 383 |
and consequently have starting (Left) and finishing points (Right) on the map.</P></DD> |
| 384 |
|
| 385 |
<DD><CODE>select r, right from r in class Rearrangement, |
| 386 |
right in r->Map[Right] where right > 5.0</CODE></DD> |
| 387 |
<DD><CODE>select r, right from r in class Rearrangement, |
| 388 |
map in r->Map where map = "IV", |
| 389 |
right in map[right] where right > 5.0</CODE></DD> |
| 390 |
</DL> |
| 391 |
|
| 392 |
<DL> |
| 393 |
<DT><H4>11b. Find Rearrangements with left ends before position 4 on chromosome IV</H4></DT> |
| 394 |
|
| 395 |
<DD><CODE>select r, left from r in class Rearrangement, |
| 396 |
map in r->Map where map = "IV", |
| 397 |
left in map[Left] where left < 4.0</CODE></DD> |
| 398 |
</DL> |
| 399 |
|
| 400 |
<DL> |
| 401 |
<DT><H4>11c. Find Rearrangements with left ends before position 4 on chromosome IV and right ends beyond position 5</H4></DT> |
| 402 |
|
| 403 |
<DD><CODE>select r, left, right from r in class Rearrangement, |
| 404 |
map in r->Map where map = "IV", |
| 405 |
left in map[Left] where left < 4.0, |
| 406 |
right in map[right] where right > 5.0</CODE></DD> |
| 407 |
</DL> |
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
<H3>Using table functions</H3> |
| 412 |
|
| 413 |
<P>Table functions can be applied to the result of any table expression. |
| 414 |
Examples of table functions are <B>count, sum, avg, first, last</B> etc. |
| 415 |
A normal select-from-where query is such a table expression. A table function |
| 416 |
can only be used on tables with a single column are they have to be restricted |
| 417 |
to work only on one column of the given table.</P> |
| 418 |
|
| 419 |
|
| 420 |
<DL> |
| 421 |
<DT><H4>12. How many predicted genes have matching cDNA.?</H4></DT> |
| 422 |
<DD><P>Note : in the worm genome project, although clone objects (cosmids and |
| 423 |
Yacs) have been fed into the sequencing reactions, the DNA sequence of |
| 424 |
an entire clone (e.g. AH6) is attached to a sequence object, of the |
| 425 |
same name (also AH6). After gene predictions have been made in these |
| 426 |
cosmid sequences, each coding sequence has a number such as AH6.1, |
| 427 |
AH6.2. In the database these are held as subsequences of the main AH6 |
| 428 |
sequence. This particular type of subsequence has a definition called |
| 429 |
Predicted_gene in the subclass.wrm file. It is more efficient to use |
| 430 |
subclasses in queries, wherever possible.</P> |
| 431 |
|
| 432 |
<P>The first answer would take a very long time examining 140,000 |
| 433 |
sequence objects. The second uses the subclass and is faster. |
| 434 |
</P> |
| 435 |
</DD> |
| 436 |
<DD><CODE>select s from s in class sequence |
| 437 |
where exists_tag s->CDS |
| 438 |
and s.name like "*.*" |
| 439 |
and exists_tag s->Matching_cDNA</CODE></DD> |
| 440 |
<DD><CODE>select g from g in class predicted_gene |
| 441 |
where exists_tag s->Matching_cDNA</CODE> |
| 442 |
The class Predicted_Gene is a subclass of Sequence and the interator <B>g</B> |
| 443 |
will loop over a much smaller set of objects that in the first query |
| 444 |
when 140,000 objects are inspected.</DD> |
| 445 |
<DD><CODE>select count(select g from g in class predicted_gene |
| 446 |
where exists_tag s->Matching_cDNA)</CODE> |
| 447 |
By forming a query that reports only the result of the <B>count</B>-function |
| 448 |
we're left with a single number as a result.</DD> |
| 449 |
</DL> |
| 450 |
|
| 451 |
<DL> |
| 452 |
<DT><H4>13. How many predicted genes are equivalent to Mendelian loci.?</H4></DT> |
| 453 |
<DD><P>for explanation, see 12.</P></DD> |
| 454 |
|
| 455 |
<DD><CODE>select g from g in class predicted_gene where exists g->Locus</CODE></DD> |
| 456 |
<DD><CODE>select g, l from g in class predicted_gene, l in g->Locus where l</CODE></DD> |
| 457 |
<DD><CODE>select count (select g from g in class predicted_gene |
| 458 |
where exists g->Locus)</CODE></DD> |
| 459 |
</DL> |
| 460 |
|
| 461 |
<DL> |
| 462 |
<DT><H4>14. How may Clones have been finished by the Sanger centre sequencing team ?.</H4></DT> |
| 463 |
<DD><P>see explanation under 12 for use of sequence class here.</P></DD> |
| 464 |
|
| 465 |
<DD><CODE>$x := count(select s from s in class sequence where exists_tag s->Finished and s->From_Laboratory = "CB")</CODE> |
| 466 |
The keyword <EM>count</EM> with the query as its argument isn't a full query in its own right. |
| 467 |
To make it a valid table expression, we assign the result of the expression to a scalar variable <B>$x</B>. |
| 468 |
The result of the query is therefore the value of this variable, and the result table will |
| 469 |
have one row with one column containing the single result value.</DD> |
| 470 |
<DD><CODE>select s from s in object("sequence", "ah6") where exists_tag s->Finished and s->From_Laboratory = "CB"</CODE></DD> |
| 471 |
</DL> |
| 472 |
|
| 473 |
<DL> |
| 474 |
<DT><H4>15. How many contigs make up chromosome IV ?, or indeed any of the chromosomes.</H4></DT> |
| 475 |
|
| 476 |
<DD><CODE>select num from m in class Genetic_Map |
| 477 |
where m = "IV", |
| 478 |
num in count (select m->Contig)</CODE></DD> |
| 479 |
<DD><CODE>select m, num from m in class Genetic_Map, |
| 480 |
num in count (select m->Contig)</CODE></DD> |
| 481 |
</DL> |
| 482 |
|
| 483 |
<DL> |
| 484 |
<DT><H4>16. Which sequence objects have DNA ?</H4></DT> |
| 485 |
|
| 486 |
<DD><CODE>select s from s in class Sequence |
| 487 |
where exists_tag s->DNA</CODE> |
| 488 |
By using the keyword <EM>exists_tag</EM> we don't have to open |
| 489 |
every sequence object to look at its <I>DNA</I>-tag. This |
| 490 |
tag is indexed and the lookups to the database-index are very quick. |
| 491 |
Compare this qith the execution time of this query : </DD> |
| 492 |
|
| 493 |
<DD><CODE>select s from s in class Sequence |
| 494 |
where exists s->DNA</CODE> |
| 495 |
This query will check the existsnce of a data-value for the <I>DNA</I>-tag. |
| 496 |
To find this out it will have to open every sequence object, |
| 497 |
which will take a very long time.</DD> |
| 498 |
|
| 499 |
</DL> |
| 500 |
|
| 501 |
<DL> |
| 502 |
<DT><H4>17. How many sequences have DNA longer than 300 base pairs.</H4></DT> |
| 503 |
|
| 504 |
<DD><CODE>select s from s in class genome_sequence |
| 505 |
where exists_tag ->DNA, |
| 506 |
length in s->DNA[2] |
| 507 |
where length > 300</CODE></DD> |
| 508 |
</DL> |
| 509 |
|
| 510 |
<DL> |
| 511 |
<DT><H4>18. How many cells have great grandchildren ?</H4></DT> |
| 512 |
|
| 513 |
<DD><CODE>select count (select c from c in class cell, |
| 514 |
d1 in c->daughter where d1, |
| 515 |
d2 in d1->daughter where d2, |
| 516 |
d3 in d2->daughter where d3)</CODE></DD> |
| 517 |
<DD><CODE>select count (select c from c in class cell where exists c->daughter->daughter->daughter)</CODE></DD> |
| 518 |
|
| 519 |
</DL> |
| 520 |
|
| 521 |
<H3>Some queries which were designed to be performed with TableMaker.</H3> |
| 522 |
|
| 523 |
<P>When converted to AQL those queries are nothing special, and creating |
| 524 |
multi-columned tables of output is the strength of AQL</P> |
| 525 |
|
| 526 |
<DL> |
| 527 |
<DT><H4>19. Make a table of the email addresses and laboratories of worm authors.</H4></DT> |
| 528 |
|
| 529 |
<DD><CODE>select a, addr, a->laboratory from a in class author |
| 530 |
where exists_tag a->E_mail, |
| 531 |
addr in a->E_Mail</CODE></DD> |
| 532 |
<DD><CODE>select a, addr, lab from a in class author where exists_tag a->E_mail, |
| 533 |
lab in a->laboratory where lab, |
| 534 |
addr in a->E_Mail</CODE></DD> |
| 535 |
<DD><CODE>select a, addr, lab from a in class author |
| 536 |
addr in a->E_mail where addr, |
| 537 |
lab in a->laboratory where lab</CODE></DD> |
| 538 |
<DD><CODE>select a, a->E_mail, a->Laboratory from a in class author |
| 539 |
where exists_tag a->E_mail and exists_tag a->Laboratory</CODE></DD> |
| 540 |
</DL> |
| 541 |
|
| 542 |
<DL> |
| 543 |
<DT><H4>20. Make a table of Loci whose name begins with C, and the clones to which they have been mapped.</H4></DT> |
| 544 |
|
| 545 |
<DD><CODE>select l, c from l in class locus, |
| 546 |
c in l->positive_Clone where c.name like "c*"</CODE></DD> |
| 547 |
</DL> |
| 548 |
|
| 549 |
<DL> |
| 550 |
<DT><H4>21. Make a table of (Mendelian) genes on chromosome IV in the order</H4></DT> |
| 551 |
|
| 552 |
<DD><P>Note : Mendelian genes refers to those mapped by conventional crossing |
| 553 |
procedures. They should have associated map data and alleles (other than |
| 554 |
those created by Tc1 insertions).</P></DD> |
| 555 |
<DD><CODE>select l, pos from l in class locus where exists_tag l->Allele, |
| 556 |
map in l->Map where map = "X", |
| 557 |
pos in map[Position] order by :pos</CODE></DD> |
| 558 |
</DL> |
| 559 |
|
| 560 |
<H3>Gene expression at cellular level</H3> |
| 561 |
|
| 562 |
<DL> |
| 563 |
<DT><H4>Which genes are expressed in named cells</H4></DT> |
| 564 |
|
| 565 |
<DD><CODE>select l from l in class Locus, |
| 566 |
ex in l->Expr_pattern |
| 567 |
where exists ex->cell order</CODE></DD> |
| 568 |
</DL> |
| 569 |
|
| 570 |
|
| 571 |
<DL> |
| 572 |
<DT><H4>Which genes are expressed in neurons.</H4></DT> |
| 573 |
|
| 574 |
<DD><CODE>select c->Expr_pattern->locus from c in class Cell |
| 575 |
where c->Fate like "*neuron*" or c->Fate like "*Neuron*"</CODE></DD> |
| 576 |
</DL> |
| 577 |
|
| 578 |
|
| 579 |
<DL> |
| 580 |
<DT><H4>Which cells are known to have loci expressed in them.</H4></DT> |
| 581 |
|
| 582 |
<DD><CODE>select c, ex, l from c in class Cell, |
| 583 |
ex in c->Expr_pattern, |
| 584 |
l in ex->locus where l</CODE></DD> |
| 585 |
</DL> |
| 586 |
|
| 587 |
|
| 588 |
<DL> |
| 589 |
<DT><H4>Which loci are expressed in embryos ?</H4></DT> |
| 590 |
|
| 591 |
<DD><CODE>select l from l in class Locus, |
| 592 |
ex in l->Expr_pattern |
| 593 |
where ex->Life_stage like "*embryo*"</CODE></DD> |
| 594 |
|
| 595 |
<DD><CODE>select l from l in class Locus, |
| 596 |
ex in l->Expr_pattern |
| 597 |
where ex->Life_stage like "*larv*"</CODE> |
| 598 |
Finds the loci expressed in larvae.</DD> |
| 599 |
|
| 600 |
</DL> |
| 601 |
|
| 602 |
<DL> |
| 603 |
<DT><H4>Which loci are expressed in embryos but not in larvae ?</H4></DT> |
| 604 |
|
| 605 |
<DD><CODE> |
| 606 |
select l from l in class Locus, |
| 607 |
ex in l->Expr_pattern |
| 608 |
where ex->Life_stage like "*embryo*" diff |
| 609 |
select l from l in class Locus, |
| 610 |
ex in l->Expr_pattern |
| 611 |
where <U>not</U> ex->Life_stage like "*larv*"</CODE> |
| 612 |
We have simply combined the sets of loci expressed in embryos and not expressed |
| 613 |
in larvae using the the table operator <EM>union</EM>. |
| 614 |
<BR> |
| 615 |
Substitute the keyword <EM>union</EM> for <EM>minus</EM> or <EM>intersect</EM> to get different |
| 616 |
ways of combining the two sets of loci.</DD> |
| 617 |
|
| 618 |
<DD><CODE>select l from l in class Locus, |
| 619 |
ex in l->Expr_pattern |
| 620 |
where ex->Life_stage like "*embryo*" and |
| 621 |
not ex->Life_stage like "*larv*"</CODE> |
| 622 |
This query produces the same result, but is much quicker to write. |
| 623 |
</DD> |
| 624 |
</DL> |
| 625 |
|
| 626 |
|
| 627 |
<DL> |
| 628 |
<DT><H4>Which loci have no expression information ?</H4></DT> |
| 629 |
|
| 630 |
<DD><CODE>select l from l in class Locus where not exists l->expr_pattern</CODE></DD> |
| 631 |
</DL> |
| 632 |
|
| 633 |
<HR> |
| 634 |
Queries designed by Fred Wobus and Sylvia Martinelli.<BR> |
| 635 |
The Sanger Centre, 06/Dec/1999 |
| 636 |
|
| 637 |
<ADDRESS><A HREF="mailto:[email protected]">[email protected]</A></ADDRESS> |
| 638 |
|
| 639 |
</BODY> |
| 640 |
</HTML> |
| 641 |
|