69 : cgiUrl(cgi_url + (nocache ?
"?nocache=true" :
""))
77 string service_name(GetService());
93 cout <<
"cache_request_id=" << args.
GetValue(
"cache_request_id") << endl;
96 LOG_POST(
Info <<
"Connecting to url:" << x_GetURL().c_str());
98 if(x_GetURL().
empty())
101 x_ConnectURL(x_GetURL());
115 cgiArgs.push_back(
"-nocache");
116 cgiArgs.push_back(
"true");
122 cout <<
"\nDirectly invoking CGI with following post request :\n" <<
MSerial_AsnText << request << endl;
124 ostringstream errStr;
130 const char*
env[] = {
"REQUEST_METHOD=POST", 0};
136 cout <<
"Process Killed or Aborted. CPipe::ExecWait return value " << retVal
137 <<
". Process Exit code: " << exitCode << endl;
141 cout <<
"OutStream size = " << outStr.str().size() << endl;
143 cout <<
"ErrStream >>>>>>>>>" << endl
144 << errStr.str() << endl
145 <<
"<<<<<<<<< ErrStream" << endl;
159 bool discarding =
true;
int linesDiscarded = 0;
165 cout <<
"Discarding header line " << ++linesDiscarded <<
" : " <<
buffer << endl;
174 virtual void Init(
void);
175 virtual int Run(
void);
185 arg_desc->AddOptionalKey(
"cgi",
"path_to_cgi",
"Directly calls the CGI instead of using the gencoll client",
CArgDescriptions::eString);
186 arg_desc->SetDependency(
"cgi", arg_desc->eExcludes,
"url");
187 arg_desc->AddOptionalKey(
"retries",
"retry_count",
"Max times to retry asking the CGI for a response.",
CArgDescriptions::eInteger);
188 arg_desc->SetDependency(
"retries", arg_desc->eExcludes,
"cgi");
191 arg_desc->SetConstraint(
"f", &(*
new CArgAllow_Strings,
"XML",
"XML1",
"xml",
"xml1",
"ASN.1",
"ASN1",
"asn1",
"asn.1"));
192 arg_desc->AddFlag(
"nocache",
"Do not use database cache; force fresh data");
198 arg_desc->AddKey(
"acc_file",
"acc_file",
"File with list of sequences - comma or semi-colon separated ids on each line. empty line or line started with # are ignored",
CArgDescriptions::eInputFile);
199 arg_desc->SetDependency(
"acc_file", arg_desc->eExcludes,
"acc");
200 arg_desc->AddFlag(
"roles",
"Add sequence role data to output");
207 arg_desc->SetDependency(
"acc_file", arg_desc->eExcludes,
"acc");
209 arg_desc->SetDependency(
"rel_id", arg_desc->eExcludes,
"acc");
210 arg_desc->SetDependency(
"rel_id", arg_desc->eExcludes,
"acc_file");
212 arg_desc->SetDependency(
"rel_file", arg_desc->eExcludes,
"acc");
213 arg_desc->SetDependency(
"rel_file", arg_desc->eExcludes,
"acc_file");
214 arg_desc->SetDependency(
"rel_file", arg_desc->eExcludes,
"rel_id");
220 arg_desc->AddOptionalKey(
"-filter",
"filter",
221 "Get assembly by sequence - filters could be: latest, refseq, genbank, major; can be combined using comma separated list of filters",
227 cmds_desc->SetUsageContext(GetArguments().GetProgramBasename(),
"Genomic Collections Service client application");
230 arg_desc->SetUsageContext(
"",
"Validate chromosome type and location");
233 AddCommonArgs(arg_desc.get());
234 cmds_desc->AddCommand(
"get-chrtype-valid", arg_desc.release(),
"vc");
237 arg_desc->SetUsageContext(
"",
"Get assembly");
239 AddAccRelId(arg_desc.get());
240 AddCommonArgs(arg_desc.get());
241 cmds_desc->AddCommand(
"get-assembly", arg_desc.release(),
"ga");
244 arg_desc->SetUsageContext(
"",
"Get assemblies containing sequence");
245 arg_desc->AddFlag(
"top_asm",
"Return top assembly only");
246 AddSeqAcc(arg_desc.get());
247 AddFilterSort(arg_desc.get());
248 AddCommonArgs(arg_desc.get());
249 cmds_desc->AddCommand(
"get-assembly-by-sequence", arg_desc.release(),
"gas");
252 arg_desc->SetUsageContext(
"",
"Get assemblies equivalent to a given one");
255 AddCommonArgs(arg_desc.get());
256 cmds_desc->AddCommand(
"get-equivalent-assemblies", arg_desc.release(),
"gea");
258 SetupArgDescriptions(cmds_desc.release());
274 if(args[
"cgi"]) service.
Reset(
new CDirectCGIExec(args[
"cgi"].AsString(), args[
"nocache"]));
275 else if(args[
"url"]) service.
Reset(
new CGencollService(args[
"url"].AsString(), args[
"nocache"]));
276 else if(args.
Exist(
"gc-cache") && args[
"gc-cache"])
280 if (args[
"retries"]) service->SetTryLimit(args[
"retries"].AsInteger());
282 return RunWithService(*service, args, ostr);
309 list< CRef<CSeqdesc> >&
l = desc->
SetDescr().Set();
318 static list<string>
GetIDs(
const string& ids)
320 list<string> id_list;
329 list<string> accessions;
334 if (line.empty() || line[0] ==
'#') {
338 list<string> tlst=
GetIDs(line);
340 accessions.splice(accessions.end(),tlst);
350 return args[
"acc"].HasValue() ?
GetIDs(args[
"acc"].AsString()) :
351 args[
"acc_file"].HasValue() ?
GetIDsFromFile(args[
"acc_file"].AsInputFile()) :
356 return args[
"rel_id"].HasValue() ?
GetIDs(args[
"rel_id"].AsString()) :
357 args[
"rel_file"].HasValue() ?
GetIDsFromFile(args[
"rel_file"].AsInputFile()) :
366 ostr << service.
ValidateChrType(args[
"type"].AsString(), args[
"loc"].AsString());
370 if (args[
"acc"] || args[
"acc_file"])
372 else if (args[
"rel_id"] || args[
"rel_file"])
375 ERR_POST(
Error <<
"Either accession or release id should be provided");
377 else if(args.
GetCommand() ==
"get-assembly-by-sequence")
379 list<string> filter_s;
382 const int filter = accumulate(filter_s.begin(), filter_s.end(), 0, [](
int acc,
const string&
f)
384 return acc | ENUM_METHOD_NAME(EGCClient_GetAssemblyBySequenceFilter)()->FindValue(f);
387 const bool with_roles = args[
"roles"];
389 if(!seqlist.empty()){
396 else if(args.
GetCommand() ==
"get-equivalent-assemblies")
408 int main(
int argc,
const char* argv[])
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
void remove_if(Container &c, Predicate *__pred)
int RunWithService(CGenomicCollectionsService &service, const CArgs &args, CNcbiOstream &ostr)
virtual int Run(void)
Run the application.
virtual void Init(void)
Initialize the application.
CCommandArgDescriptions –.
virtual void Ask(const CGCClientRequest &request, CGCClientResponse &reply)
void SkipHeader(istream &is)
CDirectCGIExec(const string &cgi_path, bool nocache)
CGencollService(const CArgs &args)
CGencollService(const string &cgi_url, bool nocache)
virtual string x_GetURL()
CGencollService(bool nocache)
virtual void x_Connect()
These run with m_Mutex already acquired.
CRef< CGCClient_EquivalentAssemblies > GetEquivalentAssemblies(const string &acc, int equivalency)
static void AddArguments(CArgDescriptions &arg_desc)
CRef< CGCClient_AssembliesForSequences > FindAssembliesBySequences(const string &sequence_acc, int filter, CGCClient_GetAssemblyBySequenceRequest::ESort sort=CGCClient_GetAssemblyBySequenceRequest::eSort_default, bool with_roles=false)
Find assemblies by sequence accession.
CRef< CGC_Assembly > GetAssembly(const string &acc, const string &mode)
CRef< CGCClient_AssemblyInfo > FindOneAssemblyBySequences(const string &sequence_acc, int filter, CGCClient_GetAssemblyBySequenceRequest::ESort sort=CGCClient_GetAssemblyBySequenceRequest::eSort_default)
Find assembly by sequence accession.
string ValidateChrType(const string &chrType, const string &chrLoc)
static CNcbiApplication * Instance(void)
Singleton method.
std::ofstream out("events_result.xml")
main entry point for tests
static CGC_AssemblyDesc * GetAssebmlyDesc(CRef< CGC_Assembly > &assembly)
static list< string > GetAccessions(const CArgs &args)
static list< string > GetReleaseIds(const CArgs &args)
static list< string > GetIDs(const string &ids)
static list< string > GetIDsFromFile(CNcbiIstream &istr)
int main(int argc, const char *argv[])
static CRef< CGC_Assembly > RemoveVersions(CRef< CGC_Assembly > assembly)
static bool isVersionsObject(CRef< CSeqdesc > desc)
User-defined methods of the data storage class.
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.
bool Exist(const string &name) const
Check existence of argument description.
string GetCommand(void) const
Get current command.
@ eInputFile
Name of file (must exist and be readable)
@ eString
An arbitrary string.
@ eOutputFile
Name of file (must be writable)
@ eInteger
Convertible into an integer number (int or Int8)
CDiagContext & GetDiagContext(void)
Get diag context instance.
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
static void SetOldPostFormat(bool value)
Set old/new format flag.
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
void Error(CExceptionArgs_Base &args)
virtual const char * what(void) const noexcept
Standard report (includes full backlog).
void Info(CExceptionArgs_Base &args)
#define MSerial_AsnBinary
#define ENUM_METHOD_NAME(EnumName)
virtual void x_Connect(void) override
#define MSerial_AsnText
I/O stream manipulators –.
void Reset(void)
Reset reference object.
EFinish
ExecWait return code.
static EFinish ExecWait(const string &cmd, const vector< string > &args, CNcbiIstream &in, CNcbiOstream &out, CNcbiOstream &err, int &exit_code, const string ¤t_dir=kEmptyStr, const char *const envp[]=0, IProcessWatcher *watcher=0, const STimeout *kill_timeout=0, size_t pipe_size=0)
Execute a command with a vector of arguments, and wait for its completion.
@ eDone
Process finished normally.
CNcbiIstream & NcbiGetlineEOL(CNcbiIstream &is, string &str, string::size_type *count=NULL)
Read from "is" to "str" the next line (taking into account platform specifics of End-of-Line)
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
static SIZE_TYPE FindNoCase(const CTempString str, const CTempString pattern, SIZE_TYPE start, SIZE_TYPE end, EOccurrence which=eFirst)
Find the pattern in the specified range of a string using a case insensitive search.
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate whitespace in a string (in-place)
static string & ToUpper(string &str)
Convert string to upper case – string& version.
@ fSplit_Tokenize
All delimiters are merged and trimmed, to get non-empty tokens only.
void Run(void)
Enter the main loop.
bool IsSetValue(const string &name) const
Check if an argument with the given name exists.
const string & GetValue(const string &name, bool *is_found=0) const
Get value for the given name.
bool IsStr(void) const
Check if variant Str is selected.
bool IsSetType(void) const
type of object within class Check if a value has been assigned to Type data member.
const TStr & GetStr(void) const
Get the variant data.
const TType & GetType(void) const
Get the Type member data.
const TUnit & GetUnit(void) const
Get the variant data.
void SetDesc(TDesc &value)
Assign a value to Desc data member.
bool IsSetDesc(void) const
descriptors live in a shared data block Check if a value has been assigned to Desc data member.
bool IsAssembly_set(void) const
Check if variant Assembly_set is selected.
bool CanGetDescr(void) const
Check if it is safe to call GetDescr method.
void SetDesc(TDesc &value)
Assign a value to Desc data member.
const TAssembly_set & GetAssembly_set(void) const
Get the variant data.
bool IsSetDesc(void) const
descriptors live in a shared data block Check if a value has been assigned to Desc data member.
TUnit & SetUnit(void)
Select the variant.
bool IsUnit(void) const
Check if variant Unit is selected.
TAssembly_set & SetAssembly_set(void)
Select the variant.
void SetDescr(TDescr &value)
Assign a value to Descr data member.
const TUser & GetUser(void) const
Get the variant data.
bool IsUser(void) const
Check if variant User is selected.
constexpr auto sort(_Init &&init)
constexpr bool empty(list< Ts... >) noexcept
Magic spell ;-) needed for some weird compilers... very empiric.
Defines the CNcbiApplication and CAppException classes for creating NCBI applications.
#define GetArgs
Avoid preprocessor name clash with the NCBI C Toolkit.
Defines command line argument related classes.
Defines unified interface to application:
std::istream & in(std::istream &in_, double &x_)
static SLJIT_INLINE sljit_ins l(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)