NCBI C++ ToolKit
eutils_sample.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: eutils_sample.cpp 90029 2020-05-05 14:03:22Z ivanov $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Author: Aleksey Grichenko
27  *
28  * File Description:
29  * Example of using e-utils
30  *
31  */
32 
33 #include <ncbi_pch.hpp>
34 
35 #include <corelib/ncbiapp.hpp>
36 #include <corelib/ncbienv.hpp>
37 #include <corelib/ncbiargs.hpp>
38 
39 #include <objects/seq/Bioseq.hpp>
42 
60 
61 
64 
65 
66 /////////////////////////////////////////////////////////////////////////////
67 //
68 // EUtils demo application
69 //
70 
72 {
73 public:
74  virtual void Init(void);
75  virtual int Run (void);
76  virtual void Exit(void);
77 
78 private:
79  void CallEInfo(const CArgs& args);
80  void CallESearch(const CArgs& args);
81  void CallEPost(const CArgs& args);
82  void CallEGQuery(const CArgs& args);
83  void CallELink(const CArgs& args);
84  void CallESummary(const CArgs& args);
85  void CallEFetch(const CArgs& args);
86  void CallESpell(const CArgs& args);
87  void CallEHistory(const CArgs& args);
88 
92 
94  void x_SetHttpMethod(CEUtils_Request& req, const CArgs& args);
95  void x_DumpRequest(CEUtils_Request& req);
96 
99 };
100 
101 
103 {
104  if ( !m_Ctx ) {
106  }
107  return m_Ctx;
108 }
109 
110 
112 {
113  // Prepare command line descriptions
114  //
115 
116  // Create
117  unique_ptr<CArgDescriptions> arg_desc(new CArgDescriptions);
118 
119  arg_desc->AddFlag("einfo", "Call einfo utility", true);
120  arg_desc->AddFlag("efetch", "Call efetch utility", true);
121  // arg_desc->SetDependency("einfo", CArgDescriptions::eExcludes, "efetch");
122  arg_desc->AddFlag("esearch", "Call esearch utility", true);
123  arg_desc->AddFlag("epost", "Call epost utility", true);
124  arg_desc->AddFlag("elink", "Call elink utility", true);
125  arg_desc->AddFlag("egquery", "Call egquery utility", true);
126  arg_desc->AddFlag("esummary", "Call esummary utility", true);
127  arg_desc->AddFlag("espell", "Call espell utility", true);
128  arg_desc->AddFlag("ehistory", "Call ehistory utility", true);
129 
130  // Switch HTTP method
131  arg_desc->AddDefaultKey("http", "Method",
132  "HTTP method used to send requests",
133  CArgDescriptions::eString, "post");
134  arg_desc->SetConstraint("http", &(*new CArgAllow_Strings, "post", "get"));
135 
136  // Debug flag
137  arg_desc->AddFlag("dump", "Print raw incoming data", true);
138 
139  // Context setup
140  arg_desc->AddOptionalKey("webenv", "WebEnv", "Web environment",
142  arg_desc->AddOptionalKey("query_key", "query_key", "Query key",
144  arg_desc->AddOptionalKey("tool", "tool", "Client tool",
146  arg_desc->AddOptionalKey("email", "email", "Client e-mail",
148 
149  // Arguments for all queries
150  arg_desc->AddOptionalKey("db", "db", "Database name",
152  arg_desc->AddOptionalKey("id", "id", "ID to fetch",
154  arg_desc->AddOptionalKey("term", "term", "Term to search for",
156  arg_desc->AddOptionalKey("retstart", "RetStart", "First item to fetch",
158  arg_desc->SetConstraint("retstart", new CArgAllow_Integers(1, kMax_Int));
159  arg_desc->AddOptionalKey("retmax", "RetMax", "Number of items to fetch",
161  arg_desc->SetConstraint("retmax", new CArgAllow_Integers(1, kMax_Int));
162  arg_desc->AddDefaultKey("retmode", "RetMode", "Data format",
163  CArgDescriptions::eString, "text");
164  arg_desc->SetConstraint("retmode", &(*new CArgAllow_Strings,
165  "text", "xml", "asn", "html"));
166  arg_desc->AddOptionalKey("rettype", "RetType", "Fetched data type",
168  arg_desc->SetConstraint("rettype", &(*new CArgAllow_Strings,
169  // Literature
170  "uilist", "abstract", "citation", "medline", "full",
171  // Sequence
172  "native", "fasta", "gb", "gbc", "gbwithparts", "est", "gss",
173  "gp", "gpc", "seqid", "acc", "chr", "flt", "rsr", "brief", "docset",
174  // Search
175  "count", "uilist"));
176  arg_desc->AddOptionalKey("reldate", "RelDate", "Age of date in days",
178  // taxonomy only
179  arg_desc->AddOptionalKey("report", "Report", "Taxonomy data format",
181  arg_desc->SetConstraint("report", &(*new CArgAllow_Strings,
182  "uilist", "brief", "docsum", "xml"));
183  // esearch
184  arg_desc->AddOptionalKey("usehistory", "UseHistory", "Use history",
186  arg_desc->AddOptionalKey("sort", "Sort", "Sort order or 'none'",
188 
189  // Dependencies
190  // ESearch
191  arg_desc->SetDependency("esearch", CArgDescriptions::eRequires, "db");
192  arg_desc->SetDependency("esearch", CArgDescriptions::eRequires, "term");
193  arg_desc->SetDependency("usehistory", CArgDescriptions::eRequires, "esearch");
194  arg_desc->SetDependency("sort", CArgDescriptions::eRequires, "esearch");
195  // EGQuery
196  arg_desc->SetDependency("egquery", CArgDescriptions::eRequires, "term");
197  // EFetch
198  arg_desc->SetDependency("efetch", CArgDescriptions::eRequires, "db");
199  arg_desc->SetDependency("epost", CArgDescriptions::eRequires, "db");
200  arg_desc->SetDependency("epost", CArgDescriptions::eRequires, "id");
201  // ELink
202  arg_desc->SetDependency("elink", CArgDescriptions::eRequires, "db");
203  // ESummary
204  arg_desc->SetDependency("esummary", CArgDescriptions::eRequires, "db");
205  // ESpell
206  arg_desc->SetDependency("espell", CArgDescriptions::eRequires, "db");
207  arg_desc->SetDependency("espell", CArgDescriptions::eRequires, "term");
208 
209  // elink arguments
210  // dbfrom
211  arg_desc->AddOptionalKey("dbfrom", "dbfrom", "origination db for elink",
213  // cmd
214  arg_desc->AddOptionalKey("cmd", "Command", "elink command",
216  arg_desc->SetConstraint("cmd", &(*new CArgAllow_Strings,
217  "prlinks", "llinks", "llinkslib", "lcheck", "ncheck",
218  "neighbor", "neighbor_history", "acheck"));
219  // linkname
220  arg_desc->AddOptionalKey("linkname", "Linkname", "elink linkname",
222  // holding
223  arg_desc->AddOptionalKey("holding", "holding", "elink holding",
225  // version
226  arg_desc->AddOptionalKey("version", "Version", "elink DTD version",
228 
229  // Program description
230  string prog_description =
231  "Test loading data from EUtils";
232  arg_desc->SetUsageContext(GetArguments().GetProgramBasename(),
233  prog_description, false);
234 
235  // Pass argument descriptions to the application
236  SetupArgDescriptions(arg_desc.release());
237 }
238 
239 
241 {
242  if ( args["http"].AsString() == "get" ) {
244  }
245 }
246 
247 
249 {
250  string data;
251  req.Read(&data);
252  cout << data << endl;
253 }
254 
255 
256 void CEUtilsApp::CallEInfo(const CArgs& args)
257 {
258  string db = args["db"] ? args["db"].AsString() : kEmptyStr;
259  CEInfo_Request req(db, x_GetCtx());
260  x_SetHttpMethod(req, args);
261 
262  cout << req.GetScriptName() << "?" << req.GetQueryString() << endl;
263 
264  if ( m_DumpRequests ) {
265  x_DumpRequest(req);
266  return;
267  }
268 
270  _ASSERT(result);
271  cout << MSerial_Xml << *result << endl;
272  if ( result->IsDbList() ) {
273  for (const auto& name : result->GetDbList().GetDbName()) {
274  req.SetDatabase(name);
275  cout << req.GetScriptName() << "?" << req.GetQueryString() << endl;
277  _ASSERT(db_info);
278  cout << MSerial_Xml << *db_info << endl;
279  }
280  }
281 }
282 
283 
285 {
286  // Prepare request
287  CESearch_Request req(args["db"].AsString(), x_GetCtx());
288  x_SetHttpMethod(req, args);
289 
290  req.SetTerm(args["term"].AsString());
291  if ( args["usehistory"] ) {
292  req.SetUseHistory(args["usehistory"].AsBoolean());
293  }
294  if ( args["sort"] ) {
295  req.SetSortOrderName(args["sort"].AsString());
296  }
297  if ( args["reldate"] ) {
298  req.SetRelDate(args["reldate"].AsInteger());
299  }
300 
301  if ( args["retmax"] ) {
302  req.SetRetMax(args["retmax"].AsInteger());
303  }
304 
305  string rettype = args["rettype"] ? args["rettype"].AsString() : kEmptyStr;
306  if (rettype == "count") {
308  }
309  else if (rettype == "uilist") {
311  }
312  else if ( !rettype.empty() ) {
313  ERR_POST(Error << "Rettype " << rettype <<
314  " is incompatible with e-search request.");
315  return;
316  }
317 
318  // Print query string
319  cout << req.GetScriptName() << "?" << req.GetQueryString() << endl;
320 
321  if ( m_DumpRequests ) {
322  x_DumpRequest(req);
323  return;
324  }
325 
326  // Get and show the results
328  _ASSERT(result);
329  cout << MSerial_Xml << *result << endl;
330  cout << "WebEnv=" << x_GetCtx()->GetWebEnv() << endl;
331  cout << "query_key=" << x_GetCtx()->GetQueryKey() << endl;
332 }
333 
334 
336 {
337  // Prepare request
338  CEGQuery_Request req(x_GetCtx());
339  x_SetHttpMethod(req, args);
340 
341  req.SetTerm(args["term"].AsString());
342 
343  // Print query string
344  cout << req.GetScriptName() << "?" << req.GetQueryString() << endl;
345 
346  if ( m_DumpRequests ) {
347  x_DumpRequest(req);
348  return;
349  }
350 
351  // Get and show the results
353  _ASSERT(result);
354  cout << MSerial_Xml << *result << endl;
355 }
356 
357 
358 void CEUtilsApp::CallEPost(const CArgs& args)
359 {
360  // Prepare request
361  CEPost_Request req(args["db"].AsString(), x_GetCtx());
362  x_SetHttpMethod(req, args);
363 
364  req.GetId().SetIds(args["id"].AsString());
365 
366  // Print query string
367  cout << req.GetScriptName() << "?" << req.GetQueryString() << endl;
368 
369  if ( m_DumpRequests ) {
370  x_DumpRequest(req);
371  return;
372  }
373 
374  // Get and show the results
376  _ASSERT(result);
377  cout << MSerial_Xml << *result << endl;
378  cout << "WebEnv=" << x_GetCtx()->GetWebEnv() << endl;
379  cout << "query_key=" << x_GetCtx()->GetQueryKey() << endl;
380 }
381 
382 
383 void CEUtilsApp::CallELink(const CArgs& args)
384 {
385  // Prepare request
386  CELink_Request req(args["db"].AsString(), x_GetCtx());
387  x_SetHttpMethod(req, args);
388 
389  if ( args["dbfrom"] ) {
390  req.SetDbFrom(args["dbfrom"].AsString());
391  }
392  // If WebEnv was set (as an command line argument or by previous requests)
393  // use it instead of id.
394  if ( req.GetConnContext()->GetWebEnv().empty() && args["id"] ) {
395  req.GetIdGroups().SetGroups(args["id"].AsString());
396  }
397  if ( args["cmd"] ) {
398  string cmd = args["cmd"].AsString();
399  if (cmd == "prlinks") {
401  }
402  else if (cmd == "llinks" ) {
404  }
405  else if (cmd == "llinkslib") {
407  }
408  else if (cmd == "lcheck") {
410  }
411  else if (cmd == "ncheck") {
413  }
414  else if (cmd == "neighbor") {
416  }
417  else if (cmd == "neighbor_history") {
419  }
420  else if (cmd == "acheck") {
422  }
423  else {
424  ERR_POST(Error << "Unsupported elink command: " << cmd);
425  }
426  }
427  if ( args["linkname"] ) {
428  req.SetLinkName(args["linkname"].AsString());
429  }
430  if ( args["holding"] ) {
431  req.SetHolding(args["holding"].AsString());
432  }
433  if ( args["version"] ) {
434  req.SetHolding(args["version"].AsString());
435  }
436  if ( args["reldate"] ) {
437  req.SetRelDate(args["reldate"].AsInteger());
438  }
439 
440  // Print query string
441  cout << req.GetScriptName() << "?" << req.GetQueryString() << endl;
442 
443  if ( m_DumpRequests ) {
444  x_DumpRequest(req);
445  return;
446  }
447 
448  // Get and show the results
450  _ASSERT(result);
451  cout << MSerial_Xml << *result << endl;
452 }
453 
454 
456 {
457  // Prepare request
458  string db = args["db"] ? args["db"].AsString() : kEmptyStr;
459  CESummary_Request req(db, x_GetCtx());
460  x_SetHttpMethod(req, args);
461 
462  // If WebEnv was set (as an command line argument or by previous requests)
463  // use it instead of id.
464  if ( req.GetConnContext()->GetWebEnv().empty() && args["id"] ) {
465  req.GetId().SetIds(args["id"].AsString());
466  }
467  if ( args["retstart"] ) {
468  req.SetRetStart(args["retstart"].AsInteger());
469  }
470  if ( args["retmax"] ) {
471  req.SetRetMax(args["retmax"].AsInteger());
472  }
473 
474  // Print query string
475  cout << req.GetScriptName() << "?" << req.GetQueryString() << endl;
476 
477  if ( m_DumpRequests ) {
478  x_DumpRequest(req);
479  return;
480  }
481 
482  try {
483  // Get and show the results. GetESummaryResult() may fail if the
484  // selected database uses an incompatible DTD, so report exceptions
485  // if any (in real life this case must be handled by using XmlWrapp
486  // library to parse the data).
488  _ASSERT(result);
489  cout << MSerial_Xml << *result << endl;
490  }
491  catch (CSerialException& ex) {
492  cout << "Deserialization error: " << ex.what() << endl;
493  }
494 }
495 
496 
497 void CEUtilsApp::CallESpell(const CArgs& args)
498 {
499  // Prepare request
500  string db = args["db"] ? args["db"].AsString() : kEmptyStr;
501  CESpell_Request req(db, x_GetCtx());
502  x_SetHttpMethod(req, args);
503 
504  req.SetTerm(args["term"].AsString());
505 
506  // Print query string
507  cout << req.GetScriptName() << "?" << req.GetQueryString() << endl;
508 
509  if ( m_DumpRequests ) {
510  x_DumpRequest(req);
511  return;
512  }
513 
514  // Get and show the results
516  _ASSERT(result);
517  cout << MSerial_Xml << *result << endl;
518 }
519 
520 
522 {
523  // Prepare request
524  string db;
525  if ( args["db"] ) {
526  db = args["db"].AsString();
527  }
528  CEHistory_Request req(db, x_GetCtx());
529  x_SetHttpMethod(req, args);
530 
531  // Print query string
532  cout << req.GetScriptName() << "?" << req.GetQueryString() << endl;
533 
534  if ( m_DumpRequests ) {
535  x_DumpRequest(req);
536  return;
537  }
538 
539  // Get and show the results
541  _ASSERT(result);
542  cout << MSerial_Xml << *result << endl;
543 }
544 
545 
547 {
548  // Prepare literature request
549  string db = args["db"].AsString();
551  if (db == "pubmed") {
553  }
554  else if (db == "pmc") {
556  }
557  else if (db == "journals") {
559  }
560  else if (db == "omim") {
562  }
563  else {
564  return 0;
565  }
566  unique_ptr<CEFetch_Literature_Request> lit_req(
568 
569  string rettype = args["rettype"] ? args["rettype"].AsString() : kEmptyStr;
570  if (rettype == "uilist") {
571  lit_req->SetRetType(CEFetch_Literature_Request::eRetType_uilist);
572  }
573  else if (rettype == "abstract") {
575  }
576  else if (rettype == "citation") {
578  }
579  else if (rettype == "medline") {
581  }
582  else if (rettype == "full") {
583  lit_req->SetRetType(CEFetch_Literature_Request::eRetType_full);
584  }
585  else if ( !rettype.empty() ) {
586  ERR_POST(Error << "Rettype " << rettype <<
587  " is incompatible with the selected database " << db);
588  return 0;
589  }
590 
591  return lit_req.release();
592 }
593 
594 
596 {
597  // Prepare sequence request
598  string db = args["db"].AsString();
600  if (db == "gene") {
602  }
603  else if (db == "genome") {
605  }
606  else if (db == "nucleotide") {
608  }
609  else if (db == "nuccore") {
611  }
612  else if (db == "nucest") {
614  }
615  else if (db == "nucgss") {
617  }
618  else if (db == "protein") {
620  }
621  else if (db == "popset") {
623  }
624  else if (db == "snp") {
626  }
627  else if (db == "sequences") {
629  }
630  else {
631  return 0;
632  }
633  unique_ptr<CEFetch_Sequence_Request> seq_req(
634  new CEFetch_Sequence_Request(sdb, x_GetCtx()));
635 
636  string rettype = args["rettype"] ? args["rettype"].AsString() : kEmptyStr;
637  if (rettype == "native") {
638  seq_req->SetRetType(CEFetch_Sequence_Request::eRetType_native);
639  }
640  else if (rettype == "fasta") {
641  seq_req->SetRetType(CEFetch_Sequence_Request::eRetType_fasta);
642  }
643  else if (rettype == "gb") {
644  seq_req->SetRetType(CEFetch_Sequence_Request::eRetType_gb);
645  }
646  else if (rettype == "gbc") {
647  seq_req->SetRetType(CEFetch_Sequence_Request::eRetType_gbc);
648  }
649  else if (rettype == "gbwithparts") {
651  }
652  else if (rettype == "est") {
653  seq_req->SetRetType(CEFetch_Sequence_Request::eRetType_est);
654  }
655  else if (rettype == "gss") {
656  seq_req->SetRetType(CEFetch_Sequence_Request::eRetType_gss);
657  }
658  else if (rettype == "gp") {
659  seq_req->SetRetType(CEFetch_Sequence_Request::eRetType_gp);
660  }
661  else if (rettype == "gpc") {
662  seq_req->SetRetType(CEFetch_Sequence_Request::eRetType_gpc);
663  }
664  else if (rettype == "seqid") {
665  seq_req->SetRetType(CEFetch_Sequence_Request::eRetType_seqid);
666  }
667  else if (rettype == "acc") {
668  seq_req->SetRetType(CEFetch_Sequence_Request::eRetType_acc);
669  }
670  else if (rettype == "chr") {
671  seq_req->SetRetType(CEFetch_Sequence_Request::eRetType_chr);
672  }
673  else if (rettype == "flt") {
674  seq_req->SetRetType(CEFetch_Sequence_Request::eRetType_flt);
675  }
676  else if (rettype == "rsr") {
677  seq_req->SetRetType(CEFetch_Sequence_Request::eRetType_rsr);
678  }
679  else if (rettype == "brief") {
680  seq_req->SetRetType(CEFetch_Sequence_Request::eRetType_brief);
681  }
682  else if (rettype == "docset") {
683  seq_req->SetRetType(CEFetch_Sequence_Request::eRetType_docset);
684  }
685  else if ( !rettype.empty() ) {
686  ERR_POST(Error << "Rettype " << rettype <<
687  " is incompatible with the selected database " << db);
688  return 0;
689  }
690 
691  return seq_req.release();
692 }
693 
694 
696 {
697  // Prepare taxonomy request
698  string db = args["db"].AsString();
699  if (db != "taxonomy") {
700  return 0;
701  }
702  unique_ptr<CEFetch_Taxonomy_Request> tax_req(
704 
705  if ( args["report"] ) {
706  string report = args["report"].AsString();
707  if (report == "uilist") {
708  tax_req->SetReport(CEFetch_Taxonomy_Request::eReport_uilist);
709  }
710  else if (report == "brief") {
711  tax_req->SetReport(CEFetch_Taxonomy_Request::eReport_brief);
712  }
713  else if (report == "docsum") {
714  tax_req->SetReport(CEFetch_Taxonomy_Request::eReport_docsum);
715  }
716  else if (report == "xml") {
717  tax_req->SetReport(CEFetch_Taxonomy_Request::eReport_xml);
718  }
719  else {
720  ERR_POST(Error << "Unsupported taxonomy report: " << report);
721  return 0;
722  }
723  }
724  return tax_req.release();
725 }
726 
727 
728 void CEUtilsApp::CallEFetch(const CArgs& args)
729 {
730  // Try to create literature request
731  unique_ptr<CEFetch_Request> req(x_CreateLitRequest(args));
732  if ( !req.get() ) {
733  // Try to create sequence request
734  req.reset(x_CreateSeqRequest(args));
735  }
736  if ( !req.get() ) {
737  // Try to create taxonomy request
738  req.reset(x_CreateTaxRequest(args));
739  }
740  if ( !req.get() ) {
741  // the database is not related to any known request type
742  ERR_POST(Error << "Can not connect to database "
743  << args["db"].AsString() << " using the specified arguments.");
744  return;
745  }
746  x_SetHttpMethod(*req, args);
747 
748  // If WebEnv was set (as an command line argument or by previous requests)
749  // use it instead of id.
750  if ( req->GetConnContext()->GetWebEnv().empty() && args["id"] ) {
751  req->GetId().SetIds(args["id"].AsString());
752  }
753 
754  string retmode_str = args["retmode"].AsString();
756  if (retmode_str == "text") {
758  }
759  else if (retmode_str == "xml") {
761  }
762  else if (retmode_str == "html") {
764  }
765  else if (retmode_str == "asn") {
767  }
768  else {
769  ERR_POST(Error << "Unknown retmode: " << retmode_str);
770  }
771  req->SetRetMode(retmode);
772 
773  cout << req->GetScriptName() << "?" << req->GetQueryString() << endl;
774 
775  if ( m_DumpRequests ) {
776  x_DumpRequest(*req);
777  return;
778  }
779 
780  // efetch can return different object types, just print plain content
781  string content;
782  req->Read(&content);
783  cout << content << endl;
784 }
785 
786 
788 {
789  // Process command line args
790  const CArgs& args = GetArgs();
791 
792  m_DumpRequests = args["dump"];
793 
794  // Set connection context parameters
795  if (args["webenv"]) {
796  x_GetCtx()->SetWebEnv(args["webenv"].AsString());
797  }
798  if (args["query_key"]) {
799  x_GetCtx()->SetQueryKey(args["query_key"].AsString());
800  }
801  if (args["tool"]) {
802  x_GetCtx()->SetTool(args["tool"].AsString());
803  }
804  if (args["email"]) {
805  x_GetCtx()->SetEmail(args["email"].AsString());
806  }
807 
808  // Call the requested utils
809  if ( args["einfo"] ) {
810  CallEInfo(args);
811  }
812  if ( args["egquery"] ) {
813  CallEGQuery(args);
814  }
815  if ( args["espell"] ) {
816  CallESpell(args);
817  }
818  if ( args["esearch"] ) {
819  CallESearch(args);
820  }
821  if ( args["epost"] ) {
822  CallEPost(args);
823  }
824  if ( args["elink"] ) {
825  CallELink(args);
826  }
827  if ( args["esummary"] ) {
828  CallESummary(args);
829  }
830  if ( args["efetch"] ) {
831  CallEFetch(args);
832  }
833  // EHistory is the last one - shows all other requests if any
834  if ( args["ehistory"] ) {
835  CallEHistory(args);
836  }
837  return 0;
838 }
839 
840 
842 {
843  return;
844 }
845 
846 
847 /////////////////////////////////////////////////////////////////////////////
848 // MAIN
849 
850 int NcbiSys_main(int argc, ncbi::TXChar* argv[])
851 {
852  return CEUtilsApp().AppMain(argc, argv);
853 }
CArgAllow_Integers –.
Definition: ncbiargs.hpp:1751
CArgAllow_Strings –.
Definition: ncbiargs.hpp:1641
CArgDescriptions –.
Definition: ncbiargs.hpp:541
CArgs –.
Definition: ncbiargs.hpp:379
CEFetch_Literature_Request.
Definition: efetch.hpp:127
CEFetch_Request.
Definition: efetch.hpp:59
CEFetch_Sequence_Request.
Definition: efetch.hpp:180
CEFetch_Taxonomy_Request.
Definition: efetch.hpp:281
CEGQuery_Request.
Definition: egquery.hpp:57
CEHistory_Request.
Definition: ehistory.hpp:59
CEInfo_Request.
Definition: einfo.hpp:58
CEPost_Request.
Definition: epost.hpp:59
CESearch_Request.
Definition: esearch.hpp:59
CESpell_Request.
Definition: espell.hpp:59
CESummary_Request.
Definition: esummary.hpp:58
void x_SetHttpMethod(CEUtils_Request &req, const CArgs &args)
void CallEInfo(const CArgs &args)
void CallESpell(const CArgs &args)
virtual void Init(void)
Initialize the application.
void CallEGQuery(const CArgs &args)
virtual void Exit(void)
Cleanup on application exit.
void x_DumpRequest(CEUtils_Request &req)
void CallEPost(const CArgs &args)
CRef< CEUtils_ConnContext > & x_GetCtx(void)
CEFetch_Request * x_CreateSeqRequest(const CArgs &args)
void CallESearch(const CArgs &args)
void CallELink(const CArgs &args)
void CallEHistory(const CArgs &args)
bool m_DumpRequests
void CallESummary(const CArgs &args)
virtual int Run(void)
Run the application.
CEFetch_Request * x_CreateLitRequest(const CArgs &args)
CEFetch_Request * x_CreateTaxRequest(const CArgs &args)
void CallEFetch(const CArgs &args)
CRef< CEUtils_ConnContext > m_Ctx
CEUtils_ConnContext.
Definition: eutils.hpp:65
CEUtils_Request.
Definition: eutils.hpp:110
Root class for all serialization exceptions.
Definition: exception.hpp:50
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
USING_SCOPE(objects)
int NcbiSys_main(int argc, ncbi::TXChar *argv[])
USING_NCBI_SCOPE
virtual const CArgs & GetArgs(void) const
Get parsed command line arguments.
Definition: ncbiapp.cpp:285
int AppMain(int argc, const char *const *argv, const char *const *envp=0, EAppDiagStream diag=eDS_Default, const char *conf=NcbiEmptyCStr, const string &name=NcbiEmptyString)
Main function (entry point) for the NCBI application.
Definition: ncbiapp.cpp:799
virtual void SetupArgDescriptions(CArgDescriptions *arg_desc)
Setup the command line argument descriptions.
Definition: ncbiapp.cpp:1175
const CNcbiArguments & GetArguments(void) const
Get the application's cached unprocessed command-line arguments.
@ eRequires
One argument requires another.
Definition: ncbiargs.hpp:956
@ eBoolean
{'true', 't', 'false', 'f'}, case-insensitive
Definition: ncbiargs.hpp:590
@ eString
An arbitrary string.
Definition: ncbiargs.hpp:589
@ eInteger
Convertible into an integer number (int or Int8)
Definition: ncbiargs.hpp:592
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
Definition: ncbidiag.hpp:186
virtual string GetQueryString(void) const
Get CGI script query string.
Definition: esummary.cpp:55
ERetMode
Output format for efetch requests.
Definition: efetch.hpp:81
void SetDatabase(const string &database)
Setting new database disconnects the request.
Definition: eutils.cpp:281
const CEUtils_IdGroupSet & GetIdGroups(void) const
Multiple ID groups.
Definition: elink.hpp:79
void SetSortOrderName(CTempString name)
Set sort order. Empty string indicates no sorting (or the default one).
Definition: esearch.cpp:83
void SetRetStart(int retstart)
Definition: esummary.hpp:77
const CEUtils_IdGroup & GetId(void) const
Group of ids required if history is not used.
Definition: esummary.hpp:71
ESequenceDB
Sequence databases.
Definition: efetch.hpp:183
CRef< elink::CELinkResult > GetELinkResult(void)
Get search result.
Definition: elink.cpp:139
void SetRequestMethod(ERequestMethod method)
Set HTTP method.
Definition: eutils.hpp:184
void SetRetMax(int retmax)
Definition: esummary.hpp:81
virtual string GetQueryString(void) const
Get CGI script query string.
Definition: eutils.cpp:199
virtual string GetQueryString(void) const
Get CGI script query string.
Definition: egquery.cpp:52
ELiteratureDB
Literature databases.
Definition: efetch.hpp:130
CRef< espell::CESpellResult > GetESpellResult(void)
Get search results.
Definition: espell.cpp:71
void SetTool(const string &tool)
Definition: eutils.hpp:87
CRef< CEUtils_ConnContext > & GetConnContext(void) const
Get current request context.
Definition: eutils.cpp:61
void SetGroups(const string &groups)
Parse a set of id groups from a single string ('id=12,34&id=56,78').
Definition: eutils.cpp:331
CRef< einfo::CEInfoResult > GetEInfoResult(void)
Get result.
Definition: einfo.cpp:59
const string & GetScriptName(void) const
Get CGI script name (e.g. efetch.fcgi).
Definition: eutils.hpp:119
void SetTerm(const string &term)
Definition: esearch.hpp:82
virtual string GetQueryString(void) const
Get CGI script query string.
Definition: espell.cpp:54
CRef< ehistory::CEHistoryResult > GetEHistoryResult(void)
Get request history.
Definition: ehistory.cpp:59
CRef< epost::CEPostResult > GetEPostResult(void)
Get search results.
Definition: epost.cpp:71
const CEUtils_IdGroup & GetId(void) const
Group of ids to be added to the search history.
Definition: epost.hpp:76
void SetLinkName(const string &linkname)
Definition: elink.hpp:134
void SetTerm(const string &term)
Definition: espell.hpp:76
void SetRelDate(int days)
Definition: esearch.hpp:91
void SetEmail(const string &email)
Definition: eutils.hpp:91
CRef< esearch::CESearchResult > GetESearchResult(void)
Get search results.
Definition: esearch.cpp:156
CRef< esummary::CESummaryResult > GetESummaryResult(void)
Get search result.
Definition: esummary.cpp:78
virtual string GetQueryString(void) const
Get CGI script query string.
Definition: epost.cpp:54
void Read(string *content)
Read the whole stream into the string.
Definition: eutils.cpp:274
void SetRetType(ERetType rettype)
Definition: esearch.hpp:122
CRef< egquery::CResult > GetResult(void)
Get search results.
Definition: egquery.cpp:69
const string & GetWebEnv(void) const
Get WebEnv.
Definition: eutils.hpp:75
const string & GetQueryKey(void) const
Get query_key.
Definition: eutils.hpp:80
void SetUseHistory(bool value)
Definition: esearch.hpp:78
void SetRetMax(int retmax)
Definition: esearch.hpp:112
void SetDbFrom(const string &dbfrom)
Definition: elink.hpp:76
void SetQueryKey(const string &query_key)
Set query_key.
Definition: eutils.hpp:82
void SetHolding(const string &holding)
Definition: elink.hpp:140
void SetWebEnv(const string &webenv)
Set WebEnv.
Definition: eutils.hpp:77
void SetTerm(const string &term)
Definition: egquery.hpp:74
void SetIds(const string &ids)
Parse all ids from a string (e.g. 'id=123,456,78').
Definition: eutils.cpp:320
void SetRelDate(int days)
Definition: elink.hpp:89
void SetCommand(ECommand cmd)
Definition: elink.hpp:128
virtual string GetQueryString(void) const
Get CGI script query string.
Definition: elink.cpp:78
virtual string GetQueryString(void) const
Get CGI script query string.
Definition: esearch.cpp:101
@ eRetMode_text
Return data as plain text.
Definition: efetch.hpp:85
@ eRetMode_xml
Return data as XML.
Definition: efetch.hpp:83
@ eRetMode_html
Return data as HTML.
Definition: efetch.hpp:84
@ eRetMode_asn
Return data as text ASN.1.
Definition: efetch.hpp:86
@ eCmd_llinks
LinkOut URLs, except PubMed libraries.
Definition: elink.hpp:118
@ eCmd_ncheck
Check for the existence of neighbor links.
Definition: elink.hpp:121
@ eCmd_lcheck
Check for the existence of external links.
Definition: elink.hpp:120
@ eCmd_prlinks
Links to the primary provider.
Definition: elink.hpp:117
@ eCmd_acheck
Entrez databases links.
Definition: elink.hpp:125
@ eCmd_neighbor
Display neighbors within a database (default)
Definition: elink.hpp:122
@ eCmd_llinkslib
LinkOut URLs and Attributes.
Definition: elink.hpp:119
@ eCmd_neighbor_history
Create history for use in other EUtils.
Definition: elink.hpp:124
@ eHttp_Get
Use GET.
Definition: eutils.hpp:178
void Error(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1197
virtual const char * what(void) const noexcept
Standard report (includes full backlog).
Definition: ncbiexpt.cpp:342
#define MSerial_Xml
Definition: serialbase.hpp:698
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
#define kMax_Int
Definition: ncbi_limits.h:184
#define kEmptyStr
Definition: ncbistr.hpp:123
char TXChar
Definition: ncbistr.hpp:172
Defines the CNcbiApplication and CAppException classes for creating NCBI applications.
Defines command line argument related classes.
Defines unified interface to application:
#define _ASSERT
else result
Definition: token2.c:20
Modified on Sat Dec 02 09:22:04 2023 by modify_doxy.py rev. 669887