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

Go to the SVN repository for this file.

1 #ifndef FEAT_CI__HPP
2 #define FEAT_CI__HPP
3 
4 /* $Id: feat_ci.hpp 90144 2020-05-15 14:51:14Z 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, Michael Kimelman, Eugene Vasilchenko
30 *
31 * File Description:
32 * Object manager iterators
33 *
34 */
35 
36 #include <corelib/ncbistd.hpp>
42 #include <objmgr/mapped_feat.hpp>
43 
46 
47 class CSeq_annot_Handle;
48 
49 /** @addtogroup ObjectManagerIterators
50  *
51  * @{
52  */
53 
54 
55 /////////////////////////////////////////////////////////////////////////////
56 ///
57 /// CFeat_CI --
58 ///
59 /// Enumerate CSeq_feat objects related to a bioseq, seq-loc,
60 /// or contained in a particular seq-entry or seq-annot
61 /// regardless of the referenced locations.
62 
64 {
65 public:
66  CFeat_CI(void);
67 
68  /// Search features on the whole bioseq
69  explicit
70  CFeat_CI(const CBioseq_Handle& bioseq);
71 
72  /// Search features on the whole bioseq
73  ///
74  /// @sa
75  /// SAnnotSelector
76  CFeat_CI(const CBioseq_Handle& bioseq,
77  const SAnnotSelector& sel);
78 
79  /// Search features on part of the bioseq
80  CFeat_CI(const CBioseq_Handle& bioseq,
81  const CRange<TSeqPos>& range,
83 
84  /// Search features on part of the bioseq
85  CFeat_CI(const CBioseq_Handle& bioseq,
86  const CRange<TSeqPos>& range,
87  const SAnnotSelector& sel);
88 
89  /// Search features on part of the bioseq
90  CFeat_CI(const CBioseq_Handle& bioseq,
91  const CRange<TSeqPos>& range,
92  ENa_strand strand,
93  const SAnnotSelector& sel);
94 
95  /// Search features related to the location
96  CFeat_CI(CScope& scope,
97  const CSeq_loc& loc);
98 
99  /// Search features related to the location
100  ///
101  /// @sa
102  /// SAnnotSelector
103  CFeat_CI(CScope& scope,
104  const CSeq_loc& loc,
105  const SAnnotSelector& sel);
106 
107  /// Iterate all features from the seq-annot regardless of their location
108  explicit
109  CFeat_CI(const CSeq_annot_Handle& annot);
110 
111  /// Iterate all features from the seq-annot regardless of their location
112  ///
113  /// @sa
114  /// SAnnotSelector
115  CFeat_CI(const CSeq_annot_Handle& annot,
116  const SAnnotSelector& sel);
117 
118  /// Iterate all features from the seq-annot that annotate the location
119  CFeat_CI(const CSeq_loc& loc,
120  const CSeq_annot_Handle& annot);
121 
122  /// Iterate all features from the seq-annot that annotate the location
123  ///
124  /// @sa
125  /// SAnnotSelector
126  CFeat_CI(const CSeq_loc& loc,
127  const CSeq_annot_Handle& annot,
128  const SAnnotSelector& sel);
129 
130  /// Iterate all features from the seq-entry regardless of their location
131  explicit
132  CFeat_CI(const CSeq_entry_Handle& entry);
133 
134  /// Iterate all features from the seq-entry regardless of their location
135  ///
136  /// @sa
137  /// SAnnotSelector
138  CFeat_CI(const CSeq_entry_Handle& entry,
139  const SAnnotSelector& sel);
140 
141  /// Search features with specified id
143  typedef int TFeatureIdInt;
144  typedef string TFeatureIdStr;
145  CFeat_CI(const CTSE_Handle& tse,
146  const SAnnotSelector& sel,
147  const TFeatureId& id);
148  CFeat_CI(const CTSE_Handle& tse,
149  const SAnnotSelector& sel,
150  const TFeatureIdInt& int_id);
151  CFeat_CI(const CTSE_Handle& tse,
152  const SAnnotSelector& sel,
153  const TFeatureIdStr& str_id);
154 
155  CFeat_CI(const CFeat_CI& iter);
156  virtual ~CFeat_CI(void);
157  CFeat_CI& operator= (const CFeat_CI& iter);
158 
159  /// Move to the next object in iterated sequence
160  CFeat_CI& operator++(void);
161 
162  /// Move to the pervious object in iterated sequence
163  CFeat_CI& operator--(void);
164 
165  /// Check if iterator points to an object
167 
168  void Update(void);
169  void Rewind(void);
170 
171  const CFeat_CI& begin() const
172  {
173  return *this;
174  }
175  CFeat_CI end() const
176  {
177  return CFeat_CI(*this, at_end);
178  }
179  bool operator!=(const CFeat_CI& it) const
180  {
181  return CAnnotTypes_CI::operator!=(it);
182  }
183 
184  const CMappedFeat& operator* (void) const;
185  const CMappedFeat* operator-> (void) const;
186 
187 private:
188  CFeat_CI& operator++ (int);
190 
192  : CAnnotTypes_CI(it, at_end)
193  {
194  }
195 
196  void x_AddFeaturesWithId(const CTSE_Handle& tse,
197  const SAnnotSelector& sel,
198  const TFeatureId& feat_id);
199  typedef vector<CSeq_feat_Handle> TSeq_feat_Handles;
200  void x_AddFeatures(const SAnnotSelector& sel,
201  const TSeq_feat_Handles& feats);
202 
203  CMappedFeat m_MappedFeat;// current feature object returned by operator->()
204 };
205 
206 
207 
208 inline
210 {
211  if ( IsValid() ) {
213  }
214  else {
216  }
217 }
218 
219 
220 inline
222 {
223  Next();
224  Update();
225  return *this;
226 }
227 
228 
229 inline
231 {
232  Prev();
233  Update();
234  return *this;
235 }
236 
237 
238 inline
240 {
242  Update();
243 }
244 
245 
246 inline
248 {
249  return m_MappedFeat;
250 }
251 
252 
253 inline
255 {
256  return &m_MappedFeat;
257 }
258 
259 
260 /* @} */
261 
262 
265 
266 #endif // FEAT_CI__HPP
CAnnot_Collector & GetCollector(void)
bool IsValid(void) const
const TIterator & GetIterator(void) const
bool operator!=(const CAnnotTypes_CI &it) const
CBioseq_Handle –.
CFeat_CI –.
Definition: feat_ci.hpp:64
CMappedFeat –.
Definition: mapped_feat.hpp:59
CScope –.
Definition: scope.hpp:92
CSeq_annot_Handle –.
CSeq_entry_Handle –.
Include a standard set of the NCBI C++ Toolkit most basic headers.
CVect2< NCBI_PROMOTE(int,U) > operator*(int v1, const CVect2< U > &v2)
Definition: globals.hpp:371
int TFeatureIdInt
Definition: feat_ci.hpp:143
void Update(void)
Definition: feat_ci.hpp:209
CObject_id TFeatureId
Search features with specified id.
Definition: feat_ci.hpp:142
vector< CSeq_feat_Handle > TSeq_feat_Handles
Definition: feat_ci.hpp:199
bool operator!=(const CFeat_CI &it) const
Definition: feat_ci.hpp:179
CMappedFeat m_MappedFeat
Definition: feat_ci.hpp:203
const CMappedFeat & operator*(void) const
Definition: feat_ci.hpp:247
CMappedFeat & Set(CAnnot_Collector &collector, const CAnnotObject_Ref &feat_ref)
Definition: mapped_feat.cpp:86
CFeat_CI & operator--(void)
Move to the pervious object in iterated sequence.
Definition: feat_ci.hpp:230
CFeat_CI(const CFeat_CI &it, EAtEnd)
Definition: feat_ci.hpp:191
DECLARE_OPERATOR_BOOL(IsValid())
Check if iterator points to an object.
CFeat_CI end() const
Definition: feat_ci.hpp:175
const CMappedFeat * operator->(void) const
Definition: feat_ci.hpp:254
const CFeat_CI & begin() const
Definition: feat_ci.hpp:171
void Rewind(void)
Definition: feat_ci.hpp:239
CFeat_CI & operator++(void)
Move to the next object in iterated sequence.
Definition: feat_ci.hpp:221
string TFeatureIdStr
Definition: feat_ci.hpp:144
void Reset(void)
Definition: mapped_feat.cpp:77
#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
ENa_strand
strand of nucleic acid
Definition: Na_strand_.hpp:64
@ eNa_strand_unknown
Definition: Na_strand_.hpp:65
range(_Ty, _Ty) -> range< _Ty >
S & operator--(CNetRef< S > &r, int)
SAnnotSelector –.
Modified on Sat Apr 13 11:45:34 2024 by modify_doxy.py rev. 669887