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

Go to the SVN repository for this file.

1 /* $Id: table_reader.cpp 45436 2020-08-03 17:23:15Z 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: Colleen Bollin, Andrea Asztalos
27 */
28 
29 #include <ncbi_pch.hpp>
30 #include <corelib/ncbiexpt.hpp>
33 
40 
41 #include <wx/progdlg.h>
42 #include <wx/evtloop.h>
43 
46 
49 
50 CMiscSeqTable::CMiscSeqTable(CRef<CSeq_table> table, CSeq_entry_Handle entry, edit::CSeqIdGuesser &id_guesser, CRef<CUser_object> column_properties,
51  const string& constraint_field, CRef<edit::CStringConstraint> string_constraint, ICommandProccessor* cmd_processor)
52  : m_Table(table), m_Seh(entry), m_id_guesser(id_guesser), m_ColProperties(column_properties),
53  m_ConstrField(constraint_field), m_StrConstraint(string_constraint),
54  m_CmdProccessor(cmd_processor)
55 {
56 }
57 
59 {
60  CRef<CMacroCmdComposite> apply_cmd(new CMacroCmdComposite("Apply table to entry"));
61  bool status = false;
62  try {
63  status = x_ApplyMiscSeqTableToSeqEntry(apply_cmd);
64  }
65  catch (CException& e) {
66  apply_cmd->Execute();
67  apply_cmd->Unexecute();
68  NCBI_RETHROW_SAME(e, e.GetMsg());
69  }
70 
71  if (status) {
72  // Introduce Undo Manager or undo changes in case of error
73  if (m_CmdProccessor) {
74  m_CmdProccessor->Execute(apply_cmd);
75  }
76  }
77  else {
78  // There was a problem and Undo Manager was not involved
79  apply_cmd->Execute(); // this call resets state to let Unexecute be run
80  apply_cmd->Unexecute();
81  NcbiMessageBox("Unable to apply table");
82  }
83 }
84 
85 namespace {
86  const char* kMatchString = "match ";
87 
88  string s_AdjustFieldName(const string& field_name, CFieldNamePanel::EFieldType field_type)
89  {
90  string adjust_field = field_name;
91 
92  if (field_type != CFieldNamePanel::eFieldType_CDSGeneProt &&
93  field_type != CFieldNamePanel::eFieldType_Pub &&
95  field_type != CFieldNamePanel::eFieldType_Misc) {
96  size_t pos = adjust_field.find(' ');
97  if (pos != string::npos) {
98  adjust_field = adjust_field.substr(pos + 1, string::npos);
99  }
100  }
101  return adjust_field;
102  }
103 
104  bool s_GetFieldType(string field_name, CFieldNamePanel::EFieldType& guess_field_type)
105  {
106  switch (guess_field_type) {
108  {
109  vector<CFieldNamePanel::EFieldType> guess_preference;
110  guess_preference.push_back(CFieldNamePanel::eFieldType_Source);
111  guess_preference.push_back(CFieldNamePanel::eFieldType_CDSGeneProt);
112  guess_preference.push_back(CFieldNamePanel::eFieldType_RNA);
113  guess_preference.push_back(CFieldNamePanel::eFieldType_Feature);
114  guess_preference.push_back(CFieldNamePanel::eFieldType_Misc);
115  guess_preference.push_back(CFieldNamePanel::eFieldType_Pub);
116  guess_preference.push_back(CFieldNamePanel::eFieldType_DBLink);
117  guess_preference.push_back(CFieldNamePanel::eFieldType_MolInfo);
118  for (auto& it : guess_preference) {
119  if (s_GetFieldType(field_name, it)) {
120  guess_field_type = it;
121  return true;
122  }
123  }
124  }
125  break;
127  return (!CFieldChoicePanel::AutoMatchSrc(field_name).empty());
129  return (!CFieldChoicePanel::AutoMatchFeat(field_name).empty());
131  return (!CFieldChoicePanel::AutoMatchCGP(field_name).empty());
133  return (!CFieldChoicePanel::AutoMatchRNA(field_name).empty());
135  return (!CFieldChoicePanel::AutoMatchMisc(field_name).empty());
137  return (!CFieldChoicePanel::AutoMatchPub(field_name).empty());
139  return (!CFieldChoicePanel::AutoMatchDBLink(field_name).empty());
141  return (!CFieldChoicePanel::AutoMatchMolInfo(field_name).empty());
142  default:
143  break;
144  }
145 
146  return false;
147  }
148 
149  CFieldNamePanel::EFieldType s_GuessFieldType(const string& field_name)
150  {
152  if (NStr::EqualNocase(field_name, "taxname")) {
154  }
155  else if (NStr::EqualNocase(field_name, "protein name")) {
157  }
158  else if (NStr::StartsWith(field_name, "author ", NStr::eNocase) ||
159  NStr::EqualNocase(field_name, "journal") ||
160  NStr::EqualNocase(field_name, "volume") || NStr::EqualNocase(field_name, "issue") ||
161  NStr::EqualNocase(field_name, "pages") || NStr::EqualNocase(field_name, "title") ||
162  NStr::EqualNocase(field_name, "pmid") || NStr::EqualNocase(field_name, "status")) {
164  }
165  else if (NStr::StartsWith(field_name, "Structured", NStr::eNocase)) {
167  }
168  else if (NStr::StartsWith(field_name, kDefinitionLineLabel, NStr::eNocase)) {
170  }
171  else if (NStr::EqualNocase(field_name, kBankITComment)) {
173  }
174  else if (NStr::EqualNocase(field_name, kComment)) {
176  }
177  else if (NStr::EqualNocase(field_name, kFileSeqId)) {
179  }
180  else if (NStr::EqualNocase(field_name, kGeneralId)) {
182  }
183  else if (NStr::EqualNocase(field_name, kLocalId)) {
185  }
186  else if (NStr::EqualNocase(field_name, kFieldTypeSeqId)
187  || NStr::EqualNocase(field_name, "accession")) {
189  }
190  return type;
191  }
192 
193  CFieldNamePanel::EFieldType s_GetFieldType(const string& field_name)
194  {
195  // Note: field_name does not contain the field type names, as in 'Source qualifier acronym'
196  auto field_type = s_GuessFieldType(field_name);
197 
198  if (field_type == CFieldNamePanel::eFieldType_Unknown) {
199  s_GetFieldType(field_name, field_type);
200  }
201 
202  return field_type;
203  }
204 
205  int s_GetSubtype(const string& field_name, CFieldNamePanel::EFieldType field_type)
206  {
207  int subtype = -1;
208 
209  if (field_type == CFieldNamePanel::eFieldType_Feature) {
210  string field(field_name);
211  size_t pos = field_name.find(' ');
212  if (pos != string::npos) {
213  field = field_name.substr(0, pos);
214  }
215  return CSeqFeatData::SubtypeNameToValue(field);
216  }
217  else if (field_type == CFieldNamePanel::eFieldType_CDSGeneProt) {
218  if (NStr::StartsWith(field_name, "protein")) {
220  }
221  else if (NStr::StartsWith(field_name, "CDS") || field_name == "codon-start") {
223  }
224  else if (NStr::StartsWith(field_name, "gene")) {
226  }
227  else if (NStr::StartsWith(field_name, "mRNA")) {
229  }
230  else if (NStr::StartsWith(field_name, "mat_peptide")) {
232  }
233  }
234  else if (field_type == CFieldNamePanel::eFieldType_RNA) {
235  if (NStr::StartsWith(field_name, "preRNA")) {
237  }
238  else if (NStr::StartsWith(field_name, "mRNA")) {
240  }
241  else if (NStr::StartsWith(field_name, "tRNA")) {
243  }
244  else if (NStr::StartsWith(field_name, "rRNA")) {
246  }
247  else if (NStr::StartsWith(field_name, "ncRNA")) {
248  if (field_name.find("snRNA ") != string::npos) {
250  }
251  else if (field_name.find("scRNA ") != string::npos) {
253  }
254  else if (field_name.find("snoRNA ") != string::npos) {
256  }
258  }
259  else if (NStr::StartsWith(field_name, "tmRNA")) {
261  }
262  else if (NStr::StartsWith(field_name, "miscRNA")) {
264  }
265  }
266  return subtype;
267  }
268 
269 
270  string s_GetPropFromMetaInfo(const string& meta_string, const string& prop_name)
271  {
272  string value;
273 
274  string tag = "&" + prop_name + "=";
275 
276  size_t tag_idx = meta_string.find(tag);
277  if (tag_idx != string::npos) {
278  // End of value is the start of the next value qualifier (this allows
279  // embedded blanks in values)
280  size_t tag_end_idx = meta_string.find_first_of("&", tag_idx + 1);
281  size_t start_idx = tag_idx + string(tag).length();
282 
283  if (tag_end_idx == string::npos) {
284  value = meta_string.substr(start_idx, meta_string.length() - start_idx);
285  }
286  else {
287  value = meta_string.substr(start_idx, tag_end_idx - start_idx);
288  }
289  }
290 
291  return value;
292  }
293 
294  edit::EExistingText s_GetExistingTextInstructionFromText(const string& update_rule, const string& separator)
295  {
297 
298  if (NStr::EqualNocase(update_rule, "append")) {
299  if (NStr::Equal(separator, ";")) {
301  }
302  else if (NStr::Equal(separator, " ")) {
304  }
305  else if (NStr::Equal(separator, ":")) {
307  }
308  else if (NStr::Equal(separator, ",")) {
310  }
311  else if (NStr::Equal(separator, "")) {
313  }
314  }
315  else if (NStr::Equal(update_rule, "prefix")) {
316  if (NStr::Equal(separator, ";")) {
318  }
319  else if (NStr::Equal(separator, " ")) {
321  }
322  else if (NStr::Equal(separator, ":")) {
324  }
325  else if (NStr::Equal(separator, ",")) {
327  }
328  else if (NStr::Equal(separator, "")) {
330  }
331  }
332  else if (NStr::Equal(update_rule, "ignore")) {
334  }
335  else if (NStr::Equal(update_rule, "add_new_qual")) {
337  }
338  else if (NStr::Equal(update_rule, "replace")) {
340  }
341 
342  return rval;
343  }
344 
345  bool s_IsSequenceIDField(const string& field)
346  {
349  }
350 } // end of namespace
351 
353 {
354  set<string> seen_id, duplicate_id;
355  for (int row = 0; row < m_Table->GetNum_rows(); row++) {
356  string id_value;
357 
358  if (id_col->GetData().IsId()) {
359  id_col->GetData().GetId()[row]->GetLabel(&id_value, CSeq_id::eContent);
360  }
361  else if (id_col->GetData().IsInt()) {
362  id_value = NStr::NumericToString(id_col->GetData().GetInt()[row]);
363  }
364  else if (id_col->GetData().IsString()) {
365  id_value = id_col->GetData().GetString()[row];
366  }
367 
368  if (!NStr::IsBlank(id_value)) {
369  if (seen_id.find(id_value) != seen_id.end()) {
370  duplicate_id.insert(id_value);
371  }
372  seen_id.insert(id_value);
373  }
374  }
375  if (!duplicate_id.empty()) {
376  CGenericReportDlg* report = new CGenericReportDlg(NULL);
377  report->SetTitle(wxT("Duplicate row ids"));
378  report->SetText(wxString(NStr::Join(duplicate_id, "\n")));
379  report->Show(true);
380  NCBI_THROW(CException, eInvalid, "Multiple rows apply to the same object. Cannot continue.");
381  }
382 }
383 
385 {
386  wxBusyCursor wait;
387  if (!wxEventLoopBase::GetActive() || !wxEventLoopBase::GetActive()->IsYielding())
388  wxTheApp->Yield();
389  bool modified = false;
390 
391  size_t id_col_num = x_FindIDColumn();
392 
393  x_CreateEditingActions(id_col_num);
394 
395  bool desc_present = false;
396  for (auto action : m_ActionList) {
397  if (action && dynamic_cast<IEditingActionDesc*>(action.GetPointer()))
398  desc_present = true;
399  }
400 
401  if (desc_present) {
403  if (cmd) {
404  cmd->Execute();
405  apply_cmd->AddCommand(*cmd);
406  }
407  }
408 
409  x_InterpretColumnProperties(id_col_num);
410  x_GetIdColumnProps(id_col_num);
411 
412  map<string, set<CSeq_entry_Handle> > value_to_sehs;
414 
415  wxGenericProgressDialog progress("Applying table values", wxEmptyString);
416  CRef<CSeqTable_column> id_col = m_Table->GetColumns()[id_col_num];
417  x_CheckDuplicateIds(id_col);
418  for (int row = 0; row < m_Table->GetNum_rows(); row++) {
419  string id_value;
420 
421  if (id_col->GetData().IsId()) {
422  id_col->GetData().GetId()[row]->GetLabel(&id_value, CSeq_id::eContent);
423  }
424  else if (id_col->GetData().IsInt()) {
425  id_value = NStr::NumericToString(id_col->GetData().GetInt()[row]);
426  }
427  else if (id_col->GetData().IsString()) {
428  id_value = id_col->GetData().GetString()[row];
429  }
430 
431 
432  CRef<edit::CStringConstraint> id_constraint(new edit::CStringConstraint(id_value, edit::CStringConstraint::eMatchType_Equals));
434  x_SetTopSeqEntryForActions(id_value, sehs, value_to_sehs);
435  for (auto &seh : sehs)
436  {
437  for (auto& it : m_ActionList)
438  {
439  if (it)
440  it->SetTopSeqEntry(seh);
441  }
442  modified |= x_SetConstraints(id_col_num, id_constraint) && x_ApplyRowToEntry(row, id_col_num, apply_cmd);
443  for (auto& it : m_ActionList)
444  {
445  if (it)
446  {
447  it->ResetChangedDescriptors();
448  it->ResetChangedFeatures();
449  }
450  }
451  }
452  if (row % 100 == 0)
453  {
454  progress.Update(100*row/m_Table->GetNum_rows());
455  if (!wxEventLoopBase::GetActive() || !wxEventLoopBase::GetActive()->IsYielding())
456  wxTheApp->Yield();
457  }
458  }
459 
460  if (desc_present) {
462  if (cmd) {
463  cmd->Execute();
464  apply_cmd->AddCommand(*cmd);
465  }
466  }
467 
468  return modified;
469 }
470 
472 {
473  for (size_t col_num = 0; col_num < m_Table->GetColumns().size(); col_num++) {
474  if (NStr::StartsWith(m_Table->GetColumns()[col_num]->GetHeader().GetTitle(), kMatchString)) {
475  return col_num;
476  }
477  }
478  // by default, id column is 0 if no other column is specified
479  return 0;
480 }
481 
482 void CMiscSeqTable::x_GetIdColumnProps(size_t id_col_num)
483 {
484  CRef<CSeqTable_column> id_col = m_Table->GetColumns()[id_col_num];
485 
486  m_IdFieldName = id_col->GetHeader().GetTitle();
487  if (NStr::StartsWith(m_IdFieldName, kMatchString)) {
488  m_IdFieldName = m_IdFieldName.substr(CTempString(kMatchString).length());
489  }
490 
491  m_IdFieldType = s_GetFieldType(m_IdFieldName);
492  m_IdSubtype = s_GetSubtype(m_IdFieldName, m_IdFieldType);
493  m_IdFieldName = s_AdjustFieldName(m_IdFieldName, m_IdFieldType);
494 }
495 
497 {
498  m_ActionList.clear();
499 
500  for (size_t col_num = 0; col_num < m_Table->GetColumns().size(); col_num++) {
501  if (col_num != id_col_num) {
502  string field_name;
503  if (m_Table->GetColumns()[col_num]->IsSetHeader()
504  && m_Table->GetColumns()[col_num]->GetHeader().IsSetTitle()) {
505  field_name = m_Table->GetColumns()[col_num]->GetHeader().GetTitle();
506  }
507 
508  CIRef<IEditingAction> action;
509  if (!field_name.empty()) {
510  CFieldNamePanel::EFieldType field_type = s_GetFieldType(field_name);
511  int field_subtype = s_GetSubtype(field_name, field_type);
512  field_name = s_AdjustFieldName(field_name, field_type);
513  action = CreateAction(m_Seh, field_name, field_type, field_subtype);
514  }
515  _ASSERT(action);
516  m_ActionList.push_back(action);
517  }
518  }
519 }
520 
522 {
523  m_EraseIfBlank.clear();
524  m_ExistingText.clear();
525 
526  for (size_t col_num = 0; col_num < m_Table->GetColumns().size(); col_num++) {
527  if (col_num != id_col_num) {
528  if (col_num < m_ColProperties->GetData().size()) {
529  const CUser_field& field_meta_info = m_ColProperties->GetData()[col_num].GetObject();
530 
531  string col_meta_info = field_meta_info.GetData().GetStr();
532  string ur = s_GetPropFromMetaInfo(col_meta_info, "update_rule");
533  string ts = s_GetPropFromMetaInfo(col_meta_info, "text_separator");
534  m_ExistingText.push_back(s_GetExistingTextInstructionFromText(ur, ts));
535  string blanks = s_GetPropFromMetaInfo(col_meta_info, "blanks");
536  if (NStr::EqualNocase(blanks, "erase")) {
537  m_EraseIfBlank.push_back(true);
538  }
539  else {
540  m_EraseIfBlank.push_back(false);
541  }
542  }
543  else {
545  m_EraseIfBlank.push_back(false);
546  }
547  }
548  }
549 }
550 
551 void CMiscSeqTable::x_SetTopSeqEntryForActions(const string& id_value, set<CSeq_entry_Handle> &sehs, const map<string, set<CSeq_entry_Handle> > &value_to_sehs)
552 {
553  sehs.clear();
554  bool found(false);
555  if (s_IsSequenceIDField(m_IdFieldName)) {
556  CRef<CSeq_id> seqid = m_id_guesser.Guess(id_value);
557  if (seqid) {
558  CBioseq_Handle bsh = m_Seh.GetScope().GetBioseqHandle(*seqid);
560  sehs.insert(bseh);
561  found = true;
562  }
563  }
564 
565  if (!found) {
566  auto it = value_to_sehs.find(id_value);
567  if (it != value_to_sehs.end())
568  sehs = it->second;
569  }
570 }
571 
573  string id_field_name, CFieldNamePanel::EFieldType id_field_type, int id_subtype)
574 {
575  value_to_sehs.clear();
576  if (s_IsSequenceIDField(id_field_name))
577  {
578  id_field_name = "Local ID";
579  id_field_type = CFieldNamePanel::eFieldType_LocalId;
580  id_subtype = -1;
581  }
582 
583 
584  CIRef<IEditingAction> id_action = CreateAction(seh, id_field_name, id_field_type, id_subtype);
585  id_action->NOOP();
586 
587  const map<CSeq_feat_Handle, CRef<CSeq_feat>> feathdlesmap = id_action->GetChangedFeatures();
588  const map<const CSeqdesc*, CRef<CSeqdesc>> descrmap = id_action->GetChangedDescriptors();
589 
590  for (auto &fh : feathdlesmap) {
591  CBioseq_Handle bsh = seh.GetScope().GetBioseqHandle(fh.first.GetLocation());
593  id_action->SetTopSeqEntry(bseh);
594  id_action->NOOP();
595 
596  const vector<string>& values = id_action->GetChangedValues();
597  for (auto v : values)
598  value_to_sehs[v].insert(bseh);
599  id_action->ResetChangedValues();
600  }
601 
602  if (!descrmap.empty()) {
603  for ( CSeq_entry_CI entry_it(seh, CSeq_entry_CI::fRecursive|CSeq_entry_CI::fIncludeGivenEntry); entry_it; ++entry_it ) {
604  for ( CSeqdesc_CI desc_iter(*entry_it, CSeqdesc::e_not_set, 1); desc_iter; ++desc_iter) {
605  if (descrmap.find(&*desc_iter) != descrmap.end()) {
606  CSeq_entry_Handle bseh = desc_iter.GetSeq_entry_Handle();
607  id_action->SetTopSeqEntry(bseh);
608  id_action->NOOP();
609  const vector<string>& values = id_action->GetChangedValues();
610  for (auto v : values)
611  value_to_sehs[v].insert(bseh);
612  id_action->ResetChangedValues();
613  }
614  }
615  }
616  }
617 }
618 
620 {
621  bool ID_is_Seqid = s_IsSequenceIDField(m_IdFieldName);
622  if (!m_StrConstraint && ID_is_Seqid) {
623  return true;
624  }
625 
627  int constr_field_subtype = -1;
628 
629  if (m_StrConstraint) {
630  constr_field_type = s_GetFieldType(m_ConstrField);
631  constr_field_subtype = s_GetSubtype(m_ConstrField, constr_field_type);
632  m_ConstrField = s_AdjustFieldName(m_ConstrField, constr_field_type);
633  }
634 
635  bool rval = true;
636  TEditingActionVec::iterator iter = m_ActionList.begin();
637  for (size_t col_num = 0; col_num < m_Table->GetColumns().size() && rval && iter != m_ActionList.end(); col_num++) {
638  if (col_num != id_col_num) {
639  string field_name;
640  if (m_Table->GetColumns()[col_num]->IsSetHeader()
641  && m_Table->GetColumns()[col_num]->GetHeader().IsSetTitle()) {
642  field_name = m_Table->GetColumns()[col_num]->GetHeader().GetTitle();
643  }
644 
645  if (!field_name.empty()) {
646  CFieldNamePanel::EFieldType field_type = s_GetFieldType(field_name);
647  int field_subtype = s_GetSubtype(field_name, field_type);
648  field_name = s_AdjustFieldName(field_name, field_type);
649 
651  if (m_StrConstraint) {
652  string ncRNA_class;
653  CRef<CEditingActionConstraint> field_constraint =
654  CreateEditingActionConstraint(field_name, field_type, field_subtype, kEmptyStr, m_ConstrField, constr_field_type, constr_field_subtype, ncRNA_class, CRef<CConstraintMatcher>(new CSimpleConstraintMatcher(m_StrConstraint)));
655  if (!field_constraint) {
656  rval = false;
657  }
658  constraint = field_constraint;
659  }
660 
661  if (!ID_is_Seqid) {
662  string ncRNA_class;
663  CRef<CEditingActionConstraint> idfield_constraint =
664  CreateEditingActionConstraint(field_name, field_type, field_subtype, kEmptyStr, m_IdFieldName, m_IdFieldType, m_IdSubtype, ncRNA_class, CRef<CConstraintMatcher>(new CSimpleConstraintMatcher(id_constraint)));
665  if (!idfield_constraint) {
666  rval = false;
667  }
668  if (constraint) {
669  *constraint += idfield_constraint;
670  }
671  else {
672  constraint = idfield_constraint;
673  }
674  }
675 
676  if (constraint && *iter) {
677  (*iter)->SetConstraint(constraint);
678  }
679  }
680  ++iter;
681  }
682  }
683 
684  return rval;
685 }
686 
687 bool CMiscSeqTable::x_ApplyRowToEntry(int row, size_t id_col_num, CRef<CMacroCmdComposite> apply_cmd)
688 {
689  bool rval = false;
690  size_t col_num = 0;
691 
692  vector<bool>::iterator eb_it = m_EraseIfBlank.begin();
693  vector<edit::EExistingText>::iterator existing_text_it = m_ExistingText.begin();
694 
696  string new_val;
697  if (col_num < id_col_num) {
698  new_val = m_Table->GetColumns()[col_num]->GetData().GetString()[row];
699  }
700  else {
701  new_val = m_Table->GetColumns()[col_num + 1]->GetData().GetString()[row];
702  }
703 
704  if (*action)
705  {
706  if (new_val.empty()) {
707  rval = true;
708  if (*eb_it) {
709  (*action)->Remove();
710  CRef<CCmdComposite> cmd = (*action)->GetActionCommand();
711  if (cmd)
712  {
713  cmd->Execute();
714  apply_cmd->AddCommand(*cmd);
715  }
716  }
717  }
718  else if (!new_val.empty()) {
719  (*action)->SetExistingText(*existing_text_it);
720  (*action)->Apply(new_val);
721  CRef<CCmdComposite> cmd = (*action)->GetActionCommand();
722  if (cmd)
723  {
724  cmd->Execute();
725  apply_cmd->AddCommand(*cmd);
726  }
727  rval = true;
728  }
729  }
730 
731  col_num++;
732  eb_it++;
733  existing_text_it++;
734  }
735 
736  return rval;
737 }
738 
740 
User-defined methods of the data storage class.
CBioseq_Handle –.
void AddCommand(IEditCommand &command)
static string AutoMatchRNA(string field_name)
static string AutoMatchFeat(string field_name)
static string AutoMatchSrc(string field_name)
static string AutoMatchMolInfo(string field_name)
static string AutoMatchMisc(string field_name)
static string AutoMatchPub(string field_name)
static string AutoMatchDBLink(string field_name)
static string AutoMatchCGP(string field_name)
void SetText(const wxString &text)
implements special composite command, which does not call to its internal commands when run the very ...
CRef< objects::edit::CStringConstraint > m_StrConstraint
TEditingActionVec m_ActionList
void x_GetIdColumnProps(size_t id_col_num)
CRef< objects::CSeq_table > m_Table
bool x_SetConstraints(size_t id_col_num, CRef< edit::CStringConstraint > id_constraint)
objects::CSeq_entry_Handle m_Seh
string m_ConstrField
CFieldNamePanel::EFieldType m_IdFieldType
string m_IdFieldName
ICommandProccessor * m_CmdProccessor
size_t x_FindIDColumn()
vector< bool > m_EraseIfBlank
bool x_ApplyRowToEntry(int row, size_t id_col_num, CRef< CMacroCmdComposite > apply_cmd)
void x_CreateEditingActions(size_t id_col_num)
void x_InterpretColumnProperties(size_t id_col_num)
void x_SetTopSeqEntryForActions(const string &id_value, set< CSeq_entry_Handle > &sehs, const map< string, set< CSeq_entry_Handle > > &value_to_sehs)
static void s_GetValueToSehMap(objects::CSeq_entry_Handle seh, map< string, set< CSeq_entry_Handle > > &value_to_sehs, string id_field_name, CFieldNamePanel::EFieldType id_field_type, int id_subtype)
bool x_ApplyMiscSeqTableToSeqEntry(CRef< CMacroCmdComposite > apply_cmd)
vector< objects::edit::EExistingText > m_ExistingText
void ApplyTableToEntry()
CMiscSeqTable(CRef< objects::CSeq_table > table, objects::CSeq_entry_Handle entry, edit::CSeqIdGuesser &id_guesser, CRef< objects::CUser_object > column_properties, const string &constraint_field=kEmptyStr, CRef< objects::edit::CStringConstraint > string_constraint=CRef< edit::CStringConstraint >(NULL), ICommandProccessor *cmd_processor=NULL)
void x_CheckDuplicateIds(CRef< CSeqTable_column > id_col)
CRef< objects::CUser_object > m_ColProperties
edit::CSeqIdGuesser & m_id_guesser
static CRef< CCmdComposite > GetPropagateUpCommand(objects::CSeq_entry_Handle seh)
static CRef< CCmdComposite > GetPropagateDownCommand(objects::CSeq_entry_Handle seh)
static ESubtype SubtypeNameToValue(CTempString sName)
Turn a string into its ESubtype which is NOT necessarily related to the identifier of the enum.
CSeq_entry_CI –.
CSeq_entry_Handle –.
CSeqdesc_CI –.
Definition: seqdesc_ci.hpp:65
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_iterator end() const
Definition: map.hpp:152
bool empty() const
Definition: map.hpp:149
const_iterator find(const key_type &key) const
Definition: map.hpp:153
Definition: map.hpp:338
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
void clear()
Definition: set.hpp:153
bool empty() const
Definition: set.hpp:133
const_iterator find(const key_type &key) const
Definition: set.hpp:137
const_iterator end() const
Definition: set.hpp:136
CRef< CEditingActionConstraint > CreateEditingActionConstraint(const string &field, CFieldNamePanel::EFieldType field_type, int subtype, const string &ncRNA_class, const string &const_field, CFieldNamePanel::EFieldType const_field_type, int const_subtype, string &const_ncRNA_class, CRef< CConstraintMatcher >constraint)
CIRef< IEditingAction > CreateAction(CSeq_entry_Handle seh, const string &field, CFieldNamePanel::EFieldType field_type, int subtype, const string &ncRNA_class=kEmptyStr, CConstRef< objects::CSeq_submit > submit=CConstRef< objects::CSeq_submit >(NULL))
const char * kDefinitionLineLabel
const char * kFileSeqId
const char * kFieldTypeSeqId
const char * kComment
const char * kLocalId
const char * kGeneralId
const char * kBankITComment
const char * kSequenceIdColLabel
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
static int type
Definition: getdata.c:31
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
string
Definition: cgiapp.hpp:687
#define NULL
Definition: ncbistd.hpp:225
#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
const string & GetMsg(void) const
Get message string.
Definition: ncbiexpt.cpp:461
#define NCBI_RETHROW_SAME(prev_exception, message)
Generic macro to re-throw the same exception.
Definition: ncbiexpt.hpp:749
virtual void Execute()
Do the editing action.
virtual void Unexecute()
Undo (opposite to Execute())
EDialogReturnValue NcbiMessageBox(const string &message, TDialogType type=eDialog_Ok, EDialogIcon icon=eIcon_Exclamation, const string &title="Error", EDialogTextMode text_mode=eRaw)
Definition: message_box.cpp:48
@ eContent
Untagged human-readable accession or the like.
Definition: Seq_id.hpp:605
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
Definition: scope.cpp:95
CSeq_entry_Handle GetSeq_entry_Handle(void) const
Get parent Seq-entry handle.
CScope & GetScope(void) const
Get scope this handle belongs to.
@ fIncludeGivenEntry
Include the top (given) entry.
@ fRecursive
Iterate recursively.
TObjectType & GetObject(void)
Get object.
Definition: ncbiobj.hpp:1011
#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 bool IsBlank(const CTempString str, SIZE_TYPE pos=0)
Check if a string is blank (has no text).
Definition: ncbistr.cpp:106
static string Join(const TContainer &arr, const CTempString &delim)
Join strings using the specified delimiter.
Definition: ncbistr.hpp:2697
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 enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
Definition: ncbistr.hpp:673
static bool Equal(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2, ECase use_case=eCase)
Test for equality of a substring with another string.
Definition: ncbistr.hpp:5384
@ eNocase
Case insensitive compare.
Definition: ncbistr.hpp:1206
const TStr & GetStr(void) const
Get the variant data.
const TData & GetData(void) const
Get the Data member data.
bool IsId(void) const
Check if variant Id is selected.
const TTitle & GetTitle(void) const
Get the Title member data.
bool IsString(void) const
Check if variant String is selected.
const THeader & GetHeader(void) const
Get the Header member data.
bool IsInt(void) const
Check if variant Int is selected.
const TInt & GetInt(void) const
Get the variant data.
const TString & GetString(void) const
Get the variant data.
const TData & GetData(void) const
Get the Data member data.
const TId & GetId(void) const
Get the variant data.
@ e_not_set
No variant selected.
Definition: Seqdesc_.hpp:110
<!DOCTYPE HTML >< html > n< header > n< title > PubSeq Gateway Help Page</title > n< style > n table
#define wxT(x)
Definition: muParser.cpp:41
constexpr bool empty(list< Ts... >) noexcept
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
const char * tag
Defines NCBI C++ exception handling.
bool QualifierNamesAreEquivalent(string name1, string name2)
#define row(bind, expected)
Definition: string_bind.c:73
EExistingText
@ eExistingText_cancel
@ eExistingText_append_semi
@ eExistingText_append_space
@ eExistingText_prefix_colon
@ eExistingText_add_qual
@ eExistingText_append_none
@ eExistingText_leave_old
@ eExistingText_prefix_none
@ eExistingText_prefix_space
@ eExistingText_append_colon
@ eExistingText_prefix_comma
@ eExistingText_append_comma
@ eExistingText_prefix_semi
@ eExistingText_replace_old
Definition: type.c:6
USING_SCOPE(objects)
#define _ASSERT
Modified on Tue Apr 16 20:09:43 2024 by modify_doxy.py rev. 669887