NCBI C Toolkit Cross Reference

C/demo/testent2.c


  1 #include <ncbi.h>
  2 #include <asn.h>
  3 #include <objall.h>
  4 #include <objsub.h>
  5 #include <objfdef.h>
  6 #include <sqnutils.h>
  7 #include <ent2api.h>
  8 #include <urlquery.h>
  9 
 10 static void SaveEntrezRequest (Entrez2RequestPtr e2rq)
 11 
 12 {
 13   AsnIoPtr  aip;
 14 
 15   if (e2rq == NULL) return;
 16   aip = AsnIoOpen ("stdout", "w");
 17   if (aip == NULL) return;
 18   Entrez2RequestAsnWrite (e2rq, aip, NULL);
 19   AsnIoFlush (aip);
 20   AsnIoClose (aip);
 21   printf ("\n");
 22   fflush (stdout);
 23 }
 24 
 25 static void SaveEntrezReply (Entrez2ReplyPtr e2ry)
 26 
 27 {
 28   AsnIoPtr  aip;
 29 
 30   if (e2ry == NULL) {
 31     printf ("Entrez2ReplyPtr is NULL\n");
 32     return;
 33   }
 34   aip = AsnIoOpen ("stdout", "w");
 35   if (aip == NULL) return;
 36   Entrez2ReplyAsnWrite (e2ry, aip, NULL);
 37   AsnIoFlush (aip);
 38   AsnIoClose (aip);
 39   printf ("\n\n");
 40   fflush (stdout);
 41 }
 42 
 43 static void SaveBooleanIdList (Entrez2ReplyPtr e2ry)
 44 
 45 {
 46   Entrez2BooleanReplyPtr  e2br;
 47   Entrez2IdListPtr        e2lp;
 48   Int4                    i;
 49   E2ReplyPtr              reply;
 50   Uint4                   uid;
 51 
 52   if (e2ry == NULL) return;
 53   reply = e2ry->reply;
 54   if (reply == NULL || reply->choice != E2Reply_eval_boolean) return;
 55   e2br = EntrezExtractBooleanReply (e2ry);
 56   if (e2br == NULL) return;
 57 
 58   printf ("Boolean reply - count is %ld\n", (long) e2br->count);
 59   e2lp = e2br->uids;
 60   if (e2lp != NULL) {
 61     BSSeek (e2lp->uids, 0, SEEK_SET);
 62     for (i = 0; i < e2lp->num; i++) {
 63       uid = Nlm_BSGetUint4 (e2lp->uids);
 64       printf ("%ld\n", (long) uid);
 65     }
 66   }
 67   printf ("\n");
 68 
 69   Entrez2BooleanReplyFree (e2br);
 70 }
 71 
 72 static Int4 pmuidlist [] = {
 73   3038955,
 74   2539356
 75 };
 76 
 77 static Int4 jkuidlist [] = {
 78   11449736,
 79   11449725,
 80   10838572,
 81   9707937,
 82   9707929,
 83   8743683,
 84   1937004,
 85   2005826,
 86   2678811,
 87   2539356,
 88   7252148
 89 };
 90 
 91 static Int4 nucuidlist [] = {
 92   14993658,
 93   14971124
 94 };
 95 
 96 static Int4 protuidlist [] = {
 97   131784,
 98   172345
 99 };
