NCBI C++ ToolKit
feature_search_tool.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: feature_search_tool.cpp 47029 2022-05-16 18:09:35Z asztalos $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Andrey Yazhuk
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
34 #include "feature_search_tool.hpp"
35 
37 
41 
43 #include <gui/objutils/label.hpp>
44 #include <gui/objutils/utils.hpp>
45 #include <gui/objutils/snp_gui.hpp>
46 
49 
50 #include <objmgr/util/sequence.hpp>
51 #include <objmgr/util/feature.hpp>
52 #include <objmgr/seq_vector.hpp>
53 #include <objmgr/feat_ci.hpp>
54 
55 #include <wx/sizer.h>
56 #include <wx/stattext.h>
57 #include <wx/choice.h>
58 #include <wx/srchctrl.h>
59 
60 #define ID_COMBOBOX 10003
61 #define ID_TEXT 11414
62 #define ID_BUTTON1 10005
63 #define ID_HYPERLINKCTRL 10999
64 
67 
68 static const char* kFetPattern = "FetPattern";
69 static const char* kFetTypes = "FetTypes";
70 
71 ///////////////////////////////////////////////////////////////////////////////
72 /// CFeatureSearchTool
74 {
75 }
76 
77 
79 {
80  static string name("Feature Search");
81  return name;
82 }
83 
84 
86 {
87  return new CFeatureSearchTool();
88 }
89 
90 
92 {
93  return "";
94 }
95 
96 
98 {
100  return form;
101 }
102 
103 
105 {
106  ISeqLocSearchContext* sl_ctx =
107  dynamic_cast<ISeqLocSearchContext*>(context);
108  return sl_ctx != NULL;
109 }
110 
111 
113 {
115  CFeatureSearchQuery* f_query = dynamic_cast<CFeatureSearchQuery*>(&query);
116  if(f_query) {
117  job.Reset(new CFeatureSearchJob(*f_query));
118  }
119  return job;
120 }
121 
122 
124 {
125  return "search_tool::feature_search_tool";
126 }
127 
128 
130 {
131  return "Search Tool - Feature Search";
132 }
133 
134 
135 ///////////////////////////////////////////////////////////////////////////////
136 /// CFeatureSearchQuery
137 
139  const string& pattern,
140  bool case_sensitive,
141  TPatternType pt_type,
142  const TFeatTypeItemSet& feat_types)
143 : CSearchQueryBase(locs),
144  m_Pattern(pattern),
145  m_PatternType(pt_type),
146  m_CaseSensitive(case_sensitive),
147  m_FeatTypesSet(feat_types)
148 {
149 }
150 
152 {
153  string s(m_Pattern);
154  s.append(" ");
155  // TODO: write a string dumper for Feature Types Set
156 
157  return s;
158 }
159 
160 
161 ///////////////////////////////////////////////////////////////////////////////
162 /// CFeatureSearchForm
163 
164 static const int eCmdSelectFeatureTypes = 10000;
165 /*
166 BEGIN_EVENT_MAP(CFeatureSearchForm, CSearchFormBase)
167  ON_COMMAND(eCmdSelectFeatureTypes, &CFeatureSearchForm::OnSelectFeatureType)
168 END_EVENT_MAP()
169 */
170 
171 
173 : m_Tool(&tool)
174 {
175 }
176 
177 
179 {
180 }
181 
182 
184 {
185  x_CreateWidgets();
186 }
187 
188 
190 {
192 }
193 
195 {
197 
198  string strText = "";
199 
201  string lbl = ft_it->GetDescription();
202  if (!lbl.empty()) {
203  strText += strText.empty()?"":", ";
204  strText += lbl;
205  }
206  }
207 
208  if (strText.empty()) {
209  strText = "Click To Select ...";
210  }
211 
212  list<string> strList;
213  NStr::Wrap(strText, 25, strList);
214 
215  m_HyperLink->SetLabel(ToWxString(*strList.begin() + "..."));
216  m_HyperLink->SetToolTip(ToWxString(NStr::Join(strList, "\n")));
217  m_HyperLink->GetParent()->Layout();
218  m_HyperLink->Update();
219 }
220 
222 {
224 
226  if (!m_FeatureTypes.empty()){
228  const CFeatList* feat_list = CSeqFeatData::GetFeatList();
229  ITERATE(CFeatList, ft_it, *feat_list) {
230  const CFeatListItem& item = *ft_it;
231  string desc = item.GetDescription();
232 
233  if (find(m_FeatureTypes.begin(), m_FeatureTypes.end(), desc)!=
234  m_FeatureTypes.end()){
235  m_FeatTypesSet.insert(item);
236  }
237  }
238  }
239 }
240 
241 
243 {
244  if (m_TypeCombo) {
245  view.Set(kFetPattern, ToStdString( m_TypeCombo->GetStringSelection() ));
246  }
247 
248  list<string> strList;
249  ITERATE(CFeatList, ft_it, m_FeatTypesSet) {
250  strList.push_back(ft_it->GetDescription());
251  }
252  view.Set(kFetTypes, strList);
253 }
254 
255 
256 wxSizer* CFeatureSearchForm::GetWidget(wxWindow * parent)
257 {
258  if (!m_Sizer) {
259  wxFlexGridSizer * sz = new wxFlexGridSizer(0, 4, 0, 0);
260  sz->AddGrowableCol(3);
261  m_Sizer = sz;
262 
263  wxStaticText* stat1 = new wxStaticText(parent, wxID_STATIC,
264  wxT("Search Context:"));
265  m_Sizer->Add(stat1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
266 
267  m_DbCombo = new wxChoice(parent, ID_COMBOBOX,
268  wxDefaultPosition, wxDefaultSize,
269  0, (const wxString*)NULL);
270 
271  m_Sizer->Add(m_DbCombo,1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
272 
273  // search type
274  wxStaticText* stat2 = new wxStaticText( parent, wxID_STATIC,
275  wxT("Search Type:"));
276  m_Sizer->Add(stat2, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
277 
278  m_TypeCombo = new wxChoice(parent, ID_COMBOBOX,
279  wxDefaultPosition, wxDefaultSize,
280  0, (const wxString*)NULL);
281  m_TypeCombo->Append(wxT("Exact Match"));
282  m_TypeCombo->Append(wxT("Regular Expression"));
283  m_TypeCombo->Append(wxT("Wildcard"));
284 
285  if (!m_SearchPattern.empty()) {
286  m_TypeCombo->SetStringSelection(ToWxString(m_SearchPattern));
287  } else {
288  m_TypeCombo->Select(0);
289  }
290 
291  m_Sizer->Add(m_TypeCombo,1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
292 
293  m_Sizer->Add(new wxStaticText( parent, wxID_STATIC,
294  wxT("Feature Types:"),
295  wxDefaultPosition, wxDefaultSize, 0 ),
296  0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
297 
298  // editbox with button
299  //wxBoxSizer* featTypeSizer = new wxBoxSizer(wxHORIZONTAL);
300  //m_Sizer->Add(featTypeSizer, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 0);
301 
302 
303  //wxStaticText* itemStaticText4 = new wxStaticText( parent, wxID_STATIC, wxT("Static text"), wxDefaultPosition, wxDefaultSize, wxDOUBLE_BORDER );
304  //featTypeSizer->Add(itemStaticText4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
305 
306  m_HyperLink = new wxHyperlinkCtrl( parent, ID_HYPERLINKCTRL,
307  wxT("Click To Select ..."), wxT(""),
308  wxDefaultPosition, wxDefaultSize,
309  wxHL_DEFAULT_STYLE);
310  m_Sizer->Add(m_HyperLink, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
311 
312 
313  wxStaticText* stat3 = new wxStaticText( parent, wxID_STATIC,
314  wxT("Search Expression:"));
315  m_Sizer->Add(stat3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
316 
317  m_Text = new CSearchControl(parent, ID_TEXT, wxT(""),
318  wxDefaultPosition, wxDefaultSize,
319  wxTE_PROCESS_ENTER );
320  m_Sizer->Add(m_Text,1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
321  }
322  return m_Sizer;
323 }
324 
325 
327 {
328 }
329 
330 
332 {
333  return m_Tool.GetPointer();
334 }
335 
336 
338 {
339  m_SeqLocContexts.clear();
340  for( size_t i = 0; i < m_Contexts.size(); i++ ) {
341  if (m_DbCombo->GetSelection() != 0 &&
342  m_DbCombo->GetSelection() != int(i + 1) ) {
343  continue;
344  }
345  ISeqLocSearchContext* seq_ctx =
346  dynamic_cast<ISeqLocSearchContext*>(m_Contexts[i]);
347  m_SeqLocContexts.push_back(seq_ctx);
348  }
349 
350  _ASSERT(m_SeqLocContexts.size());
351 
352  /// accumulate locations from all selected contexts
353  TScopedLocs sc_locs;
354 
355  for( size_t i = 0; i < m_SeqLocContexts.size(); i++ ) {
357  _ASSERT(sl_ctx);
358 
359  // tereshko: skip context if it can't participate in search anymore (selection loss, etc)
360  if (sl_ctx->GetSearchLoc().IsNull()) continue;
361 
362  CRef<CSeq_loc> loc(new CSeq_loc());
363  if (m_bRange) {
364  loc = sl_ctx->GetSearchLoc();
365  }
366  else {
367  CRef<CSeq_id> id(new CSeq_id());
368  id->Assign(*(sl_ctx->GetSearchLoc()->GetId()));
369  loc->SetWhole(*id);
370  }
371 
373  sl.m_Loc = loc;
374  sl.m_Scope = sl_ctx->GetSearchScope();
375  sl.m_ContextName = sl_ctx->GetDMContextName();
376  sl.m_AnnotNames = sl_ctx->GetAnnotNames();
377  sc_locs.push_back(sl);
378  }
379 
380  switch (m_TypeCombo->GetSelection()){
382  case 1: m_PatternType = CSearchToolBase::eRegexp; break;
383  case 2: m_PatternType = CSearchToolBase::eWildcard; break;
384  }
385 
386  string pattern = ToStdString(m_Text->GetValue());
388 
390  ref = new CFeatureSearchQuery(sc_locs, pattern,
391  false, // case sensitive
393  return ref;
394 }
395 
396 
397 ///////////////////////////////////////////////////////////////////////////////
398 /// CFeatureSearchJob
399 
401 : m_Query(&query),
402  m_PatternType(CSearchToolBase::eExactMatch)
403 {
404  string s_locs, id;
405  static string sep(", ");
406 
407  NON_CONST_ITERATE(TScopedLocs, it, m_Query->GetScopedLocs()) {
408  CLabel::GetLabel(*it->m_Loc, &id, CLabel::eDefault, it->m_Scope.GetPointer());
409  s_locs += id;
410  s_locs += sep;
411  }
412 
413  if( ! s_locs.empty()) {
414  s_locs.resize(s_locs.size() - sep.size());
415  }
416  string s_pat = m_Query->GetPattern();
417  m_Descr = "Search Features \"" + s_pat + "\" on " + s_locs;
418 }
419 
420 
422 {
423  m_Error.Reset();
424 
425  if( m_Query->GetScopedLocs().empty()) {
426  m_Error = new CAppJobError("Invalid input parameters - no search context specified.");
427  }
428  if(m_Query->GetPattern().empty()) {
429  m_Error = new CAppJobError("Search pattern is empty.");
430  }
431  return m_Error ? false : true;
432 }
433 
434 
436 {
437  m_SearchStr = m_Query->GetPattern();
438  TScopedLocs& scoped_locs = m_Query->GetScopedLocs();
439  m_PatternType = m_Query->GetPatternType();
440  m_CaseSensitive = m_Query->GetCaseSensitive();
441  m_Pattern = NULL;
442 
443  switch(m_PatternType) {
445  m_SearchStr += '*';
446  m_SearchStr.insert(m_SearchStr.begin(), '*');
447  break;
448 
449  case CSearchToolBase::eRegexp: {{
453  break;
454  }}
455  default:
456  break;
457  }
458 
459  const TFeatTypeItemSet& feat_types = m_Query->GetFeatTypes();
460 
461  x_SearchFeatures(scoped_locs, feat_types);
462 
463  if (m_Pattern) {
464  delete m_Pattern;
465  m_Pattern = NULL;
466  }
467 
468  return eCompleted;
469 }
470 
471 
473 {
474  obj_list.AddColumn(CObjectList::eString, "Location");
475  obj_list.AddColumn(CObjectList::eString, "Strand");
476  obj_list.AddColumn(CObjectList::eString, "Accession");
477  obj_list.AddColumn(CObjectList::eString, "Context");
478 }
479 
481 {
482  //_ASSERT(loc.GetId());
483 
484  string out;
485 
486  if (!loc.GetId()) {
487  loc.GetLabel(&out);
488  }
489  else {
490  if (loc.Which() == CSeq_loc::e_Whole || loc.GetTotalRange().Empty()) {
491  out += "0-0";
492  } else {
494  out += "-";
495  out += NStr::UIntToString(loc.GetTotalRange().GetTo() + 1);
496  if (loc.GetStrand() == eNa_strand_minus)
497  out += " -";
498  }
499  }
500 
501  return out;
502 }
503 
504 static const string kProgressStr("Searching features. ");
505 
507  const TFeatTypeItemSet& feat_types)
508 {
509  {
510  CMutexGuard Guard(m_Mutex);
512  }
513 
514  // Create Annot Selector filtering the right feature types
515  SAnnotSelector sel = CSeqUtils::GetAnnotSelector(); /// all feature types
516 
517  if( ! feat_types.empty()) {
518  // set filter on the subtypes
519  ITERATE(TFeatTypeItemSet, it_f, feat_types) {
520  const TFeatTypeItem& item = *it_f;
521  if(item.GetSubtype() == CSeqFeatData::eSubtype_any) {
522  sel.IncludeFeatType((CSeqFeatData::E_Choice) item.GetType());
523  } else {
524  sel.IncludeFeatSubtype((CSeqFeatData::ESubtype) it_f->GetSubtype());
525  }
526  }
527  }
528 
529  string label;
530  string loc_label;
531 
532  // for every Seq_loc
533  NON_CONST_ITERATE(TScopedLocs, it_sl, scoped_locs) {
534  // extract context data
535  TScopedLoc& sc_loc = *it_sl;
536  CSeq_loc& seq_loc = *sc_loc.m_Loc;
537  CScope& scope = *sc_loc.m_Scope;
538  const set<string>& annot_names = sc_loc.m_AnnotNames;
539 
540  loc_label.clear();
541  CLabel::GetLabel(seq_loc, &loc_label, CLabel::eDefault, &scope);
542 
543  {
544  CMutexGuard Guard(m_Mutex);
546  m_ProgressStr.append(loc_label);
547  }
548 
549  if (IsCanceled()) {
550  LOG_POST(Info << m_Descr << " canceled.");
551  return;
552  }
553 
554  // create Feature Iterator
555  CFeat_CI feat_iter(scope, seq_loc, sel);
556  int cnt = 0;
557  int cnt_found = 0;
558 
559  if (feat_iter.GetSize() == 0 && x_IsSNP()) {
560  CSeq_feat_Handle snph = x_SearchForSNP(seq_loc, scope, annot_names);
561  if (snph) {
562  cnt++;
563  cnt_found++;
564 
565  const CSeq_feat& feat = snph.GetOriginalSeq_feat().GetObject();
566  x_AddFeatToResults(feat, scope, loc_label, cnt, cnt_found, sc_loc.m_ContextName);
567  }
568  }
569  else {
570  for (; feat_iter && !IsCanceled(); ++feat_iter, ++cnt) {
571  if (cnt > 0 && cnt % 100) {
572  CMutexGuard Guard(m_Mutex);
574  m_ProgressStr.append(loc_label);
575  m_ProgressStr.append(" [");
576  m_ProgressStr.append(NStr::IntToString(cnt_found));
577  m_ProgressStr.append("/");
579  m_ProgressStr.append("]");
580  }
581 
582  bool found = false;
583  switch (feat_iter->GetData().Which()) {
584  case CSeqFeatData::e_Gene: {
585  // Gene is a special case
586  const CGene_ref& gene_ref = feat_iter->GetData().GetGene();
587  found = x_Match(gene_ref);
588  break;
589  }
590  default: {
591  // for all other feature types, the label contains all available
592  // (searchable) string information
593  label.erase();
595  found = x_Match(label);
596  break;
597  }
598  }
599  // make sure we search the comment field
600  if (!found && feat_iter->IsSetComment()) {
601  found = x_Match(feat_iter->GetComment());
602  }
603 
604  // also search the exception text, as this is free-form
605  if (!found && feat_iter->IsSetExcept_text()) {
606  found = x_Match(feat_iter->GetExcept_text());
607  }
608 
609  if (found) {
610  ++cnt_found;
611  const CSeq_feat& feat = (CSeqFeatData::e_Gene == feat_iter->GetData().Which() ? feat_iter->GetMappedFeature() : feat_iter->GetOriginalFeature());
612  x_AddFeatToResults(feat, scope, loc_label, cnt, cnt_found, sc_loc.m_ContextName);
613  }
614  }
615  }
616  }
617 }
618 
620  const string& loc_label, const int cnt, const int cnt_found, const string& ctx_name)
621 {
622  {
623  CMutexGuard Guard(m_Mutex);
625  m_ProgressStr.append(loc_label);
626  m_ProgressStr.append(" [");
627  m_ProgressStr.append(NStr::IntToString(cnt_found));
628  m_ProgressStr.append("/");
630  m_ProgressStr.append("]");
631  }
632 
633  CSeq_feat& non_const_feat = const_cast<CSeq_feat&>(feat);
634 
635  string locplustrand = SeqLocToString(feat.GetLocation());
636  string strand = "+";
637  string location = locplustrand;
638 
639  if (locplustrand.find_last_of('-') == (locplustrand.length() - 1)) {
640  location.resize(location.size() - 2);
641  strand = "-";
642  }
643 
644  x_AddToResults(non_const_feat, scope, location, strand, loc_label, ctx_name);
645 }
646 
648  const string& loc_name,
649  const string& strand,
650  const string& acc_name,
651  const string& ctx_name)
652 {
653  static const int kUpdateIncrement = 200;
654 
655  // adding the result to the Accumulator
656  int row = m_AccList.AddRow(&obj, &scope);
657  m_AccList.SetString(0, row, loc_name);
658  m_AccList.SetString(1, row, strand);
659  m_AccList.SetString(2, row, acc_name);
660  m_AccList.SetString(3, row, ctx_name);
661 
662  int count = m_AccList.GetNumRows();
663  if(count >= kUpdateIncrement) {
664  // time to update the Result
665  CMutexGuard Guard(m_Mutex);
666 
667  // transfer results from Accumulator to m_TempResult
670 
671  // update progress string
672  m_ProgressStr = NStr::IntToString(count, NStr::fWithCommas) + " feature";
673  if (count != 1) {
674  m_ProgressStr += "s";
675  }
676  m_ProgressStr += " found.";
677  }
678 }
679 
680 
681 bool CFeatureSearchJob::x_Match(const string& text) const
682 {
683  switch(m_PatternType) {
685  //return text.find(m_SearchStr) != string::npos;
687  return NPOS != NStr::Find(text, m_SearchStr, use_case);
688  }
691  return NStr::MatchesMask(text, m_SearchStr, use_case);
692  }
694  return ! m_Pattern->GetMatch(text).empty();
695  }
696  default:
697  _ASSERT(false);
698  return false;
699  }
700 }
701 
703 {
704  CRegexp re_snp("^([rs]s)([0-9]{3,})(?::.+)?$");
705  return re_snp.IsMatch(m_SearchStr);
706 }
707 
709 {
711 
712  NSNPWebServices::Search(m_SearchStr, "", SNPSearchResultList);
713  for (const auto& res_it : SNPSearchResultList) {
714  for (const auto& var_it : res_it.second) {
715 
716  const CVariation::TPlacements& placements = var_it->GetPlacements();
717  _ASSERT(placements.size() == 1);
718  if (placements.size() != 1)
719  continue;
720 
721  const auto& pl = placements.front();
722  if (pl->IsSetLoc() && sequence::IsSameBioseq(*seq_loc.GetId(), *pl->GetLoc().GetId(), &scope)) {
723 
725  sel.SetFeatSubtype(CSeqFeatData::eSubtype_variation);
726  for (const auto& it : annot_names) {
727  sel.AddNamedAnnots(it);
728  sel.IncludeNamedAnnotAccession(it);
729  }
730 
731  CFeat_CI feat_it(scope, pl->GetLoc(), sel);
732  if (feat_it) {
733  //LOG_POST(Info << MSerial_AsnText << feat_it->GetOriginalFeature());
734  return *feat_it;
735  }
736  }
737  }
738  }
739  return CSeq_feat_Handle();
740 }
741 
742 
743 /// genes have a lot of embedded labels. many of these are optional, so the
744 /// checking is a bit tedious This could be done with CStdTypeConstIterator<>,
745 /// but this would pick up an inadvertent db-tag that we don't really want
746 /// to search
747 bool CFeatureSearchJob::x_Match(const objects::CGene_ref& gene_ref) const
748 {
749  if (gene_ref.IsSetLocus() && x_Match(gene_ref.GetLocus())) {
750  return true;
751  }
752  if (gene_ref.IsSetAllele() && x_Match(gene_ref.GetAllele())) {
753  return true;
754  }
755  if (gene_ref.IsSetDesc() && x_Match(gene_ref.GetDesc())) {
756  return true;
757  }
758  if (gene_ref.IsSetMaploc() && x_Match(gene_ref.GetMaploc())) {
759  return true;
760  }
761  if (gene_ref.IsSetLocus_tag() && x_Match(gene_ref.GetLocus_tag())) {
762  return true;
763  }
764  if (gene_ref.IsSetSyn()) {
765  ITERATE (CGene_ref::TSyn, iter, gene_ref.GetSyn()) {
766  if (x_Match(*iter))
767  return true;
768  }
769  }
770  return false;
771 }
772 
773 
User-defined methods of the data storage class.
size_t GetSize(void) const
CAppJobError Default implementation for IAppJobError - encapsulates a text error message.
CObjectList * GetObjectList()
CFeatListItem - basic configuration data for one "feature" type.
string GetDescription() const
CConfigurableItems - a static list of items that can be configured.
CFeat_CI –.
Definition: feat_ci.hpp:64
CFeatureSearchJob.
CSeqLocToolQuery::TFeatTypeItemSet TFeatTypeItemSet
virtual void x_DoSearch()
performs searching, assuming that params are correct; Implement in derived classes
CFeatureSearchJob(CSeqLocToolQuery &query)
virtual bool x_ValidateParams()
returns true if Job params are correct, implement in derived classes
CSeqLocToolQuery::SScopedLoc TScopedLoc
bool x_Match(const string &text)
CSeqLocToolQuery::TFeatTypeItem TFeatTypeItem
CRef< CSeqLocToolQuery > m_Query
CSeqLocToolQuery::TScopedLocs TScopedLocs
void x_SearchFeatures(TScopedLocs &scoped_locs, const TFeatTypeItemSet &feat_types)
void x_AddToResults(CObject &obj, objects::CScope &scope, const string &loc_name, const string &ctx_name)
CFeatureSearchTool.
CFeatureSearchTool.
CObjectList Data structure representing a list of CObjects with associated Scopes and other optional ...
Definition: object_list.hpp:63
int AddRow(CObject *obj, objects::CScope *scope)
void SetString(int col, int row, const string &val)
void Append(const CObjectList &list)
adds rows from the given list, the lists must have identical sets of columns
void ClearRows()
int AddColumn(EColumnType type, const string &name, int col=-1)
int GetNumRows() const
CObject –.
Definition: ncbiobj.hpp:180
CRef –.
Definition: ncbiobj.hpp:618
CRegexp –.
Definition: regexp.hpp:70
class CRegistryReadView provides a nested hierarchical view at a particular key.
Definition: reg_view.hpp:58
string GetString(const string &key, const string &default_val=kEmptyStr) const
Definition: reg_view.cpp:246
void GetStringList(const string &key, list< string > &val) const
Definition: reg_view.cpp:268
void Set(const string &key, int val)
access a named key at this level, with no recursion
Definition: reg_view.cpp:533
CScope –.
Definition: scope.hpp:92
CSearchControl.
CSearchControl * m_Text
void UpdateContextCombo(wxChoice *combo)
TFeatTypeItemSet m_FeatTypesSet
CRef< CDMSearchResult > m_TempResult
holds temporary results, guarded by Mutex
string m_Descr
human-readable description of the Job
CMutex m_Mutex
synchronizes access to the Job members
CRef< CAppJobError > m_Error
CObjectList m_AccList
accumulates found objects before they are transferred to m_ResultList
CSearchQueryBase.
vector< SScopedLoc > TScopedLocs
CSearchToolBase.
static const CFeatList * GetFeatList()
CSeq_feat_Handle –.
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
virtual void Init()
IDMSearchQuery - abstract data mining query.
IDMSearchTool interface representing a single search tool in Data Mining Service.
IDataMiningContext IDataMiningContext represents an abstract context for a Search.
virtual string GetDMContextName()=0
returns Name of the context to be used in UI
ISeqlocSearchContext.
virtual CRef< objects::CScope > GetSearchScope()=0
virtual set< string > GetAnnotNames() const
virtual CRef< objects::CSeq_loc > GetSearchLoc()=0
IUITool represents an abstract algorithm that is bound to a UI component.
Definition: ui_tool.hpp:59
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
void clear()
Definition: set.hpp:153
static uch flags
std::ofstream out("events_result.xml")
main entry point for tests
USING_SCOPE(objects)
static const int eCmdSelectFeatureTypes
CFeatureSearchForm.
static const char * kFetTypes
#define ID_HYPERLINKCTRL
#define ID_TEXT
static const char * kFetPattern
#define ID_COMBOBOX
static const string kProgressStr("Searching features. ")
#define false
Definition: bool.h:36
static const char location[]
Definition: config.c:97
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
#define NULL
Definition: ncbistd.hpp:225
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
Definition: ncbidiag.hpp:226
void Info(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1185
static objects::SAnnotSelector GetAnnotSelector(TAnnotFlags flags=0)
request an annotation selector for a given type
Definition: utils.cpp:167
bool m_CaseSensitive
regular expression to apply
objects::CSeq_feat_Handle x_SearchForSNP(const objects::CSeq_loc &seq_loc, objects::CScope &scope, const set< string > &annot_names)
virtual void x_LoadSettings(const CRegistryReadView &view)
CFeatureSearchForm(CFeatureSearchTool &tool)
virtual string GetExtensionIdentifier() const
returns the unique human-readable identifier for the extension the id should use lowercase letters se...
CRef< CFeatureSearchTool > m_Tool
virtual string ToString() const
Prepare a string representation of a query (for logging and debugging)
virtual CRef< CSearchJobBase > x_CreateJob(IDMSearchQuery &query)
implementing CSearchToolBase pure virtual function
virtual void x_SaveSettings(CRegistryWriteView view) const
wxHyperlinkCtrl * m_HyperLink
CRegexp * m_Pattern
search patteern for "Exact Match" and "Wildcard" modes
CFeatureSearchQuery::TScopedLocs TScopedLocs
TPatternType m_PatternType
CFeatureSearchQuery(TScopedLocs &locs, const string &pattern, bool case_sensitive, TPatternType pt_type, const TFeatTypeItemSet &feat_types)
CFeatureSearchQuery.
CFeatureSearchTool()
CFeatureSearchTool.
virtual IDMSearchTool * x_GetTool()
virtual string GetName() const
returns unique name of the method that is used in UI to identify it
virtual CIRef< IDMSearchQuery > ConstructQuery()
virtual CIRef< IDMSearchForm > CreateSearchForm()
factory method for creating a form representing the tool
virtual wxSizer * GetWidget(wxWindow *parent)
return a widget associated with the form; the form controls the lifetime of the widget (do not delete...
string SeqLocToString(const objects::CSeq_loc &loc)
virtual void x_CreateWidgets()
virtual string GetExtensionLabel() const
returns a displayable label for this extension ( please capitalize the key words - "My Extension" )
virtual bool IsCompatible(IDataMiningContext *context)
retuns true if the tool is compatible with the provided Search Context
virtual void x_SetupColumns(CObjectList &obj_list)
add custom columns if needed
virtual string GetDescription() const
returns a detailed description of the method that is used in UI
vector< ISeqLocSearchContext * > m_SeqLocContexts
list< string > m_FeatureTypes
void x_AddFeatToResults(const objects::CSeq_feat &feat, objects::CScope &scope, const string &loc_label, const int cnt, const int cnt_found, const string &ctx_name)
virtual IUITool * Clone() const
static void GetLabel(const CObject &obj, string *label, ELabelType type=eDefault)
Definition: label.cpp:140
list< TSNPSearchCompoundResult > TSNPSearchCompoundResultList
results of a search for one or several ids
Definition: snp_gui.hpp:234
virtual bool IsCanceled() const override
EJobState
Job states (describe FSM)
Definition: app_job.hpp:86
static void Search(const std::string &sTerms, const std::string &sAssemblyAccession, TSNPSearchCompoundResultList &ResultList)
search for given SNP ID(s) and get a list of results
@ eCompleted
Definition: app_job.hpp:89
@ eDefault
Definition: label.hpp:73
@ eUserTypeAndContent
Definition: label.hpp:66
void SetWhole(TWhole &v)
Definition: Seq_loc.hpp:982
ENa_strand GetStrand(void) const
Get the location's strand.
Definition: Seq_loc.cpp:882
TRange GetTotalRange(void) const
Definition: Seq_loc.hpp:913
const CSeq_id * GetId(void) const
Get the id of the location return NULL if has multiple ids or no id at all.
Definition: Seq_loc.hpp:941
void GetLabel(string *label) const
Appends a label suitable for display (e.g., error messages) label must point to an existing string ob...
Definition: Seq_loc.cpp:3467
bool IsSameBioseq(const CSeq_id &id1, const CSeq_id &id2, CScope *scope, CScope::EGetBioseqFlag get_flag=CScope::eGetBioseq_All)
Determines if two CSeq_ids represent the same CBioseq.
bool IsSetComment(void) const
const CSeqFeatData & GetData(void) const
bool IsSetExcept_text(void) const
const string & GetComment(void) const
const string & GetExcept_text(void) const
CConstRef< CSeq_feat > GetOriginalSeq_feat(void) const
SAnnotSelector & IncludeFeatSubtype(TFeatSubtype subtype)
Include feature subtype in the search.
const CSeq_feat & GetOriginalFeature(void) const
Get original feature with unmapped location/product.
const CSeq_feat & GetMappedFeature(void) const
Feature mapped to the master sequence.
SAnnotSelector & IncludeFeatType(TFeatType type)
Include feature type in the search.
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:998
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
bool IsNull(void) const THROWS_NONE
Check if pointer is null – same effect as Empty().
Definition: ncbiobj.hpp:735
TObjectType & GetObject(void) const
Get object.
Definition: ncbiobj.hpp:1697
bool Empty(void) const
Definition: range.hpp:148
bool IsMatch(CTempString str, TMatch flags=fMatch_default)
Check existence substring which match a specified pattern.
Definition: regexp.cpp:193
CTempString GetMatch(CTempString str, size_t offset=0, size_t idx=0, TMatch flags=fMatch_default, bool noreturn=false)
Get matching pattern and subpatterns.
Definition: regexp.cpp:182
ECompile
Flags for compile regular expressions.
Definition: regexp.hpp:101
@ fCompile_default
Definition: regexp.hpp:102
@ fCompile_ignore_case
Definition: regexp.hpp:103
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static bool MatchesMask(CTempString str, CTempString mask, ECase use_case=eCase)
Match "str" against the "mask".
Definition: ncbistr.cpp:389
#define NPOS
Definition: ncbistr.hpp:133
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate spaces in a string (in-place)
Definition: ncbistr.cpp:3201
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5084
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.
Definition: ncbistr.cpp:2891
static string Join(const TContainer &arr, const CTempString &delim)
Join strings using the specified delimiter.
Definition: ncbistr.hpp:2697
bool empty(void) const
Return true if the represented string is empty (i.e., the length is zero)
Definition: tempstr.hpp:334
static string UIntToString(unsigned int value, TNumToStringFlags flags=0, int base=10)
Convert UInt to string.
Definition: ncbistr.hpp:5109
ECase
Which type of string comparison.
Definition: ncbistr.hpp:1204
static void Wrap(const string &str, SIZE_TYPE width, IWrapDest &dest, TWrapFlags flags, const string *prefix, const string *prefix1)
Definition: ncbistr.cpp:5347
@ fWithCommas
Use commas as thousands separator.
Definition: ncbistr.hpp:254
@ eNocase
Case insensitive compare.
Definition: ncbistr.hpp:1206
@ eCase
Case sensitive compare.
Definition: ncbistr.hpp:1205
static const char label[]
TTo GetTo(void) const
Get the To member data.
Definition: Range_.hpp:269
TFrom GetFrom(void) const
Get the From member data.
Definition: Range_.hpp:222
list< string > TSyn
Definition: Gene_ref_.hpp:102
E_Choice Which(void) const
Which variant is currently selected.
const TLocation & GetLocation(void) const
Get the Location member data.
Definition: Seq_feat_.hpp:1117
E_Choice
Choice variants.
const TGene & GetGene(void) const
Get the variant data.
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seq_loc_.hpp:475
@ eNa_strand_minus
Definition: Na_strand_.hpp:67
@ e_Whole
whole sequence
Definition: Seq_loc_.hpp:100
list< CRef< CVariantPlacement > > TPlacements
int i
static void text(MDB_val *v)
Definition: mdb_dump.c:62
#define wxT(x)
Definition: muParser.cpp:41
static unsigned cnt[256]
#define row(bind, expected)
Definition: string_bind.c:73
CRef< objects::CScope > m_Scope
CRef< objects::CSeq_loc > m_Loc
SAnnotSelector –.
static string query
#define _ASSERT
static CS_CONTEXT * context
Definition: will_convert.c:21
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
Modified on Wed Apr 24 14:19:25 2024 by modify_doxy.py rev. 669887