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

Go to the SVN repository for this file.

00001 #ifndef OBJECTS_OBJMGR_IMPL___SEQ_ENTRY_INFO__HPP
00002 #define OBJECTS_OBJMGR_IMPL___SEQ_ENTRY_INFO__HPP
00003 
00004 /*  $Id: seq_entry_info.hpp 47024 2010-09-01 19:02:10Z vasilche $
00005 * ===========================================================================
00006 *
00007 *                            PUBLIC DOMAIN NOTICE
00008 *               National Center for Biotechnology Information
00009 *
00010 *  This software/database is a "United States Government Work" under the
00011 *  terms of the United States Copyright Act.  It was written as part of
00012 *  the author's official duties as a United States Government employee and
00013 *  thus cannot be copyrighted.  This software/database is freely available
00014 *  to the public for use. The National Library of Medicine and the U.S.
00015 *  Government have not placed any restriction on its use or reproduction.
00016 *
00017 *  Although all reasonable efforts have been taken to ensure the accuracy
00018 *  and reliability of the software and data, the NLM and the U.S.
00019 *  Government do not and cannot warrant the performance or results that
00020 *  may be obtained by using this software or data. The NLM and the U.S.
00021 *  Government disclaim all warranties, express or implied, including
00022 *  warranties of performance, merchantability or fitness for any particular
00023 *  purpose.
00024 *
00025 *  Please cite the author in any work or product based on this material.
00026 *
00027 * ===========================================================================
00028 *
00029 * Author: Eugene Vasilchenko
00030 *
00031 * File Description:
00032 *   Seq_entry info -- entry for data source
00033 *
00034 */
00035 
00036 
00037 #include <objmgr/impl/tse_info_object.hpp>
00038 #include <objects/seqset/Seq_entry.hpp>
00039 #include <objects/seqset/Bioseq_set.hpp>
00040 #include <objects/seq/Seq_descr.hpp>
00041 #include <vector>
00042 #include <list>
00043 
00044 BEGIN_NCBI_SCOPE
00045 BEGIN_SCOPE(objects)
00046 
00047 
00048 // forward declaration
00049 class CSeq_entry;
00050 class CBioseq;
00051 class CBioseq_set;
00052 class CSeq_annot;
00053 
00054 class CDataSource;
00055 class CTSE_Info;
00056 class CSeq_entry_Info;
00057 class CBioseq_Base_Info;
00058 class CBioseq_set_Info;
00059 class CBioseq_Info;
00060 class CSeq_annot_Info;
00061 class CSeq_descr;
00062 class CSeqdesc;
00063 
00064 ////////////////////////////////////////////////////////////////////
00065 //
00066 //  CSeq_entry_Info::
00067 //
00068 //    General information and indexes for seq-entries
00069 //
00070 
00071 
00072 class NCBI_XOBJMGR_EXPORT CSeq_entry_Info : public CTSE_Info_Object
00073 {
00074     typedef CTSE_Info_Object TParent;
00075 public:
00076     // 'ctors
00077     CSeq_entry_Info(void);
00078     explicit CSeq_entry_Info(const CSeq_entry_Info& info,
00079                              TObjectCopyMap* copy_map);
00080     explicit CSeq_entry_Info(CSeq_entry& entry);
00081     virtual ~CSeq_entry_Info(void);
00082 
00083     const CBioseq_set_Info& GetParentBioseq_set_Info(void) const;
00084     CBioseq_set_Info& GetParentBioseq_set_Info(void);
00085 
00086     const CSeq_entry_Info& GetParentSeq_entry_Info(void) const;
00087     CSeq_entry_Info& GetParentSeq_entry_Info(void);
00088 
00089     // Get unique bio object id
00090     virtual const CBioObjectId& GetBioObjectId(void) const;
00091 
00092     typedef CSeq_entry TObject;
00093 
00094     bool HasSeq_entry(void) const;
00095     CConstRef<TObject> GetCompleteSeq_entry(void) const;
00096     CConstRef<TObject> GetSeq_entryCore(void) const;
00097     CConstRef<TObject> GetSeq_entrySkeleton(void) const;
00098 
00099     // Seq-entry access
00100     typedef TObject::E_Choice E_Choice;
00101     E_Choice Which(void) const;
00102     void x_CheckWhich(E_Choice which) const;
00103     void Reset(void);
00104 
00105     typedef CBioseq_set_Info TSet;
00106     bool IsSet(void) const;
00107     const TSet& GetSet(void) const;
00108     TSet& SetSet(void);
00109 
00110     // SelectSet switches Seq-entry to e_Set variant
00111     TSet& SelectSet(void);
00112     TSet& SelectSet(TSet& seqset);
00113     TSet& SelectSet(CBioseq_set& seqset);
00114 
00115     typedef CBioseq_Info TSeq;
00116     bool IsSeq(void) const;
00117     const TSeq& GetSeq(void) const;
00118     TSeq& SetSeq(void);
00119 
00120     // SelectSeq switches Seq-entry to e_Seq variant
00121     TSeq& SelectSeq(TSeq& seq);
00122     TSeq& SelectSeq(CBioseq& seq);
00123 
00124     typedef CSeq_descr TDescr;
00125     // Bioseq-set access
00126     bool IsSetDescr(void) const;
00127     const TDescr& GetDescr(void) const;
00128     void ResetDescr(void);
00129     void SetDescr(TDescr& v);
00130     TDescr& SetDescr(void);
00131     bool AddSeqdesc(CSeqdesc& d);
00132     CRef<CSeqdesc> RemoveSeqdesc(const CSeqdesc& d);
00133     //    void AddDescr(CSeq_entry_Info& src);
00134     void AddSeq_descr(const TDescr& v);
00135 
00136     // get current content no matter what type it is
00137     const CBioseq_Base_Info& x_GetBaseInfo(void) const;
00138 
00139     // low level access for CSeqdesc_CI in case sequence is split
00140     typedef CSeq_descr::Tdata::const_iterator TDesc_CI;
00141     typedef unsigned TDescTypeMask;
00142     bool x_IsEndDesc(TDesc_CI iter) const;
00143     TDesc_CI x_GetFirstDesc(TDescTypeMask types) const;
00144     TDesc_CI x_GetNextDesc(TDesc_CI iter, TDescTypeMask types) const;
00145 
00146     CRef<CSeq_annot_Info> AddAnnot(CSeq_annot& annot);
00147     void AddAnnot(CRef<CSeq_annot_Info> annot);
00148     void RemoveAnnot(CRef<CSeq_annot_Info> annot);
00149 
00150     typedef vector< CRef<CSeq_annot_Info> > TAnnot;
00151     const TAnnot& GetLoadedAnnot(void) const;
00152 
00153     CRef<CSeq_entry_Info> AddEntry(CSeq_entry& entry, int index = -1);
00154     void AddEntry(CRef<CSeq_entry_Info> entry, int index = -1);
00155     void RemoveEntry(CRef<CSeq_entry_Info> entry);
00156 
00157     // tree initialization
00158     void x_ParentAttach(CBioseq_set_Info& parent);
00159     void x_ParentDetach(CBioseq_set_Info& parent);
00160 
00161     // attaching/detaching to CDataSource (it's in CTSE_Info)
00162     virtual void x_DSAttachContents(CDataSource& ds);
00163     virtual void x_DSDetachContents(CDataSource& ds);
00164 
00165     // attaching/detaching to CTSE_Info
00166     virtual void x_TSEAttachContents(CTSE_Info& tse_info);
00167     virtual void x_TSEDetachContents(CTSE_Info& tse_info);
00168 
00169     void UpdateAnnotIndex(void) const;
00170 
00171     void x_SetBioseqChunkId(TChunkId chunk_id);
00172 
00173     typedef vector<CSeq_id_Handle> TSeqIds;
00174     // fill ids with all Bioseqs Seq-ids from this TSE
00175     // the result will be sorted and contain no duplicates
00176     void x_GetBioseqsIds(TSeqIds& ids) const;
00177     virtual void GetBioseqsIds(TSeqIds& ids) const;
00178     // fill ids with all Annot Seq-ids from this TSE
00179     // the result will be sorted and contain no duplicates
00180     void x_GetAnnotIds(TSeqIds& ids) const;
00181     virtual void GetAnnotIds(TSeqIds& ids) const;
00182     // fill seq_ids with all Bioseqs Seq-ids and annot_ids with annotations ids
00183     // the result will be sorted and contain no duplicates
00184     virtual void GetSeqAndAnnotIds(TSeqIds& seq_ids, TSeqIds& annot_ids) const;
00185 
00186 protected:
00187     friend class CScope_Impl;
00188     friend class CDataSource;
00189 
00190     friend class CAnnot_Collector;
00191     friend class CSeq_annot_CI;
00192 
00193     friend class CTSE_Info;
00194     friend class CBioseq_Base_Info;
00195     friend class CBioseq_Info;
00196     friend class CBioseq_set_Info;
00197     friend class CSeq_annot_Info;
00198 
00199     void x_AttachContents(void);
00200     void x_DetachContents(void);
00201 
00202     TObject& x_GetObject(void);
00203     const TObject& x_GetObject(void) const;
00204 
00205     void x_SetObject(TObject& obj);
00206     void x_SetObject(const CSeq_entry_Info& info, TObjectCopyMap* copy_map);
00207 
00208     void x_Select(CSeq_entry::E_Choice which,
00209                   CBioseq_Base_Info* contents);
00210     void x_Select(CSeq_entry::E_Choice which,
00211                   CRef<CBioseq_Base_Info> contents);
00212 
00213     void x_DSMapObject(CConstRef<TObject> obj, CDataSource& ds);
00214     void x_DSUnmapObject(CConstRef<TObject> obj, CDataSource& ds);
00215 
00216     void x_UpdateAnnotIndexContents(CTSE_Info& tse);
00217 
00218     void x_DoUpdate(TNeedUpdateFlags flags);
00219     void x_SetNeedUpdateContents(TNeedUpdateFlags flags);
00220 
00221     static CRef<TObject> sx_ShallowCopy(TObject& obj);
00222 
00223     // Seq-entry pointer
00224     CRef<TObject>           m_Object;
00225 
00226     // Bioseq/Bioseq_set info
00227     E_Choice                m_Which;
00228     CRef<CBioseq_Base_Info> m_Contents;
00229 
00230     // Hide copy methods
00231     CSeq_entry_Info& operator= (const CSeq_entry_Info&);
00232     
00233 };
00234 
00235 
00236 
00237 /////////////////////////////////////////////////////////////////////
00238 //
00239 //  Inline methods
00240 //
00241 /////////////////////////////////////////////////////////////////////
00242 
00243 inline
00244 bool CSeq_entry_Info::HasSeq_entry(void) const
00245 {
00246     return m_Object.NotEmpty();
00247 }
00248 
00249 
00250 inline
00251 CSeq_entry::E_Choice CSeq_entry_Info::Which(void) const
00252 {
00253     return m_Which;
00254 }
00255 
00256 inline 
00257 CConstRef<CSeq_entry> CSeq_entry_Info::GetSeq_entrySkeleton(void) const
00258 {
00259     return m_Object;   
00260 }
00261 
00262 inline
00263 CSeq_entry& CSeq_entry_Info::x_GetObject(void)
00264 {
00265     return *m_Object;
00266 }
00267 
00268 
00269 inline
00270 const CSeq_entry& CSeq_entry_Info::x_GetObject(void) const
00271 {
00272     return *m_Object;
00273 }
00274 
00275 
00276 inline 
00277 const CBioseq_Base_Info& CSeq_entry_Info::x_GetBaseInfo(void) const
00278 {
00279     return *m_Contents;
00280 }
00281 
00282 inline
00283 bool CSeq_entry_Info::IsSet(void) const
00284 {
00285     return Which() == CSeq_entry::e_Set;
00286 }
00287 
00288 
00289 inline
00290 bool CSeq_entry_Info::IsSeq(void) const
00291 {
00292     return Which() == CSeq_entry::e_Seq;
00293 }
00294 
00295 
00296 END_SCOPE(objects)
00297 END_NCBI_SCOPE
00298 
00299 #endif  /* OBJECTS_OBJMGR_IMPL___SEQ_ENTRY_INFO__HPP */
Modified on Fri Sep 19 19:27:19 2014 by modify_doxy.py rev. 426318