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

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_SEQ_GRAPHIC___SEGMENT_MAP_DS__HPP
2 #define GUI_WIDGETS_SEQ_GRAPHIC___SEGMENT_MAP_DS__HPP
3 
4 /* $Id: segment_map_ds.hpp 44596 2020-01-29 15:41:36Z filippov $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Liangshou Wu
30  *
31  * File Description:
32  *
33  */
34 
35 #include <corelib/ncbiobj.hpp>
38 
40 
41 class ICache;
42 
43 const int kSegmentLoadLimit = 100;
44 
45 ///////////////////////////////////////////////////////////////////////////////
46 /// CSGSegmentMapDS
47 ///
49 {
50 public:
51  /// It is not technically correct to name a specific segment
52  /// level as config/scaffold and component because segment map
53  /// is just a representation of sequence relationship at different
54  /// level of sequence assembly.
55  /// Assumption: For all chromosome sequences, contigs/scaffolds are
56  /// at level 0, and components are at level 1. For any other sequences,
57  /// there will be only one level of segments which are components. And
58  /// the components are at level 0.
60  eInvalid = -2,
61  eAdaptive = -1, ///< show either contigs or components based on range
62  eContig = 0,
63  eComponent = 1
64  };
65 
66  CSGSegmentMapDS(objects::CScope& scope, const objects::CSeq_id& id);
67 
68  void LoadSegmentMap(const TSeqRange& range, int cutoff, TJobToken token);
69 
70  /// Used in sequence track for showing segment color.
71  void LoadSegmentSmear(const TSeqRange& range, TModelUnit scale, const objects::CSeqVector* seq_vec = nullptr);
72 
73  void LoadSegmentMapSeqIDs(CSeqGlyph::TObjects& objs, TJobToken token);
74 
75  void LoadSwitchPoints();
76 
77  /// Get total number of segment map levels.
78  int GetSegmentMapLevels(const TSeqRange& range) const;
79 
80  /// Query if there is segment maps for given level.
81  /// @param level if it is -1, it checks all the way down until
82  /// either finding one or reaching the bottom.
83  bool HasSegmentMap(int level, const TSeqRange& range) const;
84  bool HasComponent(const TSeqRange& range) const;
85  bool HasScaffold(const TSeqRange& range) const;
86 
87  void GetAnnotNames(objects::SAnnotSelector& sel,
88  const TSeqRange& range, TAnnotNameTitleMap& names) const;
89 
90  void SetAnnot(const string& annot);
91  const string& GetAnnot() const;
92 
93  void SetChromosome(bool flag);
94  bool IsChromosome() const;
95 
96  /// Set which segment level to show.
97  /// @param level is the conceptual segment level. It needs
98  /// to be converted to the real segment level. If the level
99  /// is the actual segment level, call SetDepth() directly.
100  void SetSegmentLevel(ESegmentLevel level);
101 
102  /// Set cache client to use
103  static void SetICacheClient(ICache* pCache);
104  /// Enables/disables the segment map
105  static void SetEnabled(bool enabled = true);
106  /// Indicates if the segment map is enabled
107  static bool GetEnabled();
108 
109 private:
110  /// Convert conceptual segment level to real segment depth.
111  /// For all chromosome sequences, contigs/scaffolds are at level 0,
112  /// and components are at level 1. For any other sequences, there will
113  /// be only one level of segments (components) which are at level 0.
114  /// -1 means 'Adaptive'.
115  int x_ConceptualToRealDepth(ESegmentLevel level) const;
116 
117 private:
118  /// Flag to indicate if the sequence is a chromosome sequence.
120 
121  /// The named annotation storing segment map data.
122  /// Used in sequence track (not segment map tracks, such as
123  /// components or scaffolds)
124  string m_Annot;
125 
126  /// Cache, used to store segment smear
127  static ICache* m_Cache;
128  /// Indicates if the segment map is enabled
129  static bool m_Enabled;
130 };
131 
132 ///////////////////////////////////////////////////////////////////////////////
133 /// CSGFeatureDSType
134 ///
136  public CObject,
137  public ISGDataSourceType,
138  public IExtension
139 {
140 public:
141  /// create an instance of the layout track type using default settings.
142  virtual ISGDataSource* CreateDS(SConstScopedObject& object) const;
143 
144  /// @name IExtension interface implementation
145  /// @{
146  virtual string GetExtensionIdentifier() const;
147  virtual string GetExtensionLabel() const;
148  /// @}
149 
150  /// check if the data source can be shared.
151  virtual bool IsSharable() const;
152 };
153 
154 
155 ///////////////////////////////////////////////////////////////////////////////
156 /// CSGFeatureDS inline methods
157 ///
158 inline
159 void CSGSegmentMapDS::SetAnnot(const string& annot)
160 { m_Annot = annot; }
161 
162 
163 inline
164 const string& CSGSegmentMapDS::GetAnnot() const
165 { return m_Annot; }
166 
167 inline
169 { m_IsChromosome = flag; }
170 
171 inline
173 { return m_IsChromosome; }
174 
175 
177 
178 #endif /* GUI_WIDGETS_SEQ_GRAPHIC___SEGMENT_MAP_DS__HPP */
CObject –.
Definition: ncbiobj.hpp:180
CSGFeatureDSType.
CSGSegmentMapDS.
void SetAnnot(const string &annot)
CSGFeatureDS inline methods.
bool IsChromosome() const
const string & GetAnnot() const
void SetChromosome(bool flag)
static ICache * m_Cache
Cache, used to store segment smear.
bool m_IsChromosome
Flag to indicate if the sequence is a chromosome sequence.
ESegmentLevel
It is not technically correct to name a specific segment level as config/scaffold and component becau...
static bool m_Enabled
Indicates if the segment map is enabled.
string m_Annot
The named annotation storing segment map data.
list< CRef< CSeqGlyph > > TObjects
Definition: seq_glyph.hpp:85
BLOB cache read/write/maintenance interface.
Definition: icache.hpp:64
IExtension IExtension interface represents an abstract pluggable component.
Definition: extension.hpp:57
ISGDataSourceFactory.
File Description:
static const struct name_t names[]
GLdouble TModelUnit
Definition: gltypes.hpp:48
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_GUIWIDGETS_SEQGRAPHIC_EXPORT
Definition: gui_export.h:536
range(_Ty, _Ty) -> range< _Ty >
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
const int kSegmentLoadLimit
void SetChromosome(objects::CBioSource &src, string chromosome)
Modified on Sun Apr 21 03:42:41 2024 by modify_doxy.py rev. 669887