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

Go to the SVN repository for this file.

1 #ifndef SEQ_ANNOT_INFO__HPP
2 #define SEQ_ANNOT_INFO__HPP
3 
4 /* $Id: seq_annot_info.hpp 99506 2023-04-10 19:49:27Z 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: Eugene Vasilchenko
30 *
31 * File Description:
32 * Seq-annot object information
33 *
34 */
35 
36 #include <corelib/ncbiobj.hpp>
37 
38 #include <util/range.hpp>
39 
42 #include <objmgr/annot_name.hpp>
46 
47 #include <vector>
48 
51 
52 class CDataSource;
53 class CSeq_annot;
54 class CSeq_entry;
55 class CTSE_Info;
56 class CBioseq_Base_Info;
57 class CAnnotObject_Info;
58 struct SAnnotObject_Key;
61 class CSeqTableInfo;
62 class CFeat_id;
63 class CGene_ref;
64 class CSeq_feat_Handle;
66 
68 {
70 public:
71  // typedefs from CSeq_annot
78  typedef Int4 TAnnotIndex;
79 
80  // annotation index marking the Seq-annot as a whole
81  static const TAnnotIndex kWholeAnnotIndex = kMax_I4;
82 
83  explicit CSeq_annot_Info(CSeq_annot& annot, int chunk_id = 0);
84  explicit CSeq_annot_Info(CSeq_annot_SNP_Info& snp_annot);
85  explicit CSeq_annot_Info(const CSeq_annot_Info& src,
86  TObjectCopyMap* copy_map);
87  ~CSeq_annot_Info(void);
88 
89  const CBioseq_Base_Info& GetParentBioseq_Base_Info(void) const;
90  CBioseq_Base_Info& GetParentBioseq_Base_Info(void);
91 
92  const CSeq_entry_Info& GetParentSeq_entry_Info(void) const;
93  CSeq_entry_Info& GetParentSeq_entry_Info(void);
94 
95  const CSeq_entry_Info& GetXrefTSE(void) const;
96 
98  CConstRef<TObject> GetCompleteSeq_annot(void) const;
99  CConstRef<TObject> GetSeq_annotCore(void) const;
100  CConstRef<TObject> GetSeq_annotSkeleton(void) const;
101 
102  const CAnnotName& GetName(void) const;
103 
104  int GetChunkId(void) const {
105  return m_ChunkId;
106  }
107 
108  // tree initialization
109  virtual void x_DSAttachContents(CDataSource& ds);
110  virtual void x_DSDetachContents(CDataSource& ds);
111 
112  virtual void x_TSEAttachContents(CTSE_Info& tse);
113  virtual void x_TSEDetachContents(CTSE_Info& tse);
114 
115  void x_ParentAttach(CBioseq_Base_Info& parent);
116  void x_ParentDetach(CBioseq_Base_Info& parent);
117 
118  //
119  void UpdateAnnotIndex(void) const;
120 
122 
123  const TObject& x_GetObject(void) const;
124 
125  void x_SetObject(TObject& obj);
126  void x_SetObject(const CSeq_annot_Info& info, TObjectCopyMap* copy_map);
127 
128  void x_SetSNP_annot_Info(CSeq_annot_SNP_Info& snp_info);
129  bool x_HasSNP_annot_Info(void) const;
130  const CSeq_annot_SNP_Info& x_GetSNP_annot_Info(void) const;
131 
132  TAnnotIndex x_GetSNPFeatCount(void) const;
133  TAnnotIndex x_GetAnnotCount(void) const;
134 
135  void x_DoUpdate(TNeedUpdateFlags flags);
136 
138  const TAnnotObjectInfos& GetAnnotObjectInfos(void) const;
139 
141  const TAnnotObjectKeys& GetAnnotObjectKeys(void) const;
142  const SAnnotObject_Key& GetAnnotObjectKey(size_t i) const;
143 
144  // individual annotation editing API
145  void Remove(TAnnotIndex index);
146  // return true if new CSeq_id may appear in TSE annot index
147  bool Replace(TAnnotIndex index, const CSeq_feat& new_obj);
148  bool Replace(TAnnotIndex index, const CSeq_align& new_obj);
149  bool Replace(TAnnotIndex index, const CSeq_graph& new_obj);
150  // return true in 'second' if new CSeq_id may appear in TSE annot index
151  pair<TAnnotIndex, bool> Add(const CSeq_feat& new_obj);
152  pair<TAnnotIndex, bool> Add(const CSeq_align& new_obj);
153  pair<TAnnotIndex, bool> Add(const CSeq_graph& new_obj);
154 
155  void ReorderFtable(const vector<CSeq_feat_Handle>& feats);
156 
157  void Update(TAnnotIndex index);
158  void UpdateAll();
159 
160  void AddFeatId(TAnnotIndex index,
161  const CObject_id& id,
162  EFeatIdType id_type);
163  void RemoveFeatId(TAnnotIndex index,
164  const CObject_id& id,
165  EFeatIdType id_type);
166  void ClearFeatIds(TAnnotIndex index,
167  EFeatIdType id_type);
168 
169  const CAnnotObject_Info& GetInfo(TAnnotIndex index) const;
170 
171  const CSeqTableInfo& GetTableInfo(void) const;
172  bool IsSortedTable(void) const;
173  CSeq_annot_SortedIter StartSortedIterator(CRange<TSeqPos> range) const;
174  bool MatchBitFilter(const SAnnotSelector& sel,
175  const CSeq_annot_SortedIter& iter) const;
176 
177  void UpdateTableFeat(CRef<CSeq_feat>& seq_feat,
178  CRef<CSeq_point>& seq_point,
179  CRef<CSeq_interval>& seq_interval,
180  const CAnnotObject_Info& feat_info) const;
181  void UpdateTableFeatLocation(CRef<CSeq_loc>& seq_loc,
182  CRef<CSeq_point>& seq_point,
183  CRef<CSeq_interval>& seq_interval,
184  const CAnnotObject_Info& feat_info) const;
185  void UpdateTableFeatProduct(CRef<CSeq_loc>& seq_loc,
186  CRef<CSeq_point>& seq_point,
187  CRef<CSeq_interval>& seq_interval,
188  const CAnnotObject_Info& feat_info) const;
189  bool IsTableFeatPartial(const CAnnotObject_Info& feat_info) const;
190 
191  virtual string GetDescription(void) const;
192 
193  // special access to SNP or sorted table features
194  bool TableFeat_HasLabel(TAnnotIndex index) const;
195  string TableFeat_GetLabel(TAnnotIndex index) const;
196 
197 protected:
198  friend class CDataSource;
199  friend class CTSE_Info;
200  friend class CSeq_entry_Info;
201 
202  void x_UpdateName(void);
203 
206 
207  void x_InitAnnotList(void);
208  void x_InitAnnotList(const CSeq_annot_Info& info);
209 
210  void x_InitFeatList(TFtable& objs);
211  void x_InitAlignList(TAlign& objs);
212  void x_InitGraphList(TGraph& objs);
213  void x_InitLocsList(TLocs& annot);
214  void x_InitFeatTable(TSeq_table& table);
215  void x_InitFeatList(TFtable& objs, const CSeq_annot_Info& info);
216  void x_InitAlignList(TAlign& objs, const CSeq_annot_Info& info);
217  void x_InitGraphList(TGraph& objs, const CSeq_annot_Info& info);
218  void x_InitLocsList(TLocs& annot, const CSeq_annot_Info& info);
219 
220  void x_InitAnnotKeys(CTSE_Info& tse);
221 
222  void x_InitFeatKeys(CTSE_Info& tse);
223  void x_InitAlignKeys(CTSE_Info& tse);
224  void x_InitGraphKeys(CTSE_Info& tse);
225  void x_InitLocsKeys(CTSE_Info& tse);
226  void x_InitFeatTableKeys(CTSE_Info& tse);
227 
228  void x_AddAlignKeys(CAnnotObject_Info& info,
229  const CSeq_align& align,
230  const CMasterSeqSegments* master,
231  CTSEAnnotObjectMapper& mapper);
233  void x_AddAlignIndex(CAnnotObject_Info& info,
234  const CSeq_align& align,
235  CTSEAnnotObjectMapper& mapper,
236  vector<CHandleRangeMap>& hrmaps,
237  const TTotalRangesMap* total_ranges_map = 0);
238 
239  void x_UnmapAnnotObjects(CTSE_Info& tse);
240  void x_DropAnnotObjects(CTSE_Info& tse);
241 
242  void x_UnmapAnnotObject(CAnnotObject_Info& info);
243  // return true if new CSeq_id may appear in TSE annot index
244  bool x_MapAnnotObject(CAnnotObject_Info& info);
245  bool x_RemapAnnotObject(CAnnotObject_Info& info);
246 
247  void x_MapFeatIds(CAnnotObject_Info& info);
248  void x_UnmapFeatIds(CAnnotObject_Info& info);
249  void x_MapFeatById(const CFeat_id& id,
251  EFeatIdType id_type);
252  void x_UnmapFeatById(const CFeat_id& id,
254  EFeatIdType id_type);
255  void x_MapFeatByGene(const CGene_ref& gene, CAnnotObject_Info& info);
256  void x_UnmapFeatByGene(const CGene_ref& gene, CAnnotObject_Info& info);
257 
258  // return true if new CSeq_id may appear in TSE annot index
259  bool x_Map(const CTSEAnnotObjectMapper& mapper,
260  const SAnnotObject_Key& key,
261  const SAnnotObject_Index& index);
262 
263  void x_UpdateObjectKeys(CAnnotObject_Info& info, size_t keys_begin);
264 
265  // Seq-annot object
267 
268  // name of Seq-annot
270 
271  // annot object infos array
273 
274  // SNP annotation table
276 
277  // Feature table info
279 
280  // chunk ID for deterministic ordering
282 
283 private:
286 };
287 
288 
290 {
291 public:
292 
293  DECLARE_OPERATOR_BOOL(m_ObjectRow < m_NumRows);
294 
296  {
297  ++m_ObjectRow;
298  x_Settle();
299  return *this;
300  }
301 
302  size_t GetRow(void) const
303  {
304  return m_ObjectRow;
305  }
306 
307  const CRange<TSeqPos>& GetRange(void) const
308  {
309  return m_ObjectRange;
310  }
311 
312 protected:
313  void x_Settle(void);
314  bool x_Valid(void);
315 
316 private:
317  friend class CSeq_annot_Info;
318 
321  size_t m_ObjectRow, m_NumRows;
323 };
324 
325 
326 /////////////////////////////////////////////////////////////////////
327 //
328 // Inline methods
329 //
330 /////////////////////////////////////////////////////////////////////
331 
332 
333 inline
335 {
336  return *m_Object;
337 }
338 
339 
340 inline
343 {
344  return m_ObjectIndex.GetInfos();
345 }
346 
347 
348 inline
351 {
352  return m_ObjectIndex.GetKeys();
353 }
354 
355 
356 inline
357 const SAnnotObject_Key&
359 {
360  return m_ObjectIndex.GetKey(i);
361 }
362 
363 
364 inline
366 {
367  return m_SNP_Info.NotEmpty();
368 }
369 
370 
371 inline
373 {
374  return *m_SNP_Info;
375 }
376 
377 inline
379 {
380  return *m_Table_Info;
381 }
382 
383 inline
385 {
386  return m_Object;
387 }
388 
389 inline
391 {
392  _ASSERT(size_t(index) < GetAnnotObjectInfos().size());
393  return GetAnnotObjectInfos()[index];
394 }
395 
396 
399 
400 #endif // SEQ_ANNOT_INFO__HPP
CFeat_id –.
Definition: Feat_id.hpp:66
const SAnnotObject_Key & GetAnnotObjectKey(size_t i) const
const TAnnotObjectInfos & GetAnnotObjectInfos(void) const
CRef< CSeq_annot_SNP_Info > m_SNP_Info
const CAnnotObject_Info & GetInfo(TAnnotIndex index) const
CSeq_annot_Info & operator=(const CSeq_annot_Info &)
const TAnnotObjectKeys & GetAnnotObjectKeys(void) const
CSeq_annot_Info(const CSeq_annot_Info &)
bool x_HasSNP_annot_Info(void) const
CRef< TObject > m_Object
CSeq_annot::C_Data C_Data
SAnnotObjectsIndex::TObjectInfos TAnnotObjectInfos
CConstRef< TObject > GetSeq_annotSkeleton(void) const
C_Data::TSeq_table TSeq_table
const TObject & x_GetObject(void) const
map< CSeq_id_Handle, COpenRange< TSeqPos > > TTotalRangesMap
C_Data::TGraph TGraph
CRef< CSeqTableInfo > m_Table_Info
CSeq_annot TObject
C_Data::TAlign TAlign
const CSeqTableInfo & GetTableInfo(void) const
int GetChunkId(void) const
SAnnotObjectsIndex::TObjectKeys TAnnotObjectKeys
C_Data::TLocs TLocs
SAnnotObjectsIndex m_ObjectIndex
C_Data::TFtable TFtable
const CSeq_annot_SNP_Info & x_GetSNP_annot_Info(void) const
CTSE_Info_Object TParent
CRange< TSeqPos > m_RequestRange
CRange< TSeqPos > m_ObjectRange
DECLARE_OPERATOR_BOOL(m_ObjectRow< m_NumRows)
CRef< CSeqTableInfo > m_Table_Info
const CRange< TSeqPos > & GetRange(void) const
size_t GetRow(void) const
CSeq_annot_SortedIter & operator++(void)
void x_DSMapObject(CConstRef< TObject > obj, CDataSource &ds)
void x_DSUnmapObject(CConstRef< TObject > obj, CDataSource &ds)
Definition: Seq_entry.hpp:56
CSeq_feat_Handle –.
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
virtual void x_DoUpdate(TNeedUpdateFlags flags)
virtual void x_DSDetachContents(CDataSource &ds)
virtual void x_TSEAttachContents(CTSE_Info &tse)
virtual void x_DSAttachContents(CDataSource &ds)
virtual void x_TSEDetachContents(CTSE_Info &tse)
virtual string GetDescription(void) const
virtual void x_UpdateAnnotIndexContents(CTSE_Info &tse)
Definition: map.hpp:338
static uch flags
bool NotEmpty(void) const THROWS_NONE
Check if CRef is not empty – pointing to an object and has a non-null value.
Definition: ncbiobj.hpp:726
int32_t Int4
4-byte (32-bit) signed integer
Definition: ncbitype.h:102
#define kMax_I4
Definition: ncbi_limits.h:218
#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
list< CRef< CSeq_graph > > TGraph
Definition: Seq_annot_.hpp:195
list< CRef< CSeq_align > > TAlign
Definition: Seq_annot_.hpp:194
list< CRef< CSeq_loc > > TLocs
Definition: Seq_annot_.hpp:197
list< CRef< CSeq_feat > > TFtable
Definition: Seq_annot_.hpp:193
<!DOCTYPE HTML >< html > n< header > n< title > PubSeq Gateway Help Page</title > n< style > n table
int i
static MDB_envinfo info
Definition: mdb_load.c:37
range(_Ty, _Ty) -> range< _Ty >
const struct ncbi::grid::netcache::search::fields::SIZE size
const struct ncbi::grid::netcache::search::fields::KEY key
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
TObjectInfos & GetInfos(void)
const SAnnotObject_Key & GetKey(size_t i) const
vector< SAnnotObject_Key > TObjectKeys
deque< CAnnotObject_Info > TObjectInfos
const TObjectKeys & GetKeys(void) const
SAnnotSelector –.
#define _ASSERT
Modified on Sun Apr 21 03:39:53 2024 by modify_doxy.py rev. 669887