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

Go to the SVN repository for this file.

1 #ifndef OBJMGR_SCOPE__HPP
2 #define OBJMGR_SCOPE__HPP
3 
4 /* $Id: scope.hpp 101834 2024-02-20 19:05:51Z 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 * Authors:
30 * Andrei Gourianov
31 * Aleksey Grichenko
32 * Michael Kimelman
33 * Denis Vakatov
34 * Eugene Vasilchenko
35 *
36 * File Description:
37 * Scope is top-level object available to a client.
38 * Its purpose is to define a scope of visibility and reference
39 * resolution and provide access to the bio sequence data
40 *
41 */
42 
43 #include <corelib/ncbiobj.hpp>
45 #include <objmgr/tse_handle.hpp>
49 #include <objmgr/bioseq_handle.hpp>
54 
55 
58 
59 /** @addtogroup ObjectManagerCore
60  *
61  * @{
62  */
63 
64 
65 // fwd decl
66 // objects
67 class CSeq_entry;
68 class CBioseq_set;
69 class CBioseq;
70 class CSeq_annot;
71 class CSeq_submit;
72 class CSeq_id;
73 class CSeq_loc;
74 
75 // objmgr
76 class CSeq_id_Handle;
77 class CObjectManager;
78 class CScope_Impl;
79 class CSynonymsSet;
80 class CBlobIdKey;
81 class CDataLoader;
82 
83 
84 /////////////////////////////////////////////////////////////////////////////
85 ///
86 /// CScope --
87 ///
88 /// Scope of cache visibility and reference resolution
89 ///
90 
92 {
93 public:
94  explicit CScope(CObjectManager& objmgr);
95  virtual ~CScope(void);
96 
97  /// priority type and special value for added objects
98  typedef int TPriority;
99  enum EPriority {
100  kPriority_Default = -1, ///< Use default priority for added data
101  kPriority_NotSet = -1 ///< Deprecated: use kPriority_Default instead
102  };
103 
104  /// Get object manager controlling this scope
105  CObjectManager& GetObjectManager(void);
106 
107  // CBioseq_Handle methods:
108  /// Get bioseq handle by seq-id
109  CBioseq_Handle GetBioseqHandle(const CSeq_id& id);
110 
111  /// Get bioseq handle by seq-id handle
112  CBioseq_Handle GetBioseqHandle(const CSeq_id_Handle& id);
113 
114  /// Get bioseq handle by seq-loc.
115  /// If the seq-loc contains no seq-ids or there's a single seq-id which
116  /// can not be resolved, returns empty handle.
117  /// If the seq-loc references only parts of a segmented set, the method
118  /// returns bioseq handle for the master bioseq.
119  /// If the seq-loc contains a single seq-id, the bioseq handle for this
120  /// id is returned.
121  /// If there are multiple seq-ids not belonging to the same seg-set,
122  /// the method throws CObjMgrException.
123  CBioseq_Handle GetBioseqHandle(const CSeq_loc& loc);
124 
126  eGetBioseq_Resolved, ///< Search only in already resolved ids
127  eGetBioseq_Loaded, ///< Search in all loaded TSEs in the scope
128  eGetBioseq_All ///< Search bioseq, load if not loaded yet
129  };
130 
131  /// Get bioseq handle without loading new data
132  CBioseq_Handle GetBioseqHandle(const CSeq_id& id,
133  EGetBioseqFlag get_flag);
134  /// Get bioseq handle without loading new data
135  CBioseq_Handle GetBioseqHandle(const CSeq_id_Handle& id,
136  EGetBioseqFlag get_flag);
137 
138  /// Check if two seq-ids are resolved to the same Bioseq
139  bool IsSameBioseq(const CSeq_id_Handle& id1,
140  const CSeq_id_Handle& id2,
141  EGetBioseqFlag get_flag);
142 
143  typedef vector<CSeq_id_Handle> TIds;
144  typedef vector<CBioseq_Handle> TBioseqHandles;
145  /// Get bioseq handles for all ids. The returned vector contains
146  /// bioseq handles for all requested ids in the same order.
147  TBioseqHandles GetBioseqHandles(const TIds& ids);
148 
149  /// Get CDD annotations for all ids.
150  typedef vector<CTSE_Handle> TCDD_Entries;
151  TCDD_Entries GetCDDAnnots(const TIds& idhs);
152  TCDD_Entries GetCDDAnnots(const TBioseqHandles& bhs);
153 
154  /// GetXxxHandle control values.
155  enum EMissing {
158  eMissing_Default = eMissing_Throw
159  };
160 
162  /// Get Seq-entry handle by its blob-id, with possible loading.
163  /// The blob-id can be obtained from CTSE_Handle::GetBlobId() or
164  /// from specific data loader (see CGBDataLoader::GetBlobId()).
165  CSeq_entry_Handle GetSeq_entryHandle(CDataLoader* loader,
166  const TBlobId& blob_id,
167  EMissing action = eMissing_Default);
168 
169  // Deprecated interface
170  /// Find object in scope
171  /// If object is not found GetXxxHandle() methods will either
172  /// throw an exception or return null handle depending on argument.
173  CTSE_Handle GetTSE_Handle(const CSeq_entry& tse,
174  EMissing action = eMissing_Default);
175  CBioseq_Handle GetBioseqHandle(const CBioseq& bioseq,
176  EMissing action = eMissing_Default);
177  CBioseq_set_Handle GetBioseq_setHandle(const CBioseq_set& seqset,
178  EMissing action = eMissing_Default);
179  CSeq_entry_Handle GetSeq_entryHandle(const CSeq_entry& entry,
180  EMissing action = eMissing_Default);
181  CSeq_annot_Handle GetSeq_annotHandle(const CSeq_annot& annot,
182  EMissing action = eMissing_Default);
183  CSeq_feat_Handle GetSeq_featHandle(const CSeq_feat& feat,
184  EMissing action = eMissing_Default);
185 
186  CBioseq_Handle GetObjectHandle(const CBioseq& bioseq,
187  EMissing action = eMissing_Default);
188  CBioseq_set_Handle GetObjectHandle(const CBioseq_set& seqset,
189  EMissing action = eMissing_Default);
190  CSeq_entry_Handle GetObjectHandle(const CSeq_entry& entry,
191  EMissing action = eMissing_Default);
192  CSeq_annot_Handle GetObjectHandle(const CSeq_annot& annot,
193  EMissing action = eMissing_Default);
194  CSeq_feat_Handle GetObjectHandle(const CSeq_feat& feat,
195  EMissing action = eMissing_Default);
196 
197  /// Get edit handle for the specified object
198  /// Throw an exception if object is not found, or non-editable
199  CBioseq_EditHandle GetBioseqEditHandle(const CBioseq& bioseq);
200  CSeq_entry_EditHandle GetSeq_entryEditHandle(const CSeq_entry& entry);
201  CSeq_annot_EditHandle GetSeq_annotEditHandle(const CSeq_annot& annot);
202  CBioseq_set_EditHandle GetBioseq_setEditHandle(const CBioseq_set& seqset);
203 
204  CBioseq_EditHandle GetObjectEditHandle(const CBioseq& bioseq);
205  CBioseq_set_EditHandle GetObjectEditHandle(const CBioseq_set& seqset);
206  CSeq_entry_EditHandle GetObjectEditHandle(const CSeq_entry& entry);
207  CSeq_annot_EditHandle GetObjectEditHandle(const CSeq_annot& annot);
208 
209  /// Get bioseq handle for sequence withing one TSE
210  CBioseq_Handle GetBioseqHandleFromTSE(const CSeq_id& id,
211  const CTSE_Handle& tse);
212  CBioseq_Handle GetBioseqHandleFromTSE(const CSeq_id_Handle& id,
213  const CTSE_Handle& tse);
214 
215  CBioseq_Handle GetBioseqHandleFromTSE(const CSeq_id& id,
216  const CBioseq_Handle& bh);
217 
218  /// Get bioseq handle for sequence withing one TSE
219  CBioseq_Handle GetBioseqHandleFromTSE(const CSeq_id& id,
220  const CSeq_entry_Handle& seh);
221 
222  /// Get bioseq handle for sequence withing one TSE
223  CBioseq_Handle GetBioseqHandleFromTSE(const CSeq_id_Handle& id,
224  const CBioseq_Handle& bh);
225 
226  /// Get bioseq handle for sequence withing one TSE
227  CBioseq_Handle GetBioseqHandleFromTSE(const CSeq_id_Handle& id,
228  const CSeq_entry_Handle& seh);
229 
230 
231  // CScope contents modification methods
232 
233  /// Add default data loaders from object manager
234  void AddDefaults(TPriority pri = kPriority_Default);
235 
236  /// Add data loader by name.
237  /// The loader (or its factory) must be known to Object Manager.
238  void AddDataLoader(const string& loader_name,
239  TPriority pri = kPriority_Default);
240 
241  /// Add the scope's datasources as a single group with the given priority
242  /// All data sources (data loaders and explicitly added data) have
243  /// priorities. The scope scans data sources in order of increasing
244  /// priorities to find the sequence you've requested. By default,
245  /// explicitly added data have priority 9, and data loaders - priority
246  /// 99, so the scope will first look in explicit data, then in data
247  /// loaders. If you have conflicting data or loaders (e.g. GenBank and
248  /// BLAST), you may need different priorities to make scope first look,
249  /// for example, in BLAST, and then if sequence is not found - in GenBank.
250  /// Note, that the priority you've specified for a data loader at
251  /// registration time (RegisterInObjectManager()) is a new default for
252  /// it, and can be overridden when you add the data loader to a scope.
253  void AddScope(CScope& scope,
254  TPriority pri = kPriority_Default);
255 
256 
257  /// AddXxx() control values
258  enum EExist {
261  eExist_Default = eExist_Throw
262  };
263  /// Add seq_entry, default priority is higher than for defaults or loaders
264  /// Add object to the score with possibility to edit it directly.
265  /// If the object is already in the scope the AddXxx() methods will
266  /// throw an exception or return handle to existent object depending
267  /// on the action argument.
268  CSeq_entry_Handle AddTopLevelSeqEntry(CSeq_entry& top_entry,
269  TPriority pri = kPriority_Default,
270  EExist action = eExist_Default);
271  /// Add shared Seq-entry, scope will not modify it.
272  /// If edit handle is requested, scope will create a copy object.
273  /// If the object is already in the scope the AddXxx() methods will
274  /// throw an exception or return handle to existent object depending
275  /// on the action argument.
276  CSeq_entry_Handle AddTopLevelSeqEntry(const CSeq_entry& top_entry,
277  TPriority pri = kPriority_Default,
278  EExist action = eExist_Throw);
279 
280 
281  /// Add bioseq, return bioseq handle. Try to use unresolved seq-id
282  /// from the bioseq, fail if all ids are already resolved to
283  /// other sequences.
284  /// Add object to the score with possibility to edit it directly.
285  /// If the object is already in the scope the AddXxx() methods will
286  /// throw an exception or return handle to existent object depending
287  /// on the action argument.
288  CBioseq_Handle AddBioseq(CBioseq& bioseq,
289  TPriority pri = kPriority_Default,
290  EExist action = eExist_Throw);
291 
292  /// Add shared Bioseq, scope will not modify it.
293  /// If edit handle is requested, scope will create a copy object.
294  /// If the object is already in the scope the AddXxx() methods will
295  /// throw an exception or return handle to existent object depending
296  /// on the action argument.
297  CBioseq_Handle AddBioseq(const CBioseq& bioseq,
298  TPriority pri = kPriority_Default,
299  EExist action = eExist_Throw);
300 
301  /// Add GC-Assembly. Sequences from the assembly are converted
302  /// to bioseqs and added to the scope as a new top level seq-entry.
303  CSeq_entry_Handle AddGC_Assembly(const CGC_Assembly& gc_assembly,
305  TPriority pri = kPriority_Default,
306  EExist action = eExist_Throw);
307 
308  /// Add Seq-annot, return its CSeq_annot_Handle.
309  /// Add object to the score with possibility to edit it directly.
310  /// If the object is already in the scope the AddXxx() methods will
311  /// throw an exception or return handle to existent object depending
312  /// on the action argument.
313  CSeq_annot_Handle AddSeq_annot(CSeq_annot& annot,
314  TPriority pri = kPriority_Default,
315  EExist action = eExist_Throw);
316  /// Add shared Seq-annot, scope will not modify it.
317  /// If edit handle is requested, scope will create a copy object.
318  /// If the object is already in the scope the AddXxx() methods will
319  /// throw an exception or return handle to existent object depending
320  /// on the action argument.
321  CSeq_annot_Handle AddSeq_annot(const CSeq_annot& annot,
322  TPriority pri = kPriority_Default,
323  EExist action = eExist_Throw);
324 
325  /// Add Seq-submit, return its CSeq_entry_Handle.
326  /// Add object to the score with possibility to edit it directly.
327  CSeq_entry_Handle AddSeq_submit(CSeq_submit& submit,
328  TPriority pri = kPriority_Default);
329 
330  /// Get editable Biosec handle by regular one
331  CBioseq_EditHandle GetEditHandle(const CBioseq_Handle& seq);
332 
333  /// Get editable SeqEntry handle by regular one
334  CSeq_entry_EditHandle GetEditHandle(const CSeq_entry_Handle& entry);
335 
336  /// Get editable Seq-annot handle by regular one
337  CSeq_annot_EditHandle GetEditHandle(const CSeq_annot_Handle& annot);
338 
339  /// Get editable Biosec-set handle by regular one
340  CBioseq_set_EditHandle GetEditHandle(const CBioseq_set_Handle& seqset);
341 
345  eRemoveIfLocked
346  };
347  /// Clean all unused TSEs from the scope's cache and release the memory.
348  /// TSEs referenced by any handles are not removed.
349  /// Explicitly added entries are not removed.
350  /// Edited entries retrieved from a data loader are removed,
351  /// so that their unmodified version will be visible.
352  void ResetHistory(EActionIfLocked action = eKeepIfLocked);
353  /// Clear all information in the scope except added data loaders.
354  void ResetDataAndHistory(void);
355  /// Clear all information in the scope including data loaders.
357  eRemoveDataLoaders
358  };
359  void ResetDataAndHistory(ERemoveDataLoaders remove_data_loaders);
360 
361  /// Remove single TSE from the scope's history. If there are other
362  /// live handles referencing the TSE, nothing is removed.
363  /// @param tse
364  /// TSE to be removed from the cache.
365  void RemoveFromHistory(const CTSE_Handle& tse,
366  EActionIfLocked action = eKeepIfLocked);
367  /// Remove the bioseq's TSE from the scope's history. If there are other
368  /// live handles referencing the TSE, nothing is removed.
369  /// @param bioseq
370  /// Bioseq, which TSE is to be removed from the cache.
371  void RemoveFromHistory(const CBioseq_Handle& bioseq,
372  EActionIfLocked action = eKeepIfLocked);
373  /// Remove the Seq-id failed resolution from the scope's history.
374  /// @param seq_id
375  /// Seq-id that failed resolution
376  void RemoveFromHistory(const CSeq_id_Handle& seq_id);
377  /// Remove the Seq-id failed resolution from the scope's history.
378  /// @param seq_id
379  /// Seq-id that failed resolution
380  void RemoveFromHistory(const CSeq_id& seq_id);
381 
382  /// Revoke data loader from the scope. Throw exception if the
383  /// operation fails (e.g. data source is in use or not found).
384  void RemoveDataLoader(const string& loader_name,
385  EActionIfLocked action = eThrowIfLocked);
386  /// Revoke TSE previously added using AddTopLevelSeqEntry() or
387  /// AddBioseq(). Throw exception if the TSE is still in use or
388  /// not found in the scope.
389  void RemoveTopLevelSeqEntry(const CTSE_Handle& entry);
390  void RemoveTopLevelSeqEntry(const CSeq_entry_Handle& entry);
391 
392  /// Revoke Bioseq previously added using AddBioseq().
393  /// Throw exception if the Bioseq is still in use or
394  /// not found in the scope.
395  void RemoveBioseq(const CBioseq_Handle& seq);
396 
397  /// Revoke Seq-annot previously added using AddSeq_annot().
398  /// Throw exception if the Bioseq is still in use or
399  /// not found in the scope.
400  void RemoveSeq_annot(const CSeq_annot_Handle& annot);
401 
402  /// EForceLoad flag instruct scope to ignore already loaded information
403  /// and always request data loader for data.
404  enum EForceLoad {
406  eForceLoad
407  };
408  /// Flags to control behavior of various meta-data getters
409  /// fForceLoad instructs scope to ignore already loaded information
410  /// and alway request data loader for data
411  /// fThrowOnMissing instructs to throw an exeption if the requested data
412  /// is missing - either sequence id cannot be found in any data loader
413  /// or the sequence doesn't have the requested meta-data
414  /// without the flag getter will return special value
415  enum EGetFlags {
416  /// ignore already loaded information and alway request data loader
417  fForceLoad = (1 << 0), // == eForceLoad for compatibility
418 
419  /// fThrowOnMissingSequence will cause exception to be thrown
420  /// if sequence not found.
421  /// The exception type/code: CObjMgrException/eFindFailed
422  /// @sa CObjMgrException
423  fThrowOnMissingSequence = (1 << 1),
424 
425  /// fThrowOnMissingData will cause exception to be thrown
426  /// if sequence is found but doesn't have the data
427  /// The exception type/code: CObjMgrException/eMissingData
428  /// @sa CObjMgrException
429  fThrowOnMissingData = (1 << 2),
430 
431  /// throw exception if sequence or requested data aren't found
432  /// @sa fThrowOnMissingSequence
433  /// @sa fThrowOnMissingData
434  /// @sa CObjMgrException
435  fThrowOnMissing = fThrowOnMissingSequence|fThrowOnMissingData,
436 
437  /// avoid time-consuming recalculation of missing data
438  fDoNotRecalculate = (1 << 3)
439  };
440  typedef int TGetFlags;
441  /// obsolete enum
442  /// @sa EGetFlags
444  eNoForceLabelLoad = eNoForceLoad,
445  eForceLabelLoad = eForceLoad
446  };
447 
448  /// Check existence of sequence with this id
449  bool Exists(const CSeq_id& id);
450  bool Exists(const CSeq_id_Handle& id);
451 
452  /// Get "native" bioseq ids without filtering and matching.
453  /// Returns empty ids if the sequence is not found
454  /// @sa EGetflags
455  TIds GetIds(const CSeq_id& id , TGetFlags flags = 0);
456  TIds GetIds(const CSeq_id_Handle& idh, TGetFlags flags = 0);
457 
458  /// Get accession.version Seq-id
459  /// Returns null CSeq_id_Handle if the sequence is not found
460  /// or if it doesn't have accession
461  /// @sa EGetflags
462  CSeq_id_Handle GetAccVer(const CSeq_id_Handle& idh, TGetFlags flags = 0);
463 
464  /// Get GI of a sequence
465  /// Returns ZERO_GI if the sequence is not found or if it doesn't have GI
466  /// @sa EGetflags
467  TGi GetGi(const CSeq_id_Handle& idh, TGetFlags flags = 0);
468 
469  // helper methods to lookup for specific Seq-id types
470  static CSeq_id_Handle x_GetAccVer(const TIds& ids);
471  static TGi x_GetGi(const TIds& ids);
472 
473  /// Get short description of bioseq, usually "accession.version"
474  /// Returns empty string if the sequence is not found.
475  /// @sa EGetflags
476  string GetLabel(const CSeq_id& id, TGetFlags flags = 0);
477  string GetLabel(const CSeq_id_Handle& idh, TGetFlags flags = 0);
478 
479  /// Get taxonomy id of bioseq
480  /// Return -1 if sequence is not found
481  /// Return 0 if sequence doesn't have taxonomy id
482  /// @sa EGetflags
483  TTaxId GetTaxId(const CSeq_id& id, TGetFlags flags = 0);
484  TTaxId GetTaxId(const CSeq_id_Handle& idh, TGetFlags flags = 0);
485 
486  /// Get sequence length
487  /// Return kInvalidSeqPos if sequence is not found
488  /// @sa EGetflags
489  TSeqPos GetSequenceLength(const CSeq_id& id, TGetFlags flags = 0);
490  TSeqPos GetSequenceLength(const CSeq_id_Handle& id, TGetFlags flags = 0);
491 
492  /// Get molecular type of sequence (protein/dna/rna)
493  /// Return CSeq_inst::eMol_not_set if sequence is not found
494  /// @sa EGetflags
495  /// @sa CSeq_inst::EMol
497  TGetFlags flags = 0);
499  TGetFlags flags = 0);
500 
501  /// Get sequence GenBank state
502  /// Return (fState_not_found|fState_no_data) if sequence is not found
503  /// @sa EGetflags
504  /// @sa CBioseq_Handle::EBioseqStateFlags
505  CBioseq_Handle::TBioseqStateFlags GetSequenceState(const CSeq_id& id, TGetFlags flags = 0);
506  CBioseq_Handle::TBioseqStateFlags GetSequenceState(const CSeq_id_Handle& id, TGetFlags flags = 0);
507 
508  /// Get sequence data hash value
509  /// Return 0 if sequence is not found or if its hash is not known
510  /// Note: 0 can be a real hash value, use flags to distinguish these cases
511  /// @sa EGetflags
512  typedef int TSequenceHash;
513  TSequenceHash GetSequenceHash(const CSeq_id& id, TGetFlags flags = 0);
514  TSequenceHash GetSequenceHash(const CSeq_id_Handle& id, TGetFlags flags = 0);
515 
516  /// Bulk retrieval methods
517  /// Common argument typedef - vector of requested ids
518  typedef vector<CSeq_id_Handle> TSeq_id_Handles;
519 
520  /// Get all ids of sequences
521  /// Returns empty ids if the sequence is not found
522  /// @sa EGetflags
523  typedef vector<TIds> TBulkIds;
525  TGetFlags flags = 0);
527  const TSeq_id_Handles& idhs,
528  TGetFlags flags = 0);
529 
530  /// Get accession.version Seq-id
531  /// Returns null CSeq_id_Handles for sequences that aren't found
532  /// or don't have accession id.
533  /// @sa GetAccVer
534  /// @sa EGetflags
536  TGetFlags flags = 0);
538  const TSeq_id_Handles& idhs,
539  TGetFlags flags = 0);
540 
541  /// Get GI of a sequence
542  /// Returns ZERO_GI for sequence that aren't found or don't have GI
543  /// @sa GetGi
544  /// @sa EGetflags
545  typedef vector<TGi> TGIs;
547  TGetFlags flags = 0);
549  const TSeq_id_Handles& idhs,
550  TGetFlags flags = 0);
551 
552  /// Get short descriptions of sequences, usually "accession.version"
553  /// Returns empty strings for sequences that aren't found
554  /// @sa GetLabel
555  /// @sa EGetflags
556  typedef vector<string> TLabels;
558  TGetFlags flags = 0);
560  const TSeq_id_Handles& idhs,
561  TGetFlags flags = 0);
562 
563  /// Get taxonomy ids of sequences
564  /// Return -1 for sequences that aren't found
565  /// Return 0 for sequences that don't have taxonomy id
566  /// @sa EGetflags
567  typedef vector<TTaxId> TTaxIds;
569  TGetFlags flags = 0);
571  const TSeq_id_Handles& idhs,
572  TGetFlags flags = 0);
573 
574  /// Get lengths of sequences
575  /// Return kInvalidSeqPos for sequences that aren't found
576  /// @sa EGetflags
577  typedef vector<TSeqPos> TSequenceLengths;
579  TGetFlags flags = 0);
581  const TSeq_id_Handles& idhs,
582  TGetFlags flags = 0);
583 
584  /// Get molecular types of sequences (protein/dna/rna)
585  /// Return CSeq_inst::eMol_not_set for sequences that aren't found
586  /// @sa EGetflags
587  /// @sa CSeq_inst::EMol
588  typedef vector<CSeq_inst::TMol> TSequenceTypes;
590  TGetFlags flags = 0);
592  const TSeq_id_Handles& idhs,
593  TGetFlags flags = 0);
594 
595  /// Get GenBank states of sequences
596  /// Return (fState_not_found|fState_no_data) for sequences
597  /// that aren't found
598  /// @sa EGetflags
599  /// @sa CBioseq_Handle::EBioseqStateFlags
600  typedef vector<CBioseq_Handle::TBioseqStateFlags> TSequenceStates;
602  TGetFlags flags = 0);
604  const TSeq_id_Handles& idhs,
605  TGetFlags flags = 0);
606 
607  /// Get data hashes of sequences
608  /// Return 0 for sequences that aren't found or they don't have hash
609  /// Note: 0 can be a real hash value, use flags to distinguish these cases
610  /// @sa EGetflags
611  typedef vector<TSequenceHash> TSequenceHashes;
613  TGetFlags flags = 0);
615  const TSeq_id_Handles& idhs,
616  TGetFlags flags = 0);
617 
618  /// Get bioseq synonyms, resolving to the bioseq in this scope.
619  CConstRef<CSynonymsSet> GetSynonyms(const CSeq_id& id);
620 
621  /// Get bioseq synonyms, resolving to the bioseq in this scope.
622  CConstRef<CSynonymsSet> GetSynonyms(const CSeq_id_Handle& id);
623 
624  /// Get bioseq synonyms, resolving to the bioseq in this scope.
625  CConstRef<CSynonymsSet> GetSynonyms(const CBioseq_Handle& bh);
626 
627  // deprecated interface
628  void AttachEntry(CSeq_entry& parent, CSeq_entry& entry);
629  void RemoveEntry(CSeq_entry& entry);
630 
631  void AttachAnnot(CSeq_entry& parent, CSeq_annot& annot);
632  void RemoveAnnot(CSeq_entry& parent, CSeq_annot& annot);
633  void ReplaceAnnot(CSeq_entry& entry,
634  CSeq_annot& old_annot, CSeq_annot& new_annot);
635 
636  CBioseq_Handle GetBioseqHandleFromTSE(const CSeq_id& id,
637  const CSeq_entry& tse);
638  CBioseq_Handle GetBioseqHandleFromTSE(const CSeq_id_Handle& id,
639  const CSeq_entry& tse);
640 
641  enum ETSEKind {
643  eAllTSEs
644  };
645  typedef vector<CSeq_entry_Handle> TTSE_Handles;
646  void GetAllTSEs(TTSE_Handles& tses, enum ETSEKind kind = eManualTSEs);
647 
648  CScopeTransaction GetTransaction();
649 
650  void UpdateAnnotIndex(void);
651 
652  /// Return current application-wide KeepExternalAnnotsForEdit flag.
653  ///
654  /// By default edited sequences lose their connection to external annotations.
655  /// This behavior can be changed for all newly created scopes by calling
656  /// SetDefaultKeepExternalAnnotsForEdit(true), and current application-wide
657  /// default can be retrieved by GetDefaultKeepExternalAnnotsForEdit().
658  /// @sa
659  /// SetDefaultKeepExternalAnnotsForEdit(), SetKeepExternalAnnotsForEdit()
660  static bool GetDefaultKeepExternalAnnotsForEdit();
661 
662  /// Set new application-wide KeepExternalAnnotsForEdit flag.
663  ///
664  /// By default edited sequences lose their connection to external annotations.
665  /// This behavior can be changed for all newly created scopes by calling
666  /// SetDefaultKeepExternalAnnotsForEdit(true), and current application-wide
667  /// default can be retrieved by GetDefaultKeepExternalAnnotsForEdit().
668  /// @sa
669  /// GetDefaultKeepExternalAnnotsForEdit(), SetKeepExternalAnnotsForEdit()
670  static void SetDefaultKeepExternalAnnotsForEdit(bool keep = true);
671 
672  /// Return this scope's KeepExternalAnnotsForEdit flag.
673  ///
674  /// By default edited sequences lose their connection to external annotations.
675  /// This behavior can be changed for any scope by calling
676  /// SetKeepExternalAnnotsForEdit(true), and current scope's behavior
677  /// can be retrieved by GetKeepExternalAnnotsForEdit().
678  /// @sa
679  /// SetDefaultKeepExternalAnnotsForEdit(), SetKeepExternalAnnotsForEdit()
680  bool GetKeepExternalAnnotsForEdit() const;
681 
682  /// Change this scope's KeepExternalAnnotsForEdit flag.
683  ///
684  /// By default edited sequences lose their connection to external annotations.
685  /// This behavior can be changed for any scope by calling
686  /// SetKeepExternalAnnotsForEdit(true), and current scope's behavior
687  /// can be retrieved by GetKeepExternalAnnotsForEdit().
688  /// @sa
689  /// GetDefaultKeepExternalAnnotsForEdit(), GetKeepExternalAnnotsForEdit()
690  void SetKeepExternalAnnotsForEdit(bool keep = true);
691 
692 protected:
693  CScope_Impl& GetImpl(void);
694 
695 private:
696  // to prevent copying
697  CScope(const CScope&);
699 
700  friend class CSeqMap_CI;
701  friend class CSeq_annot_CI;
702  friend class CAnnot_Collector;
703  friend class CBioseq_CI;
704  friend class CHeapScope;
706  friend class CScopeTransaction;
707 
710 };
711 
712 
713 /////////////////////////////////////////////////////////////////////////////
714 // CScope inline methods
715 /////////////////////////////////////////////////////////////////////////////
716 
717 
718 inline
720 {
721  return *m_Impl;
722 }
723 
724 
725 inline
727  EMissing action)
728 {
729  return GetBioseqHandle(obj, action);
730 }
731 
732 
733 inline
735  EMissing action)
736 {
737  return GetBioseq_setHandle(obj, action);
738 }
739 
740 
741 inline
743  EMissing action)
744 {
745  return GetSeq_entryHandle(obj, action);
746 }
747 
748 
749 inline
751  EMissing action)
752 {
753  return GetSeq_annotHandle(obj, action);
754 }
755 
756 
757 inline
759  EMissing action)
760 {
761  return GetSeq_featHandle(feat, action);
762 }
763 
764 
765 inline
767 {
768  return GetBioseqEditHandle(obj);
769 }
770 
771 
772 inline
774 {
775  return GetBioseq_setEditHandle(obj);
776 }
777 
778 
779 inline
781 {
782  return GetSeq_entryEditHandle(obj);
783 }
784 
785 
786 inline
788 {
789  return GetSeq_annotEditHandle(obj);
790 }
791 
792 
793 inline
795 {
797 }
798 
799 
800 /* @} */
801 
802 
805 
806 #endif//OBJMGR_SCOPE__HPP
User-defined methods of the data storage class.
pair< string, int > GetAccVer(const CAlignModel &a, CScope &scope)
Definition: chainer.cpp:6323
CBioseq_CI –.
Definition: bioseq_ci.hpp:69
CBioseq_EditHandle –.
CBioseq_Handle –.
CBioseq_set_EditHandle –.
CBioseq_set_Handle –.
CConstRef –.
Definition: ncbiobj.hpp:1266
CObjectManager –.
CObject –.
Definition: ncbiobj.hpp:180
Scope Transaction.
CScope –.
Definition: scope.hpp:92
Iterator over CSeqMap.
Definition: seq_map_ci.hpp:252
CSeq_annot_CI –.
CSeq_annot_Handle –.
CSeq_entry_Handle –.
CSeq_entry_Handle –.
Definition: Seq_entry.hpp:56
CSeq_feat_Handle –.
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
static uch flags
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
SStrictId_Tax::TId TTaxId
Taxon id type.
Definition: ncbimisc.hpp:1048
string GetLabel(const CSeq_id &id)
bool IsSameBioseq(const CSeq_id &id1, const CSeq_id &id2, CScope *scope, CScope::EGetBioseqFlag get_flag=CScope::eGetBioseq_All)
Determines if two CSeq_ids represent the same CBioseq.
TTaxId GetTaxId(const CBioseq_Handle &handle)
return the tax-id associated with a given sequence.
Definition: sequence.cpp:274
void GetAccVers(TSeq_id_Handles *results, const TSeq_id_Handles &idhs, TGetFlags flags=0)
EForceLabelLoad
obsolete enum
Definition: scope.hpp:443
TSequenceHashes GetSequenceHashes(const TSeq_id_Handles &idhs, TGetFlags flags=0)
vector< TTaxId > TTaxIds
Get taxonomy ids of sequences Return -1 for sequences that aren't found Return 0 for sequences that d...
Definition: scope.hpp:567
vector< TSeqPos > TSequenceLengths
Get lengths of sequences Return kInvalidSeqPos for sequences that aren't found.
Definition: scope.hpp:577
CScope & operator=(const CScope &)
void GetSequenceLengths(TSequenceLengths *results, const TSeq_id_Handles &idhs, TGetFlags flags=0)
ETSEKind
Definition: scope.hpp:641
CSeq_entry_Handle GetSeq_entryHandle(CDataLoader *loader, const TBlobId &blob_id, EMissing action=eMissing_Default)
Get Seq-entry handle by its blob-id, with possible loading.
Definition: scope.cpp:113
CScope_Impl & GetImpl(void)
Definition: scope.hpp:719
CBioseq_set_EditHandle GetBioseq_setEditHandle(const CBioseq_set &seqset)
Definition: scope.cpp:241
TSequenceStates GetSequenceStates(const TSeq_id_Handles &idhs, TGetFlags flags=0)
EExist
AddXxx() control values.
Definition: scope.hpp:258
void GetSequenceHashes(TSequenceHashes *results, const TSeq_id_Handles &idhs, TGetFlags flags=0)
void GetGis(TGIs *results, const TSeq_id_Handles &idhs, TGetFlags flags=0)
TSeq_id_Handles GetAccVers(const TSeq_id_Handles &idhs, TGetFlags flags=0)
Get accession.version Seq-id Returns null CSeq_id_Handles for sequences that aren't found or don't ha...
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
Definition: scope.cpp:95
vector< string > TLabels
Get short descriptions of sequences, usually "accession.version" Returns empty strings for sequences ...
Definition: scope.hpp:556
EActionIfLocked
Definition: scope.hpp:342
vector< TGi > TGIs
Get GI of a sequence Returns ZERO_GI for sequence that aren't found or don't have GI.
Definition: scope.hpp:545
TSequenceTypes GetSequenceTypes(const TSeq_id_Handles &idhs, TGetFlags flags=0)
EGetFlags
Flags to control behavior of various meta-data getters fForceLoad instructs scope to ignore already l...
Definition: scope.hpp:415
CSeq_feat_Handle GetSeq_featHandle(const CSeq_feat &feat, EMissing action=eMissing_Default)
Definition: scope.cpp:200
FParserFlags
Parser options.
vector< CBioseq_Handle::TBioseqStateFlags > TSequenceStates
Get GenBank states of sequences Return (fState_not_found|fState_no_data) for sequences that aren't fo...
Definition: scope.hpp:600
vector< TSequenceHash > TSequenceHashes
Get data hashes of sequences Return 0 for sequences that aren't found or they don't have hash Note: 0...
Definition: scope.hpp:611
vector< CBioseq_Handle > TBioseqHandles
Definition: scope.hpp:144
CBioseq_set_Handle GetBioseq_setHandle(const CBioseq_set &seqset, EMissing action=eMissing_Default)
Definition: scope.cpp:176
int TSequenceHash
Get sequence data hash value Return 0 if sequence is not found or if its hash is not known Note: 0 ca...
Definition: scope.hpp:512
CSeq_annot_Handle GetSeq_annotHandle(const CSeq_annot &annot, EMissing action=eMissing_Default)
Definition: scope.cpp:192
TGIs GetGis(const TSeq_id_Handles &idhs, TGetFlags flags=0)
vector< CTSE_Handle > TCDD_Entries
Get CDD annotations for all ids.
Definition: scope.hpp:150
void RemoveTopLevelSeqEntry(const CTSE_Handle &entry)
Revoke TSE previously added using AddTopLevelSeqEntry() or AddBioseq().
Definition: scope.cpp:376
TLabels GetLabels(const TSeq_id_Handles &idhs, TGetFlags flags=0)
CBlobIdKey TBlobId
Definition: scope.hpp:161
void GetTaxIds(TTaxIds *results, const TSeq_id_Handles &idhs, TGetFlags flags=0)
CSeq_entry_EditHandle GetSeq_entryEditHandle(const CSeq_entry &entry)
Definition: scope.cpp:207
vector< CSeq_inst::TMol > TSequenceTypes
Get molecular types of sequences (protein/dna/rna) Return CSeq_inst::eMol_not_set for sequences that ...
Definition: scope.hpp:588
void GetSequenceTypes(TSequenceTypes *results, const TSeq_id_Handles &idhs, TGetFlags flags=0)
TBulkIds GetBulkIds(const TSeq_id_Handles &idhs, TGetFlags flags=0)
void GetSequenceStates(TSequenceStates *results, const TSeq_id_Handles &idhs, TGetFlags flags=0)
ERemoveDataLoaders
Clear all information in the scope including data loaders.
Definition: scope.hpp:356
EGetBioseqFlag
Definition: scope.hpp:125
TSequenceLengths GetSequenceLengths(const TSeq_id_Handles &idhs, TGetFlags flags=0)
TTaxIds GetTaxIds(const TSeq_id_Handles &idhs, TGetFlags flags=0)
EForceLoad
EForceLoad flag instruct scope to ignore already loaded information and always request data loader fo...
Definition: scope.hpp:404
int TPriority
priority type and special value for added objects
Definition: scope.hpp:98
void GetBulkIds(TBulkIds *results, const TSeq_id_Handles &idhs, TGetFlags flags=0)
vector< CSeq_id_Handle > TIds
Definition: scope.hpp:143
EPriority
Definition: scope.hpp:99
CRef< CScope_Impl > m_Impl
Definition: scope.hpp:709
int TGetFlags
Definition: scope.hpp:440
void GetLabels(TLabels *results, const TSeq_id_Handles &idhs, TGetFlags flags=0)
vector< TIds > TBulkIds
Get all ids of sequences Returns empty ids if the sequence is not found.
Definition: scope.hpp:523
vector< CSeq_entry_Handle > TTSE_Handles
Definition: scope.hpp:645
CRef< CScope > m_HeapScope
Definition: scope.hpp:708
CScope(const CScope &)
CBioseq_EditHandle GetObjectEditHandle(const CBioseq &bioseq)
Definition: scope.hpp:766
CSeq_annot_EditHandle GetSeq_annotEditHandle(const CSeq_annot &annot)
Definition: scope.cpp:218
EMissing
GetXxxHandle control values.
Definition: scope.hpp:155
CBioseq_EditHandle GetBioseqEditHandle(const CBioseq &bioseq)
Get edit handle for the specified object Throw an exception if object is not found,...
Definition: scope.cpp:229
CBioseq_Handle GetObjectHandle(const CBioseq &bioseq, EMissing action=eMissing_Default)
Definition: scope.hpp:726
vector< CSeq_id_Handle > TSeq_id_Handles
Bulk retrieval methods Common argument typedef - vector of requested ids.
Definition: scope.hpp:518
@ eManualTSEs
Definition: scope.hpp:642
@ eExist_Throw
Definition: scope.hpp:259
@ eExist_Get
Definition: scope.hpp:260
@ eKeepIfLocked
Definition: scope.hpp:343
@ eThrowIfLocked
Definition: scope.hpp:344
@ eGetBioseq_Resolved
Search only in already resolved ids.
Definition: scope.hpp:126
@ eGetBioseq_Loaded
Search in all loaded TSEs in the scope.
Definition: scope.hpp:127
@ eNoForceLoad
Definition: scope.hpp:405
@ eMissing_Null
Definition: scope.hpp:157
@ eMissing_Throw
Definition: scope.hpp:156
const CTSE_Handle & GetTSE_Handle(void) const
#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
EMol
molecule class in living organism
Definition: Seq_inst_.hpp:108
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
static int * results[]
static bool GetIds(const T &d, set< string > &labels, const string name="", bool detect=false, bool found=false)
Uint4 GetSequenceType(const CBioseq_Handle &bsh)
Return a (corrected) set of flags identifying the sequence type.
Definition: sequtils.cpp:42
Modified on Fri Sep 20 14:58:03 2024 by modify_doxy.py rev. 669887