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

Go to the SVN repository for this file.

1 #ifndef BIOSEQ_CI__HPP
2 #define BIOSEQ_CI__HPP
3 
4 /* $Id: bioseq_ci.hpp 59914 2013-09-26 15:15:41Z vasilche $
5 * ===========================================================================
6 *
7 * PUBLIC DOMAIN NOTICE
8 * National Center for Biotechnology Information
9 *
10 * This software/database is a "United States Government Work" under the
11 * terms of the United States Copyright Act. It was written as part of
12 * the author's official duties as a United States Government employee and
13 * thus cannot be copyrighted. This software/database is freely available
14 * to the public for use. The National Library of Medicine and the U.S.
15 * Government have not placed any restriction on its use or reproduction.
16 *
17 * Although all reasonable efforts have been taken to ensure the accuracy
18 * and reliability of the software and data, the NLM and the U.S.
19 * Government do not and cannot warrant the performance or results that
20 * may be obtained by using this software or data. The NLM and the U.S.
21 * Government disclaim all warranties, express or implied, including
22 * warranties of performance, merchantability or fitness for any particular
23 * purpose.
24 *
25 * Please cite the author in any work or product based on this material.
26 *
27 * ===========================================================================
28 *
29 * Author: Aleksey Grichenko
30 *
31 * File Description:
32 * Iterates over bioseqs from a given seq-entry and scope
33 *
34 */
35 
36 
37 #include <corelib/ncbiobj.hpp>
38 #include <objmgr/bioseq_handle.hpp>
41 #include <objmgr/seq_entry_ci.hpp>
42 #include <objects/seq/Seq_inst.hpp>
43 
44 #include <vector>
45 
48 
49 
50 /** @addtogroup ObjectManagerIterators
51  *
52  * @{
53  */
54 
55 
56 class CScope;
57 class CBioseq_Handle;
58 class CSeq_entry;
59 
60 
61 /////////////////////////////////////////////////////////////////////////////
62 ///
63 /// CBioseq_CI --
64 ///
65 /// Enumerate bioseqs in a given seq-entry
66 ///
67 
69 {
70 public:
71  /// Class of bioseqs to iterate
73  eLevel_All, ///< Any bioseq
74  eLevel_Mains, ///< Main bioseq only
75  eLevel_Parts, ///< Parts only
76  eLevel_IgnoreClass ///< Search for bioseqs in any bioseq-set
77  ///< regardless of types and classes.
78  };
79 
80  // 'ctors
81  CBioseq_CI(void);
82 
83  /// Create an iterator that enumerates bioseqs
84  /// from the entry taken from the scope. Use optional
85  /// filter to iterate over selected bioseq types only.
86  /// Filter value eMol_na may be used to include both
87  /// dna and rna bioseqs.
88  explicit
89  CBioseq_CI(const CSeq_entry_Handle& entry,
91  EBioseqLevelFlag level = eLevel_All);
92 
93  explicit
94  CBioseq_CI(const CBioseq_set_Handle& bioseq_set,
96  EBioseqLevelFlag level = eLevel_All);
97 
98  /// Create an iterator that enumerates bioseqs
99  /// from the entry taken from the given scope. Use optional
100  /// filter to iterate over selected bioseq types only.
101  /// Filter value eMol_na may be used to include both
102  /// dna and rna bioseqs.
103  CBioseq_CI(CScope& scope, const CSeq_entry& entry,
105  EBioseqLevelFlag level = eLevel_All);
106 
107  CBioseq_CI(const CBioseq_CI& bioseq_ci);
108  ~CBioseq_CI(void);
109 
110  /// Get the current scope for the iterator
111  CScope& GetScope(void) const;
112 
113  CBioseq_CI& operator= (const CBioseq_CI& bioseq_ci);
114 
115  /// Move to the next object in iterated sequence
116  CBioseq_CI& operator++ (void);
117 
118  /// Check if iterator points to an object
119  DECLARE_OPERATOR_BOOL(m_CurrentBioseq);
120 
121  const CBioseq_Handle& operator* (void) const;
122  const CBioseq_Handle* operator-> (void) const;
123 
124 private:
125  void x_Initialize(const CSeq_entry_Handle& entry);
126 
127  void x_PushEntry(const CSeq_entry_Handle& entry);
128  void x_PopEntry(bool next = true);
129  void x_NextEntry(void);
130 
131  void x_Settle(void);
132 
133  bool x_IsValidMolType(const CBioseq_Info& seq) const;
134  bool x_SkipClass(CBioseq_set::TClass set_class);
135 
136  typedef vector<CSeq_entry_CI> TEntryStack;
137 
141  CSeq_entry_Handle m_CurrentEntry; // current entry to process (whole)
142  CBioseq_Handle m_CurrentBioseq; // current found Bioseq
143  TEntryStack m_EntryStack; // path to the current entry
145 };
146 
147 
148 inline
150 {
151  return m_CurrentBioseq;
152 }
153 
154 
155 inline
157 {
158  return &m_CurrentBioseq;
159 }
160 
161 
162 inline
164 {
165  return m_Scope.GetScope();
166 }
167 
168 
169 /* @} */
170 
171 
174 
175 #endif // BIOSEQ_CI__HPP
CBioseq_CI –.
Definition: bioseq_ci.hpp:69
CBioseq_Handle –.
CBioseq_set_Handle –.
CScope & GetScope(void) const
Definition: heap_scope.cpp:68
CScope –.
Definition: scope.hpp:92
CSeq_entry_Handle –.
Definition: Seq_entry.hpp:56
static DLIST_TYPE *DLIST_NAME() next(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
Definition: dlist.tmpl.h:56
CVect2< NCBI_PROMOTE(int,U) > operator*(int v1, const CVect2< U > &v2)
Definition: globals.hpp:371
CBioseq_Handle m_CurrentBioseq
Definition: bioseq_ci.hpp:142
CSeq_inst::EMol m_Filter
Definition: bioseq_ci.hpp:139
CSeq_entry_Handle m_CurrentEntry
Definition: bioseq_ci.hpp:141
EBioseqLevelFlag
Class of bioseqs to iterate.
Definition: bioseq_ci.hpp:72
CHeapScope m_Scope
Definition: bioseq_ci.hpp:138
CScope & GetScope(void) const
Get the current scope for the iterator.
Definition: bioseq_ci.hpp:163
const CBioseq_Handle * operator->(void) const
Definition: bioseq_ci.hpp:156
DECLARE_OPERATOR_BOOL(m_CurrentBioseq)
Check if iterator points to an object.
TEntryStack m_EntryStack
Definition: bioseq_ci.hpp:143
EBioseqLevelFlag m_Level
Definition: bioseq_ci.hpp:140
const CBioseq_Handle & operator*(void) const
Definition: bioseq_ci.hpp:149
vector< CSeq_entry_CI > TEntryStack
Definition: bioseq_ci.hpp:136
@ eLevel_All
Any bioseq.
Definition: bioseq_ci.hpp:73
@ eLevel_Parts
Parts only.
Definition: bioseq_ci.hpp:75
@ eLevel_Mains
Main bioseq only.
Definition: bioseq_ci.hpp:74
#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
#define NCBI_XOBJMGR_EXPORT
Definition: ncbi_export.h:1307
EMol
molecule class in living organism
Definition: Seq_inst_.hpp:108
@ eMol_not_set
> cdna = rna
Definition: Seq_inst_.hpp:109
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
CScope & GetScope()
Modified on Sat May 25 14:15:59 2024 by modify_doxy.py rev. 669887