100 
101 static Int4 taxuidlist [] = {
102   40674
103 };
104 
105 static Int4 DoInfoValidation (Entrez2ReplyPtr e2ry, Boolean showinfo)
106 
107 {
108   CharPtr              cookie;
109   Entrez2DbInfoPtr     e2db;
110   Entrez2FieldInfoPtr  e2fd;
111   Entrez2InfoPtr       e2ip;
112   ValNodePtr           head = NULL;
113   Int4                 orgtermcount = -1;
114   E2ReplyPtr           reply;
115   CharPtr              str;
116   ValNodePtr           vnp;
117 
118   if (e2ry != NULL) {
119     cookie = StringSave (e2ry->cookie);
120     reply = e2ry->reply;
121     if (showinfo) {
122       SaveEntrezReply (e2ry);
123     }
124     if (reply != NULL && reply->choice == E2Reply_get_info) {
125       e2ip = EntrezExtractInfoReply (e2ry);
126       if (ValidateEntrez2InfoPtr (e2ip, &head)) {
127         printf ("GetInfo validation succeeded\n");
128       } else {
129         printf ("GetInfo validation failed\n");
130         for (vnp = head; vnp != NULL; vnp = vnp->next) {
131           str = (CharPtr) vnp->data.ptrvalue;
132           if (str == NULL) continue;
133           printf ("%s\n", str);
134         }
135         ValNodeFreeData (head);
136       }
137       if (e2ip != NULL) {
138         for (e2db = e2ip->db_info; e2db != NULL; e2db = e2db->next) {
139           if (StringICmp (e2db->db_name, "nucleotide") == 0) {
140             for (e2fd = e2db->fields; e2fd != NULL; e2fd = e2fd->next) {
141               if (StringICmp (e2fd->field_name, "ORGN") == 0) {
142                 orgtermcount = e2fd->term_count;
143                 printf ("Nucleotide ORGN term count is %ld\n", orgtermcount);
144               }
145             }
146           }
147         }
148       }
149       Entrez2InfoFree (e2ip);
150     } else {
151       if (reply != NULL) {
152         printf ("GetInfo request returned reply choice %d\n", (int) reply->choice);
153         SaveEntrezReply (e2ry);
154       } else {
155         printf ("GetInfo request returned NULL reply\n");
156       }
157       Entrez2ReplyFree (e2ry);
158     }
159     if (cookie == NULL) {
160       cookie = "(null)";
161     }
162     printf ("initial returned cookie:\n%s\n\n", cookie);
163   } else {
164     printf ("GetInfo request failed\n\n");
165   }
166   return orgtermcount;
167 }
168 
169 static void NewTextE2 (Boolean showuids, Boolean showinfo)
170 
171 {
172   Entrez2RequestPtr  e2rq;
173   Entrez2ReplyPtr    e2ry;
174   CharPtr            key1 = NULL;
175   Int4               pos = -1;
176   CharPtr            str;
177 
178   e2rq = EntrezCreateGetInfoRequest ();
179   SaveEntrezRequest (e2rq);
180   e2ry = EntrezSynchronousQuery (e2rq);
181   e2rq = Entrez2RequestFree (e2rq);
182   DoInfoValidation (e2ry, showinfo);
183 
184   str = "\"1900/01/01\"[MDAT] : \"1993/12/31\"[MDAT]";
185   e2rq = EntrezCreateBooleanRequest (TRUE, TRUE, "nucleotide", str, 0, 0, NULL, 0, 0);
186   SaveEntrezRequest (e2rq);
187   e2ry = EntrezSynchronousQuery (e2rq);
188   e2rq = Entrez2RequestFree (e2rq);
189   if (e2ry != NULL) {
190     SaveEntrezReply (e2ry);
191     if (showuids) {
192       SaveBooleanIdList (e2ry); /* also frees e2ry */
193     } else {
194       Entrez2ReplyFree (e2ry);
195     }
196   } else {
197     printf ("Boolean request failed\n");
198   }
199 
200   e2rq = EntrezCreateBooleanRequest (FALSE, FALSE, "PubMed", NULL, 0, 0, NULL, 0, 0);
201   EntrezAddToBooleanRequest (e2rq, NULL, 0, NULL, NULL, NULL, 0, 11, jkuidlist, NULL, FALSE, FALSE);
202   SaveEntrezRequest (e2rq);
203   e2ry = EntrezSynchronousQuery (e2rq);
204   e2rq = Entrez2RequestFree (e2rq);
205   if (e2ry != NULL) {
206     key1 = StringSave (e2ry->key);
207     SaveEntrezReply (e2ry);
208     if (showuids) {
209       SaveBooleanIdList (e2ry); /* also frees e2ry */
210     } else {
211       Entrez2ReplyFree (e2ry);
212     }
213   } else {
214     printf ("Boolean request failed\n");
215   }
216 
217   e2rq = EntrezCreateBooleanRequest (FALSE, FALSE, "PubMed", NULL, 0, 0, NULL, 0, 0);
218   EntrezAddToBooleanRequest (e2rq, NULL, 0, NULL, NULL, key1, 0, 0, NULL, NULL, FALSE, FALSE);
219   SaveEntrezRequest (e2rq);
220   e2ry = EntrezSynchronousQuery (e2rq);
221   e2rq = Entrez2RequestFree (e2rq);
222   if (e2ry != NULL) {
223     SaveEntrezReply (e2ry);
224     if (showuids) {
225       SaveBooleanIdList (e2ry); /* also frees e2ry */
226     } else {
227       Entrez2ReplyFree (e2ry);
228     }
229   } else {
230     printf ("Boolean request failed\n");
231   }
232 
233   e2rq = EntrezCreateGetTermPositionRequest ("PubMed", "AUTH", "wheelan s");
234   SaveEntrezRequest (e2rq);
235   e2ry = EntrezSynchronousQuery (e2rq);
236   e2rq = Entrez2RequestFree (e2rq);
237   if (e2ry != NULL) {
238     SaveEntrezReply (e2ry);
239     pos = EntrezExtractTermPosReply (e2ry);
240     Entrez2ReplyFree (e2ry);
241   } else {
242     printf ("GetTermPosition request failed\n");
243   }
244 
245   if (pos >= 0) {
246     e2rq = EntrezCreateGetTermListRequest ("PubMed", "AUTH", pos, 4);
247     SaveEntrezRequest (e2rq);
248     e2ry = EntrezSynchronousQuery (e2rq);
249     e2rq = Entrez2RequestFree (e2rq);
250     if (e2ry != NULL) {
251       SaveEntrezReply (e2ry);
252       Entrez2ReplyFree (e2ry);
253     } else {
254       printf ("GetTermList request failed\n");
255     }
256   }
257 
258   e2rq = EntrezCreateBooleanRequest (FALSE, FALSE, "PubMed", NULL, 0, 0, NULL, 0, 0);
259   EntrezAddToBooleanRequest (e2rq, NULL, 0, "AUTH", "wheelan s", NULL, 0, 0, NULL, NULL, FALSE, FALSE);
260   SaveEntrezRequest (e2rq);
261   e2ry = EntrezSynchronousQuery (e2rq);
262   e2rq = Entrez2RequestFree (e2rq);
263   if (e2ry != NULL) {
264     SaveEntrezReply (e2ry);
265     if (showuids) {
266       SaveBooleanIdList (e2ry); /* also frees e2ry */
267     } else {
268       Entrez2ReplyFree (e2ry);
269     }
270   } else {
271     printf ("Boolean request failed\n");
272   }
273 
274   e2rq = EntrezCreateBooleanRequest (FALSE, FALSE, "PubMed", NULL, 0, 0, NULL, 0, 0);
275   EntrezAddToBooleanRequest (e2rq, NULL, 0, "AUTH", "wheelan s", NULL, 0, 0, NULL, NULL, FALSE, TRUE);
276   SaveEntrezRequest (e2rq);
277   e2ry = EntrezSynchronousQuery (e2rq);
278   e2rq = Entrez2RequestFree (e2rq);
279   if (e2ry != NULL) {
280     SaveEntrezReply (e2ry);
281     if (showuids) {
282       SaveBooleanIdList (e2ry); /* also frees e2ry */
283     } else {
284       Entrez2ReplyFree (e2ry);
285     }
286   } else {
287     printf ("Boolean request failed\n");
288   }
289 }
290 
291 static void TestE2 (Boolean dohuge, Boolean showuids, Boolean showinfo)
292 
293 {
294   Int4               count;
295   Entrez2RequestPtr  e2rq;
296   Entrez2ReplyPtr    e2ry;
297   CharPtr            key1 = NULL;
298   CharPtr            key2 = NULL;
299   CharPtr            key3 = NULL;
300   Int4               orgtermcount = -1;
301   Int4               pos = -1;
302   CharPtr            str;
303 
304   e2rq = EntrezCreateGetInfoRequest ();
305   SaveEntrezRequest (e2rq);
306   e2ry = EntrezSynchronousQuery (e2rq);
307   e2rq = Entrez2RequestFree (e2rq);
308   orgtermcount = DoInfoValidation (e2ry, showinfo);
309 
310   e2rq = EntrezCreateBooleanRequest (FALSE, FALSE, "taxonomy", NULL, 0, 0, NULL, 0, 0);
311   EntrezAddToBooleanRequest (e2rq, NULL, 0, NULL, NULL, NULL, 0, 1, taxuidlist, NULL, FALSE, FALSE);
312   SaveEntrezRequest (e2rq);
313   e2ry = EntrezSynchronousQuery (e2rq);
314   e2rq = Entrez2RequestFree (e2rq);
315   if (e2ry != NULL) {
316     SaveEntrezReply (e2ry);
317     if (showuids) {
318       SaveBooleanIdList (e2ry); /* also frees e2ry */
319     } else {
320       Entrez2ReplyFree (e2ry);
321     }
322   } else {
323     printf ("Boolean request failed\n");
324   }
325 
326   e2rq = EntrezCreateBooleanRequest (FALSE, TRUE, "PubMed", "ras mutation binding", 0, 0, NULL, 0, 0);
327   SaveEntrezRequest (e2rq);
328   e2ry = EntrezSynchronousQuery (e2rq);
329   e2rq = Entrez2RequestFree (e2rq);
330   if (e2ry != NULL) {
331     SaveEntrezReply (e2ry);
332     if (showuids) {
333       SaveBooleanIdList (e2ry); /* also frees e2ry */
334     } else {
335       Entrez2ReplyFree (e2ry);
336     }
337   } else {
338     printf ("Boolean request failed\n");
339   }
340 
341   e2rq = EntrezCreateBooleanRequest (TRUE, TRUE, "Nucleotide", "recA [BAD", 0, 0, NULL, 10, 0);
342   SaveEntrezRequest (e2rq);
343   e2ry = EntrezSynchronousQuery (e2rq);
344   e2rq = Entrez2RequestFree (e2rq);
345   if (e2ry != NULL) {
346     SaveEntrezReply (e2ry);
347     if (showuids) {
348       SaveBooleanIdList (e2ry); /* also frees e2ry */
349     } else {
350       Entrez2ReplyFree (e2ry);
351     }
352   } else {
353     printf ("Boolean request failed\n");
354   }
355 
356   e2rq = EntrezCreateGetTermPositionRequest ("nucleotide", "ORGN", "Zea");
357   SaveEntrezRequest (e2rq);
358   e2ry = EntrezSynchronousQuery (e2rq);
359   e2rq = Entrez2RequestFree (e2rq);
360   if (e2ry != NULL) {
361     SaveEntrezReply (e2ry);
362     pos = EntrezExtractTermPosReply (e2ry); /* also frees e2ry */
363     printf ("Zea position is %ld\n", pos);
364   } else {
365     printf ("GetTermPosition request failed\n");
366   }
367 
368   if (pos >= 0 && orgtermcount >= 0) {
369     count = 20;
370     if (pos + count >= orgtermcount) {
371       count = orgtermcount - pos - 1;
372     }
373     e2rq = EntrezCreateGetTermListRequest ("nucleotide", "ORGN", pos, count);
374     SaveEntrezRequest (e2rq);
375     e2ry = EntrezSynchronousQuery (e2rq);
376     e2rq = Entrez2RequestFree (e2rq);
377     if (e2ry != NULL) {
378       SaveEntrezReply (e2ry);
379       Entrez2ReplyFree (e2ry);
380     } else {
381       printf ("GetTermList request failed\n");
382     }
383   }
384 
385   e2rq = EntrezCreateDocSumRequest ("nucleotide", 1322283, 0, NULL, NULL);
386   SaveEntrezRequest (e2rq);
387   e2ry = EntrezSynchronousQuery (e2rq);
388   e2rq = Entrez2RequestFree (e2rq);
389   if (e2ry != NULL) {
390     SaveEntrezReply (e2ry);
391     Entrez2ReplyFree (e2ry);
392   } else {
393     printf ("DocSum request failed\n");
394   }
395 
396   e2rq = EntrezCreateDocSumRequest ("Nucleotide", 0, 2, nucuidlist, NULL);
397   SaveEntrezRequest (e2rq);
398   e2ry = EntrezSynchronousQuery (e2rq);
399   e2rq = Entrez2RequestFree (e2rq);
400   if (e2ry != NULL) {
401     SaveEntrezReply (e2ry);
402     Entrez2ReplyFree (e2ry);
403   } else {
404     printf ("DocSum request failed\n");
405   }
406 
407   e2rq = EntrezCreateGetLinksRequest ("Protein", 0, 1, protuidlist, NULL, "protein_protein", 30000, FALSE, TRUE);
408   SaveEntrezRequest (e2rq);
409   e2ry = EntrezSynchronousQuery (e2rq);
410   e2rq = Entrez2RequestFree (e2rq);
411   if (e2ry != NULL) {
412     SaveEntrezReply (e2ry);
413     Entrez2ReplyFree (e2ry);
414   } else {
415     printf ("GetLinks request failed\n");
416   }
417 
418   e2rq = EntrezCreateGetLinksRequest ("Protein", 0, 2, protuidlist, NULL, "protein_protein", 30000, FALSE, TRUE);
419   SaveEntrezRequest (e2rq);
420   e2ry = EntrezSynchronousQuery (e2rq);
421   e2rq = Entrez2RequestFree (e2rq);
422   if (e2ry != NULL) {
423     SaveEntrezReply (e2ry);
424     Entrez2ReplyFree (e2ry);
425   } else {
426     printf ("GetLinks request failed\n");
427   }
428 
429   str = "((\"Aedes albopictus\"[Organism] AND ((1900[MDAT] : 3000[MDAT]) NOT patent[PROP])) AND gene_in_genomic[PROP])";
430   e2rq = EntrezCreateBooleanRequest (TRUE, TRUE, "nucleotide", str, 0, 0, NULL, 0, 0);
431   SaveEntrezRequest (e2rq);
432   e2ry = EntrezSynchronousQuery (e2rq);
433   e2rq = Entrez2RequestFree (e2rq);
434   if (e2ry != NULL) {
435     SaveEntrezReply (e2ry);
436     if (showuids) {
437       SaveBooleanIdList (e2ry); /* also frees e2ry */
438     } else {
439       Entrez2ReplyFree (e2ry);
440     }
441   } else {
442     printf ("Boolean request failed\n");
443   }
444 
445   e2rq = EntrezCreateBooleanRequest (TRUE, TRUE, "PubMed", "Kans JA [AUTH]", 0, 0, NULL, 0, 0);
446   SaveEntrezRequest (e2rq);
447   e2ry = EntrezSynchronousQuery (e2rq);
448   e2rq = Entrez2RequestFree (e2rq);
449   if (e2ry != NULL) {
450     key1 = StringSave (e2ry->key);
451     SaveEntrezReply (e2ry);
452     if (showuids) {
453       SaveBooleanIdList (e2ry); /* also frees e2ry */
454     } else {
455       Entrez2ReplyFree (e2ry);
456     }
457   } else {
458     printf ("Boolean request failed\n");
459   }
460 
461   e2rq = EntrezCreateBooleanRequest (TRUE, TRUE, "PubMed", "Casadaban MJ [AUTH]", 0, 0, NULL, 0, 0);
462   SaveEntrezRequest (e2rq);
463   e2ry = EntrezSynchronousQuery (e2rq);
464   e2rq = Entrez2RequestFree (e2rq);
465   if (e2ry != NULL) {
466     key2 = StringSave (e2ry->key);
467     SaveEntrezReply (e2ry);
468     if (showuids) {
469       SaveBooleanIdList (e2ry); /* also frees e2ry */
470     } else {
471       Entrez2ReplyFree (e2ry);
472     }
473   } else {
474     printf ("Boolean request failed\n");
475   }
476 
477   e2rq = EntrezCreateBooleanRequest (TRUE, TRUE, "PubMed", NULL, 0, 0, NULL, 0, 0);
478   EntrezAddToBooleanRequest (e2rq, NULL, 0, NULL, NULL, key1, 0, 0, NULL, NULL, FALSE, FALSE);
479   EntrezAddToBooleanRequest (e2rq, NULL, ENTREZ_OP_AND, NULL, NULL, NULL, 0, 0, NULL, NULL, FALSE, FALSE);
480   EntrezAddToBooleanRequest (e2rq, NULL, 0, NULL, NULL, key2, 0, 0, NULL, NULL, FALSE, FALSE);
481   SaveEntrezRequest (e2rq);
482   e2ry = EntrezSynchronousQuery (e2rq);
483   e2rq = Entrez2RequestFree (e2rq);
484   if (e2ry != NULL) {
485     SaveEntrezReply (e2ry);
486     if (showuids) {
487       SaveBooleanIdList (e2ry); /* also frees e2ry */
488     } else {
489       Entrez2ReplyFree (e2ry);
490     }
491   } else {
492     printf ("Boolean request failed\n");
493   }
494 
495   e2rq = EntrezCreateBooleanRequest (TRUE, TRUE, "PubMed", NULL, 0, 0, NULL, 0, 0);
496   EntrezAddToBooleanRequest (e2rq, NULL, 0, NULL, NULL, NULL, 0, 2, pmuidlist, NULL, FALSE, FALSE);
497   SaveEntrezRequest (e2rq);
498   e2ry = EntrezSynchronousQuery (e2rq);
499   e2rq = Entrez2RequestFree (e2rq);
500   if (e2ry != NULL) {
501     key3 = StringSave (e2ry->key);
502     SaveEntrezReply (e2ry);
503     if (showuids) {
504       SaveBooleanIdList (e2ry); /* also frees e2ry */
505     } else {
506       Entrez2ReplyFree (e2ry);
507     }
508   } else {
509     printf ("Boolean request failed\n");
510   }
511 
512   e2rq = EntrezCreateBooleanRequest (TRUE, TRUE, "PubMed", NULL, 0, 0, NULL, 0, 0);
513   EntrezAddToBooleanRequest (e2rq, NULL, 0, "AUTH", "Kans JA", NULL, 0, 0, NULL, NULL, FALSE, FALSE);
514   EntrezAddToBooleanRequest (e2rq, NULL, ENTREZ_OP_AND, NULL, NULL, NULL, 0, 0, NULL, NULL, FALSE, FALSE);
515   EntrezAddToBooleanRequest (e2rq, NULL, 0, NULL, NULL, key3, 0, 0, NULL, NULL, FALSE, FALSE);
516   SaveEntrezRequest (e2rq);
517   e2ry = EntrezSynchronousQuery (e2rq);
518   e2rq = Entrez2RequestFree (e2rq);
519   if (e2ry != NULL) {
520     SaveEntrezReply (e2ry);
521     if (showuids) {
522       SaveBooleanIdList (e2ry); /* also frees e2ry */
523     } else {
524       Entrez2ReplyFree (e2ry);
525     }
526   } else {
527     printf ("Boolean request failed\n");
528   }
529 
530   e2rq = EntrezCreateBooleanRequest (TRUE, TRUE, "PubMed", NULL, 0, 0, NULL, 20, 0);
531   EntrezAddToBooleanRequest (e2rq, NULL, 0, "AUTH", "Kans JA", NULL, 0, 0, NULL, NULL, FALSE, FALSE);
532   SaveEntrezRequest (e2rq);
533   e2ry = EntrezSynchronousQuery (e2rq);
534   e2rq = Entrez2RequestFree (e2rq);
535   if (e2ry != NULL) {
536     SaveEntrezReply (e2ry);
537     if (showuids) {
538       SaveBooleanIdList (e2ry); /* also frees e2ry */
539     } else {
540       Entrez2ReplyFree (e2ry);
541     }
542   } else {
543     printf ("Boolean request failed\n");
544   }
545 
546   /*
547   e2rq = EntrezCreateBooleanRequest (TRUE, TRUE, "PubMed", NULL, 0, 0, NULL, 0, 0);
548   EntrezAddToBooleanRequest (e2rq, NULL, ENTREZ_OP_LEFT_PAREN, NULL, NULL, NULL, 0, 0, NULL, NULL, FALSE, FALSE);
549   EntrezAddToBooleanRequest (e2rq, NULL, 0, "WORD", "immunit", NULL, 0, 0, NULL, NULL, FALSE, FALSE);
550   EntrezAddToBooleanRequest (e2rq, NULL, ENTREZ_OP_RANGE, NULL, NULL, NULL, 0, 0, NULL, NULL, FALSE, FALSE);
551   EntrezAddToBooleanRequest (e2rq, NULL, 0, "WORD", "immunitarian", NULL, 0, 0, NULL, NULL, FALSE, FALSE);
552   EntrezAddToBooleanRequest (e2rq, NULL, ENTREZ_OP_RIGHT_PAREN, NULL, NULL, NULL, 0, 0, NULL, NULL, FALSE, FALSE);
553   */
554   /*
555   e2rq = EntrezCreateBooleanRequest (TRUE, TRUE, "PubMed", "transposase* [WORD]", 0, 0, NULL, 0, 0);
556   */
557   e2rq = EntrezCreateBooleanRequest (TRUE, TRUE, "PubMed", NULL, 0, 0, NULL, 0, 0);
558   EntrezAddToBooleanRequest (e2rq, NULL, 0, "WORD", "transposase*", NULL, 0, 0, NULL, NULL, FALSE, FALSE);
559   SaveEntrezRequest (e2rq);
560   e2ry = EntrezSynchronousQuery (e2rq);
561   e2rq = Entrez2RequestFree (e2rq);
562   if (e2ry != NULL) {
563     SaveEntrezReply (e2ry);
564     if (showuids) {
565       SaveBooleanIdList (e2ry); /* also frees e2ry */
566     } else {
567       Entrez2ReplyFree (e2ry);
568     }
569   } else {
570     printf ("Boolean request failed\n");
571   }
572 
573   if (dohuge) {
574     str = "\"nucleotide all\"[filter] NOT ApoE";
575     e2rq = EntrezCreateBooleanRequest (TRUE, TRUE, "nucleotide", str, 0, 0, NULL, 0, 0);
576     SaveEntrezRequest (e2rq);
577     e2ry = EntrezSynchronousQuery (e2rq);
578     e2rq = Entrez2RequestFree (e2rq);
579     if (e2ry != NULL) {
580       SaveEntrezReply (e2ry);
581       if (showuids) {
582         SaveBooleanIdList (e2ry); /* also frees e2ry */
583       } else {
584         Entrez2ReplyFree (e2ry);
585       }
586     } else {
587       printf ("Boolean request failed\n");
588     }
589   }
590 }
591 
592 /* Args structure contains command-line arguments */
593 
594 #define v_argService  0
595 #define h_argHuge     1
596 #define u_argUids     2
597 #define g_argInfo     3
598 #define n_argNewTests 4
599 
600 Args myargs [] = {
601   {"Service", NULL, NULL, NULL,
602     TRUE, 'v', ARG_STRING, 0.0, 0, NULL},
603   {"Do Huge Boolean Query", "F", NULL, NULL,
604     TRUE, 'h', ARG_BOOLEAN, 0.0, 0, NULL},
605   {"Show UID List", "F", NULL, NULL,
606     TRUE, 'u', ARG_BOOLEAN, 0.0, 0, NULL},
607   {"Show Get-Info Reply", "F", NULL, NULL,
608     TRUE, 'g', ARG_BOOLEAN, 0.0, 0, NULL},
609   {"New Tests", "F", NULL, NULL,
610     TRUE, 'n', ARG_BOOLEAN, 0.0, 0, NULL},
611 };
612 
613 Int2 Main (void)
614 
615 {
616   Boolean  dohuge, newtests, showinfo, showuids;
617   CharPtr  service;
618 
619   /* standard setup */
620 
621   ErrSetFatalLevel (SEV_MAX);
622   ErrClearOptFlags (EO_SHOW_USERSTR);
623   UseLocalAsnloadDataAndErrMsg ();
624   ErrPathReset ();
625 
626   if (! AllObjLoad ()) {
627     Message (MSG_FATAL, "AllObjLoad failed");
628     return 1;
629   }
630   if (! SubmitAsnLoad ()) {
631     Message (MSG_FATAL, "SubmitAsnLoad failed");
632     return 1;
633   }
634   if (! FeatDefSetLoad ()) {
635     Message (MSG_FATAL, "FeatDefSetLoad failed");
636     return 1;
637   }
638   if (! SeqCodeSetLoad ()) {
639     Message (MSG_FATAL, "SeqCodeSetLoad failed");
640     return 1;
641   }
642   if (! GeneticCodeTableLoad ()) {
643     Message (MSG_FATAL, "GeneticCodeTableLoad failed");
644     return 1;
645   }
646 
647   /* process command line arguments */
648 
649   if (! GetArgs ("testent2", sizeof (myargs) / sizeof (Args), myargs)) {
650     return 0;
651   }
652 
653   service = myargs [v_argService].strvalue;
654   dohuge = (Boolean) myargs [h_argHuge].intvalue;
655   showuids = (Boolean) myargs [u_argUids].intvalue;
656   showinfo = (Boolean) myargs [g_argInfo].intvalue;
657   newtests = (Boolean) myargs [n_argNewTests].intvalue;
658 
659   if (! StringHasNoText (service)) {
660     EntrezSetService (service);
661     printf ("testent2 %s\n", service);
662   }
663 
664   if (newtests) {
665     NewTextE2 (showuids, showinfo);
666   } else {
667     TestE2 (dohuge, showuids, showinfo);
668   }
669   printf ("testent2 finished\n");
670 
671   return 0;
672 }
673 
674 
675 

source navigation ]   [ diff markup ]   [ identifier search ]   [ freetext search ]   [ file search ]  

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.