📄 annot_selector.hpp
字号:
/* * =========================================================================== * PRODUCTION $Log: annot_selector.hpp,v $ * PRODUCTION Revision 1000.2 2004/04/12 17:26:57 gouriano * PRODUCTION PRODUCTION: UPGRADED [CATCHUP_003] Dev-tree R1.30 * PRODUCTION * =========================================================================== */#ifndef ANNOT_SELECTOR__HPP#define ANNOT_SELECTOR__HPP/* $Id: annot_selector.hpp,v 1000.2 2004/04/12 17:26:57 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: Aleksey Grichenko, Michael Kimelman, Eugene Vasilchenko** File Description:* Annotations selector structure.**/#include <corelib/ncbi_limits.h>#include <objects/seq/Seq_annot.hpp>#include <objects/seqfeat/SeqFeatData.hpp>#include <vector>BEGIN_NCBI_SCOPEBEGIN_SCOPE(objects)class CSeq_entry;class CSeq_annot;class CSeq_entry_Handle;class CSeq_annot_Handle;class CAnnotObject_Info;class CAnnotName{public: CAnnotName(void) : m_Named(false) { } CAnnotName(const string& name) : m_Named(true), m_Name(name) { } CAnnotName(const char* name) : m_Named(true), m_Name(name) { } bool IsNamed(void) const { return m_Named; } const string& GetName(void) const { _ASSERT(m_Named); return m_Name; } void SetUnnamed(void) { m_Named = false; m_Name.erase(); } void SetNamed(const string& name) { m_Name = name; m_Named = true; } bool operator<(const CAnnotName& name) const { return name.m_Named && (!m_Named || name.m_Name > m_Name); } bool operator==(const CAnnotName& name) const { return name.m_Named == m_Named && name.m_Name == m_Name; } bool operator!=(const CAnnotName& name) const { return name.m_Named != m_Named || name.m_Name != m_Name; }private: bool m_Named; string m_Name;};struct SAnnotTypeSelector{ typedef CSeq_annot::C_Data::E_Choice TAnnotType; typedef CSeqFeatData::E_Choice TFeatType; typedef CSeqFeatData::ESubtype TFeatSubtype; SAnnotTypeSelector(TAnnotType annot = CSeq_annot::C_Data::e_not_set) : m_FeatSubtype(CSeqFeatData::eSubtype_any), m_FeatType(CSeqFeatData::e_not_set), m_AnnotType(annot) { } SAnnotTypeSelector(TFeatType feat) : m_FeatSubtype(CSeqFeatData::eSubtype_any), m_FeatType(feat), m_AnnotType(CSeq_annot::C_Data::e_Ftable) { } SAnnotTypeSelector(TFeatSubtype feat_subtype) : m_FeatSubtype(feat_subtype), m_FeatType(CSeqFeatData::GetTypeFromSubtype(feat_subtype)), m_AnnotType(CSeq_annot::C_Data::e_Ftable) { } TAnnotType GetAnnotType(void) const { return TAnnotType(m_AnnotType); } TFeatType GetFeatType(void) const { return TFeatType(m_FeatType); } TFeatSubtype GetFeatSubtype(void) const { return TFeatSubtype(m_FeatSubtype); } bool operator<(const SAnnotTypeSelector& s) const { if ( m_AnnotType != s.m_AnnotType ) return m_AnnotType < s.m_AnnotType; if ( m_FeatType != s.m_FeatType ) return m_FeatType < s.m_FeatType; return m_FeatSubtype < s.m_FeatSubtype; } bool operator==(const SAnnotTypeSelector& s) const { return m_AnnotType == s.m_AnnotType && m_FeatType == s.m_FeatType && m_FeatSubtype == s.m_FeatSubtype; } bool operator!=(const SAnnotTypeSelector& s) const { return m_AnnotType != s.m_AnnotType || m_FeatType != s.m_FeatType || m_FeatSubtype != s.m_FeatSubtype; } void SetAnnotType(TAnnotType type) { m_AnnotType = type; // Reset feature type/subtype if (m_AnnotType != CSeq_annot::C_Data::e_Ftable) { m_FeatType = CSeqFeatData::e_not_set; m_FeatSubtype = CSeqFeatData::eSubtype_any; } } void SetFeatType(TFeatType type) { m_FeatType = type; // Adjust annot type and feature subtype m_AnnotType = CSeq_annot::C_Data::e_Ftable; m_FeatSubtype = CSeqFeatData::eSubtype_any; } void SetFeatSubtype(TFeatSubtype subtype) { m_FeatSubtype = subtype; // Adjust annot type and feature type m_AnnotType = CSeq_annot::C_Data::e_Ftable; if (m_FeatSubtype != CSeqFeatData::eSubtype_any) { m_FeatType = CSeqFeatData::GetTypeFromSubtype(GetFeatSubtype()); } }private: Uint2 m_FeatSubtype; // Seq-feat subtype Uint1 m_FeatType; // Seq-feat type Uint1 m_AnnotType; // Annotation type};// Structure to select type of Seq-annotstruct NCBI_XOBJMGR_EXPORT SAnnotSelector : public SAnnotTypeSelector{ // Flag to indicate location overlapping method enum EOverlapType { eOverlap_Intervals, // default - overlapping of individual intervals eOverlap_TotalRange // overlapping of total ranges only }; // Flag to indicate references resolution method enum EResolveMethod { eResolve_None, // Do not search annotations on segments eResolve_TSE, // default - search only on segments in the same TSE eResolve_All // Search annotations for all referenced sequences }; // Flag to indicate adaptive segment selection enum ESegmentSelect { eSegmentSelect_All, eSegmentSelect_First, eSegmentSelect_Last }; // Flag to indicate sorting method enum ESortOrder { eSortOrder_None, // do not sort annotations for faster retrieval eSortOrder_Normal, // default - increasing start, decreasing length eSortOrder_Reverse // decresing end, decreasing length }; // Flag to indicate joining feature visible through multiple segments enum ECombineMethod { eCombine_None, // default - do not combine feature from segments eCombine_All // combine feature from different segments }; enum EIdResolving { eLoadedOnly, // Resolve only ids already loaded into the scope eIgnoreUnresolved, // Ignore unresolved ids (default) eFailUnresolved // Throw exception for unresolved ids }; SAnnotSelector(TAnnotType annot = CSeq_annot::C_Data::e_not_set, TFeatType feat = CSeqFeatData::e_not_set); SAnnotSelector(TFeatType feat); SAnnotSelector(TAnnotType annot, TFeatType feat, bool feat_product); SAnnotSelector(TFeatType feat, bool feat_product); SAnnotSelector(const SAnnotSelector& sel); SAnnotSelector& operator=(const SAnnotSelector& sel); ~SAnnotSelector(void); SAnnotSelector& SetAnnotType(TAnnotType type) { x_ClearAnnotTypesSet(); SAnnotTypeSelector::SetAnnotType(type); return *this; } SAnnotSelector& SetFeatType(TFeatType type) { x_ClearAnnotTypesSet(); SAnnotTypeSelector::SetFeatType(type); return *this; } SAnnotSelector& SetFeatSubtype(TFeatSubtype subtype) { x_ClearAnnotTypesSet(); SAnnotTypeSelector::SetFeatSubtype(subtype); return *this; } SAnnotSelector& IncludeAnnotType(TAnnotType type); SAnnotSelector& ExcludeAnnotType(TAnnotType type); SAnnotSelector& IncludeFeatType(TFeatType type); SAnnotSelector& ExcludeFeatType(TFeatType type); SAnnotSelector& IncludeFeatSubtype(TFeatSubtype subtype); SAnnotSelector& ExcludeFeatSubtype(TFeatSubtype subtype); // Set type if not set yet, else do nothing. SAnnotSelector& CheckAnnotType(TAnnotType type); // Return true if at least one subtype of the type is included // or selected type is not set (any). bool IncludedAnnotType(TAnnotType type) const; bool IncludedFeatType(TFeatType type) const; bool IncludedFeatSubtype(TFeatSubtype subtype) const; bool MatchType(const CAnnotObject_Info& annot_info) const; bool GetFeatProduct(void) const { return m_FeatProduct; } SAnnotSelector& SetByProduct(bool byProduct = true) { m_FeatProduct = byProduct; return *this; } SAnnotSelector& SetOverlapType(EOverlapType overlap_type) { m_OverlapType = overlap_type; return *this; } SAnnotSelector& SetOverlapIntervals(void)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -