66 #include <wx/statline.h>
67 #include <wx/textctrl.h>
68 #include <wx/stattext.h>
69 #include <wx/valnum.h>
70 #include <wx/filedlg.h>
71 #include <wx/choicebk.h>
73 #include <wx/artprov.h>
74 #include <wx/bmpbuttn.h>
75 #include <wx/radiobox.h>
76 #include <wx/radiobut.h>
77 #include <wx/combobox.h>
78 #include <wx/checkbox.h>
89 #define SYMBOL_CADVSTRINGCONSTRAINTPANEL_STYLE wxTAB_TRAVERSAL
90 #define SYMBOL_CADVSTRINGCONSTRAINTPANEL_TITLE _("StringConstraintPanel")
91 #define SYMBOL_CADVSTRINGCONSTRAINTPANEL_IDNAME ID_CADVSTRINGCONSTRAINTPANEL
92 #define SYMBOL_CADVSTRINGCONSTRAINTPANEL_SIZE wxDefaultSize
93 #define SYMBOL_CADVSTRINGCONSTRAINTPANEL_POSITION wxDefaultPosition
115 bool Create( wxWindow* parent,
131 void OnClear( wxCommandEvent& event );
156 void SetChoices(
const vector<string> &choices,
const vector<string> &values);
168 virtual pair<string, string>
GetMatcher(
const pair<string, string>& target,
size_t num);
169 virtual vector<CFuncWithArgs>
GetFuncWithArgs(
const pair<string, string>& target,
size_t num)
const;
171 virtual void GetVars(vector<string> &vars,
size_t num);
172 virtual string GetQualName(
const pair<string, string>& target);
185 virtual void SetFieldNames(
const vector<string>& field_names);
263 : m_target(target), m_id(-1), m_num(0)
266 Create(parent,
id, caption, pos,
size, style);
272 SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
273 wxFrame::Create( parent,
id, caption, pos,
size, style );
278 GetSizer()->SetSizeHints(
this);
280 Centre(wxBOTH|wxCENTRE_ON_SCREEN);
300 wxBoxSizer* itemBoxSizer1 =
new wxBoxSizer(wxVERTICAL);
301 SetSizer(itemBoxSizer1);
303 wxPanel* itemCBulkCmdDlg1 =
new wxPanel(
this,
wxID_ANY);
304 itemBoxSizer1->Add(itemCBulkCmdDlg1, 1, wxGROW, 0);
306 wxBoxSizer* itemBoxSizer2 =
new wxBoxSizer(wxVERTICAL);
307 itemCBulkCmdDlg1->SetSizer(itemBoxSizer2);
310 itemBoxSizer2->Add(
m_Notebook, 1, wxGROW|wxALL, 5);
314 bool special_target = (target == macro::CMacroBioData::sm_SeqAlign
315 || target == macro::CMacroBioData::sm_TSEntry
316 || target == macro::CMacroBioData::sm_SeqSet);
318 if (!special_target) {
340 m_Notebook->AddPage(panel4,
_(
"CDS-Gene-Prot-mRNA"));
350 bool molinfo_target = (target == macro::CMacroBioData::sm_MolInfo
351 || target == macro::CMacroBioData::sm_BioSource
355 if (molinfo_target) {
365 if (target == macro::CMacroBioData::sm_Pubdesc) {
367 bool extended =
true;
376 if (target == macro::CMacroBioData::sm_StrComm
377 || target == macro::CMacroBioData::sm_SeqNa) {
379 m_Notebook->AddPage(panel8,
_(
"Structured Comment"));
383 if (target == macro::CMacroBioData::sm_DBLink
385 || target == macro::CMacroBioData::sm_StrComm
386 || target == macro::CMacroBioData::sm_BioSource
387 || target == macro::CMacroBioData::sm_MolInfo) {
397 if (target == macro::CMacroBioData::sm_SeqNa
398 || target == macro::CMacroBioData::sm_Seq
399 || target == macro::CMacroBioData::sm_Seqdesc
400 || target == macro::CMacroBioData::sm_UserObject)
419 m_Notebook->AddPage(panel12,
_(
"Sequence and Features"));
426 wxBoxSizer* itemBoxSizer3 =
new wxBoxSizer(wxHORIZONTAL);
427 itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL, 0);
429 wxButton* itemButton13 =
new wxButton( itemCBulkCmdDlg1, wxID_OK,
_(
"Accept"), wxDefaultPosition, wxDefaultSize, 0 );
430 itemBoxSizer3->Add(itemButton13, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
432 wxButton* itemButton14 =
new wxButton( itemCBulkCmdDlg1, wxID_CANCEL,
_(
"Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
433 itemBoxSizer3->Add(itemButton14, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
435 if (target == macro::CMacroBioData::sm_RNA ||
436 target == macro::CMacroBioData::sm_rRNA ||
437 target == macro::CMacroBioData::sm_mRNA ||
438 target == macro::CMacroBioData::sm_miscRNA) {
441 if (target == macro::CMacroBioData::sm_BioSource)
445 if (target == macro::CMacroBioData::sm_MolInfo ||
NStr::StartsWith(target, macro::CMacroBioData::sm_Seq))
449 if (target == macro::CMacroBioData::sm_Pubdesc)
453 if (target == macro::CMacroBioData::sm_StrComm)
457 if (target == macro::CMacroBioData::sm_DBLink)
461 if (target == macro::CMacroBioData::sm_SeqNa)
506 LOG_POST(
Info <<
"***Matching: " << item.first <<
", constraint: " << item.second);
508 if (item.first.empty() || item.second.empty()) {
520 wxWindow* parent = GetParent();
578 wxWindowID
id,
const wxPoint& pos,
const wxSize&
size,
long style )
581 Create(parent,
id, pos,
size, style);
590 wxWindowID
id,
const wxPoint& pos,
const wxSize&
size,
long style )
593 wxPanel::Create( parent,
id, pos,
size, style );
598 GetSizer()->SetSizeHints(
this);
617 m_IgnoreSpace =
NULL;
619 m_IgnorePunct =
NULL;
625 m_MatchChoice =
NULL;
627 m_ClearButton =
NULL;
628 m_WordSubstBtn =
NULL;
629 m_ConstraintType =
NULL;
638 wxPanel* parentPanel =
this;
640 wxBoxSizer* itemBoxSizer0 =
new wxBoxSizer(wxVERTICAL);
641 parentPanel->SetSizer(itemBoxSizer0);
643 wxBoxSizer* itemBoxSizer1 =
new wxBoxSizer(wxHORIZONTAL);
644 itemBoxSizer0->Add(itemBoxSizer1, 0, wxGROW|wxALL, 0);
646 m_panel =
new T(parentPanel);
647 itemBoxSizer1->Add(m_panel, 0, wxALIGN_TOP|wxALL, 5);
649 wxBoxSizer* itemBoxSizer2 =
new wxBoxSizer(wxVERTICAL);
650 itemBoxSizer1->Add(itemBoxSizer2, 0, wxALIGN_TOP|wxALL, 5);
652 wxBoxSizer* itemBoxSizer3 =
new wxBoxSizer(wxHORIZONTAL);
653 itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
655 wxArrayString m_MatchTypeStrings;
656 m_MatchTypeStrings.Add(
_(
"Contains"));
657 m_MatchTypeStrings.Add(
_(
"Does not contain"));
658 m_MatchTypeStrings.Add(
_(
"Equals"));
659 m_MatchTypeStrings.Add(
_(
"Does not equal"));
660 m_MatchTypeStrings.Add(
_(
"Starts with"));
661 m_MatchTypeStrings.Add(
_(
"Ends with"));
662 m_MatchTypeStrings.Add(
_(
"Is one of"));
663 m_MatchTypeStrings.Add(
_(
"Is not one of"));
664 m_MatchTypeStrings.Add(
_(
"Does not start with"));
665 m_MatchTypeStrings.Add(
_(
"Does not end with"));
667 m_MatchType =
new wxChoice( parentPanel, ID_STRING_CONSTRAINT_MATCH_CHOICE, wxDefaultPosition, wxDefaultSize, m_MatchTypeStrings, 0 );
668 m_MatchType->SetStringSelection(
_(
"Contains"));
669 itemBoxSizer3->Add(m_MatchType, 0, wxALIGN_TOP|wxLEFT|wxRIGHT|wxBOTTOM, 5);
672 m_TextSizer =
new wxBoxSizer(wxVERTICAL);
673 itemBoxSizer3->Add(m_TextSizer, 0, wxALIGN_TOP, 0);
675 m_MatchText =
new wxTextCtrl( parentPanel, ID_STRING_CONSTRAINT_MATCH_TEXT, wxEmptyString, wxDefaultPosition, wxSize(300, -1), wxTE_MULTILINE );
676 m_TextSizer->Add(m_MatchText, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5);
677 wxArrayString choice_strings;
678 m_MatchChoice =
new wxComboBox(parentPanel,
wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(300, -1), choice_strings, 0 );
679 m_MatchChoice->Hide();
681 wxBoxSizer* itemBoxSizer6 =
new wxBoxSizer(wxHORIZONTAL);
682 itemBoxSizer2->Add(itemBoxSizer6, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
684 wxBoxSizer* itemBoxSizer7 =
new wxBoxSizer(wxVERTICAL);
685 itemBoxSizer6->Add(itemBoxSizer7, 0, wxALIGN_TOP|wxALL, 5);
687 m_AnyLetters =
new wxRadioButton( parentPanel, ID_STRING_CONSTRAINT_RADIO0,
_(
"Any letters"), wxDefaultPosition, wxDefaultSize, 0 );
688 m_AnyLetters->SetValue(
true);
689 itemBoxSizer7->Add(m_AnyLetters, 0, wxALIGN_LEFT|wxALL, 5);
691 m_AllUpper =
new wxRadioButton( parentPanel, ID_STRING_CONSTRAINT_RADIO1,
_(
"All letters are upper case"), wxDefaultPosition, wxDefaultSize, 0 );
692 m_AllUpper->SetValue(
false);
693 itemBoxSizer7->Add(m_AllUpper, 0, wxALIGN_LEFT|wxALL, 5);
695 m_AllLower =
new wxRadioButton( parentPanel, ID_STRING_CONSTRAINT_RADIO2,
_(
"All letters are lower case"), wxDefaultPosition, wxDefaultSize, 0 );
696 m_AllLower->SetValue(
false);
697 itemBoxSizer7->Add(m_AllLower, 0, wxALIGN_LEFT|wxALL, 5);
699 m_AllPunct =
new wxRadioButton( parentPanel, ID_STRING_CONSTRAINT_RADIO3,
_(
"All characters are punctuation"), wxDefaultPosition, wxDefaultSize, 0 );
700 m_AllPunct->SetValue(
false);
701 itemBoxSizer7->Add(m_AllPunct, 0, wxALIGN_LEFT|wxALL, 5);
704 wxBoxSizer* itemBoxSizer8 =
new wxBoxSizer(wxVERTICAL);
705 itemBoxSizer6->Add(itemBoxSizer8, 0, wxALIGN_TOP|wxALL, 5);
707 m_IgnoreCase =
new wxCheckBox( parentPanel, ID_STRING_CONSTRAINT_CHECKBOX5,
_(
"Ignore Case"), wxDefaultPosition, wxDefaultSize, 0 );
708 m_IgnoreCase->SetValue(
false);
709 itemBoxSizer8->Add(m_IgnoreCase, 0, wxALIGN_LEFT|wxALL, 5);
711 m_IgnoreSpace =
new wxCheckBox( parentPanel, ID_STRING_CONSTRAINT_CHECKBOX6,
_(
"Ignore Space"), wxDefaultPosition, wxDefaultSize, 0 );
712 m_IgnoreSpace->SetValue(
false);
713 itemBoxSizer8->Add(m_IgnoreSpace, 0, wxALIGN_LEFT|wxALL, 5);
715 m_IgnorePunct =
new wxCheckBox( parentPanel, ID_STRING_CONSTRAINT_CHECKBOX8,
_(
"Ignore Punctuation"), wxDefaultPosition, wxDefaultSize, 0 );
716 m_IgnorePunct->SetValue(
false);
717 itemBoxSizer8->Add(m_IgnorePunct, 0, wxALIGN_LEFT|wxALL, 5);
719 m_WholeWord =
new wxCheckBox( parentPanel, ID_STRING_CONSTRAINT_CHECKBOX7,
_(
"Whole Word"), wxDefaultPosition, wxDefaultSize, 0 );
720 m_WholeWord->SetValue(
false);
721 itemBoxSizer8->Add(m_WholeWord, 0, wxALIGN_LEFT|wxALL, 5);
723 m_IgnoreSyn =
new wxCheckBox( parentPanel, ID_STRING_CONSTRAINT_CHECKBOX9,
_(
"Ignore 'putative' synonyms"), wxDefaultPosition, wxDefaultSize, 0 );
724 m_IgnoreSyn->SetValue(
false);
725 itemBoxSizer8->Add(m_IgnoreSyn, 0, wxALIGN_LEFT|wxALL, 5);
727 wxBoxSizer* itemBoxSizer9 =
new wxBoxSizer(wxHORIZONTAL);
728 itemBoxSizer2->Add(itemBoxSizer9, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
730 m_ClearButton =
new wxButton( parentPanel, ID_STRING_CONSTRAINT_CLEAR_BUTTON,
_(
"Clear Constraint"), wxDefaultPosition, wxDefaultSize, 0 );
731 itemBoxSizer9->Add(m_ClearButton, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
734 m_WordSubstBtn =
new wxButton( parentPanel, ID_STRING_CONSTRAINT_WORDSUBST_BUTTON,
_(
"Word Substitutions"), wxDefaultPosition, wxDefaultSize, 0 );
735 itemBoxSizer9->Add(m_WordSubstBtn, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
739 wxBoxSizer* hor_sizer =
new wxBoxSizer(wxHORIZONTAL);
740 itemBoxSizer0->Add(hor_sizer, 0, wxALIGN_LEFT | wxALL, 0);
742 wxArrayString present_not_present;
743 present_not_present.Add(
_(
"Match value"));
744 present_not_present.Add(
_(
"Present"));
745 present_not_present.Add(
_(
"Not present"));
746 present_not_present.Add(
_(
"From table"));
747 m_ConstraintType =
new wxRadioBox(parentPanel, ID_CONSTRAINT_TYPE, wxEmptyString, wxDefaultPosition, wxDefaultSize, present_not_present, 1, wxRA_SPECIFY_ROWS);
748 m_ConstraintType->SetSelection(0);
749 hor_sizer->Add(m_ConstraintType, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT, 5);
752 m_TableSizer =
new wxFlexGridSizer(0, 2, 0, 0);
753 hor_sizer->Add(m_TableSizer, 0, wxALIGN_BOTTOM | wxRESERVE_SPACE_EVEN_IF_HIDDEN | wxALL, 0);
755 wxStaticText* itemStaticText10 =
new wxStaticText(parentPanel, wxID_STATIC,
_(
"File name"), wxDefaultPosition, wxDefaultSize, 0);
756 m_TableSizer->Add(itemStaticText10, 0, wxALIGN_LEFT | wxRESERVE_SPACE_EVEN_IF_HIDDEN | wxLEFT, 5);
758 wxStaticText* itemStaticText11 =
new wxStaticText(parentPanel, wxID_STATIC,
_(
"Column"), wxDefaultPosition, wxDefaultSize, 0);
759 m_TableSizer->Add(itemStaticText11, 0, wxALIGN_LEFT | wxRESERVE_SPACE_EVEN_IF_HIDDEN | wxLEFT, 5);
761 wxBoxSizer* itemBoxSizer11 =
new wxBoxSizer(wxHORIZONTAL);
762 m_TableSizer->Add(itemBoxSizer11, 0, wxALIGN_LEFT | wxRESERVE_SPACE_EVEN_IF_HIDDEN | wxALL, 0);
764 m_Tablename =
new wxTextCtrl(parentPanel, ID_CONSTRAINT_TABLENAME, wxEmptyString, wxDefaultPosition, wxSize(270,-1));
765 itemBoxSizer11->Add(m_Tablename, 0, wxALIGN_CENTER_VERTICAL | wxRESERVE_SPACE_EVEN_IF_HIDDEN | wxALL, 5);
767 wxButton* itemButton12 =
new wxBitmapButton(parentPanel, ID_OPENFILEBTMBTN, wxArtProvider::GetBitmap(
wxT(
"menu::open")), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW);
768 itemButton12->SetToolTip(
wxT(
"Choose a table file..."));
769 itemBoxSizer11->Add(itemButton12, 0, wxALIGN_CENTER_VERTICAL | wxRESERVE_SPACE_EVEN_IF_HIDDEN| wxALL, 2);
772 wxIntegerValidator<unsigned> validator;
774 m_Column =
new wxTextCtrl(parentPanel, ID_CONSTRAINT_TABLECOL, wxEmptyString, wxDefaultPosition, wxSize(30, -1), 0, validator);
775 m_TableSizer->Add(m_Column, 0, wxALIGN_LEFT | wxRESERVE_SPACE_EVEN_IF_HIDDEN | wxALL, 5);
777 hor_sizer->Hide(m_TableSizer,
true);
782 bool allow_other =
true;
783 vector<string> choices = panel->
GetChoices(allow_other);
785 SetChoices(choices, values);
804 m_MatchChoice->Hide();
805 m_TextSizer->Replace(m_MatchChoice, m_MatchText);
811 m_MatchType->SetStringSelection(
_(
"Contains"));
812 m_MatchText->SetValue(wxEmptyString);
813 m_IgnoreCase->SetValue(
false);
814 m_IgnoreSpace->SetValue(
false);
815 m_WholeWord->SetValue(
false);
816 m_IgnorePunct->SetValue(
false);
817 m_IgnoreSyn->SetValue(
false);
818 m_AnyLetters->SetValue(
true);
819 m_AllUpper->SetValue(
false);
820 m_AllLower->SetValue(
false);
821 m_AllPunct->SetValue(
false);
822 m_SynonymFile.clear();
823 m_SynonymList.Reset();
829 string match_text = x_GetMatchText();
830 event.Enable(m_ConstraintType->GetSelection() == 0 && !match_text.empty());
836 int sel = m_ConstraintType->GetSelection();
837 bool enable = (sel == 0);
838 EnableStringConstraint(enable);
841 m_TableSizer->ShowItems(enable);
847 if (m_MatchChoice->IsShown())
848 m_MatchChoice->Enable(enable);
850 m_MatchText->Enable(enable);
852 m_MatchType->Enable(enable);
853 m_MatchText->Enable(enable);
854 m_IgnoreCase->Enable(enable);
855 m_IgnoreSpace->Enable(enable);
856 m_WholeWord->Enable(enable);
857 m_IgnorePunct->Enable(enable);
858 m_IgnoreSyn->Enable(enable);
859 m_AnyLetters->Enable(enable);
860 m_AllUpper->Enable(enable);
861 m_AllLower->Enable(enable);
862 m_AllPunct->Enable(enable);
863 m_ClearButton->Enable(enable);
865 m_WordSubstBtn->Enable(enable);
871 wxArrayString choice_strings;
872 ITERATE(vector<string>, it, choices) {
875 m_MatchChoice->Set(choice_strings);
877 _ASSERT(values.empty() || choices.size() == values.size());
879 m_choice_to_value.clear();
880 for (
size_t i = 0;
i < values.size();
i++)
881 m_choice_to_value[choices[
i]] = values[
i];
889 if (!m_MatchChoice->IsListEmpty() &&
890 (m_MatchType->GetSelection() == eMatchType_Equals || m_MatchType->GetSelection() == eMatchType_DoesNotEqual)) {
893 m_TextSizer->Replace(m_MatchText, m_MatchChoice);
894 m_MatchChoice->Show();
900 m_MatchChoice->Hide();
901 m_TextSizer->Replace(m_MatchChoice, m_MatchText);
920 if (event.GetId() != ID_OPENFILEBTMBTN)
923 wxFileDialog dlg(
this,
wxT(
"Select table file"), wxEmptyString, wxEmptyString,
_(
"All files (*.*)|*.*"), wxFD_OPEN | wxFD_FILE_MUST_EXIST);
925 if (dlg.ShowModal() == wxID_OK) {
927 m_Tablename->SetValue(mapped_path);
928 m_Tablename->SetInsertionPoint(m_Tablename->GetLastPosition());
967 template <
typename T>
970 m_choice_to_value.clear();
973 bool allow_other =
true;
974 vector<string> choices = panel->
GetChoices(allow_other);
976 SetChoices(choices, values);
980 template <
typename T>
984 if (field_name_panel)
989 string field_name = field_name_panel->
GetFieldName(
false);
990 vector<string> text_constraint;
992 text_constraint.push_back(
label);
994 text_constraint.push_back(GetTextConstraint(field, num));
995 return make_pair(GetDescription(field_name),
NStr::Join(text_constraint,
" AND "));
1000 template<
typename T>
1003 vector<CFuncWithArgs> functions;
1006 if (!field_name_panel)
1012 string match_text = x_GetMatchText();
1015 int sel = m_ConstraintType->GetSelection();
1018 switch (m_MatchType->GetSelection()) {
1019 case eMatchType_Contains:
1020 fn.
m_FName = macro::CMacroFunction_StringConstraints::sm_Contain;
1022 case eMatchType_DoesNotContain:
1023 fn.
m_FName = macro::CMacroFunction_StringConstraints::sm_Contain;
1026 case eMatchType_Equals:
1027 fn.
m_FName = macro::CMacroFunction_StringConstraints::sm_Equal;
1029 case eMatchType_DoesNotEqual:
1030 fn.
m_FName = macro::CMacroFunction_StringConstraints::sm_Equal;
1033 case eMatchType_StartsWith:
1034 fn.
m_FName = macro::CMacroFunction_StringConstraints::sm_Start;
1036 case eMatchType_DoesNotStartWith:
1037 fn.
m_FName = macro::CMacroFunction_StringConstraints::sm_Start;
1040 case eMatchType_EndsWith:
1041 fn.
m_FName = macro::CMacroFunction_StringConstraints::sm_End;
1043 case eMatchType_DoesNotEndWith:
1044 fn.
m_FName = macro::CMacroFunction_StringConstraints::sm_End;
1047 case eMatchType_IsOneOf:
1048 fn.
m_FName = macro::CMacroFunction_StringConstraints::sm_InList;
1050 case eMatchType_IsNotOneOf:
1051 fn.
m_FName = macro::CMacroFunction_StringConstraints::sm_InList;
1058 if (!fn.
m_FName.empty() && !match_text.empty()) {
1067 if (!m_SynonymFile.empty() && m_SynonymList && m_SynonymList->IsSet()) {
1070 for (
const auto& ws : m_SynonymList->Get()) {
1077 functions.push_back(fn);
1080 if (m_AllUpper->GetValue()) {
1082 fn.
m_FName = macro::CMacroFunction_StringConstraints::sm_Upper;
1084 functions.push_back(fn);
1086 if (m_AllLower->GetValue()) {
1088 fn.
m_FName = macro::CMacroFunction_StringConstraints::sm_Lower;
1090 functions.push_back(fn);
1092 if (m_AllPunct->GetValue()) {
1094 fn.
m_FName = macro::CMacroFunction_StringConstraints::sm_Punct;
1096 functions.push_back(fn);
1099 else if (sel == 1 || sel == 2) {
1101 fn.
m_FName = macro::CMacroFunction_IsPresent::GetFuncName();
1106 functions.push_back(fn);
1108 else if (sel == 3) {
1110 fn.
m_FName = macro::CMacroFunction_InTable::GetFuncName();
1114 functions.push_back(fn);
1120 template <
typename T>
1125 match_text =
ToStdString(m_MatchText->GetValue());
1128 match_text =
ToStdString(m_MatchChoice->GetValue());
1135 template <
typename T>
1139 if (field_name_panel)
1141 string field = field_name_panel->
GetMacroFieldName(target.first, target.second);
1147 template <
typename T>
1150 int constraint_sel = m_ConstraintType->GetSelection();
1151 if (constraint_sel == 1)
1152 return field +
" is present";
1153 if (constraint_sel == 2)
1154 return field +
" is not present";
1155 if (constraint_sel == 3)
1156 return field +
" is used as identifier";
1159 string match_text = x_GetMatchText();
1161 if (!match_text.empty()) {
1162 switch(m_MatchType->GetSelection()) {
1163 case eMatchType_Contains:
1166 case eMatchType_DoesNotContain:
1167 str =
"does not contain ";
1169 case eMatchType_Equals:
1172 case eMatchType_DoesNotEqual:
1173 str =
"does not equal ";
1175 case eMatchType_StartsWith:
1176 str =
"starts with ";
1178 case eMatchType_EndsWith:
1181 case eMatchType_IsOneOf:
1184 case eMatchType_IsNotOneOf:
1185 str =
"is not one of ";
1187 case eMatchType_DoesNotStartWith:
1188 str =
"does not start with ";
1190 case eMatchType_DoesNotEndWith:
1191 str =
"does not ends with ";
1197 str +=
"'" + match_text +
"' ";
1199 vector<string> subs;
1200 if (!m_IgnoreCase->GetValue())
1201 subs.push_back(
"case-sensitive");
1203 if (m_IgnoreSpace->GetValue())
1204 subs.push_back(
"ignore spaces");
1206 if (m_IgnorePunct->GetValue())
1207 subs.push_back(
"ignore punctuation");
1209 if (m_WholeWord->GetValue())
1210 subs.push_back(
"whole word");
1212 if (m_IgnoreSyn->GetValue())
1213 subs.push_back(
"ignore 'putative' synonyms");
1215 if (!subs.empty()) {
1217 str +=
"(" + sub +
")";
1220 if (m_SynonymList && m_SynonymList->IsSet()) {
1221 for (
const auto& ws : m_SynonymList->Get()) {
1229 if (m_AllUpper->GetValue())
1230 sub =
"all letters are upper case";
1232 if (m_AllLower->GetValue())
1233 sub =
"all letters are lower case";
1235 if (m_AllPunct->GetValue())
1236 sub =
"all characters are punctiation";
1245 return field +
" " +
str;
1248 template <
typename T>
1256 int constraint_sel = m_ConstraintType->GetSelection();
1257 if (constraint_sel == 1)
1258 return macro::CMacroFunction_IsPresent::GetFuncName() +
"(" + field +
")";
1259 if (constraint_sel == 2)
1260 return "NOT " + macro::CMacroFunction_IsPresent::GetFuncName() +
"(" + field +
")";
1261 if (constraint_sel == 3) {
1262 if (m_Tablename->IsShown() && !m_Tablename->IsEmpty()) {
1263 string filename =
"\"" +
ToStdString(m_Tablename->GetValue()) +
"\"";
1264 string func = macro::CMacroFunction_InTable::GetFuncName();
1265 func +=
"(" + field +
", " + filename +
", " +
ToStdString(m_Column->GetValue()) +
", \"\\t\")";
1272 string match_text = x_GetMatchText();
1273 auto selection = m_MatchType->GetSelection();
1275 if (!match_text.empty()) {
1277 case eMatchType_Contains:
1278 str = macro::CMacroFunction_StringConstraints::sm_Contain;
1280 case eMatchType_DoesNotContain:
1281 str =
"NOT " +
CTempString(macro::CMacroFunction_StringConstraints::sm_Contain);
1283 case eMatchType_Equals:
1284 str = macro::CMacroFunction_StringConstraints::sm_Equal;
1286 case eMatchType_DoesNotEqual:
1287 str =
"NOT " +
CTempString(macro::CMacroFunction_StringConstraints::sm_Equal);
1289 case eMatchType_StartsWith:
1290 str = macro::CMacroFunction_StringConstraints::sm_Start;
1292 case eMatchType_EndsWith:
1293 str = macro::CMacroFunction_StringConstraints::sm_End;
1295 case eMatchType_DoesNotStartWith:
1296 str =
"NOT " +
CTempString(macro::CMacroFunction_StringConstraints::sm_Start);
1298 case eMatchType_DoesNotEndWith:
1299 str =
"NOT " +
CTempString(macro::CMacroFunction_StringConstraints::sm_End);
1304 string case_sensitive = (!m_IgnoreCase->GetValue()) ?
"true" :
"false";
1305 string ignore_space = (m_IgnoreSpace->GetValue()) ?
"true" :
"false";
1306 string ignore_punctuation = (m_IgnorePunct->GetValue()) ?
"true" :
"false";
1307 string whole_word = (m_WholeWord->GetValue()) ?
"true" :
"false";
1308 string ignore_weasel = (m_IgnoreSyn->GetValue()) ?
"true" :
"false";
1311 string match_var = x_GetVariable();
1313 str +=
"(" + field +
"," + match_var + num_str +
"," + case_sensitive +
",";
1314 str += ignore_space +
"," + ignore_punctuation +
"," + whole_word +
"," + ignore_weasel;
1316 if (m_SynonymList && m_SynonymList->IsSet()) {
1317 str +=
", \"" + m_SynonymFile +
"\"";
1319 for (
const auto& it : m_SynonymList->Get()) {
1320 const string& word = it->GetWord();
1322 str +=
", " + match_var + num_str;
1337 (selection == eMatchType_IsOneOf || selection == eMatchType_IsNotOneOf)) {
1338 vector<string> tokens;
1340 if (tokens.size() > 1) {
1341 if (selection == eMatchType_IsOneOf) {
1342 str = field +
" IN (";
1344 else if (selection == eMatchType_IsNotOneOf) {
1345 str = field +
" NOT IN (";
1348 for (
auto& it : tokens) {
1349 str +=
"\"" + it +
"\", ";
1360 if (m_AllUpper->GetValue())
1361 sub =
CTempString(macro::CMacroFunction_StringConstraints::sm_Upper) +
"(" + field +
")";
1363 if (m_AllLower->GetValue())
1364 sub =
CTempString(macro::CMacroFunction_StringConstraints::sm_Lower) +
"(" + field +
")";
1366 if (m_AllPunct->GetValue())
1367 sub =
CTempString(macro::CMacroFunction_StringConstraints::sm_Punct) +
"(" + field +
")";
1378 template <
typename T>
1385 string match_text = x_GetMatchText();
1386 if (!match_text.empty()) {
1387 string match_var = x_GetVariable();
1388 if (!match_var.empty()) {
1389 vars.push_back(match_var + num_str +
" = %" + match_text +
"%");
1391 if (m_SynonymList && m_SynonymList->IsSet()) {
1393 for (
const auto& it : m_SynonymList->Get()) {
1394 const string& word = it->GetWord();
1406 template <
typename T>
1410 switch (m_MatchType->GetSelection()) {
1411 case eMatchType_Contains:
1412 match_var =
"contains";
1414 case eMatchType_DoesNotContain:
1415 match_var =
"not_contains";
1417 case eMatchType_Equals:
1418 match_var =
"equals";
1420 case eMatchType_DoesNotEqual:
1421 match_var =
"not_equals";
1423 case eMatchType_StartsWith:
1424 match_var =
"starts";
1426 case eMatchType_EndsWith:
1429 case eMatchType_DoesNotStartWith:
1430 match_var =
"not_starts";
1432 case eMatchType_DoesNotEndWith:
1433 match_var =
"not_ends";
1441 template <
typename T>
1445 auto it = m_choice_to_value.find(
orig);
1446 if (it != m_choice_to_value.end())
1451 template <
typename T>
1459 template <
typename T>
1462 m_SynonymFile = filename;
1463 m_SynonymList = word_subst;
1466 template <
typename T>
1469 m_panel->SetFieldName(field);
1472 template <
typename T>
1479 if (match_it != args.end()) {
1481 m_MatchText->SetValue(wxString(match_it->second));
1483 m_MatchChoice->SetValue(wxString(match_it->second));
1504 if (!
NStr::EndsWith(m_SynonymFile,
"/synonyms.txt") && m_SynonymFile !=
"synonyms.txt") {
1505 if (!wxFileExists(
ToWxString(m_SynonymFile))) {
1506 NcbiErrorBox(
"Constraint using the word substitution file '" + m_SynonymFile +
1507 "' cannot be opened as the file does not exist.");
1511 macro::CMacroLib::GetInstance().StoreSynonymList(m_SynonymFile);
1520 while (args.count(fieldname) > 0) {
1522 ws->SetWord(args.at(fieldname));
1524 ws->SetSynonyms() = macro::CMacroLib::GetInstance().GetSynonymListForPhrase(m_SynonymFile, ws->GetWord());
1527 if (args.count(fieldname)) {
1531 if (args.count(fieldname)) {
1535 m_SynonymList->Set().push_back(ws);
1544 template <
typename T>
1548 const auto& args = fn_it.m_FArgs;
1549 const string& fn_name = fn_it.m_FName;
1550 if (
NStr::EqualNocase(fn_name, macro::CMacroFunction_StringConstraints::sm_Contain)) {
1551 m_ConstraintType->SetSelection(0);
1552 EnableStringConstraint(
true);
1553 if (fn_it.m_Negate) {
1554 m_MatchType->SetSelection(eMatchType_DoesNotContain);
1557 m_MatchType->SetSelection(eMatchType_Contains);
1559 x_SetControls(args);
1561 else if (
NStr::EqualNocase(fn_name, macro::CMacroFunction_StringConstraints::sm_Equal)) {
1562 m_ConstraintType->SetSelection(0);
1563 EnableStringConstraint(
true);
1564 if (fn_it.m_Negate) {
1565 m_MatchType->SetSelection(eMatchType_DoesNotEqual);
1568 m_MatchType->SetSelection(eMatchType_Equals);
1570 x_SetControls(args);
1572 else if (
NStr::EqualNocase(fn_name, macro::CMacroFunction_StringConstraints::sm_Start)) {
1573 m_ConstraintType->SetSelection(0);
1574 EnableStringConstraint(
true);
1575 if (fn_it.m_Negate) {
1576 m_MatchType->SetSelection(eMatchType_DoesNotStartWith);
1579 m_MatchType->SetSelection(eMatchType_StartsWith);
1581 x_SetControls(args);
1583 else if (
NStr::EqualNocase(fn_name, macro::CMacroFunction_StringConstraints::sm_End)) {
1584 m_ConstraintType->SetSelection(0);
1585 EnableStringConstraint(
true);
1586 if (fn_it.m_Negate) {
1587 m_MatchType->SetSelection(eMatchType_DoesNotEndWith);
1590 m_MatchType->SetSelection(eMatchType_EndsWith);
1592 x_SetControls(args);
1594 else if (
NStr::EqualNocase(fn_name, macro::CMacroFunction_StringConstraints::sm_InList)) {
1595 m_ConstraintType->SetSelection(0);
1596 EnableStringConstraint(
true);
1597 if (fn_it.m_Negate) {
1598 m_MatchType->SetSelection(eMatchType_IsNotOneOf);
1601 m_MatchType->SetSelection(eMatchType_IsOneOf);
1603 x_SetControls(args);
1605 else if (
NStr::EqualNocase(fn_name, macro::CMacroFunction_IsPresent::GetFuncName())) {
1608 int sel = (fn_it.m_Negate) ? 2 : 1;
1609 m_ConstraintType->SetSelection(sel);
1610 EnableStringConstraint(
false);
1612 else if (
NStr::EqualNocase(fn_name, macro::CMacroFunction_StringConstraints::sm_Upper)) {
1613 m_ConstraintType->SetSelection(0);
1614 EnableStringConstraint(
true);
1616 m_AllUpper->SetValue(
true);
1618 else if (
NStr::EqualNocase(fn_name, macro::CMacroFunction_StringConstraints::sm_Lower)) {
1619 m_ConstraintType->SetSelection(0);
1620 EnableStringConstraint(
true);
1622 m_AllLower->SetValue(
true);
1624 else if (
NStr::EqualNocase(fn_name, macro::CMacroFunction_StringConstraints::sm_Punct)) {
1625 m_ConstraintType->SetSelection(0);
1626 EnableStringConstraint(
true);
1628 m_AllPunct->SetValue(
true);
1630 else if (
NStr::EqualNocase(fn_name, macro::CMacroFunction_InTable::GetFuncName())) {
1631 m_ConstraintType->SetSelection(3);
1632 EnableStringConstraint(
false);
1633 m_TableSizer->ShowItems(
true);
1645 m_ConstraintType->SetSelection(0);
1646 EnableStringConstraint(
true);
1647 if (fn_it.m_Negate) {
1648 m_MatchType->SetSelection(eMatchType_IsNotOneOf);
1651 m_MatchType->SetSelection(eMatchType_IsOneOf);
1657 if (match_it != args.end()) {
1659 m_MatchText->SetValue(wxString(match_it->second));
1661 m_MatchChoice->SetValue(wxString(match_it->second));
1667 template <
typename T>
1676 template <
typename T>
1684 template <
typename T>
1692 template <
typename T>
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
static vector< string > GetFieldNames()
void ListPresentFeaturesFirst(objects::CSeq_entry_Handle seh, vector< const objects::CFeatListItem * > *featlist=nullptr)
void SetMacroFieldNames(const vector< string > &field_names)
void SetMacroSelf(const string &self)
void SetFieldNames(const vector< string > &field_names)
virtual string GetFieldName(const bool subfield=false)=0
Returns the name of the field as selected in the panel.
virtual string GetMacroFieldName(const string &target, const string &selected_field=kEmptyStr)
virtual vector< string > GetChoices(bool &allow_other)
virtual string GetMacroFieldLabel(const string &target, const string &selected_field=kEmptyStr)
static bool IsFeature(const string &target)
virtual vector< string > GetMacroValues()
Class to store one function as it appears in the macro and its arguments (as GUI fieldnames)
unordered_map< string, string > TInterpretedArgs
Map of control names and corresponding values. It may contain more 'arguments' than the function has.
string m_FName
Function name as it appears in the macro.
@ ID_MACROADDCONSTRAINTCHOICEBK
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &caption=_("Add Macro Constraint"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxMINIMIZE_BOX|wxMAXIMIZE_BOX|wxCLOSE_BOX|wxTAB_TRAVERSAL)
wxChoicebook * m_Notebook
wxBitmap GetBitmapResource(const wxString &name)
wxIcon GetIconResource(const wxString &name)
void OnAccept(wxCommandEvent &event)
vector< EMMatcherPanelType > m_MatchingTypes
pair< string, string > m_target
void SetAndUpdateConstraint(SMacroConstraint &constr)
void SetConstraint(const SMacroConstraint &constr)
void SetStringSelection(const string &sel)
void OnCancel(wxCommandEvent &event)
static bool ShowToolTips()
wxDECLARE_NO_COPY_CLASS(CMacroAdvStringConstraintPanel)
wxCheckBox * m_IgnoreCase
bool Create(wxWindow *parent, wxWindowID id=ID_CADVSTRINGCONSTRAINTPANEL, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL)
Creation.
void OnOpenFile(wxCommandEvent &event)
void OnClear(wxCommandEvent &event)
virtual void SetFieldName(const string &field)
map< string, string > m_choice_to_value
virtual void PopulateFeatureListbox(CSeq_entry_Handle seh)
void OnUpdateWordSubstButton(wxUpdateUIEvent &event)
wxCheckBox * m_IgnorePunct
virtual vector< CFuncWithArgs > GetFuncWithArgs(const pair< string, string > &target, size_t num) const
string x_GetMatchText() const
virtual void SetMatcher(const vector< CFuncWithArgs > &func_info)
virtual void SetFieldNames(const vector< string > &field_names)
wxRadioButton * m_AllLower
void CreateControls()
Creates the controls and sizers.
void SetMacroSelf(const string &self)
void ShowChoiceOrText(void)
void Init()
Initialises member variables.
wxComboBox * m_MatchChoice
string GetTextConstraint(const string &field, size_t num)
CRef< CWord_substitution_set > m_SynonymList
virtual string GetQualName(const pair< string, string > &target)
wxRadioButton * m_AllUpper
void EnableStringConstraint(bool enable)
string ReplaceChoices(const string &orig)
void OnWordSubstitution(wxCommandEvent &event)
static bool ShowToolTips()
Should we show tooltips?
void SetMacroFieldNames(const vector< string > &field_names)
~CMacroAdvStringConstraintPanel()
Destructor.
virtual void GetVars(vector< string > &vars, size_t num)
wxRadioBox * m_ConstraintType
void OnConstraintType(wxCommandEvent &event)
wxCheckBox * m_IgnoreSpace
void OnMatchTypeSelected(wxCommandEvent &event)
virtual void AddWordSubstSet(const string &filename, CRef< CWord_substitution_set > word_subst)
CMacroAdvStringConstraintPanel()
Constructors.
wxButton * m_WordSubstBtn
wxRadioButton * m_AnyLetters
string x_GetVariable() const
void SetChoices(const vector< string > &choices, const vector< string > &values)
wxRadioButton * m_AllPunct
@ ID_STRING_CONSTRAINT_MATCH_TEXT
@ ID_STRING_CONSTRAINT_CHECKBOX9
@ ID_STRING_CONSTRAINT_WORDSUBST_BUTTON
@ ID_STRING_CONSTRAINT_CHECKBOX8
@ ID_STRING_CONSTRAINT_RADIO3
@ ID_STRING_CONSTRAINT_RADIO1
@ ID_STRING_CONSTRAINT_RADIO2
@ ID_STRING_CONSTRAINT_CHECKBOX6
@ ID_STRING_CONSTRAINT_RADIO0
@ ID_STRING_CONSTRAINT_CHECKBOX7
@ ID_STRING_CONSTRAINT_CHECKBOX5
@ ID_STRING_CONSTRAINT_CLEAR_BUTTON
@ ID_STRING_CONSTRAINT_MATCH_CHOICE
@ ID_CONSTRAINT_TABLENAME
@ ID_CADVSTRINGCONSTRAINTPANEL
virtual pair< string, string > GetMatcher(const pair< string, string > &target, size_t num)
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
void x_SetControls(const CFuncWithArgs::TInterpretedArgs &args)
string GetDescription(const string &field)
wxFlexGridSizer * m_TableSizer
@ eMatchType_DoesNotEndWith
@ eMatchType_DoesNotContain
@ eMatchType_DoesNotStartWith
@ eMatchType_DoesNotEqual
virtual void UpdateEditor(void)
void AddConstraint(pair< string, string > item, int id, const vector< string > &vars=vector< string >(), const string &qual_name=kEmptyStr, EMMatcherPanelType panel_type=EMMatcherPanelType::eMMatcher_NotSet, const vector< CFuncWithArgs > &func_info=vector< CFuncWithArgs >())
virtual void GetVars(vector< string > &vars, size_t num)
virtual string GetQualName(const pair< string, string > &target)
virtual vector< CFuncWithArgs > GetFuncWithArgs(const pair< string, string > &target, size_t num) const
virtual pair< string, string > GetMatcher(const pair< string, string > &target, size_t num)=0
virtual void SetMatcher(const vector< CFuncWithArgs > &func_info)
static string GetDescription(const objects::CWord_substitution &ws)
void SetSubstitutionList(const CRef< objects::CWord_substitution_set > &subst_list)
static vector< string > GetStrings()
static vector< string > GetMacroFieldNames()
static vector< string > GetFieldNames()
static vector< string > GetMacroFieldNames()
static vector< string > GetMacroFieldNames(bool extended=false)
static vector< string > GetFieldNames(bool extended=false)
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
CWord_substitution_set –.
const char * kDefinitionLineLabel
static const char * str(char *buf, int n)
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#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)
void NcbiErrorBox(const string &message, const string &title="Error")
specialized Message Box function for reporting critical errors
string GetLabel(const CSeq_id &id)
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static bool StringToBool(const CTempString str)
Convert string to bool.
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 bool EndsWith(const CTempString str, const CTempString end, ECase use_case=eCase)
Check if a string ends with a specified suffix value.
static const string BoolToString(bool value)
Convert bool to string.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
static string Join(const TContainer &arr, const CTempString &delim)
Join strings using the specified delimiter.
static bool EqualCase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-sensitive equality of a substring with another string.
static string UIntToString(unsigned int value, TNumToStringFlags flags=0, int base=10)
Convert UInt to string.
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
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.
static const char label[]
where boath are integers</td > n< td ></td > n</tr > n< tr > n< td > tse</td > n< td > optional</td > n< td > String</td > n< td class=\"description\"> TSE option controls what blob is orig
#define SYMBOL_CADVSTRINGCONSTRAINTPANEL_STYLE
#define SYMBOL_CADVSTRINGCONSTRAINTPANEL_IDNAME
#define SYMBOL_CADVSTRINGCONSTRAINTPANEL_POSITION
#define SYMBOL_CADVSTRINGCONSTRAINTPANEL_SIZE
const string kComparisonOp
const string kConstr_IgnorePunct
const string kConstr_IgnoreWeasel
const string kConstr_SynCaseSens
const string kConstr_StrCaseSens
const string kConstr_SynFile
const string kConstr_WholeWord
const string kConstr_SynWholeWord
const string kConstr_SynMatch
const string kConstr_Match
const string kConstr_IgnoreSpace
void ReportUsage(const wxString &dialog_name, const string &action_name)
Report events in the macro_flow_editor and in the macro_editor.
const struct ncbi::grid::netcache::search::fields::SIZE size
static SLJIT_INLINE sljit_ins nr(sljit_gpr dst, sljit_gpr src)
vector< CFuncWithArgs > m_FuncInfo
interpreted functions with their arguments
string m_Fieldname
fieldname referred in the constraint
vector< string > m_Variables
variables used in the constraint
EMMatcherPanelType m_MatcherType
string m_Constraint
constraint expression, e.g., Strand() = "plus"
string m_Label
description of the constraint as it is listed in the macro editor
wxString GetAbsolutePath(const wxString &localpath)
wxString ToWxString(const string &s)
string ToStdString(const wxString &s)