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

Go to the SVN repository for this file.

1 /* $Id: annot_types_ci.cpp 90163 2020-05-18 16:26:33Z 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>
35 #include <objmgr/bioseq_handle.hpp>
37 #include <objmgr/scope.hpp>
43 
46 
47 
48 /////////////////////////////////////////////////////////////////////////////
49 // CAnnotTypes_CI
50 /////////////////////////////////////////////////////////////////////////////
51 
52 
54  : m_DataCollector(0)
55 {
56  return;
57 }
58 
59 
61  : m_DataCollector(new CAnnot_Collector(scope))
62 {
63  return;
64 }
65 
66 /*
67 CAnnotTypes_CI::CAnnotTypes_CI(TAnnotType type,
68  const CBioseq_Handle& bioseq,
69  const SAnnotSelector* params)
70  : m_DataCollector(new CAnnot_Collector(bioseq.GetScope()))
71 {
72  if ( !params ) {
73  SAnnotSelector sel(type);
74  m_DataCollector->x_Initialize(sel,
75  bioseq,
76  CRange<TSeqPos>::GetWhole(),
77  eNa_strand_unknown);
78  }
79  else if ( !params->CheckAnnotType(type) ) {
80  SAnnotSelector sel(*params);
81  sel.ForceAnnotType(type);
82  m_DataCollector->x_Initialize(sel,
83  bioseq,
84  CRange<TSeqPos>::GetWhole(),
85  eNa_strand_unknown);
86  }
87  else {
88  m_DataCollector->x_Initialize(*params,
89  bioseq,
90  CRange<TSeqPos>::GetWhole(),
91  eNa_strand_unknown);
92  }
93  Rewind();
94 }
95 */
96 
98  const CBioseq_Handle& bioseq,
99  const CRange<TSeqPos>& range,
100  ENa_strand strand,
101  const SAnnotSelector* params)
102  : m_DataCollector(new CAnnot_Collector(bioseq.GetScope()))
103 {
104  if ( !params ) {
105  SAnnotSelector sel(type);
106  m_DataCollector->x_Initialize(sel, bioseq, range, strand);
107  }
108  else if ( type != CSeq_annot::C_Data::e_not_set &&
109  !params->CheckAnnotType(type) ) {
110  SAnnotSelector sel(*params);
111  sel.ForceAnnotType(type);
112  m_DataCollector->x_Initialize(sel, bioseq, range, strand);
113  }
114  else {
115  m_DataCollector->x_Initialize(*params, bioseq, range, strand);
116  }
117  Rewind();
118 }
119 
120 
122  const CSeq_loc& loc,
123  const SAnnotSelector& params)
124 {
125  if ( loc.IsWhole() ) {
126  CBioseq_Handle bh = scope.GetBioseqHandle(loc.GetWhole());
127  if ( bh ) {
129  bh,
132  Rewind();
133  return;
134  }
135  }
136  else if ( loc.IsInt() ) {
137  const CSeq_interval& seq_int = loc.GetInt();
138  CBioseq_Handle bh = scope.GetBioseqHandle(seq_int.GetId());
139  if ( bh ) {
140  CRange<TSeqPos> range(seq_int.GetFrom(), seq_int.GetTo());
141  ENa_strand strand =
142  seq_int.IsSetStrand()? seq_int.GetStrand(): eNa_strand_unknown;
143  m_DataCollector->x_Initialize(params, bh, range, strand);
144  Rewind();
145  return;
146  }
147  }
148  CHandleRangeMap master_loc;
149  master_loc.AddLocation(loc);
150  m_DataCollector->x_Initialize(params, master_loc);
151  Rewind();
152 }
153 
154 
156  CScope& scope,
157  const CSeq_loc& loc,
158  const SAnnotSelector* params)
159  : m_DataCollector(new CAnnot_Collector(scope))
160 {
161  if ( !params ) {
162  x_Init(scope, loc, SAnnotSelector(type));
163  }
164  else if ( type != CSeq_annot::C_Data::e_not_set &&
165  !params->CheckAnnotType(type) ) {
166  SAnnotSelector sel(*params);
167  sel.ForceAnnotType(type);
168  x_Init(scope, loc, sel);
169  }
170  else {
171  x_Init(scope, loc, *params);
172  }
173 }
174 
175 
177  const CSeq_annot_Handle& annot,
178  const SAnnotSelector* params)
179  : m_DataCollector(new CAnnot_Collector(annot.GetScope()))
180 {
181  SAnnotSelector sel = params ? *params : SAnnotSelector();
182  sel.ForceAnnotType(type)
183  .SetResolveNone() // nothing to resolve
184  .SetLimitSeqAnnot(annot);
186  Rewind();
187 }
188 
189 
191  const CSeq_loc& loc,
192  const CSeq_annot_Handle& annot,
193  const SAnnotSelector* params)
194  : m_DataCollector(new CAnnot_Collector(annot.GetScope()))
195 {
196  SAnnotSelector sel = params ? *params : SAnnotSelector();
197  sel.ForceAnnotType(type)
198  .SetLimitSeqAnnot(annot);
199  x_Init(annot.GetScope(), loc, sel);
200 }
201 
202 
204  const CSeq_entry_Handle& entry,
205  const SAnnotSelector* params)
206  : m_DataCollector(new CAnnot_Collector(entry.GetScope()))
207 {
208  SAnnotSelector sel = params ? *params : SAnnotSelector();
209  sel.ForceAnnotType(type)
210  .SetResolveNone() // nothing to resolve
212  .SetLimitSeqEntry(entry);
214  Rewind();
215 }
216 
217 
219 {
220  return Get().GetSeq_annot_Handle();
221 }
222 
223 
225 {
226  return;
227 }
228 
229 
231 {
233 }
234 
235 
237 {
239 }
240 
241 
243 {
245 }
246 
247 
const CSeq_annot_Handle & GetSeq_annot_Handle(void) const
virtual ~CAnnotTypes_CI(void)
const CAnnotObject_Ref & Get(void) const
const TAnnotNames & GetAnnotNames(void) const
bool MaxSearchSegmentsLimitIsReached(void) const
vector< SAnnotTypeSelector > TAnnotTypes
SAnnotSelector::TAnnotType TAnnotType
void x_Init(CScope &scope, const CSeq_loc &loc, const SAnnotSelector &params)
CSeq_annot_Handle GetAnnot(void) const
const TAnnotTypes & GetAnnotTypes(void) const
CRef< CAnnot_Collector > m_DataCollector
const TAnnotTypes & x_GetAnnotTypes(void) const
bool x_MaxSearchSegmentsLimitIsReached(void) const
const TAnnotNames & x_GetAnnotNames(void) const
void x_Initialize(const SAnnotSelector &selector, const CBioseq_Handle &bioseq, const CRange< TSeqPos > &range, ENa_strand strand)
CBioseq_Handle –.
void AddLocation(const CSeq_loc &loc, ETransSplicing trans_splcing=eNoTransSplicing)
CScope –.
Definition: scope.hpp:92
CSeq_annot_Handle –.
CSeq_entry_Handle –.
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
Definition: scope.cpp:95
CScope & GetScope(void) const
Get scope this handle belongs to.
SAnnotSelector & ForceAnnotType(TAnnotType type)
Set annot type, include all subtypes.
SAnnotSelector & SetLimitSeqAnnot(const CSeq_annot_Handle &limit)
Limit annotations to those from the seq-annot only.
bool CheckAnnotType(TAnnotType type) const
Check annot type (ignore subtypes).
SAnnotSelector & SetResolveNone(void)
SetResolveNone() is equivalent to SetResolveMethod(eResolve_None).
SAnnotSelector & SetSortOrder(ESortOrder sort_order)
Set sort order of annotations.
SAnnotSelector & SetLimitSeqEntry(const CSeq_entry_Handle &limit)
Limit annotations to those from the seq-entry only.
@ eSortOrder_None
do not sort annotations for faster retrieval
#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
ENa_strand
strand of nucleic acid
Definition: Na_strand_.hpp:64
const TId & GetId(void) const
Get the Id member data.
const TWhole & GetWhole(void) const
Get the variant data.
Definition: Seq_loc_.cpp:172
TFrom GetFrom(void) const
Get the From member data.
bool IsSetStrand(void) const
Check if a value has been assigned to Strand data member.
TStrand GetStrand(void) const
Get the Strand member data.
TTo GetTo(void) const
Get the To member data.
bool IsWhole(void) const
Check if variant Whole is selected.
Definition: Seq_loc_.hpp:522
bool IsInt(void) const
Check if variant Int is selected.
Definition: Seq_loc_.hpp:528
const TInt & GetInt(void) const
Get the variant data.
Definition: Seq_loc_.cpp:194
@ eNa_strand_unknown
Definition: Na_strand_.hpp:65
@ e_not_set
No variant selected.
Definition: Seq_annot_.hpp:132
range(_Ty, _Ty) -> range< _Ty >
SAnnotSelector –.
Definition: type.c:6
CScope & GetScope()
Modified on Tue Apr 16 20:14:26 2024 by modify_doxy.py rev. 669887