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

Go to the SVN repository for this file.

1 #ifndef OBJECTS_OBJMGR_IMPL___TSE_INFO__HPP
2 #define OBJECTS_OBJMGR_IMPL___TSE_INFO__HPP
3 
4 /* $Id: tse_info.hpp 99889 2023-05-18 18:05:50Z 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, Eugene Vasilchenko
30 *
31 * File Description:
32 * TSE info -- entry for data source seq-id to TSE map
33 *
34 */
35 
36 
39 #include <objmgr/impl/tse_lock.hpp>
40 
41 #include <objmgr/edit_saver.hpp>
42 #include <objmgr/bioseq_handle.hpp>
43 #include <objmgr/blob_id.hpp>
44 #include <objmgr/bio_object_id.hpp>
46 
47 #include <util/rangemap.hpp>
48 #include <corelib/ncbiobj.hpp>
49 #include <corelib/ncbimtx.hpp>
51 
52 #include <map>
53 #include <set>
54 #include <vector>
55 
58 
59 class CScope_Impl;
60 class CTSE_ScopeInfo;
61 class CBioseq_Info;
62 class CSeq_entry_Info;
63 class CSeq_annot_Info;
64 class CSeq_submit;
65 class CSubmit_block;
67 class CTSE_Chunk_Info;
68 class CTSE_Split_Info;
69 class CTSE_Info_Object;
70 class CTSE_Lock;
71 class CTSE_LoadLock;
72 class CTSE_LoadLockGuard;
73 
74 class CDataSource;
75 class CHandleRange;
76 class CAnnotTypes_CI;
77 class CSeq_entry;
78 
79 class CSeq_literal;
80 class CObject_id;
81 
82 class ITSE_Assigner;
84 class IEditSaver;
85 
86 class CSeq_annot_Finder;
87 class CMasterSeqSegments;
88 
89 ////////////////////////////////////////////////////////////////////
90 //
91 // CTSE_Info::
92 //
93 // General information and indexes for top level seq-entries
94 //
95 
96 
98 {
99  SIdAnnotObjs(void);
100  ~SIdAnnotObjs(void);
101  SIdAnnotObjs(const SIdAnnotObjs& objs);
102 
105  typedef vector<TRangeMap*> TAnnotSet;
106  typedef vector<CConstRef<CSeq_annot_SNP_Info> > TSNPSet;
107 
108  size_t x_GetRangeMapCount(void) const
109  {
110  return m_AnnotSet.size();
111  }
112  bool x_RangeMapIsEmpty(size_t index) const
113  {
114  _ASSERT(index < x_GetRangeMapCount());
115  TRangeMap* slot = m_AnnotSet[index];
116  return !slot || slot->empty();
117  }
118  const TRangeMap& x_GetRangeMap(size_t index) const
119  {
120  _ASSERT(!x_RangeMapIsEmpty(index));
121  return *m_AnnotSet[index];
122  }
123 
124  TRangeMap& x_GetRangeMap(size_t index);
125  bool x_CleanRangeMaps(void);
126 
129 
130 private:
131  const SIdAnnotObjs& operator=(const SIdAnnotObjs& objs);
132 };
133 
134 
136 {
139 
141 };
142 
143 
145 {
146 public:
147  CTSE_SetObjectInfo(void);
148  ~CTSE_SetObjectInfo(void);
149 
152  };
153  // struct SBioseq_Info {
154  // vector<CSeq_id_Handle> m_Removed_ids;
155  // };
158  };
161  // typedef map<CConstRef<CBioseq>, SBioseq_Info> TBioseq_InfoMap;
162 
165  // TBioseq_InfoMap m_Bioseq_InfoMap;
167 
168 private:
171 };
172 
174 
175 
176 class CBioseqUpdater : public CObject {
177 public:
178  virtual void Update(CBioseq_Info& seq) = 0;
179 };
180 
181 
183 {
185 public:
186 /*
187  /// State of bioseq handle (defined in CBioseq_Handle)
188  enum EBlobState {
189  fState_none = 0,
190  fState_suppress_temp = 1 << 0,
191  fState_suppress_perm = 1 << 1,
192  fState_suppress = fState_suppress_temp | fState_suppress_perm,
193  fState_dead = 1 << 2,
194  fState_confidential = 1 << 3,
195  fState_withdrawn = 1 << 4,
196  fState_no_data = 1 << 5,
197  fState_conflict = 1 << 6,
198  fState_conn_failed = 1 << 7,
199  fState_other_error = 1 << 8
200  };
201  /// Type of top level object added to scope (defined in CTSE_Handle)
202  enum ETopLevelObjectType {
203  eTopLevelSeq_entry,
204  eTopLevelBioseq_set,
205  eTopLevelBioseq,
206  eTopLevelSeq_annot,
207  eTopLevelSeq_submit
208  };
209 */
212  typedef int TBlobVersion;
213  typedef pair<TBlobState, TBlobVersion> TBlobOrder;
215 
216  // 'ctors
217  // Argument tse will be parentized.
218  explicit CTSE_Info(void);
219  explicit CTSE_Info(const TBlobId& blob_id,
220  TBlobVersion blob_version = -1);
221  explicit CTSE_Info(CSeq_entry& tse,
223  explicit CTSE_Info(CSeq_entry& tse,
224  TBlobState blob_state,
225  const TBlobId& blob_id,
226  TBlobVersion blob_version = -1);
227  explicit CTSE_Info(const CTSE_Lock& tse);
228  virtual ~CTSE_Info(void);
229 
230  bool HasDataSource(void) const;
231  CDataSource& GetDataSource(void) const;
232 
233  bool IsLocked(void) const;
234 
235  CConstRef<CSeq_entry> GetCompleteTSE(void) const;
236  CConstRef<CSeq_entry> GetTSECore(void) const;
237 
238  const CTSE_Info& GetTSE_Info(void) const;
239  CTSE_Info& GetTSE_Info(void);
240 
241  CTSE_Info& Assign(const CTSE_Lock& tse);
242  CTSE_Info& Assign(const CTSE_Lock& tse,
243  CRef<CSeq_entry> entry);
244 
245  // Additional TSE info not available in CSeq_entry
246  const TBlobId& GetBlobId(void) const;
247  TBlobVersion GetBlobVersion(void) const;
248  void SetBlobVersion(TBlobVersion version);
249 
250  TBlobState GetBlobState(void) const;
251  void ResetBlobState(TBlobState state = CBioseq_Handle::fState_none);
252  void SetBlobState(TBlobState state);
253  bool IsDead(void) const;
254  bool IsUnavailable(void) const;
255 
256  // return bits used to determine best TSE, less is better
257  TBlobState GetBlobStateOrder(void) const;
258 
259  // return full blob order object, less is better
260  TBlobOrder GetBlobOrder(void) const;
261 
262  // return initial top-level object type
263  ETopLevelObjectType GetTopLevelObjectType() const;
264  const CSerialObject* GetTopLevelObjectPtr() const;
265  void SetTopLevelObject(ETopLevelObjectType type, CSerialObject* ptr);
266  void SetTopLevelObjectType(ETopLevelObjectType type);
267 
268  // Seq-submit support:
269  // return full Seq-submit object, may require to update entry/annot list
270  bool IsTopLevelSeq_submit() const;
271  const CSeq_submit& GetTopLevelSeq_submit() const;
272  // More efficient Seq-submit.sub access
273  const CSubmit_block& GetTopLevelSubmit_block() const;
274  CSubmit_block& SetTopLevelSubmit_block() const;
275  void SetTopLevelSubmit_block(CSubmit_block& sub) const;
276 
277  const CAnnotName& GetName(void) const;
278  void SetName(const CAnnotName& name);
279 
280  void SetSeq_entry(CSeq_entry& entry, CTSE_SetObjectInfo* set_info = 0);
281 
282  size_t GetUsedMemory(void) const;
283  void SetUsedMemory(size_t size);
284  void AddUsedMemory(size_t size);
285 
286  // Annot index access
287  bool HasAnnot(const CAnnotName& name) const;
288  bool HasUnnamedAnnot(void) const;
289  bool HasNamedAnnot(const string& name) const;
290 
291  // Check types of IDs used in the annotations
292  bool HasMatchingAnnotIds(void) const;
293  bool OnlyGiAnnotIds(void) const;
294 
295  // indexes types
299 
304 
309  {
311  bool m_Orphan;
312  };
314 
315  struct SFeatIdInfo
316  {
318  : m_Type(type), m_IsChunk(false)
319  {
320  m_Info = info;
321  }
323  : m_Type(type), m_IsChunk(true)
324  {
325  m_ChunkId = chunk_id;
326  }
327 
329  bool m_IsChunk;
330  union {
333  };
334  };
335  typedef int TFeatIdInt;
336  typedef string TFeatIdStr;
339  {
342 
346  };
348  typedef pair<string, bool> TLocusKey;
350 
351  typedef vector<CSeq_id_Handle> TSeqIds;
353 
354  // find bioseq with exactly the same id
355  bool ContainsBioseq(const CSeq_id_Handle& id) const;
356  CConstRef<CBioseq_Info> FindBioseq(const CSeq_id_Handle& id) const;
357 
358  // find bioseq with matching id
359  // returns matching Seq-id handle
360  CSeq_id_Handle ContainsMatchingBioseq(const CSeq_id_Handle& id) const;
361  CConstRef<CBioseq_Info> FindMatchingBioseq(const CSeq_id_Handle& id) const;
362  SSeqMatch_TSE GetSeqMatch(const CSeq_id_Handle& id) const;
363 
364  CConstRef<CBioseq_Info> GetSegSetMaster(void) const;
365  CConstRef<CMasterSeqSegments> GetMasterSeqSegments(void) const;
366 
367  // fill ids with all Bioseqs Seq-ids from this TSE
368  // the result will be sorted and contain no duplicates
369  virtual void GetBioseqsIds(TSeqIds& ids) const;
370  // fill ids with all Annot Seq-ids from this TSE
371  // the result will be sorted and contain no duplicates
372  virtual void GetAnnotIds(TSeqIds& ids) const;
373 
374  // patch loaded CBioseq objects now, and split CBioseq objects when loaded
375  void SetBioseqUpdater(CRef<CBioseqUpdater> updater);
376 
377  void UpdateAnnotIndex(const CSeq_id_Handle& id) const;
378  void UpdateAnnotIndex(void) const;
379  void UpdateAnnotIndex(const CTSE_Info_Object& object) const;
380  void UpdateAnnotIndex(void);
381  void UpdateAnnotIndex(CTSE_Info_Object& object);
382  void UpdateFeatIdIndex(CSeqFeatData::E_Choice type,
383  EFeatIdType id_type) const;
384  void UpdateFeatIdIndex(CSeqFeatData::ESubtype subtype,
385  EFeatIdType id_type) const;
386 
387  void x_UpdateAnnotIndexContents(CTSE_Info& tse);
388 
389  void x_DSAttachContents(CDataSource& ds);
390  void x_DSDetachContents(CDataSource& ds);
391 
392  virtual void x_SetDirtyAnnotIndexNoParent(void);
393  virtual void x_ResetDirtyAnnotIndexNoParent(void);
394 
395  void x_GetRecords(const CSeq_id_Handle& id, bool bioseq) const;
396  void x_LoadChunk(TChunkId chunk_id) const;
397  void x_LoadChunks(const TChunkIds& chunk_ids) const;
398 
399  CTSE_Split_Info& GetSplitInfo(void);
400  const CTSE_Split_Info& GetSplitInfo(void) const;
401  bool HasSplitInfo(void) const;
402  bool x_NeedsDelayedMainChunk(void) const;
403  void x_LoadDelayedMainChunk(void) const;
404 
405  const CSeq_id_Handle& GetRequestedId(void) const;
406  void SetRequestedId(const CSeq_id_Handle& requested_id) const;
407 
408  // annot object map mutex
412  TAnnotLock& GetAnnotLock(void) const;
413 
415 
416  CBioseq_set_Info& x_GetBioseq_set(int id);
417  CBioseq_Info& x_GetBioseq(const CSeq_id_Handle& id);
418 
419  CTSE_Info_Object* x_FindBioObject(const CBioObjectId& uniq_id) const;
420 
423 
424  bool x_HasFeaturesWithId(CSeqFeatData::ESubtype subtype) const;
425 
426  typedef vector<CAnnotObject_Info*> TAnnotObjects;
427  void x_AddFeaturesById(TAnnotObjects& objects,
428  const SFeatIdIndex& index,
429  TFeatIdInt id,
430  EFeatIdType id_type,
431  const CSeq_annot_Info* src_annot = 0) const;
432  void x_AddFeaturesById(TAnnotObjects& objects,
433  CSeqFeatData::ESubtype subtype,
434  TFeatIdInt id,
435  EFeatIdType id_type,
436  const CSeq_annot_Info* src_annot = 0) const;
437  void x_AddAllFeaturesById(TAnnotObjects& objects,
438  TFeatIdInt id,
439  EFeatIdType id_type,
440  const CSeq_annot_Info* src_annot = 0) const;
441  TAnnotObjects x_GetFeaturesById(CSeqFeatData::E_Choice type,
442  TFeatIdInt id,
443  EFeatIdType id_type,
444  const CSeq_annot_Info* src_annot = 0) const;
445  TAnnotObjects x_GetFeaturesById(CSeqFeatData::ESubtype subtype,
446  TFeatIdInt id,
447  EFeatIdType id_type,
448  const CSeq_annot_Info* src_annot = 0) const;
449  void x_AddFeaturesById(TAnnotObjects& objects,
450  const SFeatIdIndex& index,
451  const TFeatIdStr& id,
452  EFeatIdType id_type,
453  const CSeq_annot_Info* src_annot = 0) const;
454  void x_AddFeaturesById(TAnnotObjects& objects,
455  CSeqFeatData::ESubtype subtype,
456  const TFeatIdStr& id,
457  EFeatIdType id_type,
458  const CSeq_annot_Info* src_annot = 0) const;
459  void x_AddAllFeaturesById(TAnnotObjects& objects,
460  const TFeatIdStr& id,
461  EFeatIdType id_type,
462  const CSeq_annot_Info* src_annot = 0) const;
463  TAnnotObjects x_GetFeaturesById(CSeqFeatData::E_Choice type,
464  const TFeatIdStr& id,
465  EFeatIdType id_type,
466  const CSeq_annot_Info* src_annot = 0) const;
467  TAnnotObjects x_GetFeaturesById(CSeqFeatData::ESubtype subtype,
468  const TFeatIdStr& id,
469  EFeatIdType id_type,
470  const CSeq_annot_Info* src_annot = 0) const;
471  TAnnotObjects x_GetFeaturesById(CSeqFeatData::E_Choice type,
472  const TFeatId& id,
473  EFeatIdType id_type,
474  const CSeq_annot_Info* src_annot = 0) const;
475  TAnnotObjects x_GetFeaturesById(CSeqFeatData::ESubtype subtype,
476  const TFeatId& id,
477  EFeatIdType id_type,
478  const CSeq_annot_Info* src_annot = 0) const;
479  TAnnotObjects x_GetFeaturesByLocus(const string& locus,
480  bool tag,
481  const CSeq_annot_Info* src_annot = 0) const;
482 
483  typedef pair<CConstRef<CSeq_annot_Info>, CTSE_Lock> TSeq_annot_Lock;
484  typedef pair<TSeq_annot_Lock, int> TSeq_feat_Lock;
485  TSeq_feat_Lock x_FindSeq_feat(const CSeq_id_Handle& loc_id,
486  TSeqPos loc_pos,
487  const CSeq_feat& feat) const;
488 
489  virtual string GetDescription(void) const;
490 
491  CSeq_submit& x_GetTopLevelSeq_submit() const;
492 
493 private:
494  friend class CTSE_Guard;
495  friend class CDataSource;
496  friend class CScope_Impl;
497  friend class CTSE_ScopeInfo;
498  friend class CDataLoader;
499  friend class CAnnot_Collector;
500  friend class CSeq_entry_Info;
501  friend class CSeq_annot_Info;
502  friend class CBioseq_Info;
503  friend class CBioseq_set_Info;
504  friend class CTSE_Info_Object;
505  friend class CTSE_Chunk_Info;
506  friend class CTSE_Split_Info;
507  friend class CSeq_annot_SNP_Info;
508 
509  friend class ITSE_Assigner;
510  friend class CTSE_Default_Assigner;
511  friend class CSeq_annot_Finder;
512 
513 
514  void x_Initialize(void);
515  void x_Reset(void); // can be called after incomplete loading
516 
517  void x_DSMapObject(CConstRef<TObject> obj, CDataSource& ds);
518  void x_DSUnmapObject(CConstRef<TObject> obj, CDataSource& ds);
519 
520  void x_SetBioseqId(const CSeq_id_Handle& id, CBioseq_Info* info);
521  void x_SetBioseqIds(CBioseq_Info* info);
522  void x_ResetBioseqId(const CSeq_id_Handle& id, CBioseq_Info* info);
523 
524  void x_SetBioseq_setId(int key, CBioseq_set_Info* info);
525  void x_ResetBioseq_setId(int key, CBioseq_set_Info* info);
526 
527  // index access methods
528  TAnnotObjs& x_SetAnnotObjs(const CAnnotName& name);
529  const TAnnotObjs* x_GetAnnotObjs(const CAnnotName& name) const;
530  const TAnnotObjs* x_GetUnnamedAnnotObjs(void) const;
531  void x_RemoveAnnotObjs(const CAnnotName& name);
532  const SIdAnnotObjs* x_GetIdObjects(const TAnnotObjs& objs,
533  const CSeq_id_Handle& idh) const;
534  const SIdAnnotObjs* x_GetIdObjects(const CAnnotName& name,
535  const CSeq_id_Handle& id) const;
536  const SIdAnnotObjs* x_GetUnnamedIdObjects(const CSeq_id_Handle& id) const;
537 
538  // tse annot index should be locked by TAnnotLockReadGuard
539  bool x_HasIdObjects(const CSeq_id_Handle& id) const;
540 
541  // return true in 'second' if new CSeq_id may appear in TSE annot index
542  pair<SIdAnnotObjs*, bool> x_SetIdObjects(TAnnotObjs& objs,
543  const CAnnotName& name,
544  const CSeq_id_Handle& id);
545  pair<SIdAnnotObjs*, bool> x_SetIdObjects(const CAnnotName& name,
546  const CSeq_id_Handle& idh);
547 
548  CRef<CSeq_annot_SNP_Info> x_GetSNP_Info(const CConstRef<CSeq_annot>& annot);
549 
550  // return true if new CSeq_id may appear in TSE annot index
551  bool x_MapSNP_Table(const CAnnotName& name,
552  const CSeq_id_Handle& key,
553  const CSeq_annot_SNP_Info& snp_info);
554  void x_UnmapSNP_Table(const CAnnotName& name,
555  const CSeq_id_Handle& key,
556  const CSeq_annot_SNP_Info& snp_info);
557 
558  void x_MapAnnotObject(TRangeMap& rangeMap,
559  const SAnnotObject_Key& key,
560  const SAnnotObject_Index& index);
561  bool x_UnmapAnnotObject(TRangeMap& rangeMap,
562  const CAnnotObject_Info& info,
563  const SAnnotObject_Key& key);
564  void x_MapAnnotObject(SIdAnnotObjs& objs,
565  const SAnnotObject_Key& key,
566  const SAnnotObject_Index& index);
567  bool x_UnmapAnnotObject(SIdAnnotObjs& objs,
568  const CAnnotObject_Info& info,
569  const SAnnotObject_Key& key);
570  // return true if new CSeq_id may appear in TSE annot index
571  bool x_MapAnnotObject(TAnnotObjs& objs,
572  const CAnnotName& name,
573  const SAnnotObject_Key& key,
574  const SAnnotObject_Index& index);
575  // return true if new CSeq_id may appear in TSE annot index
576  bool x_MapAnnotObject(const CAnnotName& name,
577  const SAnnotObject_Key& key,
578  const SAnnotObject_Index& index);
579 
580  bool x_UnmapAnnotObject(TAnnotObjs& objs,
581  const CAnnotName& name,
582  const CAnnotObject_Info& info,
583  const SAnnotObject_Key& key);
584  void x_UnmapAnnotObject(const CAnnotName& name,
585  const CAnnotObject_Info& info,
586  const SAnnotObject_Key& key);
587  void x_UnmapAnnotObjects(const SAnnotObjectsIndex& infos);
588 
589  void x_MapFeatById(TFeatIdInt id,
591  EFeatIdType type);
592  void x_UnmapFeatById(TFeatIdInt id,
594  EFeatIdType type);
595  void x_MapFeatById(const TFeatIdStr& id,
597  EFeatIdType type);
598  void x_UnmapFeatById(const TFeatIdStr& id,
600  EFeatIdType type);
601  void x_MapFeatById(const TFeatId& id,
603  EFeatIdType type);
604  void x_UnmapFeatById(const TFeatId& id,
606  EFeatIdType type);
607  void x_MapFeatByLocus(const string& locus, bool tag,
609  void x_UnmapFeatByLocus(const string& locus, bool tag,
611 
612  void x_MapChunkByFeatType(CSeqFeatData::ESubtype subtype,
613  TChunkId chunk_id);
614  void x_MapChunkByFeatType(CSeqFeatData::E_Choice type,
615  TChunkId chunk_id);
616  void x_MapChunkByFeatType(const SAnnotTypeSelector& type,
617  TChunkId chunk_id);
618 
619  void x_MapChunkByFeatId(TFeatIdInt id,
620  CSeqFeatData::ESubtype subtype,
621  TChunkId chunk_id,
622  EFeatIdType type);
623  void x_MapChunkByFeatId(TFeatIdInt id,
625  TChunkId chunk_id,
626  EFeatIdType id_type);
627  void x_MapChunkByFeatId(TFeatIdInt id,
628  const SAnnotTypeSelector& type,
629  TChunkId chunk_id,
630  EFeatIdType id_type);
631  void x_MapChunkByFeatId(const TFeatIdStr& id,
632  CSeqFeatData::ESubtype subtype,
633  TChunkId chunk_id,
634  EFeatIdType id_type);
635  void x_MapChunkByFeatId(const TFeatIdStr& id,
637  TChunkId chunk_id,
638  EFeatIdType id_type);
639  void x_MapChunkByFeatId(const TFeatIdStr& id,
640  const SAnnotTypeSelector& type,
641  TChunkId chunk_id,
642  EFeatIdType id_type);
643  void x_MapChunkByFeatId(const TFeatId& id,
644  CSeqFeatData::ESubtype subtype,
645  TChunkId chunk_id,
646  EFeatIdType id_type);
647  void x_MapChunkByFeatId(const TFeatId& id,
649  TChunkId chunk_id,
650  EFeatIdType id_type);
651  void x_MapChunkByFeatId(const TFeatId& id,
652  const SAnnotTypeSelector& type,
653  TChunkId chunk_id,
654  EFeatIdType id_type);
655 
656  friend class CTSEAnnotObjectMapper;
657 
658  void x_IndexSeqTSE(const CSeq_id_Handle& id);
659  void x_UnindexSeqTSE(const CSeq_id_Handle& id);
660  // return true if new CSeq_id may appear in TSE annot index
661  bool x_IndexAnnotTSE(const CAnnotName& name, const CSeq_id_Handle& id);
662  void x_UnindexAnnotTSE(const CAnnotName& name, const CSeq_id_Handle& id);
663 
664  void x_DoUpdate(TNeedUpdateFlags flags);
665 
666  //void x_RegisterRemovedIds(const CConstRef<CBioseq>&, CBioseq_Info*);
667  CBioObjectId x_IndexBioseq(CBioseq_Info*);
668  CBioObjectId x_IndexBioseq_set(CBioseq_set_Info*);
669 
670  CBioObjectId x_RegisterBioObject(CTSE_Info_Object& info);
671  void x_UnregisterBioObject(CTSE_Info_Object& info);
672 
673  friend class CTSE_Lock;
674  friend class CTSE_LoadLock;
675  friend class CTSE_LoadLockGuard;
676 
677  // Owner data-source
679 
680  //////////////////////////////////////////////////////////////////
681  // TSE information in addition to CSeq_entry
682 
683  // Unique blob-id within data-source and corresponding data-loader
686 
687  // Suppression level
689 
690  // Initial top-level objects type
693 
694  // TSE has name
696 
697  // estimations of memory useage, 0 - means unknown
698  size_t m_UsedMemory;
699 
700  //////////////////////////////////////////////////////////////////
701  // Runtime state within object manager
702 
703  enum ELoadState {
706  eDropped
707  };
708  enum ECacheState {
710  eInCache
711  };
712  atomic<ELoadState> m_LoadState;
714 
715  typedef list< CRef<CTSE_Info> > TTSE_Cache;
716  mutable TTSE_Cache::iterator m_CachePosition;
717 
718  // lock counter for garbage collector
720 
721  class CLoadMutex : public CObject, public CMutex
722  {
723  public:
725  };
726 
728 
729  // ID to bioseq-info
735 
736  // Split chunks
738 
739  // SNP info set: temporarily used in SetSeq_entry()
741 
742  // Annot objects maps: ID to annot-selector-map
747 
750 
752  fAnnotIds_NonGi = 1 << 0, // Have annots with non-gi ids
753  fAnnotIds_Matching = 1 << 1 // Have annots with multiple matching ids
754  };
755  typedef int TAnnotIdsFlags;
756 
757  // Do not use ID matching for annotations
759 
760  // information about original TSE for its copy
761  struct SBaseTSE
762  {
763  SBaseTSE(const CTSE_Lock& tse)
764  : m_BaseTSE(tse)
765  {
766  }
767 
770  };
771  unique_ptr<SBaseTSE> m_BaseTSE;
772 
777 
780 
782 
783 private:
784  // Hide copy methods
786  CTSE_Info& operator= (const CTSE_Info&);
787 };
788 
789 
790 
791 /////////////////////////////////////////////////////////////////////
792 //
793 // Inline methods
794 //
795 /////////////////////////////////////////////////////////////////////
796 
797 inline
798 bool CTSE_Info::HasDataSource(void) const
799 {
800  return m_DataSource != 0;
801 }
802 
803 
804 inline
806 {
808  return *m_DataSource;
809 }
810 
811 
812 inline
813 bool CTSE_Info::IsLocked(void) const
814 {
815  return m_LockCounter.Get() != 0;
816 }
817 
818 
819 inline
821 {
822  return *this;
823 }
824 
825 
826 inline
828 {
829  return *this;
830 }
831 
832 
833 inline
835 {
836  return m_BlobState;
837 }
838 
839 
840 inline
842 {
843  m_BlobState = state;
844 }
845 
846 
847 inline
849 {
850  m_BlobState |= state;
851 }
852 
853 
854 inline
855 bool CTSE_Info::IsDead(void) const
856 {
858 }
859 
860 
861 inline
862 bool CTSE_Info::IsUnavailable(void) const
863 {
865 }
866 
867 
868 inline
870 {
873 }
874 
875 
876 inline
878 {
879  return m_BlobVersion;
880 }
881 
882 
883 inline
885 {
886  // less blob state order first,
887  // higher blob version second
889 }
890 
891 
892 inline
893 const CAnnotName& CTSE_Info::GetName(void) const
894 {
895  return m_Name;
896 }
897 
898 
899 inline
900 size_t CTSE_Info::GetUsedMemory(void) const
901 {
902  return m_UsedMemory;
903 }
904 
905 
906 inline
908 {
909  return m_BlobId;
910 }
911 
912 
913 inline
915 {
916  return m_AnnotLock;
917 }
918 
919 
920 inline
922 {
923  return m_RequestedId;
924 }
925 
926 
927 inline
928 void CTSE_Info::SetRequestedId(const CSeq_id_Handle& requested_id) const
929 {
930  m_RequestedId = requested_id;
931 }
932 
933 
934 inline
936 {
937  return (m_AnnotIdsFlags & fAnnotIds_Matching) != 0;
938 }
939 
940 
941 inline
943 {
944  return (m_AnnotIdsFlags & fAnnotIds_NonGi) == 0;
945 }
946 
947 
948 inline
950 {
951  return m_EditSaver;
952 }
953 
954 
956 {
957 public:
959  : m_TSE(tse), m_Name(name),
960  m_AnnotObjs(tse.x_SetAnnotObjs(name))
961  {
962  }
963 
964  // return true if new CSeq_id may appear in TSE annot index
965  bool Map(const SAnnotObject_Key& key,
966  const SAnnotObject_Index& index) const
967  {
968  return m_TSE.x_MapAnnotObject(m_AnnotObjs, m_Name, key, index);
969  }
970 
972  const CAnnotObject_Info& info) const
973  {
975  if ( m_AnnotObjs.empty() ) {
977  }
978  }
979 
980 private:
984 };
985 
986 
989 
990 #endif /* OBJECTS_OBJMGR_IMPL___TSE_INFO__HPP */
AutoPtr –.
Definition: ncbimisc.hpp:401
CAtomicCounter_WithAutoInit –.
Definition: ncbicntr.hpp:120
virtual void Update(CBioseq_Info &seq)=0
CFastMutex –.
Definition: ncbimtx.hpp:667
CMutex –.
Definition: ncbimtx.hpp:749
CObject –.
Definition: ncbiobj.hpp:180
vector< CSeq_id_Handle > TSeqIds
Definition: Seq_entry.hpp:56
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
Base class for all serializable objects.
Definition: serialbase.hpp:150
CSubmit_block –.
const CAnnotName & m_Name
Definition: tse_info.hpp:982
void Unmap(const SAnnotObject_Key &key, const CAnnotObject_Info &info) const
Definition: tse_info.hpp:971
bool Map(const SAnnotObject_Key &key, const SAnnotObject_Index &index) const
Definition: tse_info.hpp:965
CTSE_Info::TAnnotObjs & m_AnnotObjs
Definition: tse_info.hpp:983
CTSEAnnotObjectMapper(CTSE_Info &tse, const CAnnotName &name)
Definition: tse_info.hpp:958
ETopLevelObjectType
Type of top level object added to scope.
Definition: tse_handle.hpp:127
CConditionVariable m_LoadWait
Definition: tse_info.hpp:724
vector< TChunkId > TChunkIds
TBioseq_sets m_Bioseq_sets
Definition: tse_info.hpp:730
TBlobVersion GetBlobVersion(void) const
Definition: tse_info.hpp:877
TBioObjects m_BioObjects
Definition: tse_info.hpp:776
TNamedAnnotObjs m_NamedAnnotObjs
Definition: tse_info.hpp:743
TTSE_Cache::iterator m_CachePosition
Definition: tse_info.hpp:716
bool IsUnavailable(void) const
Definition: tse_info.hpp:862
CRef< CTSE_Split_Info > m_Split
Definition: tse_info.hpp:737
TBlobOrder GetBlobOrder(void) const
Definition: tse_info.hpp:884
CAtomicCounter_WithAutoInit m_LockCounter
Definition: tse_info.hpp:719
CSeq_id_Handle m_RequestedId
Definition: tse_info.hpp:749
CAnnotName m_Name
Definition: tse_info.hpp:695
size_t GetUsedMemory(void) const
Definition: tse_info.hpp:900
CDataSource & GetDataSource(void) const
Definition: tse_info.hpp:805
map< CSeq_id_Handle, SIdAnnotInfo > TIdAnnotInfoMap
Definition: tse_info.hpp:313
SIdAnnotObjs::TRange TRange
Definition: tse_info.hpp:300
pair< TBlobState, TBlobVersion > TBlobOrder
Definition: tse_info.hpp:213
int TFeatIdInt
Definition: tse_info.hpp:335
TBioseqs m_Removed_Bioseqs
Definition: tse_info.hpp:733
set< CAnnotName > TNames
Definition: tse_info.hpp:307
TBlobVersion m_BlobVersion
Definition: tse_info.hpp:685
CBioseq_Info * TBioseqInfo
Definition: tse_info.hpp:297
int TBlobVersion
Definition: tse_info.hpp:212
TBlobState GetBlobState(void) const
Definition: tse_info.hpp:834
@ fAnnotIds_NonGi
Definition: tse_info.hpp:752
@ fAnnotIds_Matching
Definition: tse_info.hpp:753
bool OnlyGiAnnotIds(void) const
Definition: tse_info.hpp:942
TLocusIndex m_LocusIndex
Definition: tse_info.hpp:746
vector< CAnnotObject_Info * > TAnnotObjects
Definition: tse_info.hpp:426
CRef< CSerialObject > m_TopLevelObjectPtr
Definition: tse_info.hpp:692
CTSE_Info(const CTSE_Info &)
void x_RemoveAnnotObjs(const CAnnotName &name)
Definition: tse_info.cpp:1080
SIdAnnotObjs::TRangeMap TRangeMap
Definition: tse_info.hpp:301
void SetBlobState(TBlobState state)
Definition: tse_info.hpp:848
multimap< TLocusKey, CAnnotObject_Info * > TLocusIndex
Definition: tse_info.hpp:349
string TFeatIdStr
Definition: tse_info.hpp:336
TAnnotLock::TWriteLockGuard TAnnotLockWriteGuard
Definition: tse_info.hpp:411
bool IsLocked(void) const
Definition: tse_info.hpp:813
unique_ptr< SBaseTSE > m_BaseTSE
Definition: tse_info.hpp:771
TBlobState GetBlobStateOrder(void) const
Definition: tse_info.hpp:869
TAnnotLock::TReadLockGuard TAnnotLockReadGuard
Definition: tse_info.hpp:410
pair< CConstRef< CSeq_annot_Info >, CTSE_Lock > TSeq_annot_Lock
Definition: tse_info.hpp:483
CMutex TAnnotLock
Definition: tse_info.hpp:409
TBlobId m_BlobId
Definition: tse_info.hpp:684
TBlobState m_BlobState
Definition: tse_info.hpp:688
TAnnotLock m_AnnotLock
Definition: tse_info.hpp:748
CBioseq_Handle::TBioseqStateFlags TBlobState
Definition: tse_info.hpp:211
CRef< CBioseqUpdater > m_BioseqUpdater
Definition: tse_info.hpp:781
map< CBioObjectId, CTSE_Info_Object * > TBioObjects
Definition: tse_info.hpp:775
CRef< CTSE_SetObjectInfo > m_SetObjectInfo
Definition: tse_info.hpp:740
TBioseqs m_Bioseqs
Definition: tse_info.hpp:731
SIdAnnotObjs::TSNPSet TSNPSet
Definition: tse_info.hpp:303
const TBlobId & GetBlobId(void) const
Definition: tse_info.hpp:907
bool m_MasterSeqSegmentsLoaded
Definition: tse_info.hpp:778
ETopLevelObjectType m_TopLevelObjectType
Definition: tse_info.hpp:691
list< CRef< CTSE_Info > > TTSE_Cache
Definition: tse_info.hpp:715
bool HasMatchingAnnotIds(void) const
Definition: tse_info.hpp:935
map< CSeqFeatData::ESubtype, SFeatIdIndex > TFeatIdIndex
Definition: tse_info.hpp:347
TAnnotLock & GetAnnotLock(void) const
Definition: tse_info.hpp:914
map< CSeq_id_Handle, TBioseqInfo > TBioseqs
Definition: tse_info.hpp:298
map< CAnnotName, TAnnotObjs > TNamedAnnotObjs
Definition: tse_info.hpp:306
atomic< ELoadState > m_LoadState
Definition: tse_info.hpp:712
bool HasDataSource(void) const
Definition: tse_info.hpp:798
TBioseq_sets m_Removed_Bioseq_sets
Definition: tse_info.hpp:732
TFeatIdIndex m_FeatIdIndex
Definition: tse_info.hpp:745
int m_InternalBioObjNumber
Definition: tse_info.hpp:774
vector< CSeq_id_Handle > TSeqIds
Definition: tse_info.hpp:351
const CAnnotName & GetName(void) const
Definition: tse_info.hpp:893
ECacheState m_CacheState
Definition: tse_info.hpp:713
CRef< CLoadMutex > m_LoadMutex
Definition: tse_info.hpp:727
TIdAnnotInfoMap m_IdAnnotInfoMap
Definition: tse_info.hpp:744
void ResetBlobState(TBlobState state=CBioseq_Handle::fState_none)
Definition: tse_info.hpp:841
CFastMutex m_BioseqsMutex
Definition: tse_info.hpp:734
CRef< IEditSaver > m_EditSaver
Definition: tse_info.hpp:773
int TAnnotIdsFlags
Definition: tse_info.hpp:755
CDataSource * m_DataSource
Definition: tse_info.hpp:678
size_t m_UsedMemory
Definition: tse_info.hpp:698
CObject_id TFeatId
Definition: tse_info.hpp:337
pair< string, bool > TLocusKey
Definition: tse_info.hpp:348
TAnnotIdsFlags m_AnnotIdsFlags
Definition: tse_info.hpp:758
CRef< IEditSaver > GetEditSaver() const
Definition: tse_info.hpp:949
pair< TSeq_annot_Lock, int > TSeq_feat_Lock
Definition: tse_info.hpp:484
const CTSE_Info & GetTSE_Info(void) const
Definition: tse_info.hpp:820
map< TIntId, CBioseq_set_Info * > TBioseq_sets
Definition: tse_info.hpp:296
CConstRef< CMasterSeqSegments > m_MasterSeqSegments
Definition: tse_info.hpp:779
const CSeq_id_Handle & GetRequestedId(void) const
Definition: tse_info.hpp:921
void x_MapAnnotObject(TRangeMap &rangeMap, const SAnnotObject_Key &key, const SAnnotObject_Index &index)
Definition: tse_info.cpp:1180
CSeq_entry_Info TParent
Definition: tse_info.hpp:184
CTSE_Handle::ETopLevelObjectType ETopLevelObjectType
Definition: tse_info.hpp:214
bool x_UnmapAnnotObject(TRangeMap &rangeMap, const CAnnotObject_Info &info, const SAnnotObject_Key &key)
Definition: tse_info.cpp:1190
SIdAnnotObjs::TAnnotSet TAnnotSet
Definition: tse_info.hpp:302
bool IsDead(void) const
Definition: tse_info.hpp:855
CBlobIdKey TBlobId
Definition: tse_info.hpp:210
void SetRequestedId(const CSeq_id_Handle &requested_id) const
Definition: tse_info.hpp:928
TSeqIds TBioseqsIds
Definition: tse_info.hpp:352
map< CSeq_id_Handle, SIdAnnotObjs > TAnnotObjs
Definition: tse_info.hpp:305
CTSE_SetObjectInfo(const CTSE_SetObjectInfo &)
TSeq_annot_InfoMap m_Seq_annot_InfoMap
Definition: tse_info.hpp:163
TBioseq_set_InfoMap m_Bioseq_set_InfoMap
Definition: tse_info.hpp:164
map< CConstRef< CBioseq_set >, SBioseq_set_Info > TBioseq_set_InfoMap
Definition: tse_info.hpp:160
CRef< CSeq_entry > m_TSE
Definition: tse_info.hpp:166
map< CConstRef< CSeq_annot >, SSeq_annot_Info > TSeq_annot_InfoMap
Definition: tse_info.hpp:159
void operator=(const CTSE_SetObjectInfo &)
Edit Saver Interface.
Definition: edit_saver.hpp:72
bool empty() const
Definition: map.hpp:149
Definition: map.hpp:338
static uch flags
IEditSaver * GetEditSaver(const Handle &handle)
#define true
Definition: bool.h:35
#define false
Definition: bool.h:36
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
TValue Get(void) const THROWS_NONE
Get atomic counter value.
Definition: ncbicntr.hpp:168
int8_t Int1
1-byte (8-bit) signed integer
Definition: ncbitype.h:98
bool empty(void) const
Definition: rangemap.hpp:428
#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
E_Choice
Choice variants.
static MDB_envinfo info
Definition: mdb_load.c:37
const string version
version string
Definition: variables.hpp:66
const struct ncbi::grid::netcache::search::fields::SIZE size
const struct ncbi::grid::netcache::search::fields::KEY key
const char * tag
Multi-threading – mutexes; rw-locks; semaphore.
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
SBaseTSE(const CTSE_Lock &tse)
Definition: tse_info.hpp:763
TObjectCopyMap m_ObjectCopyMap
Definition: tse_info.hpp:769
CTSE_Lock m_BaseTSE
Definition: tse_info.hpp:768
multimap< TFeatIdStr, SFeatIdInfo > TIndexStr
Definition: tse_info.hpp:341
AutoPtr< TIndexInt > m_IndexInt
Definition: tse_info.hpp:344
multimap< TFeatIdInt, SFeatIdInfo > TIndexInt
Definition: tse_info.hpp:340
AutoPtr< TIndexStr > m_IndexStr
Definition: tse_info.hpp:345
SFeatIdInfo(EFeatIdType type, CAnnotObject_Info *info)
Definition: tse_info.hpp:317
SFeatIdInfo(EFeatIdType type, TChunkId chunk_id)
Definition: tse_info.hpp:322
CAnnotObject_Info * m_Info
Definition: tse_info.hpp:331
CRef< CSeq_annot_SNP_Info > m_SNP_annot_Info
Definition: tse_info.hpp:151
const TRangeMap & x_GetRangeMap(size_t index) const
Definition: tse_info.hpp:118
TSNPSet m_SNPSet
Definition: tse_info.hpp:128
vector< CConstRef< CSeq_annot_SNP_Info > > TSNPSet
Definition: tse_info.hpp:106
TAnnotSet m_AnnotSet
Definition: tse_info.hpp:127
vector< TRangeMap * > TAnnotSet
Definition: tse_info.hpp:105
bool x_RangeMapIsEmpty(size_t index) const
Definition: tse_info.hpp:112
const SIdAnnotObjs & operator=(const SIdAnnotObjs &objs)
CRangeMultimap< SAnnotObject_Index, TSeqPos > TRangeMap
Definition: tse_info.hpp:104
size_t x_GetRangeMapCount(void) const
Definition: tse_info.hpp:108
CRange< TSeqPos > TRange
Definition: tse_info.hpp:103
DECLARE_OPERATOR_BOOL_REF(m_Bioseq)
CConstRef< CBioseq_Info > m_Bioseq
Definition: tse_info.hpp:138
CSeq_id_Handle m_Seq_id
Definition: tse_info.hpp:137
Definition: type.c:6
#define _ASSERT
Modified on Wed Sep 04 15:02:57 2024 by modify_doxy.py rev. 669887