74 virtual void Init(
void);
75 virtual int Run (
void);
76 virtual void Exit(
void);
119 arg_desc->AddFlag(
"einfo",
"Call einfo utility",
true);
120 arg_desc->AddFlag(
"efetch",
"Call efetch utility",
true);
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);
131 arg_desc->AddDefaultKey(
"http",
"Method",
132 "HTTP method used to send requests",
137 arg_desc->AddFlag(
"dump",
"Print raw incoming data",
true);
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",
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",
159 arg_desc->AddOptionalKey(
"retmax",
"RetMax",
"Number of items to fetch",
162 arg_desc->AddDefaultKey(
"retmode",
"RetMode",
"Data format",
165 "text",
"xml",
"asn",
"html"));
166 arg_desc->AddOptionalKey(
"rettype",
"RetType",
"Fetched data type",
170 "uilist",
"abstract",
"citation",
"medline",
"full",
172 "native",
"fasta",
"gb",
"gbc",
"gbwithparts",
"est",
"gss",
173 "gp",
"gpc",
"seqid",
"acc",
"chr",
"flt",
"rsr",
"brief",
"docset",
176 arg_desc->AddOptionalKey(
"reldate",
"RelDate",
"Age of date in days",
179 arg_desc->AddOptionalKey(
"report",
"Report",
"Taxonomy data format",
182 "uilist",
"brief",
"docsum",
"xml"));
184 arg_desc->AddOptionalKey(
"usehistory",
"UseHistory",
"Use history",
186 arg_desc->AddOptionalKey(
"sort",
"Sort",
"Sort order or 'none'",
211 arg_desc->AddOptionalKey(
"dbfrom",
"dbfrom",
"origination db for elink",
214 arg_desc->AddOptionalKey(
"cmd",
"Command",
"elink command",
217 "prlinks",
"llinks",
"llinkslib",
"lcheck",
"ncheck",
218 "neighbor",
"neighbor_history",
"acheck"));
220 arg_desc->AddOptionalKey(
"linkname",
"Linkname",
"elink linkname",
223 arg_desc->AddOptionalKey(
"holding",
"holding",
"elink holding",
226 arg_desc->AddOptionalKey(
"version",
"Version",
"elink DTD version",
230 string prog_description =
231 "Test loading data from EUtils";
232 arg_desc->SetUsageContext(
GetArguments().GetProgramBasename(),
233 prog_description,
false);
242 if ( args[
"http"].AsString() ==
"get" ) {
252 cout << data << endl;
258 string db = args[
"db"] ? args[
"db"].AsString() :
kEmptyStr;
272 if (
result->IsDbList() ) {
273 for (
const auto& name :
result->GetDbList().GetDbName()) {
290 req.
SetTerm(args[
"term"].AsString());
291 if ( args[
"usehistory"] ) {
294 if ( args[
"sort"] ) {
297 if ( args[
"reldate"] ) {
301 if ( args[
"retmax"] ) {
302 req.
SetRetMax(args[
"retmax"].AsInteger());
305 string rettype = args[
"rettype"] ? args[
"rettype"].AsString() :
kEmptyStr;
306 if (rettype ==
"count") {
309 else if (rettype ==
"uilist") {
312 else if ( !rettype.empty() ) {
314 " is incompatible with e-search request.");
341 req.
SetTerm(args[
"term"].AsString());
389 if ( args[
"dbfrom"] ) {
390 req.
SetDbFrom(args[
"dbfrom"].AsString());
398 string cmd = args[
"cmd"].AsString();
399 if (
cmd ==
"prlinks") {
402 else if (
cmd ==
"llinks" ) {
405 else if (
cmd ==
"llinkslib") {
408 else if (
cmd ==
"lcheck") {
411 else if (
cmd ==
"ncheck") {
414 else if (
cmd ==
"neighbor") {
417 else if (
cmd ==
"neighbor_history") {
420 else if (
cmd ==
"acheck") {
427 if ( args[
"linkname"] ) {
430 if ( args[
"holding"] ) {
433 if ( args[
"version"] ) {
436 if ( args[
"reldate"] ) {
458 string db = args[
"db"] ? args[
"db"].AsString() :
kEmptyStr;
467 if ( args[
"retstart"] ) {
470 if ( args[
"retmax"] ) {
471 req.
SetRetMax(args[
"retmax"].AsInteger());
492 cout <<
"Deserialization error: " << ex.
what() << endl;
500 string db = args[
"db"] ? args[
"db"].AsString() :
kEmptyStr;
504 req.
SetTerm(args[
"term"].AsString());
526 db = args[
"db"].AsString();
549 string db = args[
"db"].AsString();
551 if (db ==
"pubmed") {
554 else if (db ==
"pmc") {
557 else if (db ==
"journals") {
560 else if (db ==
"omim") {
566 unique_ptr<CEFetch_Literature_Request> lit_req(
569 string rettype = args[
"rettype"] ? args[
"rettype"].AsString() :
kEmptyStr;
570 if (rettype ==
"uilist") {
573 else if (rettype ==
"abstract") {
576 else if (rettype ==
"citation") {
579 else if (rettype ==
"medline") {
582 else if (rettype ==
"full") {
585 else if ( !rettype.empty() ) {
587 " is incompatible with the selected database " << db);
591 return lit_req.release();
598 string db = args[
"db"].AsString();
603 else if (db ==
"genome") {
606 else if (db ==
"nucleotide") {
609 else if (db ==
"nuccore") {
612 else if (db ==
"nucest") {
615 else if (db ==
"nucgss") {
618 else if (db ==
"protein") {
621 else if (db ==
"popset") {
624 else if (db ==
"snp") {
627 else if (db ==
"sequences") {
633 unique_ptr<CEFetch_Sequence_Request> seq_req(
636 string rettype = args[
"rettype"] ? args[
"rettype"].AsString() :
kEmptyStr;
637 if (rettype ==
"native") {
640 else if (rettype ==
"fasta") {
643 else if (rettype ==
"gb") {
646 else if (rettype ==
"gbc") {
649 else if (rettype ==
"gbwithparts") {
652 else if (rettype ==
"est") {
655 else if (rettype ==
"gss") {
658 else if (rettype ==
"gp") {
661 else if (rettype ==
"gpc") {
664 else if (rettype ==
"seqid") {
667 else if (rettype ==
"acc") {
670 else if (rettype ==
"chr") {
673 else if (rettype ==
"flt") {
676 else if (rettype ==
"rsr") {
679 else if (rettype ==
"brief") {
682 else if (rettype ==
"docset") {
685 else if ( !rettype.empty() ) {
687 " is incompatible with the selected database " << db);
691 return seq_req.release();
698 string db = args[
"db"].AsString();
699 if (db !=
"taxonomy") {
702 unique_ptr<CEFetch_Taxonomy_Request> tax_req(
705 if ( args[
"report"] ) {
706 string report = args[
"report"].AsString();
707 if (report ==
"uilist") {
710 else if (report ==
"brief") {
713 else if (report ==
"docsum") {
716 else if (report ==
"xml") {
720 ERR_POST(
Error <<
"Unsupported taxonomy report: " << report);
724 return tax_req.release();
743 << args[
"db"].AsString() <<
" using the specified arguments.");
750 if ( req->GetConnContext()->GetWebEnv().empty() && args[
"id"] ) {
751 req->GetId().SetIds(args[
"id"].AsString());
754 string retmode_str = args[
"retmode"].AsString();
756 if (retmode_str ==
"text") {
759 else if (retmode_str ==
"xml") {
762 else if (retmode_str ==
"html") {
765 else if (retmode_str ==
"asn") {
771 req->SetRetMode(retmode);
773 cout << req->GetScriptName() <<
"?" << req->GetQueryString() << endl;
783 cout << content << endl;
795 if (args[
"webenv"]) {
798 if (args[
"query_key"]) {
809 if ( args[
"einfo"] ) {
812 if ( args[
"egquery"] ) {
815 if ( args[
"espell"] ) {
818 if ( args[
"esearch"] ) {
821 if ( args[
"epost"] ) {
824 if ( args[
"elink"] ) {
827 if ( args[
"esummary"] ) {
830 if ( args[
"efetch"] ) {
834 if ( args[
"ehistory"] ) {
CEFetch_Literature_Request.
CEFetch_Sequence_Request.
CEFetch_Taxonomy_Request.
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)
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
Root class for all serialization exceptions.
int NcbiSys_main(int argc, ncbi::TXChar *argv[])
virtual const CArgs & GetArgs(void) const
Get parsed command line arguments.
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.
virtual void SetupArgDescriptions(CArgDescriptions *arg_desc)
Setup the command line argument descriptions.
const CNcbiArguments & GetArguments(void) const
Get the application's cached unprocessed command-line arguments.
@ eRequires
One argument requires another.
@ eBoolean
{'true', 't', 'false', 'f'}, case-insensitive
@ eString
An arbitrary string.
@ eInteger
Convertible into an integer number (int or Int8)
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
virtual string GetQueryString(void) const
Get CGI script query string.
ERetMode
Output format for efetch requests.
void SetDatabase(const string &database)
Setting new database disconnects the request.
const CEUtils_IdGroupSet & GetIdGroups(void) const
Multiple ID groups.
void SetSortOrderName(CTempString name)
Set sort order. Empty string indicates no sorting (or the default one).
void SetRetStart(int retstart)
const CEUtils_IdGroup & GetId(void) const
Group of ids required if history is not used.
ESequenceDB
Sequence databases.
CRef< elink::CELinkResult > GetELinkResult(void)
Get search result.
void SetRequestMethod(ERequestMethod method)
Set HTTP method.
void SetRetMax(int retmax)
virtual string GetQueryString(void) const
Get CGI script query string.
virtual string GetQueryString(void) const
Get CGI script query string.
ELiteratureDB
Literature databases.
CRef< espell::CESpellResult > GetESpellResult(void)
Get search results.
void SetTool(const string &tool)
CRef< CEUtils_ConnContext > & GetConnContext(void) const
Get current request context.
void SetGroups(const string &groups)
Parse a set of id groups from a single string ('id=12,34&id=56,78').
CRef< einfo::CEInfoResult > GetEInfoResult(void)
Get result.
const string & GetScriptName(void) const
Get CGI script name (e.g. efetch.fcgi).
void SetTerm(const string &term)
virtual string GetQueryString(void) const
Get CGI script query string.
CRef< ehistory::CEHistoryResult > GetEHistoryResult(void)
Get request history.
CRef< epost::CEPostResult > GetEPostResult(void)
Get search results.
const CEUtils_IdGroup & GetId(void) const
Group of ids to be added to the search history.
void SetLinkName(const string &linkname)
void SetTerm(const string &term)
void SetRelDate(int days)
void SetEmail(const string &email)
CRef< esearch::CESearchResult > GetESearchResult(void)
Get search results.
CRef< esummary::CESummaryResult > GetESummaryResult(void)
Get search result.
virtual string GetQueryString(void) const
Get CGI script query string.
void Read(string *content)
Read the whole stream into the string.
void SetRetType(ERetType rettype)
CRef< egquery::CResult > GetResult(void)
Get search results.
const string & GetWebEnv(void) const
Get WebEnv.
const string & GetQueryKey(void) const
Get query_key.
void SetUseHistory(bool value)
void SetRetMax(int retmax)
void SetDbFrom(const string &dbfrom)
void SetQueryKey(const string &query_key)
Set query_key.
void SetHolding(const string &holding)
void SetWebEnv(const string &webenv)
Set WebEnv.
void SetTerm(const string &term)
void SetIds(const string &ids)
Parse all ids from a string (e.g. 'id=123,456,78').
void SetRelDate(int days)
void SetCommand(ECommand cmd)
virtual string GetQueryString(void) const
Get CGI script query string.
virtual string GetQueryString(void) const
Get CGI script query string.
@ eRetMode_text
Return data as plain text.
@ eRetMode_xml
Return data as XML.
@ eRetMode_html
Return data as HTML.
@ eRetMode_asn
Return data as text ASN.1.
@ eCmd_llinks
LinkOut URLs, except PubMed libraries.
@ eCmd_ncheck
Check for the existence of neighbor links.
@ eCmd_lcheck
Check for the existence of external links.
@ eCmd_prlinks
Links to the primary provider.
@ eCmd_acheck
Entrez databases links.
@ eCmd_neighbor
Display neighbors within a database (default)
@ eCmd_llinkslib
LinkOut URLs and Attributes.
@ eCmd_neighbor_history
Create history for use in other EUtils.
void Error(CExceptionArgs_Base &args)
virtual const char * what(void) const noexcept
Standard report (includes full backlog).
void Reset(void)
Reset reference object.
Defines the CNcbiApplication and CAppException classes for creating NCBI applications.
Defines command line argument related classes.
Defines unified interface to application: