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

Go to the SVN repository for this file.

1 /* $Id: macro_rmv_itemdata.cpp 46836 2021-10-28 20:47: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>
38 
41 #include <wx/msgdlg.h>
42 
45 USING_SCOPE(macro);
47 
48 // CRmvQualTreeItemData
50  : CMacroActionItemData(description, type)
51 {
52 }
53 
55 {
57 
58  vector<string> fieldnames = CMacroEditorContext::GetInstance().GetFieldNames(m_FieldType);
59  m_Panel->SetControlValues(kField, fieldnames);
60 }
61 
63 {
66  bool modified = (new_target != m_Target);
67  m_Target = new_target;
68  return modified;
69  }
70  return false;
71 }
72 
74 {
75  string descr = "Remove ";
77  descr += "publication ";
78  }
79  descr += m_ArgList[kField].GetValue();
80  return descr;
81 }
82 
84 {
85  string function;
86  string field = m_ArgList[kField].GetValue();
87 
88  if (field.empty()) return function;
90 
92  if (field == "author name list") {
93  function = CMacroFunction_RemovePubAuthors::GetFuncName() + "();";
94  }
95  else if (field == "author middle initials") {
96  string rt_var = "obj";
98 
99  function += CMacroFunction_RemovePubAuthorMI::GetFuncName();
100  function += "(" + rt_var + ");";
101  } else if (field != "date") {
102  // TODO - handle removal of date
103  string rt_var;
104  function = NMItemData::GetResolveFuncForPubQual(field, rt_var, constraints);
105 
107  function += "(" + rt_var + ");";
108  }
109  }
110  else if (NMItemData::MultipleValuesAllowed(path)) {
111  // place the constraint in the Do section
112  string rt_var = "obj";
113  function = NMItemData::GetResolveFuncForMultiValuedQual(path, rt_var, constraints, true);
114 
115  if (function.empty()) {
117  function += "(\"" + path + "\");";
118  }
119  else {
121  function += "(" + rt_var + ");";
122  }
123  }
125  string rt_var;
126  bool found_constraint = false;
127  function = NMItemData::GetResolveFuncForDBLink(m_ArgList[kField].GetValue(), rt_var, constraints, found_constraint);
129  function += "(" + rt_var + ");";
130  }
131  else {
133  function += "(\"" + path + "\");";
134  }
135  return function;
136 }
137 
139 {
140  vector<string> funcs{ CMacroFunction_RemoveQual::GetFuncName() };
141 
143  auto pub_fncs = x_GetPubFunctions();
144  funcs.reserve(funcs.size() + pub_fncs.size() + 2);
145  funcs.push_back(CMacroFunction_RemovePubAuthors::GetFuncName());
146  funcs.push_back(CMacroFunction_RemovePubAuthorMI::GetFuncName());
147  funcs.insert(funcs.end(), pub_fncs.begin(), pub_fncs.end());
148  }
150  funcs.push_back(CMacroFunction_Resolve::GetFuncName());
151  }
152  return funcs;
153 }
154 
155 
156 // CRmvMiscQualTreeItemData
158  : CRmvQualTreeItemData("Remove selected descriptors", EMacroFieldType::eMiscDescriptorsToRmv)
159 {
160 }
161 
163 {
165  bool modified = (new_target != m_Target);
166  m_Target = new_target;
167  return modified;
168 }
169 
171 {
172  string function;
173  string field = m_ArgList[kField].GetValue();
174 
175  if (field.empty()) return function;
177 
178  NMItemData::UpdateConstraintsForMisc(constraints, field, m_Target);
180  string rt_var = "obj";
181  function = NMItemData::GetResolveFuncForMultiValuedQual(path, rt_var, constraints, true);
182 
183  if (function.empty()) {
185  function += "(\"" + path + "\");";
186  }
187  else {
189  function += "(" + rt_var + ");";
190  }
191  }
192  else {
193  function = CMacroFunction_RemoveDescriptor::GetFuncName() + "();";
194  }
195  return function;
196 }
197 
199 {
200  return { CMacroFunction_Resolve::GetFuncName(), CMacroFunction_RemoveQual::GetFuncName(), CMacroFunction_RemoveDescriptor::GetFuncName() };
201 }
202 
203 // CRmvBsrcQualTreeItemData
205  : CMacroActionItemData("Remove biosource qualifiers", EMacroFieldType::eBiosourceText)
206 {
207 }
208 
209 const vector<string>& CRmvBsrcQualTreeItemData::GetKeywords() const
210 {
212 }
213 
215 {
217  args.push_back(GetSetArgs()[0]);
218  x_LoadPanel(parent, CMacroFunction_RemoveModifier::GetFuncName(), args);
219 
221  m_Panel->SetControlValues(kField, fieldnames);
222 }
223 
225 {
226  string descr = "Remove ";
228  switch (m_FieldType) {
230  descr += "location";
231  break;
233  descr += "origin";
234  break;
237  descr += m_ArgList[kField].GetValue();
238  break;
239  default:
240  break;
241  }
242  return descr;
243 }
244 
246 {
247  string function;
248  string field_name = m_ArgList[kField].GetValue();
249 
252  if (field_name == "dbxref") {
253  string rt_var = "obj";
254  function = NMItemData::GetResolveFuncForDbXref(path, rt_var, constraints);
255  if (function.empty()) {
257  function += "(\"org.db\");";
258  }
259  else {
261  function += "(" + rt_var + ");";
262  }
263  }
264  else if (NMacroUtil::IsStructVoucherPart(field_name)) {
265  string rt_var = "obj";
266  bool found_constraint = false;
267  function = NMItemData::GetResolveFuncForSVPart(field_name, rt_var, constraints, found_constraint);
268 
269  auto pos = field_name.find_last_of('-');
270  function += CMacroFunction_RemoveSubfield::GetFuncName();
271  function += "(" + rt_var + ", \"" + field_name.substr(pos + 1) + "\");";
272  }
273  else {
274  if (path.find(',') != NPOS) {
275  vector<string> tokens;
276  NStr::Split(path, ",", tokens);
277 
278  _ASSERT(tokens.size() == 2);
279  // it is either an orgmod or a subsource modifier
280  string rt_var = "obj_bsrc";
281  function = NMItemData::GetResolveFuncForQual(tokens[0], tokens[1], rt_var, constraints);
282 
283  function += CMacroFunction_RemoveModifier::GetFuncName();
284  function += "(" + rt_var + ");";
285  }
286  else {
288  function += "(\"" + path + "\");";
289  }
290  }
291 
292  return function;
293 }
294 
296 {
297  return { CMacroFunction_Resolve::GetFuncName(), CMacroFunction_RemoveQual::GetFuncName(),
298  CMacroFunction_RemoveSubfield::GetFuncName(), CMacroFunction_RemoveModifier::GetFuncName() };
299 }
300 
301 // CRmvStrCommQualTreeItemData
303  : CMacroActionItemData("Remove structured comment fields", EMacroFieldType::eStructComment)
304 {
305 }
306 
308 {
309  TArgumentsVector args{ GetSetArgs()[0] };
310  args.push_back(GetOptionalArgs()[5]);
311  x_LoadPanel(parent, "RemoveStrCommQual", args);
312 
313  vector<string> fieldnames = CMacroEditorContext::GetInstance().GetFieldNames(m_FieldType);
314  m_Panel->SetControlValues(kField, fieldnames);
315  m_Panel->SetSelection(kField, 0);
316 
317  m_Panel->GetArgumentList().Attach(NMItemData::OnStructCommFieldChanged);
318 }
319 
321 {
322  return "Remove " + NMItemData::GetStructCommQualDescr(m_ArgList);
323 }
324 
326 {
327  string field_name = (m_ArgList[kStrCommField].GetShown()) ? m_ArgList[kStrCommField].GetValue() : kEmptyStr;
328  string rt_var = "obj";
329  string function = NMItemData::GetResolveFuncForStrCommQual(m_ArgList[kField].GetValue(), field_name, rt_var, constraints);
331  function += "(" + rt_var + ");";
332  return function;
333 }
334 
336 {
337  return { CMacroFunction_RemoveQual::GetFuncName(), CMacroFunction_Resolve::GetFuncName() };
338 }
339 
340 
341 // CRmvProteinQualTreeItemData
343  : CRmvQualTreeItemData("Remove protein (CDS product) fields", EMacroFieldType::eProtein)
344 {
345 }
346 
348 {
349  TArgumentsVector args{ GetSetArgs()[0] };
350  args.push_back(GetOptionalArgs()[2]);
351  x_LoadPanel(parent, "RemoveProteinQual", args);
352 
353  vector<string> fieldnames = CMacroEditorContext::GetInstance().GetFieldNames(m_FieldType);
354  m_Panel->SetControlValues(kField, fieldnames);
355 
356  m_Panel->GetArgumentList().Attach(NMItemData::OnProteinNameSingle);
357 }
358 
360 {
363  return descr;
364 }
365 
367 {
368  string function;
369  bool update_mrna = m_ArgList[kUpdatemRNA].GetEnabled() && m_ArgList[kUpdatemRNA].IsTrue();
370 
373  // place the constraint in the Do section
374  string rt_var = "obj";
375  function = NMItemData::GetResolveFuncForMultiValuedQual(path, rt_var, constraints, !update_mrna);
376 
377  if (function.empty()) {
379  function += "(\"" + path + "\");";
380  }
381  else {
383  function += "(" + rt_var + ");";
384  }
385  }
386  else {
388  function += "(\"" + path + "\");";
389  }
390 
391  NMItemData::AppendUpdatemRNAFnc(update_mrna, function);
392  return function;
393 }
394 
396 {
397  return { CMacroFunction_Resolve::GetFuncName(),
399  CMacroFunction_UpdatemRNAProduct::GetFuncName()
400  };
401 }
402 
403 
404 // CRmvFeatQualTreeItemData
406  : CRmvQualTreeItemData("Remove feature qualifiers", EMacroFieldType::eFeatQualifiers)
407 {
408 }
409 
411 {
412  TArgumentsVector args(GetOptionalArgs().begin(), GetOptionalArgs().begin() + 3);
413  x_LoadPanel(parent, "RemoveFeatureQual", args);
414 
415  vector<string> features = CMacroEditorContext::GetInstance().GetFeatureTypes(false, false, true);
416  m_Panel->SetControlValues(kFeatType, features);
417  vector<string> qualifiers = CMacroEditorContext::GetInstance().GetFeatQualifiers();
418  m_Panel->SetControlValues(kFeatQual, qualifiers);
419 
420  m_Panel->GetArgumentList().Attach(NMItemData::OnProteinNameSingle);
421 }
422 
424 {
426  bool modified = (new_target != m_Target);
427  m_Target = new_target;
428  m_SelectedField = m_ArgList[kFeatType].GetValue();
429  return modified;
430 }
431 
433 {
434  string descr = "Remove " + m_ArgList[kFeatType].GetValue().get() + " " + m_ArgList[kFeatQual].GetValue().get();
436  return descr;
437 }
438 
440 {
442 
443  string function;
444  bool update_mrna = m_ArgList[kUpdatemRNA].GetEnabled() && m_ArgList[kUpdatemRNA].IsTrue();
446 
447  string rt_var = "obj";
449  // place the constraint in the Do section
450  function = NMItemData::GetResolveFuncForMultiValuedQual(path, rt_var, constraints, !update_mrna);
451 
452  if (function.empty()) {
454  function += "(\"" + path + "\");";
455  }
456  else {
458  function += "(" + rt_var + ");";
459  }
460  }
461  else if (path.find(',') != NPOS) {
462  vector<string> tokens;
463  NStr::Split(path, ",", tokens);
464  _ASSERT(tokens.size() == 2);
465 
466  if (!NStr::EqualNocase(m_ArgList[kFeatType].GetValue().get(), "gene") && CMacroEditorContext::s_IsGeneQualifier(tokens[1])) {
467  function = NMItemData::GetResolveFuncForGeneQuals(tokens[0], tokens[1], rt_var, constraints);
468  function += CMacroFunction_RemoveQual::GetFuncName() + "(" + rt_var + ");";
469  }
470  else if (NMacroUtil::IsSatelliteSubfield(tokens[1]) || NMacroUtil::IsMobileElementTSubfield(tokens[1])) {
471  function = NMItemData::GetResolveFuncForQual(tokens[0], m_ArgList[kFeatQual].GetValue(), rt_var, constraints);
472 
473  function += CMacroFunction_RemoveSubfield::GetFuncName();
474  function += "(" + rt_var + ", \"" + m_ArgList[kFeatQual].GetValue() + "\");";
475  }
476  else {
477  function = NMItemData::GetResolveFuncForQual(tokens[0], tokens[1], rt_var, constraints);
478  function += CMacroFunction_RemoveQual::GetFuncName() + "(" + rt_var + ");";
479  }
480  }
481  else if (path == "dbxref") {
482  function = NMItemData::GetResolveFuncForDbXref(path, rt_var, constraints);
483  if (!function.empty()) {
484  function += CMacroFunction_RemoveQual::GetFuncName() + "(" + rt_var + ");";
485  }
486  else {
487  function += CMacroFunction_RemoveQual::GetFuncName() + "(\"" + path + "\");";
488  }
489  }
490  else {
491  function = CMacroFunction_RemoveQual::GetFuncName() + "(\"" + path + "\");";
492  }
493 
494  NMItemData::AppendUpdatemRNAFnc(update_mrna, function);
495  return function;
496 }
497 
499 {
500  return { CMacroFunction_Resolve::GetFuncName(),
502  CMacroFunction_UpdatemRNAProduct::GetFuncName(),
503  CMacroFunction_RemoveSubfield::GetFuncName()
504  };
505 }
506 
507 // CRmvRNAQualTreeItemData
509  : CRmvQualTreeItemData("Remove RNA qualifiers", EMacroFieldType::eRNA)
510 {
511 }
512 
514 {
515  TArgumentsVector args{ GetSetArgs()[0] };
516  args.push_back(GetOptionalArgs()[3]);
517  args.push_back(GetOptionalArgs()[4]);
518  x_LoadPanel(parent, "RemoveRNAQual", args);
519 
520  vector<string> rnas = CMacroEditorContext::GetInstance().GetRNATypes();
521  m_Panel->SetControlValues(kRNAType, rnas);
522  m_Panel->SetSelection(kRNAType, 0);
523  vector<string> class_types = CMacroEditorContext::GetInstance().GetncRNAClassTypes();
524  m_Panel->SetControlValues(kncRNAClass, class_types);
525  vector<string> fieldnames = CMacroEditorContext::GetInstance().GetFieldNames(m_FieldType);
526  m_Panel->SetControlValues(kField, fieldnames);
527 
528  m_Panel->GetArgumentList().Attach(NMItemData::OnRnaTypeChanged);
529 }
530 
532 {
534  bool modified = (new_target != m_Target);
535  m_Target = new_target;
536  m_SelectedField = m_ArgList[kRNAType].GetValue();
537  return modified;
538 }
539 
541 {
542  string descr = "Remove";
543  if (m_ArgList[kncRNAClass].GetEnabled() && !m_ArgList[kncRNAClass].Empty()) {
544  descr += " " + m_ArgList[kncRNAClass].GetValue();
545  }
546  descr += " " + m_ArgList[kRNAType].GetValue() + " ";
547  if (m_ArgList[kRNAType].GetValue() == "any") {
548  descr += "RNA ";
549  }
550  descr += m_ArgList[kField].GetValue();
551  return descr;
552 }
553 
555 {
556  if (m_ArgList[kField].Empty())
557  return kEmptyStr;
558 
560 
561  string function;
562  string field = m_ArgList[kField].GetValue();
563  if (NStr::StartsWith(field, "gene")) {
565  NMItemData::WrapInQuotes(gene_field);
566  function = CMacroFunction_RmvRelFeatQual::GetFuncName();
567  function += "(\"gene\", " + gene_field + ");";
568  }
569  else {
570  string path = CMacroEditorContext::GetInstance().GetAsnPathToFieldName(m_ArgList[kRNAType].GetValue() + " " + field, m_FieldType);
571  if (path.empty())
572  return kEmptyStr;
573 
574  if (path.find(',') != NPOS) {
575  vector<string> tokens;
576  NStr::Split(path, ",", tokens);
577 
578  _ASSERT(tokens.size() == 2);
579  string rt_var = "obj";
580  function = NMItemData::GetResolveFuncForQual(tokens[0], tokens[1], rt_var, constraints);
581 
583  function += "(" + rt_var + ");";
584  }
585  else if (path.find("::") != NPOS) {
586  function = CMacroFunction_RemoveRnaProduct::GetFuncName() + "();";
587  }
588  else {
590  function += "(\"" + path + "\");";
591  }
592  }
593 
594  return function;
595 }
596 
598 {
600  CMacroFunction_RemoveRnaProduct::GetFuncName(),
601  CMacroFunction_RmvRelFeatQual::GetFuncName(),
602  CMacroFunction_Resolve::GetFuncName() };
603 }
604 
605 
606 // CRemoveDescrTreeItemData
608  : CMacroActionItemData("Remove descriptors", EMacroFieldType::eDescriptors)
609 {
610 }
611 
613 {
614  x_LoadPanel(parent, CMacroFunction_RemoveDescriptor::GetFuncName(), { GetSetArgs()[0] });
615 
616  vector<string> fieldnames = CMacroEditorContext::GetInstance().GetFieldNames(m_FieldType);
617  m_Panel->SetControlValues(kField, fieldnames);
618 }
619 
621 {
622  // select FOR EACH target based on descriptor type:
623  const string& descriptor = m_ArgList[kField].GetValue();
625  if (NStr::EqualNocase(descriptor, "BioSource")) {
626  new_target = CMacroBioData::sm_BioSource;
627  }
628  else if (NStr::EqualNocase(descriptor, "Molinfo")) {
629  new_target = CMacroBioData::sm_MolInfo;
630  }
631  else if (NStr::EqualNocase(descriptor, "Publication")) {
632  new_target = CMacroBioData::sm_Pubdesc;
633  }
634  else if (NStr::EqualNocase(descriptor, "StructuredComment")) {
635  new_target = CMacroBioData::sm_StrComm;
636  }
637  else if (NStr::EqualNocase(descriptor, "DBLink")) {
638  new_target = CMacroBioData::sm_DBLink;
639  }
640  else if (NStr::EqualNocase(descriptor, "User")) {
641  new_target = CMacroBioData::sm_UserObject;
642  }
643 
644  bool modified = (m_Target != new_target);
645  m_Target = new_target;
646  return modified;
647 }
648 
650 {
651  return "Remove " + m_ArgList[kField].GetValue() + " descriptor";
652 }
653 
655 {
656  if (m_ArgList[kField].Empty())
657  return kEmptyStr;
658 
660  if (!path.empty() && path != m_ArgList[kField].GetValue().get()) {
661  string new_constraint = CMacroFunction_ChoiceType::GetFuncName();
662  new_constraint += "() = \"" + path + "\"";
663  constraints.insert(constraints.begin(), make_pair("", new_constraint));
664  }
665 
666  return CMacroFunction_RemoveDescriptor::GetFuncName() + "();";
667 }
668 
670 {
671  return { CMacroFunction_RemoveDescriptor::GetFuncName() };
672 }
673 
674 // CRemoveFeatureTreeItemData
677 {
678 }
679 
681 {
683  x_LoadPanel(parent, CMacroFunction_RemoveFeature::GetFuncName(), args);
684 
686  m_Panel->SetControlValues(kFeatType, features);
687  m_Panel->GetArgumentList().Attach(NMItemData::OnSelectFeature);
688 }
689 
691 {
693  bool modified = (m_Target != new_target);
694  m_Target = new_target;
695  return modified;
696 }
697 
699 {
700  string descr = "Remove " + m_ArgList[kFeatType].GetValue() + " features";
701  if (HasVariables() && m_ArgList[kRmvOverlapGene].IsTrue()) {
702  descr += " and the overlapping genes";
703  }
704  return descr;
705 }
706 
708 {
709  return (m_ArgList[kRmvOverlapGene].GetEnabled());
710 }
711 
713 {
714  if (HasVariables())
715  return kRmvOverlapGene + " = %" + m_ArgList[kRmvOverlapGene].GetValue() + "%";
716 
717  return kEmptyStr;
718 }
719 
721 {
722  if (m_ArgList[kFeatType].GetValue() == "All") {
724  }
725 
727  string func = CMacroFunction_RemoveFeature::GetFuncName() + "(";
728  if (HasVariables()) {
729  func += kRmvOverlapGene;
730  }
731  func += ");";
732  return func;
733 }
734 
736 {
737  return { CMacroFunction_RemoveFeature::GetFuncName(), CMacroFunction_RemoveAllFeatures::GetFuncName() };
738 }
739 
740 
741 // CRemoveDuplFeatsTreeItemData
743  : CMacroActionItemData("Remove duplicate features", EMacroFieldType::eFeatQualifiers)
744 {
745 }
746 
748 {
749  x_LoadPanel(parent, CMacroFunction_RemoveDuplFeatures::GetFuncName(), GetRmvDuplFeaturesArgs());
750 
752  m_Panel->SetControlValues(kFeatType, features);
753 }
754 
756 {
757  string descr = "Remove duplicate ";
758  if (m_ArgList[kFeatType].GetValue() != "All") {
759  descr += m_ArgList[kFeatType].GetValue();
760  }
761  descr += " features";
762 
763  if (m_ArgList[kCheckPartials].IsTrue()) {
764  descr += " (check partials)";
765  }
766  if (m_ArgList[kCaseSens].IsTrue()) {
767  if (descr.find("partials") != NPOS) {
768  descr += ",";
769  }
770  descr += " (case sensitive)";
771  }
772  if (m_ArgList[kRemoveProteins].IsTrue()) {
773  descr += " and remove protein products";
774  }
775  return descr;
776 }
777 
779 {
780  string variables;
781  variables += kCheckPartials + " = %" + m_ArgList[kCheckPartials].GetValue() + "%\n";
782  variables += kCaseSens + " = %" + m_ArgList[kCaseSens].GetValue() + "%\n";
783  variables += kRemoveProteins + " = %" + m_ArgList[kRemoveProteins].GetValue() + "%";
784  return variables;
785 }
786 
788 {
789  if (m_ArgList[kFeatType].GetValue().get().empty())
790  return kEmptyStr;
791 
792  string function = CMacroFunction_RemoveDuplFeatures::GetFuncName();
793  function += "(\"" + m_ArgList[kFeatType].GetValue() + "\",";
794  function += kCheckPartials + ", " + kCaseSens + ", " + kRemoveProteins + ");";
795  return function;
796 }
797 
799 {
800  return { CMacroFunction_RemoveDuplFeatures::GetFuncName() };
801 }
802 
803 
804 // CRemoveDbXrefTreeItemData
806  : CMacroActionItemData("Remove all, illegal dbxrefs from features", EMacroFieldType::eFeatQualifiers)
807 {
808 }
809 
811 {
812  x_LoadPanel(parent, "RemoveDbXref", GetRmvDbxrefArgs());
813 
815  m_Panel->SetControlValues(kFeatType, features);
816 
817  m_Panel->GetArgumentList().Attach(NMItemData::OnIllegalDbXrefSelected);
818 }
819 
821 {
823  bool modified = (m_Target != new_target);
824  m_Target = new_target;
825  return modified;
826 }
827 
829 {
830  string descr;
831 
832  if (m_ArgList[kAllDbxref].IsTrue()) {
833  descr = "Remove all ";
834  }
835  else {
836  descr = "Remove illegal ";
837  }
838 
839  descr += "dbxrefs from " + m_ArgList[kFeatType].GetValue() + " features";
840  if (m_ArgList[kMoveToNote].GetEnabled() && m_ArgList[kMoveToNote].IsTrue()) {
841  descr += " and copy their values to note";
842  }
843  return descr;
844 }
845 
847 {
848  if (m_ArgList[kFeatType].Empty())
849  return kEmptyStr;
850 
852 
853  if (m_ArgList[kAllDbxref].IsTrue()) {
854  string function = CMacroFunction_RemoveQual::GetFuncName() + "(\"dbxref\");";
855  return function;
856  }
857 
858  string path = "dbxref", rt_var = "obj";
859  string function = rt_var + " = " + CMacroFunction_Resolve::GetFuncName() + "(\"" + path + "\")";
860  function += " WHERE " + CMacroFunction_IllegalDbXref::GetFuncName() + "(" + rt_var + ")";
861 
862  // check if there are any relevant constraints
863  TConstraints::iterator it = constraints.begin();
864  while (it != constraints.end()) {
865  if (it->second.find(path) != NPOS) {
866  NStr::ReplaceInPlace(it->second, path, rt_var + ".db");
867  function += " AND " + it->second;
868  it = constraints.erase(it);
869  }
870  else {
871  ++it;
872  }
873  }
874  function += ";\n";
875  if (m_ArgList[kMoveToNote].GetEnabled() && m_ArgList[kMoveToNote].IsTrue()) {
877  function += "(" + rt_var + ", \"comment\", \"eAppend\", \";\");\n";
878  }
879 
880  function += CMacroFunction_RemoveQual::GetFuncName() + "(" + rt_var + ");";
881  return function;
882 }
883 
885 {
887  CMacroFunction_Resolve::GetFuncName(),
889 }
890 
892 {
894 }
895 
896 
897 
898 
899 // CRmvOrgNameTreeItemData
901  : CMacroActionItemData("Remove organism name from biosource modifiers", EMacroFieldType::eBiosourceText)
902 {
903 }
904 
906 {
908 
909  vector<string> fieldnames = CMacroEditorContext::GetInstance().GetFieldNames(m_FieldType);
910  m_Panel->SetControlValues(m_Args[0]->GetName(), fieldnames);
911 }
912 
914 {
915  return "Remove organism name from " + m_Args[0]->GetValue();
916 }
917 
919 {
920  string function;
922  if (path.find(',') != NPOS) {
923  vector<string> tokens;
924  NStr::Split(path, ",", tokens);
925 
926  string rt_var = "obj";
927  function = NMItemData::GetResolveFuncForQual(tokens[0], tokens[1], rt_var, constraints);
928 
930  function += "(\"" + NMItemData::GetEditableFieldForPair(m_Args[0]->GetValue(), rt_var, false) + "\");";
931  }
932  return function;
933 }
934 
936 {
937  return { CMacroFunction_Resolve::GetFuncName(), CMacroFunction_RemoveOrgName::GetFuncName() };
938 }
939 
940 
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
const vector< string > & GetBsrcKeywords() const
vector< string > GetFieldNames(EMacroFieldType type) const
@ ePubFieldType_AuthorMiddleInitial
virtual vector< string > GetMainFunctions() const
virtual string GetFunction(TConstraints &constraints) const
virtual void x_AddParamPanel(wxWindow *parent)
virtual vector< string > GetFunctionNames() const
virtual string GetMacroDescription() const
virtual void x_AddParamPanel(wxWindow *parent)
virtual vector< string > GetFunctionNames() const
virtual string GetFunction(TConstraints &constraints) const
virtual string GetMacroDescription() const
virtual string GetMacroDescription() const
virtual vector< string > GetFunctionNames() const
virtual string GetFunction(TConstraints &constraints) const
virtual void x_AddParamPanel(wxWindow *parent)
virtual vector< string > GetFunctionNames() const
virtual bool HasVariables() const
virtual string GetFunction(TConstraints &constraints) const
virtual void x_AddParamPanel(wxWindow *parent)
virtual string GetMacroDescription() const
virtual string GetMacroDescription() const
virtual vector< string > GetFunctionNames() const
virtual void x_AddParamPanel(wxWindow *parent)
virtual const vector< string > & GetKeywords() const
virtual string GetFunction(TConstraints &constraints) const
virtual vector< string > GetFunctionNames() const
virtual string GetMacroDescription() const
virtual string GetFunction(TConstraints &constraints) const
virtual void x_AddParamPanel(wxWindow *parent)
virtual string GetFunction(TConstraints &constraints) const
virtual vector< string > GetFunctionNames() const
virtual string GetFunction(TConstraints &constraints) 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
virtual vector< string > GetFunctionNames() const
virtual void x_AddParamPanel(wxWindow *parent)
virtual vector< string > GetFunctionNames() const
virtual string GetMacroDescription() const
virtual void x_AddParamPanel(wxWindow *parent)
CRmvQualTreeItemData(const string &description, EMacroFieldType type)
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
virtual string GetFunction(TConstraints &constraints) const
virtual void x_AddParamPanel(wxWindow *parent)
virtual vector< string > GetFunctionNames() const
virtual string GetMacroDescription() 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
bool Empty(const CNcbiOstrstream &src)
Definition: fileutil.cpp:523
static const char * sm_Seqdesc
static const char * sm_BioSource
static CTempString GetFuncName()
bool IsStructVoucherPart(const string &field)
Definition: macro_util.cpp:826
static const char * sm_DBLink
static CTempString GetFuncName()
static const char * sm_Pubdesc
static CTempString GetFuncName()
static const char * sm_UserObject
static const char * sm_StrComm
bool IsSatelliteSubfield(const string &field)
Definition: macro_util.cpp:903
bool IsMobileElementTSubfield(const string &field)
Definition: macro_util.cpp:908
static const char * sm_MolInfo
static CTempString GetFuncName()
#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 & 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.
Definition: ncbistr.cpp:3405
const_iterator begin() const
Return an iterator to the string's starting position.
Definition: tempstr.hpp:299
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)
string GetResolveFuncForDbXref(const string &path, const string &rt_var, TConstraints &constraints)
void OnIllegalDbXrefSelected(CArgumentList &list, CArgument &arg)
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)
CTempString UpdateTargetForMisc(const string &fieldname)
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)
string GetResolveFuncForApplyAuthors(CPubFieldType::EPubFieldType type, const string &rt_var, TConstraints &constraints)
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)
EMacroFieldType GetSourceTypeInSinglePanel(const CArgumentList &arg_list)
void OnRnaTypeChanged(CArgumentList &list, CArgument &arg)
void UpdateConstraintsForRnas(TConstraints &constraints, const CArgumentList &arg_list)
void UpdateConstraintsForMisc(TConstraints &constraints, const string &fieldname, const string &target)
void OnSelectFeature(CArgumentList &list, CArgument &arg)
string GetResolveFuncForPubQual(const string &field, string &rt_var, TConstraints &constraints)
void AppendUpdatemRNAFnc(bool update_mrna, string &function)
const string kMoveToNote
const TArgumentsVector & GetSetArgs()
const string kFeatQual
const TArgumentsVector & GetRmvDbxrefArgs()
const string kField
const string kCaseSens
const string kRmvOverlapGene
const string kAllDbxref
const string kRNAType
const string kncRNAClass
const TArgumentsVector & GetOptionalArgs()
const TArgumentsVector & GetRmvDuplFeaturesArgs()
const string kFeatType
const string kCheckPartials
const TArgumentsVector & GetBsrcArgs()
const string kUpdatemRNA
const string kRemoveProteins
const string kStrCommField
constexpr bool empty(list< Ts... >) noexcept
Definition: type.c:6
#define _ASSERT
static const char *const features[]
Modified on Sat Apr 20 12:21:53 2024 by modify_doxy.py rev. 669887