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

Go to the SVN repository for this file.

1 /* $Id: tbl_edit_dlg.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: Colleen Bollin
27  */
28 
29 
30 #include <ncbi_pch.hpp>
31 
32 ////@begin includes
33 ////@end includes
34 
37 #include <objects/seq/Seqdesc.hpp>
40 #include <objmgr/bioseq_ci.hpp>
41 #include <objmgr/seqdesc_ci.hpp>
44 //#include <gui/packages/pkg_sequence_edit/srcedit_util.hpp>
50 
56 
57 #include <wx/msgdlg.h>
58 #include <wx/stattext.h>
59 
60 ////@begin XPM images
61 ////@end XPM images
62 
64 
66 
67 
68 /*!
69  * CTblEditDlg type definition
70  */
71 
72 IMPLEMENT_DYNAMIC_CLASS( CTblEditDlg, CBulkCmdDlg )
73 
74 
75 /*!
76  * CTblEditDlg event table definition
77  */
78 
79 BEGIN_EVENT_TABLE( CTblEditDlg, CBulkCmdDlg )
80 
81 ////@begin CTblEditDlg event table entries
83 
85 
87 
88 ////@end CTblEditDlg event table entries
89 
91 
93 
94 
95 /*!
96  * CTblEditDlg constructors
97  */
98 
100 : m_Converter (NULL)
101 {
102  Init();
103 }
104 
105 CTblEditDlg::CTblEditDlg( wxWindow* parent, CSeq_entry_Handle seh,
106  CTableCommandConverter* converter,
107  IWorkbench* workbench,
108  wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style, wxString label )
109 : m_TopSeqEntry(seh),
110  m_Converter (converter),
111  m_Workbench (workbench),
112  m_StaticLabel(label)
113 {
114  Init();
115  Create(parent, id, caption, pos, size, style);
116 }
117 
118 
119 /*!
120  * CTblEditDlg creator
121  */
122 
123 bool CTblEditDlg::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
124 {
125 ////@begin CTblEditDlg creation
126  SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
127  CBulkCmdDlg::Create( parent, id, caption, pos, size, style );
128 
129  CreateControls();
130  if (GetSizer())
131  {
132  GetSizer()->SetSizeHints(this);
133  }
134  Centre();
135 ////@end CTblEditDlg creation
136  return true;
137 }
138 
139 
140 /*!
141  * CTblEditDlg destructor
142  */
143 
145 {
146 ////@begin CTblEditDlg destruction
147 ////@end CTblEditDlg destruction
148  delete m_Converter;
149 }
150 
151 
152 /*!
153  * Member initialisation
154  */
155 
157 {
158 ////@begin CTblEditDlg member initialisation
159  m_GridHolder = NULL;
161  m_ImportBtn = NULL;
162  m_ExportBtn = NULL;
163 ////@end CTblEditDlg member initialisation
164  m_SaveFileDir = wxEmptyString;
165  m_SaveFileName = wxEmptyString;
166 }
167 
168 
169 /*!
170  * Control creation for CTblEditDlg
171  */
172 
174 {
175 ////@begin CTblEditDlg content construction
176  // Generated by DialogBlocks, 10/06/2013 17:54:01 (unregistered)
177 
178  CTblEditDlg* itemCBulkCmdDlg1 = this;
179 
180  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
181  itemCBulkCmdDlg1->SetSizer(itemBoxSizer2);
182 
183  m_GridHolder = new wxBoxSizer(wxVERTICAL);
184  itemBoxSizer2->Add(m_GridHolder, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
185 
186  m_TableControlsSizer = new wxBoxSizer(wxHORIZONTAL);
187  itemBoxSizer2->Add(m_TableControlsSizer, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
188 
189  m_ImportBtn = new wxButton( itemCBulkCmdDlg1, ID_IMPORT_TABLE, _("Import Table"), wxDefaultPosition, wxDefaultSize, 0 );
190  m_TableControlsSizer->Add(m_ImportBtn, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
191 
192  m_ExportBtn = new wxButton( itemCBulkCmdDlg1, ID_EXPORT_TABLE, _("Export Table"), wxDefaultPosition, wxDefaultSize, 0 );
193  m_TableControlsSizer->Add(m_ExportBtn, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
194 
195  wxButton* itemButton7 = new wxButton( itemCBulkCmdDlg1, ID_CLEAR_TABLE, _("Clear Table"), wxDefaultPosition, wxDefaultSize, 0 );
196  m_TableControlsSizer->Add(itemButton7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
197 
198  wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxHORIZONTAL);
199  itemBoxSizer2->Add(itemBoxSizer8, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
200 
201  wxButton* itemButton9 = new wxButton( itemCBulkCmdDlg1, wxID_OK, _("Accept"), wxDefaultPosition, wxDefaultSize, 0 );
202  itemBoxSizer8->Add(itemButton9, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
203 
204  wxButton* itemButton10 = new wxButton( itemCBulkCmdDlg1, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
205  itemBoxSizer8->Add(itemButton10, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
206 
207 ////@end CTblEditDlg content construction
208  if (!m_StaticLabel.empty())
209  {
210  wxStaticText* staticPrompt = new wxStaticText(itemCBulkCmdDlg1, wxID_STATIC, m_StaticLabel, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER);
211  m_GridHolder->Add(staticPrompt,0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
212  }
213 
215  CRef<CSeq_table> choices = m_Converter->GetChoices(values_table);
216  int glyph_col = m_Converter->GetCollapsible();
217  m_Grid = new CSeqTableGridPanel(this, values_table, choices, glyph_col);
218  m_GridHolder->Add(m_Grid, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
219 
222 
224  if (converter) {
225  wxButton* problem_btn = new wxButton( itemCBulkCmdDlg1, ID_UPDATE_PROBLEMS, _("Recheck Problems"), wxDefaultPosition, wxDefaultSize, 0 );
226  m_TableControlsSizer->Add(problem_btn, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
227  }
228 
229  // set read-only columns
230  int pos = 0;
231  bool all_read_only = true;
232  ITERATE (CSeq_table::TColumns, it, values_table->GetColumns()) {
233  if (pos > 0) {
234  if ((*it)->IsSetHeader() && (*it)->GetHeader().IsSetTitle() && m_Converter->IsReadOnlyColumn((*it)->GetHeader().GetTitle())) {
235  m_Grid->MakeColumnReadOnly(pos - 1, true);
236  } else {
237  all_read_only = false;
238  }
239  }
240  pos++;
241  }
242  if (all_read_only) {
243  itemButton7->Show(false);
244  }
245 
246  if (!m_Workbench) {
247  m_ImportBtn->Show(false);
248  m_ExportBtn->Show(false);
249  }
250 }
251 
252 
253 /*!
254  * Should we show tooltips?
255  */
256 
258 {
259  return true;
260 }
261 
262 /*!
263  * Get bitmap resources
264  */
265 
266 wxBitmap CTblEditDlg::GetBitmapResource( const wxString& name )
267 {
268  // Bitmap retrieval
269 ////@begin CTblEditDlg bitmap retrieval
270  wxUnusedVar(name);
271  return wxNullBitmap;
272 ////@end CTblEditDlg bitmap retrieval
273 }
274 
275 /*!
276  * Get icon resources
277  */
278 
279 wxIcon CTblEditDlg::GetIconResource( const wxString& name )
280 {
281  // Icon retrieval
282 ////@begin CTblEditDlg icon retrieval
283  wxUnusedVar(name);
284  return wxNullIcon;
285 ////@end CTblEditDlg icon retrieval
286 }
287 
289 {
290  CRef<CSeq_table> values_table = m_Grid->GetValuesTable();
292 
293  return cmd;
294 }
295 
296 
298 {
299  CRef<CSeq_table> values_table = m_Grid->GetValuesTable();
300  return m_Converter->GetErrorMessage(values_table);
301 }
302 
303 
304 static int s_FindColumn( CRef<CSeq_table> table, const string& name )
305 {
306  int i = 0;
307 
308  for (i = 0; i < table->GetColumns().size(); i++) {
309  CConstRef<CSeqTable_column> col = table->GetColumns()[i];
310  if (col->IsSetHeader()) {
311  if(col->GetHeader().IsSetTitle() && NStr::Equal(col->GetHeader().GetTitle(), name)) {
312  return i;
313  }
314  if (col->GetHeader().IsSetField_name() && NStr::Equal(col->GetHeader().GetField_name(), name)) {
315  return i;
316  }
317  }
318  }
319  return -1;
320 }
321 
322 
323 static void x_SetAllTableStringValues ( CRef<CSeq_table> table, const string& val)
324 {
325  if (!table || !table->IsSetColumns()) {
326  return;
327  }
328  int i = 0;
329 
330  for (i = 0; i < table->SetColumns().size(); i++) {
331  CRef<CSeqTable_column> col = table->SetColumns()[i];
332  if (col->IsSetData() && col->GetData().IsString()) {
333  for (int j = 0; j < col->GetData().GetString().size(); j++) {
334  col->SetData().SetString()[j] = val;
335  }
336  }
337  }
338 }
339 
340 
341 // Converters
342 
344 {
345  CRef<objects::CSeqTable_column> comment_col = FindSeqTableColumnByName (values_table, column_name);
346  bool all_same = AreAllColumnValuesTheSame (comment_col, "");
347 
348  string msg = "";
349  if (!all_same) {
350  msg = column_name + " differs for different sequences.";
351  }
352  return msg;
353 }
354 
355 
356 // Converter for DBLink Fields
358 {
360  ITERATE (vector<string>, it, m_DBLinkFields) {
361  if (s_FindColumn(values_table, *it) < 0) {
362  // add the column
363  AddValueToTable(values_table, *it, "", values_table->GetNum_rows() - 1);
364  }
365  }
366  FillShortColumns(values_table);
367 
368  return values_table;
369 }
370 
371 
373 {
374  return ApplyDBLinkValuesTableToSeqEntry(values_table, seh);
375 }
376 
377 
379 {
380  CRef<CCmdComposite> cmd( new CCmdComposite("Bulk DBLink Descriptor Remove") );
381 
382  objects::CBioseq_CI b_iter(seh, objects::CSeq_inst::eMol_na);
383  for ( ; b_iter ; ++b_iter ) {
384  objects::CSeqdesc_CI desc_ci( *b_iter, objects::CSeqdesc::e_User);
385  while (desc_ci) {
386  if (desc_ci->GetUser().IsSetType()
387  && desc_ci->GetUser().GetType().IsStr()
388  && NStr::EqualNocase(desc_ci->GetUser().GetType().GetStr(), "DBLink")) {
389  CIRef<IEditCommand> cmdDelDesc(new CCmdDelDesc(desc_ci.GetSeq_entry_Handle(), *desc_ci));
390  cmd->AddCommand(*cmdDelDesc);
391  }
392  ++desc_ci;
393  }
394  }
395  return cmd;
396 }
397 
398 
400 {
401  ITERATE (vector<string>, it, m_DBLinkFields) {
402  if (NStr::EqualNocase(*it, column_name)) {
403  return *it;
404  }
405  }
406  return "";
407 }
408 
409 
411 {
412  return "Unknown error";
413 }
414 
415 
416 // Converter for comment descriptors
418 {
420  FillShortColumns(values_table);
421 
422  return values_table;
423 }
424 
425 
427 {
428  return ApplyCommentValuesTableToSeqEntry(values_table, seh, m_Label);
429 }
430 
431 
433 {
434  CRef<CCmdComposite> cmd( new CCmdComposite("Bulk Comment Descriptor Remove") );
435 
436  objects::CBioseq_CI b_iter(seh, objects::CSeq_inst::eMol_na);
437  for ( ; b_iter ; ++b_iter ) {
438  objects::CSeqdesc_CI desc_ci( *b_iter, objects::CSeqdesc::e_Comment);
439  while (desc_ci) {
440  CIRef<IEditCommand> cmdDelDesc(new CCmdDelDesc(desc_ci.GetSeq_entry_Handle(), *desc_ci));
441  cmd->AddCommand(*cmdDelDesc);
442  ++desc_ci;
443  }
444  }
445  return cmd;
446 }
447 
448 
450 {
451  return m_Label;
452 }
453 
454 
456 {
457  return "Unknown error";
458 }
459 
460 
462 {
464  bool all_same = AreAllColumnValuesTheSame (comment_col, "");
465 
466  if (all_same) {
467  return "";
468  } else {
469  return m_Label + " differs for different sequences. This is unexpected.";
470  }
471 }
472 
473 
474 // Converter for chimera comment descriptors
476 {
478  FillShortColumns(values_table);
479 
480  return values_table;
481 }
482 
483 
485 {
486  return ApplyChimeraValuesTableToSeqEntry(values_table, seh, m_Label);
487 }
488 
489 
491 {
492  CRef<CSeq_table> values_table = GetValuesTableFromSeqEntry (seh);
493  x_SetAllTableStringValues(values_table, "");
494  return ApplySrcTableToSeqEntry(values_table, seh);
495 }
496 
497 
499 {
500  return m_Label;
501 }
502 
503 
505 {
506  return "Unknown error";
507 }
508 
509 
511 {
513  bool all_same = AreAllColumnValuesTheSame (comment_col, "");
514  bool any_missing = AreAnyColumnValuesMissing (comment_col);
515  if (all_same) {
516  return "";
517  } else if (any_missing) {
518  return "Chimera program information is not provided for all sequences";
519  } else {
520  return "Chimera program information is provided but is not consistent for all sequences";
521  }
522 }
523 
524 
525 // Converter for Molinfo fields
527 {
529  FillShortColumns(values_table);
530 
531  return values_table;
532 }
533 
534 
536 {
537  return ApplyMolInfoValuesTableToSeqEntry(values_table, seh);
538 }
539 
540 
542 {
543  return ApplyMolInfoValuesTableToSeqEntry(values_table, seh, add_confirmed);
544 }
545 
546 
548 {
549  CRef<CSeq_table> values_table = GetValuesTableFromSeqEntry (seh);
550  x_SetAllTableStringValues(values_table, "");
551  return ApplySrcTableToSeqEntry(values_table, seh);
552 }
553 
554 
556 {
557  while (table->GetColumns().size() <= n) {
559  table->SetColumns().push_back(col);
560  }
561  return table->SetColumns()[n];
562 }
563 
564 
566 {
567  CRef<CSeq_table> choices(new CSeq_table());
568  // TODO: Add existing values as choices
569  int mol_pos = s_FindColumn( values_table, kMoleculeType );
570  int top_pos = s_FindColumn( values_table, kTopology );
571 
572  if (mol_pos > 0) {
573  CRef<CSeqTable_column> col = s_GetNthColumn(choices, mol_pos - 1);
574  vector<string> mol_strings = GetMoleculeTypeOptions (m_WizardType);
575  for (size_t i = 0; i < mol_strings.size(); i++) {
576  col->SetData().SetString().push_back(mol_strings[i]);
577  }
578  }
579  if (top_pos > 0) {
580  CRef<CSeqTable_column> col = s_GetNthColumn(choices, top_pos - 1);
581  col->SetData().SetString().push_back("linear");
583  col->SetData().SetString().push_back("circular");
584  }
585  }
586  return choices;
587 }
588 
589 
591 {
592  if (NStr::EqualNocase(column_name, kMoleculeType)
593  || NStr::EqualNocase(column_name, "Molecule-Type")
594  || NStr::EqualNocase(column_name, "moltype")
595  || NStr::EqualNocase(column_name, "mol-type")
596  || NStr::EqualNocase(column_name, "mol type")) {
597  return kMoleculeType;
598  } else if (NStr::EqualNocase(column_name, kTopology)) {
599  return kTopology;
600  } else {
601  return "";
602  }
603 }
604 
605 
607 {
608  return "Unknown error";
609 }
610 
611 
612 // Converter for src.genome fields
614 {
615  vector<string> qual_names;
616  qual_names.push_back("genome");
617  CRef<CSeq_table> values_table = GetSeqTableForSrcQualFromSeqEntry (seh, qual_names);
618  FillShortColumns(values_table);
619 
620  return values_table;
621 }
622 
623 
625 {
626  return ApplySrcTableToSeqEntry(values_table, seh);
627 }
628 
629 
631 {
632  CRef<CSeq_table> values_table = GetValuesTableFromSeqEntry (seh);
633  x_SetAllTableStringValues(values_table, "");
634  return ApplySrcTableToSeqEntry(values_table, seh);
635 }
636 
637 
638 
640 {
641  return "genome";
642 }
643 
644 
646 {
647  CRef<CSeq_table> choices(new CSeq_table());
648  CRef<CSeqTable_column> col = s_GetNthColumn(choices, 0);
650  for (size_t i = 0; i < strings.size(); i++) {
651  col->SetData().SetString().push_back(strings[i]);
652  }
653  return choices;
654 }
655 
656 
658 {
659  return "Unknown error";
660 }
661 
662 
664 {
665  CRef<objects::CSeqTable_column> col = FindSeqTableColumnByName (values_table, column_name);
666  bool all_same = AreAllColumnValuesTheSame (col, "");
667 
668  if (all_same) {
669  return "";
670  } else {
671  return "Sequences contain a mixture of organelles. This is unusual.";
672  }
673 }
674 
675 
676 
677 // converter for primer info
678 static const string kUniversalPrimers = "[universal primers]";
679 static const string kSpeciesSpecificPrimers = "[amplified with species-specific primers]";
680 static const string kUniversalPrimersLabel = "universal primers";
681 static const string kSpeciesSpecificPrimersLabel = "species-specific primers";
682 static const string kPrimerType = "Primer Type";
683 
684 static bool s_RemoveValueFromNote (string& note, string value)
685 {
686  bool any_change = false;
687  size_t pos = NStr::Find(note, value);
688  if (pos != string::npos) {
689  string before = "";
690  if (pos > 0) {
691  before = note.substr(0, pos);
692  }
693  string after = note.substr(pos + value.length());
694  note = before + after;
695  any_change = true;
696  }
697  return any_change;
698 }
699 
700 
702 {
703  vector<string> qual_names;
704  qual_names.push_back(kSubSourceNote);
705  qual_names.push_back("fwd-primer-name");
706  qual_names.push_back("fwd-primer-seq");
707  qual_names.push_back("rev-primer-name");
708  qual_names.push_back("rev-primer-seq");
709  CRef<CSeq_table> values_table = GetSeqTableForSrcQualFromSeqEntry (seh, qual_names);
710  FillShortColumns(values_table);
711 
713  note_col->SetHeader().SetTitle(kPrimerType);
714  for (int j = 0; j < note_col->GetData().GetString().size(); j++) {
715  if (NStr::Find(note_col->GetData().GetString()[j], kUniversalPrimers) != string::npos) {
716  note_col->SetData().SetString()[j] = kUniversalPrimersLabel;
717  } else if (NStr::Find(note_col->GetData().GetString()[j], kSpeciesSpecificPrimers) != string::npos) {
718  note_col->SetData().SetString()[j] = kSpeciesSpecificPrimersLabel;
719  } else {
720  note_col->SetData().SetString()[j] = "";
721  }
722  }
723 
724  return values_table;
725 }
726 
727 
729 {
730  vector<string> qual_names;
731  qual_names.push_back(kSubSourceNote);
732 
733  CRef<CSeq_table> orig_notes = GetSeqTableForSrcQualFromSeqEntry (seh, qual_names);
734  CRef<CSeqTable_column> orig_note_col = FindSeqTableColumnByName (orig_notes, kSubSourceNote);
735  CRef<CSeqTable_column> new_note_col = FindSeqTableColumnByName (values_table, kPrimerType);
736 
737  new_note_col->SetHeader().SetTitle(kSubSourceNote);
738  for (int j = 0; j < new_note_col->GetData().GetString().size(); j++) {
739  string orig_val = "";
740  string add_val = "";
741  if (j < orig_note_col->GetData().GetString().size()) {
742  orig_val = orig_note_col->GetData().GetString()[j];
743  add_val = orig_val;
746  }
747  string new_val = new_note_col->GetData().GetString()[j];
749  new_val = kUniversalPrimers;
750  } else if (NStr::EqualNocase(new_val, kSpeciesSpecificPrimersLabel)) {
751  new_val = kSpeciesSpecificPrimers;
752  }
753  new_note_col->SetData().SetString()[j] = new_val + add_val;
754  }
755 
756  CRef<CCmdComposite> cmd = ApplySrcTableToSeqEntry(values_table, seh);
757  return cmd;
758 }
759 
760 
762 {
763  if (NStr::EqualNocase(column_name, kPrimerType)) {
764  return kPrimerType;
765  } else if (IsFwdPrimerName(column_name)) {
766  return "fwd-primer-name";
767  } else if (IsRevPrimerName(column_name)) {
768  return "rev-primer-name";
769  } else if (IsFwdPrimerSeq(column_name)) {
770  return "fwd-primer-seq";
771  } else if (IsRevPrimerSeq(column_name)) {
772  return "rev-primer-seq";
773  } else {
774  return "";
775  }
776 }
777 
778 
780 {
781  return "Unknown error";
782 }
783 
784 
786 {
787  CRef<CSeq_table> choices(new CSeq_table());
788  CRef<CSeqTable_column> col = s_GetNthColumn(choices, 0);
789  col->SetData().SetString().push_back(kUniversalPrimersLabel);
790  col->SetData().SetString().push_back(kSpeciesSpecificPrimersLabel);
791 
792  return choices;
793 }
794 
795 
797 {
798  return kPrimerType;
799 }
800 
801 
803 {
804  CRef<CSeq_table> values_table = GetValuesTableFromSeqEntry (seh);
805  x_SetAllTableStringValues(values_table, "");
806  return GetCommandFromValuesTable (values_table, seh);
807 }
808 
809 
811 {
812  CRef<objects::CSeqTable_column> col = FindSeqTableColumnByName (values_table, column_name);
813 
814  bool is_primertype = false;
815  if (col == NULL && NStr::EqualNocase(column_name, kSubSourceNote)) {
816  is_primertype = true;
817  col = FindSeqTableColumnByName (values_table, kPrimerType);
818  } else if (NStr::EqualNocase(column_name, kPrimerType)) {
819  is_primertype = true;
820  }
821 
822  if (col == NULL) {
823  return "";
824  }
825 
826  string mixed_msg = "";
827 
828  if (is_primertype) {
829  int num_universal = 0;
830  int num_species = 0;
831  int num_both = 0;
832  int num_rows = values_table->GetNum_rows();
833 
834  for (size_t i = 0; i < col->GetData().GetSize(); i++) {
835  bool has_universal = false;
836  if (NStr::Find(col->GetData().GetString()[i], kUniversalPrimersLabel) != string::npos) {
837  num_universal++;
838  has_universal = true;
839  }
840  if (NStr::Find(col->GetData().GetString()[i], kSpeciesSpecificPrimersLabel) != string::npos) {
841  num_species++;
842  if (has_universal) {
843  num_both++;
844  }
845  }
846  }
847  if (num_both > 0) {
848  mixed_msg = "Some sequences specify both universal and species-specific primers. This is unwanted.";
849  } else if (num_universal > 0 && num_species > 0) {
850  if (num_universal + num_species < num_rows) {
851  mixed_msg = "Primer type information is missing for some sequences.";
852  } else {
853  mixed_msg = "Sequences are a mixture of universal and species-specific primers.";
854  }
855  } else if (num_universal > 0 && num_universal < num_rows) {
856  mixed_msg = "Universal primers are specifed for some but not all sequences. This is unexpected.";
857  } else if (num_species > 0 && num_species < num_rows) {
858  mixed_msg = "Species-specific primers are specifed for some but not all sequences. This is unexpected.";
859  }
860  } else {
861  bool all_same = AreAllColumnValuesTheSame (col, "");
862 
863  if (!all_same) {
864  mixed_msg = column_name + " differs for different sequences.";
865  }
866  }
867  return mixed_msg;
868 }
869 
870 
871 // Converter for Structured Comment Fields
872 
873 static string s_GetPrefixForStructuredComment (const objects::CUser_object& user)
874 {
875  string prefix = "";
876 
877  ITERATE (objects::CUser_object::TData, field_it, user.GetData()) {
878  if ((*field_it)->IsSetLabel()
879  && (*field_it)->GetLabel().IsStr()
880  && NStr::Equal((*field_it)->GetLabel().GetStr(), "StructuredCommentPrefix")
881  && (*field_it)->IsSetData()
882  && (*field_it)->GetData().IsStr()) {
883  prefix = (*field_it)->GetData().GetStr();
884  return prefix;
885  }
886  }
887  return prefix;
888 }
889 
890 
892 {
893  CRef<objects::CSeq_table> table(new objects::CSeq_table());
894  CRef<objects::CSeqTable_column> id_col(new objects::CSeqTable_column());
895  id_col->SetHeader().SetField_id(objects::CSeqTable_column_info::eField_id_location_id);
896  id_col->SetHeader().SetTitle(kSequenceIdColLabel);
897  table->SetColumns().push_back(id_col);
898 
899  int row = 0;
900  objects::CBioseq_CI b_iter(seh, objects::CSeq_inst::eMol_na);
901  for ( ; b_iter ; ++b_iter ) {
902  CRef<objects::CSeq_id> id(new objects::CSeq_id());
903  id->Assign (*(b_iter->GetSeqId()));
904  id_col->SetData().SetId().push_back(id);
905 
906  objects::CSeqdesc_CI it (*b_iter, objects::CSeqdesc::e_User);
907  while (it) {
908  if (it->GetUser().IsSetType()
909  && it->GetUser().GetType().IsStr()
910  && NStr::EqualNocase(it->GetUser().GetType().GetStr(), "StructuredComment")
912  ITERATE (objects::CUser_object::TData, field_it, it->GetUser().GetData()) {
913  if ((*field_it)->IsSetLabel()
914  && (*field_it)->GetLabel().IsStr()
915  && !NStr::EqualNocase((*field_it)->GetLabel().GetStr(), "StructuredCommentPrefix")
916  && !NStr::EqualNocase((*field_it)->GetLabel().GetStr(), "StructuredCommentSuffix")
917  && (*field_it)->IsSetData()) {
918  string existing_val = "";
919  if ((*field_it)->GetData().IsStr()) {
920  existing_val = (*field_it)->GetData().GetStr();
921  } else if ((*field_it)->GetData().IsStrs()) {
922  for (vector<CStringUTF8>::const_iterator str_it = (*field_it)->GetData().GetStrs().begin();
923  str_it != (*field_it)->GetData().GetStrs().end();
924  ++str_it) {
925  existing_val += ", " + *str_it;
926  }
927  while (NStr::StartsWith(existing_val, ", ")) {
928  existing_val = existing_val.substr(2);
929  }
930  }
931  AddValueToTable (table, (*field_it)->GetLabel().GetStr(), existing_val, row);
932  }
933  }
934  }
935  ++it;
936  }
937 
938  row++;
939  }
940 
941  table->SetNum_rows(row);
942  if (row > 0) {
943  ITERATE (vector<string>, it, m_Fields) {
944  if (s_FindColumn(table, *it) < 0) {
945  // add the column
946  AddValueToTable(table, *it, "", table->GetNum_rows() - 1);
947  }
948  }
949  }
950 
951  return table;
952 }
953 
954 
956 {
957  CRef<CCmdComposite> cmd( new CCmdComposite("Bulk Structured Comment Edit") );
958 
960  if (!id_col) {
961  return cmd;
962  }
963 
964  const objects::CSeq_table::TColumns & columns = values_table->GetColumns();
965  size_t num_cols = columns.size();
966 
967  for (size_t row = 0; row < values_table->GetNum_rows() && row < id_col->GetData().GetSize(); row++) {
968  objects::CBioseq_Handle bsh = seh.GetBioseqHandle(*(id_col->GetData().GetId()[row]));
969  CRef<objects::CSeqdesc> new_desc( new objects::CSeqdesc );
970 
971  objects::CSeqdesc_CI desc_ci( bsh, objects::CSeqdesc::e_User);
972  bool found = false;
973  while (desc_ci && !found) {
974  if (desc_ci->GetUser().IsSetType()
975  && desc_ci->GetUser().GetType().IsStr()
976  && NStr::EqualNocase(desc_ci->GetUser().GetType().GetStr(), "StructuredComment")
978  found = true;
979  new_desc->SetUser().Assign(desc_ci->GetUser());
980  } else {
981  ++desc_ci;
982  }
983  }
984 
985  bool any_change = false;
986  if (!found) {
987  any_change = true;
988  new_desc->SetUser().SetType().SetStr("StructuredComment");
989  objects::CUser_field& field = new_desc->SetUser().SetField("StructuredCommentPrefix");
990  field.SetLabel().SetStr("StructuredCommentPrefix");
991  field.SetData().SetStr(m_Prefix);
992  }
993 
994  for (size_t i = 1; i < num_cols; i++) {
995  string col_name = values_table->GetColumns()[i]->GetHeader().GetTitle();
996 
997  objects::CUser_field& field = new_desc->SetUser().SetField(col_name);
998  if (!field.IsSetLabel() || !field.GetLabel().IsStr() || NStr::IsBlank(field.GetLabel().GetStr())) {
999  field.SetLabel().SetStr(col_name);
1000  }
1001  string new_val = values_table->GetColumns()[i]->GetData().GetString()[row];
1002  field.SetData().SetStr(new_val);
1003  any_change = true;
1004  }
1005 
1006  if (!found) {
1007  any_change = true;
1008  objects::CUser_field& field = new_desc->SetUser().SetField("StructuredCommentSuffix");
1009  string suffix = m_Prefix;
1010  NStr::ReplaceInPlace(suffix, "-START##", "-END##");
1011  field.SetLabel().SetStr("StructuredCommentSuffix");
1012  field.SetData().SetStr(suffix);
1013  }
1014 
1015  if (any_change) {
1016  if (desc_ci) {
1017  CRef<CCmdChangeSeqdesc> ecmd(new CCmdChangeSeqdesc(desc_ci.GetSeq_entry_Handle(), *desc_ci, *new_desc));
1018  cmd->AddCommand (*ecmd);
1019  } else {
1020  new_desc->SetUser().SetType().SetStr("StructuredComment");
1021  cmd->AddCommand( *CRef<CCmdCreateDesc>(new CCmdCreateDesc(bsh.GetParentEntry(), *new_desc)) );
1022  }
1023  }
1024  }
1025 
1026  // send composite command
1027  return cmd;
1028 }
1029 
1030 
1032 {
1033  CRef<CCmdComposite> cmd( new CCmdComposite("Bulk Structured Comment Remove") );
1034  objects::CBioseq_CI b_iter(seh, objects::CSeq_inst::eMol_na);
1035  for ( ; b_iter ; ++b_iter ) {
1036  objects::CSeqdesc_CI desc_ci( *b_iter, objects::CSeqdesc::e_User);
1037  while (desc_ci) {
1038  if (desc_ci->GetUser().IsSetType()
1039  && desc_ci->GetUser().GetType().IsStr()
1040  && NStr::EqualNocase(desc_ci->GetUser().GetType().GetStr(), "StructuredComment")
1041  && NStr::EqualNocase(s_GetPrefixForStructuredComment(desc_ci->GetUser()), m_Prefix)) {
1042  CIRef<IEditCommand> cmdDelDesc(new CCmdDelDesc(desc_ci.GetSeq_entry_Handle(), *desc_ci));
1043  cmd->AddCommand(*cmdDelDesc);
1044  }
1045  ++desc_ci;
1046  }
1047  }
1048  return cmd;
1049 }
1050 
1051 
1053 {
1054  return column_name;
1055 }
1056 
1057 
1059 {
1060  // TODO - complain about missing fields here
1061  return "Unknown error";
1062 }
1063 
1064 
1066 (const objects::CSeq_feat& ftemplate,
1067  const TFeatureSeqTableColumnList& reqs,
1068  const TFeatureSeqTableColumnList& opts)
1069 {
1070  m_Template = new objects::CSeq_feat();
1071  m_Template->Assign(ftemplate);
1072  m_Reqs.assign(reqs.begin(), reqs.end());
1073  m_Opts.assign(opts.begin(), opts.end());
1074 }
1075 
1076 
1080  vector<string>& problems)
1081 {
1082  vector<string> add_values;
1083  for (size_t j = 0; j < val_col->GetData().GetSize(); j++) {
1084  add_values.push_back(val_col->GetData().GetString()[j]);
1085  }
1086  vector<string> add_problems = rule_col->IsValid(add_values);
1087  MergeStringVectors(problems, add_problems);
1088 }
1089 
1090 
1092 {
1093  vector<string> problems;
1094 
1095  // the first kSkipColumns columns are not associated with column handlers
1096  for (size_t i = kSkipColumns; i < values_table->GetColumns().size(); i++) {
1097  if (values_table->GetColumns()[i]->IsSetData()
1098  && (values_table->GetColumns()[i]->GetData().IsString())) {
1100  if (col) {
1101  AddProblemsToColumn(values_table->GetColumns()[i], col, problems);
1102  }
1103  }
1104  }
1105  CRef<objects::CSeqTable_column> problems_col(new objects::CSeqTable_column());
1106  problems_col->SetHeader().SetTitle(kProblems);
1107  problems_col->SetData().SetString();
1108  ITERATE(vector<string>, it, problems) {
1109  problems_col->SetData().SetString().push_back(*it);
1110  }
1111  return problems_col;
1112 }
1113 
1114 
1116 {
1118  int num_rows_to_check = 0;
1119  if (table->IsSetColumns() && table->GetColumns().size() > 0 && table->GetColumns().front()->IsSetData()) {
1120  num_rows_to_check = static_cast<int>(table->GetColumns().front()->GetData().GetId().size());
1121  }
1122 
1123  // add one for every nucleotide sequence that doesn't have one
1124  objects::CBioseq_CI bi(seh, objects::CSeq_inst::eMol_na);
1125  while (bi) {
1126  bool needed = true;
1127 
1128  for (int i = 0; i < num_rows_to_check; i++) {
1129  ITERATE(objects::CBioseq::TId, id_it, bi->GetCompleteBioseq()->GetId()) {
1130  if (table->GetColumns()[0]->GetSeq_id(i)->Compare(**id_it) == objects::CSeq_id::e_YES) {
1131  needed = false;
1132  break;
1133  }
1134  }
1135  if (!needed) {
1136  break;
1137  }
1138  }
1139  if (needed) {
1140  CRef<objects::CSeq_feat> f(new objects::CSeq_feat());
1141  f->Assign(*m_Template);
1142  CRef<objects::CSeq_id> id(new objects::CSeq_id());
1143  id->Assign(*(bi->GetSeqId()));
1144  f->SetLocation().SetInt().SetId().Assign(*id);
1145  f->SetLocation().SetInt().SetFrom(0);
1146  f->SetLocation().SetInt().SetTo(bi->GetBioseqLength() - 1);
1148  }
1149  ++bi;
1150  }
1151 
1154  if (!col) {
1155  col.Reset(new objects::CSeqTable_column());
1156  col->SetHeader().SetTitle((*it)->GetLabel());
1157  for (size_t i = 0; i < table->GetNum_rows(); i++) {
1158  col->SetData().SetString().push_back("");
1159  }
1160  table->SetColumns().push_back(col);
1161  }
1162  }
1163 
1165 
1167 
1168  return table;
1169 }
1170 
1171 
1173 {
1174  CRef<CCmdComposite> cmd(new CCmdComposite("Edit Features by table"));
1175  bool do_something = false;
1177  if (delcmd) {
1178  cmd->AddCommand(*delcmd);
1179  do_something = true;
1180  }
1181  CRef<CCmdComposite> addcmd = AddFeatureSeqTableToSeqEntry(table, seh, m_Template->GetData().GetSubtype(), m_Reqs, m_Opts);
1182  if (addcmd) {
1183  cmd->AddCommand(*addcmd);
1184  do_something = true;
1185  }
1186 
1187  if (!do_something) {
1188  cmd.Reset(NULL);
1189  }
1190  return cmd;
1191 }
1192 
1193 
1195 {
1196  // TODO - complain about missing fields here
1197  return "Unknown error";
1198 }
1199 
1200 
1202 {
1204  return cmd;
1205 }
1206 
1207 
1209 {
1210  return column_name;
1211 }
1212 
1213 
1215 {
1216  int partial_start = s_FindColumn( values_table, kPartialStart);
1217  int partial_stop = s_FindColumn( values_table, kPartialStop );
1218 
1219  CRef<objects::CSeq_table> choices(new objects::CSeq_table());
1220 
1221  vector<string> tf_strings = GetTrueFalseList();
1222  if (partial_start > 0) {
1223  CRef<CSeqTable_column> col = s_GetNthColumn(choices, partial_start - 1);
1224  for (size_t i = 0; i < tf_strings.size(); i++) {
1225  col->SetData().SetString().push_back(tf_strings[i]);
1226  }
1227  }
1228  if (partial_stop > 0) {
1229  CRef<CSeqTable_column> col = s_GetNthColumn(choices, partial_stop - 1);
1230  for (size_t i = 0; i < tf_strings.size(); i++) {
1231  col->SetData().SetString().push_back(tf_strings[i]);
1232  }
1233  }
1234 
1235  return choices;
1236 }
1237 
1238 
1239 vector<string> GetAssemblyDataFields()
1240 {
1241  vector<string> fields;
1242 
1243  fields.push_back("Assembly Method");
1244  fields.push_back("Assembly Name");
1245  fields.push_back("Sequencing Technology");
1246  fields.push_back("Coverage");
1247 
1248  return fields;
1249 }
1250 
1251 
1253 {
1255  if (!converter) {
1256  return "";
1257  }
1258  string error = "";
1259  int col = 1;
1260  vector<string> already_seen;
1261 
1262  NON_CONST_ITERATE (objects::CSeq_table::TColumns, cit, table->SetColumns()) {
1263  if ((*cit)->IsSetData() && !(*cit)->GetData().IsId()) {
1264  string orig_name = "";
1265  if ((*cit)->IsSetHeader()
1266  && (*cit)->GetHeader().IsSetTitle()) {
1267  orig_name = (*cit)->GetHeader().GetTitle();
1268  }
1269  if (NStr::IsBlank(orig_name)) {
1270  error += "Column " + NStr::NumericToString(col) + " has no header; ";
1271  } else {
1272  string new_name = converter->RemapColumnName(orig_name);
1273  if (NStr::IsBlank(new_name)) {
1274  error += "Column " + NStr::NumericToString(col) + " header '" + orig_name + "' is not recognized; ";
1275  } else {
1276  (*cit)->SetHeader().SetTitle(new_name);
1277  int as_col = 1;
1278  ITERATE (vector<string>, sit, already_seen) {
1279  if (NStr::Equal(new_name, *sit)) {
1280  error += "Column " + NStr::NumericToString(col) + " ("
1281  + orig_name + ") and column " + NStr::NumericToString(as_col)
1282  + " refer to the same field (" + new_name + "); ";
1283  }
1284  as_col++;
1285  }
1286  already_seen.push_back(new_name);
1287  }
1288  }
1289  }
1290  col++;
1291  }
1292 
1293  if (!NStr::IsBlank(error)) {
1294  error = error.substr(0, error.length() - 2);
1295  }
1296  return error;
1297 }
1298 
1299 
1300 /*!
1301  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_IMPORT_TABLE
1302  */
1303 
1304 void CTblEditDlg::OnImportTableClick( wxCommandEvent& event )
1305 {
1306  CRef<CFileLoadWizard> fileManager(new CFileLoadWizard());
1307  vector<string> format_ids;
1308  format_ids.push_back("file_loader_table");
1309  fileManager->LoadFormats(format_ids);
1310 
1311  //fileManager->SetServiceLocator(m_Workbench);
1312  vector<CIRef<IOpenObjectsPanelClient> > loadManagers;
1313  loadManagers.push_back(CIRef<IOpenObjectsPanelClient>(fileManager.GetPointer()));
1314 
1315  COpenObjectsDlg dlg(NULL);
1316  dlg.SetSize(710, 480);
1317 
1318  dlg.SetRegistryPath("Dialogs.Edit.OpenTable");
1319  dlg.SetManagers(loadManagers);
1320 
1321  if (dlg.ShowModal() == wxID_OK) {
1322  CIRef<IObjectLoader> object_loader(dlg.GetObjectLoader());
1323  if (!object_loader) {
1324  wxMessageBox(wxT("Failed to get object loader"), wxT("Error"),
1325  wxOK | wxICON_ERROR);
1326  }
1327  else {
1328  IExecuteUnit* execute_unit = dynamic_cast<IExecuteUnit*>(object_loader.GetPointer());
1329  if (execute_unit) {
1330  if (!execute_unit->PreExecute())
1331  return;
1332 
1333  if (!GUI_AsyncExecUnit(*execute_unit, wxT("Reading file(s)...")))
1334  return; // Canceled
1335 
1336  if (!execute_unit->PostExecute())
1337  return;
1338  }
1339  const IObjectLoader::TObjects& objects = object_loader->GetObjects();
1341  const CObject& ptr = obj_it->GetObject();
1342  const objects::CSeq_annot* annot = dynamic_cast<const objects::CSeq_annot*>(&ptr);
1343  if (annot && annot->IsSeq_table()) {
1344  CRef<objects::CSeq_table> input_table (new objects::CSeq_table());
1345  input_table->Assign(annot->GetData().GetSeq_table());
1346  // adjust for import
1347  FixTableAfterImport (input_table);
1348 
1349  // make sure qual names are all legit
1350  string error = x_FindBadImportColumns(input_table);
1351  if (!NStr::IsBlank(error)) {
1352  wxMessageBox(ToWxString(error), wxT("Error"),
1353  wxOK | wxICON_ERROR, this);
1354  return;
1355  }
1356 
1357  // get existing table
1359  if (!values_table) {
1360  return;
1361  }
1362 
1363  error = FindBadRows (input_table, values_table, m_TopSeqEntry);
1364  if (!NStr::IsBlank(error)) {
1365  wxMessageBox(ToWxString(error), wxT("Error"),
1366  wxOK | wxICON_ERROR, this);
1367  return;
1368  }
1369 
1370  if (CountTableColumnConflicts(values_table, *input_table) > 0) {
1371  wxMessageBox(wxT("New table conflicts with existing values"), wxT("Error"),
1372  wxOK | wxICON_ERROR, this);
1373  return;
1374  }
1375 
1376  // merge input table with existing table
1377  int num_new = CombineTables (values_table, *input_table);
1378  m_Grid->SetValuesTable(values_table);
1379  }
1380  }
1381  }
1382  }
1383 }
1384 
1385 
1386 /*!
1387  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_EXPORT_TABLE
1388  */
1389 
1390 void CTblEditDlg::OnExportTableClick( wxCommandEvent& event )
1391 {
1393  if (!grid_table) {
1394  return;
1395  }
1396 
1397  CRef<objects::CSeq_table> values_table(new objects::CSeq_table());
1398  values_table->Assign(*grid_table);
1399 
1400  SaveTableFile (this, m_SaveFileDir, m_SaveFileName, values_table);
1401 }
1402 
1403 
1404 /*!
1405  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_CLEAR_TABLE
1406  */
1407 
1408 void CTblEditDlg::OnClearTableClick( wxCommandEvent& event )
1409 {
1411  NON_CONST_ITERATE (objects::CSeq_table::TColumns, cit, table->SetColumns()) {
1412  if ((*cit)->IsSetData() && !(*cit)->GetData().IsId()) {
1413  bool read_only = false;
1414  if ((*cit)->IsSetHeader()
1415  && (*cit)->GetHeader().IsSetTitle()
1416  && m_Converter->IsReadOnlyColumn((*cit)->GetHeader().GetTitle())) {
1417  read_only = true;
1418  }
1419 
1420  if (!read_only) {
1421  (*cit)->SetData().SetString().clear();
1422  }
1423  }
1424  }
1426 }
1427 
1428 
1429 /*!
1430  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_UPDATE_PROBLEMS
1431  */
1432 
1433 void CTblEditDlg::OnUpdateProblems( wxCommandEvent& event )
1434 {
1436  if (converter) {
1440  if (problems) {
1441  table->SetColumns().push_back(problems);
1443  }
1445  }
1446 }
1447 
1448 
bool GUI_AsyncExecUnit(IExecuteUnit &exec_unit, const wxString &msg)
Definition: async_call.cpp:53
bool Create(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_FRAME_STYLE, const wxString &name=wxFrameNameStr)
virtual CRef< objects::CSeq_table > GetValuesTableFromSeqEntry(objects::CSeq_entry_Handle seh)
virtual string RemapColumnName(string column_name)
virtual string GetErrorMessage(CRef< objects::CSeq_table >)
virtual CRef< CCmdComposite > ClearAllValues(objects::CSeq_entry_Handle seh)
virtual string CheckForMixedValues(CRef< objects::CSeq_table > table, string column_name="")
CSourceRequirements::EWizardSrcType m_SrcType
virtual CRef< CCmdComposite > GetCommandFromValuesTable(CRef< objects::CSeq_table >, objects::CSeq_entry_Handle seh)
virtual string RemapColumnName(string column_name)
virtual CRef< objects::CSeq_table > GetValuesTableFromSeqEntry(objects::CSeq_entry_Handle seh)
virtual CRef< CCmdComposite > GetCommandFromValuesTable(CRef< objects::CSeq_table > values_table, objects::CSeq_entry_Handle seh)
virtual string CheckForMixedValues(CRef< objects::CSeq_table > table, string column_name="")
virtual string GetErrorMessage(CRef< objects::CSeq_table > values_table)
virtual CRef< CCmdComposite > ClearAllValues(objects::CSeq_entry_Handle seh)
virtual CRef< CCmdComposite > GetCommandFromValuesTable(CRef< objects::CSeq_table >, objects::CSeq_entry_Handle seh)
virtual CRef< CCmdComposite > ClearAllValues(objects::CSeq_entry_Handle seh)
vector< string > m_DBLinkFields
virtual string RemapColumnName(string column_name)
virtual CRef< objects::CSeq_table > GetValuesTableFromSeqEntry(objects::CSeq_entry_Handle seh)
virtual string GetErrorMessage(CRef< objects::CSeq_table > table)
virtual void SetRegistryPath(const string &path)
Definition: dialog.cpp:59
virtual vector< string > IsValid(const vector< string > &values)
CFeatureTableCommandConverter(const objects::CSeq_feat &ftemplate, const TFeatureSeqTableColumnList &reqs, const TFeatureSeqTableColumnList &opts)
virtual CRef< objects::CSeq_table > GetValuesTableFromSeqEntry(objects::CSeq_entry_Handle seh)
virtual CRef< objects::CSeq_table > GetChoices(CRef< objects::CSeq_table > values_table)
CRef< objects::CSeq_feat > m_Template
virtual CRef< CCmdComposite > ClearAllValues(objects::CSeq_entry_Handle seh)
virtual string RemapColumnName(string column_name)
TFeatureSeqTableColumnList m_Opts
virtual CRef< CCmdComposite > GetCommandFromValuesTable(CRef< objects::CSeq_table >, objects::CSeq_entry_Handle seh)
virtual CRef< objects::CSeqTable_column > MakeProblemsColumn(CRef< objects::CSeq_table > values_table)
TFeatureSeqTableColumnList m_Reqs
virtual string GetErrorMessage(CRef< objects::CSeq_table >)
virtual CRef< CCmdComposite > ClearAllValues(objects::CSeq_entry_Handle seh)
virtual string RemapColumnName(string column_name)
virtual CRef< objects::CSeq_table > GetChoices(CRef< objects::CSeq_table > values_table)
virtual string CheckForMixedValues(CRef< objects::CSeq_table > values_table, string column_name="")
CSourceRequirements::EWizardType m_WizardType
virtual CRef< CCmdComposite > GetCommandFromValuesTable(CRef< objects::CSeq_table >, objects::CSeq_entry_Handle seh)
CSourceRequirements::EWizardSrcType m_SrcType
virtual string GetErrorMessage(CRef< objects::CSeq_table >)
virtual CRef< objects::CSeq_table > GetValuesTableFromSeqEntry(objects::CSeq_entry_Handle seh)
virtual CRef< objects::CSeq_table > GetValuesTableFromSeqEntry(objects::CSeq_entry_Handle seh)
virtual CRef< CCmdComposite > ClearAllValues(objects::CSeq_entry_Handle seh)
virtual string RemapColumnName(string column_name)
CSourceRequirements::EWizardType m_WizardType
virtual CRef< objects::CSeq_table > GetChoices(CRef< objects::CSeq_table > values_table)
virtual string GetErrorMessage(CRef< objects::CSeq_table >)
virtual CRef< CCmdComposite > GetCommandFromValuesTable(CRef< objects::CSeq_table >, objects::CSeq_entry_Handle seh)
CObject –.
Definition: ncbiobj.hpp:180
IObjectLoader * GetObjectLoader()
void SetManagers(vector< CIRef< IOpenObjectsPanelClient > > &managers)
virtual CRef< objects::CSeq_table > GetValuesTableFromSeqEntry(objects::CSeq_entry_Handle seh)
virtual string GetErrorMessage(CRef< objects::CSeq_table >)
virtual CRef< CCmdComposite > GetCommandFromValuesTable(CRef< objects::CSeq_table >, objects::CSeq_entry_Handle seh)
virtual CRef< CCmdComposite > ClearAllValues(objects::CSeq_entry_Handle seh)
virtual CRef< objects::CSeq_table > GetChoices(CRef< objects::CSeq_table > values_table)
virtual string RemapColumnName(string column_name)
virtual string CheckForMixedValues(CRef< objects::CSeq_table > values_table, string column_name="")
void MakeColumnReadOnly(int pos, bool val=true)
void SetValuesTable(CRef< objects::CSeq_table > table)
CRef< objects::CSeq_table > GetValuesTable()
CSeq_entry_Handle –.
virtual CRef< CCmdComposite > GetCommandFromValuesTable(CRef< objects::CSeq_table >, objects::CSeq_entry_Handle seh)
virtual CRef< CCmdComposite > ClearAllValues(objects::CSeq_entry_Handle seh)
virtual string GetErrorMessage(CRef< objects::CSeq_table >)
virtual string RemapColumnName(string column_name)
virtual CRef< objects::CSeq_table > GetValuesTableFromSeqEntry(objects::CSeq_entry_Handle seh)
virtual bool IsReadOnlyColumn(string column_name)
virtual CRef< objects::CSeq_table > GetValuesTableFromSeqEntry(objects::CSeq_entry_Handle seh)=0
virtual CRef< CCmdComposite > GetCommandFromValuesTable(CRef< objects::CSeq_table >, objects::CSeq_entry_Handle seh)=0
virtual string GetErrorMessage(CRef< objects::CSeq_table >)=0
virtual int GetCollapsible()
virtual CRef< objects::CSeq_table > GetChoices(CRef< objects::CSeq_table > values_table)
virtual string CheckForMixedValues(CRef< objects::CSeq_table > values_table, string column_name)
virtual string RemapColumnName(string column_name)=0
wxString m_SaveFileName
virtual CRef< CCmdComposite > GetCommand()
virtual string GetErrorMessage()
void CreateControls()
Creates the controls and sizers.
string x_FindBadImportColumns(CRef< objects::CSeq_table > table)
wxString m_SaveFileDir
wxButton * m_ImportBtn
wxBoxSizer * m_TableControlsSizer
void OnExportTableClick(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_EXPORT_TABLE
CTblEditDlg()
Constructors.
IWorkbench * m_Workbench
void OnImportTableClick(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_IMPORT_TABLE
wxBoxSizer * m_GridHolder
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
~CTblEditDlg()
Destructor.
void OnUpdateProblems(wxCommandEvent &event)
static bool ShowToolTips()
Should we show tooltips?
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
wxString m_StaticLabel
void OnClearTableClick(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_CLEAR_TABLE
CSeqTableGridPanel * m_Grid
CTableCommandConverter * m_Converter
objects::CSeq_entry_Handle m_TopSeqEntry
wxButton * m_ExportBtn
void Init()
Initialises member variables.
bool Create(wxWindow *parent, wxWindowID id=10079, const wxString &caption=_("TblEditDlg"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
Creation.
virtual bool PreExecute()=0
virtual bool PostExecute()=0
vector< SObject > TObjects
IWorkbench is the central interface in the application framework.
Definition: workbench.hpp:113
#define _(proto)
Definition: ct_nlmzip_i.h:78
const string kProblems
vector< CRef< CFeatureSeqTableColumnBase > > TFeatureSeqTableColumnList
const string kPartialStart
const string kPartialStop
const char * kTopology
const char * kMoleculeType
const char * kSubSourceNote
const char * kSequenceIdColLabel
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
static void Init(void)
Definition: cursor6.c:76
static const char *const strings[]
Definition: utf8.c:21
static FILE * f
Definition: readconf.c:23
static const column_t columns[]
Definition: utf8_2.c:22
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
#define NULL
Definition: ncbistd.hpp:225
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:998
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
#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 IsBlank(const CTempString str, SIZE_TYPE pos=0)
Check if a string is blank (has no text).
Definition: ncbistr.cpp:106
static SIZE_TYPE Find(const CTempString str, const CTempString pattern, ECase use_case=eCase, EDirection direction=eForwardSearch, SIZE_TYPE occurrence=0)
Find the pattern in the string.
Definition: ncbistr.cpp:2882
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 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:5378
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 const char label[]
const TColumns & GetColumns(void) const
Get the Columns member data.
Definition: Seq_table_.hpp:433
bool IsSetTitle(void) const
user friendly column name, can be skipped Check if a value has been assigned to Title data member.
void SetHeader(THeader &value)
Assign a value to Header data member.
const TTitle & GetTitle(void) const
Get the Title member data.
bool IsString(void) const
Check if variant String is selected.
bool IsSetField_name(void) const
any column can be identified by ASN.1 text locator string with omitted object type.
vector< CRef< CSeqTable_column > > TColumns
Definition: Seq_table_.hpp:92
const THeader & GetHeader(void) const
Get the Header member data.
const TField_name & GetField_name(void) const
Get the Field_name member data.
void SetData(TData &value)
Assign a value to Data data member.
bool IsSetHeader(void) const
column description or reference to previously defined info information about data Check if a value ha...
bool IsSetData(void) const
row data Check if a value has been assigned to Data data member.
TNum_rows GetNum_rows(void) const
Get the Num_rows member data.
Definition: Seq_table_.hpp:393
const TString & GetString(void) const
Get the variant data.
const TData & GetData(void) const
Get the Data member data.
<!DOCTYPE HTML >< html > n< header > n< title > PubSeq Gateway Help Page</title > n< style > n table
END_EVENT_TABLE()
int i
yy_size_t n
CRef< CCmdComposite > ApplyCommentValuesTableToSeqEntry(CRef< objects::CSeq_table >values_table, objects::CSeq_entry_Handle seh, const string &label)
CRef< objects::CSeq_table > BuildCommentDescriptorValuesTableFromSeqEntry(objects::CSeq_entry_Handle seh, const string &label)
vector< string > GetSrcGenomeOptions(CSourceRequirements::EWizardType wizard_type, CSourceRequirements::EWizardSrcType src_type)
vector< string > GetMoleculeTypeOptions(CSourceRequirements::EWizardType wizard_type)
CRef< objects::CSeq_table > BuildMolInfoValuesTableFromSeqEntry(objects::CSeq_entry_Handle seh, CSourceRequirements::EWizardType wizard_type)
CRef< objects::CSeq_table > BuildChimeraValuesTableFromSeqEntry(objects::CSeq_entry_Handle seh, const string &label, CSourceRequirements::EWizardSrcType src_type)
CRef< CCmdComposite > ApplyMolInfoValuesTableToSeqEntry(CRef< objects::CSeq_table >values_table, objects::CSeq_entry_Handle seh, bool add_confirmed=true)
CRef< CCmdComposite > ApplyDBLinkValuesTableToSeqEntry(CRef< objects::CSeq_table >values_table, objects::CSeq_entry_Handle seh)
CRef< CCmdComposite > ApplyChimeraValuesTableToSeqEntry(CRef< objects::CSeq_table >values_table, objects::CSeq_entry_Handle seh, const string &label)
CRef< objects::CSeq_table > BuildDBLinkValuesTableFromSeqEntry(objects::CSeq_entry_Handle seh)
#define wxT(x)
Definition: muParser.cpp:41
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
static const int kSkipColumns
CRef< CSeqTable_column > FindSeqTableColumnByName(CRef< objects::CSeq_table > values_table, string column_name)
void FillShortColumns(CRef< objects::CSeq_table > values_table)
void AddValueToTable(CRef< CSeq_table > table, string subtype_name, string value, size_t row, edit::EExistingText existing_text=edit::eExistingText_replace_old)
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
CRef< CCmdComposite > ApplySrcTableToSeqEntry(CRef< objects::CSeq_table >values_table, objects::CSeq_entry_Handle seh)
bool IsFwdPrimerSeq(string name)
CRef< objects::CSeq_table > GetSeqTableForSrcQualFromSeqEntry(objects::CSeq_entry_Handle seh, vector< string > qual_names)
bool IsRevPrimerSeq(string name)
bool IsFwdPrimerName(string name)
bool IsRevPrimerName(string name)
#define row(bind, expected)
Definition: string_bind.c:73
int CombineTables(CRef< objects::CSeq_table > dst, const objects::CSeq_table &src)
bool AreAnyColumnValuesMissing(CRef< objects::CSeqTable_column > col)
bool AreAllColumnValuesTheSame(CRef< objects::CSeqTable_column > col, string default_val="")
int AddFeatureToSeqTable(const objects::CSeq_feat &f, CRef< objects::CSeq_table > table)
bool SaveTableFile(wxWindow *parent, wxString &save_file_dir, wxString &save_file_name, CRef< objects::CSeq_table > values_table)
int CountTableColumnConflicts(CRef< objects::CSeq_table > dst, const objects::CSeq_table &src)
CRef< CCmdComposite > AddFeatureSeqTableToSeqEntry(CRef< objects::CSeq_table > table, objects::CSeq_entry_Handle entry, objects::CSeqFeatData::ESubtype subtype, const TFeatureSeqTableColumnList &reqs, const TFeatureSeqTableColumnList &opts)
CRef< CCmdComposite > RemoveMatchingFeaturesWithoutLocalIntFeatureIdsFromSeqEntry(objects::CSeq_entry_Handle entry, const objects::CSeq_feat &feat, const TFeatureSeqTableColumnList &reqs)
void AddProblemsColumnToFeatureSeqTable(CRef< objects::CSeq_table > table, const TFeatureSeqTableColumnList &reqs, const TFeatureSeqTableColumnList &opts)
CRef< CFeatureSeqTableColumnBase > GetColumnRuleForFeatureSeqTable(CRef< objects::CSeqTable_column > col, const TFeatureSeqTableColumnList &reqs, const TFeatureSeqTableColumnList &opts)
void RemoveProblemsColumn(CRef< objects::CSeq_table > values_table)
vector< string > GetTrueFalseList()
void FixTableAfterImport(CRef< objects::CSeq_table > input_table)
string FindBadRows(CRef< objects::CSeq_table > src, CRef< objects::CSeq_table > dst, objects::CSeq_entry_Handle seh)
CRef< objects::CSeq_table > GetFeaturesFromSeqEntry(objects::CSeq_entry_Handle entry, const objects::CSeq_feat &feat, const TFeatureSeqTableColumnList &reqs)
void MergeStringVectors(vector< string > &problems, vector< string > add)
static const string kPrimerType
static string s_GetPrefixForStructuredComment(const objects::CUser_object &user)
static const string kUniversalPrimersLabel
USING_SCOPE(ncbi::objects)
static void AddProblemsToColumn(CRef< objects::CSeqTable_column > val_col, CRef< CFeatureSeqTableColumnBase > rule_col, vector< string > &problems)
static const string kUniversalPrimers
static const string kSpeciesSpecificPrimersLabel
static int s_FindColumn(CRef< CSeq_table > table, const string &name)
static bool s_RemoveValueFromNote(string &note, string value)
static void x_SetAllTableStringValues(CRef< CSeq_table > table, const string &val)
static const string kSpeciesSpecificPrimers
vector< string > GetAssemblyDataFields()
CRef< CSeqTable_column > s_GetNthColumn(CRef< CSeq_table > table, int n)
#define ID_EXPORT_TABLE
#define ID_UPDATE_PROBLEMS
#define ID_CLEAR_TABLE
#define ID_IMPORT_TABLE
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
Modified on Fri Sep 20 14:57:36 2024 by modify_doxy.py rev. 669887