📄 seq_loc.hpp
字号:
/* * =========================================================================== * PRODUCTION $Log: Seq_loc.hpp,v $ * PRODUCTION Revision 1000.3 2004/06/01 19:30:53 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.37 * PRODUCTION * =========================================================================== *//* $Id: Seq_loc.hpp,v 1000.3 2004/06/01 19:30:53 gouriano Exp $ * =========================================================================== * * PUBLIC DOMAIN NOTICE * National Center for Biotechnology Information * * This software/database is a "United States Government Work" under the * terms of the United States Copyright Act. It was written as part of * the author's official duties as a United States Government employee and * thus cannot be copyrighted. This software/database is freely available * to the public for use. The National Library of Medicine and the U.S. * Government have not placed any restriction on its use or reproduction. * * Although all reasonable efforts have been taken to ensure the accuracy * and reliability of the software and data, the NLM and the U.S. * Government do not and cannot warrant the performance or results that * may be obtained by using this software or data. The NLM and the U.S. * Government disclaim all warranties, express or implied, including * warranties of performance, merchantability or fitness for any particular * purpose. * * Please cite the author in any work or product based on this material. * * =========================================================================== * * Author: Cliff Clausen, Eugene Vasilchenko * * File Description: * ....... * * Remark: * This code was originally generated by application DATATOOL * using specifications from the ASN data definition file * 'seqloc.asn'. * * =========================================================================== */#ifndef OBJECTS_SEQLOC_SEQ_LOC_HPP#define OBJECTS_SEQLOC_SEQ_LOC_HPP// generated includes#include <objects/seqloc/Seq_loc_.hpp>#include <objects/seqloc/Seq_loc_mix.hpp>#include <objects/seqloc/Packed_seqpnt.hpp>#include <objects/seqloc/Packed_seqint.hpp>#include <objects/seqloc/Seq_id.hpp>#include <objects/general/Int_fuzz.hpp>//#include <corelib/ncbiexpt.hpp>#include <util/range.hpp>#include <vector>BEGIN_NCBI_SCOPEBEGIN_objects_SCOPE // namespace ncbi::objects::class NCBI_SEQLOC_EXPORT CSeq_loc : public CSeq_loc_Base{public: typedef CSeq_loc_Base Tparent; typedef CPacked_seqpnt_Base::TPoints TPoints; typedef CPacked_seqint_Base::Tdata TIntervals; typedef CSeq_loc_mix_Base::Tdata TLocations; typedef CSeq_id TId; typedef ENa_strand TStrand; typedef TSeqPos TPoint; typedef CPacked_seqint::TRanges TRanges; // constructor CSeq_loc(void); CSeq_loc(E_Choice index); CSeq_loc(TId& id, TPoint point, TStrand strand = eNa_strand_unknown); CSeq_loc(TId& id, const TPoints& points, TStrand strand = eNa_strand_unknown); CSeq_loc(TId& id, TPoint from, TPoint to, TStrand strand = eNa_strand_unknown); CSeq_loc(TId& id, TRanges ivals, TStrand strand = eNa_strand_unknown); // destructor virtual ~CSeq_loc(void); // See related functions in util/sequence.hpp: // // TSeqPos GetLength(const CSeq_loc&, CScope*) // bool IsOneBioseq(const CSeq_loc&, CScope*) // const CSeq_id& GetId(const CSeq_loc&, CScope*) // TSeqPos GetStart(const CSeq_loc&, CScope*) // sequence::ECompare Compare(const CSeq_loc&, CSeq_loc&, CScope*) // sequence::SeqLocMerge(...) // typedef CRange<TSeqPos> TRange; TRange GetTotalRange(void) const; void InvalidateTotalRangeCache(void); // Special case for circular sequences. No ID is checked for // circular locations. If the sequence is not circular // (seq_len == kInvalidSeqPos) all functions work like GetTotalRange() TSeqPos GetStart(TSeqPos seq_len) const; TSeqPos GetEnd(TSeqPos seq_len) const; TSeqPos GetCircularLength(TSeqPos seq_len) const; // Appends a label suitable for display (e.g., error messages) // label must point to an existing string object // Method just returns if label is null. Note this label is NOT // GenBank-style. void GetLabel(string* label) const; // check left (5') or right (3') end of location for e_Lim fuzz bool IsPartialLeft (void) const; bool IsPartialRight (void) const; // set / remove e_Lim fuzz on left (5') or right (3') end void SetPartialLeft (bool val); void SetPartialRight(bool val); // set the 'id' field in all parts of this location void SetId(CSeq_id& id); // stores id void SetId(const CSeq_id& id); // stores a new copy of id // check that the 'id' field in all parts of the location is the same // as the specifies id. // if the id parameter is NULL will return the location's id (if unique) void CheckId(const CSeq_id*& id) const; void InvalidateIdCache(void); virtual void Assign(const CSerialObject& source, ESerialRecursionMode how = eRecursive); virtual bool Equals(const CSerialObject& object, ESerialRecursionMode how = eRecursive) const; // Compare locations if they are defined on the same single sequence // or throw exception. int Compare(const CSeq_loc& loc) const; void Add(const CSeq_loc& other);private: // Prohibit copy constructor & assignment operator CSeq_loc(const CSeq_loc&); CSeq_loc& operator= (const CSeq_loc&); TRange x_UpdateTotalRange(void) const; TRange x_CalculateTotalRangeCheckId(const CSeq_id*& id) const; void x_CheckId(const CSeq_id*& id) const; void x_UpdateId(const CSeq_id*& total_id, const CSeq_id* id) const; void x_ChangeToMix(const CSeq_loc& other); void x_ChangeToPackedInt(const CSeq_loc& other); void x_ChangeToPackedPnt(const CSeq_loc& other); void x_InvalidateCache(void); enum { kDirtyCache = -2, kSeveralIds = -3 }; mutable TRange m_TotalRangeCache; // Seq-id for the whole seq-loc or null if multiple IDs were found mutable const CSeq_id* m_IdCache;};// Seq-loc iterator class -- iterates all intervals from a seq-loc// in the correct order.class NCBI_SEQLOC_EXPORT CSeq_loc_CI{public: // Options for empty locations processing enum EEmptyFlag { eEmpty_Skip, // ignore empty locations eEmpty_Allow // treat empty locations as usual }; CSeq_loc_CI(void); CSeq_loc_CI(const CSeq_loc& loc, EEmptyFlag empty_flag = eEmpty_Skip); ~CSeq_loc_CI(void); CSeq_loc_CI(const CSeq_loc_CI& iter); CSeq_loc_CI& operator= (const CSeq_loc_CI& iter); CSeq_loc_CI& operator++ (void); operator bool (void) const; typedef CRange<TSeqPos> TRange; // Get seq_id of the current location const CSeq_id& GetSeq_id(void) const; // Get the range TRange GetRange(void) const; // Get strand ENa_strand GetStrand(void) const; // Get seq-loc for the current interval const CSeq_loc& GetSeq_loc(void) const; // Return null if non-fuzzy const CInt_fuzz* GetFuzzFrom(void) const; const CInt_fuzz* GetFuzzTo (void) const; // True if the current location is a whole sequence bool IsWhole(void) const; // True if the current location is empty bool IsEmpty(void) const; // True if the current location is a single point bool IsPoint(void) const;private: // Check the iterator position bool x_IsValid(void) const; // Check the position, throw exception if not valid void x_CheckNotValid(const char* where) const; void x_ThrowNotValid(const char* where) const; // Process the location, fill the list void x_ProcessLocation(const CSeq_loc& loc); // Simple location structure: id/from/to struct SLoc_Info { SLoc_Info(void); CConstRef<CSeq_id> m_Id; TRange m_Range; ENa_strand m_Strand; // The original seq-loc for the interval CConstRef<CSeq_loc> m_Loc; CConstRef<CInt_fuzz> m_Fuzz[2]; }; typedef list<SLoc_Info> TLocList; // Prevent seq-loc destruction CConstRef<CSeq_loc> m_Location; // List of intervals TLocList m_LocList; // Current interval TLocList::const_iterator m_CurLoc; // Empty locations processing option EEmptyFlag m_EmptyFlag;};/////////////////// CSeq_loc inline methodsinlinevoid CSeq_loc::InvalidateTotalRangeCache(void){ m_TotalRangeCache.SetFrom(TSeqPos(kDirtyCache));}inline void CSeq_loc::InvalidateIdCache(void){ m_IdCache = 0;}inline void CSeq_loc::x_InvalidateCache(void){ InvalidateTotalRangeCache(); InvalidateIdCache();}// constructorinlineCSeq_loc::CSeq_loc(void){ x_InvalidateCache();}inlineCSeq_loc::TRange CSeq_loc::GetTotalRange(void) const{ TRange range = m_TotalRangeCache;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -