46 #include <wx/statbox.h>
47 #include <wx/stattext.h>
48 #include <wx/textctrl.h>
49 #include <wx/choice.h>
51 #include <wx/valtext.h>
96 wxPanel::Create( parent,
id, pos,
size, style );
148 wxBoxSizer* itemBoxSizer1 =
new wxBoxSizer(wxVERTICAL);
149 itemPanel2->SetSizer(itemBoxSizer1);
151 wxStaticBox* itemStaticBoxSizer3Static =
new wxStaticBox(itemPanel2,
wxID_ANY,
_(
"Number of features on sequence"));
152 wxStaticBoxSizer* itemStaticBoxSizer4 =
new wxStaticBoxSizer(itemStaticBoxSizer3Static, wxHORIZONTAL);
153 itemBoxSizer1->Add(itemStaticBoxSizer4, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
156 itemStaticBoxSizer4->Add(
m_FeatureType, 0, wxALIGN_TOP|wxALL, 5);
157 objects::CSeq_entry_Handle seh;
161 wxArrayString countTypeStrings;
162 countTypeStrings.Add(
_(
"Exactly"));
163 countTypeStrings.Add(
_(
"Fewer than"));
164 countTypeStrings.Add(
_(
"Fewer than or equal to"));
165 countTypeStrings.Add(
_(
"More than"));
166 countTypeStrings.Add(
_(
"More than or equal to"));
167 m_FeatChoice =
new wxChoice( itemPanel2,
wxID_ANY, wxDefaultPosition, wxDefaultSize, countTypeStrings, 0 );
169 itemStaticBoxSizer4->Add(
m_FeatChoice, 0, wxALIGN_TOP|wxALL, 5);
171 m_FeatCount =
new wxTextCtrl( itemPanel2,
wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
172 itemStaticBoxSizer4->Add(
m_FeatCount, 0, wxALIGN_TOP|wxALL, 5);
173 m_FeatCount->SetValidator( wxTextValidator( wxFILTER_NUMERIC ) );
175 wxFlexGridSizer* itemFlexGridSizer5 =
new wxFlexGridSizer(0, 2, 0, 0);
176 itemBoxSizer1->Add(itemFlexGridSizer5, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
178 wxStaticText* itemStaticText6 =
new wxStaticText(itemPanel2, wxID_STATIC,
_(
"Length of sequence"), wxDefaultPosition, wxDefaultSize, 0);
179 itemFlexGridSizer5->Add(itemStaticText6, 0, wxALIGN_RIGHT | wxALL, 5);
181 wxBoxSizer* itemBoxSizer7 =
new wxBoxSizer(wxHORIZONTAL);
182 itemFlexGridSizer5->Add(itemBoxSizer7, 0, wxALIGN_LEFT, 0);
184 countTypeStrings.Insert(
"Any", 0);
187 itemBoxSizer7->Add(
m_LengthChoice, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
190 itemBoxSizer7->Add(
m_Length, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
191 m_Length->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
193 wxStaticText* itemStaticText8 =
new wxStaticText(itemPanel2, wxID_STATIC,
_(
"Sequence representation"), wxDefaultPosition, wxDefaultSize, 0);
194 itemFlexGridSizer5->Add(itemStaticText8, 0, wxALIGN_RIGHT | wxALL, 5);
196 wxArrayString seqReprStrings;
197 bool allow_other =
false;
200 seqReprStrings.Insert(
"Default", 0);
205 wxFlexGridSizer* itemFlexGridSizer8 =
new wxFlexGridSizer(0, 2, 0, 0);
206 itemBoxSizer1->Add(itemFlexGridSizer8, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
208 wxStaticText* itemStaticText9 =
new wxStaticText(itemPanel2, wxID_STATIC,
_(
"There are"), wxDefaultPosition, wxDefaultSize, 0);
209 itemFlexGridSizer8->Add(itemStaticText9, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxRIGHT, 5);
211 wxBoxSizer* itemBoxSizer10 =
new wxBoxSizer(wxHORIZONTAL);
212 itemFlexGridSizer8->Add(itemBoxSizer10, 0, wxALIGN_LEFT | wxALL, 0);
214 wxArrayString distancetypes;
215 distancetypes.Add(
_(
"Any distance"));
216 distancetypes.Add(
_(
"Exactly"));
217 distancetypes.Add(
_(
"At least"));
218 distancetypes.Add(
_(
"At most"));
221 itemBoxSizer10->Add(
m_Dist5EndChoice, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
223 m_5EndDistance =
new wxTextCtrl(itemPanel2,
wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
224 itemBoxSizer10->Add(
m_5EndDistance, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
228 wxStaticText* itemStaticText11 =
new wxStaticText(itemPanel2, wxID_STATIC,
_(
"nucleotides before the first"), wxDefaultPosition, wxDefaultSize, 0);
229 itemBoxSizer10->Add(itemStaticText11, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
236 wxStaticText* itemStaticText12 =
new wxStaticText(itemPanel2, wxID_STATIC,
_(
"There are"), wxDefaultPosition, wxDefaultSize, 0);
237 itemFlexGridSizer8->Add(itemStaticText12, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL |wxRIGHT, 5);
239 wxBoxSizer* itemBoxSizer13 =
new wxBoxSizer(wxHORIZONTAL);
240 itemFlexGridSizer8->Add(itemBoxSizer13, 0, wxALIGN_LEFT | wxALL, 0);
244 itemBoxSizer13->Add(
m_Dist3EndChoice, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
246 m_3EndDistance =
new wxTextCtrl(itemPanel2,
wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
247 itemBoxSizer13->Add(
m_3EndDistance, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
251 wxStaticText* itemStaticText14 =
new wxStaticText(itemPanel2, wxID_STATIC,
_(
"nucleotides after the last"), wxDefaultPosition, wxDefaultSize, 0);
252 itemBoxSizer13->Add(itemStaticText14, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
266 vector<string> features;
271 ITERATE(vector<const CFeatListItem *>, feat_it, featlist) {
274 int feat_type = item.
GetType();
276 types[pair<int, int>(feat_type, feat_subtype)] = desc;
277 if (existing.
find(desc) == existing.
end()) {
279 features.push_back(desc);
283 wxArrayString selected_features;
284 selected_features.push_back(
_(
"Any"));
285 bool show_legal_only =
false;
286 for (
size_t i = 1;
i < features.size(); ++
i) {
290 selected_features.push_back(
ToWxString(features[
i]));
294 return selected_features;
301 event.Enable(enable);
353 vector<CFuncWithArgs> functions;
358 fn.
m_FName = macro::CMacroFunction_NumberOfFeatures::GetFuncName();
368 functions.push_back(fn);
373 if (!
m_Length->GetValue().IsEmpty()) {
375 fn.
m_FName = macro::CMacroFunction_GetSequence::sm_SeqForFeat;
378 fn.
m_FName = macro::CMacroFunction_GetSequence::sm_SeqForDescr;
392 functions.push_back(fn);
398 if (repr_index > 0) {
400 fn.
m_FName = macro::CMacroFunction_GetSequence::sm_SeqForFeat;
403 fn.
m_FName = macro::CMacroFunction_GetSequence::sm_SeqForDescr;
409 string selected =
m_SeqReprChoice->GetString(repr_index).ToStdString();
414 functions.push_back(fn);
420 fn.
m_FName = macro::CMacroFunction_LocationDistConstraint::sm_FromStart;
432 functions.push_back(fn);
438 fn.
m_FName = macro::CMacroFunction_LocationDistConstraint::sm_FromStop;
450 functions.push_back(fn);
459 const auto& args = fn_it.m_FArgs;
460 if (
NStr::EqualNocase(fn_it.m_FName, macro::CMacroFunction_NumberOfFeatures::GetFuncName())) {
463 if (feat_type != args.end() && feat_count != args.end()) {
467 if (fn_it.m_ParentFnc ==
"=")
469 else if (fn_it.m_ParentFnc ==
"<")
471 else if (fn_it.m_ParentFnc ==
"<=")
473 else if (fn_it.m_ParentFnc ==
">")
475 else if (fn_it.m_ParentFnc ==
">=")
480 else if (
NStr::EqualNocase(fn_it.m_FName, macro::CMacroFunction_GetSequence::sm_SeqForFeat) ||
481 NStr::EqualNocase(fn_it.m_FName, macro::CMacroFunction_GetSequence::sm_SeqForDescr) ||
485 if (field != args.end() &&
count != args.end()) {
486 if (field->second ==
"inst.length") {
489 if (fn_it.m_ParentFnc ==
"=")
491 else if (fn_it.m_ParentFnc ==
"<")
493 else if (fn_it.m_ParentFnc ==
"<=")
495 else if (fn_it.m_ParentFnc ==
">")
497 else if (fn_it.m_ParentFnc ==
">=")
501 else if (field->second ==
"inst.repr") {
507 else if (
NStr::EqualNocase(fn_it.m_FName, macro::CMacroFunction_LocationDistConstraint::sm_FromStart)) {
510 if (feat_it != args.end() && dist_it != args.end()) {
516 if (fn_it.m_ParentFnc ==
"=")
518 else if (fn_it.m_ParentFnc ==
">=")
520 else if (fn_it.m_ParentFnc ==
"<=")
524 else if (
NStr::EqualNocase(fn_it.m_FName, macro::CMacroFunction_LocationDistConstraint::sm_FromStop)) {
527 if (feat_it != args.end() && dist_it != args.end()) {
533 if (fn_it.m_ParentFnc ==
"=")
535 else if (fn_it.m_ParentFnc ==
">=")
537 else if (fn_it.m_ParentFnc ==
"<=")
546 vector<string> constraints;
548 if (!
m_Length->GetValue().IsEmpty()) {
549 string length_asn =
"inst.length";
550 string str = length_asn;
552 str = macro::CMacroFunction_GetSequence::sm_SeqForFeat +
string(
"(\"" + length_asn +
"\")");
555 str = macro::CMacroFunction_GetSequence::sm_SeqForDescr +
string(
"(\"" + length_asn +
"\")");
558 string d =
m_Length->GetValue().ToStdString();
560 case 1:
str +=
" = " + d;
break;
561 case 2:
str +=
" < " + d;
break;
562 case 3:
str +=
" <= " + d;
break;
563 case 4:
str +=
" > " + d;
break;
564 case 5:
str +=
" >= " + d;
break;
565 default:
str.clear();
break;
568 constraints.push_back(
str);
572 if (repr_index > 0) {
573 string repr_asn =
"inst.repr";
574 string str = repr_asn;
576 str = macro::CMacroFunction_GetSequence::sm_SeqForFeat +
string(
"(\"" + repr_asn +
"\")");
579 str = macro::CMacroFunction_GetSequence::sm_SeqForDescr +
string(
"(\"" + repr_asn +
"\")");
586 constraints.push_back(
str);
592 string str = macro::CMacroFunction_NumberOfFeatures::GetFuncName();
593 str +=
"(\"" + feat +
"\")";
596 case 0:
str +=
" = " + d;
break;
597 case 1:
str +=
" < " + d;
break;
598 case 2:
str +=
" <= " + d;
break;
599 case 3:
str +=
" > " + d;
break;
600 case 4:
str +=
" >= " + d;
break;
601 default:
str.clear();
break;
604 constraints.push_back(
str);
608 string str = macro::CMacroFunction_LocationDistConstraint::sm_FromStart;
609 str +=
"(" +
string(macro::CMacroFunction_FirstOrLastItem::sm_First) +
"(";
610 str += macro::CMacroFunction_Features_For_Object::GetFuncName();
615 str +=
"(\"" + feature +
"\")))";
619 case 1:
str +=
" = " + d;
break;
620 case 2:
str +=
" >= " + d;
break;
621 case 3:
str +=
" <= " + d;
break;
622 default:
str.clear();
break;
626 constraints.push_back(
str);
630 string str = macro::CMacroFunction_LocationDistConstraint::sm_FromStop;
631 str +=
"(" +
string(macro::CMacroFunction_FirstOrLastItem::sm_Last) +
"(";
632 str += macro::CMacroFunction_Features_For_Object::GetFuncName();
637 str +=
"(\"" + feature +
"\")))";
641 case 1:
str +=
" = " + d;
break;
642 case 2:
str +=
" >= " + d;
break;
643 case 3:
str +=
" <= " + d;
break;
644 default:
str.clear();
break;
648 constraints.push_back(
str);
651 if (!constraints.empty()) {
659 vector<string> descriptions;
662 if (repr_index > 0) {
667 descriptions.push_back(
label);
670 if (!
m_Length->GetValue().IsEmpty()) {
671 string label =
"sequence length is ";
674 case 1:
label +=
"exactly ";
break;
675 case 2:
label +=
"fewer than ";
break;
676 case 3:
label +=
"fewer than or equal to ";
break;
677 case 4:
label +=
"more than ";
break;
678 case 5:
label +=
"more than or equal to ";
break;
682 descriptions.push_back(
label);
686 string label =
"the number of "+ feat +
" features on sequence is ";
689 case 0:
label +=
"exactly ";
break;
690 case 1:
label +=
"fewer than ";
break;
691 case 2:
label +=
"fewer than or equal to ";
break;
692 case 3:
label +=
"more than ";
break;
693 case 4:
label +=
"more than or equal to ";
break;
697 descriptions.push_back(
label);
701 string label =
"there are ";
704 case 1:
label +=
"exactly ";
break;
705 case 2:
label +=
"at least ";
break;
706 case 3:
label +=
"at most ";
break;
707 default:
label.clear();
break;
711 label +=
" nucleotides before the first ";
715 label += feature +
" ";
718 descriptions.push_back(
label);
722 string label =
"there are ";
725 case 1:
label +=
"exactly ";
break;
726 case 2:
label +=
"at least ";
break;
727 case 3:
label +=
"at most ";
break;
728 default:
label.clear();
break;
732 label +=
" nucleotides after the last ";
736 label += feature +
" ";
739 descriptions.push_back(
label);
742 if (!descriptions.empty()) {
CFeatListItem - basic configuration data for one "feature" type.
string GetDescription() const
virtual bool SetFieldName(const string &field)
virtual string GetFieldName(const bool subfield=false)
Returns the name of the field as selected in the panel.
static bool s_IsRarelyUsedOrDiscouragedFeatureType(int subtype)
void ListPresentFeaturesFirst(const objects::CSeq_entry_Handle &entry, vector< const objects::CFeatListItem * > *featlist=nullptr)
static bool IsDescriptor(const string &target)
static bool IsFeature(const string &target)
Class to store one function as it appears in the macro and its arguments (as GUI fieldnames)
string m_FName
Function name as it appears in the macro.
string GetGUIMolinfoValue(const string ¯o_field, const string &molinfo_field)
static CMacroEditorContext & GetInstance()
string GetAsnMolinfoValue(const string &molinfo_field, const string &choice)
wxChoice * m_Dist3EndChoice
void OnDistanceSelected(wxCommandEvent &event)
string GetLocationConstraint(const string &feat, const string &target)
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
void OnLengthTextCtrlUpdate(wxUpdateUIEvent &event)
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
string GetDescription(const string &feat) const
CFeatureTypePanel * m_FeatureType
virtual void SetMatcher(const vector< CFuncWithArgs > &func_info)
wxChoice * m_SeqReprChoice
wxTextCtrl * m_3EndDistance
~CMacroFeatsOnSeqPanel()
Destructor.
wxChoice * m_FirstFeatureChoice
wxChoice * m_LengthChoice
wxArrayString x_GetFeatureChoices()
wxChoice * m_Dist5EndChoice
virtual vector< CFuncWithArgs > GetFuncWithArgs(const pair< string, string > &target, size_t num) const
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL)
static bool ShowToolTips()
Should we show tooltips?
CMacroFeatsOnSeqPanel()
Constructors.
wxTextCtrl * m_5EndDistance
void CreateControls()
Creates the controls and sizers.
virtual pair< string, string > GetMatcher(const pair< string, string > &target, size_t num)
void Init()
Initialises member variables.
wxChoice * m_LastFeatureChoice
static string GetFieldName(EMolInfoFieldType field_type)
static vector< string > GetChoicesForField(CMolInfoFieldType::EMolInfoFieldType field_type, bool &allow_other)
const TLegalQualifiers & GetLegalQualifiers(void) const
Get a list of all the legal qualifiers for the feature.
static ESubtype SubtypeNameToValue(CTempString sName)
Turn a string into its ESubtype which is NOT necessarily related to the identifier of the enum.
static bool IsRegulatory(ESubtype subtype)
constexpr bool empty() const
iterator_bool insert(const value_type &val)
const_iterator find(const key_type &key) const
const_iterator end() const
IMPLEMENT_CLASS(CFloatingFrame, CFloatingFrameBaseClass) const static long kFloatFrameStyle
CFloatingFrame.
static const char * str(char *buf, int n)
static const struct type types[]
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
vector< const objects::CFeatListItem * > GetSortedFeatList(objects::CSeq_entry_Handle seh, size_t max=numeric_limits< size_t >::max())
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static string Join(const TContainer &arr, const CTempString &delim)
Join strings using the specified delimiter.
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 const char label[]
#define ID_MACRO_FEATS_DISTCHOICE2
#define ID_MACRO_FEATS_LENGTHTEXT
#define ID_MACRO_FEATS_DISTCHOICE1
#define ID_MACRO_FEATS_CHOICE
const string kComparisonOp
const string kConstr_FeatCount
const string kConstr_FeatType
const string kConstr_Match
const string kConstr_Distance
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
wxString ToWxString(const string &s)
void ToArrayString(const vector< string > &out, wxArrayString &in)