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

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_SEQ_GRAPHIC___ALIGNMENT_TRACK__HPP
2 #define GUI_WIDGETS_SEQ_GRAPHIC___ALIGNMENT_TRACK__HPP
3 
4 /* $Id: alignment_track.hpp 47419 2023-03-23 02:33:55Z evgeniev $
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>
36 #include <gui/utils/extension.hpp>
44 
45 //#include <objects/seqloc/Seq_interval.hpp>
47 
48 class wxEvtHandler;
49 
51 
52 class CGeneModelConfig;
53 
54 ///////////////////////////////////////////////////////////////////////////////
55 /// CAlignmentTrack --
56 ///
57 
59  public CDataTrack
60 {
61  friend class CAlignmentTrackFactory;
62 
63 public:
64  enum EJobType {
69  eJob_CoverageGraph
70  };
71 
72  enum ELayout {
73  eLayout_Adaptive = 0, ///< adaptive using loading costs to switch between rendering modes
74  eLayout_Packed, ///< smear/pack all alignments into one smear bar
75  eLayout_ExpandedByPos, ///< one alignment per row sorted by pos
76  eLayout_Full, ///< one alignment per row sorted by pos
77  eLayout_Default = eLayout_Adaptive
78  };
79 
87  eAlign_Non
88  };
89 
90  /// @name static methods.
91  /// static methods for converting layout str and label position str
92  /// layout setting and label position setting.
93  /// @{
94  static ELayout LayoutStrToValue(const string& layout);
95  static const string& LayoutValueToStr(ELayout layout);
96  static CAlignmentConfig::ELabelPosition LabelPosStrToValue(const string& pos);
97  static const string& LabelPosValueToStr(CAlignmentConfig::ELabelPosition pos);
98  static CAlignmentConfig::EHideSraAlignments HideFlagStrToValue(const string& hideSra);
99  static const string& HideFlagValueToStr(CAlignmentConfig::EHideSraAlignments hideSra);
100  static CAlignmentConfig::EUnalignedTailsMode UnalignedTailsModeStrToValue(const string& tailsMode);
101  static const string& UnalignedTailsModeValueToStr(CAlignmentConfig::EUnalignedTailsMode tailsMode);
102  /// @}
103 
104 
106  virtual ~CAlignmentTrack();
107 
108  /// @name CLayoutTrack public methods.
109  /// @{
110  virtual const CTrackTypeInfo& GetTypeInfo() const override;
111  virtual string GetFullTitle() const override;
112  /// @}
113 
114  /// @name CDataTrack public methods
115  /// @{
116  virtual CRef<CSGGenBankDS> GetDataSource() override;
117  virtual CConstRef<CSGGenBankDS> GetDataSource() const override;
118  /// @}
119 
120  void SetAnnot(const string& annot);
121  void SetDSContext(ISGDataSourceContext* ds_ctx);
122 
123  void SetAlnType(IAlnExplorer::EAlignType type);
124 
125  /// @name content menu event handlers.
126  /// @{
127  void OnToggleContent(int id);
128  void OnChangeProjectedFeats();
129  /// @}
130 
131  void SetDefaultProfile(const string& profile);
132 
133  /// @name CGlyphContainer public methods.
134  /// @{
135  virtual void GetHTMLActiveAreas(TAreaVector *p_areas) const override;
136  virtual CHTMLActiveArea* InitHTMLActiveArea(TAreaVector* p_areas) const override;
137  virtual void x_UpdateBoundingBox() override;
138  /// @}
139 
140 protected:
141  /// @name CLayoutTrack virtual methods overloading.
142  /// @{
143  virtual void x_LoadSettings(const string& preset_style,
144  const TKeyValuePairs& settings) override;
145 
146  /// save part of settings to a profile string.
147  /// Only the potential settings changed by users will be saved.
148  virtual void x_SaveSettings(const string& preset_style) override;
149 
150  virtual void x_OnIconClicked(TIconID id) override;
151  /// @}
152 
153  /// @name CDataTrack pure virtual interfaces
154  /// @{
155  virtual void x_UpdateData() override;
156  virtual void x_OnJobCompleted(CAppJobNotification& notify) override;
157  /// @}
158 
159  void x_OnContentIconClicked();
160  void x_OnLayoutIconClicked();
161  void x_OnScoreIconClicked();
162  void x_OnStatIconClicked();
163  void x_OnTailsIconClicked();
164  void x_OnLayoutPolicyChanged();
165 
166  void x_AddAlignmentLayout(const CSGJobResult& result);
167  void x_AddAlignFeatLayout(CBatchJobResult& results);
168  void x_AddGraphLayout(const CSGJobResult& result);
169  void x_AddAlignStatLayout(const CSGJobResult& result);
170 
171 private:
173  eIcon_Score = eIcon_MaxTrackIconID + 1,
174  eIcon_Stat = eIcon_MaxTrackIconID + 2,
175  eIcon_Tails = eIcon_MaxTrackIconID + 3
176  };
177 
178 private:
179  /// @name prohibited copy constructor and assignment operator.
180  /// @{
183  /// @}
184 
185  void x_AddAlignFeat_Recursive(CLayoutGroup::TObjectList& objs);
186 
187  void x_LoadAlignedSeqFeats(vector< CRef<CAlignGlyph> >& aligns,
188  CAlignGlyph* aln);
189 
190  EAlignGlyphType x_GetAlignGlyphType(const CSeqGlyph* glyph) const;
191 
192  /// save all track settings to the configuration file.
193  /// this is not used currently.
194  void x_SaveConfiguration(const string& preset_style) const;
195 
196  /// common function for loading settings for multialign, pairwise aligns,
197  /// and align smear.
198  void x_LoadAlignmentSettings(const string& key,
199  CRef<CAlignmentConfig>& conf);
200 
201  void x_SaveAlignmentSettings(const string& key,
202  CConstRef<CAlignmentConfig> conf) const;
203 
204  void x_LoadMultiAlignSettings();
205  void x_SaveMultiAlignSettings() const;
206  void x_LoadPWAlignSettings();
207  void x_SavePWAlignSettings() const;
208  void x_LoadAlignSmearSettings();
209  void x_SaveAlignSmearSettings() const;
210  void x_LoadMPPWAlignSettings();
211  void x_LoadMatePairSettings();
212  void x_SaveMatePairSettings() const;
213  void x_SetMsg();
214  CRef<CHistParams> x_GetGraphParams();
215 
216  int x_LayoutToCutoff(CAlignmentTrack::ELayout layout);
217  int x_LayoutToCutoff_SRA(CAlignmentTrack::ELayout layout);
218 
219 private:
220  /// wx-related event handler.
221  wxEvtHandler* m_ContentHandler;
222 
223  string m_AnnotName;
226 
227  string m_DefaultProfile = "Default"; ///> Default Settings profile
228 
232  CRef<CAlignmentConfig> m_MPPWAlignConf; ///< for linked pairwise aligns
238 
239  ELayout m_Layout = eLayout_Adaptive;
240  bool m_IsDefaultLayout = true;
246 
247  double m_MinPileUpCost = 3.; /// MinPileUpCost - Show Coverage Graph if cost is higher than MinPileUpCost
248  double m_MinAlignCost = 1.5; /// MinAlignCost - Show Alignment Graph if cost is higher than MinAlignCost
249  double m_MaxAlignCost = 15; /// MaxAlignCost Show PileUp Graph is cost is higher than MaxAlignCost
250 
251  int m_MaxAlignShownFull = 250000;
252  int m_MaxAlignShownAdaptive = 7500;
253 
254 
255  // Flag, indicating which SRA alignments to hide
257  // Flag, indicating how to display unaligned tails
259 
260  bool m_ShowSecondPassAlignments = true;
261 
262  // Flag indicate if compact display is enabled.
264 
265  /// Alignment number threshold between compact mode and non-compact mode.
266  /// Maximal number of alignments shown in the non-compact mode
268  /// Alignment number threshold between compact mode and extreme compact mode.
269  /// Maximal number of alignments shown in the compact mode
271 
272  typedef vector<int> TSubtypeVec;
274 
279 
280  // cached info
282  size_t m_ObjNum;
283 
286  vector<CRef<CAlnStatGlyph>> m_StatGlyph;
287 
289 
290 };
291 
292 ///////////////////////////////////////////////////////////////////////////////
293 /// CAlignmentTrackFactory
294 ///
296  public CObject,
297  public ILayoutTrackFactory,
298  public ITrackConfigurable,
299  public IIconProvider,
300  public IExtension
301 {
302 public:
304 
305  /// @name ILayoutTrackFactory interface implementation
306  /// @{
307  /// create a layout track based on the input objects and extra parameters.
308  virtual TTrackMap CreateTracks(
309  SConstScopedObject& object,
310  ISGDataSourceContext* ds_context,
311  CRenderingContext* r_cntx,
312  const SExtraParams& params = SExtraParams(),
313  const TAnnotMetaDataList& src_annots = TAnnotMetaDataList()) const override;
314 
315  virtual void GetMatchedAnnots(
316  const TAnnotMetaDataList& src_annots,
317  const ILayoutTrackFactory::SExtraParams& params,
318  TAnnotNameTitleMap& out_annots) const override;
319 
320  virtual bool UnderstandLevel() const override
321  { return true; }
322 
323  virtual bool NeedBackgroundInit() const override
324  { return true; }
325 
326  virtual const CTrackTypeInfo& GetThisTypeInfo() const override
327  { return GetTypeInfo(); }
328  /// @}
329 
330  static const CTrackTypeInfo& GetTypeInfo()
331  { return CAlignmentTrack::m_TypeInfo; }
332 
333 
334  /// @name ITrackConfigurable interface implementation
335  /// @{
337  GetSettings(const string& profile,
338  const TKeyValuePairs& settings,
339  const CTempTrackProxy* track_proxy) const override;
340  /// @}
341 
342  /// @name IIconProvider interface implementation
343  /// @{
344  virtual void RegisterIconImages() const override;
345  /// @}
346 
347  /// @name IExtension interface implementation
348  /// @{
349  virtual string GetExtensionIdentifier() const override;
350  virtual string GetExtensionLabel() const override;
351  /// @}
352 };
353 
354 
355 ///////////////////////////////////////////////////////////////////////////////
356 /// CAlignmentTrack inline methods
357 ///////////////////////////////////////////////////////////////////////////////
358 inline /*virtual*/
360 {
362 }
363 
364 inline /*virtual*/
366 {
368 }
369 
370 inline
372 { m_DSContext.Reset(ds_ctx); }
373 
374 inline
376 { m_AlnType = type; }
377 
378 inline
380 {
384 }
385 
386 inline
388 {
391 }
392 
393 inline
395 {
397 }
398 
399 inline
401 {
404 }
405 
406 inline
408 {
410 }
411 
412 inline
414 {
417 }
418 
419 inline
421 {
423  m_MPPWAlignConf->m_ShowLabel = false;
426 }
427 
428 inline
429 void CAlignmentTrack::SetDefaultProfile(const string& profile)
430 {
431  m_DefaultProfile = profile;
432 }
433 
434 
436 
437 #endif // GUI_WIDGETS_SEQ_GRAPHIC___ALIGNMENT_TRACK__HPP
bool m_ShowUnalignedTailsForTrans2GenomicAln
EUnalignedTailsMode m_UnalignedTailsMode
CAlignmentTrackFactory.
virtual const CTrackTypeInfo & GetThisTypeInfo() const override
virtual bool NeedBackgroundInit() const override
Background track initialization.
static const CTrackTypeInfo & GetTypeInfo()
virtual bool UnderstandLevel() const override
Have any concept of level.
CAlignmentTrack –.
static CTrackTypeInfo m_TypeInfo
CRef< CSGAlignmentDS > m_DS
size_t m_CompactThreshold
Alignment number threshold between compact mode and non-compact mode.
CRef< CAlnStatConfig > m_StatConf
void x_LoadAlignmentSettings(const string &key, CRef< CAlignmentConfig > &conf)
common function for loading settings for multialign, pairwise aligns, and align smear.
CAlignmentTrack(const CAlignmentTrack &)
bool m_ShowUnalignedTailsForTrans2GenomicAln
vector< CRef< CAlnStatGlyph > > m_StatGlyph
void SetDSContext(ISGDataSourceContext *ds_ctx)
CAlignmentConfig::EHideSraAlignments m_HideSraAlignments
void x_LoadMPPWAlignSettings()
size_t m_ExtremeCompactThreshold
Alignment number threshold between compact mode and extreme compact mode.
void x_SavePWAlignSettings() const
virtual CRef< CSGGenBankDS > GetDataSource() override
CAlignmentTrack inline methods.
vector< int > TSubtypeVec
CRef< CSimpleLayout > m_GeneModelLayout
CRef< CColumnLayout > m_Column
void SetDefaultProfile(const string &profile)
CRef< CBoundaryParams > m_GeneGroupConf
void x_LoadAlignSmearSettings()
CRef< CAlignmentConfig > m_MultiAlignConf
> Default Settings profile
CIRef< ISGDataSourceContext > m_DSContext
void x_SaveMultiAlignSettings() const
void SetAlnType(IAlnExplorer::EAlignType type)
IAlnExplorer::EAlignType m_AlnType
CRef< CAlignmentConfig > m_MPPWAlignConf
for linked pairwise aligns
CAlignmentConfig::EUnalignedTailsMode m_UnalignedTailsMode
TSubtypeVec m_ProjectedFeats
CAlignmentTrack & operator=(const CAlignmentTrack &)
CRef< CAlignmentConfig > m_AlignSmearConf
CRef< CGeneModelConfig > m_GeneModelConfig
void x_SaveAlignSmearSettings() const
void x_LoadMultiAlignSettings()
CRef< CMatePairConfig > m_MatePairConf
@ eLayout_Full
one alignment per row sorted by pos
@ eLayout_ExpandedByPos
one alignment per row sorted by pos
@ eLayout_Packed
smear/pack all alignments into one smear bar
CRef< CBoundaryParams > m_FeatGroupConf
CRef< CAlignmentConfig > m_PWAlignConf
void x_SaveAlignmentSettings(const string &key, CConstRef< CAlignmentConfig > conf) const
wxEvtHandler * m_ContentHandler
wx-related event handler.
CAppJobNotification Notification send by CAppJobEventTranslator.
CBatchJobResult – the data structure holding the seqgraphic job results for a batch job processing.
CConstRef –.
Definition: ncbiobj.hpp:1266
CDataTrack - a abstract base class for layout tracks which need to deal with background data retrieva...
Definition: data_track.hpp:55
virtual CRef< CSGGenBankDS > GetDataSource()=0
Method for accessing the data source.
virtual void x_UpdateData()=0
update track content.
virtual void x_OnJobCompleted(CAppJobNotification &notify)=0
virtual void x_UpdateBoundingBox()
Update the bounding box assuming children's sizes are fixed if any.
virtual void GetHTMLActiveAreas(TAreaVector *p_areas) const
Get html active areas.
virtual const CTrackTypeInfo & GetTypeInfo() const
ILayoutPolicy::TObjectList TObjectList
virtual void x_SaveSettings(const string &preset_style)
save the track settings to a profile string.
virtual void x_LoadSettings(const string &preset_style, const TKeyValuePairs &settings)
load the track settings.
virtual void x_OnIconClicked(TIconID id)
Mouse left-click event handler on an icon.
virtual string GetFullTitle() const
get a more meaningful title.
virtual CHTMLActiveArea * InitHTMLActiveArea(TAreaVector *p_areas) const
Initialize the HTML active area for a track.
CObject –.
Definition: ncbiobj.hpp:180
CRef –.
Definition: ncbiobj.hpp:618
CRenderingContext offers the basic context and utility methods for rendering layout objects in featur...
CSGJobResult – the data structure holding the seqgraphic job results.
class CSeqGlyph defines an interface that wraps a rectilinear abstract object.
Definition: seq_glyph.hpp:82
File Description:
CTrackTypeInfo - holds description of a layout track type.
IExtension IExtension interface represents an abstract pluggable component.
Definition: extension.hpp:57
IIconProvider interface for tracks providing track icons.
ILayoutTrackFactory.
ISGDSManager is seqgraphic data source manage that serves as an data source context.
ITrackConfigurable interface for tracks that are configurable.
map< string, string > TKeyValuePairs
static int type
Definition: getdata.c:31
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:998
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
#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
const struct ncbi::grid::netcache::search::fields::KEY key
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
extra parameter for initializing a track.
Definition: type.c:6
else result
Definition: token2.c:20
Modified on Wed Apr 17 13:08:16 2024 by modify_doxy.py rev. 669887