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

Go to the SVN repository for this file.

1 /* $Id: macro_general_itemdata.cpp 47464 2023-04-20 00:19:10Z evgeniev $
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>
32 #include <objects/seq/Seq_gap.hpp>
33 #include <util/xregexp/regexp.hpp>
43 
50 
51 #include <wx/msgdlg.h>
52 
55 USING_SCOPE(macro);
57 
58 
59 // CFixPrimerTreeItemData
60 CFixPrimerTreeItemData::CFixPrimerTreeItemData(const string& description, bool fixI)
61  : CMacroActionSimpleItemData(kEmptyStr, description), m_FixI(fixI)
62 {
63 }
64 
66 {
67  string function = x_GetFncName();
68  function += "(\"pcr-primers..forward..seq\");\n";
69  function += x_GetFncName();
70  function += "(\"pcr-primers..reverse..seq\");";
71  return function;
72 }
73 
75 {
76  if (m_FixI) {
78  }
80 }
81 
83 {
84  return { x_GetFncName() };
85 }
86 
87 // CFixSubsrcFormatTreeItemData
89  : CMacroActionItemData(description)
90 {}
91 
93 {
95 
96  vector<string> fields{ "altitude", "collection-date", "lat-lon" };
97  m_Panel->SetControlValues(m_Args[0]->GetName(), fields);
98 }
99 
101 {
102  return "Fix " + m_Args[0]->GetValue() + " format";
103 }
104 
106 {
107  string rt_var = "obj";
108  string function = NMItemData::GetResolveFuncForQual("subtype", m_Args[0]->GetValue(), rt_var, constraints);
109  function += CMacroFunction_FixFormat::GetFuncName() + CTempString("(" + rt_var + ");");
110  return function;
111 }
112 
114 {
115  return { CMacroFunction_Resolve::GetFuncName(), CMacroFunction_FixFormat::GetFuncName() };
116 }
117 
118 
119 // CFixSrcQualsTreeItemData
122 {
123 }
124 
126 {
127  x_LoadPanel(parent, CMacroFunction_FixSourceQualCaps::GetFuncName(), { GetSetArgs()[0] });
128 }
129 
131 {
132  return "Fix capitalization in " + m_ArgList[kField].GetValue() + " source qualifier";
133 }
134 
136 {
137  string function;
139  if (path.find(',') != NPOS) {
140  vector<string> tokens;
141  NStr::Split(path, ",", tokens);
142 
143  _ASSERT(tokens.size() == 2);
144  // it is either an orgmod or a soubsource modifier
145  string rt_var = "obj";
146  function = NMItemData::GetResolveFuncForQual(tokens[0], tokens[1], rt_var, constraints);
147 
148  function += CMacroFunction_FixSourceQualCaps::GetFuncName() + "(" + rt_var + ");";
149  }
150  return function;
151 }
152 
154 {
155  return { CMacroFunction_Resolve::GetFuncName(), CMacroFunction_FixSourceQualCaps::GetFuncName() };
156 }
157 
158 
159 // CFixMouseStrainTreeItemData
161  : CMacroActionSimpleItemData(kEmptyStr, description)
162 {
163 }
164 
166 {
167  string rt_var = "obj";
168  string function = NMItemData::GetResolveFuncForQual("org.orgname.mod", "strain", rt_var, constraints);
169  function += CMacroFunction_FixMouseStrain::GetFuncName() + CTempString("(" + rt_var + ");");
170  return function;
171 }
172 
174 {
175  return { CMacroFunction_Resolve::GetFuncName(), CMacroFunction_FixMouseStrain::GetFuncName() };
176 }
177 
178 
179 // CFixPubCapsTreeItemData
181  : CMacroActionItemData(description, type)
182 {
183 }
184 
186 {
188 }
189 
191 {
192  string descr = "Fix pub ";
193  switch (m_FieldType) {
195  descr += "affiliation";
196  break;
198  descr += "affiliation country";
199  break;
201  descr += "affiliation except institute and department";
202  break;
204  descr += "authors";
205  break;
207  descr += "title";
208  break;
209  default:
210  descr.resize(0);
211  }
212  if (m_ArgList[kPunctonly].IsTrue()) {
213  descr += " (punctuation only)";
214  }
215  return descr;
216 }
217 
219 {
220  return kPunctonly + " = %" + m_ArgList[kPunctonly].GetValue() + "%";
221 }
222 
224 {
225  string rt_var = "obj";
226  string function;
227 
228  switch (m_FieldType) {
230  function = NMItemData::GetResolveFuncForPubQualConst("affiliation", rt_var, constraints, m_FieldType);
232  break;
236  break;
238  function = NMItemData::GetResolveFuncForPubQualConst("affiliation", rt_var, constraints, m_FieldType);
240  break;
244  break;
248  break;
249  default:
250  break;
251  }
252  function += "(" + rt_var + ", " + kPunctonly + ");";
253 
254  return function;
255 }
256 
258 {
259  auto fncs = x_GetPubFunctions();
260  switch (m_FieldType) {
263  break;
266  break;
269  break;
272  break;
275  break;
276  default:
277  break;
278  }
279  return fncs;
280 }
281 
282 // CFixCapsLastNameTreeItemData
284  : CMacroActionSimpleItemData(kEmptyStr, description)
285 {
286 }
287 
289 {
290  string rt_var;
291  string function = NMItemData::GetResolveFuncForPubQual("author last name", rt_var, constraints);
292 
293  function += CMacroFunction_FixAuthorCaps::GetFuncName();
294  function += "(" + rt_var + ");";
295  return function;
296 }
297 
299 {
300  return { CMacroFunction_FixAuthorCaps::GetFuncName(), CMacroFunction_PubFields::sm_PubAuthors };
301 }
302 
303 // CRetranslateCDSTreeItemData
305  : CMacroActionItemData(description)
306 {
307 }
308 
310 {
311  TArgumentsVector args{ GetOptionalArgs()[7] };
312  x_LoadPanel(parent, CMacroFunction_RetranslateCDS::GetFuncName(), args);
313 }
314 
316 {
317  return kObeyStopCodon + " = %" + m_ArgList[kObeyStopCodon].GetValue() + "%";
318 }
319 
321 {
322  return CMacroFunction_RetranslateCDS::GetFuncName() + "(" + kObeyStopCodon + ");";
323 }
324 
326 {
327  return { CMacroFunction_RetranslateCDS::GetFuncName() };
328 }
329 
330 
331 // CRestoreRNAEditingTreeItemData
333  : CMacroActionItemData(description)
334 {
335 }
336 
338 {
339  TArgumentsVector args{ GetOptionalArgs()[10] };
340  x_LoadPanel(parent, CMacroFunction_RestoreRNAEditing::GetFuncName(), args);
341 }
342 
344 {
345  return kProteinName + " = %" + m_ArgList[kProteinName].GetValue() + "%";
346 }
347 
349 {
350  return CMacroFunction_RestoreRNAEditing::GetFuncName() + "(" + kProteinName + ");";
351 }
352 
354 {
355  return { CMacroFunction_RestoreRNAEditing::GetFuncName() };
356 }
357 
358 // CUpdateReplacedECTreeItemData
360  : CMacroActionItemData(description)
361 {
362 }
363 
365 {
366  x_LoadPanel(parent, CMacroFunction_UpdateReplacedECNumbers::GetFuncName(), GetUpdateRpldECNumbersArgs());
367 }
368 
370 {
371  return m_Description;
372 }
373 
375 {
376  string variables;
377  variables += kDelImproper + " = " + m_ArgList[kDelImproper].GetValue() + "\n";
378  variables += kDelUnrecog + " = " + m_ArgList[kDelUnrecog].GetValue() + "\n";
379  variables += kDelMultRepl + " = " + m_ArgList[kDelMultRepl].GetValue() + "\n";
380  return variables;
381 }
382 
384 {
385  string function = CMacroFunction_UpdateReplacedECNumbers::GetFuncName();
386  function += "(" + kDelImproper + ", " + kDelUnrecog + ", " + kDelMultRepl + ");";
387  return function;
388 }
389 
391 {
392  return { CMacroFunction_UpdateReplacedECNumbers::GetFuncName() };
393 }
394 
395 // CAddGeneXrefTreeItemData
398 {
399 }
400 
402 {
403  TArgumentsVector args{ GetOptionalArgs()[0] };
404  x_LoadPanel(parent, CMacroFunction_AddGeneXref::GetFuncName(), args);
405 
406  vector<string> features = CMacroEditorContext::GetInstance().GetFeatureTypes(false);
407  m_Panel->SetControlValues(kFeatType, features);
408 }
409 
411 {
413  bool modified = (m_Target != new_target);
414  m_Target = new_target;
415  m_SelectedField = m_ArgList[kFeatType].GetValue();
416  return modified;
417 }
418 
420 {
421  return "Add gene Xrefs from overlapping gene features for " + m_ArgList[kFeatType].GetValue() + " features";
422 }
423 
425 {
427  return CMacroFunction_AddGeneXref::GetFuncName() + "();";
428 }
429 
431 {
432  return { CMacroFunction_AddGeneXref::GetFuncName() };
433 }
434 
435 // CRemoveGeneXrefTreeItemData
438 {
439 }
440 
442 {
444 
445  vector<string> features = CMacroEditorContext::GetInstance().GetFeatureTypes(true);
446  m_Panel->SetControlValues(kFeatType, features);
447 }
448 
450 {
452  bool modified = (m_Target != new_target);
453  m_Target = new_target;
454  m_SelectedField = m_ArgList[kFeatType].GetValue();
455  return modified;
456 }
457 
459 {
460  string descr = "Remove";
461  string suppr_type = x_TranslateType(m_ArgList[kSuppressingType].GetValue());
462  string necess_type = x_TranslateType(m_ArgList[kNecessaryType].GetValue());
463 
464  if (suppr_type != "any") {
465  descr += " " + suppr_type;
466  }
467  if (necess_type != "any") {
468  descr += " " + necess_type;
469  }
470 
471  descr += " gene xrefs from " + m_ArgList[kFeatType].GetValue() + " features";
472  return descr;
473 }
474 
476 {
477  string variables;
478  variables += kSuppressingType + " = %" + x_TranslateType(m_ArgList[kSuppressingType].GetValue()) + "%\n";
479  variables += kNecessaryType + " = %" + x_TranslateType(m_ArgList[kNecessaryType].GetValue()) + "%";
480  return variables;
481 }
482 
484 {
486  string function = CMacroFunction_RemoveGeneXref::GetFuncName();
487  function += "(" + kSuppressingType + ", " + kNecessaryType + ");";
488  return function;
489 }
490 
491 string CRemoveGeneXrefTreeItemData::x_TranslateType(const string& dlg_type) const
492 {
493  string type = dlg_type;
495  NStr::ReplaceInPlace(type, "-", "");
496  if (type.find(" or ") != NPOS) {
497  type = "any";
498  }
499  return type;
500 }
501 
503 {
505 }
506 
507 
508 // CConvertClassTreeItemData
510  : CMacroActionItemData("Convert set class type")
511 {
512 }
513 
515 {
517  x_LoadPanel(parent, "ConvertClassType", args);
518 
520  m_Panel->SetControlValues(kFromField, fieldnames);
522  m_Panel->SetControlValues(kToField, fieldnames);
524 }
525 
527 {
528  string descr = "Convert " + m_ArgList[kFromField].GetValue();
529  descr += "s to " + m_ArgList[kToField].GetValue() + "s";
530  if (m_ArgList[kInconsTaxa].IsTrue()) {
531  descr += " when taxnames are inconsistent";
532  }
533  return descr;
534 }
535 
537 {
538  string new_constraint = CMacroFunction_StringConstraints::sm_Equal;
539  new_constraint += "(\"class\", \"" + CMacroEditorContext::GetInstance().GetAsnPathToFieldName(m_ArgList[kFromField].GetValue(), m_FieldType) + "\")";
540  constraints.emplace_back("class", new_constraint);
541  if (m_ArgList[kInconsTaxa].IsTrue()) {
542  constraints.emplace_back(kEmptyStr, CMacroFunction_InconsistentTaxa::GetFuncName() + CTempString("()"));
543  }
544 
545  string func = CMacroFunction_SetQual::GetFuncName();
546  func += "(\"class\", \"" + CMacroEditorContext::GetInstance().GetAsnPathToFieldName(m_ArgList[kToField].GetValue(), m_FieldType) + "\");";
547  return func;
548 }
549 
551 {
553 }
554 
555 
556 /// CDiscrepancyAutofixTreeItemData
558  : CMacroActionItemData(description)
559 {
560 }
561 
563 {
564  x_LoadPanel(parent, CMacroFunction_DiscrepancyAutofix::GetFuncName(), GetDiscrReportArgs());
565 
566  static vector<string> s_test_names;
567 
568  if (s_test_names.empty()) {
570  s_test_names.reserve(tests.size());
571  for (auto tn : tests) {
572  s_test_names.push_back(string(GetDiscrepancyCaseName(tn)));
573  }
574  }
575 
576  m_Panel->SetControlValues(kTestName, s_test_names);
577 }
578 
580 {
581  string descr = "Perform autofix for ";
582  if (!m_Args.empty()) {
583  descr += m_Args.front()->GetValue();
584  }
585  descr += " discrepancy report test";
586  return descr;
587 }
588 
590 {
591  m_TestVars.resize(0);
592  NStr::Split(m_Args.front()->GetValue().get(), ", ", m_TestVars, NStr::fSplit_Tokenize);
593 
594  string variables;
595  if (m_TestVars.size() == 1) {
596  variables = kTestName + "= \"" + m_TestVars[0] + "\"";
597  }
598  else {
599  unsigned int count = 0;
600  for (auto& it : m_TestVars) {
601  if (!variables.empty()) {
602  variables += "\n";
603  }
604  variables += kTestName + NStr::IntToString(++count) + " = \"" + it + "\"";
605  }
606  }
607  return variables;
608 }
609 
611 {
612  string function;
613  if (m_Args.empty()) {
614  function += CMacroFunction_DiscrepancyAutofix::GetFuncName() + "();";
615  }
616  else {
617  if (m_TestVars.size() == 1) {
618  function += CMacroFunction_DiscrepancyAutofix::GetFuncName();
619  function += "(" + kTestName + ");";
620  }
621  else {
622  for (size_t count = 0; count < m_TestVars.size(); ++count) {
623  if (!function.empty()) {
624  function += "\n";
625  }
626  function += CMacroFunction_DiscrepancyAutofix::GetFuncName();
627  function += "(" + kTestName + NStr::SizetToString(count + 1) + ");";
628  }
629  }
630  }
631 
632  return function;
633 }
634 
636 {
637  return { CMacroFunction_DiscrepancyAutofix::GetFuncName() };
638 }
639 
640 
641 // CAutodefTreeItemData
643  : CMacroActionItemData("Generate definition lines", EMacroFieldType::eBiosourceAutodef)
644 {
645 }
646 
648 {
650 
651  vector<string> fieldnames = CMacroEditorContext::GetInstance().GetFieldNames(m_FieldType);
652  m_Panel->SetControlValues(kSourceField, fieldnames);
653 
654  m_Panel->GetArgumentList().Attach(NMItemData::OnMiscFeatRuleSelected);
655  m_Panel->GetArgumentList().Attach(NMItemData::OnAutodefCompleteSelected);
656 }
657 
659 {
660  string descr = "Autodef ";
661 
662  bool is_complete = false;
663  if (m_ArgList[kAutodefCompl].IsTrue()) {
664  if (!m_ArgList[kListFeatRule].GetEnabled()) {
665  is_complete = true;
666  }
667  else {
668  return kEmptyStr;
669  }
670  }
671  if (is_complete) {
672  descr += "complete ";
673  }
674  else {
675  descr += m_ArgList[kListFeatRule].GetValue();
676  }
677 
678  if (!m_ArgList[kSourceField].Empty()) {
679  descr += " with modifier " + m_ArgList[kSourceField].GetValue();
680  }
681 
682  string misc_feat_rule = (m_ArgList[kMiscFeatRule].GetEnabled()) ? m_ArgList[kMiscFeatRule].GetValue().get() : "Delete";
683  if (NStr::StartsWith(misc_feat_rule, "Look for")) {
684  misc_feat_rule = "look for non-coding product in misc-feature comment";
685  }
686  else if (NStr::StartsWith(misc_feat_rule, "Use comment")) {
687  misc_feat_rule = "use misc-feature comment before first semicolon";
688  }
689 
690  if (misc_feat_rule != "Delete") {
691  descr += ", " + misc_feat_rule;
692  }
693  return descr;
694 }
695 
697 {
698  string variables;
699  if (m_ArgList[kListFeatRule].GetEnabled()) {
700  variables = kListFeatRule + " = \"" + m_ArgList[kListFeatRule].GetValue() + "\"\n";
701  }
702  string misc_feat_rule = (m_ArgList[kMiscFeatRule].GetEnabled()) ? m_ArgList[kMiscFeatRule].GetValue().get() : "Delete";
703  if (NStr::StartsWith(misc_feat_rule, "Look for")) {
704  misc_feat_rule = "NonCodingProductFeat";
705  }
706  else if (NStr::StartsWith(misc_feat_rule, "Use comment")) {
707  misc_feat_rule = "CommentFeat";
708  }
709  variables += kMiscFeatRule + " = \"" + misc_feat_rule + "\"";
710  return variables;
711 }
712 
714 {
715  bool is_complete = false;
716  if (m_ArgList[kAutodefCompl].IsTrue()) {
717  if (!m_ArgList[kListFeatRule].GetEnabled()) {
718  is_complete = true;
719  }
720  else {
721  return kEmptyStr;
722  }
723  }
724 
725  string function;
726  if (is_complete) {
728  function += "(";
729  }
730  else {
732  function += "(" + kListFeatRule + ", ";
733  }
734  function += kMiscFeatRule;
735 
736  vector<string> modifiers;
737  NStr::Split(m_ArgList[kSourceField].GetValue().get(), ", ", modifiers, NStr::fSplit_Tokenize);
738 
739  if (!modifiers.empty()) {
740  for (auto& it : modifiers) {
741  function += ", \"" + it + "\"";
742  }
743  }
744  function += ");";
745  return function;
746 }
747 
749 {
751 }
752 
753 
754 // CAddAssemblyGapsNTreeItemData
756  : CMacroActionItemData("Convert raw sequence to delta based on Ns, it creates assembly gaps")
757 {
759  m_WithAssemblyParams = true;
760 }
761 
763 {
764  TArgumentsVector args;
765  x_LoadPanel(parent, CMacroFunction_ConvertRawToDeltabyNs::GetFuncName(), args);
766  m_RawSeqToDeltaPanel = dynamic_cast<CRawSeqToDeltaByNPanel*>(m_Panel->LoadCustomPanel(m_Type));
767 }
768 
770 {
771  string descr = "Add assembly gaps ";
772  bool is_assembly_gap = false;
773  string gap_type, linkage, linkage_evidence;
775  m_RawSeqToDeltaPanel->GetAssemblyParams(is_assembly_gap, gap_type, linkage, linkage_evidence);
776  if (!is_assembly_gap) {
777  return kEmptyStr;
778  }
779 
780  descr += "with gap_type '" + gap_type + "', ";
781  if (!linkage.empty()) {
782  descr += "with linkage '" + linkage + "', ";
783  }
784  else {
785  descr += "with no linkage, ";
786  }
787 
788  if (!linkage_evidence.empty()) {
789  descr += "with linkage_evidence '" + linkage_evidence + "'";
790  }
791  else {
792  descr += "with no linkage evidence";
793  }
795  descr += ", adjust coding regions";
796  }
798  descr += ", keep gap length";
799  }
800  return descr;
801 }
802 
804 {
806  return kEmptyStr;
807  long min_known;
808  long max_known;
809  long min_unknown;
810  long max_unknown;
811  m_RawSeqToDeltaPanel->GetMinMax(min_known, max_known, min_unknown, max_unknown);
812 
813  int gap_type = CSeq_gap::eType_unknown;
814  int linkage = -1;
815  int linkage_evidence = -1;
816  m_RawSeqToDeltaPanel->GetAssemblyParams(m_IsAssemblyGap, gap_type, linkage, linkage_evidence);
817 
818  string variables;
819  size_t index = 0;
820  auto& gap_vars = GetAddAssemblyGapsNArgs();
821  variables += gap_vars[index] + " = " + NStr::Int8ToString(min_unknown) + "\n";
822  variables += gap_vars[++index] + " = " + NStr::Int8ToString(max_unknown) + "\n";
823  variables += gap_vars[++index] + " = " + NStr::Int8ToString(min_known) + "\n";
824  variables += gap_vars[++index] + " = " + NStr::Int8ToString(max_known) + "\n";
825  variables += gap_vars[++index] + " = " + NStr::BoolToString(m_RawSeqToDeltaPanel->GetAdjustCDS()) + "\n";
826  variables += gap_vars[++index] + " = " + NStr::BoolToString(m_RawSeqToDeltaPanel->GetKeepGapLength()) + "\n";
827  variables += gap_vars[++index] + " = \"" + CSeq_gap::ENUM_METHOD_NAME(EType)()->FindName(gap_type, true) + "\"\n";
828  variables += gap_vars[++index] + " = \"" + CSeq_gap::ENUM_METHOD_NAME(ELinkage)()->FindName(linkage, true) +"\"\n";
829  variables += gap_vars[++index] + " = \"" + CLinkage_evidence::ENUM_METHOD_NAME(EType)()->FindName(linkage_evidence, true) + "\"";
830  return variables;
831 }
832 
834 {
835  if (!m_IsAssemblyGap) {
836  return kEmptyStr;
837  }
838 
839  auto& gap_vars = GetAddAssemblyGapsNArgs();
840 
841  string function;
842  function = CMacroFunction_ConvertRawToDeltabyNs::GetFuncName();
843  function += "(" + gap_vars.front();
844  for (size_t index = 1; index < gap_vars.size(); ++index) {
845  function += ", " + gap_vars[index];
846  }
847  function += ");";
848  return function;
849 }
850 
852 {
853  return { CMacroFunction_ConvertRawToDeltabyNs::GetFuncName() };
854 }
855 
856 bool IAddGapsInfo::SetData(const vector<CFuncWithArgs>& func_info)
857 {
858  if (func_info.size() != 1 || !m_RawSeqToDeltaPanel)
859  return false;
860  if (m_WithAssemblyParams && !NStr::EqualNocase(func_info.front().m_FName, CMacroFunction_ConvertRawToDeltabyNs::GetFuncName()))
861  return false;
862  if (!m_WithAssemblyParams && !NStr::EqualNocase(func_info.front().m_FName, CMacroFunction_AddGapFeaturesByNs::GetFuncName()))
863  return false;
864 
865  auto& args = func_info.front().m_FArgs;
866  try {
868  NStr::StringToInt(args.at(kMaxKnown)),
870  NStr::StringToInt(args.at(kMaxUnknown)));
871  }
872  catch (const exception&) {
873  return false;
874  }
875 
876  try {
879  if (m_WithAssemblyParams) {
880  m_RawSeqToDeltaPanel->SetAssemblyParams(true, args.at(kGapType), args.at(kLinkage), args.at(kLinkEvidence));
881  }
882  }
883  catch (const exception&) {
884  return false;
885  }
886  return true;
887 }
888 
889 
890 
891 // CAddGapsNTreeItemData
893  : CMacroActionItemData("Convert raw sequence to delta based on Ns, it creates gap features")
894 {
896  m_WithAssemblyParams = false;
897 }
898 
900 {
901  TArgumentsVector args;
902  x_LoadPanel(parent, CMacroFunction_AddGapFeaturesByNs::GetFuncName(), args);
903  m_RawSeqToDeltaPanel = dynamic_cast<CRawSeqToDeltaByNPanel*>(m_Panel->LoadCustomPanel(m_Type));
904 }
905 
907 {
908  string descr = "Add gaps";
909  bool is_assembly_gap = false;
910  string gap_type, linkage, linkage_evidence;
912  m_RawSeqToDeltaPanel->GetAssemblyParams(is_assembly_gap, gap_type, linkage, linkage_evidence);
913  if (is_assembly_gap) {
914  return kEmptyStr;
915  }
916 
918  descr += ", adjust coding regions";
919  }
921  descr += ", keep gap length";
922  }
923  return descr;
924 }
925 
927 {
929  return kEmptyStr;
930  long min_known;
931  long max_known;
932  long min_unknown;
933  long max_unknown;
934  m_RawSeqToDeltaPanel->GetMinMax(min_known, max_known, min_unknown, max_unknown);
935 
936  string variables;
937  size_t index = 0;
938  auto& gap_vars = GetAddAssemblyGapsNArgs();
939  variables += gap_vars[index] + " = " + NStr::Int8ToString(min_unknown) + "\n";
940  variables += gap_vars[++index] + " = " + NStr::Int8ToString(max_unknown) + "\n";
941  variables += gap_vars[++index] + " = " + NStr::Int8ToString(min_known) + "\n";
942  variables += gap_vars[++index] + " = " + NStr::Int8ToString(max_known) + "\n";
943  variables += gap_vars[++index] + " = " + NStr::BoolToString(m_RawSeqToDeltaPanel->GetAdjustCDS()) + "\n";
944  variables += gap_vars[++index] + " = " + NStr::BoolToString(m_RawSeqToDeltaPanel->GetKeepGapLength());
945  return variables;
946 }
947 
949 {
950  auto& gap_vars = GetAddAssemblyGapsNArgs();
951 
952  string function;
953  function = CMacroFunction_AddGapFeaturesByNs::GetFuncName();
954  function += "(" + gap_vars.front();
955  for (size_t index = 1; index < 6; ++index) {
956  function += ", " + gap_vars[index];
957  }
958  function += ");";
959  return function;
960 }
961 
963 {
964  return { CMacroFunction_AddGapFeaturesByNs::GetFuncName() };
965 }
966 
967 
968 // CSetExceptionsTreeItemData
970  : CMacroActionItemData("Set feature exception", EMacroFieldType::eFeatQualifiers)
971 {
972 }
973 
975 {
976  x_LoadPanel(parent, "SetFeatException", GetSetExceptionArgs());
977 
978  vector<string> features = CMacroEditorContext::GetInstance().GetFeatureTypes(false);
979  m_Panel->SetControlValues(kFeatType, features);
980 
981  bool is_refseq = false;
982  vector<string> explanation_strings = CSeq_feat::GetListOfLegalExceptions(is_refseq);
983  m_Panel->SetControlValues(kExceptionType, explanation_strings);
984 }
985 
987 {
989  bool modified = (new_target != m_Target);
990  m_Target = new_target;
991  m_SelectedField = m_ArgList[kFeatType].GetValue();
992  return modified;
993 }
994 
996 {
997  string descr = "Set exception to '";
998  descr += m_ArgList[kExceptionType].GetValue() + "' for " + m_ArgList[kFeatType].GetValue() + " features ";
999 
1000  if (m_ArgList[kMoveExplanation].IsTrue()) {
1001  descr += ", copy exception to note";
1002  }
1003 
1004  string feat_product = m_ArgList[kWhereFeatProduct].GetValue();
1005  if (!NStr::EqualNocase(feat_product, "Either")) {
1006  feat_product[0] = tolower((unsigned char)feat_product[0]);
1007  descr += " where feature product is " + feat_product;
1008  }
1009  return descr;
1010 }
1011 
1013 {
1014  return kExceptionType + " = %" + m_ArgList[kExceptionType].GetValue() + "%";
1015 }
1016 
1018 {
1020  return kEmptyStr;
1021 
1023 
1024  string feat_product = m_ArgList[kWhereFeatProduct].GetValue();
1025  feat_product[0] = tolower((unsigned char)feat_product[0]);
1026 
1027  if (!NStr::EqualNocase(feat_product, "Either")) {
1028  string new_constraint = CMacroFunction_IsPresent::GetFuncName();
1029  new_constraint += "(\"product\")";
1030 
1031  if (NStr::EqualNocase(feat_product, "Absent")) {
1032  new_constraint = "NOT " + new_constraint;
1033  }
1034  constraints.emplace_back("product is " + feat_product, new_constraint);
1035  }
1036 
1037  string function;
1038  if (m_ArgList[kMoveExplanation].IsTrue()) {
1040  function += "(\"except-text\", \"comment\", \"eAppend\", \";\");\n";
1041  }
1042 
1044  function += "(\"except-text\", " + kExceptionType + ", \"eReplace\");\n";
1045 
1047  function += "(\"except\", true);";
1048  return function;
1049 }
1050 
1052 {
1056 }
1057 
1058 
1059 // CConvertGapsTreeItemData
1061  : CMacroActionItemData("Convert estimated length gaps to unknown length gaps by gap size")
1062 {
1063 }
1064 
1066 {
1067  TArgumentsVector args { GetOptionalArgs()[9] };
1068  x_LoadPanel(parent, "ConvertGapsBySize", args);
1069 }
1070 
1072 {
1073  return "Convert gaps of estimated length " + m_ArgList[kGapSizeCnv].GetValue() + " to unknown length gaps";
1074 }
1075 
1077 {
1078  return kGapSizeCnv + " = %" + m_ArgList[kGapSizeCnv].GetValue() + "%";
1079 }
1080 
1082 {
1083  if (m_ArgList[kGapSizeCnv].Empty())
1084  return kEmptyStr;
1085 
1086  return CMacroFunction_ToUnknownLengthGap::GetFuncName() + "(" + kGapSizeCnv + ");";
1087 }
1088 
1090 {
1091  return { CMacroFunction_ToUnknownLengthGap::GetFuncName() };
1092 }
1093 
1094 
1095 // CUpdateProteinsTreeItemData
1097  : CMacroActionItemData("Update protein sequences")
1098 {
1100 }
1101 
1103 {
1104  TArgumentsVector args;
1106  m_UpdateProtPanel = dynamic_cast<CMacroUpdProteinPanel*>(m_Panel->LoadCustomPanel(m_Type));
1107 }
1108 
1110 {
1111  return "Update protein sequences from file, match by ID";
1112 }
1113 
1115 {
1116  string filename = m_UpdateProtPanel->GetFilename();
1117  if (filename.empty())
1118  return kEmptyStr;
1119 
1121  function += "(\"" + filename + "\", \"match_by_id\");";
1122  return function;
1123 }
1124 
1126 {
1128 }
1129 
1130 bool CUpdateProteinsTreeItemData::SetData(const vector<CFuncWithArgs>& func_info)
1131 {
1132  if (!m_UpdateProtPanel || func_info.size() != 1)
1133  return false;
1134 
1135  const auto& fn = func_info.front();
1137  auto it = fn.m_FArgs.find(NMacroArgs::kTableName);
1138  if (it != fn.m_FArgs.end()) {
1139  m_UpdateProtPanel->SetFilename(it->second);
1140  return true;
1141  }
1142  }
1143 
1144  return false;
1145 }
1146 
1147 
User-defined methods of the data storage class.
static const char * kGapType
virtual string GetMacroDescription() const
virtual void x_AddParamPanel(wxWindow *parent)
virtual string GetFunction(TConstraints &constraints) const
virtual vector< string > GetFunctionNames() const
virtual vector< string > GetFunctionNames() const
virtual void x_AddParamPanel(wxWindow *parent)
virtual string GetMacroDescription() const
virtual string GetFunction(TConstraints &constraints) const
virtual string GetMacroDescription() const
virtual string GetFunction(TConstraints &constraints) const
virtual vector< string > GetFunctionNames() const
virtual void x_AddParamPanel(wxWindow *parent)
CAddGeneXrefTreeItemData(const string &description)
virtual vector< string > GetFunctionNames() const
virtual void x_AddParamPanel(wxWindow *parent)
virtual string GetFunction(TConstraints &constraints) const
virtual string GetMacroDescription() const
virtual void x_AddParamPanel(wxWindow *parent)
virtual string GetMacroDescription() const
virtual vector< string > GetFunctionNames() const
virtual string GetFunction(TConstraints &constraints) const
virtual void x_AddParamPanel(wxWindow *parent)
virtual string GetMacroDescription() const
virtual vector< string > GetFunctionNames() const
virtual string GetFunction(TConstraints &constraints) const
CDiscrepancyAutofixTreeItemData(const string &description)
CDiscrepancyAutofixTreeItemData.
virtual vector< string > GetFunctionNames() const
virtual string GetFunction(TConstraints &constraints) const
virtual void x_AddParamPanel(wxWindow *parent)
CFixCapsLastNameTreeItemData(const string &description)
virtual string GetFunction(TConstraints &constraints) const
virtual vector< string > GetFunctionNames() const
CFixMouseStrainTreeItemData(const string &description)
virtual string GetFunction(TConstraints &constraints) const
virtual vector< string > GetFunctionNames() const
CTempString x_GetFncName() const
virtual vector< string > GetFunctionNames() const
virtual string GetFunction(TConstraints &constraints) const
CFixPrimerTreeItemData(const string &description, bool fixI)
virtual string GetFunction(TConstraints &constraints) const
CFixPubCapsTreeItemData(const string &description, EMacroFieldType type)
virtual string GetMacroDescription() const
virtual vector< string > GetFunctionNames() const
virtual void x_AddParamPanel(wxWindow *parent)
virtual string GetMacroDescription() const
virtual vector< string > GetFunctionNames() const
virtual void x_AddParamPanel(wxWindow *parent)
virtual string GetFunction(TConstraints &constraints) const
CFixSrcQualsTreeItemData(const string &description)
virtual vector< string > GetFunctionNames() const
virtual string GetFunction(TConstraints &constraints) const
virtual void x_AddParamPanel(wxWindow *parent)
virtual string GetMacroDescription() const
CFixSubsrcFormatTreeItemData(const string &description)
EMacroFieldType m_FieldType
for actions such as appply/edit/etc.
vector< string > x_GetPubFunctions() const
vector< string > GetFeatureTypes(bool for_removal=false, bool to_create=false, bool include_all=false) const
string GetAsnPathToFieldName(const string &field, EMacroFieldType type, const string &target=kEmptyStr)
static CMacroEditorContext & GetInstance()
vector< string > GetFieldNames(EMacroFieldType type) const
void SetFilename(const string &fname)
static string GetLabelForType(EPubFieldType field_type)
void GetMinMax(long &min_known, long &max_known, long &min_unknown, long &max_unknown)
void SetAssemblyParams(bool is_assembly_gap, const string &gap_type, const string &linkage, const string &linkage_evidence)
void SetMinMax(const long min_known, const long max_known, const long min_unknown, const long max_unknown)
void GetAssemblyParams(bool &is_assembly_gap, int &gap_type, int &linkage, int &linkage_evidence)
virtual vector< string > GetFunctionNames() const
virtual string GetFunction(TConstraints &constraints) const
CRemoveGeneXrefTreeItemData(const string &description)
virtual string GetMacroDescription() const
virtual void x_AddParamPanel(wxWindow *parent)
string x_TranslateType(const string &dlg_type) const
virtual vector< string > GetFunctionNames() const
virtual string GetFunction(TConstraints &constraints) const
CRestoreRNAEditingTreeItemData(const string &description)
virtual void x_AddParamPanel(wxWindow *parent)
CRetranslateCDSTreeItemData(const string &description)
virtual vector< string > GetFunctionNames() const
virtual string GetFunction(TConstraints &constraints) const
virtual void x_AddParamPanel(wxWindow *parent)
static vector< string > GetListOfLegalExceptions(bool include_refseq)
Produces the list of legal exceptions.
Definition: Seq_feat.cpp:526
virtual vector< string > GetFunctionNames() const
virtual void x_AddParamPanel(wxWindow *parent)
virtual string GetFunction(TConstraints &constraints) 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
virtual void x_AddParamPanel(wxWindow *parent)
virtual string GetFunction(TConstraints &constraints) const
bool SetData(const vector< CFuncWithArgs > &func_info)
virtual vector< string > GetFunctionNames() const
CMacroUpdProteinPanel * m_UpdateProtPanel
virtual string GetMacroDescription() const
virtual vector< string > GetFunctionNames() const
CUpdateReplacedECTreeItemData(const string &description)
virtual string GetMacroDescription() const
virtual string GetFunction(TConstraints &constraints) const
virtual void x_AddParamPanel(wxWindow *parent)
CRawSeqToDeltaByNPanel * m_RawSeqToDeltaPanel
bool SetData(const vector< CFuncWithArgs > &func_info)
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
eTestNames GetDiscrepancyCaseName(string_view)
@ eAutofix
TTestNamesSet GetDiscrepancyTests(TGroup group)
bool Empty(const CNcbiOstrstream &src)
Definition: fileutil.cpp:523
static int type
Definition: getdata.c:31
static DbTestEntry * tests
Definition: testodbc.c:388
static CTempString GetFuncName()
static CTempString GetFuncName()
static CTempString GetFuncName()
static CTempString GetFuncName()
static CTempString GetFuncName()
static CTempString GetFuncName()
static const char * sm_PubAuthors
static CTempString GetFuncName()
static CTempString GetFuncName()
static CTempString GetFuncName()
static CTempString GetFuncName()
static CTempString GetFuncName()
static CTempString GetFuncName()
static CTempString GetFuncName()
static CTempString GetFuncName()
#define ENUM_METHOD_NAME(EnumName)
Definition: serialbase.hpp:994
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static bool StringToBool(const CTempString str)
Convert string to bool.
Definition: ncbistr.cpp:2812
static string SizetToString(size_t value, TNumToStringFlags flags=0, int base=10)
Convert size_t to string.
Definition: ncbistr.cpp:2742
static string Int8ToString(Int8 value, TNumToStringFlags flags=0, int base=10)
Convert Int8 to string.
Definition: ncbistr.hpp:5153
#define kEmptyStr
Definition: ncbistr.hpp:123
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
Definition: ncbistr.cpp:630
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:3452
#define NPOS
Definition: ncbistr.hpp:133
static const string BoolToString(bool value)
Convert bool to string.
Definition: ncbistr.cpp:2806
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5078
static long StringToLong(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to long.
Definition: ncbistr.cpp:653
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:5406
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:5347
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:3396
static string & ToLower(string &str)
Convert string to lower case – string& version.
Definition: ncbistr.cpp:405
@ fSplit_Tokenize
All delimiters are merged and trimmed, to get non-empty tokens only.
Definition: ncbistr.hpp:2510
vector< macro::SArgMetaData > TArgumentsVector
Functions used in the DO/DONE section affecting the top seq-entry.
USING_SCOPE(objects)
string GetResolveFuncForPubQualConst(const string &field, const string &rt_var, TConstraints &constraints, EMacroFieldType field_type)
CTempString UpdateTargetForFeatures(const string &feature, const string &qualifier, bool for_removal=false)
void UpdateConstraintsForFeatures(TConstraints &constraints, const string &feature)
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".
void OnAutodefCompleteSelected(CArgumentList &list, CArgument &arg)
string GetResolveFuncForPubQual(const string &field, string &rt_var, TConstraints &constraints)
void OnMiscFeatRuleSelected(CArgumentList &list, CArgument &arg)
const vector< string > & GetAddAssemblyGapsNArgs()
const TArgumentsVector & GetUpdateRpldECNumbersArgs()
const string kMinUnknown
const string kWhereFeatProduct
const TArgumentsVector & GetRemoveGeneXrefArgs()
const string kDelUnrecog
const string kMiscFeatRule
const string kExceptionType
const string kToField
const TArgumentsVector & GetSetArgs()
const string kListFeatRule
const string kInconsTaxa
const string kProteinName
const string kFromField
const string kField
const string kTableName
const string kAutodefCompl
const string kLinkEvidence
const string kKeepGapLength
const TArgumentsVector & GetSetExceptionArgs()
const string kSuppressingType
const TArgumentsVector & GetFixPubCapsArgs()
const string kTestName
const string kMinKnown
const string kMaxUnknown
const string kDelMultRepl
const string kNecessaryType
const TArgumentsVector & GetAutodefArgs()
const TArgumentsVector & GetOptionalArgs()
const TArgumentsVector & GetDiscrReportArgs()
const TArgumentsVector & GetConvertSetArgs()
const string kSourceField
const string kGapSizeCnv
const string kFeatType
const string kDelImproper
const string kLinkage
const string kMaxKnown
const string kAdjustCDS
const string kPunctonly
const string kMoveExplanation
const string kObeyStopCodon
constexpr bool empty(list< Ts... >) noexcept
int tolower(Uchar c)
Definition: ncbictype.hpp:72
#define count
Definition: type.c:6
#define _ASSERT
C++ wrappers for the Perl-compatible regular expression (PCRE) library.
Modified on Fri Sep 20 14:58:09 2024 by modify_doxy.py rev. 669887