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

Go to the SVN repository for this file.

1 /* $Id: feat_ci.cpp 78010 2017-05-18 14:44:05Z vasilche $
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 * Author: Aleksey Grichenko, Eugene Vasilchenko
27 *
28 * File Description:
29 * Object manager iterators
30 *
31 */
32 
33 #include <ncbi_pch.hpp>
34 #include <objmgr/feat_ci.hpp>
35 #include <objmgr/bioseq_handle.hpp>
42 #include <objmgr/impl/tse_info.hpp>
52 
55 
56 
58 {
59 }
60 
61 
63  : CAnnotTypes_CI(iter)
64 {
65  Update();
66 }
67 
68 
70 {
71 }
72 
73 
75 {
76  if ( this != &iter ) {
77  CAnnotTypes_CI::operator=(iter);
78  Update();
79  }
80  return *this;
81 }
82 
83 
85  : CAnnotTypes_CI(CSeq_annot::C_Data::e_Ftable,
86  bioseq,
87  CRange<TSeqPos>::GetWhole(),
89 {
90  Update();
91 }
92 
93 
95  const SAnnotSelector& sel)
96  : CAnnotTypes_CI(CSeq_annot::C_Data::e_Ftable,
97  bioseq,
98  CRange<TSeqPos>::GetWhole(),
100  &sel)
101 {
102  Update();
103 }
104 
105 
107  const CRange<TSeqPos>& range,
108  ENa_strand strand)
109  : CAnnotTypes_CI(CSeq_annot::C_Data::e_Ftable,
110  bioseq,
111  range,
112  strand)
113 {
114  Update();
115 }
116 
117 
119  const CRange<TSeqPos>& range,
120  const SAnnotSelector& sel)
121  : CAnnotTypes_CI(CSeq_annot::C_Data::e_Ftable,
122  bioseq,
123  range,
125  &sel)
126 {
127  Update();
128 }
129 
130 
132  const CRange<TSeqPos>& range,
133  ENa_strand strand,
134  const SAnnotSelector& sel)
135  : CAnnotTypes_CI(CSeq_annot::C_Data::e_Ftable,
136  bioseq,
137  range,
138  strand,
139  &sel)
140 {
141  Update();
142 }
143 
144 
146  const CSeq_loc& loc)
147  : CAnnotTypes_CI(CSeq_annot::C_Data::e_Ftable,
148  scope,
149  loc)
150 {
151  Update();
152 }
153 
154 
156  const CSeq_loc& loc,
157  const SAnnotSelector& sel)
158  : CAnnotTypes_CI(CSeq_annot::C_Data::e_Ftable,
159  scope,
160  loc,
161  &sel)
162 {
163  Update();
164 }
165 
166 
168  : CAnnotTypes_CI(CSeq_annot::C_Data::e_Ftable,
169  annot)
170 {
171  Update();
172 }
173 
174 
176  const SAnnotSelector& sel)
177  : CAnnotTypes_CI(CSeq_annot::C_Data::e_Ftable,
178  annot,
179  &sel)
180 {
181  Update();
182 }
183 
184 
186  const CSeq_annot_Handle& annot)
187  : CAnnotTypes_CI(CSeq_annot::C_Data::e_Ftable,
188  loc,
189  annot)
190 {
191  Update();
192 }
193 
194 
196  const CSeq_annot_Handle& annot,
197  const SAnnotSelector& sel)
198  : CAnnotTypes_CI(CSeq_annot::C_Data::e_Ftable,
199  loc,
200  annot,
201  &sel)
202 {
203  Update();
204 }
205 
206 
208  : CAnnotTypes_CI(CSeq_annot::C_Data::e_Ftable,
209  entry)
210 {
211  Update();
212 }
213 
214 
216  const SAnnotSelector& sel)
217  : CAnnotTypes_CI(CSeq_annot::C_Data::e_Ftable,
218  entry,
219  &sel)
220 {
221  Update();
222 }
223 
224 
226  const SAnnotSelector& sel,
227  const TFeatureId& feat_id)
228  : CAnnotTypes_CI(tse.GetScope())
229 {
230  x_AddFeaturesWithId(tse, sel, feat_id);
231 }
232 
233 
235  const SAnnotSelector& sel,
236  const TFeatureIdInt& int_id)
237  : CAnnotTypes_CI(tse.GetScope())
238 {
239  CObject_id feat_id;
240  feat_id.SetId(int_id);
241  x_AddFeaturesWithId(tse, sel, feat_id);
242 }
243 
244 
246  const SAnnotSelector& sel,
247  const TFeatureIdStr& str_id)
248  : CAnnotTypes_CI(tse.GetScope())
249 {
250  CObject_id feat_id;
251  feat_id.SetStr(str_id);
252  x_AddFeaturesWithId(tse, sel, feat_id);
253 }
254 
255 
257  const SAnnotSelector& sel,
258  const TFeatureId& feat_id)
259 {
260  CSeqFeatData::ESubtype subtype = sel.GetFeatSubtype();
261  if ( subtype == CSeqFeatData::eSubtype_any ) {
262  if ( sel.GetFeatProduct() ) {
263  x_AddFeatures(sel, tse.GetFeaturesWithXref(subtype, feat_id));
264  }
265  else {
266  x_AddFeatures(sel, tse.GetFeaturesWithId(subtype, feat_id));
267  }
268  }
269  else {
270  pair<size_t, size_t> range = CAnnotType_Index::GetIndexRange(sel);
271  for ( size_t i = range.first; i < range.second; ++i ) {
273  if ( !tse.x_GetTSE_Info().x_HasFeaturesWithId(subtype) ) {
274  continue;
275  }
276  if ( sel.GetFeatProduct() ) {
277  x_AddFeatures(sel, tse.GetFeaturesWithXref(subtype, feat_id));
278  }
279  else {
280  x_AddFeatures(sel, tse.GetFeaturesWithId(subtype, feat_id));
281  }
282  }
283  }
284  Rewind();
285 }
286 
287 
289  const TSeq_feat_Handles& feats)
290 {
291  CAnnot_Collector& collector = GetCollector();
292  collector.m_Selector = &sel;
293  ITERATE ( TSeq_feat_Handles, it, feats ) {
294  const CAnnotObject_Info& info = it->x_GetAnnotObject_Info();
295  if ( collector.x_MatchLimitObject(info) ) {
296  CAnnotObject_Ref feat_ref(info, it->GetAnnot());
297  collector.x_AddObject(feat_ref);
298  }
299  }
300 }
301 
302 
User-defined methods of the data storage class.
static CSeqFeatData::ESubtype GetSubtypeForIndex(size_t index)
static TIndexRange GetIndexRange(const SAnnotTypeSelector &sel)
CAnnot_Collector & GetCollector(void)
void x_AddObject(CAnnotObject_Ref &object_ref)
bool x_MatchLimitObject(const CAnnotObject_Info &annot_info) const
const SAnnotSelector * m_Selector
CBioseq_Handle –.
CFeat_CI –.
Definition: feat_ci.hpp:64
CRange –.
Definition: Range.hpp:68
CScope –.
Definition: scope.hpp:92
CSeq_annot_Handle –.
CSeq_entry_Handle –.
TSeq_feat_Handles GetFeaturesWithId(CSeqFeatData::E_Choice type, TFeatureIdInt id) const
Definition: tse_handle.cpp:604
TSeq_feat_Handles GetFeaturesWithXref(CSeqFeatData::E_Choice type, TFeatureIdInt id) const
Definition: tse_handle.cpp:620
const CTSE_Info & x_GetTSE_Info(void) const
Definition: tse_handle.cpp:116
bool x_HasFeaturesWithId(CSeqFeatData::ESubtype subtype) const
Definition: tse_info.cpp:1461
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
int TFeatureIdInt
Definition: feat_ci.hpp:143
void Update(void)
Definition: feat_ci.hpp:209
CFeat_CI(void)
Definition: feat_ci.cpp:57
vector< CSeq_feat_Handle > TSeq_feat_Handles
Definition: feat_ci.hpp:199
void x_AddFeatures(const SAnnotSelector &sel, const TSeq_feat_Handles &feats)
Definition: feat_ci.cpp:288
virtual ~CFeat_CI(void)
Definition: feat_ci.cpp:69
void x_AddFeaturesWithId(const CTSE_Handle &tse, const SAnnotSelector &sel, const TFeatureId &feat_id)
Definition: feat_ci.cpp:256
bool GetFeatProduct(void) const
Return true if the features should be searched using their product rather than location.
CFeat_CI & operator=(const CFeat_CI &iter)
Definition: feat_ci.cpp:74
void Rewind(void)
Definition: feat_ci.hpp:239
string TFeatureIdStr
Definition: feat_ci.hpp:144
#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
TStr & SetStr(void)
Select the variant.
Definition: Object_id_.hpp:304
TId & SetId(void)
Select the variant.
Definition: Object_id_.hpp:277
ENa_strand
strand of nucleic acid
Definition: Na_strand_.hpp:64
@ eNa_strand_unknown
Definition: Na_strand_.hpp:65
int i
static MDB_envinfo info
Definition: mdb_load.c:37
range(_Ty, _Ty) -> range< _Ty >
SAnnotSelector –.
TFeatSubtype GetFeatSubtype(void) const
CScope & GetScope()
Modified on Sun Apr 21 03:39:39 2024 by modify_doxy.py rev. 669887