include/objmgr/bioseq_handle.hpp

Go to the documentation of this file.
00001 #ifndef BIOSEQ_HANDLE__HPP
00002 #define BIOSEQ_HANDLE__HPP
00003 
00004 /*  $Id: bioseq_handle.hpp 176124 2009-11-16 15:20:36Z 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: Aleksey Grichenko, Michael Kimelman, Eugene Vasilchenko
00030 *
00031 * File Description:
00032 *
00033 */
00034 
00035 #include <corelib/ncbistd.hpp>
00036 
00037 #include <objects/seqloc/Na_strand.hpp>
00038 #include <objects/seqset/Bioseq_set.hpp> // for EClass
00039 #include <objects/seq/Seq_inst.hpp> // for EMol
00040 
00041 #include <objects/seq/seq_id_handle.hpp>
00042 #include <objmgr/tse_handle.hpp>
00043 
00044 BEGIN_NCBI_SCOPE
00045 BEGIN_SCOPE(objects)
00046 
00047 
00048 /** @addtogroup ObjectManagerHandles
00049  *
00050  * @{
00051  */
00052 
00053 
00054 class CDataSource;
00055 class CSeqMap;
00056 class CSeqVector;
00057 class CScope;
00058 class CSeq_id;
00059 class CSeq_loc;
00060 class CBioseq_Info;
00061 class CSeq_descr;
00062 class CSeqdesc;
00063 class CTSE_Info;
00064 class CSeq_entry;
00065 class CSeq_annot;
00066 class CSynonymsSet;
00067 class CBioseq_ScopeInfo;
00068 class CSeq_id_ScopeInfo;
00069 class CTSE_Lock;
00070 
00071 class CBioseq_Handle;
00072 class CBioseq_set_Handle;
00073 class CSeq_annot_Handle;
00074 class CSeq_entry_Handle;
00075 class CBioseq_EditHandle;
00076 class CBioseq_set_EditHandle;
00077 class CSeq_annot_EditHandle;
00078 class CSeq_entry_EditHandle;
00079 class CBioObjectId;
00080 
00081 
00082 /////////////////////////////////////////////////////////////////////////////
00083 ///
00084 ///  CBioseq_Handle --
00085 ///
00086 ///  Proxy to access the bioseq data
00087 ///
00088 
00089 // Bioseq handle -- must be a copy-safe const type.
00090 class  CBioseq_Handle
00091 {
00092 public:
00093     // Default constructor
00094     CBioseq_Handle(void);
00095 
00096     /// Reset handle and make it not to point to any bioseq
00097     void Reset(void);
00098 
00099     /// Get scope this handle belongs to
00100     CScope& GetScope(void) const;
00101 
00102     /// Get id which can be used to access this bioseq handle
00103     /// Throws an exception if none is available
00104     CConstRef<CSeq_id> GetSeqId(void) const;
00105     /// Get id used to obtain this bioseq handle
00106     CConstRef<CSeq_id> GetInitialSeqIdOrNull(void) const;
00107     
00108     /// Get unique object id
00109     const CBioObjectId& GetBioObjectId(void) const;
00110 
00111 
00112     /// Get handle of id used to obtain this bioseq handle
00113     const CSeq_id_Handle& GetSeq_id_Handle(void) const;
00114 
00115     /// Get any CSeq_id_Handle handle that can be used to access this bioseq
00116     /// Use GetSeq_id_Handle() if it's non-null
00117     CSeq_id_Handle GetAccessSeq_id_Handle(void) const;
00118 
00119     /// State of bioseq handle.
00120     enum EBioseqStateFlags {
00121         fState_none          = 0,
00122         fState_suppress_temp = 1 << 0,
00123         fState_suppress_perm = 1 << 1,
00124         fState_suppress      = fState_suppress_temp |
00125                                fState_suppress_perm,
00126         fState_dead          = 1 << 2,
00127         fState_confidential  = 1 << 3,
00128         fState_withdrawn     = 1 << 4,
00129         fState_no_data       = 1 << 5, 
00130         fState_conflict      = 1 << 6,
00131         fState_not_found     = 1 << 7,
00132         fState_other_error   = 1 << 8
00133     };
00134     typedef int TBioseqStateFlags;
00135 
00136     /// Get state of the bioseq. May be used with an empty bioseq handle
00137     /// to check why the bioseq retrieval failed.
00138     TBioseqStateFlags GetState(void) const;
00139     bool State_SuppressedTemp(void) const;
00140     bool State_SuppressedPerm(void) const;
00141     bool State_Suppressed(void) const;
00142     bool State_Confidential(void) const;
00143     bool State_Dead(void) const;
00144     bool State_Withdrawn(void) const;
00145     bool State_NoData(void) const;
00146     bool State_Conflict(void) const;
00147     bool State_NotFound(void) const;
00148 
00149     /// Check if this id can be used to obtain this bioseq handle
00150     bool IsSynonym(const CSeq_id& id) const;
00151     bool IsSynonym(const CSeq_id_Handle& idh) const;
00152 
00153     /// Get the bioseq's synonyms
00154     CConstRef<CSynonymsSet> GetSynonyms(void) const;
00155 
00156     /// Get parent Seq-entry handle
00157     ///
00158     /// @sa 
00159     ///     GetSeq_entry_Handle()
00160     CSeq_entry_Handle GetParentEntry(void) const;
00161 
00162     /// Return a handle for the parent Bioseq-set, or null handle
00163     CBioseq_set_Handle GetParentBioseq_set(void) const;
00164 
00165     /// Get parent Seq-entry handle
00166     ///
00167     /// @sa 
00168     ///     GetParentEntry()
00169     CSeq_entry_Handle GetSeq_entry_Handle(void) const;
00170 
00171     /// Get top level Seq-entry handle
00172     CSeq_entry_Handle GetTopLevelEntry(void) const;
00173 
00174     /// Get 'edit' version of handle
00175     CBioseq_EditHandle GetEditHandle(void) const;
00176 
00177     /// Bioseq core -- using partially populated CBioseq
00178     typedef CConstRef<CBioseq> TBioseqCore;
00179     
00180     /// Get bioseq core structure
00181     TBioseqCore GetBioseqCore(void) const;
00182     
00183     /// Get the complete bioseq
00184     CConstRef<CBioseq> GetCompleteBioseq(void) const;
00185 
00186     /// Unified interface for templates
00187     typedef CBioseq TObject;
00188     CConstRef<TObject> GetCompleteObject(void) const;
00189     CConstRef<TObject> GetObjectCore(void) const;
00190 
00191     //////////////////////////////////////////////////////////////////
00192     // Bioseq members
00193     // id
00194     typedef vector<CSeq_id_Handle> TId;
00195     bool IsSetId(void) const;
00196     bool CanGetId(void) const;
00197     const TId& GetId(void) const;
00198     // descr
00199     typedef CSeq_descr TDescr;
00200     bool IsSetDescr(void) const;
00201     bool CanGetDescr(void) const;
00202     const TDescr& GetDescr(void) const;
00203     // inst
00204     typedef CSeq_inst TInst;
00205     bool IsSetInst(void) const;
00206     bool CanGetInst(void) const;
00207     const TInst& GetInst(void) const;
00208     // inst.repr
00209     typedef TInst::TRepr TInst_Repr;
00210     bool IsSetInst_Repr(void) const;
00211     bool CanGetInst_Repr(void) const;
00212     TInst_Repr GetInst_Repr(void) const;
00213     // inst.mol
00214     typedef TInst::TMol TInst_Mol;
00215     bool IsSetInst_Mol(void) const;
00216     bool CanGetInst_Mol(void) const;
00217     TInst_Mol GetInst_Mol(void) const;
00218     // inst.length
00219     typedef TInst::TLength TInst_Length;
00220     bool IsSetInst_Length(void) const;
00221     bool CanGetInst_Length(void) const;
00222     TInst_Length GetInst_Length(void) const;
00223     TSeqPos GetBioseqLength(void) const; // try to calculate it if not set
00224     // inst.fuzz
00225     typedef TInst::TFuzz TInst_Fuzz;
00226     bool IsSetInst_Fuzz(void) const;
00227     bool CanGetInst_Fuzz(void) const;
00228     const TInst_Fuzz& GetInst_Fuzz(void) const;
00229     // inst.topology
00230     typedef TInst::TTopology TInst_Topology;
00231     bool IsSetInst_Topology(void) const;
00232     bool CanGetInst_Topology(void) const;
00233     TInst_Topology GetInst_Topology(void) const;
00234     // inst.strand
00235     typedef TInst::TStrand TInst_Strand;
00236     bool IsSetInst_Strand(void) const;
00237     bool CanGetInst_Strand(void) const;
00238     TInst_Strand GetInst_Strand(void) const;
00239     // inst.seq-data
00240     typedef TInst::TSeq_data TInst_Seq_data;
00241     bool IsSetInst_Seq_data(void) const;
00242     bool CanGetInst_Seq_data(void) const;
00243     const TInst_Seq_data& GetInst_Seq_data(void) const;
00244     // inst.ext
00245     typedef TInst::TExt TInst_Ext;
00246     bool IsSetInst_Ext(void) const;
00247     bool CanGetInst_Ext(void) const;
00248     const TInst_Ext& GetInst_Ext(void) const;
00249     // inst.hist
00250     typedef TInst::THist TInst_Hist;
00251     bool IsSetInst_Hist(void) const;
00252     bool CanGetInst_Hist(void) const;
00253     const TInst_Hist& GetInst_Hist(void) const;
00254     // annot
00255     bool HasAnnots(void) const;
00256 
00257     // Check sequence type
00258     typedef CSeq_inst::TMol TMol;
00259     TMol GetSequenceType(void) const;
00260     bool IsProtein(void) const;
00261     bool IsNucleotide(void) const;
00262 
00263     //////////////////////////////////////////////////////////////////
00264     // Old interface:
00265 
00266     /// Go up to a certain complexity level (or the nearest level of the same
00267     /// priority if the required class is not found):
00268     /// level   class
00269     /// 0       not-set (0) ,
00270     /// 3       nuc-prot (1) ,       -- nuc acid and coded proteins
00271     /// 2       segset (2) ,         -- segmented sequence + parts
00272     /// 2       conset (3) ,         -- constructed sequence + parts
00273     /// 1       parts (4) ,          -- parts for 2 or 3
00274     /// 1       gibb (5) ,           -- geninfo backbone
00275     /// 1       gi (6) ,             -- geninfo
00276     /// 5       genbank (7) ,        -- converted genbank
00277     /// 3       pir (8) ,            -- converted pir
00278     /// 4       pub-set (9) ,        -- all the seqs from a single publication
00279     /// 4       equiv (10) ,         -- a set of equivalent maps or seqs
00280     /// 3       swissprot (11) ,     -- converted SWISSPROT
00281     /// 3       pdb-entry (12) ,     -- a complete PDB entry
00282     /// 4       mut-set (13) ,       -- set of mutations
00283     /// 4       pop-set (14) ,       -- population study
00284     /// 4       phy-set (15) ,       -- phylogenetic study
00285     /// 4       eco-set (16) ,       -- ecological sample study
00286     /// 4       gen-prod-set (17) ,  -- genomic products, chrom+mRNa+protein
00287     /// 4       wgs-set (18) ,       -- whole genome shotgun project
00288     /// 0       other (255)
00289     CSeq_entry_Handle GetComplexityLevel(CBioseq_set::EClass cls) const;
00290     
00291     /// Return level with exact complexity, or empty handle if not found.
00292     CSeq_entry_Handle GetExactComplexityLevel(CBioseq_set::EClass cls) const;
00293 
00294     /// Get some values from core:
00295     TMol GetBioseqMolType(void) const;
00296     bool IsNa(void) const;
00297     bool IsAa(void) const;
00298 
00299     /// Get sequence map.
00300     const CSeqMap& GetSeqMap(void) const;
00301 
00302     /// Segment search flags
00303     enum EFindSegment {
00304         eFindSegment_NoLimit,   ///< No limit on resolving seq-map
00305         eFindSegment_LimitTSE   ///< Resolve in the parent TSE only
00306     };
00307 
00308     /// Check if the seq-id describes a segment of the bioseq
00309     ///
00310     /// @param id
00311     ///  Seq-id to be checked for being a segment of the handle.
00312     ///
00313     /// @param resolve_depth
00314     ///  Depth of resolving segments. Zero allows to check only top-level
00315     ///  segments.
00316     ///
00317     /// @param limit_flag
00318     ///  Allow/prohibit resolving far references. By default all segments are
00319     ///  resolved. If the flag is set to eFindSegment_LimitTSE, only near
00320     ///  references are checked.
00321     bool ContainsSegment(const CSeq_id& id,
00322                          size_t resolve_depth = kMax_Int,
00323                          EFindSegment limit_flag = eFindSegment_NoLimit) const;
00324     bool ContainsSegment(CSeq_id_Handle id,
00325                          size_t resolve_depth = kMax_Int,
00326                          EFindSegment limit_flag = eFindSegment_NoLimit) const;
00327     bool ContainsSegment(const CBioseq_Handle& part,
00328                          size_t resolve_depth = kMax_Int,
00329                          EFindSegment limit_flag = eFindSegment_NoLimit) const;
00330 
00331     /// CSeqVector constructor flags
00332     enum EVectorCoding {
00333         eCoding_NotSet, ///< Use original coding - DANGEROUS! - may change
00334         eCoding_Ncbi,   ///< Set coding to binary coding (Ncbi4na or Ncbistdaa)
00335         eCoding_Iupac   ///< Set coding to printable coding (Iupacna or Iupacaa)
00336     };
00337     enum EVectorStrand {
00338         eStrand_Plus,   ///< Plus strand
00339         eStrand_Minus   ///< Minus strand
00340     };
00341 
00342     /// Get sequence: Iupacna or Iupacaa if use_iupac_coding is true
00343     CSeqVector GetSeqVector(EVectorCoding coding,
00344                             ENa_strand strand = eNa_strand_plus) const;
00345     /// Get sequence
00346     CSeqVector GetSeqVector(ENa_strand strand = eNa_strand_plus) const;
00347     /// Get sequence: Iupacna or Iupacaa if use_iupac_coding is true
00348     CSeqVector GetSeqVector(EVectorCoding coding, EVectorStrand strand) const;
00349     /// Get sequence
00350     CSeqVector GetSeqVector(EVectorStrand strand) const;
00351 
00352     /// Return CSeq_loc referencing the given range and strand on the bioseq
00353     /// If start == 0, stop == 0, and strand == eNa_strand_unknown,
00354     /// CSeq_loc will be of type 'whole'.
00355     CRef<CSeq_loc> GetRangeSeq_loc(TSeqPos start,
00356                                    TSeqPos stop,
00357                                    ENa_strand strand
00358                                    = eNa_strand_unknown) const;
00359 
00360     /// Map a seq-loc from the bioseq's segment to the bioseq
00361     CRef<CSeq_loc> MapLocation(const CSeq_loc& loc) const;
00362 
00363     // Utility methods/operators
00364 
00365     /// Check if handles point to the same bioseq
00366     ///
00367     /// @sa
00368     ///     operator!=()
00369     bool operator== (const CBioseq_Handle& h) const;
00370 
00371     // Check if handles point to different bioseqs
00372     ///
00373     /// @sa
00374     ///     operator==()
00375     bool operator!= (const CBioseq_Handle& h) const;
00376 
00377     /// For usage in containers
00378     bool operator<  (const CBioseq_Handle& h) const;
00379 
00380     /// Check if handle points to a bioseq and is not removed
00381     ///
00382     /// @sa
00383     ///    operator !()
00384     DECLARE_OPERATOR_BOOL(m_Info.IsValid());
00385 
00386     /// Check if handle points to a removed bioseq
00387     bool IsRemoved(void) const;
00388 
00389     /// Get CTSE_Handle of containing TSE
00390     const CTSE_Handle& GetTSE_Handle(void) const;
00391 
00392 
00393     // these methods are for cross scope move only.
00394     /// Copy current bioseq into seq-entry
00395     /// 
00396     /// @param entry
00397     ///  Current bioseq will be inserted into seq-entry pointed 
00398     ///  by this handle. 
00399     //   If seq-entry is not seqset exception will be thrown
00400     /// @param index
00401     ///  Start index is 0 and -1 means end
00402     ///
00403     /// @return
00404     ///  Edit handle to inserted bioseq
00405     CBioseq_EditHandle CopyTo(const CSeq_entry_EditHandle& entry,
00406                               int index = -1) const;
00407 
00408     /// Copy current bioseq into seqset
00409     /// 
00410     /// @param entry
00411     ///  Current bioseq will be inserted into seqset pointed 
00412     ///  by this handle. 
00413     /// @param index
00414     ///  Start index is 0 and -1 means end
00415     ///
00416     /// @return
00417     ///  Edit handle to inserted bioseq
00418     CBioseq_EditHandle CopyTo(const CBioseq_set_EditHandle& seqset,
00419                               int index = -1) const;
00420 
00421     /// Copy current bioseq into seq-entry and set seq-entry as bioseq
00422     /// 
00423     /// @param entry
00424     ///  Seq-entry pointed by entry handle will be set to bioseq
00425     ///
00426     /// @return
00427     ///  Edit handle to inserted bioseq
00428     CBioseq_EditHandle CopyToSeq(const CSeq_entry_EditHandle& entry) const;
00429 
00430     /// Register argument bioseq as used by this bioseq, so it will be
00431     /// released by scope only after this bioseq is released.
00432     ///
00433     /// @param bh
00434     ///  Used bioseq handle
00435     ///
00436     /// @return
00437     ///  True if argument bioseq was successfully registered as 'used'.
00438     ///  False if argument bioseq was not registered as 'used'.
00439     ///  Possible reasons:
00440     ///   Circular reference in 'used' tree.
00441     bool AddUsedBioseq(const CBioseq_Handle& bh) const;
00442 
00443     /// Feature fetch policy describes when to look for features on sequence
00444     /// segments.
00445     enum EFeatureFetchPolicy {
00446         eFeatureFetchPolicy_default = 0,
00447         eFeatureFetchPolicy_only_near = 1
00448     };
00449     EFeatureFetchPolicy GetFeatureFetchPolicy(void) const;
00450 
00451 protected:
00452     friend class CScope_Impl;
00453     friend class CSynonymsSet;
00454     friend class CSeq_entry_EditHandle;
00455 
00456     typedef CBioseq_ScopeInfo TScopeInfo;
00457     typedef CScopeInfo_Ref<TScopeInfo> TLock;
00458 
00459     CBioseq_Handle(const CSeq_id_Handle& id, const TScopeInfo& info);
00460     CBioseq_Handle(const CSeq_id_Handle& id, const TLock& lock);
00461 
00462     CScope_Impl& x_GetScopeImpl(void) const;
00463     const CBioseq_ScopeInfo& x_GetScopeInfo(void) const;
00464 
00465     CSeq_id_Handle  m_Handle_Seq_id;
00466     TLock           m_Info;
00467 
00468 public: // non-public section
00469     const CBioseq_Info& x_GetInfo(void) const;
00470 };
00471 
00472 
00473 /////////////////////////////////////////////////////////////////////////////
00474 ///
00475 ///  CBioseq_EditHandle --
00476 ///
00477 ///  Proxy to access and edit the bioseq data
00478 ///
00479 
00480 class  CBioseq_EditHandle : public CBioseq_Handle
00481 {
00482 public:
00483     CBioseq_EditHandle(void);
00484     /// create edit interface class to the object which already allows editing
00485     /// throw an exception if the argument is not in editing mode
00486     explicit CBioseq_EditHandle(const CBioseq_Handle& h);
00487     
00488     /// Navigate object tree
00489     CSeq_entry_EditHandle GetParentEntry(void) const;
00490 
00491     // Modification functions
00492 
00493     //////////////////////////////////////////////////////////////////
00494     // Bioseq members
00495     // id
00496     void ResetId(void) const;
00497     bool AddId(const CSeq_id_Handle& id) const;
00498     bool RemoveId(const CSeq_id_Handle& id) const;
00499     // descr
00500     void ResetDescr(void) const;
00501     void SetDescr(TDescr& v) const;
00502     TDescr& SetDescr(void) const;
00503     bool AddSeqdesc(CSeqdesc& d) const;
00504     CRef<CSeqdesc> RemoveSeqdesc(const CSeqdesc& d) const;
00505     void AddSeq_descr(TDescr& v) const;
00506     // inst
00507     void SetInst(TInst& v) const;
00508     // inst.repr
00509     void SetInst_Repr(TInst_Repr v) const;
00510     // inst.mol
00511     void SetInst_Mol(TInst_Mol v) const;
00512     // inst.length
00513     void SetInst_Length(TInst_Length v) const;
00514     // inst.fuzz
00515     void SetInst_Fuzz(TInst_Fuzz& v) const;
00516     // inst.topology
00517     void SetInst_Topology(TInst_Topology v) const;
00518     // inst.strand
00519     void SetInst_Strand(TInst_Strand v) const;
00520     // inst.seq-data
00521     void SetInst_Seq_data(TInst_Seq_data& v) const;
00522     // inst.ext
00523     void SetInst_Ext(TInst_Ext& v) const;
00524     // inst.hist
00525     void SetInst_Hist(TInst_Hist& v) const;
00526     // annot
00527     //////////////////////////////////////////////////////////////////
00528 
00529 
00530     /// Attach an annotation
00531     ///
00532     /// @param annot
00533     ///  Reference to this annotation will be attached
00534     ///
00535     /// @return
00536     ///  Edit handle to the attached annotation
00537     ///
00538     /// @sa
00539     ///  CopyAnnot()
00540     ///  TakeAnnot()
00541     CSeq_annot_EditHandle AttachAnnot(CSeq_annot& annot) const;
00542 
00543     /// Attach a copy of the annotation
00544     ///
00545     /// @param annot
00546     ///  Copy of the annotation pointed by this handle will be attached
00547     ///
00548     /// @return
00549     ///  Edit handle to the attached annotation
00550     ///
00551     /// @sa
00552     ///  AttachAnnot()
00553     ///  TakeAnnot()
00554     CSeq_annot_EditHandle CopyAnnot(const CSeq_annot_Handle& annot) const;
00555 
00556     /// Remove the annotation from its location and attach to current one
00557     ///
00558     /// @param annot
00559     ///  An annotation  pointed by this handle will be removed and attached
00560     ///
00561     /// @return
00562     ///  Edit handle to the attached annotation
00563     ///
00564     /// @sa
00565     ///  AttachAnnot()
00566     ///  CopyAnnot()
00567     CSeq_annot_EditHandle TakeAnnot(const CSeq_annot_EditHandle& annot) const;
00568 
00569     // Tree modification, target handle must be in the same TSE
00570     // entry.Which() must be e_not_set or e_Set.
00571 
00572     /// Move current bioseq into seq-entry
00573     /// 
00574     /// @param entry
00575     ///  Current bioseq will be inserted into seq-entry pointed 
00576     ///  by this handle. 
00577     //   If seq-entry is not seqset exception will be thrown
00578     /// @param index
00579     ///  Start index is 0 and -1 means end
00580     ///
00581     /// @return
00582     ///  Edit handle to inserted bioseq
00583     CBioseq_EditHandle MoveTo(const CSeq_entry_EditHandle& entry,
00584                               int index = -1) const;
00585 
00586     /// Move current bioseq into seqset
00587     /// 
00588     /// @param entry
00589     ///  Current bioseq will be inserted into seqset pointed 
00590     ///  by this handle. 
00591     /// @param index
00592     ///  Start index is 0 and -1 means end
00593     ///
00594     /// @return
00595     ///  Edit handle to inserted bioseq
00596     CBioseq_EditHandle MoveTo(const CBioseq_set_EditHandle& seqset,
00597                               int index = -1) const;
00598 
00599     /// Move current bioseq into seq-entry and set seq-entry as bioseq
00600     /// 
00601     /// @param entry
00602     ///  seq-entry pointed by entry handle will be set to bioseq
00603     ///
00604     /// @return
00605     ///  Edit handle to inserted bioseq
00606     CBioseq_EditHandle MoveToSeq(const CSeq_entry_EditHandle& entry) const;
00607 
00608     /// Remove current bioseq from its location
00609     enum ERemoveMode {
00610         eRemoveSeq_entry,
00611         eKeepSeq_entry
00612     };
00613     void Remove(ERemoveMode mode = eRemoveSeq_entry) const;
00614 
00615     /// Get CSeqMap object for sequence editing
00616     CSeqMap& SetSeqMap(void) const;
00617 
00618 protected:
00619     friend class CScope_Impl;
00620 
00621     CBioseq_EditHandle(const CSeq_id_Handle& id, TScopeInfo& info);
00622     CBioseq_EditHandle(const CSeq_id_Handle& id, const TLock& lock);
00623 
00624     void x_Detach(void) const;
00625 
00626 public: // non-public section
00627     CBioseq_ScopeInfo& x_GetScopeInfo(void) const;
00628     CBioseq_Info& x_GetInfo(void) const;
00629 
00630 public:
00631     void x_RealResetDescr(void) const;
00632     void x_RealSetDescr(TDescr& v) const;
00633     bool x_RealAddSeqdesc(CSeqdesc& d) const;
00634     CRef<CSeqdesc> x_RealRemoveSeqdesc(const CSeqdesc& d) const;
00635     void x_RealAddSeq_descr(TDescr& v) const;
00636 
00637     void x_RealResetId(void) const;
00638     bool x_RealAddId(const CSeq_id_Handle& id) const;
00639     bool x_RealRemoveId(const CSeq_id_Handle& id) const;
00640 
00641     void x_RealSetInst(TInst& v) const;
00642     void x_RealSetInst_Repr(TInst_Repr v) const;
00643     void x_RealSetInst_Mol(TInst_Mol v) const;
00644     void x_RealSetInst_Length(TInst_Length v) const;
00645     void x_RealSetInst_Fuzz(TInst_Fuzz& v) const;
00646     void x_RealSetInst_Topology(TInst_Topology v) const;
00647     void x_RealSetInst_Strand(TInst_Strand v) const;
00648     void x_RealSetInst_Seq_data(TInst_Seq_data& v) const;
00649     void x_RealSetInst_Ext(TInst_Ext& v) const;
00650     void x_RealSetInst_Hist(TInst_Hist& v) const;
00651     void x_RealResetInst() const;
00652     void x_RealResetInst_Repr() const;
00653     void x_RealResetInst_Mol() const;
00654     void x_RealResetInst_Length() const;
00655     void x_RealResetInst_Fuzz() const;
00656     void x_RealResetInst_Topology() const;
00657     void x_RealResetInst_Strand() const;
00658     void x_RealResetInst_Seq_data() const;
00659     void x_RealResetInst_Ext() const;
00660     void x_RealResetInst_Hist() const;
00661 
00662 };
00663 
00664 
00665 /////////////////////////////////////////////////////////////////////////////
00666 // CBioseq_Handle inline methods
00667 /////////////////////////////////////////////////////////////////////////////
00668 
00669 
00670 inline
00671 CBioseq_Handle::CBioseq_Handle(void)
00672 {
00673 }
00674 
00675 
00676 inline
00677 bool CBioseq_Handle::State_SuppressedTemp(void) const
00678 {
00679     return (GetState() & fState_suppress_temp) != 0;
00680 }
00681 
00682 
00683 inline
00684 bool CBioseq_Handle::State_SuppressedPerm(void) const
00685 {
00686     return (GetState() & fState_suppress_perm) != 0;
00687 }
00688 
00689 
00690 inline
00691 bool CBioseq_Handle::State_Suppressed(void) const
00692 {
00693     return (GetState() & fState_suppress) != 0;
00694 }
00695 
00696 
00697 inline
00698 bool CBioseq_Handle::State_Confidential(void) const
00699 {
00700     return (GetState() & fState_confidential) != 0;
00701 }
00702 
00703 
00704 inline
00705 bool CBioseq_Handle::State_Dead(void) const
00706 {
00707     return (GetState() & fState_dead) != 0;
00708 }
00709 
00710 
00711 inline
00712 bool CBioseq_Handle::State_Withdrawn(void) const
00713 {
00714     return (GetState() & fState_withdrawn) != 0;
00715 }
00716 
00717 
00718 inline
00719 bool CBioseq_Handle::State_NoData(void) const
00720 {
00721     return (GetState() & fState_no_data) != 0;
00722 }
00723 
00724 
00725 inline
00726 bool CBioseq_Handle::State_Conflict(void) const
00727 {
00728     return (GetState() & fState_conflict) != 0;
00729 }
00730 
00731 
00732 inline
00733 bool CBioseq_Handle::State_NotFound(void) const
00734 {
00735     return (GetState() & fState_not_found) != 0;
00736 }
00737 
00738 
00739 inline
00740 const CTSE_Handle& CBioseq_Handle::GetTSE_Handle(void) const
00741 {
00742     return m_Info.GetObject().GetTSE_Handle();
00743 }
00744 
00745 
00746 inline
00747 bool CBioseq_Handle::IsRemoved(void) const
00748 {
00749     return m_Info && m_Info.GetPointerOrNull()->IsDetached();
00750 }
00751 
00752 
00753 inline
00754 const CSeq_id_Handle& CBioseq_Handle::GetSeq_id_Handle(void) const
00755 {
00756     return m_Handle_Seq_id;
00757 }
00758 
00759 
00760 inline
00761 CScope& CBioseq_Handle::GetScope(void) const 
00762 {
00763     return GetTSE_Handle().GetScope();
00764 }
00765 
00766 
00767 inline
00768 CScope_Impl& CBioseq_Handle::x_GetScopeImpl(void) const 
00769 {
00770     return GetTSE_Handle().x_GetScopeImpl();
00771 }
00772 
00773 
00774 inline
00775 bool CBioseq_Handle::operator==(const CBioseq_Handle& h) const
00776 {
00777     // No need to check m_TSE, because m_ScopeInfo is scope specific too.
00778     return m_Info == h.m_Info;
00779 }
00780 
00781 
00782 inline
00783 bool CBioseq_Handle::operator<(const CBioseq_Handle& h) const
00784 {
00785     return m_Info < h.m_Info;
00786 }
00787 
00788 
00789 inline
00790 bool CBioseq_Handle::operator!=(const CBioseq_Handle& h) const
00791 {
00792     return m_Info != h.m_Info;
00793 }
00794 
00795 
00796 inline
00797 CBioseq_ScopeInfo& CBioseq_EditHandle::x_GetScopeInfo(void) const
00798 {
00799     return const_cast<CBioseq_ScopeInfo&>(CBioseq_Handle::x_GetScopeInfo());
00800 }
00801 
00802 
00803 inline
00804 CBioseq_Info& CBioseq_EditHandle::x_GetInfo(void) const
00805 {
00806     return const_cast<CBioseq_Info&>(CBioseq_Handle::x_GetInfo());
00807 }
00808 
00809 
00810 inline
00811 CConstRef<CBioseq> CBioseq_Handle::GetCompleteObject(void) const
00812 {
00813     return GetCompleteBioseq();
00814 }
00815 
00816 
00817 inline
00818 CConstRef<CBioseq> CBioseq_Handle::GetObjectCore(void) const
00819 {
00820     return GetBioseqCore();
00821 }
00822 
00823 
00824 inline
00825 CBioseq_Handle::TMol CBioseq_Handle::GetSequenceType(void) const
00826 {
00827     return GetInst_Mol();
00828 }
00829 
00830 
00831 inline
00832 bool CBioseq_Handle::IsProtein(void) const
00833 {
00834     return CSeq_inst::IsAa(GetSequenceType());
00835 }
00836 
00837 
00838 inline
00839 bool CBioseq_Handle::IsNucleotide(void) const
00840 {
00841     return CSeq_inst::IsNa(GetSequenceType());
00842 }
00843 
00844 
00845 /* @} */
00846 
00847 
00848 END_SCOPE(objects)
00849 END_NCBI_SCOPE
00850 
00851 #endif  // BIOSEQ_HANDLE__HPP
00852 
00853 

Generated on Wed Dec 9 03:38:23 2009 for NCBI C++ ToolKit by  doxygen 1.4.6
Modified on Wed Dec 09 08:17:40 2009 by modify_doxy.py rev. 173732