56 #include <wx/stattext.h>
57 #include <wx/choice.h>
58 #include <wx/srchctrl.h>
60 #define ID_COMBOBOX 10003
62 #define ID_BUTTON1 10005
63 #define ID_HYPERLINKCTRL 10999
80 static string name(
"Feature Search");
108 return sl_ctx !=
NULL;
125 return "search_tool::feature_search_tool";
131 return "Search Tool - Feature Search";
139 const string& pattern,
145 m_PatternType(pt_type),
146 m_CaseSensitive(case_sensitive),
147 m_FeatTypesSet(feat_types)
201 string lbl = ft_it->GetDescription();
203 strText += strText.empty()?
"":
", ";
208 if (strText.empty()) {
209 strText =
"Click To Select ...";
212 list<string> strList;
248 list<string> strList;
250 strList.push_back(ft_it->GetDescription());
259 wxFlexGridSizer * sz =
new wxFlexGridSizer(0, 4, 0, 0);
260 sz->AddGrowableCol(3);
263 wxStaticText* stat1 =
new wxStaticText(parent, wxID_STATIC,
264 wxT(
"Search Context:"));
265 m_Sizer->Add(stat1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
268 wxDefaultPosition, wxDefaultSize,
269 0, (
const wxString*)
NULL);
274 wxStaticText* stat2 =
new wxStaticText( parent, wxID_STATIC,
275 wxT(
"Search Type:"));
276 m_Sizer->Add(stat2, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
279 wxDefaultPosition, wxDefaultSize,
280 0, (
const wxString*)
NULL);
293 m_Sizer->Add(
new wxStaticText( parent, wxID_STATIC,
294 wxT(
"Feature Types:"),
295 wxDefaultPosition, wxDefaultSize, 0 ),
296 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
307 wxT(
"Click To Select ..."),
wxT(
""),
308 wxDefaultPosition, wxDefaultSize,
313 wxStaticText* stat3 =
new wxStaticText( parent, wxID_STATIC,
314 wxT(
"Search Expression:"));
315 m_Sizer->Add(stat3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
318 wxDefaultPosition, wxDefaultSize,
319 wxTE_PROCESS_ENTER );
320 m_Sizer->Add(
m_Text,1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
377 sc_locs.push_back(sl);
405 static string sep(
", ");
413 if( ! s_locs.empty()) {
414 s_locs.resize(s_locs.size() - sep.size());
416 string s_pat =
m_Query->GetPattern();
417 m_Descr =
"Search Features \"" + s_pat +
"\" on " + s_locs;
425 if(
m_Query->GetScopedLocs().empty()) {
428 if(
m_Query->GetPattern().empty()) {
517 if( ! feat_types.empty()) {
537 CScope& scope = *sc_loc.m_Scope;
538 const set<string>& annot_names = sc_loc.m_AnnotNames;
555 CFeat_CI feat_iter(scope, seq_loc, sel);
571 if (
cnt > 0 &&
cnt % 100) {
620 const string& loc_label,
const int cnt,
const int cnt_found,
const string& ctx_name)
639 if (locplustrand.find_last_of(
'-') == (locplustrand.length() - 1)) {
648 const string& loc_name,
649 const string& strand,
650 const string& acc_name,
651 const string& ctx_name)
653 static const int kUpdateIncrement = 200;
663 if(count >= kUpdateIncrement) {
704 CRegexp re_snp(
"^([rs]s)([0-9]{3,})(?::.+)?$");
713 for (
const auto& res_it : SNPSearchResultList) {
714 for (
const auto& var_it : res_it.second) {
717 _ASSERT(placements.size() == 1);
718 if (placements.size() != 1)
721 const auto& pl = placements.front();
726 for (
const auto& it : annot_names) {
727 sel.AddNamedAnnots(it);
728 sel.IncludeNamedAnnotAccession(it);
731 CFeat_CI feat_it(scope, pl->GetLoc(), sel);
749 if (gene_ref.IsSetLocus() &&
x_Match(gene_ref.GetLocus())) {
752 if (gene_ref.IsSetAllele() &&
x_Match(gene_ref.GetAllele())) {
755 if (gene_ref.IsSetDesc() &&
x_Match(gene_ref.GetDesc())) {
758 if (gene_ref.IsSetMaploc() &&
x_Match(gene_ref.GetMaploc())) {
761 if (gene_ref.IsSetLocus_tag() &&
x_Match(gene_ref.GetLocus_tag())) {
764 if (gene_ref.IsSetSyn()) {
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.
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)
CObjectList Data structure representing a list of CObjects with associated Scopes and other optional ...
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
int AddColumn(EColumnType type, const string &name, int col=-1)
class CRegistryReadView provides a nested hierarchical view at a particular key.
string GetString(const string &key, const string &default_val=kEmptyStr) const
void GetStringList(const string &key, list< string > &val) const
void Set(const string &key, int val)
access a named key at this level, with no recursion
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
vector< SScopedLoc > TScopedLocs
static const CFeatList * GetFeatList()
namespace ncbi::objects::
IDMSearchQuery - abstract data mining query.
IDataMiningContext IDataMiningContext represents an abstract context for a Search.
virtual string GetDMContextName()=0
returns Name of the context to be used in UI
virtual CRef< objects::CScope > GetSearchScope()=0
virtual set< string > GetAnnotNames() const
virtual CRef< objects::CSeq_loc > GetSearchLoc()=0
iterator_bool insert(const value_type &val)
static const char location[]
std::ofstream out("events_result.xml")
main entry point for tests
#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...
void Info(CExceptionArgs_Base &args)
static objects::SAnnotSelector GetAnnotSelector(TAnnotFlags flags=0)
request an annotation selector for a given type
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)
TPatternType m_PatternType
virtual IUITool * Clone() const
static void GetLabel(const CObject &obj, string *label, ELabelType type=eDefault)
list< TSNPSearchCompoundResult > TSNPSearchCompoundResultList
results of a search for one or several ids
virtual bool IsCanceled() const override
EJobState
Job states (describe FSM)
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
ENa_strand GetStrand(void) const
Get the location's strand.
TRange GetTotalRange(void) const
const CSeq_id * GetId(void) const
Get the id of the location return NULL if has multiple ids or no id at all.
void GetLabel(string *label) const
Appends a label suitable for display (e.g., error messages) label must point to an existing string ob...
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,.
void Reset(void)
Reset reference object.
bool IsNull(void) const THROWS_NONE
Check if pointer is null – same effect as Empty().
TObjectType & GetObject(void) const
Get object.
bool IsMatch(CTempString str, TMatch flags=fMatch_default)
Check existence substring which match a specified pattern.
CTempString GetMatch(CTempString str, size_t offset=0, size_t idx=0, TMatch flags=fMatch_default, bool noreturn=false)
Get matching pattern and subpatterns.
ECompile
Flags for compile regular expressions.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static bool MatchesMask(CTempString str, CTempString mask, ECase use_case=eCase)
Match "str" against the "mask".
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate spaces in a string (in-place)
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
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 string Join(const TContainer &arr, const CTempString &delim)
Join strings using the specified delimiter.
bool empty(void) const
Return true if the represented string is empty (i.e., the length is zero)
static string UIntToString(unsigned int value, TNumToStringFlags flags=0, int base=10)
Convert UInt to string.
ECase
Which type of string comparison.
static void Wrap(const string &str, SIZE_TYPE width, IWrapDest &dest, TWrapFlags flags, const string *prefix, const string *prefix1)
@ fWithCommas
Use commas as thousands separator.
@ eNocase
Case insensitive compare.
@ eCase
Case sensitive compare.
static const char label[]
TTo GetTo(void) const
Get the To member data.
TFrom GetFrom(void) const
Get the From member data.
E_Choice Which(void) const
Which variant is currently selected.
const TLocation & GetLocation(void) const
Get the Location member data.
const TGene & GetGene(void) const
Get the variant data.
E_Choice Which(void) const
Which variant is currently selected.
list< CRef< CVariantPlacement > > TPlacements
static void text(MDB_val *v)
CRef< objects::CScope > m_Scope
CRef< objects::CSeq_loc > m_Loc
set< string > m_AnnotNames
wxString ToWxString(const string &s)
string ToStdString(const wxString &s)