NCBI C++ ToolKit
macro_biodata_iter.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef GUI_OBJUTILS___MACRO_BIODATA_ITER__HPP
2 #define GUI_OBJUTILS___MACRO_BIODATA_ITER__HPP
3 /* $Id: macro_biodata_iter.hpp 47411 2023-03-20 19:18:06Z asztalos $
4  * ===========================================================================
5  *
6  * PUBLIC DOMAIN NOTICE
7  * National Center for Biotechnology Information
8  *
9  * This software/database is a "United States Government Work" under the
10  * terms of the United States Copyright Act. It was written as part of
11  * the author's official duties as a United States Government employee and
12  * thus cannot be copyrighted. This software/database is freely available
13  * to the public for use. The National Library of Medicine and the U.S.
14  * Government have not placed any restriction on its use or reproduction.
15  *
16  * Although all reasonable efforts have been taken to ensure the accuracy
17  * and reliability of the software and data, the NLM and the U.S.
18  * Government do not and cannot warrant the performance or results that
19  * may be obtained by using this software or data. The NLM and the U.S.
20  * Government disclaim all warranties, express or implied, including
21  * warranties of performance, merchantability or fitness for any particular
22  * purpose.
23  *
24  * Please cite the author in any work or product based on this material.
25  *
26  * ===========================================================================
27  *
28  * Authors: Andrea Asztalos, Anatoly Osipov
29  *
30  * File Description: FOR EACH iterators used in macros
31  *
32  */
33 
34 /// @file macro_biodata_iter.hpp
35 /// Biodata iterators for macro execution
36 
37 #include <corelib/ncbiobj.hpp>
38 #include <serial/objectinfo.hpp>
39 #include <serial/iterator.hpp>
44 #include <objects/seq/MolInfo.hpp>
47 #include <objects/seq/Pubdesc.hpp>
48 #include <objects/pub/Pub.hpp>
50 
51 #include <objmgr/seqdesc_ci.hpp>
52 #include <objmgr/bioseq_ci.hpp>
53 #include <objmgr/feat_ci.hpp>
54 #include <objmgr/align_ci.hpp>
55 #include <objmgr/seq_entry_ci.hpp>
58 
59 #include <gui/gui_export.h>
60 #include <gui/objutils/objects.hpp>
64 #include <unordered_map>
65 
66 /** @addtogroup GUI_MACRO_SCRIPTS_UTIL
67  *
68  * @{
69  */
70 
72 
75 
77  class CRemoteUpdater;
79 BEGIN_SCOPE(macro)
80 
81 
82 ///////////////////////////////////////////////////////////////////////////////
83 /// IMacroBioDataIter - common interface of all iterators used in the editing macros
84 /// The type of the iterator is defined by "foreach" selector in the macro.
85 ///
87 {
88 public:
89  virtual ~IMacroBioDataIter() {}
90 
91  virtual IMacroBioDataIter& Begin( void ) = 0;
92  virtual IMacroBioDataIter& Next( void ) = 0;
93  virtual bool IsEnd( void ) const = 0;
94  virtual bool IsBegin( void ) = 0;
95 
96  virtual size_t GetCount() const { return 0; }
97 
98  /// Dereferences the underlying iterator
99  /// @return pointer to the object and its scope
100  virtual SConstScopedObject GetScopedObject() const = 0;
101 
102  /// Used for logging
103  /// @return unique description about the object
104  virtual string GetBestDescr() const = 0;
105 
106  /// Creates a copy of the object that will be edited.
107  /// @note The function should be called prior to any modification of the original data in
108  /// memory and prior to calling RunEditCommand().
109  /// Usually, each of these functions should be called once per iterator resolving.
110  virtual void BuildEditedObject() = 0;
111 
112 
113  CObjectInfo GetEditedObject() { return m_CurIterOI; }
114 
115  /// Constructs and executes the editing command. At the end it also stores this editing command.
116  ///@param[in,out] cmd_composite
117  /// Composite command that stores all executed commands.
118  ///@note Internally, each command swaps the read-only object with the updated object.
119  ///@sa CMacroCmdComposite().
120  virtual void RunEditCommand(CMacroCmdComposite* cmd_composite) = 0;
121 
122  /// Constructs and executes the delete command. At the end, the command is stored and
123  /// the iterator is advanced to the next object.
124  ///@param[in,out] cmd_composite
125  /// Composite command that stores all executed commands.
126  ///@sa CMacroCmdComposite().
127  virtual void RunDeleteCommand(CMacroCmdComposite* cmd_composite) = 0;
128 
129  /// Method for executing a specific command.
130  ///@param[in] cmd
131  /// Command to be executed. It has been previously constructed elsewhere.
132  ///@param[in,out] cmd_composite
133  /// Composite command that stores all executed commands.
134  ///@note This is used when changes have been made to an object other than the one pointed by the iterator.
135  /// See for example, CMacroFunction_SynchronizeCDSPartials
136  void RunCommand(CRef<CCmdComposite> cmd, CMacroCmdComposite* cmd_composite);
137 
138  bool IntendToDelete() const { return m_DeleteObject; }
139  virtual void SetToDelete(bool intent) { m_DeleteObject = intent; }
140 
141  bool IsModified() const { return m_Modified; }
142  void SetModified() { m_Modified |= true; }
143 
144  /// returns choice type string for a given identifier field_name
145  ///@param[in] field_name
146  /// Name of the choice data member to be resolved
147  ///@param[out] choice_type
148  /// Name of the choice variant
149  ///@sa CMacroFunction_ChoiceType
150  bool GetChoiceType(const string& field_name, string& choice_type) const;
151 
152  // functions that provide context on the object pointed by the iterator
153  virtual bool IsDescriptor() const = 0;
154  virtual bool IsFeature() const = 0;
155  virtual objects::CBioseq_Handle GetBioseqHandle(void) const = 0;
156  virtual const vector<string>& GetTaxnames() const { return m_Taxnames; }
157 
158  objects::CSeq_entry_Handle GetSEH() const { return m_Seh; }
159 
160  bool HasBeenCompleted() const { return m_Completed; }
161  void SetCompleted() { m_Completed = true; }
162 
163  bool IsSetSeqSubmit( void ) const { return m_SeqSubmit.NotEmpty(); }
164  const objects::CSeq_submit& GetSeqSubmit( void ) const { return *m_SeqSubmit; }
165  void SetSeqSubmit(const objects::CSeq_submit& submit) { m_SeqSubmit.Reset(&submit); }
166 
167  void SetOutputStream(CNcbiOstream* str) { m_Ostream = str; }
168  bool IsSetOutputStream() const { return (m_Ostream != nullptr); }
169  CNcbiOstream& GetOutputStream() const { return *m_Ostream; }
170 
171  // functions to handle tables
172  void SetTableToApply(const string& file_name, size_t match_col,
173  const string& delimiter, bool merge_de, bool split_firstcol, bool convert_multi, bool merge_firstcols, bool multiple_sp_only);
174  const string& GetTableName() const;
175 
176  string GetValueFromTable(size_t col);
177  bool FindInTable(const CMQueryNodeValue::TObs& objs, bool case_sensitive = true);
178  bool FindInTable(const vector<string>& strs, bool case_sensitive = true);
179 
180  string GetUnMatchedTableEntries(int& count);
181 
182  // to set execution of some of the macros in 'huge file mode'
183  void SetHugeDataMode(bool value) { m_HugeData = value; }
184  bool IsHugeDataMode() const { return m_HugeData; }
185 
186  auto& RemoteUpdater() { return m_RemoteUpdater; }
187  auto& DOIUpdater() { return m_DOIUpdater; }
188  auto& ISOJTAUpdater() { return m_ISOJTAUpdater; }
189 
190  bool TopLevelObject() const;
191  objects::CObject_id::TId& MaxFeatureId();
192 
193  void SetHugeContext(const shared_ptr<CHugeMacroContext>& context);
194 
195 protected:
196  IMacroBioDataIter(const objects::CSeq_entry_Handle& entry)
197  : m_Seh (entry), m_DeleteObject(false), m_Modified(false), m_TableToApply(kEmptyStr) {}
198 
199  /// Initializes member variable m_CurIterOI
200  virtual void x_SetDefaultObjectInfo() = 0;
201  void x_Init();
202  mutable bool m_Completed{ false }; ///< flag to be used by actions that need to be completed only once
203 
205  objects::CSeq_entry_Handle m_Seh;
207  CNcbiOstream* m_Ostream{ nullptr };
208  bool m_HugeData{ false }; ///< indicates that the data is large and some macros should take that into account (for example: taxlookup)
209 
210  shared_ptr<objects::edit::CRemoteUpdater> m_RemoteUpdater;
211  shared_ptr<CDoiLookupWithCache> m_DOIUpdater;
212  shared_ptr<CISOJTALookupWithCache> m_ISOJTAUpdater;
213  shared_ptr<CHugeMacroContext> m_MacroContext;
214 
215  // caching it for CMacroFunction_FixProteinFormat in 'normal mode'
216  mutable vector<string> m_Taxnames;
217 
218  bool m_DeleteObject; ///< indicates the intention to delete the underlying object
219  bool m_Modified; ///< indicates whether the edited object has been modified. When it's TRUE, call RunEditCommand()
220 
222  {
223  STableToApply(const string& file_name)
224  : m_Name(file_name), m_NrCols(0), m_SplitFlags(0){}
225 
226  bool SetTableToApply(const string& file_name, size_t match_col);
227  bool GetValueFromTable(size_t col, string& value);
228 
229  string m_Name;
230 
231  using TIndex = unordered_map<string, unsigned>;
232  TIndex m_Index; ///< stores the match_field value and the row number where that value appears in the table
234  TIndex::const_iterator m_CurrentPos;
235  size_t m_NrCols; /// < number of actual columns in the table
236  string m_Delimiter; ///< column delimiter
237  NStr::TSplitFlags m_SplitFlags{ 0 };
238  bool m_SplitFirstCol{ false };
239  bool m_ConvertMulti{ false };
240  bool m_MergeFirstCols{ false }; ///< when true, merges first two columns to form the seq-id match field
241  bool m_MultipleSpaceOnly{ false }; ///< when true, single space character are not considered delimiters
242 
243  using TPresent = vector<pair<string, bool>>; ///< true value for a key indicates that was present in the record
244  TPresent m_State; ///< to report values of the matching field that are present in the table, but not present in the data
245 
246  using TTableValues = vector<string>;
247  list<pair<size_t, TTableValues>> m_TableValues;
248  private:
249  void x_InitAndCheck(const string& file_name, size_t col);
250  bool x_CacheColFromTable(size_t col);
251  };
252 
254 };
255 
256 
257 ////////////////////////////////////////////////////////////////////////////////
258 /// CMacroBioData_FeatIterBase - iterates over any type of features
259 ///
261 {
262 public:
263  CMacroBioData_FeatIterBase(const objects::CSeq_entry_Handle& entry, const objects::SAnnotSelector& sel);
264  CMacroBioData_FeatIterBase(const objects::CBioseq_Handle& bsh, const objects::SAnnotSelector& sel, const objects::CSeq_loc& loc);
266 
267  virtual IMacroBioDataIter& Begin(void);
268  virtual IMacroBioDataIter& Next(void);
269  virtual bool IsEnd(void) const;
270  virtual bool IsBegin(void);
271  virtual size_t GetCount() const;
272 
273  virtual SConstScopedObject GetScopedObject() const;
274  virtual string GetBestDescr() const;
275 
276  virtual void BuildEditedObject();
277  virtual void RunEditCommand(CMacroCmdComposite* cmd_composite);
278  virtual void RunDeleteCommand(CMacroCmdComposite* cmd_composite);
279 
280  virtual bool IsDescriptor() const { return false; }
281  virtual bool IsFeature() const { return true; }
282 
283  virtual objects::CBioseq_Handle GetBioseqHandle(void) const;
284 
285  virtual void SetToDelete(bool intent);
286 
287  virtual const vector<string>& GetTaxnames() const;
288 
289  void SetCreateGeneralIdFlag();
290  bool GetCreateGeneralIdFlag() const { return m_CreateGeneralId; }
291 protected:
292  virtual void x_SetDefaultObjectInfo();
293 
294  objects::CFeat_CI m_FeatIter;
298 
299  // auxiliary flag for creating protein seq-ids
300  bool m_CreateGeneralId{ false };
301  // auxiliary data used for deleting features
303 private:
306 };
307 
308 
310 {
312  bool left_closed{ true };
313  bool right_closed{ true };
314  // default behavior - is the same as given by the OM
315  /*
316  [left, right) - features that straddle the 'open' boundary of the interval are NOT included in the selection
317  OM's selectors/iterators always include all features that straddle the left and right boundaries of an interval.
318  There is no flag to modify this behavior.
319  */
320  SFeatInterval(const TSeqRange& range, bool left = true , bool right = true)
321  : m_Range(range), left_closed(left), right_closed(right) {}
322 };
323 
324 ////////////////////////////////////////////////////////////////////////////////
325 /// CMacroBioData_FeatIntervalIter - iterates over features within [|(left, right]|) intervals
326 ///
328 {
329 public:
330  CMacroBioData_FeatIntervalIter(const objects::CBioseq_Handle& bsh,
331  const objects::SAnnotSelector& sel, const SFeatInterval& feat_interval);
333 
334  virtual IMacroBioDataIter& Begin(void);
335  virtual IMacroBioDataIter& Next(void);
336  virtual bool IsEnd(void) const;
337  virtual bool IsBegin(void);
338 
339  virtual SConstScopedObject GetScopedObject() const;
340  virtual string GetBestDescr() const;
341 
342  virtual void BuildEditedObject();
343  virtual void RunEditCommand(CMacroCmdComposite* cmd_composite) {}
344  virtual void RunDeleteCommand(CMacroCmdComposite* cmd_composite) {}
345 
346  virtual bool IsDescriptor() const { return false; }
347  virtual bool IsFeature() const { return true; }
348 
349  virtual objects::CBioseq_Handle GetBioseqHandle(void) const;
350 
351 protected:
352  virtual void x_SetDefaultObjectInfo();
353 
354  void x_StepToNextFeat();
355 
356  objects::CFeat_CI m_FeatIter;
361 
362 private:
365 };
366 
367 
368 ////////////////////////////////////////////////////////////////////////////////
369 /// CMacroBioData_BioSourceIter - iterates over all biosource descriptors and features in the seq-entry
370 ///
372 {
373 public:
374  CMacroBioData_BioSourceIter(const objects::CSeq_entry_Handle& entry);
376 
377  virtual IMacroBioDataIter& Begin(void);
378  virtual IMacroBioDataIter& Next(void);
379  virtual bool IsEnd(void) const;
380  virtual bool IsBegin(void);
381 
382  virtual SConstScopedObject GetScopedObject() const;
383  virtual string GetBestDescr() const;
384 
385  virtual void BuildEditedObject();
386  virtual void RunEditCommand(CMacroCmdComposite* cmd_composite);
387  virtual void RunDeleteCommand(CMacroCmdComposite* cmd_composite);
388 
389  virtual bool IsDescriptor() const;
390  virtual bool IsFeature() const;
391 
392  virtual objects::CBioseq_Handle GetBioseqHandle(void) const;
393 
397  eAmbiguous_False
398  };
399 
400  ECollDateType GetCollDateType() const { return m_CollDateType; }
401  void SetCollDateType(bool ambiguous) { m_CollDateType = (ambiguous) ? eAmbiguous_True : eAmbiguous_False; }
402 
403 protected:
404  virtual void x_SetDefaultObjectInfo();
405 private:
406  objects::CFeat_CI m_SrcFeatIter;
407  objects::CSeqdesc_CI m_SrcDescrIter;
408  objects::CBioseq_CI m_SeqIter; ///> provides context information
412 
414  const objects::CBioSource* x_GetBioSource();
415 private:
416  // prohibit copying and assigning
419 };
420 
421 
422 ////////////////////////////////////////////////////////////////////////////////
423 /// CMacroBioData_PubdescIter - iterates over all publication descriptors and features in the seq-entry
424 ///
426 {
427 public:
428  CMacroBioData_PubdescIter(const objects::CSeq_entry_Handle& entry);
430 
431  virtual IMacroBioDataIter& Begin(void);
432  virtual IMacroBioDataIter& Next(void);
433  virtual bool IsEnd(void) const;
434  virtual bool IsBegin(void);
435 
436  virtual SConstScopedObject GetScopedObject() const;
437  virtual string GetBestDescr() const;
438 
439  virtual void BuildEditedObject();
440  virtual void RunEditCommand(CMacroCmdComposite* cmd_composite);
441  virtual void RunDeleteCommand(CMacroCmdComposite* cmd_composite);
442 
443  virtual bool IsDescriptor() const;
444  virtual bool IsFeature() const;
445 
446  virtual objects::CBioseq_Handle GetBioseqHandle(void) const;
447 
449 
450  const TPmidLookupMap& GetPmidLookupMap() const { return m_PmidLookupMap; }
451  TPmidLookupMap& SetPmidLookupMap() { return m_PmidLookupMap; }
452 
454  TDOILookupMap& SetDOILookupMap() { return m_DOILookupMap; }
455 
457  ISOJTALookupMap& SetISOJTALookupMap() { return m_ISOJTALookupMap; }
458 
459 protected:
460  virtual void x_SetDefaultObjectInfo();
461 private:
462 
463  class CSubmitblockIter : public CObject
464  {
465  public:
468 
469  bool Processed() const { return m_Processed; }
470  void MarkProcessed() { m_Processed = true; }
471 
472  CRef<objects::CSubmit_block> BuildEditedObject();
473  const objects::CSubmit_block& GetOrigSubmitBlock() const { return m_OrigSubmitBlock.GetObject(); }
474  objects::CSubmit_block& GetEditedSubmitBlock() const { return m_EditedSubmitBlock.GetNCObject(); }
475 
476  private:
477  CConstRef<objects::CSubmit_block> m_OrigSubmitBlock{ nullptr };
478  CRef<objects::CSubmit_block> m_EditedSubmitBlock{ nullptr };
479  bool m_Processed{ false };
480  };
481 
482  objects::CFeat_CI m_PubFeatIter;
483  objects::CSeqdesc_CI m_PubDescrIter;
484  objects::CBioseq_CI m_SeqIter; ///> provides context information
485  objects::CSeq_entry_CI m_SeqSetIter;
486 
490 
491  // this will be the last in the iterated objects list
493 
494  // cache for the looked up pmids
496 
497  // cache for the looked up dois
499 
500  // cache for the looked up ISOJTAs
502 
503  // prohibit copying and assigning
506 };
507 
508 /////////////////////////////////////////////////////////////////
509 /// CMacroBioData_SeqdescIter- iterates over all types of sequence descriptors
510 ///
512 {
513 public:
514  CMacroBioData_SeqdescIter(const objects::CSeq_entry_Handle& entry);
516 
517  virtual IMacroBioDataIter& Begin(void);
518  virtual IMacroBioDataIter& Next(void);
519  virtual bool IsEnd(void) const;
520  virtual bool IsBegin(void);
521 
522  virtual SConstScopedObject GetScopedObject() const;
523  virtual string GetBestDescr() const;
524 
525  virtual void BuildEditedObject();
526  virtual void RunEditCommand(CMacroCmdComposite* cmd_composite);
527  virtual void RunDeleteCommand(CMacroCmdComposite* cmd_composite);
528 
529  virtual bool IsDescriptor() const { return true; }
530  virtual bool IsFeature() const { return false; }
531 
532  virtual objects::CBioseq_Handle GetBioseqHandle(void) const;
533 protected:
534  virtual void x_SetDefaultObjectInfo();
535  string x_GetDescription(const string& descr_name) const;
536 
537  string x_GetSeqId() const;
538  objects::CBioseq_CI m_SeqIter; ///> provides context information
539  objects::CSeq_entry_CI m_SeqSetIter;
540  objects::CSeqdesc_CI m_DescIter;
541 
542 private:
546 
549 };
550 
551 ////////////////////////////////////////////////////////////////////////////////
552 /// CMacroBioData_MolInfoIter - iterates over all molinfos in the seq-entry
553 ///
555 {
556 public:
557  CMacroBioData_MolInfoIter(const objects::CSeq_entry_Handle& entry);
559 
560  virtual IMacroBioDataIter& Begin(void);
561  virtual IMacroBioDataIter& Next(void);
562  virtual bool IsEnd(void) const;
563  virtual bool IsBegin(void);
564 
565  virtual SConstScopedObject GetScopedObject() const;
566  virtual string GetBestDescr() const;
567 
568  virtual void BuildEditedObject();
569  virtual void RunEditCommand(CMacroCmdComposite* cmd_composite);
570  virtual void RunDeleteCommand(CMacroCmdComposite* cmd_composite);
571 
572 protected:
573  virtual void x_SetDefaultObjectInfo();
574 
575 private:
579 
580  const objects::CMolInfo* x_GetMolInfo();
581 
582  // prohibit copying and assigning
585 };
586 
587 
588 /////////////////////////////////////////////////////////////////
589 /// CMacroBioData_UserObjectIter - iterates over all user objects in the seq-entry
590 ///
592 {
593 public:
594  CMacroBioData_UserObjectIter(const objects::CSeq_entry_Handle& entry);
596 
597  virtual IMacroBioDataIter& Begin(void);
598  virtual IMacroBioDataIter& Next(void);
599  virtual bool IsEnd(void) const;
600  virtual bool IsBegin(void);
601 
602  virtual SConstScopedObject GetScopedObject() const;
603  virtual string GetBestDescr() const;
604 
605  virtual void BuildEditedObject();
606  virtual void RunEditCommand(CMacroCmdComposite* cmd_composite);
607  virtual void RunDeleteCommand(CMacroCmdComposite* cmd_composite);
608 
609 protected:
610  virtual void x_SetDefaultObjectInfo();
611 
615 
616 private:
617  // prohibit copying and assigning
620 
621 };
622 
623 ////////////////////////////////////////////////////////////////////////////////
624 /// CMacroBioData_StructCommentIter - iterates over all structured comments in the seq-entry
625 ///
627 {
628 public:
629  CMacroBioData_StructCommentIter(const objects::CSeq_entry_Handle& entry);
631 
632  virtual IMacroBioDataIter& Begin(void);
633  virtual IMacroBioDataIter& Next(void);
634 
635  virtual string GetBestDescr() const;
636 
637 private:
638  void x_StepToNextStructComment();
639 
640  // prohibit copying and assigning
643 };
644 
645 
646 ////////////////////////////////////////////////////////////////////////////////
647 /// CMacroBioData_DBLinkIter - iterates over all DBlinks in the seq-entry
648 ///
650 {
651 public:
652  CMacroBioData_DBLinkIter(const objects::CSeq_entry_Handle& entry);
654 
655  virtual IMacroBioDataIter& Begin(void);
656  virtual IMacroBioDataIter& Next(void);
657 
658  virtual string GetBestDescr() const;
659 
660 private:
661  const objects::CUser_object* x_GetDBLink();
662 
663  // prohibit copying and assigning
666 };
667 
668 
669 ////////////////////////////////////////////////////////////////////////////////
670 /// CMacroBioData_AutodefOptsIter - iterates over all AutodefOptions in the seq-entry
671 ///
673 {
674 public:
675  CMacroBioData_AutodefOptsIter(const objects::CSeq_entry_Handle& entry);
677 
678  virtual IMacroBioDataIter& Begin(void);
679  virtual IMacroBioDataIter& Next(void);
680 
681  virtual string GetBestDescr() const;
682 
683 private:
684  const objects::CUser_object* x_GetAutodefOptions();
685 
686  // prohibit copying and assigning
689 };
690 /////////////////////////////////////////////////////////////////
691 /// CMacroBioData_SeqAlignIter - iterates over sequence alignments
692 ///
694 {
695 public:
696  CMacroBioData_SeqAlignIter(const objects::CSeq_entry_Handle& entry);
698 
699  virtual IMacroBioDataIter& Begin(void);
700  virtual IMacroBioDataIter& Next(void);
701  virtual bool IsEnd(void) const;
702  virtual bool IsBegin(void);
703 
704  virtual SConstScopedObject GetScopedObject() const;
705  virtual string GetBestDescr() const;
706 
707  virtual void BuildEditedObject();
708  virtual void RunEditCommand(CMacroCmdComposite* cmd_composite);
709  virtual void RunDeleteCommand(CMacroCmdComposite* cmd_composite);
710 
711  virtual bool IsDescriptor() const { return false; }
712  virtual bool IsFeature() const { return false; }
713 
714  virtual objects::CBioseq_Handle GetBioseqHandle(void) const { return objects::CBioseq_Handle(); }
715 protected:
716  virtual void x_SetDefaultObjectInfo();
717 private:
718  objects::CAlign_CI m_AlignIter;
721 private:
724 };
725 
726 
727 /////////////////////////////////////////////////////////////////
728 /// CMacroBioData_SeqIter- iterates over sequences (na and aa)
729 ///
731 {
732 public:
734  static CMacroBioData_SeqIter* s_MakeSeqIterator(const objects::CSeq_entry_Handle& entry, objects::CSeq_inst::EMol mol_type);
735 
736  virtual IMacroBioDataIter& Begin(void);
737  virtual IMacroBioDataIter& Next(void);
738  virtual bool IsEnd(void) const;
739  virtual bool IsBegin(void);
740 
741  virtual SConstScopedObject GetScopedObject() const;
742  virtual string GetBestDescr() const;
743 
744  virtual void BuildEditedObject();
745  virtual void RunEditCommand(CMacroCmdComposite* cmd_composite);
746  virtual void RunDeleteCommand(CMacroCmdComposite* cmd_composite);
747 
748  virtual bool IsDescriptor() const { return false; }
749  virtual bool IsFeature() const { return false; }
750 
751  virtual objects::CBioseq_Handle GetBioseqHandle(void) const;
752 
753  const objects::CAutoDefOptions& GetAutodefOptions() const { return m_AutodefOptions; }
754  objects::CAutoDefOptions& SetAutodefOptions() { return m_AutodefOptions; }
755 
756 protected:
757  virtual void x_SetDefaultObjectInfo();
758  CMacroBioData_SeqIter(const objects::CSeq_entry_Handle& entry);
759 protected:
760  objects::CBioseq_CI m_SeqIter;
764 
765  // cache the options between sequences
766  objects::CAutoDefOptions m_AutodefOptions;
767 private:
770 };
771 
773 {
774 public:
775  CMacroBioData_SeqNAIter(const objects::CSeq_entry_Handle& entry);
776 
777  virtual IMacroBioDataIter& Begin(void);
778  virtual bool IsBegin(void);
779 };
780 
782 {
783 public:
784  CMacroBioData_SeqAAIter(const objects::CSeq_entry_Handle& entry);
785 
786  virtual IMacroBioDataIter& Begin(void);
787  virtual bool IsBegin(void);
788 };
789 
790 /////////////////////////////////////////////////////////////////
791 /// CMacroBioData_SeqSetIter- iterates over sets
792 ///
794 {
795 public:
796  CMacroBioData_SeqSetIter(const objects::CSeq_entry_Handle& entry);
798 
799  virtual IMacroBioDataIter& Begin(void);
800  virtual IMacroBioDataIter& Next(void);
801  virtual bool IsEnd(void) const;
802  virtual bool IsBegin(void);
803 
804  virtual SConstScopedObject GetScopedObject() const;
805  virtual string GetBestDescr() const;
806 
807  virtual void BuildEditedObject();
808  virtual void RunEditCommand(CMacroCmdComposite* cmd_composite);
809  virtual void RunDeleteCommand(CMacroCmdComposite* cmd_composite);
810 
811  virtual bool IsDescriptor() const { return false; }
812  virtual bool IsFeature() const { return false; }
813 
814  virtual objects::CBioseq_Handle GetBioseqHandle(void) const { return objects::CBioseq_Handle(); }
815 protected:
816  virtual void x_SetDefaultObjectInfo();
817 private:
818  objects::CSeq_entry_CI m_SeqSetIter;
821 private:
824 };
825 
826 
827 ////////////////////////////////////////////////////////////////////////////////
828 /// CMacroBioData_TSEntryIterBase - iterator pointing to the top seq-entry
829 ///
831 {
832 public:
833  CMacroBioData_TSEntryIter(const objects::CSeq_entry_Handle& entry);
835 
836  virtual IMacroBioDataIter& Begin(void);
837  virtual IMacroBioDataIter& Next(void);
838  virtual bool IsEnd(void) const;
839  virtual bool IsBegin(void);
840 
841  virtual SConstScopedObject GetScopedObject() const;
842  virtual string GetBestDescr() const;
843 
844  virtual void BuildEditedObject();
845  virtual void RunEditCommand(CMacroCmdComposite* cmd_composite);
846  virtual void RunDeleteCommand(CMacroCmdComposite* cmd_composite);
847 
848  virtual bool IsDescriptor() const { return false; }
849  virtual bool IsFeature() const { return false; }
850 
851  virtual objects::CBioseq_Handle GetBioseqHandle(void) const { return objects::CBioseq_Handle(); }
852 
853 protected:
854  virtual void x_SetDefaultObjectInfo();
855 
856  objects::CSeq_entry_CI m_EntryIter;
859 
860 private:
863 };
864 
865 
866 END_SCOPE(macro)
868 
869 /* @} */
870 
871 #endif // GUI_OBJUTILS___MACRO_BIODATA_ITER__HPP
User-defined methods of the data storage class.
User-defined methods of the data storage class.
string GetValueFromTable(const CSeq_table &table, string column_name, size_t row)
CMacroBioData_AutodefOptsIter - iterates over all AutodefOptions in the seq-entry.
CMacroBioData_BioSourceIter - iterates over all biosource descriptors and features in the seq-entry.
CMacroBioData_DBLinkIter - iterates over all DBlinks in the seq-entry.
CMacroBioData_FeatIntervalIter - iterates over features within [|(left, right]|) intervals.
CMacroBioData_FeatIterBase - iterates over any type of features.
CMacroBioData_MolInfoIter - iterates over all molinfos in the seq-entry.
CMacroBioData_PubdescIter - iterates over all publication descriptors and features in the seq-entry.
CMacroBioData_SeqAlignIter - iterates over sequence alignments.
CMacroBioData_SeqIter- iterates over sequences (na and aa)
CMacroBioData_SeqSetIter- iterates over sets.
CMacroBioData_SeqdescIter- iterates over all types of sequence descriptors.
CMacroBioData_StructCommentIter - iterates over all structured comments in the seq-entry.
CMacroBioData_TSEntryIterBase - iterator pointing to the top seq-entry.
CMacroBioData_UserObjectIter - iterates over all user objects in the seq-entry.
implements special composite command, which does not call to its internal commands when run the very ...
CObjectInfo –.
Definition: objectinfo.hpp:597
CObject –.
Definition: ncbiobj.hpp:180
IMacroBioDataIter - common interface of all iterators used in the editing macros The type of the iter...
Definition: map.hpp:338
const char * file_name[]
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
#define false
Definition: bool.h:36
static const char * str(char *buf, int n)
Definition: stats.c:84
shared_ptr< objects::edit::CRemoteUpdater > m_RemoteUpdater
CMacroBioData_SeqSetIter(const objects::CSeq_entry_Handle &entry)
CMacroBioData_TSEntryIter(const objects::CSeq_entry_Handle &entry)
CConstRef< objects::CBioseq_set > m_OrigSeqSet
CConstRef< objects::CSeqdesc > m_FirstSeqdesc
virtual bool IsEnd(void) const =0
CConstRef< objects::CSeq_align > m_OrigSeqalign
CRef< objects::CPubdesc > m_EditedPubdesc
void SetHugeDataMode(bool value)
objects::CAutoDefOptions m_AutodefOptions
objects::CSeq_entry_CI m_SeqSetIter
vector< pair< string, bool > > TPresent
true value for a key indicates that was present in the record
virtual bool IsDescriptor() const
CMacroBioData_PubdescIter & operator=(const CMacroBioData_PubdescIter &)
virtual bool IsDescriptor() const =0
objects::CSeqdesc_CI m_DescIter
objects::CBioseq_CI m_SeqIter
STableToApply(const string &file_name)
virtual bool IsDescriptor() const
virtual bool IsFeature() const
CMacroBioData_FeatIterBase(const CMacroBioData_FeatIterBase &)
CRef< objects::CSeq_feat > m_EditedFeat
const TPmidLookupMap & GetPmidLookupMap() const
virtual objects::CBioseq_Handle GetBioseqHandle(void) const =0
CConstRef< objects::CSeq_entry > m_OrigTSE
virtual bool IsDescriptor() const
objects::CSeq_entry_CI m_SeqSetIter
> provides context information
list< SResolvedField > TObs
Definition: macro_exec.hpp:92
CMacroBioData_TSEntryIter(const CMacroBioData_TSEntryIter &)
CMacroBioData_FeatIterBase(const objects::CSeq_entry_Handle &entry, const objects::SAnnotSelector &sel)
CMacroBioData_AutodefOptsIter(const objects::CSeq_entry_Handle &entry)
virtual bool IsFeature() const
CMacroBioData_FeatIntervalIter & operator=(const CMacroBioData_FeatIntervalIter &)
CConstRef< objects::CSeq_feat > m_FirstFeat
const objects::CAutoDefOptions & GetAutodefOptions() const
CMacroBioData_UserObjectIter & operator=(const CMacroBioData_UserObjectIter &)
CMacroBioData_SeqSetIter & operator=(const CMacroBioData_SeqSetIter &)
CConstRef< objects::CSeq_feat > m_FirstFeat
CRef< objects::CSeq_entry > m_EditedTSE
CMacroBioData_BioSourceIter & operator=(const CMacroBioData_BioSourceIter &)
virtual bool IsFeature() const
void SetCollDateType(bool ambiguous)
CMacroBioData_StructCommentIter & operator=(const CMacroBioData_StructCommentIter &)
CMacroBioData_SeqAlignIter(const objects::CSeq_entry_Handle &entry)
CRef< objects::CBioseq > m_EditedSeq
virtual bool IsDescriptor() const
CRef< objects::CMolInfo > m_EditedMolinfo
shared_ptr< CDoiLookupWithCache > m_DOIUpdater
virtual objects::CBioseq_Handle GetBioseqHandle(void) const
CMacroBioData_SeqdescIter & operator=(const CMacroBioData_SeqdescIter &)
CMacroBioData_UserObjectIter(const CMacroBioData_UserObjectIter &)
CMacroBioData_MolInfoIter & operator=(const CMacroBioData_MolInfoIter &)
CConstRef< objects::CSeq_feat > m_OrigFeat
CMacroBioData_StructCommentIter(const CMacroBioData_StructCommentIter &)
objects::CSeq_entry_Handle GetSEH() const
const objects::CSubmit_block & GetOrigSubmitBlock() const
virtual void BuildEditedObject()=0
Creates a copy of the object that will be edited.
CMacroBioData_PubdescIter(const CMacroBioData_PubdescIter &)
const objects::CSeq_submit & GetSeqSubmit(void) const
virtual bool IsBegin(void)=0
CMacroBioData_MolInfoIter(const objects::CSeq_entry_Handle &entry)
virtual bool IsDescriptor() const
virtual void RunDeleteCommand(CMacroCmdComposite *cmd_composite)=0
Constructs and executes the delete command.
CMacroBioData_FeatIterBase(const objects::CBioseq_Handle &bsh, const objects::SAnnotSelector &sel, const objects::CSeq_loc &loc)
CConstRef< objects::CSeqdesc > m_OrigSeqdesc
CMacroBioData_BioSourceIter(const objects::CSeq_entry_Handle &entry)
virtual bool IsDescriptor() const
CMacroBioData_TSEntryIter & operator=(const CMacroBioData_TSEntryIter &)
ISOJTALookupMap & SetISOJTALookupMap()
virtual IMacroBioDataIter & Begin(void)=0
CMacroBioData_SeqAlignIter(const CMacroBioData_SeqAlignIter &)
SFeatInterval(const TSeqRange &range, bool left=true, bool right=true)
CMacroBioData_FeatIntervalIter(const CMacroBioData_FeatIntervalIter &)
CMacroBioData_SeqdescIter(const objects::CSeq_entry_Handle &entry)
CRef< objects::CSeqdesc > m_EditedSeqdesc
unordered_map< string, unsigned > TIndex
virtual bool IsFeature() const
CConstRef< objects::CMolInfo > m_OrigMolinfo
CRef< objects::CSeq_entry > m_EditedEntry
objects::CSeqdesc_CI m_PubDescrIter
CConstRef< objects::CMolInfo > m_FirstMolinfo
CRef< CSubmitblockIter > m_SubmitBlockIter
CMacroBioData_AutodefOptsIter & operator=(const CMacroBioData_AutodefOptsIter &)
virtual void RunDeleteCommand(CMacroCmdComposite *cmd_composite)
Constructs and executes the delete command.
CConstRef< objects::CBioSource > m_OrigSource
> provides context information
void SetSeqSubmit(const objects::CSeq_submit &submit)
shared_ptr< CHugeMacroContext > m_MacroContext
CMacroBioData_DBLinkIter(const objects::CSeq_entry_Handle &entry)
CMacroBioData_SeqSetIter(const CMacroBioData_SeqSetIter &)
objects::CSeq_entry_CI m_SeqSetIter
> provides context information
virtual objects::CBioseq_Handle GetBioseqHandle(void) const
objects::CSeq_entry_CI m_EntryIter
virtual const vector< string > & GetTaxnames() const
map< objects::CBioseq_Handle, set< objects::CSeq_feat_Handle > > m_ProductToCDS
virtual bool IsFeature() const
virtual void x_SetDefaultObjectInfo()=0
Initializes member variable m_CurIterOI.
CMacroBioData_SeqdescIter(const CMacroBioData_SeqdescIter &)
bool m_Modified
indicates whether the edited object has been modified. When it's TRUE, call RunEditCommand()
CMacroBioData_SeqAlignIter & operator=(const CMacroBioData_SeqAlignIter &)
TPresent m_State
to report values of the matching field that are present in the table, but not present in the data
CConstRef< objects::CUser_object > m_FirstUserObj
string m_Delimiter
< number of actual columns in the table
list< pair< size_t, TTableValues > > m_TableValues
virtual objects::CBioseq_Handle GetBioseqHandle(void) const
virtual IMacroBioDataIter & Next(void)=0
CRef< objects::CSeq_feat > m_EditedFeat
CMacroBioData_FeatIterBase & operator=(const CMacroBioData_FeatIterBase &)
virtual SConstScopedObject GetScopedObject() const =0
Dereferences the underlying iterator.
CMacroBioData_SeqIter(const objects::CSeq_entry_Handle &entry)
CMacroBioData_SeqIter(const CMacroBioData_SeqIter &)
virtual size_t GetCount() const
CObjectInfo GetEditedObject()
CConstRef< objects::CSeq_submit > m_SeqSubmit
virtual void SetToDelete(bool intent)
virtual bool IsFeature() const =0
shared_ptr< CISOJTALookupWithCache > m_ISOJTAUpdater
CConstRef< objects::CPubdesc > m_OrigPubdesc
ECollDateType GetCollDateType() const
CMacroBioData_AutodefOptsIter(const CMacroBioData_AutodefOptsIter &)
CMacroBioData_PubdescIter(const objects::CSeq_entry_Handle &entry)
virtual void RunEditCommand(CMacroCmdComposite *cmd_composite)
Constructs and executes the editing command.
virtual string GetBestDescr() const =0
Used for logging.
CConstRef< objects::CBioseq > m_OrigSeq
CMacroBioData_DBLinkIter(const CMacroBioData_DBLinkIter &)
TPmidLookupMap & SetPmidLookupMap()
objects::CSeqdesc_CI m_SrcDescrIter
CRef< objects::CBioSource > m_EditedSource
CRef< objects::CSeq_align > m_EditedSeqalign
CConstRef< objects::CBioSource > m_FirstSource
CRef< objects::CBioseq_set > m_EditedSeqSet
STableToApply m_TableToApply
virtual void RunEditCommand(CMacroCmdComposite *cmd_composite)=0
Constructs and executes the editing command.
CMacroBioData_DBLinkIter & operator=(const CMacroBioData_DBLinkIter &)
IMacroBioDataIter(const objects::CSeq_entry_Handle &entry)
CMacroBioData_BioSourceIter(const CMacroBioData_BioSourceIter &)
CConstRef< objects::CPubdesc > m_FirstPubdesc
bool IsSetSeqSubmit(void) const
CMacroBioData_UserObjectIter(const objects::CSeq_entry_Handle &entry)
CMacroBioData_SeqIter & operator=(const CMacroBioData_SeqIter &)
void SetOutputStream(CNcbiOstream *str)
CMacroBioData_FeatIntervalIter(const objects::CBioseq_Handle &bsh, const objects::SAnnotSelector &sel, const SFeatInterval &feat_interval)
CConstRef< objects::CSeq_feat > m_OrigFeat
virtual bool IsFeature() const
TIndex m_Index
stores the match_field value and the row number where that value appears in the table
CNcbiOstream & GetOutputStream() const
objects::CAutoDefOptions & SetAutodefOptions()
objects::CSubmit_block & GetEditedSubmitBlock() const
CMacroBioData_MolInfoIter(const CMacroBioData_MolInfoIter &)
CConstRef< objects::CUser_object > m_OrigUserObj
bool m_DeleteObject
indicates the intention to delete the underlying object
CRef< objects::CUser_object > m_EditedUserObj
vector< string > m_Taxnames
bool IsSetOutputStream() const
CMacroBioData_StructCommentIter(const objects::CSeq_entry_Handle &entry)
objects::CSeq_entry_Handle m_Seh
bool HasBeenCompleted() const
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:149
#define kEmptyStr
Definition: ncbistr.hpp:123
int TSplitFlags
Bitwise OR of ESplitFlags.
Definition: ncbistr.hpp:2510
#define NCBI_GUIOBJUTILS_EXPORT
Definition: gui_export.h:512
Defines to provide correct exporting from DLLs in Windows.
range(_Ty, _Ty) -> range< _Ty >
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
static const char delimiter[]
static CS_CONTEXT * context
Definition: will_convert.c:21
Modified on Tue May 28 05:50:32 2024 by modify_doxy.py rev. 669887