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

Go to the SVN repository for this file.

1 /* $Id: macro_edit_itemdata.cpp 46762 2021-10-01 14:01:55Z 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: Andrea Asztalos
27 
28  */
29 
30 
31 #include <ncbi_pch.hpp>
41 #include <wx/msgdlg.h>
42 
46 USING_SCOPE(macro);
47 
48 
49 namespace {
50 
51  string GetFindReplDescr(const CArgumentList& args)
52  {
53  string find_text;
54  for (auto& it : args[kFind].GetValue().get()) {
55  if (it == '"') {
56  find_text += "\\";
57  }
58  find_text += it;
59  }
60 
61  string descr = " replace '" + find_text + "'";
62  if (args[kCaseSens].IsTrue()) {
63  descr += " (case insensitive) ";
64  }
65  else {
66  descr += " (case sensitive) ";
67  }
68  descr += " with '" + args[kRepl].GetValue() + "'";
69  return descr;
70  }
71 }
72 
73 // CEditQualTreeItemData
75  : CMacroActionItemData(description, type)
76 {
77 }
78 
80 {
82 
83  vector<string> fieldnames = CMacroEditorContext::GetInstance().GetFieldNames(m_FieldType);
84  m_Panel->SetControlValues(kField, fieldnames);
85 }
86 
88 {
91  bool modified = (new_target != m_Target);
92  m_Target = new_target;
93  return modified;
94  }
95  return false;
96 }
97 
99 {
100  string descr = "Edit ";
102  descr += "publication ";
103  }
104  descr += m_ArgList[kField].GetValue();
105  return descr + GetFindReplDescr(m_ArgList);
106 }
107 
109 {
110  string variables;
111  variables += kFind + " = %" + m_ArgList[kFind].GetValue() + "%\n";
112  variables += kRepl + " = %" + m_ArgList[kRepl].GetValue() + "%\n";
113  variables += kLocation + " = \"" + m_ArgList[kLocation].GetValue() + "\"\n";
114  variables += kCaseSens + " = ";
115  if (m_ArgList[kCaseSens].IsTrue()) {
116  variables += "%false%";
117  }
118  else {
119  variables += "%true%";
120  }
121  variables += "\n" + kIsRegex + " = %" + m_ArgList[kIsRegex].GetValue() + "%";
122  return variables;
123 }
124 
126 {
127  string function;
128  const string& field = m_ArgList[kField].GetValue();
129  if (field.empty()) return function;
130 
132  if (NMacroUtil::IsStructVoucherPart(field)) {
133  string rt_var = "obj";
134  bool found_constraint = false;
135  function = NMItemData::GetResolveFuncForSVPart(field, rt_var, constraints, found_constraint);
136 
137  auto pos = field.find_last_of('-');
138  function += CMacroFunction_EditSubfield::GetFuncName();
139  function += "(\"" + NMItemData::GetEditableFieldForPair(field.substr(0, pos), rt_var, false) + "\", \"" + field.substr(pos + 1) + "\", ";
140  }
141  else if (NMItemData::MultipleValuesAllowed(path)) {
142  // place the constraint in the Do section
143  string rt_var = "obj";
144  function = NMItemData::GetResolveFuncForMultiValuedQual(path, rt_var, constraints, true);
145 
146  if (function.empty()) {
148  function += "(\"" + path + "\", ";
149  }
150  else {
152  function += "(" + rt_var + ", ";
153  }
154  }
155  else if (path.find(',') != NPOS) {
156  vector<string> tokens;
157  NStr::Split(path, ",", tokens);
158 
159  _ASSERT(tokens.size() == 2);
160  // it is either an orgmod or a soubsource modifier
161  string rt_var = "obj";
162  function = NMItemData::GetResolveFuncForQual(tokens[0], tokens[1], rt_var, constraints);
163 
165  function += "(\"" + NMItemData::GetEditableFieldForPair(field, rt_var, false) + "\", ";
166  }
168  string rt_var;
169  function = NMItemData::GetResolveFuncForPubQual(field, rt_var, constraints);
170 
172  function += "(" + rt_var + ", ";
173  }
175  string rt_var;
176  bool found_constraint = false;
177  function = NMItemData::GetResolveFuncForDBLink(m_ArgList[kField].GetValue(), rt_var, constraints, found_constraint);
179  if (found_constraint) {
180  function += "(" + rt_var + ", ";
181  }
182  else {
183  function += "(\"" + rt_var + ".data.strs\", ";
184  }
185  }
186  else {
188  function += "(\"" + CMacroEditorContext::GetInstance().GetAsnPathToFieldName(field, m_FieldType) + "\", ";
189  }
190 
193  }
194 
195  function += kFind + ", " + kRepl + ", " + kLocation + ", " + kCaseSens + ", " + kIsRegex + ");";
196  return function;
197 }
198 
200 {
201  vector<string> funcs{ CMacroFunction_Resolve::GetFuncName(),
202  CMacroFunction_EditSubfield::GetFuncName(),
204 
206  auto pub_fncs = x_GetPubFunctions();
207  funcs.reserve(funcs.size() + pub_fncs.size());
208  funcs.insert(funcs.end(), pub_fncs.begin(), pub_fncs.end());
209  }
210  return funcs;
211 }
212 
213 // CEditProteinQualTreeItemData
215  : CEditQualTreeItemData("Edit existing protein (CDS product) fields", EMacroFieldType::eProtein)
216 {
217 }
218 
220 {
222  args.push_back(GetOptionalArgs()[2]);
223  args.push_back(GetOptionalArgs()[6]);
224  x_LoadPanel(parent, "EditStringProteinQual", args);
225 
226  vector<string> fieldnames = CMacroEditorContext::GetInstance().GetFieldNames(m_FieldType);
227  m_Panel->SetControlValues(kField, fieldnames);
228 
229  m_Panel->GetArgumentList().Attach(NMItemData::OnProteinNameSingle);
230 }
231 
233 {
236  if (m_ArgList[kMoveToNote].GetEnabled() && m_ArgList[kMoveToNote].IsTrue()) {
237  descr += ", copy original protein name to CDS note";
238  }
239  return descr;
240 }
241 
243 {
244  string function;
245 
246  bool update_mrna = m_ArgList[kUpdatemRNA].GetEnabled() && m_ArgList[kUpdatemRNA].IsTrue();
247  bool move_to_note = m_ArgList[kMoveToNote].GetEnabled() && m_ArgList[kMoveToNote].IsTrue();
248 
251  if (move_to_note) {
252  function = CMacroFunction_CopyNameToCDSNote::GetFuncName();
253  function += "();\n";
254  }
255 
256  // place the constraint in the Do section
257  string rt_var = "obj";
258  string res_function = NMItemData::GetResolveFuncForMultiValuedQual(path, rt_var, constraints, !(update_mrna || move_to_note));
259 
260  if (res_function.empty()) {
262  function += "(\"" + path + "\", ";
263  }
264  else {
265  function += res_function;
267  function += "(" + rt_var + ", ";
268  }
269 
270  if (move_to_note || update_mrna) {
271  string new_constraint = CMacroFunction_StringConstraints::sm_Contain;
272  new_constraint += "(\"" + path + "\", " + kFind + ", " + kCaseSens + ")";
273  constraints.emplace_back("\"" + path + "\"", new_constraint);
274  }
275  }
276  else {
278  function += "(\"" + path + "\", ";
279  }
280 
281  function += kFind + ", " + kRepl + ", " + kLocation + ", " + kCaseSens + ", " + kIsRegex + ");";
282  NMItemData::AppendUpdatemRNAFnc(update_mrna, function);
283  return function;
284 
285 }
286 
288 {
289  return { CMacroFunction_Resolve::GetFuncName(),
290  CMacroFunction_CopyNameToCDSNote::GetFuncName(),
292  CMacroFunction_UpdatemRNAProduct::GetFuncName() };
293 }
294 
295 // CEditFeatQualTreeItemData
297  : CEditQualTreeItemData("Edit existing feature qualifiers", EMacroFieldType::eFeatQualifiers)
298 {
299 }
300 
302 {
303  TArgumentsVector args(GetOptionalArgs().begin(), GetOptionalArgs().begin() + 3);
304  copy(GetEditArgs().begin() + 1, GetEditArgs().end(), back_inserter(args));
305 
306  x_LoadPanel(parent, "EditStringQualFeature", args);
307 
308  vector<string> features = CMacroEditorContext::GetInstance().GetFeatureTypes();
309  m_Panel->SetControlValues(kFeatType, features);
310  vector<string> qualifiers = CMacroEditorContext::GetInstance().GetFeatQualifiers();
311  m_Panel->SetControlValues(kFeatQual, qualifiers);
312 
313  m_Panel->GetArgumentList().Attach(NMItemData::OnProteinNameSingle);
314 }
315 
317 {
319  bool modified = (new_target != m_Target);
320  m_Target = new_target;
321  m_SelectedField = m_ArgList[kFeatType].GetValue();
322  return modified;
323 }
324 
326 {
327  string descr = "Edit " + m_ArgList[kFeatType].GetValue() + " " + m_ArgList[kFeatQual].GetValue();
328  descr += GetFindReplDescr(m_ArgList);
330  return descr;
331 }
332 
334 {
336 
337  string function;
338  bool update_mrna = m_ArgList[kUpdatemRNA].GetEnabled() && m_ArgList[kUpdatemRNA].IsTrue();
341  // place the constraint in the Do section
342  string rt_var = "obj";
343  function = NMItemData::GetResolveFuncForMultiValuedQual(path, rt_var, constraints, !update_mrna);
344 
345  if (update_mrna) {
346  string new_constraint = CMacroFunction_StringConstraints::sm_Contain;
347  new_constraint += "(\"" + path + "\", " + kFind + ", " + kCaseSens + ")";
348  constraints.emplace_back("\"" + path + "\"", new_constraint);
349  }
350 
351  if (function.empty()) {
353  function += "(\"" + path + "\", ";
354  }
355  else {
357  function += "(" + rt_var + ", ";
358  }
359  }
360  else if (path.find(',') != NPOS) {
361  vector<string> tokens;
362  NStr::Split(path, ",", tokens);
363  _ASSERT(tokens.size() == 2);
364 
365  string rt_var = "obj";
366  if (!NStr::EqualNocase(m_ArgList[kFeatType].GetValue().get(), "gene") && CMacroEditorContext::s_IsGeneQualifier(tokens[1])) {
367  function = NMItemData::GetResolveFuncForGeneQuals(tokens[0], tokens[1], rt_var, constraints);
368 
370  function += "(" + rt_var + ", ";
371  }
372  else {
373  if (NMacroUtil::IsSatelliteSubfield(tokens[1])) {
374  function = NMItemData::GetResolveFuncForQual(tokens[0], m_ArgList[kFeatQual].GetValue(), rt_var, constraints);
375 
376  function += CMacroFunction_EditSubfield::GetFuncName();
377  function += "(\"" + NMItemData::GetEditableFieldForPair("satellite", rt_var, true) + "\", \"" + m_ArgList[kFeatQual].GetValue() + "\", ";
378  }
379  else if (NMacroUtil::IsMobileElementTSubfield(tokens[1])) {
380  function = NMItemData::GetResolveFuncForQual(tokens[0], m_ArgList[kFeatQual].GetValue(), rt_var, constraints);
381 
382  function += CMacroFunction_EditSubfield::GetFuncName();
383  function += "(\"" + NMItemData::GetEditableFieldForPair(kMobileElementTQual, rt_var, true) + "\", \"" + m_ArgList[kFeatQual].GetValue() + "\", ";
384  }
385  else {
386  function = NMItemData::GetResolveFuncForQual(tokens[0], tokens[1], rt_var, constraints);
387 
389  function += "(\"" + NMItemData::GetEditableFieldForPair(m_ArgList[kFeatQual].GetValue(), rt_var, true) + "\", ";
390  }
391  }
392  }
393  else {
395  function += "(\"" + path + "\", ";
396  }
397 
398  function += kFind + ", " + kRepl + ", " + kLocation + ", " + kCaseSens + ", " + kIsRegex + ");";
399  NMItemData::AppendUpdatemRNAFnc(update_mrna, function);
400  return function;
401 }
402 
404 {
405  return { CMacroFunction_Resolve::GetFuncName(),
406  CMacroFunction_EditSubfield::GetFuncName(),
408  CMacroFunction_GeneQual::GetFuncName(),
409  CMacroFunction_UpdatemRNAProduct::GetFuncName() };
410 }
411 
412 // CEditRNAQualTreeItemData
414  : CEditQualTreeItemData("Edit existing RNA qualifiers", EMacroFieldType::eRNA)
415 {
416 }
417 
419 {
421  args.push_back(GetOptionalArgs()[3]);
422  args.push_back(GetOptionalArgs()[4]);
423  x_LoadPanel(parent, "EditStringRNAQual", args);
424 
425  vector<string> rnas = CMacroEditorContext::GetInstance().GetRNATypes();
426  m_Panel->SetControlValues(kRNAType, rnas);
427  m_Panel->SetSelection(kRNAType, 0);
428  vector<string> class_types = CMacroEditorContext::GetInstance().GetncRNAClassTypes();
429  m_Panel->SetControlValues(kncRNAClass, class_types);
430  vector<string> fieldnames = CMacroEditorContext::GetInstance().GetFieldNames(m_FieldType);
431  m_Panel->SetControlValues(kField, fieldnames);
432 
433  m_Panel->GetArgumentList().Attach(NMItemData::OnRnaTypeChanged);
434 }
435 
437 {
439  bool modified = (new_target != m_Target);
440  m_Target = new_target;
441  m_SelectedField = m_ArgList[kRNAType].GetValue();
442  return modified;
443 }
444 
446 {
447  string descr = "Edit";
448  if (m_ArgList[kncRNAClass].GetEnabled() && !m_ArgList[kncRNAClass].Empty()) {
449  descr += " " + m_ArgList[kncRNAClass].GetValue();
450  }
451  descr += " " + m_ArgList[kRNAType].GetValue() + " " + m_ArgList[kField].GetValue();
452  descr += GetFindReplDescr(m_ArgList);
453  return descr;
454 }
455 
457 {
458  if (m_ArgList[kField].Empty())
459  return kEmptyStr;
460 
462 
463  string function;
464  string field = m_ArgList[kField].GetValue();
465  if (m_ArgList[kRNAType].GetValue().get() == "tRNA" && NMacroUtil::StringsAreEquivalent(field, "codons recognized")) {
466  return function;
467  }
468 
469  if (NStr::StartsWith(field, "gene")) {
471  NMItemData::WrapInQuotes(gene_field);
473  function += "(\"gene\", " + gene_field + ", ";
474  }
475  else {
476  string path = CMacroEditorContext::GetInstance().GetAsnPathToFieldName(m_ArgList[kRNAType].GetValue() + " " + field, m_FieldType);
477  if (path.find(',') != NPOS) {
478  vector<string> tokens;
479  NStr::Split(path, ",", tokens);
480 
481  _ASSERT(tokens.size() == 2);
482  string rt_var = "obj";
483  function = NMItemData::GetResolveFuncForQual(tokens[0], tokens[1], rt_var, constraints);
484 
486  function += "(\"" + NMItemData::GetEditableFieldForPair(tokens[1], rt_var, true) + "\", ";
487  }
488  else {
490  function += "(\"" + path + "\", ";
491  }
492  }
493 
494  function += kFind + ", " + kRepl + ", " + kLocation + ", " + kCaseSens + ", " + kIsRegex + ");";
495  return function;
496 }
497 
499 {
501  CMacroFunction_Resolve::GetFuncName(),
503  };
504 }
505 
506 // CEditStrCommQualTreeItemData
508  : CEditQualTreeItemData("Edit existing structured comment fields", EMacroFieldType::eStructComment)
509 {
510 }
511 
513 {
515  args.push_back(GetOptionalArgs()[5]);
516  x_LoadPanel(parent, "EditStringStrCommQual", args);
517 
518  vector<string> fieldnames = CMacroEditorContext::GetInstance().GetFieldNames(m_FieldType);
519  m_Panel->SetControlValues(kField, fieldnames);
520  m_Panel->SetSelection(kField, 0);
521 
522  m_Panel->GetArgumentList().Attach(NMItemData::OnStructCommFieldChanged);
523 }
524 
526 {
527  string descr = "Edit " + NMItemData::GetStructCommQualDescr(m_ArgList);
528  return descr + GetFindReplDescr(m_ArgList);
529 }
530 
532 {
533  string field_name = (m_ArgList[kStrCommField].GetShown()) ? m_ArgList[kStrCommField].GetValue() : kEmptyStr;
534  string rt_var = "obj";
535  string function = NMItemData::GetResolveFuncForStrCommQual(m_ArgList[kField].GetValue(), field_name, rt_var, constraints);
536 
537 
539  if (NStr::EqualNocase(m_ArgList[kField].GetValue().get(), "Field name")) {
540  function += "(\"" + rt_var + ".label.str\", ";
541  }
542  else {
543  function += "(\"" + rt_var + ".data.str\", ";
544  }
545 
546  function += kFind + ", " + kRepl + ", " + kLocation + ", " + kCaseSens + ", " + kIsRegex + ");";
547  return function;
548 }
549 
551 {
552  return { CMacroFunction_Resolve::GetFuncName(), CMacroFunction_EditStringQual::GetFuncName() };
553 }
554 
555 
556 namespace {
557 
558  string GetDescrForSeqType(const string& apply_seq)
559  {
560  string descr;
561  if (NStr::EqualNocase(apply_seq, "any sequence")) {
562  descr = "any";
563  }
564  else {
565  descr = apply_seq;
566  NStr::ToLower(descr);
567  }
568 
569  descr = " where sequence type is " + descr;
570  return descr;
571  }
572 }
573 
575  : CMacroActionItemData("Edit multiple molinfo fields at once", EMacroFieldType::eMolinfo)
576 {
577 }
578 
580 {
582 
583  vector<EMacroFieldType> types
590  };
591 
592  vector<string> fieldnames;
593  size_t index = 0;
594  for (auto& it : types) {
596 
597  fieldnames.insert(fieldnames.begin(), "Any");
598  m_Panel->SetControlValues(m_Args[index]->GetName(), fieldnames);
599  m_Panel->SetSelection(m_Args[index]->GetName(), 0);
600  fieldnames[0] = "No change";
601  m_Panel->SetControlValues(m_Args[++index]->GetName(), fieldnames);
602  m_Panel->SetSelection(m_Args[index]->GetName(), 0);
603  ++index;
604  }
605 }
606 
608 {
610  const string& target = m_ArgList[kApplySeq].GetValue();
611  if (NStr::EqualNocase(target, "Any sequence")) {
612  new_target = CMacroBioData::sm_Seq;
613  }
614  else if (NStr::EqualNocase(target, "proteins")) {
615  new_target = CMacroBioData::sm_SeqAa;
616  }
617 
618  bool modified = (new_target != m_Target);
619  m_Target = new_target;
620  return modified;
621 }
622 
624 {
625  string descr;
626  x_GetDescrChangeTo("molecule", kMolFrom, kMolTo, descr);
627  x_GetDescrChangeTo("technique", kTechFrom, kTechTo, descr);
628  x_GetDescrChangeTo("completedness", kComplFrom, kComplTo, descr);
629  x_GetDescrChangeTo("class", kClassFrom, kClassTo, descr);
630  x_GetDescrChangeTo("topology", kTopFrom, kTopTo, descr);
631  x_GetDescrChangeTo("strand", kStrandFrom, kStrandTo, descr);
632 
633  if (!descr.empty()) {
634  x_GetDescrChangeFrom("molecule", kMolFrom, kMolTo, descr);
635  x_GetDescrChangeFrom("technique", kTechFrom, kTechTo, descr);
636  x_GetDescrChangeFrom("completedness", kComplFrom, kComplTo, descr);
637  x_GetDescrChangeFrom("class", kClassFrom, kClassTo, descr);
638  x_GetDescrChangeFrom("topology", kTopFrom, kTopTo, descr);
639  x_GetDescrChangeFrom("strand", kStrandFrom, kStrandTo, descr);
640  }
641  descr += GetDescrForSeqType(m_ArgList[kApplySeq].GetValue());
642  descr[0] = toupper((unsigned char)descr[0]);
643  return descr;
644 }
645 
646 void CEditMolinfoFieldsTreeItemData::x_GetDescrChangeTo(const string& field, const CTempString& from, const CTempString& to, string& change_to) const
647 {
648  if (m_ArgList[to].GetValue() == "No change")
649  return;
650  if (m_ArgList[from].Empty() && m_ArgList[to].Empty())
651  return;
652 
653  string to_value = m_ArgList[to].GetValue();
654  if (to_value == " ") {
655  to_value = "unknown/not-set";
656  }
657  if (!change_to.empty()) {
658  change_to += " and ";
659  }
660  if (change_to.find("change") == NPOS) {
661  change_to += "change ";
662  }
663  change_to += "to " + field + " " + to_value;
664 }
665 
666 void CEditMolinfoFieldsTreeItemData::x_GetDescrChangeFrom(const string& field, const CTempString& from, const CTempString& to, string& change_from) const
667 {
668  if (m_ArgList[to].GetValue() == "No change")
669  return;
670  if (m_ArgList[from].Empty() && m_ArgList[to].Empty())
671  return;
672 
673  if (m_ArgList[from].GetValue() != "Any") {
674  string from_value = m_ArgList[from].GetValue();
675  if (from_value == " ") {
676  from_value = "unknown/not-set";
677  }
678  if (change_from.find("where") != NPOS) {
679  change_from += " and ";
680  }
681  else {
682  change_from += " where ";
683  }
684  change_from += field + " is " + from_value;
685  }
686 }
687 
688 // It will always add a molinfo descriptor if there is not one already (Sequin)
690 {
691  const string& target = m_ArgList[kApplySeq].GetValue();
692  string new_constraint;
693  if (NStr::EqualNocase(target, "DNA")) {
695  new_constraint += "(\"inst.mol\", \"dna\")";
696  }
697  else if (NStr::EqualNocase(target, "RNA")) {
699  new_constraint += "(\"inst.mol\", \"rna\")";
700  }
701  if (!new_constraint.empty()) {
702  constraints.insert(constraints.begin(), { kEmptyStr, new_constraint });
703  }
704 
705  string function = x_GetFunctionFor("molecule", kMolFrom, kMolTo, constraints);
706  function += x_GetFunctionFor("technique", kTechFrom, kTechTo, constraints);
707  function += x_GetFunctionFor("completedness", kComplFrom, kComplTo, constraints);
708  function += x_GetFunctionFor("class", kClassFrom, kClassTo, constraints);
709  function += x_GetFunctionFor("topology", kTopFrom, kTopTo, constraints);
710  function += x_GetFunctionFor("strand", kStrandFrom, kStrandTo, constraints);
711  if (!function.empty()) function.pop_back();
712  return function;
713 }
714 
715 string CEditMolinfoFieldsTreeItemData::x_GetFunctionFor(const string& field, const CTempString& from, const CTempString& to, TConstraints& constraints) const
716 {
717  if (m_ArgList[to].GetValue() == "No change")
718  return kEmptyStr;
719  if (m_ArgList[from].Empty() && m_ArgList[to].Empty())
720  return kEmptyStr;
721 
722  string function = CMacroFunction_SetQual::GetFuncName();
723  function += "(\"" + CMacroEditorContext::GetInstance().GetAsnPathToFieldName(field, m_FieldType, m_Target) + "\", ";
724  function += "\"" + CMacroEditorContext::GetInstance().GetAsnMolinfoValue(field, m_ArgList[to].GetValue()) + "\");";
725  if (m_ArgList[from].GetValue() != "Any") {
726  string new_constraint = CMacroFunction_StringConstraints::sm_Equal;
727  new_constraint += "(\"" + CMacroEditorContext::GetInstance().GetAsnPathToFieldName(field, m_FieldType, m_Target) + "\", ";
728  new_constraint += "\"" + CMacroEditorContext::GetInstance().GetAsnMolinfoValue(field, m_ArgList[from].GetValue()) + "\")";
729  bool found = false;
730  if (field == "class") {
731  for (auto& it : constraints) {
732  if (NStr::EqualNocase(it.second, new_constraint)) {
733  found = true;
734  break;
735  }
736  }
737  }
738  if (!found) {
739  constraints.insert(constraints.begin(), { kEmptyStr, new_constraint });
740  }
741  }
742  function += "\n";
743  return function;
744 }
745 
747 {
749 }
virtual void x_AddParamPanel(wxWindow *parent)
virtual string GetFunction(TConstraints &constraints) const
virtual string GetMacroDescription() const
virtual vector< string > GetFunctionNames() const
void x_GetDescrChangeTo(const string &field, const CTempString &from, const CTempString &to, string &change_to) const
virtual void x_AddParamPanel(wxWindow *parent)
void x_GetDescrChangeFrom(const string &field, const CTempString &from, const CTempString &to, string &change_from) const
virtual vector< string > GetFunctionNames() const
virtual string GetMacroDescription() const
string x_GetFunctionFor(const string &field, const CTempString &from, const CTempString &to, TConstraints &constraints) const
virtual string GetFunction(TConstraints &constraints) const
virtual vector< string > GetFunctionNames() const
virtual string GetFunction(TConstraints &constraints) const
virtual void x_AddParamPanel(wxWindow *parent)
virtual string GetMacroDescription() const
CEditQualTreeItemData(const string &description, EMacroFieldType type)
virtual string GetMacroDescription() const
virtual void x_AddParamPanel(wxWindow *parent)
virtual string GetFunction(TConstraints &constraints) const
virtual vector< string > GetFunctionNames() const
virtual void x_AddParamPanel(wxWindow *parent)
virtual string GetFunction(TConstraints &constraints) const
virtual vector< string > GetFunctionNames() const
virtual string GetMacroDescription() const
virtual void x_AddParamPanel(wxWindow *parent)
virtual vector< string > GetFunctionNames() const
virtual string GetMacroDescription() const
virtual string GetFunction(TConstraints &constraints) const
EMacroFieldType m_FieldType
for actions such as appply/edit/etc.
vector< string > x_GetPubFunctions() const
static bool s_IsGeneQualifier(const string &field)
vector< string > GetFeatureTypes(bool for_removal=false, bool to_create=false, bool include_all=false) const
vector< string > GetRNATypes() const
string GetAsnPathToFieldName(const string &field, EMacroFieldType type, const string &target=kEmptyStr)
vector< string > GetncRNAClassTypes(bool include_any=true) const
static CMacroEditorContext & GetInstance()
vector< string > GetFeatQualifiers() const
string GetAsnMolinfoValue(const string &molinfo_field, const string &choice)
vector< string > GetFieldNames(EMacroFieldType type) const
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
Definition: tempstr.hpp:65
void x_LoadPanel(wxWindow *parent, const string &panel_name, const TArgumentsVector &arguments)
unique_ptr< CMacroPanelLoader > m_Panel
constructed panel for specifying function arguments
vector< pair< string, string > > TConstraints
const char * kLocation
bool Empty(const CNcbiOstrstream &src)
Definition: fileutil.cpp:523
static const struct type types[]
Definition: type.c:22
static const char * sm_SeqAa
bool StringsAreEquivalent(const string &name1, const string &name2)
Definition: macro_util.cpp:397
static const char * sm_SeqNa
bool IsStructVoucherPart(const string &field)
Definition: macro_util.cpp:826
static CTempString GetFuncName()
static CTempString GetFuncName()
bool IsSatelliteSubfield(const string &field)
Definition: macro_util.cpp:903
bool IsMobileElementTSubfield(const string &field)
Definition: macro_util.cpp:908
const char * kMobileElementTQual
Definition: macro_util.cpp:937
static const char * sm_FunctionName
EditRelatedFeatureQual(feat_type, field_name, find_text, repl_text, location, case_sensitive,...
static const char * sm_Seq
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define kEmptyStr
Definition: ncbistr.hpp:123
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.
Definition: ncbistr.cpp:3461
#define NPOS
Definition: ncbistr.hpp:133
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
Definition: ncbistr.hpp:5412
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
Definition: ncbistr.hpp:5353
static string & ToLower(string &str)
Convert string to lower case – string& version.
Definition: ncbistr.cpp:405
vector< macro::SArgMetaData > TArgumentsVector
USING_SCOPE(objects)
CTempString UpdateTargetForFeatures(const string &feature, const string &qualifier, bool for_removal=false)
string GetResolveFuncForDBLink(const string &field, string &rt_var, TConstraints &constraints, bool &found_constraint)
void OnStructCommFieldChanged(CArgumentList &list, CArgument &arg)
bool MultipleValuesAllowed(const string &field)
void UpdateConstraintsForFeatures(TConstraints &constraints, const string &feature)
string GetStructCommQualDescr(const CArgumentList &arg_list)
string GetResolveFuncForSVPart(const string &field, const string &rt_var, TConstraints &constraints, bool &found_constraint)
string GetResolveFuncForMultiValuedQual(const string &field, const string &rt_var, TConstraints &constraints, bool remove_constraint)
string GetResolveFuncForQual(const string &container, const string &field, const string &rt_var, TConstraints &constraints, bool remove_constraint=true)
Generates the definition of rt_var based on input "field".
string GetUpdatemRNADescription(const CArgument &arg)
void OnProteinNameSingle(CArgumentList &list, CArgument &arg)
CTempString UpdateTargetForMolinfo(const string &molinfo_type)
string GetResolveFuncForGeneQuals(const string &container, const string &field, const string &rt_var, TConstraints &constraints, bool remove_constraint=true)
CTempString UpdateTargetForRnas(const string &rna_type)
void WrapInQuotes(string &str)
string GetEditableFieldForPair(const string &field, const string &rt_var, bool is_feature)
string GetResolveFuncForStrCommQual(const string &field, const string &field_name, const string &rt_var, TConstraints &constraints)
void OnRnaTypeChanged(CArgumentList &list, CArgument &arg)
void UpdateConstraintsForRnas(TConstraints &constraints, const CArgumentList &arg_list)
void UpdateConstraintsForMisc(TConstraints &constraints, const string &fieldname, const string &target)
string GetResolveFuncForPubQual(const string &field, string &rt_var, TConstraints &constraints)
void AppendUpdatemRNAFnc(bool update_mrna, string &function)
const string kRepl
const string kStrandFrom
const string kMoveToNote
const string kStrandTo
const string kApplySeq
const string kTechTo
const string kFeatQual
const string kField
const string kCaseSens
const string kFind
const string kIsRegex
const string kComplFrom
const string kClassTo
const string kRNAType
const string kTechFrom
const string kncRNAClass
const TArgumentsVector & GetOptionalArgs()
const string kFeatType
const string kComplTo
const string kMolFrom
const string kUpdatemRNA
const string kTopFrom
const TArgumentsVector & GetEditArgs()
const string kMolTo
const TArgumentsVector & GetEditMolinfoArgs()
const string kStrCommField
const string kClassFrom
const string kTopTo
constexpr bool empty(list< Ts... >) noexcept
int toupper(Uchar c)
Definition: ncbictype.hpp:73
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
Definition: njn_matrix.hpp:613
Definition: type.c:6
#define _ASSERT
Modified on Wed Jun 12 11:16:39 2024 by modify_doxy.py rev. 669887