60 #if defined(NCBI_OS_UNIX)
87 const list< CRef<objects::CBlast4_error> > & errors = reply->GetErrors();
89 TErrorList::const_iterator
i;
91 for(
i = errors.begin();
i != errors.end();
i++) {
102 const list< CRef<CBlast4_error> > & errors = reply->GetErrors();
104 TErrorList::const_iterator
i;
106 for(
i = errors.begin();
i != errors.end();
i++) {
109 if ((*i)->CanGetMessage() && (! (*i)->GetMessage().empty())) {
111 msg += (*i)->GetMessage();
114 switch((*i)->GetCode()) {
116 m_Warn.push_back(
string(
"conversion_warning") + msg);
120 m_Errs.push_back(
string(
"internal_error") + msg);
124 m_Errs.push_back(
string(
"not_implemented") + msg);
128 m_Errs.push_back(
string(
"not_allowed") + msg);
132 m_Errs.push_back(
string(
"bad_request") + msg);
136 m_Errs.push_back(
string(
"Invalid/unknown RID (bad_request_id)") +
153 string cfg(
"Configuration required:");
181 if ( !errors.empty() ) {
229 "No response from server, cannot complete request.");
245 gsrr->SetRequest_id(
m_RID);
326 }
else if (!
done && errors.find(
"bad_request_id") !=
NPOS) {
378 m_Reply->GetBody().IsGet_search_results()) {
380 rv = & (
m_Reply->SetBody().SetGet_search_results());
392 if (gsrr && gsrr->CanGetAlignments()) {
393 rv = & (gsrr->SetAlignments());
415 const int query_index = 0;
420 temp.push_back(cur_set);
423 current_id = this_id;
425 cur_set->
Set().push_back(*it);
430 temp.push_back(cur_set);
437 TSeqAlignVector::size_type sap_index = 0;
439 const int query_index = 0;
440 if (sap_index < temp.size())
442 list< CRef< CSeq_align > > sal = temp[sap_index]->Get();
444 if (
CSeq_id::e_YES == (*it)->Compare(sal.front()->GetSeq_id(query_index) ))
446 rv.push_back(temp[sap_index]);
452 rv.push_back(cur_set);
458 rv.push_back(cur_set);
471 if (gsrr && gsrr->CanGetPhi_alignments()) {
472 rv = & (gsrr->SetPhi_alignments());
489 if (network_masks.empty()) {
496 size_t query_index = 0;
498 ITERATE(TGSRR::TMasks, masks_for_frame, network_masks) {
500 _ASSERT(masks_for_frame->NotEmpty());
503 ((*masks_for_frame)->GetLocations().front()->GetId());
504 if (previous_seqid.
Empty()) {
505 previous_seqid = current_seqid;
511 mqr = &retval[query_index];
513 mqr = &retval[++query_index];
514 previous_seqid = current_seqid;
519 _ASSERT((*masks_for_frame)->GetLocations().size() == (
size_t) 1);
520 _ASSERT((*masks_for_frame)->GetLocations().front().NotEmpty());
522 (*masks_for_frame)->GetLocations().front();
530 (*mask)->GetFrom(), (*mask)->GetTo()));
548 if (gsrr && gsrr->CanGetMasks()) {
549 rv = gsrr->SetMasks();
557 list< CRef<CBlast4_ka_block > > rv;
561 if (gsrr && gsrr->CanGetKa_blocks()) {
562 rv = (gsrr->SetKa_blocks());
574 if (gsrr && gsrr->CanGetSearch_stats()) {
575 rv = (gsrr->SetSearch_stats());
587 if (gsrr && gsrr->CanGetPssm()) {
588 rv = & (gsrr->SetPssm());
610 }
else if (
m_RID.empty()) {
625 m_Errs.push_back(
"No request exists and no RID was specified.");
646 m_Errs.push_back(
"No response from server, cannot complete request.");
650 if (reply->CanGetBody() &&
651 reply->GetBody().GetQueue_search().CanGetRequest_id()) {
653 m_RID = reply->GetBody().GetQueue_search().GetRequest_id();
675 bool try_again =
true;
687 m_Errs.push_back(
"No response from server, "
688 "cannot complete request.");
701 }
else if (
r->CanGetBody() &&
r->GetBody().IsGet_search_results()) {
704 m_Errs.push_back(
"Results were not a get-search-results reply");
731 cout <<
"polling " << 0 << endl;
735 double start_sec = 10.0;
736 double increment = 1.30;
737 double max_sleep = 300.0;
738 double max_time = timeout;
741 cout <<
"polling " << start_sec <<
"/" << increment <<
"/" << max_sleep <<
"/" << max_time <<
"/" << endl;
745 double sleep_next = start_sec;
746 double sleep_totl = 0.0;
749 cout <<
"line " << __LINE__ <<
" sleep next " << sleep_next <<
" sleep totl " << sleep_totl << endl;
755 while (
m_Pending && (sleep_totl < max_time)) {
757 cout <<
" about to sleep " << sleep_next << endl;
759 double max_left = max_time - sleep_totl;
762 if (sleep_next > max_left) {
763 sleep_next = max_left;
766 if (sleep_next < 2.0)
771 sleep_totl += sleep_next;
774 cout <<
" done, total = " << sleep_totl << endl;
776 if (sleep_next < max_sleep) {
777 sleep_next *= increment;
778 if (sleep_next > max_sleep) {
779 sleep_next = max_sleep;
784 cout <<
" next sleep time = " << sleep_next << endl;
810 "BLAST archive must be one of text ASN.1, binary ASN.1 or XML.");
830 const string & program,
831 const string & service)
833 if ((! opts_handle) || program.empty() || service.empty()) {
836 "NULL argument specified: options handle");
838 if (program.empty()) {
840 "NULL argument specified: program");
843 "NULL argument specified: service");
868 "CRemoteBlast: No remote API options.");
877 "Empty RID string specified");
894 m_CBOH->SetOptions().GetBlast4AlgoOpts();
896 string user_ipv6_address;
899 user_ipv6_address =
env.Get(
"HTTP_X_FORWARDED_FOR_IPV6");
900 if( !user_ipv6_address.empty() ){
901 algo_opts->
Add(
string(
"HTTP_X_FORWARDED_FOR_IPV6"), user_ipv6_address );
904 m_QSR->SetAlgorithm_options().Set() = *algo_opts;
915 p->SetName(field.GetName());
919 m_QSR->SetProgram_options().Set().push_back(p);
930 p->SetName(field.GetName());
934 m_QSR->SetProgram_options().Set().push_back(p);
944 p->SetName(field.GetName());
948 m_QSR->SetProgram_options().Set().push_back(p);
952 const list<Int8> * x)
958 p->SetName(field.GetName());
962 m_QSR->SetProgram_options().Set().push_back(p);
970 v->
SetString().assign((x && (*x)) ? (*x) :
"");
973 p->SetName(field.GetName());
977 m_QSR->SetProgram_options().Set().push_back(p);
982 if (bioseqs.
Empty()) {
984 "Empty reference for query.");
1003 if (!
m_QSR->IsSetQueries())
1006 "Queries must be set before setting the masks.");
1013 if (seqlocs.empty()) {
1015 "Empty list for query.");
1037 if (masking_locations.empty()) {
1041 if (
m_QSR->GetQueries().GetNumQueries() != masking_locations.size()) {
1043 oss <<
"Mismatched number of queries ("
1044 <<
m_QSR->GetQueries().GetNumQueries()
1045 <<
") and masking locations (" << masking_locations.size() <<
")";
1066 (*masked_region)->GetFrom(),
1067 (*masked_region)->GetTo()));
1068 if ((*masked_region)->CanGetStrand() &&
1076 retval->SetLocations().push_back(seqloc);
1084 retval->SetFrame(frame);
1092 vector<string>* warnings )
1099 if (query_masks->empty()) {
1103 int current_frame = query_masks->front()->GetFrame();
1107 if (!packed_seqint.
Empty())
1111 retval.push_back(network_mask);
1113 current_frame = (*mask_locs)->GetFrame();
1117 packed_seqint->AddInterval((*mask_locs)->GetSeqId(),
1118 (*mask_locs)->GetInterval().GetFrom(),
1119 (*mask_locs)->GetInterval().GetTo());
1122 if (!packed_seqint.
Empty())
1127 retval.push_back(network_mask);
1129 packed_seqint.
Reset();
1160 "Empty reference for query pssm.");
1165 string psi_program(
"blastp");
1166 string old_service(
"plain");
1167 string new_service(
"psi");
1168 string delta_service(
"delta_blast");
1170 if (
m_QSR->GetProgram() != psi_program) {
1172 "PSI-Blast is only supported for blastp.");
1175 if (
m_QSR->GetService().empty()) {
1177 "Internal error: service is not set.");
1180 if ((
m_QSR->GetService() != old_service) &&
1181 (
m_QSR->GetService() != new_service) &&
1182 (
m_QSR->GetService() != delta_service)) {
1187 string(
"PSI-Blast cannot also be ") +
1188 m_QSR->GetService() +
".");
1194 m_QSR->SetQueries(*queries_p);
1197 if(
m_QSR->GetService() != delta_service) {
1198 m_QSR->SetService(new_service);
1208 string rvalue =
m_Errs[0];
1210 for(
unsigned i = 1;
i<
m_Errs.size();
i++) {
1224 string rvalue =
m_Warn[0];
1226 for(
unsigned i = 1;
i<
m_Warn.size();
i++) {
1276 if (iter->NotEmpty()) {
1279 if (entry.
IsSeq()) {
1303 if (queries.
Empty()) {
1306 "Error: No queries specified");
1313 if (bss.
Empty() && sll.empty()) {
1316 "Error: No query data.");
1322 bool has_local_ids =
false;
1324 if ( !sll.empty() ) {
1326 if (sll.front()->IsInt()) {
1329 const int kRangeLength = kStop -
kStart + 1;
1335 const int kFullLength =
1336 bss->
GetSeq_set().front()->GetSeq().GetInst().GetLength();
1338 if (kFullLength != kRangeLength) {
1346 has_local_ids =
true;
1355 if (has_local_ids) {
1380 "Error: No PSSM specified");
1391 if (opts_handle.
Empty()) {
1394 "Error: No options specified");
1400 "Error: No database specified");
1410 if ( !tmplist.empty() ) {
1412 copy(tmplist.begin(), tmplist.end(), back_inserter(gilist));
1421 if ( !tmplist.empty() ) {
1423 copy(tmplist.begin(), tmplist.end(), back_inserter(gilist));
1441 string l_disk_cache_flag =
env.Get(
"BLAST4_DISK_CACHE");
1456 if (gi_list.empty()) {
1460 "Submitting gi lists remotely is currently not supported");
1463 #ifdef NCBI_STRICT_GI
1464 list<int> int_gi_list;
1465 ITERATE ( list<TGi>, it, gi_list ) {
1466 int_gi_list.push_back(
GI_TO(
int, *it));
1473 copy(gi_list.begin(), gi_list.end(), back_inserter(
m_GiList));
1493 const char *
key = algo_key.c_str();
1509 if (gi_list.empty()) {
1513 "Submitting negative gi lists remotely is currently not supported");
1515 #ifdef NCBI_STRICT_GI
1516 list<int> int_gi_list;
1517 ITERATE ( list<TGi>, it, gi_list ) {
1518 int_gi_list.push_back(
GI_TO(
int, *it));
1544 m_Dbs->SetType(rtype);
1553 "NULL specified for database.");
1558 m_QSR->SetSubject(*subject_p);
1572 "Error: No query data.");
1575 list< CRef<CBioseq> > seqs;
1587 m_QSR->SetSubject(*subject_p);
1604 "NULL specified for entrez query.");
1631 return int(3600*3.5);
1662 const list< CRef< CBlast4_error > > & msgs =
m_Archive->GetMessages();
1664 if((*itr)->IsSetMessage()) {
1665 string msg = (*itr)->GetMessage();
1666 if((*itr)->IsSetCode()) {
1667 switch ((*itr)->GetCode()) {
1722 if (
strategy.GetSubject()->IsDatabase())
1738 "Could not get information from archive file.");
1746 if (
m_RID.empty()) {
1757 "Polling terminated, but search is in incomplete state.");
1793 "No response from server, cannot complete request.");
1800 if (reply->CanGetBody()) {
1801 if (reply->GetBody().IsGet_request_info()) {
1803 (& reply->SetBody().SetGet_request_info());
1805 if (grir->GetDatabase().GetName() !=
"n/a") {
1818 if( grir->IsSetFormat_options() )
1826 "Could not get information from search.");
1854 list< CRef<objects::CBioseq> >
1938 if (service ==
"rpsblast") {
1940 if (program ==
"blastp") {
1942 }
else if (program ==
"tblastn" || program ==
"blastx") {
1950 if (service ==
"psi") {
1976 _ASSERT(frame == -1 || frame == 1);
2078 for (; itr; ++itr) {
2093 if (seq_entry.
IsSeq()) {
2104 query_ids.push_back(
id);
2137 query_messages.push_back(sm);
2146 query_messages.push_back(sm);
2151 search_messages.insert(search_messages.end(),
2152 alignments.empty() ? 1 : alignments.size(),
2156 NcbiCout <<
"Error/Warning messages: '"
2157 << search_messages.
ToString() <<
"'" << endl;
2164 if (alignments.empty()) {
2166 alignments.resize(1);
2181 const string kTarget(
"Effective search space used: ");
2182 const string kLength_Adj(
"Length adjustment: ");
2184 Int8 effective_search_space = 0;
2185 Int8 length_adjustment = 0;
2189 effective_search_space =
2201 const string kTmp(
"Matrix: ");
2205 m_CBOH->SetOptions().SetMatrixName((*itr).c_str());
2212 bool found_gapped =
false, found_ungapped =
false;
2213 pair<double, double> lambdas, Ks, Hs;
2217 if ((*itr)->GetGapped()) {
2218 lambdas.second = (*itr)->GetLambda();
2219 Ks.second = (*itr)->GetK();
2220 Hs.second = (*itr)->GetH();
2221 found_gapped =
true;
2223 lambdas.first = (*itr)->GetLambda();
2224 Ks.first = (*itr)->GetK();
2225 Hs.first = (*itr)->GetH();
2226 found_ungapped =
true;
2229 if (found_gapped && found_ungapped) {
2240 ancill_vector.insert(ancill_vector.end(), alignments.size(),
2246 ancill_vector, &masks));
2256 bool succeeded =
false;
2273 unique_ptr<CObjectIStream> is(
2276 (is.get())->SetEnforcedStdXml(
true);
2278 *is >> *b4_ss_reply;
2292 retval.
Reset(&b4_ss_reply->Set());
2295 b4_ss_reply.
Reset();
2311 unique_ptr<CObjectIStream> is(
2314 (is.get())->SetEnforcedStdXml(
true);
2321 "Unrecognized input format ");
2330 const string&
value)
2333 info_request->SetRequest_id(rid);
2334 info_request->SetInfo().Add(name,
value);
2343 const string&
value)
2346 if (reply.
Empty() || !reply->CanGetBody()) {
2349 if (reply->GetBody().IsGet_search_info()) {
2354 const string reply_name =
2358 if( search_param.
NotEmpty() && search_param->GetValue().IsString()) {
2359 retval = search_param->GetValue().GetString();
2403 bool try_again =
true;
2416 m_Errs.push_back(
"No response from server, "
2417 "cannot complete request.");
2433 if( !
r->CanGetBody() ) {
2434 m_Errs.push_back(
"Results were not a get-search-results reply 2");
2437 if(
r->CanGetBody() && !
r->GetBody().IsGet_search_results()) {
2438 m_Errs.push_back(
"Results were not a get-search-results reply");
2445 m_Errs.push_back(
"Results were not a get-search-results reply 3");
2448 if(
r->CanGetBody() && !
r->GetBody().IsGet_search_results()) {
2449 m_Errs.push_back(
"Results were not a get-search-results reply 4");
2465 gsrr->SetRequest_id(
m_RID);
2467 gsrr->ResetResult_types();
2468 gsrr->SetResult_types( 16) ;
2484 string BLAST4_CONN_SERVICE_NAME =
"blast4";
2486 BLAST4_CONN_SERVICE_NAME =
env.Get(
"BLAST4_CONN_SERVICE_NAME");
2490 gsrr->SetRequest_id(
m_RID);
2503 char incoming_buffer[8192];
2504 int read_max = 8192;
2505 int l_total_bytes=0, n_read;
2506 bool l_cached_ok =
true;
2512 l_total_bytes += n_read;
2514 tmp_stream->write(incoming_buffer,n_read);
2515 if( tmp_stream->bad() || tmp_stream->fail() )
2517 l_cached_ok =
false;
2518 LOG_POST(
Error <<
"CRemoteBlast::x_GetSearchResultsHTTP CAN'T WRITE CACHED DATA: BAD/FAIL STATE" );
2524 LOG_POST(
Error <<
"CRemoteBlast::x_GetSearchResultsHTTP CAN'T WRITE CACHED DATA: "<<err.what() );
2525 l_cached_ok =
false;
2536 LOG_POST(
Info <<
"CRemoteBlast::x_GetSearchResultsHTTP: DISABLE CACHE, RE-READ");
2542 tmp_stream->seekg(0);
2546 unique_ptr<CObjectIStream>
2552 LOG_POST(
Info <<
"CRemoteBlast::x_GetSearchResultsHTTP: DISABLE CACHE, CAN'T READ CACHED FILE, RE-READ");
2597 "No response from server, cannot complete request.");
2605 if (reply->CanGetBody()) {
2606 if (reply->GetBody().IsGet_search_info()) {
2617 if( search_param.
NotEmpty() && search_param->GetValue().IsSeq_loc_list())
2622 else if( search_param.
NotEmpty() && search_param->GetValue().IsBioseq_list())
2630 "Obtained database name for remote bl2seq search");
2641 unsigned int iter_num = 0;
2647 iter_num = param->GetValue().GetInteger();
2650 else if(!
m_RID.empty())
2660 unsigned int retval=0;
2670 if ( !num.empty() ) {
2680 m_Archive->GetRequest().GetBody().IsGet_request_info() &&
2681 m_Archive->GetRequest().GetBody().GetGet_request_info().IsSetRequest_id() &&
2682 (
m_Archive->GetRequest().GetBody().GetGet_request_info().GetRequest_id() ==
"Error")) {
@ eExtreme_Positional
numerical value
User-defined methods of the data storage class.
User-defined methods of the data storage class.
ESubjectMaskingType
Define the possible subject masking types.
const int kBlastMessageNoContext
Declared in blast_message.h as extern const.
Declares the CBlastOptionsBuilder class.
Boolean Blast_QueryIsTranslated(EBlastProgramType p)
Returns true if the query is translated.
Boolean Blast_QueryIsNucleotide(EBlastProgramType p)
Returns true if the query is nucleotide.
EBlastProgramType
Defines the engine's notion of the different applications of the BLAST algorithm.
vector< CRef< objects::CSeq_align_set > > TSeqAlignVector
Vector of Seq-align-sets.
Int2 BlastProgram2Number(const char *program, EBlastProgramType *number)
Set number for a given program type.
User-defined methods of the data storage class.
const string & GetName() const
Get field name (key).
static CBlast4Field & Get(EBlastOptIdx opt)
CBlast4_get_search_info_reply –.
CBlast4_get_search_info_request –.
CBlast4_get_search_results_request –.
CBlast4_get_search_strategy_reply –.
CRef< CBlast4_parameter > GetParamByName(const string name) const
Returns Blast4_parameter with specified name.
CRef< CBlast4_parameter > Add(const string name, const int &value)
Append Blast4_parameter.
size_t GetNumQueries() const
Retrieve the number of queries in this object.
CBlast4_queue_search_request –.
Class used to return ancillary data from a blast search, i.e.
Defines BLAST error codes (user errors included)
Class to build CBlastOptionsHandle from blast4 ASN objects.
Handle to the options to the BLAST algorithm.
@ eRemote
To be used when running BLAST remotely.
virtual void GetRemoteProgramAndService_Blast3(string &p, string &s) const
Get the program and service name for remote blast.
This stream exchanges data with a named service, in a constraint that the service is implemented as o...
Class to return parts of the CBlast4_request, or data associated with a CBlast4_request,...
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
NCBI C++ Object Manager dependant implementation of IQueryFactory.
CObjectIStreamAsnBinary –.
const CSeq_entry & GetQuery() const
Retrieve the query sequence.
Exception class for the CRemoteBlast class.
Error or Warning Message from search.
Search Results for All Queries.
structure for seqloc info
Root class for all serialization exceptions.
Template class for iteration on objects of class C (non-medifiable version)
Collection of masked regions for a single query sequence.
Class for the messages for an individual query sequence.
typedef for the messages for an entire BLAST search, which could be comprised of multiple query seque...
iterator_bool insert(const value_type &val)
static const char si[8][64]
bool LoadFromArchive()
Loads next chunk of archive from file.
CRef< CBlastOptionsHandle > GetSearchOptions()
Get the search options used for this search.
string GetTitle(void)
Get the title assigned for this search.
void x_SearchErrors(CRef< objects::CBlast4_reply > reply)
Iterate over error list, splitting into errors and warnings.
string GetDatabaseName() const
Accessor for the database name.
void x_CheckResultsDC(void)
Try to get and process results using disk cache.
int GetFirstDbSeq()
Get the OID range start point.
CRef< objects::CPssmWithParameters > GetPSSM(void)
Get the PSSM produced by the search.
objects::CBlast4_get_search_results_reply TGSRR
An alias for the most commonly used part of the Blast4 search results.
ENeedConfig m_NeedConfig
Bitfield to track whether all necessary configuration is done.
static CRef< CBlast4_mask > s_CreateBlastMask(const CPacked_seqint &packed_int, EBlastProgramType program)
Creates a Blast4-mask which is supposed to contain all masked locations for a given query sequence an...
string x_GetStringFromSearchInfoReply(CRef< CBlast4_reply > reply, const string &name, const string &value)
CRef< objects::CBlast4_reply > x_GetSearchResults(void)
Try to get the search results.
list< CRef< objects::CBioseq > > m_SubjectSequences
Subject Sequences.
CRef< objects::CBlast4_queries > m_Queries
Queries associated with this search.
objects::EBlast4_frame_type FrameNumber2NetworkFrame(int frame, EBlastProgramType program)
Converts the return value of CSeqLocInfo::GetFrame into the Blast4-frame-type field.
list< CRef< objects::CBlast4_ka_block > > TKarlinAltschulBlocks
Convenience typedef for a list of CRef<CBlast4_ka_block>
CRef< objects::CBlast4_reply > x_GetSearchResultsHTTP(void)
list< TGi > m_GiList
GI list.
bool HaveFirstDbSeq()
Check whether an OID range start point is specified.
string m_RID
Request ID of submitted or pre-existing search.
int GetDbFilteringAlgorithmId()
Get the database filtering algorithm ID.
string GetErrors(void)
This returns a string containing any errors that were produced by the search.
void SetDbFilteringAlgorithmKey(string algo_key, ESubjectMaskingType mask_type=eSoftSubjMasking)
Sets the filtering algorithm key to be applied to the BLAST database (not supported by server yet)
void x_CheckResults(void)
Try to get and process results.
TSeqLocInfoVector m_QueryMaskingLocations
Masking locations for queries.
TSeqAlignVector GetSeqAlignSets()
Get the seqalign vector from the results.
list< TGi > m_NegativeGiList
Negative GI list.
CFormatGuess::EFormat m_ObjectType
Type of object CBlast4_archive as determined by CFormatGuess.
bool x_IsUnknownRID(void)
Determine if this is an unknown RID.
bool HaveNegativeTaxidList()
Check whether a negative tax id list is specified.
int GetFilteringAlgorithm() const
Accessor for the filtering algorithm ID.
const TGiList GetNegativeGiListLimitation() const
bool m_use_disk_cache
Use disk cache for retrieving results default: false.
ENeedConfig
This class attempts to verify whether all necessary configuration is complete before attempting to su...
CRef< objects::CBlast4_archive > m_Archive
Archive of BLAST search and results.
void x_InitQueries(CRef< IQueryFactory > queries)
Initialize queries based on a query factory.
static CRef< CBlast4_request_body > s_BuildSearchInfoRequest(const string &rid, const string &name, const string &value)
ESearchStatus CheckStatus()
Returns the status of a previously submitted search/RID.
void SetVerbose(EDebugMode verb=eDebug)
Adjust the debugging level.
void x_GetRequestInfoFromRID()
Fetch the requested info from splitd.
list< TGi > GetNegativeGiList()
Get the negative GI list.
string GetFilteringAlgorithmKey() const
Accessor for the filtering algorithm key.
CRef< objects::CBlast4_reply > x_GetSearchStatsOnly(void)
const string & GetRID(void)
Gets the request id (RID) associated with the search.
CRef< blast::CBlastOptionsHandle > m_CBOH
Options for new search.
void SetRID(const string &rid)
Sets the RID for these results.
ESearchStatus
Represents the status of previously submitted search/RID.
vector< CConstRef< objects::CSeq_id > > TQueryIdVector
List of query ids.
void SetDatabase(const string &x)
Set the name of the database to search against.
CRef< objects::CBlast4_parameters > m_FormatOpts
Options relevant to the format application.
void x_ExtractQueryIds(CSearchResultSet::TQueryIdVector &query_ids)
Extract the query IDs from the CBlast4_queries for a given search.
static objects::CBlast4_get_search_results_reply::TMasks ConvertToRemoteMasks(const TSeqLocInfoVector &masking_locations, EBlastProgramType program, vector< string > *warnings=NULL)
Convert a TSeqLocInfoVector to a list< CRef<CBlast4_mask> > objects.
TGSRR::TMasks x_GetMasks(void)
Get the query masks from the results.
vector< string > m_Warn
List of warnings encountered.
bool HaveGiList()
Check whether a GI list is specified.
CBlastOptions & SetOptions()
Returns a reference to the internal options class which this object is a handle for.
EDebugMode
Debugging support can be turned on with eDebug or off with eSilent.
void SetSubjectSequences(CRef< IQueryFactory > subj)
Set a list of subject sequences to search against.
list< CRef< objects::CSeq_loc > > TSeqLocs
Type definition for CSeq_loc set used as queries in the BLAST remote search class.
CRef< objects::CBlast4_request_body > x_GetBlast4SearchRequestBody()
Retrieve the request body for a search submission.
static const string kNoRIDSpecified("Cannot fetch query info: No RID was specified.")
void SetGIList(const list< TGi > &gi_list)
This restricts the subject database to this list of GIs (this is not supported yet on the server end)...
CRef< objects::CBlast4_queries > GetQueries()
Get the queries used for this search.
list< TTaxId > GetTaxidList()
Get the Tax list.
void SetQueryMasks(const TSeqLocInfoVector &masking_locations)
Set the masking locations for queries.
int m_DbFilteringAlgorithmId
filtering algorithm to use in the database
EDebugMode m_Verbose
Verbosity mode: whether to produce debugging info on stdout.
EImmediacy
Indicates whether to use async mode.
ESubjectMaskingType GetSubjectMaskingType() const
set< TTaxId > m_NegativeTaxidList
vector< string > m_Errs
List of errors encountered.
void x_SetSubjectSequences(const list< CRef< objects::CBioseq > > &subj)
Set a list of subject sequences to search against (only m_SubjectSequences)
bool HaveEntrezQuery()
Check whether an Entrez query is specified.
list< TTaxId > GetNegativeTaxidList()
Get the negative tax id list.
void x_PollUntilDone(EImmediacy poll_immed, int seconds)
Poll until results are found, error occurs, or timeout expires.
~CRemoteBlast()
Destruct the search object.
void x_Init(CNcbiIstream &f)
Uses the file to populate results.
void x_ExtractUserSpecifiedMasks(CRef< IQueryFactory > query_factory, TSeqLocInfoVector &masks)
Extract the user specified masking locations from the query factory.
vector< TGi > TGiList
Define a list of gis.
void FlattenBioseqSet(const CBioseq_set &bss, list< CRef< CBioseq > > &seqs)
void SetQueries(CRef< objects::CBioseq_set > bioseqs)
Set the query as a Bioseq_set.
void SetNegativeGIList(const list< TGi > &gi_list)
This excludes the provided GIs from the subject database (this is not supported yet on the server end...
unique_ptr< CObjectIStream > m_ObjectStream
Use to ready CBlast4_archive.
CRef< objects::CBlast4_request > ExtractBlast4Request(CNcbiIstream &in)
Extract a Blast4-request (a.k.a.
list< CRef< objects::CBlast4_error > > TErrorList
Error value type used by Blast4 ASN.1 objects.
void x_SetMaskingLocationsForQueries(const TSeqLocInfoVector &masking_locations)
Set the masking locations AFTER the queries have been set in the m_QSR field.
string m_Service
Service value used when submitting this search.
bool HasDbFilteringAlgorithmKey()
Check whether a database filtering algorithm key is specified.
static void s_ExtractQueryIdsFromBioseqSet(const CBioseq_set &bss, CSearchResultSet::TQueryIdVector &query_ids)
Extract the query IDs from a CBioseq_set.
CRef< objects::CSeq_align_set > GetAlignments(void)
Get the seqalign set from the results.
bool IsLocalId(const objects::CSeq_id *seqid)
Returns true if the CSeq_id is a local id.
void SetDbFilteringAlgorithmId(int algo_id, ESubjectMaskingType mask_type=eSoftSubjMasking)
Sets the filtering algorithm ID to be applied to the BLAST database (not supported by server yet)
string ToString() const
Converts messages to a string, which is returned.
const CBlastOptions & GetOptions() const
Return the object which this object is a handle for.
virtual CRef< objects::CBioseq_set > GetBioseqSet()=0
Accessor for the CBioseq_set.
void x_InitDiskCache(void)
Initialize disk caching.
bool Submit(void)
This submits the search (if necessary) and returns immediately.
bool m_ReadFile
true if a CBlast4_archive should be read in.
int GetFinalDbSeq()
Get the OID range end point.
CBlast4_subject::TSeq_loc_list m_SubjectSeqLocs
This field is populated when dealing with a remote bl2seq search (e.g.
TSeqLocInfoVector GetMasks(void)
Get the queries' masked locations.
string m_FinalDbSeq
Final database sequence.
CRef< objects::CBlast4_database > GetDatabases()
Get the database used by the search.
list< TGi > GetGiList()
Get the GI list.
CRef< objects::CBlast4_parameters > m_AlgoOpts
Options relevant to the search algorithm.
const vector< string > & GetErrorVector()
This returns any errors encountered as a vector of strings.
string m_FirstDbSeq
First database sequence.
EState
Various states the search can be in.
void x_SubmitSearch(void)
Submit the search and process results (of submit action).
CRef< objects::CBlast4_database > m_Dbs
Databases.
CRef< objects::CBlast4_request > GetSearchStrategy()
Fetch the search strategy for this object without submitting the search.
CRef< IRemoteQueryData > MakeRemoteQueryData()
Creates and caches an IRemoteQueryData.
EBlastProgramType NetworkProgram2BlastProgramType(const string &program, const string &service)
Function to convert from program and service name into the CORE BLAST program type This is based on t...
string m_ClientId
Client ID submitting requests throw this interface.
TSeqLocInfoVector ExtractUserSpecifiedMasks()
Retrieve any user specified masking locations.
CRef< objects::CBlast4_parameters > m_ProgramOpts
Options relevant to the search application.
CRef< objects::CBlast4_reply > x_SendRequest(CRef< objects::CBlast4_request_body > body)
Send a Blast4 request and get a reply.
static void Pssm(const objects::CPssmWithParameters &pssm, bool require_scores=false)
Perform validation on the PSSM.
list< string > GetSearchStats(void)
Get the search statistics block as a list of strings.
const TGiList GetGiListLimitation() const
void x_GetRequestInfo()
Fetch the request info (wait for completion if necessary).
CRef< CSearchResultSet > GetResultSet()
Submit the search (if necessary) and return the results.
CRef< CBlastOptionsHandle > GetSearchOptions(const objects::CBlast4_parameters *aopts, const objects::CBlast4_parameters *popts, const objects::CBlast4_parameters *fopts, string *task_name=NULL)
Build and return options as a CBlastOptionsHandle.
void SetLengthAdjustment(int len_adj)
Set the length adjustment for boundary conditions.
CRef< objects::CBlast4_queue_search_request > m_QSR
Request object for new search.
set< TTaxId > m_TaxidList
int x_DefaultTimeout(void)
The default timeout is 3.5 hours.
void x_QueryMaskingLocationsToNetwork()
Converts the provided query masking locations (if any) to the network representation following the BL...
string GetService()
Get the service used for this search.
bool CheckDone(void)
Check whether the search has completed.
TKarlinAltschulBlocks GetKABlocks(void)
Get the Karlin/Altschul parameter blocks produced by the search.
string m_DbFilteringAlgorithmKey
filtering algorithm key to use in the database
CRef< objects::CBlast4_reply > m_Reply
Results of BLAST search.
CBlast4_subject::TSeq_loc_list GetSubjectSeqLocs()
list< CRef< objects::CSeq_loc > > TSeqLocList
Typedef for a list of Seq-locs.
string GetCreatedBy()
Get the created-by string associated with this search.
const vector< string > & GetWarningVector()
This returns any warnings encountered as a vector of strings.
string GetWarnings(void)
This returns any warnings encountered.
bool HaveNegativeGiList()
Check whether a negative GI list is specified.
string m_disk_cache_error_msg
disk cache error message
static const string kNoArchiveFile("Cannot fetch query info: No archive file.")
bool IsErrMsgArchive(void)
bool m_Pending
Pending state: indicates that search still needs to be queued.
string m_Task
Task used when the search was submitted (recovered via CBlastOptionsBuilder)
virtual TSeqLocs GetSeqLocs()=0
Accessor for the TSeqLocs.
bool m_disk_cache_error_flag
disk cache error flag
string GetEntrezQuery()
Get the Entrez query.
void x_SetAlgoOpts(void)
Configure new search from options handle passed to constructor.
ESubjectMaskingType m_SubjectMaskingType
string m_Program
Program value used when submitting this search.
void x_CheckConfig(void)
Verify that search object contains mandatory fields.
vector< CRef< CBlastAncillaryData > > TAncillaryVector
typedef for a vector of CRef<CBlastAncillaryData>
list< CRef< objects::CBioseq > > GetSubjectSequences()
Returns subject sequences if "bl2seq" mode used.
void x_GetRequestInfoFromFile()
Fetch the requested info from an archive file.
TGSRR * x_GetGSRR(void)
Poll until done, return the CBlast4_get_search_results_reply.
string m_EntrezQuery
Entrez Query, if any.
bool x_HasRetrievedSubjects() const
string GetDbFilteringAlgorithmKey()
Get the database filtering algorithm key.
TBlast4Opts * GetBlast4AlgoOpts()
CRemoteBlast(const string &RID)
Use the specified RID to get results for an existing search.
string m_CreatedBy
Created-by attribution for this search.
bool HasDbFilteringAlgorithmId()
Check whether a database filtering algorithm ID is specified.
void x_SetDatabase(const string &x)
Sets a subset (only m_Dbs) of what the public SetDatabase sets.
int m_ErrIgn
Count of server glitches (communication errors) to ignore.
bool IsDbSearch()
Return values states whether GetDatabases or GetSubjectSequences call should be used.
string GetEntrezQueryLimitation() const
Accessor for the entrez query.
string GetProgram()
Get the program used for this search.
bool HaveFinalDbSeq()
Check whether an OID range end point is specified.
void x_SetOneParam(objects::CBlast4Field &field, const int *value)
Set an integer parameter (not used yet).
CRef< objects::CBlast4_phi_alignments > GetPhiAlignments(void)
Get the results of a PHI-Align request, if PHI pattern was set.
void SetEntrezQuery(const char *x)
Restrict search to sequences matching this Entrez query.
EState x_GetState(void)
Determine what state the search is in.
unsigned int x_GetPsiIterationsFromServer(void)
unsigned int GetPsiNumberOfIterations(void)
static bool s_SearchPending(CRef< objects::CBlast4_reply > reply)
Determine whether the search is still running.
CSeqLocInfo::ETranslationFrame NetworkFrame2FrameNumber(objects::EBlast4_frame_type frame, EBlastProgramType program)
Converts Blast4-frame-type into CSeqLocInfo::ETranslationFrame.
bool SubmitSync(void)
This submits the search (if necessary) and polls for results.
@ eStatus_Failed
Completed but failed, call GetErrors/GetErrorVector()
@ eStatus_Pending
Not completed yet.
@ eStatus_Unknown
Never submitted or purged from the system.
@ eStatus_Done
Completed successfully.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
@ eDiag_Trace
Trace message.
@ eDiag_Info
Informational message.
@ eDiag_Error
Error message.
@ eDiag_Warning
Warning message.
@ eDiag_Fatal
Fatal error – guarantees exit(or abort)
@ eDiag_Critical
Critical error message.
void Critical(CExceptionArgs_Base &args)
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.
const string & GetMsg(void) const
Get message string.
void Trace(CExceptionArgs_Base &args)
void Warning(CExceptionArgs_Base &args)
void Fatal(CExceptionArgs_Base &args)
void Info(CExceptionArgs_Base &args)
static fstream * CreateTmpFile(const string &filename=kEmptyStr, ETextBinary text_binary=eBinary, EAllowRead allow_read=eAllowRead)
Create temporary file and return pointer to corresponding stream.
#define MSerial_AsnBinary
#define MSerial_AsnText
I/O stream manipulators –.
@ eSerial_AsnBinary
ASN.1 binary.
static int BestRank(const CRef< CSeq_id > &id)
E_SIC Compare(const CSeq_id &sid2) const
Compare() - more general.
@ e_YES
SeqIds compared, but are different.
void SetPacked_int(TPacked_int &v)
CConstBeginInfo ConstBegin(const C &obj)
Get starting point of non-modifiable object hierarchy.
pair< TObjectPtr, TTypeInfo > ObjectInfo(C &obj)
static CObjectIStream * Open(ESerialDataFormat format, CNcbiIstream &inStream, bool deleteInStream)
Create serial object reader and attach it to an input stream.
bool Empty(void) const THROWS_NONE
Check if CConstRef is empty – not pointing to any object which means having a null value.
void Reset(void)
Reset reference object.
bool NotEmpty(void) const THROWS_NONE
Check if CRef is not empty – pointing to an object and has a non-null value.
bool Empty(void) const THROWS_NONE
Check if CRef is empty – not pointing to any object, which means having a null value.
int16_t Int2
2-byte (16-bit) signed integer
int64_t Int8
8-byte (64-bit) signed integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define USING_SCOPE(ns)
Use the specified namespace.
#define END_SCOPE(ns)
End the previously defined scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
#define BEGIN_SCOPE(ns)
Define a new scope.
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
static streamsize Readsome(CNcbiIstream &is, CT_CHAR_TYPE *buf, streamsize buf_size)
static int CompareNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive compare of a substring with another string.
static Int8 StringToInt8(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to Int8.
static SIZE_TYPE Find(const CTempString str, const CTempString pattern, ECase use_case=eCase, EDirection direction=eForwardSearch, SIZE_TYPE occurrence=0)
Find the pattern in the string.
static unsigned int StringToUInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to unsigned int.
static string & ReplaceInPlace(string &src, const string &search, const string &replace, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
@ fConvErr_NoThrow
Do not throw an exception on error.
double Restart(void)
Return time elapsed since first Start() or last Restart() call (in seconds).
double Elapsed(void) const
Return time elapsed since first Start() or last Restart() call (in seconds).
void Stop(void)
Suspend the timer.
void Start(void)
Start the timer.
@ eStart
Start timer immediately after creating.
C::value_type FindBestChoice(const C &container, F score_func)
Find the best choice (lowest score) for values in a container.
strategy
Block allocation strategies.
void SetIdent(const TIdent &value)
Assign a value to Ident data member.
bool IsSeq_loc_list(void) const
Check if variant Seq_loc_list is selected.
const TInfo & GetInfo(void) const
Get the Info member data.
bool CanGetRequest_id(void) const
Check if it is safe to call GetRequest_id method.
TQuery_mask & SetQuery_mask(void)
Select the variant.
bool CanGetInfo(void) const
Check if it is safe to call GetInfo method.
TGet_search_results & SetGet_search_results(void)
Select the variant.
TInteger_list & SetInteger_list(void)
Select the variant.
bool IsPssm(void) const
Check if variant Pssm is selected.
void SetBody(TBody &value)
Assign a value to Body data member.
TSequences & SetSequences(void)
Select the variant.
list< CRef< CSeq_loc > > TSeq_loc_list
TGet_request_info & SetGet_request_info(void)
Select the variant.
const TBioseq_set & GetBioseq_set(void) const
Get the variant data.
bool IsBioseq_set(void) const
Check if variant Bioseq_set is selected.
const TSeq_loc_list & GetSeq_loc_list(void) const
Get the variant data.
TGet_search_info & SetGet_search_info(void)
Select the variant.
EBlast4_frame_type
Access to EBlast4_frame_type's attributes (values, names) as defined in spec.
const TRequest_id & GetRequest_id(void) const
Get the Request_id member data.
const TPssm & GetPssm(void) const
Get the variant data.
TQueue_search & SetQueue_search(void)
Select the variant.
TString & SetString(void)
Select the variant.
EBlast4_residue_type
Access to EBlast4_residue_type's attributes (values, names) as defined in spec.
TBig_integer_list & SetBig_integer_list(void)
Select the variant.
void SetRequest_id(const TRequest_id &value)
Assign a value to Request_id data member.
TInteger & SetInteger(void)
Select the variant.
list< CRef< CBlast4_mask > > TMasks
TPssm & SetPssm(void)
Select the variant.
list< CRef< CSeq_loc > > TSeq_loc_list
virtual void Ask(const TRequest &request, TReply &reply)
TDatabase & SetDatabase(void)
Select the variant.
@ eBlast4_error_code_bad_request_id
The RID requested is unknown or it has expired.
@ eBlast4_error_code_not_implemented
Request type is not implemented in the blast4 server.
@ eBlast4_error_code_search_pending
The search is pending.
@ eBlast4_error_code_conversion_warning
A conversion issue was found when converting to/from blast3 from/to blast4 protocol in the blast4 ser...
@ eBlast4_error_code_not_allowed
Request type is not allowed in the blast4 server.
@ eBlast4_error_code_bad_request
Malformed/invalid requests (e.g.: parsing errors or invalid data in request)
@ eBlast4_error_code_internal_error
Indicates internal errors in the blast4 server.
@ eBlast4_frame_type_minus2
@ eBlast4_frame_type_plus2
@ eBlast4_frame_type_plus3
@ eBlast4_frame_type_plus1
@ eBlast4_frame_type_minus3
@ eBlast4_frame_type_notset
@ eBlast4_frame_type_minus1
@ eBlast4_residue_type_nucleotide
@ eBlast4_residue_type_unknown
@ eBlast4_residue_type_protein
Tdata & Set(void)
Assign a value to data member.
list< CRef< CSeq_align > > Tdata
const Tdata & Get(void) const
Get the member data.
list< CRef< CSeq_interval > > Tdata
const Tdata & Get(void) const
Get the member data.
bool IsPacked_int(void) const
Check if variant Packed_int is selected.
const TPacked_int & GetPacked_int(void) const
Get the variant data.
const TSeq & GetSeq(void) const
Get the variant data.
bool CanGetSeq_set(void) const
Check if it is safe to call GetSeq_set method.
const TSet & GetSet(void) const
Get the variant data.
bool IsSeq(void) const
Check if variant Seq is selected.
bool IsSet(void) const
Check if variant Set is selected.
const TSeq_set & GetSeq_set(void) const
Get the Seq_set member data.
list< CRef< CSeq_entry > > TSeq_set
const TId & GetId(void) const
Get the Id member data.
unsigned int
A callback function used to compare two keys in a database.
Names used in blast4 network communications.
@ eBlastOpt_Web_StepNumber
@ eBlastOpt_DbFilteringAlgorithmKey
@ eBlastOpt_NegativeGiList
@ eBlastOpt_DbFilteringAlgorithmId
@ eBlastOpt_RequiredStart
@ eBlastOpt_SubjectMaskingType
string Blast4SearchInfo_BuildReplyName(const string &name, const string &value)
This function builds the reply name token in the get-search-info reply objects, provided a pair of st...
const char * kBlast4SearchInfoReqValue_Title
Used to retrieve the BLAST search title.
const char * kBlast4SearchInfoReqValue_Subjects
Used to retrieve the BLAST search subjects.
const char * kBlast4SearchInfoReqValue_PsiIterationNum
Used to retrieve the PSI-BLAST iteration number.
const char * kBlast4SearchInfoReqName_Search
Used to retrieve information about the BLAST search.
const struct ncbi::grid::netcache::search::fields::KEY key
void SleepSec(unsigned long sec, EInterruptOnSignal onsignal=eRestartOnSignal)
Sleep.
Defines: CTimeFormat - storage class for time format.
std::istream & in(std::istream &in_, double &x_)
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
double f(double x_, const double &y_)
NOTE: This file contains work in progress and the APIs are likely to change, please do not rely on th...
Declarations of auxiliary functions/classes for PSI-BLAST.
Declares the CRemoteBlast class.
Declares the CImportStrategy and CExportStrategy.
vector< TMaskedQueryRegions > TSeqLocInfoVector
Collection of masked regions for all queries in a BLAST search.
static string kStart("Start")