55 #include <wx/stattext.h>
56 #include <wx/choice.h>
57 #include <wx/srchctrl.h>
58 #include <wx/filename.h>
61 #define ID_COMBOBOX 10003
63 #define ID_COMBOBOX_UPDATE 10111
111 m_Filters.
filters.push_back(pair<string,string>(
"Show only positive strand results",
114 m_Filters.
filters.push_back(pair<string,string>(
"Show only negative strand results",
121 static string name(
"Sequence Search");
149 return sl_ctx !=
NULL;
166 return "search_tool::sequence_search_tool";
171 return "Datamining Tool - Sequence Search search";
183 const string& pattern,
188 m_PatternType(pt_type),
255 wxBoxSizer * vSz =
new wxBoxSizer(wxVERTICAL);
258 wxFlexGridSizer * sz =
new wxFlexGridSizer(1, 4, 0, 0);
259 sz->AddGrowableCol(3);
261 m_Sizer->Add(sz, 0, wxGROW|wxALL, 0);
264 sz->Add(
new wxStaticText( parent, wxID_STATIC,
265 wxT(
"Search Context:"),
266 wxDefaultPosition, wxDefaultSize, 0 ),
267 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
270 wxDefaultPosition, wxDefaultSize,
271 0, (
const wxString*)
NULL);
273 sz->Add(
m_DbCombo,1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
276 sz->Add(
new wxStaticText( parent, wxID_STATIC,
wxT(
"Search Type:"),
277 wxDefaultPosition, wxDefaultSize, 0 ),
278 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
282 wxDefaultPosition, wxDefaultSize,
283 0, (
const wxString*)
NULL);
297 sz->Add(
m_TypeCombo,1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
303 wxT(
"Search Expression:"),
304 wxDefaultPosition, wxDefaultSize, 0 ),
305 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
312 m_pPatternSizer->Add(
new wxStaticText( parent, wxID_STATIC,
wxT(
"Select Named Pattern:"), wxDefaultPosition, wxDefaultSize, 0 ),
313 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
315 wxDefaultPosition, wxDefaultSize,
316 0, (
const wxString*)
NULL);
368 if (search_loc.
IsNull()) {
372 vector<CRef<CSeq_loc> > locs;
378 locs.back()->SetInt(*ref);
382 locs.push_back(search_loc);
386 id->Assign(*(search_loc->
GetId()));
388 locs.back()->SetWhole(*
id);
396 sc_locs.push_back(sl);
409 searchString =
"#undefined#";
454 if ( (dir =
registry.
Get(
"Patterns",
"PatternPath")).empty() ) {
455 registry.
Set(
"Patterns",
"PatternPath",
"<std>, <home>",
463 ITERATE (list<string>, iter, paths) {
465 if (*iter ==
"<std>" || *iter ==
"<home>") {
470 if ( dir_name.empty() ) {
474 wxFileName fname(dir_name, wxEmptyString);
475 if ( !fname.DirExists(dir_name) ) {
482 bool cont = dir.GetFirst(&filename,
wxT(
"*.ini"), wxDIR_FILES);
484 fname.SetFullName(filename);
485 wxString full_path = fname.GetFullPath();
491 list<string> pat_ids;
492 patterns.EnumerateSections(&pat_ids);
495 ITERATE (list<string>, pat_id, pat_ids) {
496 if (*pat_id ==
"-") {
498 if (!fName.empty()) {
503 string pattern =
patterns.Get(*pat_id,
"pattern");
504 string desc =
patterns.Get(*pat_id,
"description");
505 if (!fName.empty()) {
510 cont = dir.GetNext(&filename);
521 m_PatternType(
query.GetPatternType())
524 static string sep(
", ");
527 it->m_Scope.GetPointer());
531 if( ! s_locs.empty()) {
532 s_locs.resize(s_locs.size() - sep.size());
535 m_Descr =
"Search Sequence for \"" + s_pat +
"\" on " + s_locs;
630 bool searchForward =
true, searchReverse =
true;
634 if (expr.find(
"Strand=") == 0 && expr.size() > 7) {
635 string value = expr.substr(7);
637 searchReverse =
false;
638 else if (
value ==
"'-'")
639 searchForward =
false;
643 if (!searchForward && !searchReverse)
644 searchForward = searchReverse =
true;
707 range.GetFrom() + seq_offset,
708 range.GetTo() + seq_offset));
742 range.GetFrom() + seq_offset,
743 range.GetTo() + seq_offset));
774 while((
int) coll.
size() < max_coll_size) {
779 coll.
insert(make_pair(from, to));
790 int start_pos = 0, num = 0;
795 for(
int i = 0; i < num && max_coll_size > 0 && !
IsCanceled(); ++
i ) {
799 p0 = (
int)(
data.size() - p[1]);
800 p1 = (
int)(
data.size() - p[0]);
810 coll.
insert(make_pair(from, to));
813 if((
int) coll.
size() >= max_coll_size) {
831 static const TSeqPos kMaxLen = 40;
833 if (
range.GetLength() > kMaxLen) {
837 *s = s1 +
"..." + s2;
846 const string& sequence,
847 const string& loc_name,
848 const string& strand,
849 const string& ctx_name)
851 static const int kUpdateIncrement = 250;
874 if(
count >= kUpdateIncrement) {
CAppJobError Default implementation for IAppJobError - encapsulates a text error message.
CObjectList * GetObjectList()
static CNcbiApplication * Instance(void)
Singleton method.
CObjectList Data structure representing a list of CObjects with associated Scopes and other optional ...
int AddRow(CObject *obj, objects::CScope *scope)
void AddObjectLabel(const string &name, CLabel::ELabelType type)
void SetString(int col, int row, const string &val)
void SetInteger(int col, int row, int 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 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
int m_ResultsCount
total number of results
IDMSearchTool::TFilters m_Filters
holds the final results
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
TScopedLocs & GetScopedLocs()
vector< SScopedLoc > TScopedLocs
static SIZE_TYPE ReverseComplement(const string &src, TCoding src_coding, TSeqPos pos, TSeqPos length, string &dst)
static wxString ResolvePath(const wxString &path, const wxString &rel_name)
Utility function to hide the platform specifics of locating our standard directories and files.
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 CRef< objects::CSeq_loc > GetSearchLoc()=0
iterator_bool insert(const value_type &val)
const CNcbiRegistry & GetConfig(void) const
Get the application's cached configuration parameters (read-only).
unsigned int TSeqPos
Type for sequence locations and lengths.
#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.
virtual IAppJob::EJobState x_DoSearch()
performs searching, assuming that params are correct; Implement in derived classes
CRef< CSequenceSearchTool > m_Tool
void x_GetSequence(objects::CSeqVector &vec, const CRange< TSeqPos > &range, string *s)
virtual CObjectListTableModel * x_GetNewOLTModel() const
factory method creating new column handler for CObjectListWidget
virtual IDMSearchTool * x_GetTool()
virtual CIRef< IDMSearchForm > CreateSearchForm()
factory method for creating a form representing the tool
virtual IDMSearchTool::TUIToolFlags GetFlags(void)
special flags
wxChoice * m_PatternCombo
void x_UpdateFileList(void)
CSequenceSearchQuery::TScopedLocs TScopedLocs
CSequenceSearchQuery(TScopedLocs &locs, const string &pattern, TPatternType pt_type, const string &file)
CSequenceSearchQuery.
wxFlexGridSizer * m_pSearchSizer
CRegexp * m_Pattern
search patteern for "Exact Match" and "Wildcard" modes
virtual void x_LoadSettings(const CRegistryReadView &view)
virtual string GetName() const
returns unique name of the method that is used in UI to identify it
CSequenceSearchJob(CSequenceSearchQuery &query)
CSequenceSearchJob.
virtual string GetExtensionLabel() const
returns a displayable label for this extension ( please capitalize the key words - "My Extension" )
virtual string ToString() const
Prepare a string representation of a query (for logging and debugging)
virtual bool IsCompatible(IDataMiningContext *context)
retuns true if the tool is compatible with the provided Search Context
CRef< CSequenceSearchQuery > m_Query
virtual void UpdateContexts()
updates m_ContextCombo
void x_AddToResults(CObject &obj, objects::CScope &scope, const string &sequence, const string &loc_name, const string &strand, const string &ctx_name)
virtual wxSizer * GetWidget(wxWindow *parent)
return a widget associated with the form; the form controls the lifetime of the widget (do not delete...
vector< ISeqLocSearchContext * > m_SeqLocContexts
virtual CIRef< IDMSearchQuery > ConstructQuery()
virtual IUITool * Clone() const
void x_GetMatches(const string &data, int start, TRangeCollection &coll, bool reverse)
"offset" argument defines the sequence position corresponding to the fisrt character in "data"
TPatternType m_PatternType
CSequenceSearchForm(CSequenceSearchTool &tool)
list< TDescPattern > TDescPatList
wxFlexGridSizer * m_pPatternSizer
virtual void x_SaveSettings(CRegistryWriteView view) const
pair< string, string > TDescPattern
TPatternType m_PatternType
IAppJob::EJobState x_SearchSequence(TScopedLocs &scoped_locs)
virtual void x_SetupColumns(CObjectList &obj_list)
add custom columns if needed
virtual bool x_ValidateParams()
returns true if Job params are correct, implement in derived classes
string m_PatternFile
regular expression to apply
TPatternType GetPatternType()
virtual string GetExtensionIdentifier() const
returns the unique human-readable identifier for the extension the id should use lowercase letters se...
virtual CRef< CSearchJobBase > x_CreateJob(IDMSearchQuery &query)
implementing CSearchToolBase pure virtual function
CSequenceSearchQuery::TScopedLocs TScopedLocs
TPatternType m_PatternType
CSequenceSearchTool()
CSequenceSearchTool.
virtual string GetDescription() const
returns a detailed description of the method that is used in UI
static TFileList m_FileList
CSequenceSearchForm.
static void GetLabel(const CObject &obj, string *label, ELabelType type=eDefault)
virtual bool IsCanceled() const override
EJobState
Job states (describe FSM)
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Optimized implementation of CSerialObject::Assign, which is not so efficient.
CConstRef< CSeq_id > GetSeqId(void) const
static CSeq_id_Handle GetHandle(const CSeq_id &id)
Normal way of getting a handle, works for any seq-id.
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.
const CSeq_id & GetId(const CSeq_loc &loc, CScope *scope)
If all CSeq_ids embedded in CSeq_loc refer to the same CBioseq, returns the first CSeq_id found,...
@ eCoding_Iupac
Set coding to printable coding (Iupacna or Iupacaa)
void GetSeqData(TSeqPos start, TSeqPos stop, string &buffer) const
Fill the buffer string with the sequence data for the interval [start, stop).
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().
const TOffset * GetResults(size_t idx) const
Get location of pattern/subpattern for the last GetMatch().
CTempString GetMatch(CTempString str, size_t offset=0, size_t idx=0, TMatch flags=fMatch_default, bool noreturn=false)
Get matching pattern and subpatterns.
int NumFound() const
Get number of patterns + subpatterns.
static string WildcardToRegexp(CTempString mask)
Convert wildcard mask to regular expression.
virtual const string & Get(const string §ion, const string &name, TFlags flags=0) const
Get the parameter value.
bool Set(const string §ion, const string &name, const string &value, TFlags flags=0, const string &comment=kEmptyStr)
Set the configuration parameter value.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::ifstream CNcbiIfstream
Portable alias for ifstream.
NCBI_NS_STD::string::size_type SIZE_TYPE
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
static 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.
@ fSplit_Tokenize
All delimiters are merged and trimmed, to get non-empty tokens only.
@ eForwardSearch
Search in a forward direction.
@ fWithCommas
Use commas as thousands separator.
@ eNocase
Case insensitive compare.
TTo GetTo(void) const
Get the To member data.
TFrom GetFrom(void) const
Get the From member data.
list< CRef< CSeq_interval > > Tdata
const Tdata & Get(void) const
Get the member data.
TFrom GetFrom(void) const
Get the From member data.
bool IsPacked_int(void) const
Check if variant Packed_int is selected.
bool IsInt(void) const
Check if variant Int is selected.
const TInt & GetInt(void) const
Get the variant data.
const TPacked_int & GetPacked_int(void) const
Get the variant data.
unsigned int
A callback function used to compare two keys in a database.
range(_Ty, _Ty) -> range< _Ty >
const GenericPointer< typename T::ValueType > T2 value
Defines the CNcbiApplication and CAppException classes for creating NCBI applications.
Process information in the NCBI Registry, including working with configuration files.
#define row(bind, expected)
CRef< objects::CScope > m_Scope
CRef< objects::CSeq_loc > m_Loc
static CS_CONTEXT * context
wxString ToWxString(const string &s)
string ToStdString(const wxString &s)