;
69: cgiUrl(cgi_url + (nocache ?
"?nocache=true":
""))
77 stringservice_name(GetService());
93cout <<
"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())
101x_ConnectURL(x_GetURL());
115cgiArgs.push_back(
"-nocache");
116cgiArgs.push_back(
"true");
122cout <<
"\nDirectly invoking CGI with following post request :\n"<<
MSerial_AsnText<< request << endl;
124ostringstream errStr;
130 const char*
env[] = {
"REQUEST_METHOD=POST", 0};
136cout <<
"Process Killed or Aborted. CPipe::ExecWait return value "<< retVal
137<<
". Process Exit code: "<< exitCode << endl;
141cout <<
"OutStream size = "<< outStr.str().size() << endl;
143cout <<
"ErrStream >>>>>>>>>"<< endl
144<< errStr.str() << endl
145<<
"<<<<<<<<< ErrStream"<< endl;
159 booldiscarding =
true;
intlinesDiscarded = 0;
163discarding = !( (strlen(
buffer) == 0) || (strlen(
buffer) == 1 &&
buffer[0] == 13));
165cout <<
"Discarding header line "<< ++linesDiscarded <<
" : "<<
buffer<< endl;
174 virtual void Init(
void);
175 virtual int Run(
void);
184arg_desc->AddOptionalKey(
"url",
"url_to_service",
"URL to genemic collections service.cgi",
CArgDescriptions::eString);
185arg_desc->AddOptionalKey(
"cgi",
"path_to_cgi",
"Directly calls the CGI instead of using the gencoll client",
CArgDescriptions::eString);
186arg_desc->SetDependency(
"cgi", arg_desc->eExcludes,
"url");
187arg_desc->AddOptionalKey(
"retries",
"retry_count",
"Max times to retry asking the CGI for a response.",
CArgDescriptions::eInteger);
188arg_desc->SetDependency(
"retries", arg_desc->eExcludes,
"cgi");
191arg_desc->SetConstraint(
"f", &(*
new CArgAllow_Strings,
"XML",
"XML1",
"xml",
"xml1",
"ASN.1",
"ASN1",
"asn1",
"asn.1"));
192arg_desc->AddFlag(
"nocache",
"Do not use database cache; force fresh data");
198arg_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);
199arg_desc->SetDependency(
"acc_file", arg_desc->eExcludes,
"acc");
200arg_desc->AddFlag(
"roles",
"Add sequence role data to output");
207arg_desc->SetDependency(
"acc_file", arg_desc->eExcludes,
"acc");
208arg_desc->AddKey(
"rel_id",
"release_id",
"Comma-separated list of assembly release id's'",
CArgDescriptions::eString);
209arg_desc->SetDependency(
"rel_id", arg_desc->eExcludes,
"acc");
210arg_desc->SetDependency(
"rel_id", arg_desc->eExcludes,
"acc_file");
212arg_desc->SetDependency(
"rel_file", arg_desc->eExcludes,
"acc");
213arg_desc->SetDependency(
"rel_file", arg_desc->eExcludes,
"acc_file");
214arg_desc->SetDependency(
"rel_file", arg_desc->eExcludes,
"rel_id");
220arg_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",
227cmds_desc->SetUsageContext(GetArguments().GetProgramBasename(),
"Genomic Collections Service client application");
230arg_desc->SetUsageContext(
"",
"Validate chromosome type and location");
233AddCommonArgs(arg_desc.get());
234cmds_desc->AddCommand(
"get-chrtype-valid", arg_desc.release(),
"vc");
237arg_desc->SetUsageContext(
"",
"Get assembly");
238arg_desc->AddDefaultKey(
"-mode",
"AllSequences",
"Assembly retrieval mode",
CArgDescriptions::eString,
"AssemblyOnly");
239AddAccRelId(arg_desc.get());
240AddCommonArgs(arg_desc.get());
241cmds_desc->AddCommand(
"get-assembly", arg_desc.release(),
"ga");
244arg_desc->SetUsageContext(
"",
"Get assemblies containing sequence");
245arg_desc->AddFlag(
"top_asm",
"Return top assembly only");
246AddSeqAcc(arg_desc.get());
247AddFilterSort(arg_desc.get());
248AddCommonArgs(arg_desc.get());
249cmds_desc->AddCommand(
"get-assembly-by-sequence", arg_desc.release(),
"gas");
252arg_desc->SetUsageContext(
"",
"Get assemblies equivalent to a given one");
255AddCommonArgs(arg_desc.get());
256cmds_desc->AddCommand(
"get-equivalent-assemblies", arg_desc.release(),
"gea");
258SetupArgDescriptions(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 returnRunWithService(*service, args, ostr);
297 returndesc->
IsUser() &&
309list< CRef<CSeqdesc> >&
l= desc->
SetDescr().Set();
318 staticlist<string>
GetIDs(
const string& ids)
320list<string> id_list;
329list<string> accessions;
334 if(line.empty() || line[0] ==
'#') {
338list<string> tlst=
GetIDs(line);
340accessions.splice(accessions.end(),tlst);
350 returnargs[
"acc"].HasValue() ?
GetIDs(args[
"acc"].AsString()) :
351args[
"acc_file"].HasValue() ?
GetIDsFromFile(args[
"acc_file"].AsInputFile()) :
356 returnargs[
"rel_id"].HasValue() ?
GetIDs(args[
"rel_id"].AsString()) :
357args[
"rel_file"].HasValue() ?
GetIDsFromFile(args[
"rel_file"].AsInputFile()) :
364 if(args.
GetCommand() ==
"get-chrtype-valid")
366ostr << service.
ValidateChrType(args[
"type"].AsString(), args[
"loc"].AsString());
368 else if(args.
GetCommand() ==
"get-assembly")
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")
379list<string> filter_s;
382 const intfilter = accumulate(filter_s.begin(), filter_s.end(), 0, [](
intacc,
const string&
f)
384return acc | ENUM_METHOD_NAME(EGCClient_GetAssemblyBySequenceFilter)()->FindValue(f);
387 const boolwith_roles = args[
"roles"];
389 if(!seqlist.empty()){
396 else if(args.
GetCommand() ==
"get-equivalent-assemblies")
401 ERR_POST(
Error<<
"Caught an exception from client library ..."<< ex.
what());
408 int main(
intargc,
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)
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)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4