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

Go to the SVN repository for this file.

1 /* $Id: table_reader_macro.cpp 47403 2023-03-08 19:36:58Z 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 #include <ncbi_pch.hpp>
32 
53 #include <chrono>
54 
55 
56 
59 
61  CRef<CUser_object> column_properties, const SColumnDelimiters& del_options,
62  CConstraintPanel* constraint_panel, bool test)
63 {
64  if (test) {
65  m_Filename = ToStdString(filename);
66  }
67  else {
68  auto mapped_path = GetAbsolutePath(filename);
69  m_Filename = ToStdString(mapped_path);
70  }
71  m_ColProperties.Reset(column_properties);
72  m_ConstraintPnl = constraint_panel;
73 
74  LOG_POST(Info << "Column properties:\n" << MSerial_AsnText << m_ColProperties.GetObject());
75 
78  NCBI_THROW(CException, eUnknown, "Table must have an ID column");
79  }
80 
81  TVecMacroNames macros;
82  for (auto&& it : m_MacroVec) {
83  string script = x_GetMacro(it, del_options);
84  if (it.m_CreateProteins) {
85  macros.push_back(x_GetCreateProtFeatsMacro());
86  }
87  macros.push_back(script);
88  }
89  return macros;
90 }
91 
93 {
94  if (!m_ColProperties->IsSetData())
95  return;
96 
97  m_MacroVec.clear();
99 
100  for (auto&& it : m_ColProperties->GetData()) {
101  string column = "0";
102  if (it->IsSetLabel() && it->GetLabel().IsStr()) {
103  column = it->GetLabel().GetStr().substr(string("Column.").length(), NPOS);
104  }
105  if (column == "0") {
107  break;
108  }
109 
110  if (it->IsSetData() && it->GetData().IsStr()) {
111  string col_meta_info = it->GetData().GetStr();
112  string skipped = NMItemData::GetPropertyFromInfo(col_meta_info, "skipped");
113  if (skipped == "true") {
114  continue;
115  }
116 
117  bool match_col = NStr::StringToBool(NMItemData::GetPropertyFromInfo(col_meta_info, "match"));
118  string name = NMItemData::GetPropertyFromInfo(col_meta_info, "name");
119  string qualifier = NMItemData::GetPropertyFromInfo(col_meta_info, "qualifier");
120  string qualifier_type = NMItemData::GetPropertyFromInfo(col_meta_info, "qual_type");
121 
122  _ASSERT(!name.empty());
123  _ASSERT(!qualifier.empty());
124  _ASSERT(!qualifier_type.empty());
125 
126  if (match_col) {
128  m_MatchField.m_GUIName = qualifier;
130  m_MatchField.m_MacroName = x_GetIterator(qualifier_type, m_MatchFieldType, qualifier);
131  // temporarily store the target for the matching field in the 'm_MacroName' member
132  _ASSERT(NStr::StartsWith(name, "match "));
133  }
134  else {
136  string iterator = x_GetIterator(qualifier_type, field_type, qualifier, true);
137  auto it = find_if(m_MacroVec.begin(), m_MacroVec.end(),
138  [field_type, &iterator](const SOneMacroData& elem){ return elem.m_Fieldtype == field_type; });
139 
140  if (it != m_MacroVec.end()) {
141  if (it->m_Iterator.empty()) {
142  it->m_Iterator = iterator;
143  }
144  it->m_Values.emplace_back(qualifier, column);
145  it->m_ColumnInfo.push_back(col_meta_info);
146  }
147  else {
148  SOneMacroData new_data(iterator);
149  new_data.m_Fieldtype = field_type;
150  new_data.m_Values.emplace_back(qualifier, column);
151  new_data.m_ColumnInfo.push_back(col_meta_info);
152  m_MacroVec.push_back(new_data);
153  }
154  }
155  }
156  }
157 }
158 
160 {
161  string macro_script = "MACRO TableReaderMacro \"Description\"\n";
162  macro_script += "VAR\n";
163  bool list_update_mrna = (data.m_Fieldtype == EMacroFieldType::eFeatQualifiers) ||
164  (data.m_Fieldtype == EMacroFieldType::eCdsGeneProt);
165 
166  macro_script += x_GetVariables(del_options, list_update_mrna) + "\n";
167  macro_script += "FOR EACH " + data.m_Iterator + "\n";
168 
169  TStringPairsVector constraints = x_GetStringConstraint(data.m_Iterator);
170  x_GetMatchFieldConstraint(data, del_options.m_Del, constraints);
171  string do_function = x_GetFunction(data, constraints);
172 
173  vector<string> pure_constraints;
174  pure_constraints.reserve(constraints.size());
175  for (auto p : constraints) {
176  pure_constraints.push_back(p.second);
177  }
178  macro_script += "WHERE " + NStr::Join(pure_constraints, " AND ") + "\n";
179  macro_script += "DO\n" + do_function + "\nDONE\n";
180  macro_script += "---------------------------------------------------\n";
181  return macro_script;
182 }
183 
185 {
186  string macro_script = "MACRO CreateProtFeats \"Create full length protein features\"\n";
187  macro_script += "FOR EACH TSEntry\n";
188  macro_script += "DO\n" + macro::CMacroFunction_CreateProteinFeats::GetFuncName() + "();\nDONE\n";
189  macro_script += "---------------------------------------------------\n";
190  return macro_script;
191 }
192 
193 string CTableReaderMacro::x_GetVariables(const SColumnDelimiters& del_options, bool list_update_mrna) const
194 {
195  string variables;
196  variables += NMacroArgs::kTableName + " = \"" + m_Filename + "\"\n";
197  variables += NMacroArgs::kMergeDel + " = " + NStr::BoolToString(del_options.m_Merge_delimiters) + "\n";
198  variables += NMacroArgs::kSplitFirst + " = " + NStr::BoolToString(del_options.m_Split_first_col) + "\n";
199  variables += NMacroArgs::kConvertMulti + " = " + NStr::BoolToString(del_options.m_Multispace_to_tab) + "\n";
200  variables += NMacroArgs::kMergeFirst + " = " + NStr::BoolToString(del_options.m_Merge_first_two_cols) + "\n";
201  variables += NMacroArgs::kMultipleSpsOnly + " = " + NStr::BoolToString(del_options.m_Multiple_spaces_only);
202  if (list_update_mrna) {
203  variables += "\n" + NMacroArgs::kUpdatemRNA + " = false";
204  }
205 
206  return variables;
207 }
208 
209 string CTableReaderMacro::x_GetIterator(const string& qual_type, EMacroFieldType& field_type,
210  const string& qualifier, bool apply)
211 {
212  if (qual_type.empty())
213  return kEmptyStr;
214  if (NStr::EqualNocase(qual_type, "taxname") || NStr::StartsWith(qual_type, "Source ")) {
215  field_type = EMacroFieldType::eBiosourceAll;
216  return macro::CMacroBioData::sm_BioSource;
217  }
218  else if (NStr::EqualNocase(qual_type, kFieldTypeSeqId)) {
219  field_type = EMacroFieldType::eSeqID;
220  return kEmptyStr;
221  }
222  else if (NStr::StartsWith(qual_type, "DBLink")) {
223  field_type = EMacroFieldType::eDBLink;
224  return macro::CMacroBioData::sm_SeqNa;
225  }
226  else if (NStr::StartsWith(qual_type, "MolInfo", NStr::eNocase)) {
227  field_type = EMacroFieldType::eMolinfo;
228  if (apply) {
229  return macro::CMacroBioData::sm_Seq;
230  }
231  else {
232  return macro::CMacroBioData::sm_MolInfo;
233  }
234  }
235  else if (NStr::StartsWith(qual_type, "Structured Comment")) {
236  field_type = EMacroFieldType::eStructComment;
237  return macro::CMacroBioData::sm_StrComm;
238  }
239  else if (NStr::StartsWith(qual_type, "Pub", NStr::eNocase)) {
240  field_type = EMacroFieldType::ePubdesc;
241  return macro::CMacroBioData::sm_Pubdesc;
242  }
243  else if (NStr::StartsWith(qual_type, "Misc ")) {
245  return macro::CMacroBioData::sm_SeqNa;
246  }
247  else if (NStr::StartsWith(qual_type, "CDS-Gene-Prot", NStr::eNocase)) {
248  field_type = EMacroFieldType::eCdsGeneProt;
249  CTempString new_target = NMItemData::UpdateTargetForCdsGeneProt(qualifier);
250  return new_target;
251  }
252  else if (NStr::StartsWith(qual_type, "Feature ")) {
254  vector<string> tokens;
255  NStr::Split(qualifier, " ", tokens);
256  if (tokens.size() == 2) {
257  CTempString new_target = NMItemData::UpdateTargetForFeatures(tokens[0], tokens[1]);
258  return new_target;
259  }
260  else {
261  return macro::CMacroBioData::sm_SeqFeat;
262  }
263  }
264  else if (NStr::StartsWith(qual_type, "RNA ")) {
265  field_type = EMacroFieldType::eRNA;
266  string rna_type, ncRNA_class, rna_qual;
267  NMItemData::GetRNASpecificFieldsForTableReader(qualifier, rna_type, ncRNA_class, rna_qual);
268  CTempString new_target = NMItemData::UpdateTargetForRnas(rna_type);
269  return new_target;
270  }
271  return kEmptyStr;
272 }
273 
275 {
276  auto del = delimiter;
277  if (del == "\t") del = "\\t";
278 
279  string constraint;
280 
282  vector<string> tokens;
283  NStr::Split(m_MatchField.m_GUIName, " ", tokens);
284  if (tokens.size() == 2) {
285  constraint = CFeatureFieldNamePanel::s_GetMacroFieldName(tokens[0], tokens[1], data.m_Iterator /*, selected_field */);
286  }
287  }
289  constraint = CCDSGeneProtFieldNamePanel::s_GetMacroFieldName(m_MatchField.m_GUIName, data.m_Iterator /*, selected_field */);
290  }
292  string rna_type, ncRNA_class, rna_qual;
294  constraint = CRNAFieldNamePanel::s_GetMacroFieldName(rna_type, rna_qual, data.m_Iterator /*, selected_field */);
295  }
296  else if (data.m_Fieldtype != m_MatchFieldType) {
298  m_MatchFieldType, data.m_Iterator);
299  if (path.find(',') != NPOS) {
300  vector<string> tokens;
301  NStr::Split(path, ",", tokens);
302  path = "\"" + tokens[0] + "\", \"" + tokens[1] + "\"";
303  }
304  else if (path.find('(') != NPOS) {
305  // do nothing
306  }
307  else {
308  path = "\"" + path + "\"";
309  }
310 
311 
313  constraint = path;
314  }
316 
317  if (data.m_Iterator == macro::CMacroBioData::sm_MolInfo) {
318  constraint = macro::CMacroFunction_GetSeqdesc::sm_BsrcForMolinfo + string("(") + path + ")";
319  }
320  else if (data.m_Iterator == macro::CMacroBioData::sm_StrComm ||
321  data.m_Iterator == macro::CMacroBioData::sm_Pubdesc) {
322  constraint = macro::CMacroFunction_GetSeqdesc::sm_BsrcForSeqdesc + string("(") + path + ")";
323  }
324  else if (data.m_Iterator == macro::CMacroBioData::sm_Seq ||
325  data.m_Iterator == macro::CMacroBioData::sm_SeqNa) {
326  constraint = macro::CMacroFunction_GetSeqdesc::sm_BsrcForSeq + string("(") + path + ")";
327  }
328  else if (CFieldNamePanel::IsFeature(data.m_Iterator)) {
329  constraint = macro::CMacroFunction_GetSeqdesc::sm_BsrcForFeat + string("(") + path + ")";
330  }
331  else if (data.m_Iterator == macro::CMacroBioData::sm_BioSource) {
332  constraint = path;
333  }
334 
335  m_MatchField.m_MacroName = constraint;
337  }
339  bool is_inst_field = NStr::StartsWith(path, "\"inst.");
340 
341  if (data.m_Iterator == macro::CMacroBioData::sm_MolInfo) {
342  if (is_inst_field) {
343  constraint = CTempString(macro::CMacroFunction_GetSequence::sm_SeqForDescr) + "(" + path + ")";
344  }
345  }
346  else if (data.m_Iterator == macro::CMacroBioData::sm_Seqdesc) {
347  if (is_inst_field) {
348  constraint = CTempString(macro::CMacroFunction_GetSequence::sm_SeqForDescr) + "(" + path + ")";
349  }
350  }
351  else if (CFieldNamePanel::IsFeature(data.m_Iterator)) {
352  if (is_inst_field) {
353  constraint = CTempString(macro::CMacroFunction_GetSequence::sm_SeqForFeat) + "(" + path + ")";
354  }
355  else {
356  constraint = CTempString(macro::CMacroFunction_GetSeqdesc::sm_MolinfoForFeat) + "(" + path + ")";
357  }
358  }
359  else if (data.m_Iterator == macro::CMacroBioData::sm_BioSource) {
360  if (is_inst_field) {
361  constraint = CTempString(macro::CMacroFunction_GetSequence::sm_SeqForDescr) + "(" + path + ")";
362  }
363  else {
364  constraint = CTempString(macro::CMacroFunction_GetSeqdesc::sm_MolinfoForBsrc) + "(" + path + ")";
365  }
366  }
367  else if (data.m_Iterator == macro::CMacroBioData::sm_Seq ||
368  data.m_Iterator == macro::CMacroBioData::sm_SeqNa ||
369  data.m_Iterator == macro::CMacroBioData::sm_SeqAa) {
370  constraint = path;
371  }
372  }
374  // 'path' is not used
375  constraint = macro::CMacroFunction_GetDBLink::GetFuncName() + "(\"" + m_MatchField.m_GUIName + "\")";
376  }
379  constraint = macro::CMacroFunction_StructCommDatabase::GetFuncName() + "()";
380  }
382  constraint = macro::CMacroFunction_StructCommFieldname::GetFuncName() + "()";
383  }
385  string field_name = m_MatchField.m_GUIName.substr(
387  NStr::TruncateSpacesInPlace(field_name);
388 
389  constraint = macro::CMacroFunction_StructCommField::GetFuncName();
390  constraint += "(\"" + field_name + "\")";
391  }
392  }
394  constraint = path;
395  }
396  }
397 
398  if (!constraint.empty()) {
399  m_MatchField.m_MacroName = constraint;
401  }
402 
403  constraints.emplace_back(kEmptyStr, CApplyTableItemData::s_GetMatchFieldConstraint(m_MatchField, del, data.m_Fieldtype, data.m_Iterator));
404 }
405 
407 {
408  TStringPairsVector constraints;
409  if (!m_ConstraintPnl)
410  return constraints;
411 
412  string field_in_macro;
413  CFieldNamePanel* field_name_panel = m_ConstraintPnl->GetFieldNamePanel();
414  if (field_name_panel) {
415  string field_name = field_name_panel->GetFieldName(false);
416  field_in_macro = field_name_panel->GetMacroFieldName(target);
417  }
418 
419  string str_constraint = m_ConstraintPnl->GetMacroStringConstraint(field_in_macro);
420  if (!str_constraint.empty()) {
421  constraints.emplace_back(field_in_macro, str_constraint);
422  }
423  return constraints;
424 }
425 
426 
428 {
429  string function;
430  if (data.m_Fieldtype == EMacroFieldType::eBiosourceAll) {
431  function = CApplySrcTableTreeItemData::s_GetFunction(data.m_Values, constraints, false, data.m_ColumnInfo);
432  }
433  else if (data.m_Fieldtype == EMacroFieldType::eDBLink) {
434  function = CApplyDBlinkTableTreeItemData::s_GetFunction(data.m_Values, constraints, false, data.m_ColumnInfo);
435  }
436  else if (data.m_Fieldtype == EMacroFieldType::eStructComment) {
437  function = CApplyStrCommTableTreeItemData::s_GetFunction(data.m_Values, constraints, false, data.m_ColumnInfo);
438  }
439  else if (data.m_Fieldtype == EMacroFieldType::eMolinfo) {
440  function = CApplyMolinfoTableTreeItemData::s_GetFunction(data.m_Values, constraints, false, data.m_ColumnInfo);
441  }
442  else if (data.m_Fieldtype == EMacroFieldType::eMiscDescriptors) {
443  function = CApplyMiscTableTreeItemData::s_GetFunction(data.m_Values, constraints, false, data.m_ColumnInfo);
444  }
445  else if (data.m_Fieldtype == EMacroFieldType::ePubdesc) {
446  function = CApplyPubTableTreeItemData::s_GetFunction(data.m_Values, constraints, false, data.m_ColumnInfo);
447  }
448  else if (data.m_Fieldtype == EMacroFieldType::eCdsGeneProt) {
449  string first_field = data.m_Values.front().first;
450  string feat_type, feat_qual;
451  NMItemData::GetFeatureAndField(first_field, feat_type, feat_qual);
452 
453  NMItemData::UpdateConstraintsForDualCdsGeneProt(constraints, feat_type);
454 
455  bool update_mrna = false;
456  function = CApplyCDSGeneProtTableTreeItemData::s_GetFunction(data.m_Values, constraints, false,
457  data.m_Iterator, update_mrna, data.m_ColumnInfo);
458  }
459  else if (data.m_Fieldtype == EMacroFieldType::eFeatQualifiers) {
460  // the first field's feature type determines the asn selector of the macro
461  string first_field = data.m_Values.front().first;
462  vector<string> tokens;
463  NStr::Split(first_field, " ", tokens);
464  if (tokens.size() == 2) {
465  NMItemData::UpdateConstraintsForFeatures(constraints, tokens[0]);
466  }
467  bool update_mrna = false;
468  function = CApplyFeatTableTreeItemData::s_GetFunction(data.m_Values, constraints, false,
469  data.m_Iterator, update_mrna, data.m_ColumnInfo);
470  }
471  else if (data.m_Fieldtype == EMacroFieldType::eRNA) {
472  string first_field = data.m_Values.front().first;
473  string rna_type, ncRNA_class, rna_qual;
474  NMItemData::GetRNASpecificFieldsForTableReader(first_field, rna_type, ncRNA_class, rna_qual);
475 
476  NMItemData::UpdateConstraintsForRnas(constraints, rna_type, ncRNA_class);
477 
478  function = CApplyRNATableTreeItemData::s_GetFunction(data.m_Values, constraints, false,
479  rna_type, data.m_ColumnInfo);
480  }
481 
482  if (data.m_Iterator == macro::CMacroBioData::sm_Protein &&
483  (data.m_Fieldtype == EMacroFieldType::eCdsGeneProt ||
484  data.m_Fieldtype == EMacroFieldType::eFeatQualifiers)) {
485  for (auto&& it : data.m_Values) {
486  if (NStr::EqualNocase(it.first, "protein name") ||
487  NStr::EqualNocase(it.first, "CDS product") ||
488  NStr::EqualNocase(it.first, "Protein product") ||
489  macro::NMacroUtil::StringsAreEquivalent(it.first, "protein EC number") ||
490  macro::NMacroUtil::StringsAreEquivalent(it.first, "CDS EC number")) {
491  data.m_CreateProteins = true;
492  }
493  }
494  }
495  return function;
496 }
497 
499 {
500  if (macros.empty()) {
501  LOG_POST(Info << "List of macros generated by Table Reader is empty");
502  return false;
503  }
504 
505  CRef<CMacroCmdComposite> macro_cmd(new CMacroCmdComposite("Execute macros for Table Reader"));
506  bool status = true;
507 
508  bool apply_pmid = false;
509  for (auto& it : macros) {
510  if (it.find(macro::CMacroFunction_SetPubPMID::GetFuncName()) != NPOS)
511  apply_pmid = true;
512  }
513 
514  if (apply_pmid) {
516  if (cmd) {
517  cmd->Execute();
518  macro_cmd->AddCommand(*cmd);
519  }
520  }
521 
522  auto start = chrono::steady_clock::now();
523  macro::CMacroEngine macro_engine;
524  bool data_updated = false;
525  string report_all;
526  string ignored_lines;
527 
528  for (auto&& it : macros) {
529  LOG_POST(Info << it);
530  CRef<macro::CMacroRep> macro_rep(macro_engine.Parse(it));
531  if (!macro_rep) {
532  LOG_POST(Info << "Parsing the macro for Table Reader has failed");
533  return false;
534  }
535 
536  macro::CMacroBioData bio_data(entry);
537  try {
538  macro_engine.Exec(*macro_rep, bio_data, macro_cmd, true);
539  }
540  catch (const macro::CMacroExecException& e) {
541  status = false;
542  if (e.GetErrCode() == macro::CMacroExecException::eMultipleEntries) {
543  // There was a problem and Undo Manager was not involved
544  macro_cmd->Execute(); // this call resets state to let Unexecute be run
545  macro_cmd->Unexecute();
546 
547  string msg = e.ReportAll();
548  size_t pos = msg.find("'");
549  size_t end_pos = msg.find(" ([Error]");
550  if (pos != NPOS && end_pos != NPOS) {
551  msg = msg.substr(pos, end_pos - pos);
552  }
554  report->SetTitle(wxT("Duplicate row ids"));
555  report->SetText(wxString(msg));
556  report->Show(true);
557  NCBI_THROW(CException, eInvalid, "Multiple rows apply to the same object. Cannot continue.");
558  }
559  }
560  catch (const CException& err) {
561  status = false;
562  LOG_POST(Info << "Execution of the macro has failed at " <<
563  macro_rep->GetTitle() << " step:\n" << err.ReportAll());
564  break;
565  }
566 
567  const auto& macro_stat = macro_engine.GetStatistics();
568  const auto& report = macro_stat.GetMacroReport();
569  if (!report.GetLog().empty()) {
570  report_all += report.GetName() + ":\n" + report.GetLog() + "\n";
571  }
572  else {
573  const auto& logs = macro_stat.GetFunctionsLog();
574  if (!logs.empty()) {
575  report_all += report.GetName() + ":\n";
576  }
577  for (const auto& it : logs) {
578  report_all += it->Print() + "\n";
579  }
580  }
581 
582  if (!report.GetErrorLog().empty()) {
583  report_all += "\nERRORS:\n" + report.GetErrorLog();
584  }
585 
586  const auto& unmatched = macro_stat.GetUnmatchedTableEntries();
587  if (!unmatched.empty()) {
588  _ASSERT(unmatched.size() == 1);
589  string temp = unmatched.front().first;
590  int count = unmatched.front().second;
591 
592  size_t nl_pos = temp.find("\n");
593  while (nl_pos != NPOS && count > 0) {
594  temp = temp.substr(nl_pos + 1);
595  nl_pos = temp.find("\n");
596  string value = temp.substr(0, nl_pos);
597  if (!s_LooksLikeHeader(value) && ignored_lines.find(value) == NPOS) {
598  if (!ignored_lines.empty()) {
599  ignored_lines += "\n";
600  }
601  ignored_lines += value;
602  }
603  count--;
604  }
605 
606  }
607 
608  data_updated |= macro_stat.HasDataUpdated();
609  }
610 
611  // 'status' signals only whether the macro was executed successfully or not
612  // it does not tell whether there was any actual data update
613  if (status) {
614  if (apply_pmid) {
616  if (cmd) {
617  cmd->Execute();
618  macro_cmd->AddCommand(*cmd);
619  }
620  }
621 
622  // Introduce Undo Manager or undo changes in case of error
623  cmd_processor->Execute(macro_cmd);
624 
625  auto stop = chrono::steady_clock::now();
626  chrono::duration<double> elapsed = stop - start;
627  LOG_POST(Info << "Total time spent on executing the macro is: " << elapsed.count() << " seconds.");
628  }
629  else {
630  // There was a problem and Undo Manager was not involved
631  macro_cmd->Execute(); // this call resets state to let Unexecute be run
632  macro_cmd->Unexecute();
633 
634  }
635 
636  if (!data_updated) {
637  NcbiInfoBox("Table was applied successfully. No data change has occurred.");
638  }
639  else if (!ignored_lines.empty()) {
640  NcbiInfoBox("No matches were found for these values present in the table:\n" + ignored_lines);
641  }
642 
643 #if _DEBUG
644  LOG_POST(Info << report_all);
645 #endif
646  return status;
647 }
648 
650 {
651  if (NStr::EqualNocase(value, "sequence") ||
652  NStr::EqualNocase(value, "accession") ||
657  NStr::StartsWith(value, "bankit", NStr::eNocase) ||
658  NStr::StartsWith(value, "filename", NStr::eNocase) ||
659  macro::NMacroUtil::StringsAreEquivalent(value, "file-id/seq-id") ||
661  return true;
662  return false;
663 }
664 
666 
static string s_GetFunction(const TStringPairsVector &values, TConstraints &constraints, bool del_enabled, const string &target, bool update_mrna, const vector< string > &column_info={})
static string s_GetFunction(const TStringPairsVector &values, TConstraints &constraints, bool del_enabled, const vector< string > &column_info={})
static string s_GetFunction(const TStringPairsVector &values, TConstraints &constraints, bool del_enabled, const string &target, bool update_mrna, const vector< string > &column_info={})
static string s_GetFunction(const TStringPairsVector &values, TConstraints &constraints, bool del_enabled, const vector< string > &column_info={})
static string s_GetFunction(const TStringPairsVector &values, TConstraints &constraints, bool del_enabled, const vector< string > &column_info={})
static string s_GetFunction(const TStringPairsVector &values, TConstraints &constraints, bool del_enabled, const vector< string > &column_info={})
static string s_GetFunction(const TStringPairsVector &values, TConstraints &constraints, bool del_enabled, const string &target_rna_type, const vector< string > &column_info={})
static string s_GetFunction(const TStringPairsVector &values, TConstraints &constraints, bool del_enabled, const vector< string > &column_info={})
static string s_GetFunction(const TStringPairsVector &values, TConstraints &constraints, bool del_enabled, const vector< string > &column_info={})
static string s_GetMatchFieldConstraint(const SFieldFromTable &match_field, const string &delimiter, EMacroFieldType field_type, const string &target=kEmptyStr)
static string s_GetMacroFieldName(const string &field_name, const string &target, const string &selected_field=kEmptyStr)
void AddCommand(IEditCommand &command)
CFieldNamePanel * GetFieldNamePanel(void)
string GetMacroStringConstraint(const string &field_name)
static string s_GetMacroFieldName(const string &feature, const string &qualifier, const string &target, const string &selected_field=kEmptyStr)
static string AutoMatch(string field_name)
virtual string GetFieldName(const bool subfield=false)=0
Returns the name of the field as selected in the panel.
virtual string GetMacroFieldName(const string &target, const string &selected_field=kEmptyStr)
static bool IsFeature(const string &target)
void SetText(const wxString &text)
implements special composite command, which does not call to its internal commands when run the very ...
string GetAsnPathToFieldName(const string &field, EMacroFieldType type, const string &target=kEmptyStr)
static CMacroEditorContext & GetInstance()
static CRef< CCmdComposite > GetPropagateUpCommand(objects::CSeq_entry_Handle seh)
static CRef< CCmdComposite > GetPropagateDownCommand(objects::CSeq_entry_Handle seh)
static string s_GetMacroFieldName(const string &rna_type, const string &qual_field, const string &target, const string &selected_field=kEmptyStr)
CSeq_entry_Handle –.
TVecMacroNames CreateMacros(const wxString &filename, CRef< objects::CUser_object > column_properties, const SColumnDelimiters &del_options, CConstraintPanel *panel=nullptr, bool test=false)
CMacroWorker::TVecMacroNames TVecMacroNames
SFieldFromTable m_MatchField
TStringPairsVector x_GetStringConstraint(const string &target)
static bool s_LooksLikeHeader(const string &value)
vector< SOneMacroData > m_MacroVec
string x_GetFunction(SOneMacroData &data, TStringPairsVector &constraints)
CConstraintPanel * m_ConstraintPnl
void x_GetMatchFieldConstraint(const SOneMacroData &data, const string &delimiter, TStringPairsVector &constraints)
string x_GetVariables(const SColumnDelimiters &del_options, bool list_update_mrna=false) const
EMacroFieldType m_MatchFieldType
CConstRef< objects::CUser_object > m_ColProperties
string x_GetIterator(const string &qual_type, EMacroFieldType &field_type, const string &qualifier, bool apply=false)
string x_GetMacro(SOneMacroData &data, const SColumnDelimiters &del_options)
bool RunMacro(const TVecMacroNames &macros, objects::CSeq_entry_Handle entry, ICommandProccessor *cmd_processor)
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
Definition: tempstr.hpp:65
Undo/Redo interface for editing operations.
virtual void Execute(IEditCommand *command, wxWindow *window=0)=0
const char * kStructCommFieldName
const char * kFieldTypeSeqId
const char * kStructCommDBName
const char * kStructCommFieldValuePair
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
#define test(a, b, c, d, e)
Definition: numeric.c:170
static const char * column
Definition: stats.c:23
char data[12]
Definition: iconv.c:80
string
Definition: cgiapp.hpp:690
#define NULL
Definition: ncbistd.hpp:225
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
Definition: ncbidiag.hpp:226
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
Definition: ncbiexpt.hpp:704
string ReportAll(TDiagPostFlags flags=eDPF_Exception) const
Report all exceptions.
Definition: ncbiexpt.cpp:370
void Info(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1185
bool StringsAreEquivalent(const string &name1, const string &name2)
Definition: macro_util.cpp:397
virtual void Execute()
Do the editing action.
virtual void Unexecute()
Undo (opposite to Execute())
EDialogReturnValue NcbiInfoBox(const string &message, const string &title="Info")
specialized Message Box function for reporting general information messages
#define MSerial_AsnText
I/O stream manipulators –.
Definition: serialbase.hpp:696
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:1439
TObjectType & GetObject(void) const
Get object.
Definition: ncbiobj.hpp:1697
#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
vector< pair< string, string > > TStringPairsVector
Definition: ncbistr.hpp:4804
#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:3452
#define NPOS
Definition: ncbistr.hpp:133
static const string BoolToString(bool value)
Convert bool to string.
Definition: ncbistr.cpp:2806
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate whitespace in a string (in-place)
Definition: ncbistr.cpp:3192
static string Join(const TContainer &arr, const CTempString &delim)
Join strings using the specified delimiter.
Definition: ncbistr.hpp:2699
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
@ eNocase
Case insensitive compare.
Definition: ncbistr.hpp:1206
Macro engine for macro execution.
Macro exceptions.
Functions used in the DO/DONE section affecting the top seq-entry.
#define wxT(x)
Definition: muParser.cpp:41
void UpdateConstraintsForDualCdsGeneProt(TConstraints &constraints, const string &src_feat)
CTempString UpdateTargetForFeatures(const string &feature, const string &qualifier, bool for_removal=false)
void UpdateConstraintsForFeatures(TConstraints &constraints, const string &feature)
void GetRNASpecificFieldsForTableReader(const string &field_name, string &rna_type, string &ncRNA_type, string &rna_qual)
CTempString UpdateTargetForRnas(const string &rna_type)
void UpdateConstraintsForRnas(TConstraints &constraints, const CArgumentList &arg_list)
CTempString UpdateTargetForCdsGeneProt(const string &fieldname)
void GetFeatureAndField(const string &field_name, string &feature, string &field)
string GetPropertyFromInfo(const string &info, const string &property)
const string kConvertMulti
const string kTableName
const string kMultipleSpsOnly
const string kSplitFirst
const string kMergeDel
const string kUpdatemRNA
const string kMergeFirst
constexpr bool empty(list< Ts... >) noexcept
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
#define count
static const char delimiter[]
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
USING_SCOPE(objects)
#define _ASSERT
wxString GetAbsolutePath(const wxString &localpath)
Definition: wx_utils.cpp:188
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
Modified on Fri Sep 20 14:57:57 2024 by modify_doxy.py rev. 669887