<
typenameTF>
51invoke_result_t<TF, const string&>
Get(
const string&
key, TF
f, invoke_result_t<TF, const string&> def_value)
const;
53 template<
typenameT>
54 T GetNumeric(
const string&
key)
const{
return Get(
key, [](
const auto& v) {
returnNStr::StringToNumeric<T>(v); },
T()); }
59 template<
typenameTF>
60invoke_result_t<TF, const string&>
SPsgCgiEntries::Get(
const string&
key, TF
f, invoke_result_t<TF, const string&> def_value)
const 63 returnfound ==
entries.
end() ? def_value :
f(found->second.GetValue());
70 transform(range.first, range.second, back_inserter(rv), [](
const auto& p) {
returnp.second.GetValue(); });
77 template<
classTParams>
78 structSBase : TParams
80 template<
class... TInitArgs>
86std::forward<TInitArgs>(init_args)...
95 structSOneRequest : SBase<SOneRequestParams>
104GetDataOnlyOutputFormat(
entries)
122 template<
classTParams>
123 structSParallelProcessing : SBase<TParams>
125 template<
class... TInitArgs>
133std::forward<TInitArgs>(init_args)...
139 structSBatchResolve : SParallelProcessing<SBatchResolveParams>
171 voidForEachTSE(
TExcludeexclude)
const;
175 auto GetSNPScaleLimit()
const{
returnobjects::CSeq_id::GetSNPScaleLimit_Value(
input.GetString(
"snp-scale-limit")); }
177 voidSetRequestFlags(shared_ptr<CPSG_Request> request)
const;
183 return[&](
const string& name) {
184 return input.Has(name);
192 autoids =
input.GetStringList(
"id");
194 for(
const auto&
id: ids) {
198rv.emplace_back(
id);
207 const auto&
id=
input.GetString(
"id");
218 autoblob_ids =
input.GetStringList(
"exclude-blob");
220 for(
const auto& blob_id : blob_ids) {
227 if(
input.Has(
"include-hup")) {
235m_Response(response),
261 void Error(
intstatus);
274m_Response.SetContentType(
"application/octet-stream");
278m_Response.SetContentType(
"x-ncbi-data/x-asn-binary");
282m_Response.SetContentType(
"x-ncbi-data/x-asn-text");
286m_Response.SetContentType(
"text/xml");
290m_Response.SetContentType(
"application/json");
294m_Response.WriteHeader() << m_Out.rdbuf();
297cerr << m_Err.rdbuf();
304m_Response.SetContentType(
"application/problem+json");
309m_Response.WriteHeader() << doc;
311m_Response.WriteHeader() << m_Err.rdbuf();
317 void Init()
override;
319 intHelp(
const string& request,
booljson,
CCgiResponse& response);
321 static intGetStatus(
intrv);
324 template<
classTChild,
classTParent,
class... TArgs>
325 staticTChild*
NewChild(TParent* parent, TArgs&&... args)
328 autochild =
newTChild(std::forward<TArgs>(args)...);
329parent->AppendChild(child);
347 const auto& request =
ctx.GetRequest();
359 if(
type==
"resolve") {
361}
else if(
type==
"ipg_resolve") {
369response.
DataOnly(builder.data_only);
373 const autostatus = GetStatus(rv);
374SetHTTPStatus(status);
383 if(!help_doc.
Read(
"pubseq_gateway.json")) {
385response.
WriteHeader() <<
"Missing 'pubseq_gateway.json'\n";
390 autorequest_obj = help_obj[
"request"].
SetObject();
393 if(request_obj.has(request)) {
394 auto i= request_obj.begin();
396 while(
i!= request_obj.end()) {
397 if(
i->name != request) {
398 i= request_obj.erase(
i);
412NewChild<CHTML_title>(html.
GetPointer())->AppendPlainText(
"help");
413 autobody = NewChild<CHTML_body>(html.
GetPointer());
415NewChild<CHTML_h2>(body)->AppendPlainText(
"pubseq_gateway.cgi");
416NewChild<CHTMLPlainText>(body,
"A user-friendly CGI gateway to PSG.");
418 auto i= help_obj.find(
"Common Parameters");
420 if(
i!= help_obj.end()) {
421AddParamsTable(body,
i->name, *
i);
424 for(
const auto&
r: request_obj) {
425NewChild<CHTML_hr>(body);
427 autoh2 = NewChild<CHTML_h2>(body);
428NewChild<CHTML_i>(h2)->AppendPlainText(
"request");
429h2->AppendPlainText(
string(
"=") +
r.name);
431 autor_obj =
r.value.GetObject();
432 autok = r_obj.find(
"method");
434 if(k != r_obj.end()) {
435 for(
const auto& m : k->value.GetObject()) {
436 autom_obj = m.value.GetObject();
437NewChild<CHTML_h3>(body, m.name +
string(
":"));
438NewChild<CHTMLPlainText>(body, m_obj[
"description"].GetValue().GetString());
440 autoj = m_obj.find(
"Method-specific Parameters");
442 if(j != m_obj.end()) {
443AddParamsTable(body, m.name +
string(
"-specific Parameters"), *j);
447NewChild<CHTMLPlainText>(body, r_obj[
"description"].GetValue().GetString());
450 autoj = r_obj.find(
"Request-specific Parameters");
452 if(j != r_obj.end()) {
453AddParamsTable(body, j->name, *j);
475NewChild<CHTML_h4>(body, name);
476 auto table= NewChild<CHTML_table>(body);
481 autoheader =
table->HeaderCell(
r, 0);
482header->AppendPlainText(
type.
name);
483header->SetColSpan(2);
486 for(
const auto& param :
type.value.GetObject()) {
487NewChild<CHTML_i>(
table->DataCell(
r, 0))->AppendPlainText(param.name);
488 table->DataCell(
r, 1)->AppendPlainText(param.value.GetValue().GetString());
494 int main(
intargc,
const char* argv[])
Exception classes used by the NCBI CGI framework.
void transform(Container &c, UnaryFunction *op)
CJson_ConstObject GetObject(void) const
Get JSON object contents of the node.
const CJson_ConstNode value
bool Read(std::istream &in)
Read JSON data from a stream.
CJson_Object SetObject(void)
Get JSON object contents of the node.
CJson_Value SetValue(void)
Get JSON value contents of the node.
CJson_Value & SetString(const TStringType &value)
CJson_Value & SetInt8(Int8 value)
Bio-id (such as accession)
shared_ptr< void > TApiLock
Get an API lock.
static TApiLock GetApiLock()
CNullable< string > TNucleotide
static int OneRequest(const SOneRequestParams ¶ms, shared_ptr< CPSG_Request > request)
static int ParallelProcessing(const TParams ¶ms, istream &is=cin)
int Help(const string &request, bool json, CCgiResponse &response)
void Init() override
This method is called on the CGI application initialization â before starting to process a HTTP reque...
static int GetStatus(int rv)
static TChild * NewChild(TParent *parent, TArgs &&... args)
static void AddParamsTable(CHTML_body *body, const string &name, const CJson_ConstObject_pair ¶ms)
int ProcessRequest(CCgiContext &ctx) override
This is the method you should override.
CPSG_Queue::TApiLock m_ApiLock
CTimeout â Timeout interval.
const_iterator_pair equal_range(const key_type &key) const
const_iterator find(const key_type &key) const
const_iterator end() const
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.
void Flush(void) const
Flush output stream.
void SetContentType(const string &type)
Set content type (text/html by default if not provided)
CNcbiOstream & WriteHeader(void) const
Write HTTP response header to the output stream.
@ fDoNotParseContent
do not automatically parse the request's content body (from "istr")
@ fDisableParsingAsIndex
Disable parsing input as 'indexed' query (RFC3875) even if no '=' is present.
EDiagSev
Severity level for the posted diagnostics.
static bool StrToSeverityLevel(const char *str_sev, EDiagSev &sev)
Get severity from string.
@ eDiag_Warning
Warning message.
@ e500_InternalServerError
void Error(CExceptionArgs_Base &args)
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
ESerialDataFormat
Data file format.
@ eSerial_AsnText
ASN.1 text.
@ eSerial_AsnBinary
ASN.1 binary.
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
static Int8 StringToInt8(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to Int8.
static string URLDecode(const CTempString str, EUrlDecode flag=eUrlDec_All)
URL-decode string.
@ eDefault
Default timeout (to be interpreted by the client code)
E_Choice
Choice variants.
unsigned int
A callback function used to compare two keys in a database.
The blob sat and sat key Both must be positive integers</td > n< td > Non empty string The interpretation of the blob id depends on a processor Cassandra n processor expects the following format
<!DOCTYPE HTML >< html > n< header > n< title > PubSeq Gateway Help Page</title > n< style > n table
SParallelProcessing< TIpgBatchResolveParams > TIpgBatchResolve
const struct ncbi::grid::netcache::search::fields::KEY key
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
@ eSuccess
Successfully retrieved.
@ eForbidden
User is not authorized for the retrieval.
@ eError
An error was encountered while trying to send request or to read and to process the reply.
vector< CPSG_BioId > CPSG_BioIds
EPSG_BioIdResolution
Whether to try to resolve provided seq-ids before use.
@ Resolve
Try to resolve provided seq-ids.
@ NoResolve
Use provided seq-ids as is.
int main(int argc, const char *argv[])
static SLJIT_INLINE sljit_ins l(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
SBase(const SPsgCgiEntries &entries, TInitArgs &&... init_args)
SBatchResolve(const SPsgCgiEntries &entries)
SOneRequest(const SPsgCgiEntries &entries)
static ESerialDataFormat GetDataOnlyOutputFormat(const SPsgCgiEntries &entries)
SParallelProcessing(const SPsgCgiEntries &entries, TInitArgs &&... init_args)
const ESerialDataFormat output_format
static void SetDefault(const T &value)
Arbitrary request URL arguments.
T GetNumeric(const string &key) const
bool Has(const string &key) const
SPsgCgiEntries(const TCgiEntries &e)
auto GetStringList(const string &key) const
invoke_result_t< TF, const string & > Get(const string &key, TF f, invoke_result_t< TF, const string & > def_value) const
const TCgiEntries & entries
const string & GetString(const string &key) const
SReader(const SPsgCgiEntries &i)
SPSG_UserArgs GetUserArgs() const
auto GetAccSubstitution() const
auto GetNucleotide() const
CTimeout GetResendTimeout() const
EPSG_BioIdResolution GetBioIdResolution() const
auto GetSNPScaleLimit() const
CPSG_BioId GetBioId() const
auto GetAbsPathRef() const
const SPsgCgiEntries & input
auto GetBioIdType() const
vector< string > GetNamedAnnots() const
static CPSG_BioId::TType GetBioIdType(const string &type)
function< void(string)> TExclude
static shared_ptr< TRequest > Build(const TInput &input, TArgs &&... args)
static EPSG_AccSubstitution GetAccSubstitution(const string &acc_substitution)
static SResolveParams GetResolveParams(const TInput &input)
function< bool(const string &)> TSpecified
void DataOnly(const SOneRequestParams::SDataOnly &data_only)
CCgiResponse & m_Response
void operator()(int status)
optional< ESerialDataFormat > m_Format
SResponse(CCgiResponse &response)
static wxAcceleratorEntry entries[3]
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