⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 feature.hpp

📁 ncbi源码
💻 HPP
字号:
/* * =========================================================================== * PRODUCTION $Log: feature.hpp,v $ * PRODUCTION Revision 1000.0  2004/06/01 19:54:56  gouriano * PRODUCTION PRODUCTION: IMPORTED [GCC34_MSVC7] Dev-tree R1.4 * PRODUCTION * =========================================================================== */#ifndef GUI_OBJUTILS___FEATURE__HPP#define GUI_OBJUTILS___FEATURE__HPP/*  $Id: feature.hpp,v 1000.0 2004/06/01 19:54:56 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. * * =========================================================================== * * Authors:  Mike DiCuccio * * File Description: *    CLayoutFeat -- utility class to arrange CSeq_feat objects in hierarchical *                (tree) order. */#include <corelib/ncbiobj.hpp>#include <gui/gui.hpp>#include <gui/objutils/layout.hpp>#include <objmgr/feat_ci.hpp>#include <objects/seqfeat/SeqFeatData.hpp>#include <objects/seqfeat/Seq_feat.hpp>#include <objects/seqloc/Seq_loc.hpp>#include <list>/** @addtogroup GUI_OBJUTILS * * @{ */BEGIN_NCBI_SCOPE//// Class for storing a set of nested features.// A feature describes the genetic location in true gene coordinates of any// sort of genetic object (gene / protein / RNA / etc).  Each feature has an// overall extent as well as a series of subregions//class NCBI_GUIOBJUTILS_EXPORT CLayoutFeat : public CLayoutObject{public:    typedef vector< CRef<CLayoutFeat> > TFeatList;    // ctors    CLayoutFeat(const objects::CMappedFeat& feat);    //    // pure virtual requirements    //    // Access the feature's remapped location    const objects::CSeq_loc& GetLocation(void) const;    // Comparators    bool LessByPos (const CLayoutObject& obj) const;    bool LessBySize(const CLayoutObject& obj) const;    // retrieve the type of this object    EType GetType() const;    //    // type-sepcific accessors    //    // Retrieve the feature as an object.  For safety's sake,    // this returns the remapped feature.    const CObject* GetObject(TSeqPos pos) const;        bool HasObject(const CObject* obj) const;    // Access the original feature.  The location on this feature    // may not be correct, as it hasn't been remapped    const objects::CSeq_feat&        GetFeature(void) const;    // Access a new, fully remapped feature    // This is useful for passing exact features to plugins    const objects::CMappedFeat&      GetMappedFeature(void) const;    // Access the size of this feature    TSeqPos                 size(void) const;    // Access the sub-intervals in this feature    const vector<TSeqRange>&   GetIntervals(void) const;    // Access a text string describing this feature    //const string&           GetTextId(void) const;    // Accessors for parent-child relationships in features    const CLayoutFeat*      GetParent  (void) const;    const TFeatList&        GetChildren(void) const;    void                    SetParent(CLayoutFeat* feat);    TFeatList&              SetChildren(void);    bool                    IsHiddenLabel(void) const;    void                    HideLabels();protected:    // we store a mapped feature object    objects::CMappedFeat    m_Feature;    bool                    m_HideLabel;        // parent / child relationships for this feature    CLayoutFeat*            m_Parent;    TFeatList               m_Children;    // some sort of identifier for this gene    // this is usually a locus name    //string                  m_TextId;    // individual features in this range    mutable vector<TSeqRange>  m_Intervals;    // calculate our intervals    void    x_CalcIntervals(void) const;};//// Predicates for sorting gene info////// SFeatureBySize()// arrange features by length of (extent of) feature//struct NCBI_GUIOBJUTILS_EXPORT SFeatureBySize{    bool operator() (const CLayoutFeat& g0, const CLayoutFeat& g1) const {        return (g0.size() > g1.size());    }    bool operator() (const CLayoutFeat* g0, const CLayoutFeat* g1) const {        return (g0->size() > g1->size());    }};//// SFeatureByPos()// arrange features by position.  in essence, this sorts features as a// CSeq_feat is sorted//struct NCBI_GUIOBJUTILS_EXPORT SFeatureByPos{    bool operator() (const CLayoutFeat& g0, const CLayoutFeat& g1) const {        return (g0.GetFeature().Compare(g1.GetFeature(),                                        g0.GetLocation(),                                        g1.GetLocation()) < 0);    }    bool operator() (const CLayoutFeat* g0, const CLayoutFeat* g1) const {        return (*this)(*g0, *g1);    }};inlinebool CLayoutFeat::IsHiddenLabel(void) const{    return m_HideLabel;}inlinevoid CLayoutFeat::HideLabels(){    m_HideLabel = true;}inlineconst objects::CSeq_feat& CLayoutFeat::GetFeature(void) const{    return m_Feature.GetOriginalFeature();}inlineconst CObject* CLayoutFeat::GetObject(TSeqPos pos) const{    TSeqRange r = GetLocation().GetTotalRange();    if (pos >= r.GetFrom()  &&  pos <= r.GetTo()) {        return &m_Feature.GetOriginalFeature();    }    return NULL;}inlinebool CLayoutFeat::HasObject(const CObject* obj) const{    return &m_Feature.GetOriginalFeature() == obj;}inlineconst objects::CMappedFeat& CLayoutFeat::GetMappedFeature(void) const{    return m_Feature;}inlineconst objects::CSeq_loc& CLayoutFeat::GetLocation(void) const{    return m_Feature.GetLocation();}inlineTSeqPos CLayoutFeat::size(void) const{    return GetLocation().GetTotalRange().GetLength();}// Accessors for parent-child relationships in featuresinlineconst CLayoutFeat* CLayoutFeat::GetParent(void) const{    return m_Parent;}inlineconst CLayoutFeat::TFeatList& CLayoutFeat::GetChildren(void) const{    return m_Children;}inlinevoid CLayoutFeat::SetParent(CLayoutFeat* feat){    m_Parent = feat;}inlineCLayoutFeat::TFeatList& CLayoutFeat::SetChildren(void){    return m_Children;}inlinebool CLayoutFeat::LessByPos(const CLayoutObject& obj) const{    const CLayoutFeat* feat = dynamic_cast<const CLayoutFeat*>(&obj);    if (feat) {        // two features - we sort in feature order        SFeatureByPos comp;        return (comp(*this, *feat));    } else {        // default: compare by ranges        TSeqRange r0 = GetLocation().GetTotalRange();        TSeqRange r1 = obj.GetLocation().GetTotalRange();        return (r0.GetFrom() < r1.GetFrom());    }}inlinebool CLayoutFeat::LessBySize(const CLayoutObject& obj) const{    TSeqRange r0 = GetLocation().GetTotalRange();    TSeqRange r1 = obj.GetLocation().GetTotalRange();    return (r0.GetLength() < r1.GetLength());}// Access the sub-intervals in this featureinlineconst vector<TSeqRange>& CLayoutFeat::GetIntervals(void) const{    if (m_Intervals.size() == 0) {        x_CalcIntervals();    }    return m_Intervals;}inlineCLayoutFeat::EType CLayoutFeat::GetType() const{    return eFeat;}END_NCBI_SCOPE/* @} *//* * =========================================================================== * $Log: feature.hpp,v $ * Revision 1000.0  2004/06/01 19:54:56  gouriano * PRODUCTION: IMPORTED [GCC34_MSVC7] Dev-tree R1.4 * * Revision 1.4  2004/05/14 14:24:47  dicuccio * Added new pure virtual requirement on CLayoutObject(): GetType(), returns enum * defined in CLayoutObject * * Revision 1.3  2004/05/03 13:34:54  dicuccio * FIxed include guards, doxygen groups * * Revision 1.2  2004/05/03 12:41:35  dicuccio * Fixed #includes and export specifiers * * Revision 1.1  2004/04/30 11:52:53  dicuccio * Split out from gui/utils * * Revision 1.24  2004/04/16 14:27:17  dicuccio * Added doxygen module tag * * Revision 1.23  2004/04/15 12:57:43  lebedev * Changed GetObject to return NULL or const pointer based on given position * * Revision 1.22  2004/04/12 16:48:28  dicuccio * MOved #include guard * * Revision 1.21  2004/03/11 17:19:32  dicuccio * Use TSeqRange instead of TRange.  Use gui/gui instead of gui/types * * Revision 1.20  2004/02/24 14:34:49  lebedev * Option to hide feature label added * * Revision 1.19  2003/09/30 19:49:26  dicuccio * When requesting the object behind a feature, always return the original feature * not remapped to another sequence (solves selection issues in graphical widget) * * Revision 1.18  2003/09/29 15:20:08  dicuccio * Deprecated gui/scope.hpp.  Merged gui/core/types.hpp into gui/types.hpp * * Revision 1.17  2003/08/22 15:57:11  dicuccio * Removed 'USING_SCOPE(objects)'.  Removed export specifier from inline structs * * Revision 1.16  2003/08/18 14:53:26  dicuccio * Changed nales: CFeature -> CLayoutFeat; CAlignment -> CLayoutAlign; CGraph -> * CLayoutGraph; CProtProduct -> CLayoutProtProd. * Removed USING_SCOPE(objects); * * Revision 1.15  2003/07/21 19:24:09  dicuccio * Changed storage mechanism: CLayoutObject::GetObject() is pure virtual.  Also, * CFeature now stores a CMappedFeat object instead of a CSeq_feat / CSeq_loc pair * * Revision 1.14  2003/07/11 15:24:05  dicuccio * Fix compilation error for gcc * * Revision 1.13  2003/07/11 12:40:01  dicuccio * Code clean-ups.  Fixed sorting of features to perform correct feature-order * sorting * * Revision 1.12  2003/07/11 11:46:58  dicuccio * Removed dead code * * Revision 1.11  2003/06/10 13:32:42  dicuccio * Rewored CFeature to inherit from CLayoutObject.  Removed a lot fo dead code. * * Revision 1.10  2003/05/07 17:26:17  dicuccio * Removed dead predeclaration; reformatted CVS comments * * Revision 1.9  2003/05/07 12:30:00  dicuccio * Removed CFeature::GetExtent().  Fixed long-standing bug with misreporting of * feature locations * * Revision 1.8  2003/02/25 14:42:48  dicuccio * FIxed compilation issue related to API change in CSeq_feat::Compare() * * Revision 1.7  2003/02/10 18:19:41  dicuccio * Fixed compilation errors relating to change in CFeat_CI API * * Revision 1.6  2003/01/15 20:57:37  dicuccio * Dropped private feature sort mechanism in favor of toolkit standard sort. * * Revision 1.5  2003/01/13 13:11:42  dicuccio * Namespace clean-up.  Retired namespace gui -> converted to namespace ncbi. * Moved all FLUID-generated code into namespace ncbi. * * Revision 1.4  2002/12/19 18:13:03  dicuccio * Added export specifiers for Win32. * * Revision 1.3  2002/12/11 19:00:06  dicuccio * Re-enabled selection * * Revision 1.2  2002/12/06 14:08:17  dicuccio * Moved feature sorting predicates into feature.[h,c]pp * * Revision 1.1  2002/11/29 15:28:10  dicuccio * Initial revision - moved from gui/core/view/graphic * * Revision 1.2  2002/11/09 20:57:08  dicuccio * Performance improvements:  Implemented smarter widget update (use update * flags to specify update conditions); use a more intuitive (and flexible) * mechanism to obtain features from the object manager. * * Revision 1.1  2002/11/07 16:27:26  dicuccio * Initial revision * * =========================================================================== */#endif  // GUI_OBJUTILS___FEATURE__HPP

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -