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

Go to the SVN repository for this file.

1 /* $Id: alignment_track.cpp 47479 2023-05-02 13:24:02Z ucko $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Liangshou Wu, Andrei Shkeda
27  *
28  * File Description:
29  * There are some fairly complicated logics on determining how to display
30  * the alignments based on several different factors:
31  * - Incoming data source: regular alignments vs cSRA/BAM alignments
32  * - Alignment display (layout): Smear (packed), AdaptiveSeq, and so on,
33  * see the comment on CAlignmentTrack::ELayout for more details.
34  * - Zoom level: high level vs pileup display level vs low level
35  * - Pileup display setting: enabled vs disabled
36  * - Alignment type: DNA vs protein vs mixed
37  *
38  * Here are preknowledge:
39  * - cSRA/BAM files have precomputed coverage graphs
40  * - cSRA/Bam loader is able to deliver alignment pileup quickly
41  * - For regular alignments, pileup calculation is expensive and slow.
42  * - There is a (upper) limit determining what zoom level is appropriate
43  * to show alignment pileup (for performance consideration).
44  * - Alignment display setting determines when (what zoom level) to show
45  * individual alignments.
46  *
47  * And here are the requirements:
48  * 1. At high level, the alignments shall be shown in a compact form
49  * that is either coverage graph (for cSRA data) or smear bar (for
50  * regular alignemnts). The high level is defined when the zoom level
51  * reaches to a zoom level,
52  * a. that is over the predefined pileup display level for cSRA data, or
53  * b. at which there are more alignments than a predefined number
54  * determined by the alignment display option within the visible
55  * rnage for regular alignments.
56  * 2. For regular alignments with pileup display enabled and for all cSRA
57  * data regardless of piplup display enabled or not, if the zoom level
58  * is between the predefined pileup zoom level and the zoom level
59  * determined by alignment display setting, the pileup display, instead
60  * of smear bar or coverage graph, shall be shown.
61  * 3. At low level, all individual alignments shall be shown except for
62  * one alignment display setting which is 'Smear'. With this setting,
63  * alignments shall be shown in a packed form similar to high level mode.
64  * The low level is defined when zoom level reaches to either:
65  * a. sequence level, or
66  * b. any zoom level at which there are less alignments than the
67  * predefined number determined by the alignment display setting.
68  * At this level, if pileup display is enabled, both individual
69  * alignments and pileup shall be shown.
70  *
71  */
72 
73 #include <ncbi_pch.hpp>
74 
94 
96 
97 #include <gui/objutils/utils.hpp>
99 #include <gui/objutils/label.hpp>
100 #include <gui/objutils/registry.hpp>
101 
102 #include <objmgr/util/sequence.hpp>
103 
105 
106 #include <wx/event.h>
107 #include <wx/menu.h>
108 
109 #include "wx_aln_stat_dlg.hpp"
110 
113 
114 // menu item id for projected features
115 static const size_t kProjectedFeatID = 10000;
116 // content menu item base id
117 static const size_t kContentBaseID = 10001;
118 // potential maximal menu item id range
119 // assumming there will be less than 100 menu items
120 static const int kMaxID = 100;
121 
122 /// Scale at which we unconditionally switch to coverage graph
123 static const double kMinCoverageZoomLevel = 250.;
124 /// Range length for unconditional swith to pieup
125 static const int kShowPileUpRange = 10000;
126 
127 
128 // Config key for projected CDS features
129 //static const char* const kCDSKey = "GBPlugins.SeqGraphicGeneModelCDS";
130 static const string kGeneModelBaseKey = "GBPlugins.SeqGraphicGeneModel";
131 
132 class CAlnContentEvtHandler : public wxEvtHandler
133 {
134 public:
136  : m_Track( track )
137  {}
138 
139  void OnContextMenu( wxContextMenuEvent& anEvent );
140 
141 private:
142  /// @name event handlers.
143  /// @{
144  /// on toggle a conent menu item.
145  void x_OnToggleContent(wxCommandEvent& event)
146  {
147  int track_order = event.GetId() - kContentBaseID;
148  m_Track->OnToggleContent(track_order);
149  }
150 
151  /// on change the projected feature list.
152  void x_OnChangeProjectedFeats(wxCommandEvent& /*event*/)
154 
155  /// @}
156 
157 private:
159 
160  DECLARE_EVENT_TABLE()
161 };
162 
163 
164 BEGIN_EVENT_TABLE(CAlnContentEvtHandler, wxEvtHandler)
168 
169 
170 ///////////////////////////////////////////////////////////////////////////////
171 /// CAlignmentTrack
172 
173 
174 int CAlignmentTrack::x_LayoutToCutoff(CAlignmentTrack::ELayout layout)
175 {
176  int cut_off = m_MaxAlignShownAdaptive;
177  switch (layout) {
179  cut_off = -1;
180  break;
182  cut_off = m_MaxAlignShownAdaptive;
183  break;
186  cut_off = m_MaxAlignShownFull;
187  break;
188  }
189  return cut_off;
190 }
191 
193 {
194  int cut_off = m_MaxAlignShownAdaptive;
195  switch (layout) {
197  cut_off = -1;
198  break;
200  cut_off = m_MaxAlignShownAdaptive / 3;
201  break;
204  cut_off = m_MaxAlignShownFull;
205  break;
206  }
207  return cut_off;
208 }
209 
210 
211 
212 /// layout style to layout display name
214  { CAlignmentTrack::eLayout_Packed, "Packed" },
215  { CAlignmentTrack::eLayout_Adaptive, "Adaptive" },
216  { CAlignmentTrack::eLayout_ExpandedByPos, "Ladder (one alignment per row)" },
217  { CAlignmentTrack::eLayout_Full, "Show All" }
218 };
219 
221 {
222  const auto iter = sm_LayoutDispMap.find(layout);
223  if (iter != sm_LayoutDispMap.end()) {
224  return iter->second;
225  }
226  return kEmptyStr;
227 }
228 
229 // layout style to/from layout string/name
230 
232  { "Adaptive", CAlignmentTrack::eLayout_Adaptive },
233  { "Full", CAlignmentTrack::eLayout_Full },
235  { "Smear", CAlignmentTrack::eLayout_Packed },
236  { "Packed", CAlignmentTrack::eLayout_Packed }
237 };
238 
239 
240 
242 {
243  const auto iter = sm_LayoutMap.find(layout);
244  if (iter != sm_LayoutMap.end())
245  return iter->second;
246  if (NStr::FindNoCase(layout, "Adaptive") != string::npos) // compatibility with old methods
248  LOG_POST(Warning << "CAlignmentTrack settings. Invalid layout string: '" << layout << "'");
249  return eLayout_Default;
250 }
251 
252 
254 {
255  for (auto& iter : sm_LayoutMap) {
256  if (iter.second == layout) {
257  return iter.first;
258  }
259  }
260  return kEmptyStr;
261 }
262 
263 
265 static const TLabelPosStr s_LabelPosStrs[] = {
266  { "above", CAlignmentConfig::ePos_Above },
267  { "no label", CAlignmentConfig::ePos_NoLabel },
268  { "side", CAlignmentConfig::ePos_Side },
269 };
270 
273 
274 
277 {
278  TLabelPosMap::const_iterator iter = sm_LabelPosMap.find(pos);
279  if (iter != sm_LabelPosMap.end()) {
280  return iter->second;
281  }
282  NCBI_THROW(CException, eInvalid, "Invalid label position string: " + pos);
283 }
284 
285 
286 const string&
288 {
290  for (iter = sm_LabelPosMap.begin(); iter != sm_LabelPosMap.end(); ++iter) {
291  if (iter->second == pos) {
292  return iter->first;
293  }
294  }
295  return kEmptyStr;
296 }
297 
299 static const THideSraStr s_HideSraStrs[] = {
301  { "both", CAlignmentConfig::eHide_Both },
302  { "duplicates", CAlignmentConfig::eHide_Duplicates },
303  { "none", CAlignmentConfig::eHide_None },
304 };
305 
308 
310 {
311  THideSraMap::const_iterator iter = sm_HideSraMap.find(hideSra);
312  if (iter != sm_HideSraMap.end()) {
313  return iter->second;
314  }
316 }
317 
319 {
321  for (iter = sm_HideSraMap.begin(); iter != sm_HideSraMap.end(); ++iter) {
322  if (iter->second == hideSra) {
323  return iter->first;
324  }
325  }
326  return kEmptyStr;
327 }
328 
329 // Unaligned tails
333  { "hide", CAlignmentConfig::eTails_Hide },
335 };
336 
339 
341 {
342  TUnalignedTailsModeMap::const_iterator iter = sm_UnalignedTailsModeMap.find(tailsMode);
343  if (iter != sm_UnalignedTailsModeMap.end()) {
344  return iter->second;
345  }
347 }
348 
350 {
352  for (iter = sm_UnalignedTailsModeMap.begin(); iter != sm_UnalignedTailsModeMap.end(); ++iter) {
353  if (iter->second == tailsMode) {
354  return iter->first;
355  }
356  }
357  return kEmptyStr;
358 }
359 
360 static const string kAlignGlyphKey = "GBPlugins.SeqGraphicAlignGlyphs";
361 static const string kMatePairKey = "GBPlugins.SeqGraphicMatePair";
362 static const string kBaseKey = "GBPlugins.SeqGraphicAlignment";
363 
364 static const string kTrackName = "Alignments";
365 static const string kDefProfile = "Default";
366 static const string kReadsProfile = "BAM";
367 
369  "Graphical View Alignment Track");
370 
372  : CDataTrack(r_cntx)
373  , m_ContentHandler(new CAlnContentEvtHandler(this))
374  , m_DS(ds)
375  , m_Layout(eLayout_Default)
376  , m_ShowAlignedSeqFeats(false)
377  , m_ShowLabel(true)
378  , m_ShowUnalignedTailsForTrans2GenomicAln(true)
379  , m_ShowAlnStat(false)
380  , m_ShowIdenticalBases(false)
381  , m_HideSraAlignments(CAlignmentConfig::eHide_None)
382  , m_UnalignedTailsMode(CAlignmentConfig::eTails_ShowGlyph)
383  , m_ShowSecondPassAlignments(true)
384  , m_CompactEnabled(true)
385  , m_CompactThreshold(100)
386  , m_ExtremeCompactThreshold(1000)
387  , m_AlnType(IAlnExplorer::fInvalid)
388  , m_ObjNum(0)
389  , m_Column(new CColumnLayout)
390  , m_GeneModelLayout(new CSimpleLayout)
391 {
392  m_DS->SetJobListener(this);
393  // initialize annotation selector
395  x_RegisterIcon(SIconInfo(eIcon_Content, "Content", true, "track_content"));
396  x_RegisterIcon(SIconInfo(eIcon_Layout, "Layout style",
397  true, "track_layout"));
398  x_RegisterIcon(SIconInfo(eIcon_Score, "Alignment score coloration",
399  true, "track_align_score"));
400  x_RegisterIcon(SIconInfo(eIcon_Stat, "Alignment statistics settings",
401  true, "track_stat"));
402  x_RegisterIcon(SIconInfo(eIcon_Tails, "Unaligned tails display settings",
403  true, "track_tails"));
404 
408 
409  // We want to put all alignments in one group if we want to cut off
410  // the number of rows displayed during layout. If we have multiple groups,
411  // the row number can not be easily determined
413 }
414 
415 
417 {
418  try {
419  m_DS->DeleteAllJobs();
420  SetGroup().Clear();
421  m_DS->ClearCache();
422  bool gbench_mode = !(m_gConfig && m_gConfig->GetCgiMode());
423  // gbench: release memory if there is a need
424  // sviewer: release memory occurs in m_DS destructor
425  if (gbench_mode && m_DS->NeedReleaseMemory())
426  m_DS->ReleaseMemory();
427  } catch (exception& e) {
428  ERR_POST(Error << e.what());
429  }
430 }
431 
432 
433 
435 {
436  return m_TypeInfo;
437 }
438 
439 
441 {
442  string title = GetTitle();
443  if (title.empty()) {
445  title = "Other alignments";
446  } else {
447  title = m_AnnotName;
448  }
449  }
450 
451  return title;
452 }
453 
454 
455 void CAlignmentTrack::SetAnnot(const string& annot)
456 {
457  m_AnnotName = annot;
458 }
459 
460 
462 {
463  // the menu item order:
464  // 0 - "Show labels"
465  // 1 - "Show unaligned tails for all alignments"
466  // 2 - "Show unaligned tails for transcript-to-genomic alignments"
467  // 3 - "Project features for aligned sequences"
468  // 4 - "Link mate pairs"
469  // 5 - Show Identical Bases"
470  switch (id) {
471  case 0:
472  {{
474  if (m_MultiAlignConf) {
476  }
477  if (m_PWAlignConf) {
479  }
480  if (m_AlignSmearConf) {
482  }
483  if (m_MatePairConf) {
485  }
486  break;
487  }}
488 
489  case 1:
490  {{
492  break;
493  }}
494  case 2:
496  break;
497  case 3:
499  break;
500  case 4:
501  {
502  string sort_by = (m_DS->GetSortBy() != CAlignStrandSorter::GetID()) ? CAlignStrandSorter::GetID() : "";
503  m_DS->SetSortBy(sort_by);
504  }
505  break;
506  case 5:
507  {
509  m_DS->SetSortBy(sort_by);
510  }
511  break;
512  case 6:
513  {
515  if (m_MultiAlignConf) {
517  }
518  if (m_PWAlignConf) {
520  }
521  }
522  break;
523  default:
524  break;
525  }
526  x_UpdateData();
527 }
528 
529 
531 {
534  const CFeatList* feat_list = CSeqFeatData::GetFeatList();
535  CFeatListItem item;
537  feat_list->GetItemBySubtype(*subtype, item);
538  items_set.insert(item);
539  }
540  dlg.SetSelected(items_set);
541  IGlyphDialogHost* dlg_host = dynamic_cast<IGlyphDialogHost*>(m_LTHost);
542  if (dlg_host) {
543  dlg_host->PreDialogShow();
544  }
545  if(dlg.ShowModal() == wxID_OK) {
546  dlg.GetSelected(items_set);
547  m_ProjectedFeats.clear();
549  m_ProjectedFeats.push_back(iter->GetSubtype());
550  }
551  x_UpdateData();
552  }
553  if (dlg_host) {
554  dlg_host->PostDialogShow();
555  }
556 }
557 
558 
559 void CAlignmentTrack::x_LoadSettings(const string& preset_style,
560  const TKeyValuePairs& settings)
561 {
562  if (preset_style.empty() || preset_style == kDefProfile) {
564  } else {
565  SetProfile(preset_style);
566  }
567 
568  if (!m_StatConf) {
570  }
571 
572 
574  CRegistryReadView view =
576 
577  m_DS->SetLinkMatePairs(view.GetBool("LinkMatePairAligns", false));
578  m_DS->SetDNAScoringMethod(view.GetString("DNAScoringMethod"));
579  m_DS->SetProteinScoringMethod(view.GetString("ProteinScoringMethod"));
580  m_DS->SetEnableColoration(view.GetBool("EnableColoration", true));
581  {
582  string memory_limit = view.GetString("memory_limit", "2GB");
584  }
585  m_ShowAlignedSeqFeats = view.GetBool("ShowAlignedSeqFeats", false);
586  m_ShowIdenticalBases = view.GetBool("ShowIdenticalBases", false);
587  m_ShowLabel = view.GetBool("ShowLabel", false);
588  m_ShowUnalignedTailsForTrans2GenomicAln = view.GetBool("ShowUnalignedTailsForTrans2GenomicAln", true);
589  m_ShowAlnStat = view.GetBool("ShowAlnStat", false);
590  m_CompactEnabled = view.GetBool("SupportCompactDisplay");
591  m_CompactThreshold = (size_t)view.GetInt("CompactThreshold", 100);
592  m_ExtremeCompactThreshold = (size_t)view.GetInt("ExtremeCompactThreshold", 1000);
593  m_StatConf->m_Display = view.GetInt("StatDisplay", 15);
594  m_StatConf->m_StatZoomLevel = view.GetInt("StatZoomLevel", 100);
595  m_HideSraAlignments = HideFlagStrToValue(view.GetString("HideSraAlignments"));
596  m_UnalignedTailsMode = UnalignedTailsModeStrToValue(view.GetString("UnalignedTailsMode"));
597  m_ShowSecondPassAlignments = view.GetBool("ShowSecondPass", true);
598  m_Layout = LayoutStrToValue(view.GetString("Layout"));
599 
600  m_MinPileUpCost = view.GetReal("MinPileUpCost", 3.);
601  m_MinAlignCost = view.GetReal("MinAlignCost", 1.5);
602  m_MaxAlignCost = view.GetReal("MaxAlignCost", 10.);
603  m_MaxAlignShownFull = view.GetInt("MaxAlignShownFull", 250000);
604  m_MaxAlignShownAdaptive = view.GetInt("MaxAlignShownAdaptive", 7500);
605 
606  CConstRef<CUser_field> f = view.GetField("ProjectedFeats");
607  if (f && f->GetData().Which() == CUser_field::TData::e_Str) {
608  string str = f->GetData().GetStr();
610  list<string> toks;
611  NStr::Split(str, ", |", toks, NStr::fSplit_Tokenize);
612  try {
613  ITERATE(list<string>, iter, toks)
614  {
615  m_ProjectedFeats.push_back(NStr::StringToInt(*iter));
616  }
617  } catch (CException& e) {
618  LOG_POST(Warning << "CAlignmentTrack::x_LoadSettings error on "
619  << "parsing projected feature list: " << e.GetMsg());
620  }
621  }
622 
623  m_MultiAlignProfile = view.GetString("MultiAlignProfile", kDefProfile);
624  m_PWAlignProfile = view.GetString("PWAlignProfile", kDefProfile);
625  m_AlignSmearProfile = view.GetString("AlignSmearProfile", kDefProfile);
626  m_MatePairProfile = view.GetString("MatePairProfile", kDefProfile);
627  {
637  }
638  CRef<CHistParams> graph_params = x_GetGraphParams();
639  {
641  _ASSERT(graph_params);
642  if (graph_params) {
643  graph_params->m_Height = size_view.GetInt("GraphHeight", 45);
644  graph_params->m_Scale = CHistParams::ScaleStrToValue(view.GetString("GraphScale", "log2"));
645  }
646  }
647 
648  // override those default settings passed in through profile settings
649  ITERATE (TKeyValuePairs, iter, settings) {
650  try {
651  if (NStr::EqualNocase(iter->first, "Color")) {
652  if (NStr::EqualNocase(iter->second, "false")) {
653  m_DS->SetEnableColoration(false);
654  } else {
655  m_DS->SetEnableColoration(true);
656  if ( !NStr::EqualNocase(iter->second, "true") ) {
659  m_DS->IsValidProteinScoringMethod(iter->second)) {
660  m_DS->SetProteinScoringMethod(iter->second);
661  } else if (m_DS->IsValidDNAScoringMethod(iter->second)) {
662  // treat it as DNA
663  m_DS->SetDNAScoringMethod(iter->second);
664  }
665  }
666  }
667  } else if (NStr::EqualNocase(iter->first, "DNAScoringMethod")) {
668  m_DS->SetDNAScoringMethod(iter->second);
669  } else if (NStr::EqualNocase(iter->first, "ProteinScoringMethod")) {
670  m_DS->SetProteinScoringMethod(iter->second);
671  } else if (NStr::EqualNocase(iter->first, "AlignedSeqFeats"))
673  else if (NStr::EqualNocase(iter->first, "IdenticalBases"))
675  else if (NStr::EqualNocase(iter->first, "Label"))
676  m_ShowLabel = NStr::StringToBool(iter->second);
677  else if (NStr::EqualNocase(iter->first, "ShowUnalignedTailsForTrans2GenomicAln"))
679  else if (NStr::EqualNocase(iter->first, "LinkMatePairAligns"))
680  m_DS->SetLinkMatePairs(NStr::StringToBool(iter->second));
681  else if (NStr::EqualNocase(iter->first, "Layout")) {
682  m_Layout = LayoutStrToValue(iter->second);
683  m_IsDefaultLayout = false;
684  } else if (NStr::EqualNocase(iter->first, "StatDisplay"))
685  m_StatConf->m_Display = NStr::StringToInt(iter->second);
686  else if (NStr::EqualNocase(iter->first, "StatZoomLevel")) {
688  } else if (NStr::EqualNocase(iter->first, "ShowAlnStat")) {
689  m_ShowAlnStat = NStr::StringToBool(iter->second);
690  } else if (NStr::EqualNocase(iter->first, "SupportCompactDisplay")) {
691  m_CompactEnabled = NStr::StringToBool(iter->second);
692  } else if (NStr::EqualNocase(iter->first, "SortBy")) {
693  m_DS->SetSortBy(iter->second);
694  } else if (NStr::EqualNocase(iter->first, "GraphHeight")) {
695  int height = NStr::StringToInt(iter->second, NStr::fConvErr_NoThrow);
696  if (height >= 10 && graph_params) {
697  graph_params->m_Height = height;
698  }
699  } else if (NStr::EqualNocase(iter->first, "GraphScale")) {
700  graph_params->m_Scale = CHistParams::ScaleStrToValue(iter->second);
701  } else if (NStr::EqualNocase(iter->first, "GraphColor")) {
702  CRgbaColor c(iter->second);
704  if (graph_params)
705  graph_params->m_fgColor = c;
706  } else if (NStr::EqualNocase(iter->first, "ProjectedFeats")) {
707  list<string> toks;
708  NStr::Split(iter->second, ", |", toks, NStr::fSplit_Tokenize);
709  if ( !toks.empty() ) {
710  m_ProjectedFeats.clear();
711  }
712  try {
713  ITERATE (list<string>, f_iter, toks) {
714  m_ProjectedFeats.push_back(NStr::StringToInt(*f_iter));
715  }
716  } catch (CException& e) {
717  LOG_POST(Warning << "CAlignmentTrack::x_LoadSettings() error on "
718  <<"parsing projected feature list: " << e.GetMsg());
719  }
720  } else if (NStr::EqualNocase(iter->first, "HideSraAlignments")) {
721  m_HideSraAlignments = HideFlagStrToValue(iter->second);
722  } else if (NStr::EqualNocase(iter->first, "UnalignedTailsMode")) {
724  } else if (NStr::EqualNocase(iter->first, "ShowSecondPass")) {
726  } else if (NStr::EqualNocase(iter->first, "MinPileUpCost")) {
727  auto v = NStr::StringToNumeric<double>(iter->second, NStr::fConvErr_NoThrow);
728  if (v > 0)
729  m_MinPileUpCost = v;
730  } else if (NStr::EqualNocase(iter->first, "MinAlignCost")) {
731  auto v = NStr::StringToNumeric<double>(iter->second, NStr::fConvErr_NoThrow);
732  if (v > 0)
733  m_MinAlignCost = v;
734  } else if (NStr::EqualNocase(iter->first, "MaxAlignCost")) {
735  auto v = NStr::StringToNumeric<double>(iter->second, NStr::fConvErr_NoThrow);
736  if (v > 0)
737  m_MaxAlignCost = v;
738  } else if (NStr::EqualNocase(iter->first, "MaxAlignShownFull")) {
739  auto v = NStr::StringToNumeric<int>(iter->second, NStr::fConvErr_NoThrow);
740  if (v > 0)
742  } else if (NStr::EqualNocase(iter->first, "MaxAlignShownAdaptive")) {
743  auto v = NStr::StringToNumeric<int>(iter->second, NStr::fConvErr_NoThrow);
744  if (v > 0)
746  }
747  } catch (CException&) {
748  LOG_POST(Warning << "CAlignmentTrack::x_LoadSettings() invalid settings: "
749  << iter->first << ":" << iter->second);
750  }
751  }
752 
754  if (m_MultiAlignConf) {
756  }
757  if (m_AlignSmearConf) {
759  }
760  if (m_MPPWAlignConf) {
762  }
763  if (m_MatePairConf) {
765  }
768  }
771  }
772 
774 
776 
777  // enable pileup only if match/mistamtch graph is requested
778  // enable permanent(inetcahe) cache if in cgi mode only
779  bool has_pileup_cache = m_DS->HasCoverageGraph() && !m_StatConf->ShowAGTC();
780  m_DS->EnablePileUpCache(has_pileup_cache, m_gConfig->GetCgiMode());
781 
782  // Load CDS settings using GeneModel track key
783  // not going to save it because
784  // 1. the settings belong to GeneModel track and this tracks just borrows them
785  // 2. no changes expected from alignment track
786  if (!m_GeneModelConfig) {
788  }
789 
791 /*
792  view = CSGConfigUtils::GetColorReadView(
793  registry, kCDSKey, kDefProfile, m_gConfig->GetColorTheme(), kDefProfile);
794  CSGConfigUtils::GetColor(view, "BGProtProduct", m_CdsConfig->m_bgProtProd);
795  CSGConfigUtils::GetColor(view, "FGProtProduct", m_CdsConfig->m_fgProtProd);
796  CSGConfigUtils::GetColor(view, "LabelProtProduct", m_CdsConfig->m_LabelProtProd);
797  CSGConfigUtils::GetColor(view, "SeqProtOriginal", m_CdsConfig->m_SeqProt);
798  CSGConfigUtils::GetColor(view, "SeqProtMismatch", m_CdsConfig->m_SeqProtMismatch);
799  CSGConfigUtils::GetColor(view, "SeqProtTranslated", m_CdsConfig->m_SeqProtTrans);
800 
801  // load size settings
802  view = CSGConfigUtils::GetSizeReadView(
803  registry, kCDSKey, kDefProfile, m_gConfig->GetSizeLevel(), kDefProfile);
804 
805  CSGConfigUtils::GetFont(view, "ProdFontFace", "ProdFontSize", m_CdsConfig->m_ProdFont);
806  CSGConfigUtils::GetFont(view, "TransFontFace", "TransFontSize", m_CdsConfig->m_TransFont);
807 */
809 
813 }
814 
815 
816 void CAlignmentTrack::x_SaveSettings(const string& preset_style)
817 {
818  TKeyValuePairs settings;
819 
820  if ( !preset_style.empty() ) {
821  settings["profile"] = preset_style;
822  }
823 
824  settings["Color"] = NStr::BoolToString(m_DS->GetEnableColoration());
825  settings["DNAScoringMethod"] = m_DS->GetDNAScoringMethod();
826  settings["ProteinScoringMethod"] = m_DS->GetProteinScoringMethod();
827  settings["AlignedSeqFeats"] = NStr::BoolToString(m_ShowAlignedSeqFeats);
828  settings["IdenticalBases"] = NStr::BoolToString(m_ShowIdenticalBases);
829  settings["Label"] = NStr::BoolToString(m_ShowLabel);
830  settings["LinkMatePairAligns"] = NStr::BoolToString(m_DS->GetLinkMatePairs());
831  settings["ShowUnalignedTailsForTrans2GenomicAln"] =
833  settings["Layout"] = LayoutValueToStr(m_Layout);
834 
835  string projected_feats = kEmptyStr;
837  projected_feats += NStr::IntToString(*iter) + " ";
838  }
839  if ( !projected_feats.empty() ) {
840  settings["ProjectedFeats"] = projected_feats;
841  }
842  settings["StatDisplay"] = NStr::IntToString(m_StatConf->m_Display);
843  settings["ShowAlnStat"] = NStr::BoolToString(m_ShowAlnStat);
844  settings["SupportCompactDisplay"] = NStr::BoolToString(m_CompactEnabled);
845  settings["StatZoomLevel"] = NStr::IntToString(m_StatConf->m_StatZoomLevel);
846  settings["HideSraAlignments"] = HideFlagValueToStr(m_HideSraAlignments);
847  settings["UnalignedTailsMode"] = UnalignedTailsModeValueToStr(m_UnalignedTailsMode);
848  settings["SortBy"] = m_DS->GetSortBy();
850 }
851 
852 
854 {
855  switch (id) {
856  case eIcon_Content:
858  break;
859  case eIcon_Layout:
861  break;
862  case eIcon_Score:
864  break;
865  case eIcon_Stat:
867  break;
868  case eIcon_Tails:
870  break;
871  default:
872  // use default handlers
874  }
875 }
876 
877 
879 {
880  m_DS->DeleteAllJobs();
882 
883  int align_limit = x_LayoutToCutoff(m_Layout);
884  const TSeqRange& vis_range = m_Context->GetVisSeqRange();
885  const TModelUnit& zoom_level = m_Context->GetScale();
886 /*
887  // CSRA Estimate is not accurate yet
888  if (m_DS->IsCSRALoader() && m_DS->HasCoverageGraph()) {
889  if (m_Context->GetScale() > m_StatConf->m_StatZoomLevel) {
890  m_DS->LoadCoverageGraph(vis_range, zoom_level, eJob_CoverageGraph);
891  } else {
892  if (m_Layout != eLayout_Packed) {
893  align_limit = x_LayoutToCutoff_SRA(m_Layout);
894  m_DS->LoadAlignments(vis_range, zoom_level, align_limit,
895  false, eJob_Align);
896  } else {
897  if (!m_StatGlyph)
898  SetGroup().Clear();
899  CSGAlignmentDS::TAlnMgrVec stat_aligns;
900  m_DS->CalcAlnStat(stat_aligns, m_Context->GetVisSeqRange(), m_Context->GetScale(), eJob_AlignStat);
901  }
902 
903  }
904  return;
905  }
906 */
907  if (m_DS->NeedReleaseMemory()) {
908  CRef<CSeqGlyph> p_glyph = SetGroup().GetChild(static_cast<int>(m_StatGlyph.size()));
909  auto p_group = dynamic_cast<CLayoutGroup*>(p_glyph.GetPointer());
910  if (p_group) {
911  SetGroup().Remove(p_group);
912  } else {
913  m_StatGlyph.clear();
914  SetGroup().Clear();
915  }
916  m_DS->ReleaseMemory();
917  }
918 
919  auto align_cost = -1;
920  bool sequence_level = m_Context->GetScale() <= 1./8.;
921  bool show_all = m_Layout == eLayout_Full || m_Layout == eLayout_ExpandedByPos;
922 
923  if (show_all) {
924  if (!sequence_level)
925  align_cost = m_DS->GetAlignmentCost(vis_range);
926  if (align_cost <= m_MaxAlignCost) {
927  m_DS->LoadAlignments(vis_range, zoom_level, m_MaxAlignShownFull, false, eJob_Align);
928  return;
929  }
930  }
931 
932  bool show_pileup_cache = vis_range.GetLength() < kShowPileUpRange || m_DS->IsRangeCached(vis_range);
933  if (m_DS->HasCoverageGraph()) {
934  // bam/csra alignments
935  bool show_coverage = !sequence_level;
936  if (show_coverage) {
937  if (show_pileup_cache) {
938  show_coverage = false;
939  }
940  else if (!m_StatConf->ShowAGTC()) {
942  show_coverage = m_DS->GetGraphCost(vis_range) > m_MinPileUpCost;
943  //show_coverage = m_DS->GetGraphCost(vis_range) > m_MinPileUpCost;
944  } else {
946  show_coverage = m_DS->GetGraphCost(vis_range) > m_MinPileUpCost;
947  }
948  }
949  if (show_coverage) {
950  m_DS->LoadCoverageGraph(vis_range, zoom_level, eJob_CoverageGraph);
951  } else {
952  bool show_aligns = false;
953  if (m_Layout != eLayout_Packed) {
954  if (align_cost < 0)
955  align_cost = m_DS->GetAlignmentCost(vis_range);
956  show_aligns = (align_cost <= m_MinAlignCost && m_DS->CanShowRange(vis_range, align_limit * 1.5))
957  || (align_cost <= m_MaxAlignCost && sequence_level);
958 
959  }
960  if (show_aligns) {
961  m_DS->LoadAlignments(vis_range, zoom_level, align_limit, false, eJob_Align);
962  // After alignment loading job is completed, align pileup graph can be loaded.
963  } else {
964  CRef<CSeqGlyph> p_glyph = SetGroup().GetChild(static_cast<int>(m_StatGlyph.size()));
965  auto p_group = dynamic_cast<CLayoutGroup*>(p_glyph.GetPointer());
966  if (p_group) {
967  SetGroup().Remove(p_group);
968  } else {
969  m_StatGlyph.clear();
970  SetGroup().Clear();
971  }
972  CSGAlignmentDS::TAlnMgrVec stat_aligns;
974  }
975  }
976  } else {
977  // regular alignment annotation
978  bool show_stat = m_ShowAlnStat && m_AlnType == IAlnExplorer::fDNA;
979  if (show_stat) {
980  if (align_cost < 0)
981  align_cost = m_DS->GetAlignmentCost(vis_range);
982  show_stat = show_stat && align_cost > m_MinAlignCost;
983  }
984  // Alignment statistics job, if enabled, will be
985  // launched right after alignments get loaded.
986  static const int kMaxRegulatAlignmentRows = 1000;
987  align_limit = kMaxRegulatAlignmentRows;
988  bool smear = m_Layout == eLayout_Adaptive;
989  if (m_Layout == eLayout_Packed) {
990  align_limit = -1;
991  smear = true;
992  }
993  m_DS->LoadAlignments(vis_range, zoom_level, align_limit, smear, eJob_Align);
994  }
995 }
996 
997 
999 {
1000  m_DS->ClearJobID(notify.GetJobID());
1001  CRef<CObject> res_obj = notify.GetResult();
1002  CJobResultBase* result = dynamic_cast<CJobResultBase*>(&*res_obj);
1003  if (!result) {
1004  LOG_POST(Error << "CAignmentTrack::x_OnJobCompleted() notification for job \
1005  does not contain results.");
1006  return;
1007  }
1008  CSGAlignJobResult* aln_result = dynamic_cast<CSGAlignJobResult*>(result);
1009  if (aln_result && aln_result->m_DataHandle)
1010  m_DS->SetDataHandle(aln_result->m_DataHandle);
1011 
1012  switch (result->m_Token) {
1013  case eJob_Align:
1014  x_AddAlignmentLayout(dynamic_cast<CSGJobResult&>(*res_obj));
1015  break;
1016  case eJob_AlignFeats:
1017  x_AddAlignFeatLayout(dynamic_cast<CBatchJobResult&>(*res_obj));
1018  break;
1019  case eJob_AlignScore:
1021  x_SetMsg();
1022 
1023  // make sure we don't update layout twice for synchronized jobs
1024  if (m_DS->IsBackgroundJob()) {
1025  // No need to update layout, just redraw
1026  // x_UpdateLayout();
1028  }
1030  break;
1031  case eJob_CoverageGraph:
1032  x_AddGraphLayout(dynamic_cast<CSGJobResult&>(*res_obj));
1033  break;
1034  case eJob_AlignStat:
1035  x_AddAlignStatLayout(dynamic_cast<CSGJobResult&>(*res_obj));
1036  break;
1037  default:
1038  break;
1039  }
1040 }
1041 
1042 
1044 {
1045  wxMenu menu;
1046  int curr_id = 0;
1047  wxMenuItem* item;
1048  item = menu.AppendCheckItem(kContentBaseID + curr_id++, wxT("Show labels"));
1049  if (m_ShowLabel) {
1050  item->Check();
1051  }
1052  item = menu.AppendCheckItem(kContentBaseID + curr_id++,
1053  wxT("Show alignment statistics"));
1054  if (m_ShowAlnStat) {
1055  item->Check();
1056  }
1057  item = menu.AppendCheckItem(kContentBaseID + curr_id++,
1058  wxT("Project features for aligned sequences"));
1059  if (m_ShowAlignedSeqFeats) {
1060  item->Check();
1061  }
1062  item = menu.AppendCheckItem(kContentBaseID + curr_id++, wxT("Link mate pairs"));
1063  if (m_DS->GetLinkMatePairs()) {
1064  item->Check();
1065  }
1066  item = menu.AppendCheckItem(kContentBaseID + curr_id++, wxT("Sort alignments by strand"));
1067  if ( m_DS->GetSortBy() == CAlignStrandSorter::GetID() ) {
1068  item->Check();
1069  }
1070  item = menu.AppendCheckItem(kContentBaseID + curr_id++, wxT("Sort alignments by haplotype"));
1072  item->Check();
1073  }
1074  item = menu.AppendCheckItem(kContentBaseID + curr_id++,
1075  wxT("Show identical bases"));
1076  if (m_ShowIdenticalBases) {
1077  item->Check();
1078  }
1079 
1080  menu.AppendSeparator();
1081  item = menu.Append(kProjectedFeatID, wxT("Change projected feature list..."));
1082 
1084  m_LTHost->LTH_PopupMenu(&menu);
1086 }
1087 
1088 
1090 {
1091  wxMenu menu;
1092  UseDefaultMarginWidth(menu);
1093  int id_base = 10000;
1094 
1095  for (const auto iter : sm_LayoutDispMap) {
1096  bool l_default = iter.first == eLayout_Default;
1097  wxMenuItem* item = menu.AppendRadioItem(id_base + iter.first,
1098  ToWxString(iter.second + (l_default ? " (Default)" : "")));
1099  if (m_Layout == iter.first) {
1100  item->Check();
1101  }
1102  }
1103 
1104  int compact_item_idx = id_base + max(100, (int)sm_LayoutDispMap.size());
1105  {
1106  menu.AppendSeparator();
1107  wxMenuItem* item = menu.AppendCheckItem(compact_item_idx,
1108  wxT("Enable compact display"));
1109  item->Check(m_CompactEnabled);
1110  }
1111 
1112  m_LTHost->LTH_PopupMenu(&menu);
1113  wxMenuItemList& item_list = menu.GetMenuItems();
1114  ITERATE (wxMenuItemList, iter, item_list) {
1115  if ((*iter)->GetId() == compact_item_idx) {
1116  if (m_CompactEnabled != (*iter)->IsChecked()) {
1117  m_CompactEnabled = (*iter)->IsChecked();
1118  x_UpdateData();
1119  break;
1120  }
1121  } else {
1122  ELayout id = (ELayout)((*iter)->GetId() - id_base);
1123  if ((*iter)->IsChecked() && id != m_Layout) {
1124  m_Layout = id;
1125  m_IsDefaultLayout = false;
1127  x_UpdateData();
1128  break;
1129  }
1130  }
1131  }
1132 }
1133 
1134 
1136 {
1138  return;
1139  }
1140 
1141  wxMenu menu;
1142  UseDefaultMarginWidth(menu);
1143  int id_base = 10000;
1144  int score_id = 0;
1145  int curr_id = 0;
1146 
1147 
1148  const string curr_method = m_AlnType == IAlnExplorer::fDNA ?
1150 
1152  ITERATE (CSGAlignmentDS::TMethods, iter, methods) {
1153  wxMenuItem* item = menu.AppendRadioItem(id_base + curr_id,
1154  ToWxString((*iter)->GetName()),
1155  ToWxString((*iter)->GetDescription()));
1156 
1157  if (curr_method == (*iter)->GetName()) {
1158  item->Check();
1159  score_id = curr_id;
1160  }
1161  curr_id++;
1162  }
1163  if (m_DS->HasQualityMap()) {
1164  const string& score_name = CSGAlnQualityScore::GetScoreName();
1165  wxMenuItem* item = menu.AppendRadioItem(id_base + curr_id,
1166  ToWxString(score_name), ToWxString(score_name));
1167 
1168  if (curr_method == score_name) {
1169  item->Check();
1170  score_id = curr_id;
1171  }
1172  curr_id++;
1173  }
1174 
1175  wxMenuItem* item = menu.AppendRadioItem(id_base + curr_id, wxT("Disabled"));
1176  if ( !m_DS->GetEnableColoration() ) {
1177  item->Check();
1178  score_id = curr_id;
1179  }
1180 
1181  m_LTHost->LTH_PopupMenu(&menu);
1182  wxMenuItemList& item_list = menu.GetMenuItems();
1183  ITERATE (wxMenuItemList, iter, item_list) {
1184  int checked_id = (*iter)->GetId() - id_base;
1185  if ((*iter)->IsChecked() && score_id != checked_id) {
1186  if (checked_id == curr_id) {
1187  m_DS->SetEnableColoration(false);
1188  } else {
1189  m_DS->SetEnableColoration(true);
1190  if (m_AlnType == IAlnExplorer::fDNA) {
1191  m_DS->SetDNAScoringMethod(ToStdString((*iter)->GetItemLabel()));
1192  } else if (m_AlnType == IAlnExplorer::fProtein ||
1194  m_DS->SetProteinScoringMethod(ToStdString((*iter)->GetItemLabel()));
1195  }
1196  }
1197  x_UpdateData();
1198  break;
1199  }
1200  }
1201 }
1202 
1203 
1205 {
1206  if ( !m_StatConf)
1207  return;
1208  auto graph_params = x_GetGraphParams();
1209  if (!graph_params)
1210  return;
1211 
1213  dlg.SetContent(m_StatConf->ShowAGTC());
1216  dlg.SetGraphHeight(graph_params->m_Height);
1218  IGlyphDialogHost* dlg_host = dynamic_cast<IGlyphDialogHost*>(m_LTHost);
1219  if (dlg_host) {
1220  dlg_host->PreDialogShow();
1221  }
1222  if(dlg.ShowModal() == wxID_OK) {
1227  graph_params->m_Height = max(dlg.GetGraphHeight(), 10);
1228  m_ShowAlnStat = true;
1229  x_UpdateData();
1230  }
1231  if (dlg_host) {
1232  dlg_host->PostDialogShow();
1233  }
1234 }
1235 
1237 {
1238  wxMenu menu;
1239  UseDefaultMarginWidth(menu);
1240 
1241  int id_base = 10000;
1242  int curr_id = 0;
1243 
1244  wxMenuItem* items[3];
1245  items[0] = menu.AppendRadioItem(id_base + curr_id++, "Hide tails", "Hide the unaligned tails");
1246  items[1] = menu.AppendRadioItem(id_base + curr_id++, "Show tail length", "Display the length of the unaligned tails");
1247  items[2] = menu.AppendRadioItem(id_base + curr_id++, "Show tail sequence", "Display the unaligned tails row sequence");
1248  items[m_UnalignedTailsMode]->Check();
1249  menu.AppendSeparator();
1250  wxMenuItem* itemTrans2Genomic = menu.AppendCheckItem(kContentBaseID + curr_id++,
1251  wxT("Show unaligned tails for transcript-to-genomic alignments"));
1253  itemTrans2Genomic->Check();
1254  }
1255  m_LTHost->LTH_PopupMenu(&menu);
1256 
1258  if (items[1]->IsChecked())
1259  newTailsMode = CAlignmentConfig::eTails_ShowGlyph;
1260  else if (items[2]->IsChecked())
1262 
1263  bool update = false;
1264  if (newTailsMode != m_UnalignedTailsMode) {
1265  m_UnalignedTailsMode = newTailsMode;
1266  update = true;
1267  }
1268 
1269  if (m_ShowUnalignedTailsForTrans2GenomicAln != itemTrans2Genomic->IsChecked()) {
1270  m_ShowUnalignedTailsForTrans2GenomicAln = itemTrans2Genomic->IsChecked();
1271  update = true;
1272  }
1273 
1274  if (update) {
1275  if (m_PWAlignConf) {
1278  }
1279  if (m_AlignSmearConf) {
1282  }
1283 
1285 
1286  x_UpdateData();
1287  }
1288 }
1289 
1291 {
1292  CLayoutGroup* p_group = NULL;
1293  if (!m_StatGlyph.empty()) {
1294 // if (m_StatGlyph) {
1296 // CRef<CSeqGlyph> p_glyph = SetGroup().GetChild(1);
1297  CRef<CSeqGlyph> p_glyph = SetGroup().GetChild(static_cast<int>(m_StatGlyph.size()));
1298  if (p_glyph) {
1299  p_group = dynamic_cast<CLayoutGroup*>(p_glyph.GetPointer());
1300  if (m_Layout == eLayout_Packed) {
1301  SetGroup().Remove(p_group);
1302  p_group = NULL;
1303  }
1304  }
1305  } else {
1306  p_group = &SetGroup();
1307  }
1308  if (!p_group)
1309  return;
1310 
1311  const CNamedGroup* first_group = NULL;
1312  if ( !p_group->GetChildren().empty() ) {
1313  first_group = dynamic_cast<const CNamedGroup*>(p_group->GetChildren().front().GetPointer());
1314  }
1315 
1316  p_group->SetTearline(0);
1317  vector<CLayoutGroup*> groups;
1318  if (first_group) {
1319  NON_CONST_ITERATE (CSeqGlyph::TObjects, grp_iter, p_group->SetChildren()) {
1320  CNamedGroup* curr_group = dynamic_cast<CNamedGroup*>(grp_iter->GetPointer());
1321  _ASSERT(curr_group);
1322  groups.push_back(curr_group);
1323  }
1325  } else {
1326  groups.push_back(p_group);
1327  }
1328 
1329  NON_CONST_ITERATE (vector<CLayoutGroup*>, g_iter, groups) {
1330  CLayoutGroup* curr_group = *g_iter;
1332  curr_group->SetLayoutPolicy(m_Simple);
1333  curr_group->SetTearline(eMaxRowLimit);
1336  } else {
1338  curr_group->SetLayoutPolicy(m_Column);
1339  curr_group->SetTearline(0);
1340 
1341  // Lets us limit the number of alignments displayed.
1342  // Setting this to 0 disables the restriction
1344  curr_group->SetTearline(eAdaptiveRowLimit);
1346  curr_group->SetTearline(eMaxRowLimit);
1347  }
1348  }
1349 }
1350 
1351 
1353 {
1354  //TIME_ME("x_AddAlignmentLayout()");
1355  SetMsg("");
1356  m_ObjNum = result.m_ObjectList.size();
1357  const CNamedGroup* first_group = NULL;
1358  if (m_ObjNum > 0) {
1359  first_group = dynamic_cast<const CNamedGroup*>(result.m_ObjectList.front().GetPointer());
1360  } else {
1361  // an empty track should navigable in case there are out of range object
1362  //if (m_ObjNum == 0) {
1363  m_Attrs |= fNavigable;
1364  }
1365 
1366 
1367  if (m_AlnType == IAlnExplorer::fInvalid && m_ObjNum > 0) {
1368  if (first_group) {
1369  m_AlnType = m_DS->GetAlignType(first_group->GetChildren().front());
1370  } else {
1371  m_AlnType = m_DS->GetAlignType(result.m_ObjectList.front());
1372  }
1373  }
1374 
1375  bool show_stat = (m_ShowAlnStat ||
1376  (m_DS->HasCoverageGraph() && m_ObjNum == 0)) &&
1377  // m_Context->GetScale() <= m_StatConf->m_StatZoomLevel &&
1378  // For cSRA data (with coverage graph), no need to check align type.
1380 
1381  /// all alignment we want to calculate statistics
1382  CSGAlignmentDS::TAlnMgrVec stat_aligns;
1383 
1384  // Trying to find out where to add the newly loaded objects.
1385  // Depending on what is currently being shown, we might have different
1386  // object hierarchies:
1387  // 1. both pileup and alignments
1388  // group--
1389  // |-- pileup glyph
1390  // |-- group--
1391  // |-- alignments
1392  //
1393  // 2. only smear bar or coverage graph
1394  // group--
1395  // |-- smear bar/coverage graph
1396  //
1397  // 3. only pileup
1398  // group--
1399  // |-- pileup glyph
1400  //
1401  // 4. only alignments
1402  // group--
1403  // |-- alignments
1404  //
1405 
1406  if (show_stat)
1407  // turn off navigation controls
1408  m_Attrs &= ~fNavigable;
1409 
1410  CLayoutGroup* p_group = NULL;
1411  if ( !show_stat ) {
1412  // If we are not going to show pileup (regardless of it was shown
1413  // or not), use the top level group as the parent group
1414  p_group = &SetGroup();
1415  //m_StatGlyph.Reset();
1416  m_StatGlyph.clear();
1417  } else if (!m_StatGlyph.empty()) {
1418  //} else if (m_StatGlyph) {
1419  // we are showing the pipleup, and will keep showing it.
1420  if (SetGroup().GetChildrenNum() > m_StatGlyph.size()) {
1421  // case #1
1422  // _ASSERT(SetGroup().GetChildrenNum() == 2);
1423  // CRef<CSeqGlyph> p_glyph = SetGroup().GetChild(1);
1424  CRef<CSeqGlyph> p_glyph = SetGroup().GetChild(static_cast<int>(m_StatGlyph.size()));
1425  p_group = dynamic_cast<CLayoutGroup*>(p_glyph.GetPointer());
1426  _ASSERT(p_group);
1427  if (m_ObjNum == 0) {
1428  SetGroup().Remove(p_group);
1429  p_group = NULL;
1430  }
1431  } else if (m_ObjNum > 0) {
1432  // case #3
1433  CRef<CLayoutGroup> group(new CLayoutGroup);
1434  p_group = group.GetPointer();
1435  SetGroup().PushBack(p_group);
1436  }
1437  } else {
1438  // We are not showing the pipleup, and will show it.
1439  // This falls to case #2 or #4
1440  p_group = &SetGroup();
1441  }
1442 
1443  if (p_group) {
1444  p_group->Clear();
1445  } else {
1446  x_UpdateLayout();
1447  if (show_stat) {
1448  m_DS->CalcAlnStat(stat_aligns, m_Context->GetVisSeqRange(),
1450  }
1451  return;
1452  }
1453 
1454  p_group->Set(result.m_ObjectList);
1455 
1456  /// all alignments we want to project features from
1457  vector< CRef<CAlignGlyph> > aligns;
1458 
1459  bool project_feats = m_ShowAlignedSeqFeats &&
1460  !m_Context->IsOverviewMode() &&
1461  !m_ProjectedFeats.empty();
1462 
1463 
1464  vector<CLayoutGroup*> groups;
1465  if (first_group) {
1466  NON_CONST_ITERATE (CSeqGlyph::TObjects, grp_iter, p_group->SetChildren()) {
1467  CNamedGroup* curr_group = dynamic_cast<CNamedGroup*>(grp_iter->GetPointer());
1468  _ASSERT(curr_group);
1469 
1470  // initialize named group
1471  curr_group->SetTitleColor(m_gConfig->GetFGCommentColor());
1473  curr_group->SetTitleFont(m_gConfig->GetCommentFont().GetPointer());
1474  curr_group->SetIndent(GetIndent() + 2);
1476  curr_group->SetRepeatTitle(m_gConfig->GetRepeatComment());
1477  curr_group->SetShowTitle(m_gConfig->GetShowComments());
1478  groups.push_back(curr_group);
1479  }
1480  } else {
1481  groups.push_back(p_group);
1482  }
1483 
1484  bool show_score = !m_Context->IsOverviewMode() &&
1487 
1488  CSeqGlyph::TObjects scored_alns;
1489  m_ObjNum = 0;
1490  NON_CONST_ITERATE (vector<CLayoutGroup*>, g_iter, groups) {
1491  CSeqGlyph::TObjects& objs = (*g_iter)->SetChildren();
1492  m_ObjNum += objs.size();
1493  //if (show_score) {
1494  // std::copy(objs.begin(), objs.end(), back_inserter(scored_alns));
1495  //}
1496 
1497  NON_CONST_ITERATE (CSeqGlyph::TObjects, iter, objs) {
1498  CSeqGlyph* tmp = *iter;
1499  tmp->SetRenderingContext(m_Context);
1501 
1502  switch (type)
1503  {
1504  case eAlign_Multi:
1505  {{
1506  if ( !m_MultiAlignConf ) {
1508  }
1509  CAlignGlyph* aln = dynamic_cast<CAlignGlyph*>(tmp);
1511  if (show_stat) {
1512  stat_aligns.emplace_back(&aln->GetAlignMgr());
1513  }
1514  if (show_score && aln->GetAlignMgr().IsColoringAvailable()) {
1515  scored_alns.emplace_back(tmp);
1516  }
1517  m_Attrs |= fNavigable;
1518 
1519  }}
1520  break;
1521  case eAlign_PW:
1522  {{
1523  CAlignGlyph* aln = dynamic_cast<CAlignGlyph*>(tmp);
1524  aln->SetConfig(m_PWAlignConf);
1525  if (project_feats) {
1526  // project the annotated features on the aligned
1527  // sequence onto the top sequence
1528  x_LoadAlignedSeqFeats(aligns, aln);
1529  }
1530  if (show_stat) {
1531  stat_aligns.emplace_back(&aln->GetAlignMgr());
1532  }
1533  if (show_score && aln->GetAlignMgr().IsColoringAvailable()) {
1534  if (aln->IsSimplified()) {
1535  aln->SetShowScore();
1536  } else {
1537  scored_alns.emplace_back(tmp);
1538  }
1539  }
1540  m_Attrs |= fNavigable;
1541  }}
1542  break;
1543  case eAlign_MatePair:
1544  {{
1545  if ( !m_MatePairConf ) {
1548  }
1549  CMatePairGlyph* mp = dynamic_cast<CMatePairGlyph*>(tmp);
1550  CMatePairGlyph::TAlignList& mp_aligns = mp->SetSeqAligns();
1552  NON_CONST_ITERATE(CMatePairGlyph::TAlignList, mp_iter, mp_aligns) {
1553  (*mp_iter)->SetConfig(mp_aligns.size() == 1 ? m_PWAlignConf : m_MPPWAlignConf);
1554  (*mp_iter)->SetRenderingContext(m_Context);
1555  if (show_stat) {
1556  stat_aligns.emplace_back(&(*mp_iter)->GetAlignMgr());
1557  }
1558  if (show_score && (*mp_iter)->GetAlignMgr().IsColoringAvailable()) {
1559  if ((*mp_iter)->IsSimplified()) {
1560  (*mp_iter)->SetShowScore();
1561  } else {
1562  scored_alns.emplace_back(mp_iter->GetPointer());
1563  }
1564  }
1565  }
1566  m_Attrs |= fNavigable;
1567  }}
1568  break;
1569  case eAlign_Smear:
1570  {{
1571  if ( !m_AlignSmearConf ) {
1574  // Hide the label for AlignDb smear glyphs
1575  m_AlignSmearConf->m_ShowLabel = false;
1576  }
1577  }
1578  CAlignSmearGlyph* as = dynamic_cast<CAlignSmearGlyph*>(tmp);
1580  }}
1581  break;
1582  case eAlign_Graph:
1583  {{
1584  CHistogramGlyph* graph = dynamic_cast<CHistogramGlyph*>(tmp);
1585  graph->SetDialogHost(dynamic_cast<IGlyphDialogHost*>(m_LTHost));
1586  graph->SetConfig(*m_gConfig);
1587  string coverage_annot;
1589 
1590  graph->SetAnnotName(coverage_annot);
1591  SetMsg(", Coverage graph");
1592  }}
1593  break;
1594  default:
1595  break;
1596  }
1597  }
1598  }
1599 
1603  compact_mode = CAlignmentConfig::eCompact;
1604  }
1605 
1606  if (compact_mode == CAlignmentConfig::eCompact &&
1608  compact_mode = CAlignmentConfig::eExtremeCompact;
1609  }
1610 
1611  if (m_PWAlignConf) {
1612  m_PWAlignConf->m_CompactMode = compact_mode;
1614  m_ShowLabel && compact_mode == CAlignmentConfig::eNormal;
1616  }
1617  if (m_MPPWAlignConf) {
1618  m_MPPWAlignConf->m_CompactMode = compact_mode;
1620  m_ShowLabel && compact_mode == CAlignmentConfig::eNormal;
1621  // Do we want this for multiple alignment?
1623  }
1624 
1625 
1626  int vert_space = 2;
1627  float min_dist = 4.0;
1628  if (compact_mode == CAlignmentConfig::eCompact) {
1629  vert_space = 1;
1630  min_dist = 3.0;
1631  } else if (compact_mode == CAlignmentConfig::eExtremeCompact) {
1632  vert_space = 0;
1633  min_dist = 2.0;
1634  }
1635 
1636  m_Layered->SetVertSpace(vert_space);
1637  m_Column->SetVertSpace(vert_space);
1639 
1640  //m_GeneModelLayout->SetVertSpace(2);
1641 
1642  if (show_stat) {
1643  // enable pileup only if match/mistamtch graph is requested
1644  // enable permanent(inetcahe) cache if in cgi mode only
1645  bool has_pileup_cache = m_DS->HasCoverageGraph() && !m_StatConf->ShowAGTC();
1646  m_DS->EnablePileUpCache(has_pileup_cache, m_gConfig->GetCgiMode());
1647  // calculate alignment statistics
1648  // if stat_aligns is empty, it may be because alignments are packed as
1649  // smear bar or graph. So we still need to try
1650  m_DS->CalcAlnStat(stat_aligns, m_Context->GetVisSeqRange(),
1652  }
1653 
1654  // projected features from the aligned sequences
1655  if ( !aligns.empty() ) {
1658  }
1659 
1660  // caclucate alignment score
1661  if ( !scored_alns.empty() ) {
1663  }
1664 
1666  x_SetMsg();
1667  x_UpdateLayout();
1668 }
1669 
1670 
1672 {
1673  string coverage_annot;
1675  if (!m_StatGlyph.empty())
1676  m_StatGlyph.clear();
1677 
1678  if (result.m_ObjectList.empty()) {
1679  SetGroup().Clear();
1680  SetMsg(", no data");
1681  } else {
1682  SetGroup().Set(result.m_ObjectList);
1683  for (auto& gr : SetGroup().SetChildren()) {
1684  CHistogramGlyph* graph = dynamic_cast<CHistogramGlyph*>(gr.GetPointer());
1685  if (graph) {
1686  graph->SetDialogHost(dynamic_cast<IGlyphDialogHost*>(m_LTHost));
1687  graph->SetConfig(*m_gConfig);
1688  graph->SetAnnotName(coverage_annot);
1689  SetMsg(", Coverage graph");
1690  }
1691  }
1692  }
1693 
1694  x_UpdateLayout();
1695 }
1696 
1698 {
1700  CRef<CHistParams> params;
1701  if (!m_AnnotName.empty()) {
1702  auto conf_mgr = m_gConfig->GetHistParamsManager();
1703  string coverage_annot;
1705  if (conf_mgr->HasSettings(coverage_annot)) {
1706  params = conf_mgr->GetHistParams(coverage_annot);
1707  } else {
1708  CRef<CHistParams> def_conf = conf_mgr->GetDefHistParams();
1709  params.Reset(new CHistParams(*def_conf));
1711  conf_mgr->AddSettings(coverage_annot, params);
1712  }
1713  params->m_NeedRulerLabels = false; // turn off labels for coverage graph
1714  }
1715  return params;
1716 }
1717 
1719 {
1721  x_SetMsg();
1722  CSeqGlyph::TObjects objs = result.m_ObjectList;
1723  vector<CAlnStatGlyph*> stat_glyphs;
1724  for (auto&& ch : objs) {
1725  CAlnStatGlyph* stat_glyph =
1726  dynamic_cast<CAlnStatGlyph*>(ch.GetPointer());
1727  _ASSERT(stat_glyph);
1728  if (!stat_glyph)
1729  continue;
1730  stat_glyphs.push_back(stat_glyph);
1731  }
1732 
1733  if (stat_glyphs.empty()) {
1734  if (!m_StatGlyph.empty()) {
1735  // do clean up
1736  if (SetGroup().GetChildrenNum() > m_StatGlyph.size()) {
1737  //_ASSERT(SetGroup().GetChildrenNum() == 2);
1738  CRef<CSeqGlyph> p_glyph = SetGroup().GetChild(static_cast<int>(m_StatGlyph.size()));
1739  CLayoutGroup* p_group = dynamic_cast<CLayoutGroup*>(p_glyph.GetPointer());
1740  _ASSERT(p_group);
1741  SetGroup().Set(p_group->GetChildren());
1743  } else {
1744  SetGroup().Clear();
1745  }
1746  m_StatGlyph.clear();
1747  x_UpdateLayout();
1748  }
1749  return;
1750  }
1751 
1752  CRef<CLayoutGroup> align_group;
1753  bool need_update = m_StatGlyph.empty();
1754  auto graph_params = x_GetGraphParams();
1755  CSeqGlyph::TObjects aligns;
1756  if (SetGroup().GetChildrenNum() > m_StatGlyph.size()) {
1757  if (m_StatGlyph.empty()) {
1758  align_group.Reset(new CLayoutGroup);
1759  align_group->Set(GetGroup().GetChildren());
1760  } else {
1761  CRef<CSeqGlyph> p_glyph = SetGroup().GetChild(static_cast<int>(m_StatGlyph.size()));
1762  align_group.Reset(dynamic_cast<CLayoutGroup*>(p_glyph.GetPointer()));
1763  }
1764  }
1765  m_StatGlyph.clear();
1766  CLayoutGroup& p_group = SetGroup();
1767  p_group.Clear();
1768  for (auto&& stat_glyph : stat_glyphs) {
1769  stat_glyph->SetConfig(m_StatConf, graph_params);
1770  stat_glyph->SetCgiMode(m_gConfig->GetCgiMode());
1771  stat_glyph->SetDialogHost(dynamic_cast<IGlyphDialogHost*>(m_LTHost));
1772  m_StatGlyph.emplace_back(stat_glyph);
1773  p_group.PushBack(stat_glyph);
1774  }
1775  if (align_group)
1776  p_group.PushBack(align_group.GetPointer());
1777 
1778  if (need_update)
1780  x_UpdateLayout();
1781 }
1782 
1783 
1785 {
1787  CLayoutGroup::TObjectList& objs = (*a_iter)->m_ObjectList;
1788  CAlignGlyph* align =
1789  dynamic_cast<CAlignGlyph*>((*a_iter)->m_Owner.GetPointer());
1790  if (objs.empty() || !align) continue;
1791 
1793  CLayoutGroup* parent_group =
1794  dynamic_cast<CLayoutGroup*>(align->SetParent());
1795  _ASSERT(parent_group);
1796  CLayoutGroup* group = new CLayoutGroup;
1797  parent_group->Insert(align, group);
1798  parent_group->Remove(align);
1799  group->PushBack(align);
1801  if (objs.size() > 1) {
1802  // separate objects according to feature types.
1803  // All gene model features will be grouped together.
1804  // Anything else will be grouped separately.
1805  typedef map<int, CLayoutGroup::TObjectList> TFeatGroups;
1806  TFeatGroups feat_groups;
1808  CSeqGlyph* glyph = iter->GetPointer();
1809  // if the features are in a group (any CLayoutGroup-derived group)
1810  // we know it must be a gene group
1811  CLayoutGroup* c_group = dynamic_cast<CLayoutGroup*>(glyph);
1812  if (c_group) {
1813  feat_groups[CSeqFeatData::eSubtype_gene].push_back(*iter);
1814  } else { // must be a feature
1815  const CFeatGlyph* feat = dynamic_cast<const CFeatGlyph*>(glyph);
1816  _ASSERT(feat);
1818  feat->GetFeature().GetData().Which();
1819  CSeqFeatData::ESubtype s_type =
1820  feat->GetFeature().GetData().GetSubtype();
1822  feat_groups[CSeqFeatData::eSubtype_gene].push_back(*iter);
1823  } else {
1824  feat_groups[s_type].push_back(*iter);
1825  }
1826  }
1827  }
1828  NON_CONST_ITERATE (TFeatGroups, iter, feat_groups) {
1829  if (iter->second.size() > 1) {
1830  CLayoutGroup* sub_group = new CLayoutGroup;
1831  group->PushBack(sub_group);
1832  if ( !m_FeatGroupConf ) {
1834  true, false, CRgbaColor(0.5, 0.5f, 0.5f, 0.5f),
1835  CRgbaColor(1.0f, 1.0f, 1.0f, 1.0f), 1.0));
1836  }
1837  sub_group->SetConfig(m_FeatGroupConf);
1838  sub_group->SetLayoutPolicy(m_Column);
1839  sub_group->Set(iter->second);
1840  } else {
1841  group->Append(iter->second);
1842  }
1843  }
1844  } else {
1845  group->Append(objs);
1846  }
1847  }
1848  x_SetMsg();
1849 
1850  // make sure we don't update layout twice for synchronized jobs
1851  if (m_DS->IsBackgroundJob()) {
1852  x_UpdateLayout();
1853  }
1854 }
1855 
1856 
1858 {
1860  CSeqGlyph* glyph = iter->GetPointer();
1862  if (CGeneGroup* group = dynamic_cast<CGeneGroup*>(glyph)) {
1863  if ( !m_GeneGroupConf ) {
1865  true, false, CRgbaColor(0.0, 0.6f, 0.0f, 0.1f),
1866  CRgbaColor(0.6f, 0.8f, 0.3f, 0.3f), 1.0));
1867  }
1868  group->SetConfig(m_GeneGroupConf);
1869  group->SetLayoutPolicy(m_GeneModelLayout);
1870  group->SetShowGene(true);
1871  x_AddAlignFeat_Recursive(group->SetChildren());
1872  } else if (CLayoutGroup* group = dynamic_cast<CLayoutGroup*>(glyph)) {
1873  // must be an exon group
1874  group->SetLayoutPolicy(m_Inline);
1875  x_AddAlignFeat_Recursive(group->SetChildren());
1876  } else {
1877  // must be a feature
1878  CFeatGlyph* feat = dynamic_cast<CFeatGlyph*>(glyph);
1879  _ASSERT(feat);
1880  CSeqFeatData::ESubtype subtype =
1881  feat->GetFeature().GetData().GetSubtype();
1882  feat->SetConfig(m_gConfig->GetFeatParams(subtype));
1883  feat->SetProjectedFeat(true);
1884  switch (subtype) {
1887  break;
1891  if (CCdsGlyph* cds_glyph = dynamic_cast<CCdsGlyph*>(feat)) {
1892  cds_glyph->SetCdsConfig(m_GeneModelConfig->m_CdsConfig);
1893  }
1894  break;
1895  default:
1896  break;
1897  }
1898  }
1899  }
1900 }
1901 
1903  CAlignGlyph* aln)
1904 {
1905  // anchored seq-loc
1906  const CSeq_loc& loc = aln->GetLocation();
1908  range.IntersectWith(loc.GetTotalRange());
1909 
1910  // don't project features when the size (on screen) is less than 4 pixels
1911  if (m_Context->SeqToScreen((TModelUnit)range.GetLength()) >= 4.0) {
1912  aligns.push_back(CRef<CAlignGlyph>(aln));
1913  }
1914 
1915  /*
1916  CScope& scope = m_Context->GetScope();
1917  try {
1918  const IAlnGraphicDataSource& aln_mgr = aln->GetAlignMgr();
1919  // aligned seq-id
1920  const CSeq_id& aligned_seq =
1921  aln_mgr.GetSeqId(aln_mgr.GetAnchor() == 0 ? 1 : 0);
1922 
1923  SConstScopedObject obj(aligned_seq, scope);
1924  CGeneModelFactory gene_model;
1925 
1926  // map visible range to product feature
1927  CSeq_loc_Mapper seq_range_mapper(
1928  aln->GetAlignmentObj(), aligned_seq, &scope);
1929  CRef<CSeq_loc> tmp_loc(new CSeq_loc());
1930  tmp_loc->SetInt().SetFrom(range.GetFrom());
1931  tmp_loc->SetInt().SetTo (range.GetTo());
1932  tmp_loc->SetId(*loc.GetId());
1933  CSeq_loc::TRange vis_range =
1934  seq_range_mapper.Map(tmp_loc.GetObject())->GetTotalRange();
1935 
1936  ILayoutTrackFactory::SExtraParams params(-1, true);
1937  params.m_Range = vis_range;
1938  ILayoutTrackFactory::TTrackMap tracks =
1939  gene_model.CreateTracks(obj, m_DSContext, m_Context, params);
1940  if ( !tracks.empty() ) {
1941  CLayoutGroup* parent_group =
1942  dynamic_cast<CLayoutGroup*>(aln->SetParent());
1943  _ASSERT(parent_group);
1944  CLayoutGroup* group = new CLayoutGroup;
1945  parent_group->Insert(aln, group);
1946  parent_group->Remove(aln);
1947  group->PushBack(aln);
1948  group->SetLayoutPolicy(m_Simple);
1949 
1950  NON_CONST_ITERATE (ILayoutTrackFactory::TTrackMap, iter, tracks) {
1951  CDataTrack* track =
1952  dynamic_cast<CDataTrack*>(iter->second.GetPointer());
1953  if (track) {
1954  group->PushBack(track);
1955  CRef<CCoordMapper_SeqLocMapper> mapper(
1956  new CCoordMapper_SeqLocMapper(
1957  aln->GetAlignmentObj(), *loc.GetId(), &scope));
1958  track->GetDataSource()->SetCoordMapper(mapper);
1959  track->SetHost(m_LTHost);
1960  track->SetConfig(m_gConfig);
1961  track->SetIndent(0);
1962  track->SetTrackAttr(0);
1963  track->LoadProfile("");
1964 
1965  track->SetVisRange(vis_range);
1966 
1967  if (CFeatureTrack* f_track =
1968  dynamic_cast<CFeatureTrack*>(track)) {
1969  f_track->SetLayout(CFeatureTrack::eLayout_AdaptiveInline);
1970  }
1971  track->Update(false);
1972  }
1973  }
1974  }
1975 
1976  } catch (CAnnotMapperException&) {
1977  /// ignore errors from location mapping
1978  }
1979  */
1980 }
1981 
1982 
1985 {
1986  const CAlignGlyph* align = dynamic_cast<const CAlignGlyph*>(glyph);
1987  if (align) {
1988  _ASSERT(align->GetAlignMgr().GetNumRows() >= 2);
1989  if (align->GetAlignMgr().GetNumRows() == 2)
1990  return eAlign_PW;
1991  // no pairwise alignment check if it's more than 100 rows
1992  // we really don't expect such a discontinuous alignments
1993  if (align->GetAlignMgr().GetNumRows() > 100)
1994  return eAlign_Multi;
1995  // if there are only two seq_ids involved then it can be treated as a Pairwise Alignment
1996  const CSeq_id* id = 0;
1997  for (IAlnExplorer::TNumrow row = 0; row < align->GetAlignMgr().GetNumRows(); ++row) {
1998  // skip the anchor
1999  if (align->GetAlignMgr().GetAnchor() == row)
2000  continue;
2001  const CSeq_id& seq_id = align->GetAlignMgr().GetSeqId (row);
2002  if (!id) {
2003  id = &seq_id;
2004  continue;
2005  }
2006  if (seq_id.Match(*id))
2007  continue;
2008  return eAlign_Multi;
2009  }
2010  return eAlign_PW;
2011  }
2012 
2013  const CMatePairGlyph* mp = dynamic_cast<const CMatePairGlyph*>(glyph);
2014  if (mp) {
2015  return eAlign_MatePair;
2016  }
2017 
2018  const CAlignSmearGlyph* smear = dynamic_cast<const CAlignSmearGlyph*>(glyph);
2019  if (smear) {
2020  return eAlign_Smear;
2021  }
2022 
2023  const CHistogramGlyph* graph = dynamic_cast<const CHistogramGlyph*>(glyph);
2024  if (graph) {
2025  return eAlign_Graph;
2026  }
2027 
2028  return eAlign_Non;
2029 }
2030 
2031 
2032 void CAlignmentTrack::x_SaveConfiguration(const string& preset_style) const
2033 {
2035  CRegistryWriteView view =
2037  view.Set("LinkMatePairAligns", m_DS->GetLinkMatePairs());
2038  view.Set("DNAScoringMethod", m_DS->GetDNAScoringMethod());
2039  view.Set("ProteinScoringMethod", m_DS->GetProteinScoringMethod());
2040  view.Set("EnableColoration", m_DS->GetEnableColoration());
2041  view.Set("ShowAlignedSeqFeats", m_ShowAlignedSeqFeats);
2042  view.Set("ShowIdenticalBases", m_ShowIdenticalBases);
2043  view.Set("ShowLabel", m_ShowLabel);
2044  view.Set("ShowUnalignedTailsForTrans2GenomicAln", m_ShowUnalignedTailsForTrans2GenomicAln);
2045  view.Set("Layout", LayoutValueToStr(m_Layout));
2046  view.Set("HideSraAlignments", HideFlagValueToStr(m_HideSraAlignments));
2047  view.Set("UnalignedTailsMode", UnalignedTailsModeValueToStr(m_UnalignedTailsMode));
2048  view.Set("ShowSecondPass", m_ShowSecondPassAlignments);
2049 
2050  view.Set("MultiAlignProfile", m_MultiAlignProfile);
2051  view.Set("PWAlignProfile", m_PWAlignProfile);
2052  view.Set("AlignSmearProfile", m_AlignSmearProfile);
2053  view.Set("MatePairProfile", m_MatePairProfile);
2054 
2059 }
2060 
2061 
2062 void CAlignmentTrack::x_LoadAlignmentSettings(const string& profile,
2063  CRef<CAlignmentConfig>& conf)
2064 {
2065  if ( !conf ) {
2066  conf.Reset(new CAlignmentConfig);
2067  }
2068 
2071  registry, kAlignGlyphKey, profile, kDefProfile);
2072  //conf->m_ShowLabel = view.GetBool("ShowLabel", true);
2073  conf->m_ShowLabel = m_ShowLabel;
2077 
2080  try {
2081  conf->m_LabelPos = LabelPosStrToValue(view.GetString("LabelPos"));
2082  } catch (CException& e) {
2083  LOG_POST(Warning << "CAlignmentTrack::x_LoadAlignmentSettings() "
2084  << e.GetMsg());
2085  }
2086 
2087  // load color settings
2090  CSGConfigUtils::GetColor(view, "BG", conf->m_BG);
2091  CSGConfigUtils::GetColor(view, "FG", conf->m_FG);
2092  CSGConfigUtils::GetColor(view, "Label", conf->m_Label);
2093  CSGConfigUtils::GetColor(view, "Sequence", conf->m_Sequence);
2094  CSGConfigUtils::GetColor(view, "SeqMismatch", conf->m_SeqMismatch);
2095  CSGConfigUtils::GetColor(view, "TailColor", conf->m_TailColor);
2096  CSGConfigUtils::GetColor(view, "Insertion", conf->m_Insertion);
2097  CSGConfigUtils::GetColor(view, "Gap", conf->m_Gap);
2098  CSGConfigUtils::GetColor(view, "Intron", conf->m_Intron);
2099  CSGConfigUtils::GetColor(view, "NonConsensus", conf->m_NonConsensus);
2100  CSGConfigUtils::GetColor(view, "SmearColorMin", conf->m_SmearColorMin);
2101  CSGConfigUtils::GetColor(view, "SmearColorMax", conf->m_SmearColorMax);
2102  CSGConfigUtils::GetColor(view, "UnalignedFG", conf->m_UnalignedFG);
2103  CSGConfigUtils::GetColor(view, "UnalignedSequence", conf->m_UnalignedSequence);
2104 
2105  // load size settings
2108 
2109  conf->m_BarHeight = view.GetInt("BarHeight");
2110  CSGConfigUtils::GetFont(view, "LabelFontFace", "LabelFontSize", conf->m_LabelFont);
2111  CSGConfigUtils::GetFont(view, "SeqFontFace", "SeqFontSize", conf->m_SeqFont);
2112 }
2113 
2114 
2115 void
2117  CConstRef<CAlignmentConfig> conf) const
2118 {
2119  if ( !conf || !conf->m_Dirty) {
2120  return;
2121  }
2122 
2125  registry, kAlignGlyphKey, profile, kDefProfile);
2126  view.Set("ShowLabel", conf->m_ShowLabel);
2127  view.Set("ShowIdenticalBases", conf->m_ShowIdenticalBases);
2128  view.Set("m_ShowUnalignedTailsForTrans2GenomicAln", conf->m_ShowUnalignedTailsForTrans2GenomicAln);
2129 
2130  // label position
2133  view.Set("LabelPos", LabelPosValueToStr(conf->m_LabelPos));
2134 
2135  // load color settings
2138  CSGConfigUtils::SetColor(view, "BG", conf->m_BG);
2139  CSGConfigUtils::SetColor(view, "FG", conf->m_FG);
2140  CSGConfigUtils::SetColor(view, "Label", conf->m_Label);
2141  CSGConfigUtils::SetColor(view, "Sequence", conf->m_Sequence);
2142  CSGConfigUtils::SetColor(view, "SeqMismatch", conf->m_SeqMismatch);
2143  CSGConfigUtils::SetColor(view, "TailColor", conf->m_TailColor);
2144  CSGConfigUtils::SetColor(view, "Insertion", conf->m_Insertion);
2145  CSGConfigUtils::SetColor(view, "Gap", conf->m_Gap);
2146  CSGConfigUtils::SetColor(view, "Intron", conf->m_Intron);
2147  CSGConfigUtils::SetColor(view, "NonConsensus", conf->m_NonConsensus);
2148  CSGConfigUtils::SetColor(view, "SmearColorMin", conf->m_SmearColorMin);
2149  CSGConfigUtils::SetColor(view, "SmearColorMax", conf->m_SmearColorMax);
2150  CSGConfigUtils::SetColor(view, "UnalignedFG", conf->m_UnalignedFG);
2151  CSGConfigUtils::SetColor(view, "UnalignedSequence", conf->m_UnalignedSequence);
2152 
2153  // load size settings
2156 
2157  view.Set("BarHeight", conf->m_BarHeight);
2158  CSGConfigUtils::SetFont(view, "LabelFontFace", "LabelFontSize", conf->m_LabelFont);
2159  CSGConfigUtils::SetFont(view, "SeqFontFace", "SeqFontSize", conf->m_SeqFont);
2160 
2161  conf->m_Dirty = false;
2162 }
2163 
2164 
2166 {
2167  if ( !m_MatePairConf) {
2169  }
2170 
2171  const string& profile = m_MatePairProfile;
2173 
2176  registry, kMatePairKey, profile, kDefProfile);
2177  //conf->m_ShowLabel = view.GetBool("ShowLabel", true);
2178  conf->m_ShowLabel = m_ShowLabel;
2179 
2180  // load color settings
2183  CSGConfigUtils::GetColor(view, "BG", conf->m_BG);
2184  CSGConfigUtils::GetColor(view, "FGDistance", conf->m_FGDistance);
2185  CSGConfigUtils::GetColor(view, "FGLink", conf->m_FGLink);
2186  CSGConfigUtils::GetColor(view, "FGNo", conf->m_FGNo);
2187  CSGConfigUtils::GetColor(view, "FGNonUnique", conf->m_FGNonUnique);
2188  CSGConfigUtils::GetColor(view, "FGOrientation", conf->m_FGOrientation);
2189  CSGConfigUtils::GetColor(view, "FGCoAlign", conf->m_FGCoAlign);
2190  CSGConfigUtils::GetColor(view, "FGContraAlign", conf->m_FGContraAlign);
2191  CSGConfigUtils::GetColor(view, "Label", conf->m_Label);
2192  CSGConfigUtils::GetColor(view, "SeqDistance", conf->m_SeqDistance);
2193  CSGConfigUtils::GetColor(view, "SeqMismatchDistance", conf->m_SeqMismatchDistance);
2194  CSGConfigUtils::GetColor(view, "SeqMismatchNo", conf->m_SeqMismatchNo);
2195  CSGConfigUtils::GetColor(view, "SeqMismatchNonUnique", conf->m_SeqMismatchNonUnique);
2196  CSGConfigUtils::GetColor(view, "SeqMismatchOrientation", conf->m_SeqMismatchOrientation);
2197  CSGConfigUtils::GetColor(view, "SeqNo", conf->m_SeqNo);
2198  CSGConfigUtils::GetColor(view, "SeqNonUnique", conf->m_SeqNonUnique);
2199  CSGConfigUtils::GetColor(view, "SeqOrientation", conf->m_SeqOrientation);
2200 
2201  // load size settings
2204  CSGConfigUtils::GetFont(view, "LabelFontFace", "LabelFontSize", conf->m_LabelFont);
2205 }
2206 
2207 
2209 {
2210  if ( !m_MatePairConf || !m_MatePairConf->m_Dirty) {
2211  return;
2212  }
2213 
2214  const string& profile = m_MatePairProfile;
2215  const CMatePairConfig* conf = m_MatePairConf;
2216 
2219  registry, kMatePairKey, profile, kDefProfile);
2220  view.Set("ShowLabel", conf->m_ShowLabel);
2221 
2222  // load color settings
2225  CSGConfigUtils::SetColor(view, "BG", conf->m_BG);
2226  CSGConfigUtils::SetColor(view, "FGDistance", conf->m_FGDistance);
2227  CSGConfigUtils::SetColor(view, "FGLink", conf->m_FGLink);
2228  CSGConfigUtils::SetColor(view, "FGNo", conf->m_FGNo);
2229  CSGConfigUtils::SetColor(view, "FGNonUnique", conf->m_FGNonUnique);
2230  CSGConfigUtils::SetColor(view, "FGOrientation", conf->m_FGOrientation);
2231  CSGConfigUtils::SetColor(view, "Label", conf->m_Label);
2232  CSGConfigUtils::SetColor(view, "SeqDistance", conf->m_SeqDistance);
2233  CSGConfigUtils::SetColor(view, "SeqMismatchDistance", conf->m_SeqMismatchDistance);
2234  CSGConfigUtils::SetColor(view, "SeqMismatchNo", conf->m_SeqMismatchNo);
2235  CSGConfigUtils::SetColor(view, "SeqMismatchNonUnique", conf->m_SeqMismatchNonUnique);
2236  CSGConfigUtils::SetColor(view, "SeqMismatchOrientation", conf->m_SeqMismatchOrientation);
2237  CSGConfigUtils::SetColor(view, "SeqNo", conf->m_SeqNo);
2238  CSGConfigUtils::SetColor(view, "SeqNonUnique", conf->m_SeqNonUnique);
2239  CSGConfigUtils::SetColor(view, "SeqOrientation", conf->m_SeqOrientation);
2240 
2241  // load size settings
2244  CSGConfigUtils::SetFont(view, "LabelFontFace", "LabelFontSize", conf->m_LabelFont);
2245 
2246  conf->m_Dirty = false;
2247 }
2248 
2249 
2251 {
2252  if (m_ObjNum > 0) {
2253  string msg = ", total ";
2255  msg += " object";
2256  msg += m_ObjNum > 1 ? "s shown" : " shown";
2257  SetMsg(msg);
2258  } else {
2259  SetMsg("");
2260  }
2261 }
2262 
2263 
2265 {
2266  static map<string, IAlnExplorer::EAlignType> s_ALnTypeMap = {
2267  {"na", IAlnExplorer::fDNA},
2268  {"dna", IAlnExplorer::fDNA},
2269  {"aa", IAlnExplorer::fProtein},
2270  {"protein", IAlnExplorer::fProtein},
2271  {"mixed", IAlnExplorer::fMixed}
2272  };
2273  if (s_ALnTypeMap.count(align_type) != 0)
2274  return s_ALnTypeMap[align_type];
2275  return IAlnExplorer::fInvalid;
2276 }
2277 
2278 
2280 {
2281  static map<string, CSGAlignmentDS::EDataLoader> s_AlnLoaderMap = {
2282  {"BAM", CSGAlignmentDS::eLoader_BAM},
2284  };
2285  if (s_AlnLoaderMap.count(align_loader) != 0)
2286  return s_AlnLoaderMap[align_loader];
2288 }
2289 
2290 
2292 {
2294 
2295  if (m_ShowSecondPassAlignments == false) {
2296  string msg = "second-pass alignments are hidden";
2297  CHTMLActiveArea area;
2299  area.m_Bounds.SetTop(area.m_Bounds.Top() + x_GetTBHeight());
2300  // left = 1 right = 0, makes it right-aligned
2301  area.m_Bounds.SetLeft(1);
2302  area.m_Bounds.SetRight(0);
2308  area.m_ID = msg;
2309  area.m_ParentId = GetId();
2310  // required, but nonsense fields
2311  area.m_PositiveStrand = true;
2312  area.m_SeqRange.SetFrom(0);
2313  area.m_SeqRange.SetTo(0);
2314  p_areas->push_back(area);
2315  }
2316 
2317 }
2318 
2319 
2321 {
2322  auto area = CLayoutTrack::InitHTMLActiveArea(p_areas);
2323  // Set the parent id for AlignDb tracks, it's
2325  area->m_ID = GetId();
2326  }
2327  return area;
2328 }
2329 
2330 
2332 {
2334  // if ShowSecondPass is not set not in printing mode
2335  // then make room for "second-pass alignments are hidden" message
2336  if (m_ShowSecondPassAlignments == false) {
2337  bool cgi_mode = m_gConfig && m_gConfig->GetCgiMode();
2338  if (cgi_mode && GetGl().IsPrinterFriendly() == false) {
2339  m_Group.SetTop(m_Group.GetTop() + 16);
2340  SetHeight(GetHeight() + 16);
2341  }
2342  }
2343 }
2344 
2345 
2346 
2347 
2348 ///////////////////////////////////////////////////////////////////////////////
2349 /// CAlignmentTrackFactory
2350 ///////////////////////////////////////////////////////////////////////////////
2353  ISGDataSourceContext* ds_context,
2354  CRenderingContext* r_cntx,
2355  const SExtraParams& params,
2356  const TAnnotMetaDataList& src_annots) const
2357 {
2358  TAnnotNameTitleMap annots;
2359 
2360  // LOG_POST("<<<<");
2361  if (params.m_SkipGenuineCheck && !params.m_Annots.empty()) {
2362  // LOG_POST("Skip genuine check, iterate through existing annots");
2363  ITERATE (SExtraParams::TAnnots, iter, params.m_Annots) {
2364  annots.insert(TAnnotNameTitleMap::value_type(*iter, ""));
2365  }
2366  } else {
2367  // LOG_POST("Do annots discovery");
2368  // collect non-NA tracks
2369  CIRef<ISGDataSource> pre_ds =
2370  ds_context->GetDS(typeid(CSGAlignmentDSType).name(), object);
2371  CSGAlignmentDS* aln_ds = dynamic_cast<CSGAlignmentDS*>(pre_ds.GetPointer());
2372  aln_ds->SetDepth(params.m_Level);
2373  aln_ds->SetAdaptive(params.m_Adaptive);
2375  sel.SetCollectNames();
2376  aln_ds->GetAnnotNames(sel, r_cntx->GetVisSeqRange(), annots);
2377 
2378  // collect NA tracks
2379  if ( !src_annots.empty() ) {
2380  GetMatchedAnnots(src_annots, params, annots);
2381  }
2382  }
2383  // LOG_POST("Annots done");
2384 
2385  TKeyValuePairs track_settings;
2386  CSGConfigUtils::ParseProfileString(params.m_TrackProfile, track_settings);
2387 
2389  if (track_settings.count("align_loader") > 0) {
2390  data_loader = s_ParseAlignDataLoader(track_settings["align_loader"]);
2391  }
2392 
2393  // check if there are any coverage graphs available
2394  TAnnotNameTitleMap graph_annots;
2395  try {
2396  if (params.m_CoverageGraphCheck && (CSGAlignmentDS::eLoader_Unknown == data_loader)) {
2397  // LOG_POST("Checking coverage graph");
2398  vector<string> target_g_annots;
2399  // LOG_POST("Iterate through existing annots");
2400  ITERATE (TAnnotNameTitleMap, iter, annots) {
2402  target_g_annots.push_back(iter->first);
2403  }
2404  }
2405  if ( !target_g_annots.empty() ) {
2406  // LOG_POST("Use ds based discovery");
2407  CIRef<ISGDataSource> igraph_ds =
2408  ds_context->GetDS(typeid(CSGGraphDSType).name(), object);
2409  CSGGraphDS* graph_ds = dynamic_cast<CSGGraphDS*>(igraph_ds.GetPointer());
2410  graph_ds->SetDepth(params.m_Level);
2411  graph_ds->SetAdaptive(params.m_Adaptive);
2412  SAnnotSelector graph_sel(CSeqUtils::GetAnnotSelector(target_g_annots));
2413  graph_ds->GetAnnotNames(graph_sel, r_cntx->GetVisSeqRange(), graph_annots);
2414  }
2415  // LOG_POST("Checking coverage done");
2416  }
2417  } catch(const exception&) {
2418  // ignore all errors if no actual track check is requited
2419  // otherwise throw an error
2420  if(!params.m_SkipGenuineCheck || params.m_Annots.empty()) {
2421  throw;
2422  }
2423  }
2424 
2425  // create feature tracks
2426  TTrackMap tracks;
2427  // LOG_POST("Creating tracks");
2428  ITERATE(TAnnotNameTitleMap, iter, annots) {
2429  CIRef<ISGDataSource> ds = ds_context->GetDS(
2430  typeid(CSGAlignmentDSType).name(), object);
2431  // LOG_POST("Creating tracks 1");
2432  CSGAlignmentDS* aln_ds = dynamic_cast<CSGAlignmentDS*>(ds.GetPointer());
2433  aln_ds->SetDepth(params.m_Level);
2434  aln_ds->SetAdaptive(params.m_Adaptive);
2435  aln_ds->SetAnnotName(iter->first);
2436  aln_ds->SetSortBy(params.m_SortBy);
2437  aln_ds->SetRemotePath(params.m_RemotePath);
2438  if (CSGAlignmentDS::eLoader_Unknown != data_loader)
2439  aln_ds->SetAlnDataLoader(data_loader);
2440 
2441  bool is_reads = false;
2442  // LOG_POST("Creating tracks 2");
2443  if (!CSeqUtils::IsUnnamed(iter->first)) {
2444  is_reads = (graph_annots.count(iter->first) > 0) || (CSGAlignmentDS::eLoader_Unknown != data_loader);
2445  aln_ds->SetHasCoverageGraph(is_reads);
2446  }
2447 
2448  // LOG_POST("Creating tracks 3");
2449  CRef<CAlignmentTrack> aln_track(new CAlignmentTrack(aln_ds, r_cntx));
2450  if (is_reads)
2451  aln_track->SetDefaultProfile(kReadsProfile);
2452  // only do this for non-cSRA/BAM file
2453  // this takes a lot of time and is not needed for seqconfig, so is skipped when called from it
2454  // LOG_POST("Creating tracks 4");
2455 
2456  auto aln_type = IAlnExplorer::fInvalid;
2457  if (track_settings.count("align_type") > 0)
2458  aln_type = s_ParseAlignType(track_settings["align_type"]);
2459  if (aln_type != IAlnExplorer::fInvalid) {
2460  aln_track->SetAlnType(aln_type);
2461  } else if (is_reads) {
2462  aln_track->SetAlnType(IAlnExplorer::fDNA);
2463  } else if (aln_ds->IsBamLoader() || aln_ds->IsCSRALoader()) {
2464  aln_track->SetAlnType(IAlnExplorer::fDNA);
2465  } else {
2466  try {
2467  aln_track->SetAlnType(aln_ds->InitAlignType(params.m_FastConfig));
2468  } catch (const exception&) {
2469  // if this fails, most likely the track loading will fail later as well, but we need the track to be created
2470  // here with at least reasonable type so it can be displayed even if empty
2471  aln_track->SetAlnType(IAlnExplorer::fHomogenous);
2472  }
2473  }
2474 
2475  // LOG_POST("Creating tracks 5");
2476  aln_track->SetAnnot(iter->first);
2477  if (!iter->second.empty()) {
2478  aln_track->SetTitle(iter->second);
2479  }
2480  // LOG_POST("Creating tracks 6");
2481  aln_track->SetDSContext(ds_context);
2482  // LOG_POST("Creating tracks 7");
2483  tracks[iter->first] = aln_track.GetPointer();
2484  }
2485  // LOG_POST("Creating tracks done");
2486  // LOG_POST(">>>>");
2487 
2488  return tracks;
2489 }
2490 
2492  const TAnnotMetaDataList& src_annots,
2493  const ILayoutTrackFactory::SExtraParams& params,
2494  TAnnotNameTitleMap& out_annots) const
2495 {
2496  ILayoutTrackFactory::GetMatchedAnnots(src_annots, params.m_Annots, "align", "", out_annots);
2497 }
2498 
2499 static const char* kDefaultSraFilter = "none";
2500 static const char* kDefaultUnalignedTailsMode = "glyph";
2501 static const char* kDefaultScoringMethod = "Show Differences";
2502 enum {
2506  /// special setting for TMS tracks that did not go through complete alignment type discovery in seqconfig
2507  /// (IAlnExplorer::fHomogenous)
2508  /// this will create all possible kinds of scoring methods, in other respects will look like _NUC
2509  /// this is temporary until TMS will start to serve a real alignment type
2510  CONFIG_ALL = 4
2511 };
2512 
2515  const TKeyValuePairs& settings,
2516  const CTempTrackProxy* track_proxy) const
2517 {
2518  CRef<CTrackConfigSet> config_set(new CTrackConfigSet);
2519  bool sraTrack = false;
2520  // If track_proxy is not set we generate as many configs as possible
2521  // for given track type
2522  int config_num = CONFIG_PROT; // 3. protein/mixed 2. nuc 1. nuc SRA
2523  while (config_num) {
2525  config_set->Set().push_back(config);
2526  config->SetHelp() = GetThisTypeInfo().GetDescr();
2527  config->SetLegend_text("anchor_7");
2528 
2530  CRegistryReadView view =
2532 
2533  if (track_proxy) {
2535  CLayoutTrack* track = const_cast<CLayoutTrack*>(track_proxy->GetTrack());
2536  CAlignmentTrack* aln_track = dynamic_cast<CAlignmentTrack*>(track);
2537  if (aln_track) {
2538  aln_type = aln_track->m_AlnType;
2539  }
2540 
2541  switch(aln_type) {
2543  case IAlnExplorer::fMixed:
2544  config_num = CONFIG_PROT;
2545  break;
2547  config_num = CONFIG_ALL;
2548  break;
2549  default:
2550  config_num = CONFIG_NUC;
2551  if (profile == "BAM") {
2552  // HACK, HACK
2553  // It is a hack to indicate this is a BAM/cSRA track since
2554  // we don't have access to BAM/cSRA path at this stage.
2555  config_num = CONFIG_SRA;
2556  sraTrack = true;
2557  }
2558  break;
2559  }
2560  }
2561 
2562  vector<string> scoring_methods;
2563  if (config_num == CONFIG_PROT || config_num == CONFIG_ALL) {
2564  scoring_methods.push_back(kDefaultScoringMethod);
2565  scoring_methods.push_back("Rasmol Amino Acid Colors");
2566  scoring_methods.push_back("Shapely Amino Acid Colors");
2567  scoring_methods.push_back("BLOSUM45");
2568  scoring_methods.push_back("BLOSUM62");
2569  scoring_methods.push_back("BLOSUM80");
2570  scoring_methods.push_back("Protein Quality Scoring with Coloring");
2571  scoring_methods.push_back("Hydropathy Scale");
2572  scoring_methods.push_back("Membrane preference");
2573  scoring_methods.push_back("Signal sequence");
2574  scoring_methods.push_back("Size");
2575  }
2576 
2577  if(config_num != CONFIG_PROT) {
2578  if(config_num != CONFIG_ALL) {
2579  scoring_methods.push_back(kDefaultScoringMethod);
2580  }
2581  scoring_methods.push_back("Nucleic Acid Colors");
2582  if (config_num == CONFIG_SRA) {
2583  scoring_methods.push_back(CSGAlnQualityScore::GetScoreName());
2584  }
2585  }
2586 
2587  if (!track_proxy) {
2588  switch (config_num) {
2589  case CONFIG_SRA:
2590  config->SetSubkey("SRA");
2591  break;
2592  case CONFIG_PROT:
2593  config->SetSubkey("protein");
2594  break;
2595  default:
2596  break;
2597  }
2598  }
2599 
2600  if (track_proxy) {
2601  // Configuration is for a specific track, end generation loop
2602  config_num = 0;
2603  } else {
2604  --config_num;
2605  }
2606 
2607  bool enable_color = view.GetBool("EnableColoration", true);
2608  string scoring_method = view.GetString("DNAScoringMethod", kDefaultScoringMethod);
2609  if (config_num == CONFIG_PROT) {
2610  scoring_method = view.GetString("ProteinScoringMethod", kDefaultScoringMethod);
2611  }
2612 
2613  bool aligned_seqfeats = view.GetBool("ShowAlignedSeqFeats", false);
2614  bool show_identical_bases = view.GetBool("ShowIdenticalBases", false);
2615  bool label = view.GetBool("ShowLabel", true);
2616  bool link_mate_pair = view.GetBool("LinkMatePairAligns", true);
2617  string rendering_style = view.GetString("Layout");
2618  string hide_sra = view.GetString("HideSraAlignments", kDefaultSraFilter);
2619  string unaligned_tails_mode = view.GetString("UnalignedTailsMode", kDefaultUnalignedTailsMode);
2620  bool show_second_pass = view.GetBool("ShowSecondPass", true);
2621  int flag = view.GetInt("StatDisplay", 15);
2622  bool show_aln_stat = view.GetBool("ShowAlnStat", false);
2623 
2624  ITERATE (TKeyValuePairs, iter, settings) {
2625  try {
2626  if (NStr::EqualNocase(iter->first, "Color")) {
2627  if (NStr::EqualNocase(iter->second, "false")) {
2628  enable_color = false;
2629  } else {
2630  enable_color = true;
2631  if ( !NStr::EqualNocase(iter->second, "true") ) {
2632  // verify to see if it is a legitimate scoring method
2633  ITERATE (vector<string>, sm_iter, scoring_methods) {
2634  if (NStr::EqualNocase(iter->second, *sm_iter)) {
2635  scoring_method = iter->second;
2636  break;
2637  }
2638  }
2639  }
2640  }
2641  } else if (NStr::EqualNocase(iter->first, "AlignedSeqFeats"))
2642  aligned_seqfeats = NStr::StringToBool(iter->second);
2643  else if (NStr::EqualNocase(iter->first, "IdenticalBases"))
2644  show_identical_bases = NStr::StringToBool(iter->second);
2645  else if (NStr::EqualNocase(iter->first, "show_second_pass"))
2646  show_second_pass = NStr::StringToBool(iter->second);
2647  else if (NStr::EqualNocase(iter->first, "Label"))
2648  label = NStr::StringToBool(iter->second);
2649  else if (NStr::EqualNocase(iter->first, "UnalignedTailsMode"))
2650  unaligned_tails_mode = iter->second;
2651  else if (NStr::EqualNocase(iter->first, "Layout")) {
2652  // check whether the user-provided string is a valid layout string
2653  CAlignmentTrack::LayoutStrToValue(iter->second);
2654  rendering_style = iter->second;
2655  } else if (NStr::EqualNocase(iter->first, "StatDisplay")) {
2656  flag = NStr::StringToInt(iter->second);
2657  } else if (NStr::EqualNocase(iter->first, "ShowAlnStat")) {
2658  show_aln_stat = NStr::StringToBool(iter->second);
2659  } else if (NStr::EqualNocase(iter->first, "LinkMatePairAligns")) {
2660  link_mate_pair = NStr::StringToBool(iter->second);
2661  } else if (NStr::EqualNocase(iter->first, "HideSraAlignments")) {
2662  hide_sra = iter->second;
2663  } else if (NStr::EqualNocase(iter->first, "ShowSecondPass")) {
2664  show_second_pass = NStr::StringToBool(iter->second);
2665  } else if (NStr::EqualNocase(iter->first, "GraphHeight")) {
2666  config->SetHidden_settings().push_back
2667  (CTrackConfigUtils::CreateHiddenSetting("GraphHeight", iter->second));
2668  } else if (NStr::EqualNocase(iter->first, "GraphScale")) {
2669  config->SetHidden_settings().push_back
2670  (CTrackConfigUtils::CreateHiddenSetting("GraphScale", iter->second));
2671  } else if (NStr::EqualNocase(iter->first, "GraphColor")) {
2672  config->SetHidden_settings().push_back
2673  (CTrackConfigUtils::CreateHiddenSetting("GraphColor", iter->second));
2674  } else if (NStr::EqualNocase(iter->first, "MinPileUpCost")) {
2675  config->SetHidden_settings().push_back
2676  (CTrackConfigUtils::CreateHiddenSetting("MinPileUpCost", iter->second));
2677  } else if (NStr::EqualNocase(iter->first, "MinAlignCost")) {
2678  config->SetHidden_settings().push_back
2679  (CTrackConfigUtils::CreateHiddenSetting("MinAlignCost", iter->second));
2680  } else if (NStr::EqualNocase(iter->first, "MaxAlignCost")) {
2681  config->SetHidden_settings().push_back
2682  (CTrackConfigUtils::CreateHiddenSetting("MaxAlignCost", iter->second));
2683  } else if (NStr::EqualNocase(iter->first, "MaxAlignShownFull")) {
2684  config->SetHidden_settings().push_back
2685  (CTrackConfigUtils::CreateHiddenSetting("MaxAlignShownFull", iter->second));
2686  } else if (NStr::EqualNocase(iter->first, "MaxAlignShownAdaptive")) {
2687  config->SetHidden_settings().push_back
2688  (CTrackConfigUtils::CreateHiddenSetting("MaxAlignShownAdaptive", iter->second));
2689  }
2690 
2691  } catch (CException&) {
2692  LOG_POST(Warning << "CAlignmentTrack::x_LoadSettings() invalid settings: "
2693  << iter->first << ":" << iter->second);
2694  }
2695  }
2696  if (NStr::FindNoCase(rendering_style, "adaptive") != string::npos)
2697  rendering_style = "Adaptive";
2698 
2699  // alignment rendering style settings
2701  "Layout", "Alignment Display", rendering_style,
2702  "Alignment rendering style");
2703  choice->SetValues().push_back(
2707  "Pack alignments if necessary",
2708  ""));
2709  choice->SetValues().push_back(
2713  "Always pack all alignments into a coverage graph or pileup graph",
2714  ""));
2715  choice->SetValues().push_back(
2719  "Show one alignment per row sorted by alignments' start location",
2720  ""));
2721  choice->SetValues().push_back(
2725  "Show all alignments",
2726  ""));
2727 
2728  config->SetChoice_list().push_back(choice);
2729 
2730  config->SetChoice_list().push_back(CAlnStatGlyph::CreateDisplayOptions("StatDisplay", flag));
2731 
2732  if ( !enable_color ) {
2733  scoring_method = "false";
2734  }
2735  // setting for alignment scoring method
2737  "Color", "Score method", scoring_method,
2738  "Alignment score coloration method");
2739 
2740  ITERATE (vector<string>, iter, scoring_methods) {
2741  choice->SetValues().push_back(
2743  *iter, *iter, *iter, ""));
2744  }
2745  choice->SetValues().push_back(
2747  "false", "Disabled", "No score coloration", ""));
2748  config->SetChoice_list().push_back(choice);
2749 
2750  // setting for linking mate pair (on/off)
2751  config->SetCheck_boxes().push_back(
2753  "LinkMatePairAligns", "Link mate pairs",
2754  "Enable/disable linking mate reads", "", link_mate_pair));
2755 
2756  // setting for show pileup alongside with alignments (on/off)
2757  config->SetCheck_boxes().push_back(
2759  "ShowAlnStat","Show pileup",
2760  "Enable/disable pileup display alongside with alignments", "",
2761  show_aln_stat));
2762 
2763  // setting for projecting features from aligned sequence
2764  config->SetCheck_boxes().push_back(
2766  "AlignedSeqFeats", "Project features",
2767  "Show features projected from the aligned sequences", "",
2768  aligned_seqfeats));
2769 
2770  // setting for label (on/off)
2771  config->SetCheck_boxes().push_back(
2773  "Label", "Show labels", "Show/hide alignment labels", "", label));
2774 
2775  // setting for showing identical bases for alignments, or just showing a glyph to show they match
2776  config->SetCheck_boxes().push_back(
2778  "IdenticalBases", "Show identical bases", "Write characters for matching bases", "", show_identical_bases));
2779 
2780  // setting for hide second_pass alignments (on/off)
2781  config->SetCheck_boxes().push_back(
2783  "ShowSecondPass", "Show second-pass alignments",
2784  "Show/Hide second-pass alignments", "", show_second_pass, show_second_pass == view.GetBool("ShowSecondPass", true) ));
2785 
2786  // Unaligned tails
2787  {
2789  "UnalignedTailsMode", "Unaligned Tails", unaligned_tails_mode,
2790  "Unaligned tails display mode");
2791  choice->SetValues().push_back(
2794  "Hide",
2795  "Hide the unaligned tails",
2796  ""));
2797 
2798  choice->SetValues().push_back(
2801  "Show Tail Length",
2802  "Display the length of the unaligned tails",
2803  ""));
2804 
2805  choice->SetValues().push_back(
2808  "Show Sequence",
2809  "Display the unaligned tails row sequence",
2810  ""));
2811 
2812  config->SetChoice_list().push_back(choice);
2813  }
2814 
2815  // SRA alignments to hide
2816  if (sraTrack || (CONFIG_SRA == config_num)) {
2818  "HideSraAlignments", "Hide Alignments", hide_sra,
2819  "SRA alignments to hide");
2820  choice->SetValues().push_back(
2823  "None",
2824  "Show all alignments",
2825  ""));
2826 
2827  choice->SetValues().push_back(
2830  "Duplicates",
2831  "Hide PCR duplicates",
2832  ""));
2833 
2834  choice->SetValues().push_back(
2837  "Bad reads",
2838  "Hide reads with poor sequence quality",
2839  ""));
2840 
2841  choice->SetValues().push_back(
2844  "Duplicates/Bad reads",
2845  "Hide PCR duplicates and reads with poor sequence quality",
2846  ""));
2847 
2848  config->SetChoice_list().push_back(choice);
2849  }
2850 
2851  string sort_by = kEmptyStr;
2852  if (track_proxy) {
2853  sort_by = track_proxy->GetSortBy();
2854  }
2855 
2857  "sort_by", "Sort alignments by", sort_by,
2858  "Sort alignments according to a selected criterion.");
2859 
2860  choice->SetValues().push_back(
2862  "", "No sorting", "Don't sort alignments", ""));
2863 
2865 
2866  config->SetChoice_list().push_back(choice);
2867 
2868  } // while (config_num)
2869 
2870  return config_set;
2871 }
2872 
2873 
2875 {
2876  CLayoutTrack::RegisterIconImage("track_align_score", "track_align_score.png");
2877  CLayoutTrack::RegisterIconImage("track_stat", "track_stat.png");
2878  CLayoutTrack::RegisterIconImage("track_tails", "track_tails.png");
2879 }
2880 
2881 
2883 {
2885 }
2886 
2887 
2889 {
2891 }
2892 
2893 
2894 
2895 
static const size_t kProjectedFeatID
static const TUnalignedTailsModeStr s_UnalignedTailsModeStrs[]
CStaticArrayMap< string, CAlignmentConfig::ELabelPosition > TLabelPosMap
static const THideSraStr s_HideSraStrs[]
USING_SCOPE(objects)
static const char * kDefaultScoringMethod
@ CONFIG_PROT
@ CONFIG_NUC
@ CONFIG_SRA
@ CONFIG_ALL
special setting for TMS tracks that did not go through complete alignment type discovery in seqconfig...
static const map< string, CAlignmentTrack::ELayout > sm_LayoutMap
DEFINE_STATIC_ARRAY_MAP(TLabelPosMap, sm_LabelPosMap, s_LabelPosStrs)
static const map< CAlignmentTrack::ELayout, string > sm_LayoutDispMap
layout style to layout display name
static const TLabelPosStr s_LabelPosStrs[]
static const string kTrackName
const string & s_LayoutToDisplayName(CAlignmentTrack::ELayout layout)
static const double kMinCoverageZoomLevel
Scale at which we unconditionally switch to coverage graph.
static const int kShowPileUpRange
Range length for unconditional swith to pieup.
CStaticArrayMap< string, CAlignmentConfig::EHideSraAlignments > THideSraMap
SStaticPair< const char *, CAlignmentConfig::EUnalignedTailsMode > TUnalignedTailsModeStr
static const string kMatePairKey
static const string kGeneModelBaseKey
SStaticPair< const char *, CAlignmentConfig::ELabelPosition > TLabelPosStr
static const string kDefProfile
CSGAlignmentDS::EDataLoader s_ParseAlignDataLoader(const string &align_loader)
static const string kAlignGlyphKey
SStaticPair< const char *, CAlignmentConfig::EHideSraAlignments > THideSraStr
static const int kMaxID
static const char * kDefaultUnalignedTailsMode
static const string kReadsProfile
static const size_t kContentBaseID
IAlnExplorer::EAlignType s_ParseAlignType(const string &align_type)
CStaticArrayMap< string, CAlignmentConfig::EUnalignedTailsMode > TUnalignedTailsModeMap
static const char * kDefaultSraFilter
static const string kBaseKey
void SetConfig(CConstRef< CAlignmentConfig > conf)
inline methods
static std::string const & GetHaplotypeID()
static void SetTrackSetting(objects::CChoice &choice)
static const string & GetID()
File Description:
ELabelPosition m_LabelPos
@ eNormal
no compact mode
@ eCompact
compact mode
@ eExtremeCompact
extreme compact mode
CRgbaColor m_SeqMismatch
CRgbaColor m_SmearColorMin
CRgbaColor m_SmearColorMax
CRgbaColor m_TailColor
CGlTextureFont m_LabelFont
CRgbaColor m_Sequence
CRgbaColor m_Insertion
bool m_Dirty
Dirty flag indicates any unsaved changes.
CGlTextureFont m_SeqFont
ECompactMode m_CompactMode
Alignment layout compact mode.
CRgbaColor m_UnalignedSequence
bool m_ShowUnalignedTailsForTrans2GenomicAln
CRgbaColor m_UnalignedFG
CRgbaColor m_NonConsensus
EUnalignedTailsMode m_UnalignedTailsMode
@ ePos_Above
above the rendered bar
@ ePos_Side
always on 5' side
@ ePos_NoLabel
no label
virtual void RegisterIconImages() const override
virtual void GetMatchedAnnots(const TAnnotMetaDataList &src_annots, const ILayoutTrackFactory::SExtraParams &params, TAnnotNameTitleMap &out_annots) const override
virtual string GetExtensionIdentifier() const override
returns the unique human-readable identifier for the extension the id should use lowercase letters se...
virtual string GetExtensionLabel() const override
returns a displayable label for this extension ( please capitalize the key words - "My Extension" )
virtual const CTrackTypeInfo & GetThisTypeInfo() const override
virtual CRef< objects::CTrackConfigSet > GetSettings(const string &profile, const TKeyValuePairs &settings, const CTempTrackProxy *track_proxy) const override
virtual TTrackMap CreateTracks(SConstScopedObject &object, ISGDataSourceContext *ds_context, CRenderingContext *r_cntx, const SExtraParams &params=SExtraParams(), const TAnnotMetaDataList &src_annots=TAnnotMetaDataList()) const override
CAlignmentTrackFactory.
CAlignmentTrack –.
static CTrackTypeInfo m_TypeInfo
void OnToggleContent(int id)
CRef< CSGAlignmentDS > m_DS
size_t m_CompactThreshold
Alignment number threshold between compact mode and non-compact mode.
void x_AddAlignmentLayout(const CSGJobResult &result)
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.
int x_LayoutToCutoff(CAlignmentTrack::ELayout layout)
CAlignmentTrack.
bool m_ShowUnalignedTailsForTrans2GenomicAln
void SetAnnot(const string &annot)
virtual const CTrackTypeInfo & GetTypeInfo() const override
virtual CHTMLActiveArea * InitHTMLActiveArea(TAreaVector *p_areas) const override
Initialize the HTML active area for a track.
virtual void x_OnJobCompleted(CAppJobNotification &notify) override
vector< CRef< CAlnStatGlyph > > m_StatGlyph
EAlignGlyphType x_GetAlignGlyphType(const CSeqGlyph *glyph) const
int m_MaxAlignShownFull
MaxAlignCost Show PileUp Graph is cost is higher than MaxAlignCost.
static ELayout LayoutStrToValue(const string &layout)
CAlignmentConfig::EHideSraAlignments m_HideSraAlignments
void x_LoadMPPWAlignSettings()
CAlignmentTrack(CSGAlignmentDS *ds, CRenderingContext *r_cntx)
size_t m_ExtremeCompactThreshold
Alignment number threshold between compact mode and extreme compact mode.
void x_SavePWAlignSettings() const
void x_AddGraphLayout(const CSGJobResult &result)
virtual ~CAlignmentTrack()
vector< int > TSubtypeVec
virtual void x_SaveSettings(const string &preset_style) override
save part of settings to a profile string.
static const string & LayoutValueToStr(ELayout layout)
int x_LayoutToCutoff_SRA(CAlignmentTrack::ELayout layout)
CRef< CSimpleLayout > m_GeneModelLayout
CRef< CColumnLayout > m_Column
double m_MinAlignCost
MinPileUpCost - Show Coverage Graph if cost is higher than MinPileUpCost.
static CAlignmentConfig::EUnalignedTailsMode UnalignedTailsModeStrToValue(const string &tailsMode)
CRef< CBoundaryParams > m_GeneGroupConf
CRef< CHistParams > x_GetGraphParams()
void x_LoadAlignSmearSettings()
CRef< CAlignmentConfig > m_MultiAlignConf
> Default Settings profile
virtual void x_OnIconClicked(TIconID id) override
Mouse left-click event handler on an icon.
void x_SaveMultiAlignSettings() const
virtual void x_UpdateBoundingBox() override
Update the bounding box assuming children's sizes are fixed if any.
static const string & HideFlagValueToStr(CAlignmentConfig::EHideSraAlignments hideSra)
static const string & LabelPosValueToStr(CAlignmentConfig::ELabelPosition pos)
void x_AddAlignStatLayout(const CSGJobResult &result)
IAlnExplorer::EAlignType m_AlnType
CRef< CAlignmentConfig > m_MPPWAlignConf
for linked pairwise aligns
virtual void GetHTMLActiveAreas(TAreaVector *p_areas) const override
Get html active areas.
void x_SaveConfiguration(const string &preset_style) const
save all track settings to the configuration file.
CAlignmentConfig::EUnalignedTailsMode m_UnalignedTailsMode
TSubtypeVec m_ProjectedFeats
virtual void x_UpdateData() override
update track content.
virtual string GetFullTitle() const override
get a more meaningful title.
void x_AddAlignFeatLayout(CBatchJobResult &results)
virtual void x_LoadSettings(const string &preset_style, const TKeyValuePairs &settings) override
load the track settings.
void x_LoadAlignedSeqFeats(vector< CRef< CAlignGlyph > > &aligns, CAlignGlyph *aln)
void x_SaveMatePairSettings() const
CRef< CAlignmentConfig > m_AlignSmearConf
CRef< CGeneModelConfig > m_GeneModelConfig
void x_SaveAlignSmearSettings() const
static CAlignmentConfig::ELabelPosition LabelPosStrToValue(const string &pos)
void x_LoadMultiAlignSettings()
CRef< CMatePairConfig > m_MatePairConf
void x_AddAlignFeat_Recursive(CLayoutGroup::TObjectList &objs)
@ eLayout_Adaptive
adaptive using loading costs to switch between rendering modes
@ 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
static CAlignmentConfig::EHideSraAlignments HideFlagStrToValue(const string &hideSra)
CRef< CBoundaryParams > m_FeatGroupConf
CRef< CAlignmentConfig > m_PWAlignConf
static const string & UnalignedTailsModeValueToStr(CAlignmentConfig::EUnalignedTailsMode tailsMode)
void x_SaveAlignmentSettings(const string &key, CConstRef< CAlignmentConfig > conf) const
double m_MaxAlignCost
MinAlignCost - Show Alignment Graph if cost is higher than MinAlignCost.
wxEvtHandler * m_ContentHandler
wx-related event handler.
void x_OnChangeProjectedFeats(wxCommandEvent &)
on change the projected feature list.
void OnContextMenu(wxContextMenuEvent &anEvent)
CAlignmentTrack * m_Track
void x_OnToggleContent(wxCommandEvent &event)
CAlnContentEvtHandler(CAlignmentTrack *track)
@ fBarGraph
otherwise, shown as density table
@ fShowCount
otherwise, shown percentage
@ fShowMismatch
otherwise, shown individual count
void SetDisplayFlag(FDisplay bit, bool f)
int m_StatZoomLevel
at what zoom level to turn on statistics
void SetShowLabel(bool flag)
array< CRgbaColor, eStat_Total+1 > m_Colors
color settings
@ eStat_Mismatch
mismatches (A+G+T+C - matches)
@ eStat_Total
total alignment count at this base (A+G+T+C+Gap)
bool IsBarGraph() const
CAlnStatConfig inline method implementation.
static CRef< objects::CChoice > CreateDisplayOptions(const string &option_name, int display_flag)
CAppJobNotification Notification send by CAppJobEventTranslator.
CBatchJobResult – the data structure holding the seqgraphic job results for a batch job processing.
vector< CRef< CSGJobResult > > TResults
IBoundaryParams.
CColumnLayout is for creating layout by sorting glyphs into 'columns'.
void SetVertSpace(int d)
void SetMinDist(TSeqPos dist)
void SetLimitRowPerGroup(bool f)
CDataTrack - a abstract base class for layout tracks which need to deal with background data retrieva...
Definition: data_track.hpp:55
void x_UpdateLayout()
Definition: data_track.hpp:127
void SetRulerType(int ruler_types)
void SetProjectedFeat(bool f)
void SetConfig(CConstRef< CFeatureParams > conf)
const objects::CSeq_feat & GetFeature(void) const
Access the original feature.
CFeatListItem - basic configuration data for one "feature" type.
CConfigurableItems - a static list of items that can be configured.
bool GetItemBySubtype(int subtype, CFeatListItem &config_item) const
void GetSelected(TFeatTypeItemSet &feat_types)
void SetSelected(TFeatTypeItemSet &feat_types)
CGeneGroup is a subclass of CLayoutGroup contains gene, RNA, cds, and Exon features.
bool m_ShowNtRuler
Show nucleotide ruler.
bool m_ShowAaRuler
Show protein ruler.
void LoadSettings(CConstRef< CSeqGraphicConfig > g_conf, const string &reg_path, const string &profile)
CRef< CCdsConfig > m_CdsConfig
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.
CLayoutGroup & SetGroup()
CRef< CInlineLayout > m_Inline
const CLayoutGroup::TObjectList & GetChildren() const
const CLayoutGroup & GetGroup() const
CLayoutGroup::TObjectList & SetChildren()
CRef< CLayeredLayout > m_Layered
CRef< CSimpleLayout > m_Simple
void SetLayoutPolicy(ILayoutPolicy *policy)
Set policy on how to deploy the layout of its children.
static CGuiRegistry & GetInstance()
access the application-wide singleton
Definition: registry.cpp:400
@ fNoHighlight
no highlighting on mouse over
@ fDrawBackground
highlight background for this area
@ fComment
render a label/comment on client side
@ fNoSelection
the object can't be selected
@ fTooltipEmbedded
tooltip embedded
string m_ID
area identifier
int m_Flags
area flags, will need to replace m_Type
string m_ParentId
parent entity idendifier, such as track_id
bool m_PositiveStrand
the default is true
File Description:
static EScale ScaleStrToValue(const string &scale)
EScale m_Scale
requested scale
TModelUnit m_Height
CRgbaColor m_fgColor
void SetDialogHost(IGlyphDialogHost *host)
void SetAnnotName(const string &name)
void SetConfig(const CSeqGraphicConfig &config)
CJobResultBase – the basic job result class holding a token.
CLayoutGroup is a container of CSeqGlyphs (layout objects).
void SetLayoutPolicy(ILayoutPolicy *policy)
Set policy on how to deploy the layout of its children.
void SetConfig(const CBoundaryParams *conf)
Set composition boundary parameters.
void PushBack(CSeqGlyph *obj)
Append a layout object to the end.
TObjectList & SetChildren()
const TObjectList & GetChildren() const
CLayoutGroup inline methods.
bool Remove(CSeqGlyph *obj)
Remove a layout object.
void Append(TObjectList &objs)
CConstRef< CSeqGlyph > GetChild(int idx) const
Get the layout object at index 'idx'.
void Insert(int at, CSeqGlyph *obj)
Insert a layout object before the given index.
void Set(const TObjectList &objs)
ILayoutPolicy::TObjectList TObjectList
File Description:
@ eIcon_Content
icon id for setting content
@ eIcon_Layout
icon id for setting layout style
ILayoutTrackHost * m_LTHost
Top level host owning the tracks.
string GetTitle() const
get the track title.
int GetIndent() const
TTrackAttrFlags m_Attrs
various track attributes
const string & GetId() const
virtual void x_OnIconClicked(TIconID id)
Mouse left-click event handler on an icon.
@ fNavigable
Track has navigation controls.
const string & GetProfile() const
TModelUnit x_GetTBHeight() const
Get title bar height including margin.
void SetMsg(const string &msg)
static void RegisterIconImage(const TIconAlias &key, const string &img_file)
register the image for an icon.
CConstRef< CSeqGraphicConfig > x_GetGlobalConfig() const
Method for getting global configuration from rendering context.
void SetProfile(const string &preset_style)
CLayoutTrack inline method implmentation.
CRef< CSeqGraphicConfig > m_gConfig
global configuration.
int TIconID
use int as TIconID instead of EIconID.
virtual CHTMLActiveArea * InitHTMLActiveArea(TAreaVector *p_areas) const
Initialize the HTML active area for a track.
void x_RegisterIcon(const SIconInfo &icon)
register track icons.
CMatePairConfig: the data structure holding alignment rendering parameters.
CRgbaColor m_FGOrientation
CRgbaColor m_FGDistance
bool m_Dirty
Dirty flag indicates any unsaved changes.
CRgbaColor m_FGContraAlign
CRgbaColor m_SeqDistance
CRgbaColor m_SeqNonUnique
CGlTextureFont m_LabelFont
CRgbaColor m_SeqOrientation
CRgbaColor m_SeqMismatchNo
CRgbaColor m_FGCoAlign
CRgbaColor m_SeqMismatchNonUnique
CRgbaColor m_FGNonUnique
CRgbaColor m_SeqMismatchDistance
CRgbaColor m_SeqMismatchOrientation
TAlignList & SetSeqAligns()
vector< CRef< CAlignGlyph > > TAlignList
void SetConfig(CConstRef< CMatePairConfig > conf)
CTitleGroup is a layout group with a title.
Definition: named_group.hpp:45
void SetTitleFont(CGlTextureFont *font)
void SetBackgroundColor(const CRgbaColor &color)
void SetRepeatDist(int dist)
void SetRepeatTitle(bool f)
void SetTitleColor(const CRgbaColor &color)
void SetIndent(int indent)
void SetShowTitle(bool f)
class CRegistryReadView provides a nested hierarchical view at a particular key.
Definition: reg_view.hpp:58
int GetInt(const string &key, int default_val=0) const
access a named key at this level, with no recursion
Definition: reg_view.cpp:230
double GetReal(const string &key, double default_val=0) const
Definition: reg_view.cpp:235
bool GetBool(const string &key, bool default_val=false) const
Definition: reg_view.cpp:241
string GetString(const string &key, const string &default_val=kEmptyStr) const
Definition: reg_view.cpp:246
CConstRef< objects::CUser_field > GetField(const string &key) const
provide raw field access
Definition: reg_view.cpp:104
void Set(const string &key, int val)
access a named key at this level, with no recursion
Definition: reg_view.cpp:533
CRenderingContext offers the basic context and utility methods for rendering layout objects in featur...
const TSeqRange & GetVisSeqRange() const
const TModelUnit & GetScale() const
TModelUnit SeqToScreen(const TModelUnit &size) const
convert from sequence positions to screen pixels
TModelUnit ScreenToSeq(const TModelUnit &size) const
convert from screen pixels to sequence positions
bool IsOverviewMode() const
bool WillSeqLetterFit() const
is it enougth space to sequence letters.
class CRgbaColor provides a simple abstraction for managing colors.
Definition: rgba_color.hpp:58
objects::CTSE_Handle m_DataHandle
void GetAnnotNames(objects::SAnnotSelector &sel, const TSeqRange &range, TAnnotNameTitleMap &names) const
const string & GetProteinScoringMethod() const
bool IsRangeCached(const TSeqRange &range) const
void SetEnableColoration(bool f)
bool GetEnableColoration() const
void SetDNAScoringMethod(const string &method)
void SetSortBy(const string &sortby)
IAlnExplorer::EAlignType GetAlignType(const CSeqGlyph *obj) const
void LoadAlignments(const TSeqRange &range, TModelUnit window, int align_limit, bool smear_if_overlimit, TJobToken token)
void SetRemotePath(const string &remote_path)
void SetCgiMode(bool cgi_mode)
bool CanShowRange(const TSeqRange &range, int align_limit)
const string & GetSortBy() const
bool IsValidProteinScoringMethod(const string &name)
void LoadAlignFeats(const TSeqRange &range, TModelUnit window, vector< CRef< CAlignGlyph > > aligns, const vector< int > &projected_feats, TJobToken token)
void EnablePileUpCache(bool enable, bool enable_icache)
void SetLayoutPolicy(ILayoutPolicy *layout_policy)
const TMethods & GetScoringMethods(IAlnExplorer::EAlignType aln_type)
get all the existing align scoring methods.
virtual void DeleteAllJobs()
Remove waiting jobs from queue or cancel the unfinished jobs.
IAlnExplorer::EAlignType InitAlignType(bool isFastConfig=false)
This method might need object manager to connect to ID, and it is a block call.
void SetHasCoverageGraph(bool flag)
void SetUnalignedTailsMode(CAlignmentConfig::EUnalignedTailsMode tailsMode)
void SetAnnotName(const string &name)
list< CIRef< IScoringMethod > > TMethods
keep instances of score methods here.
double GetAlignmentCost(const TSeqRange &range) const
void CalculateAlignmentScore(CSeqGlyph::TObjects &objs, TJobToken token)
void LoadCoverageGraph(const TSeqRange &range, TModelUnit window, TJobToken token)
bool IsValidDNAScoringMethod(const string &name)
double GetGraphCost(const TSeqRange &range) const
void SetHideSra(CAlignmentConfig::EHideSraAlignments hideSra)
void CalcAlnStat(const TAlnMgrVec &aligns, const TSeqRange &range, TModelUnit window, TJobToken token)
void SetMemoryLimit(Uint8 memory_limit)
vector< CConstRef< IAlnGraphicDataSource > > TAlnMgrVec
virtual void ClearJobID(TJobID job_id)
void SetProteinScoringMethod(const string &method)
void SetDataHandle(const objects::CTSE_Handle &tse)
const string & GetDNAScoringMethod() const
void SetShowSecondPassAlignments(bool value=true)
void SetAlnDataLoader(EDataLoader data_loader)
static const string & GetScoreName()
static CRegistryReadView GetSizeReadView(const CGuiRegistry &reg, const string &base_key, const string &sect, const string &key, const string &def_sect="")
static void GetFont(const CRegistryReadView &view, const string &face_key, const string &size_key, CGlTextureFont &f)
static string ComposeProfileString(const TKeyValuePairs &settings)
static CRegistryReadView GetColorReadView(const CGuiRegistry &reg, const string &base_key, const string &sect, const string &key, const string &def_sect="")
Create a read view specifically for 'Color' section.
static CRegistryReadView GetReadView(const CGuiRegistry &reg, const string &base_key, const string &curr_key, const string &def_key1="", const string &def_key2="", const string &def_key3="")
read/readwrite view creation helper methods.
static CRegistryReadView GetLabelPosReadView(const CGuiRegistry &reg, const string &base_key, const string &sect, const string &key, const string &def_sect="")
static CRegistryWriteView GetWriteView(CGuiRegistry &reg, const string &base_key, const string &curr_key, const string &def_key1="", const string &def_key2="", const string &def_key3="")
static CRegistryWriteView GetLabelPosRWView(CGuiRegistry &reg, const string &base_key, const string &sect, const string &key, const string &def_sect="")
static CRegistryWriteView GetColorRWView(CGuiRegistry &reg, const string &base_key, const string &sect, const string &key, const string &def_sect="")
static void ParseProfileString(const string &profile_str, TKeyValuePairs &settings)
static CRegistryWriteView GetSizeRWView(CGuiRegistry &reg, const string &base_key, const string &sect, const string &key, const string &def_sect="")
static void SetColor(CRegistryWriteView &view, const string &key, const CRgbaColor &color)
static void GetColor(const CRegistryReadView &view, const string &key, CRgbaColor &color)
static void SetFont(CRegistryWriteView &view, const string &face_key, const string &size_key, const CGlTextureFont &f)
static bool IsBackgroundJob()
void SetJobListener(CEventHandler *listener)
Set JobDispatcher listener.
void SetDepth(int depth)
Set the annotation selector resolving depth.
void SetAdaptive(bool flag)
CSGGraphDSType.
void GetAnnotNames(objects::SAnnotSelector &sel, const TSeqRange &range, TAnnotNameTitleMap &names, bool seq_table=false) const
CSGJobResult – the data structure holding the seqgraphic job results.
static const CFeatList * GetFeatList()
class CSeqGlyph defines an interface that wraps a rectilinear abstract object.
Definition: seq_glyph.hpp:82
void x_InitHTMLActiveArea(CHTMLActiveArea &area) const
initialize the basic information for a given active area.
Definition: seq_glyph.cpp:380
CRenderingContext * m_Context
the rendering context
Definition: seq_glyph.hpp:346
virtual void SetHeight(TModelUnit h)
Definition: seq_glyph.hpp:650
void SetParent(CSeqGlyph *p)
Definition: seq_glyph.hpp:670
void SetTearline(size_t Tearline)
tearline factor – used to limit a list of glyphs
Definition: seq_glyph.hpp:730
virtual TModelUnit GetTop() const
Definition: seq_glyph.hpp:599
virtual TModelUnit GetHeight() const
Definition: seq_glyph.hpp:587
virtual void SetTop(TModelUnit b)
Definition: seq_glyph.hpp:658
vector< CHTMLActiveArea > TAreaVector
Definition: seq_glyph.hpp:84
list< CRef< CSeqGlyph > > TObjects
Definition: seq_glyph.hpp:85
void SetRenderingContext(CRenderingContext *context)
Set the rendering context.
Definition: seq_glyph.hpp:684
CRef< CHistParamsManager > GetHistParamsManager() const
Get histogram config manager.
const string & GetLabelPos() const
CRef< CGlTextureFont > GetCommentFont() const
bool GetRepeatComment() const
const string & GetSizeLevel() const
CConstRef< CFeatureParams > GetFeatParams(TFeatSubtype subtype) const
Get feature settings using a feature subtype.
const CRgbaColor & GetFGCommentColor() const
const CRgbaColor & GetBGCommentColor() const
bool GetShowComments() const
const string & GetColorTheme() const
bool GetCgiMode() const
int GetCommentRepeatDist() const
CSimpleLayout is the simpliest layout policy that simply stack a set of glyphs one on top of the othe...
@ eSort_BySeqPos
seq start position
void SetSortingType(TSortingMethod meth)
class CStaticArrayMap<> provides access to a static array in much the same way as CStaticArraySet<>,...
Definition: static_map.hpp:175
TBase::const_iterator const_iterator
Definition: static_map.hpp:179
File Description:
const string & GetSortBy() const
const CLayoutTrack * GetTrack() const
CTrackConfigSet –.
static CRef< objects::CChoice > CreateChoice(const string &name, const string &disp_name, const string &curr_val, const string &help, bool optional=false)
Definition: layout_conf.hpp:79
static CRef< objects::CHiddenSetting > CreateHiddenSetting(const string &name, const string &value)
static CRef< objects::CCheckBox > CreateCheckBox(const string &name, const string &disp_n, const string &help_text, const string &legend_txt, bool value, bool optional=false)
Definition: layout_conf.hpp:96
static CRef< objects::CChoiceItem > CreateChoiceItem(const string &name, const string &disp_name, const string &help, const string &legend_txt, bool optional=false)
Definition: layout_conf.hpp:61
CTrackConfig –.
Definition: TrackConfig.hpp:66
CTrackTypeInfo - holds description of a layout track type.
const string & GetDescr() const
const string & GetId() const
void SetDisplay(bool is_graph)
void SetContent(bool is_agtc)
void SetValueType(bool is_count)
Alignment explorer interface.
virtual const objects::CSeq_id & GetSeqId(TNumrow row) const =0
virtual bool IsColoringAvailable() const
IGlyphDialogHost An interface used for handling issues related to any dialog pops up that requires so...
Definition: seq_glyph.hpp:399
virtual void PostDialogShow()=0
Post-processing after showing a dialog.
virtual void PreDialogShow()=0
Prepare for showing a dialog.
static void GetMatchedAnnots(const TAnnotMetaDataList &src_annots, const vector< string > &target_annots, const string &annot_type, const string &track_type, TAnnotNameTitleMap &out_annots)
Help function to find matched annotations.
virtual void LTH_PopupMenu(wxMenu *menu)=0
show track-specific context menu.
virtual void LTH_PushEventHandler(wxEvtHandler *handler)=0
virtual void LTH_OnLayoutChanged()=0
provides mouse coords in OpenGL viewport coord system
virtual void LTH_PopEventHandler()=0
ISGDSManager is seqgraphic data source manage that serves as an data source context.
virtual CIRef< ISGDataSource > GetDS(const string &type, SConstScopedObject &object)=0
Get a seqgraphic data source instance of the specified type.
virtual IAlnExplorer::TNumrow GetNumRows() const =0
virtual IAlnExplorer::TNumrow GetAnchor() const =0
iterator_bool insert(const value_type &val)
Definition: map.hpp:165
bool empty() const
Definition: map.hpp:149
Definition: map.hpp:338
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
static CMemoryRegistry registry
Definition: cn3d_tools.cpp:81
struct config config
@ fInvalid
#define true
Definition: bool.h:35
#define false
Definition: bool.h:36
static const char * str(char *buf, int n)
Definition: stats.c:84
static char tmp[3200]
Definition: utf8.c:42
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
#define NULL
Definition: ncbistd.hpp:225
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
Definition: ncbidiag.hpp:186
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
Definition: ncbidiag.hpp:226
void Error(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1197
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
Definition: ncbiexpt.hpp:704
const string & GetMsg(void) const
Get message string.
Definition: ncbiexpt.cpp:461
void Warning(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1191
bool IsSimplified() const
static objects::SAnnotSelector GetAnnotSelector(TAnnotFlags flags=0)
request an annotation selector for a given type
Definition: utils.cpp:167
static bool IsAlignDb(const string &annot)
check if a given annotation is AlignDb (potentially suffixed with batch identication string after a '...
Definition: utils.cpp:861
static void CreateCoverageAnnotName(const string &annot_name, string &coverage_annot)
Definition: utils.hpp:538
const IAlnGraphicDataSource & GetAlignMgr(void) const
Inline methods.
static bool IsGeneModelFeature(int type, int subtype)
Does feature belong to gene model track Gene, RNA, cdregion, exon, C_region, and VDJ segments.
Definition: na_utils.cpp:190
static bool IsUnnamed(const string &annot)
check if a given annotation is a unnamed annotation.
Definition: utils.hpp:525
virtual const objects::CSeq_loc & GetLocation(void) const
access the position of this object.
static TAnnotNameType NameTypeStrToValue(const string &type)
Definition: utils.cpp:140
void SetConfig(const CAlignmentConfig *conf)
@ eMaxRowLimit
@ eAdaptiveRowLimit
@ eAnnot_Other
any given named annots
Definition: utils.hpp:136
GLdouble TModelUnit
Definition: gltypes.hpp:48
void SetRight(T right)
Definition: glrect.hpp:114
T Top() const
Definition: glrect.hpp:84
IRender & GetGl()
convenience function for getting current render manager
void SetLeft(T left)
Definition: glrect.hpp:112
void SetTop(T top)
Definition: glrect.hpp:115
CRef< CObject > GetResult() const
returns non-null pointer only if Completed or Running and has temporary results available
bool Match(const CSeq_id &sid2) const
Match() - TRUE if SeqIds are equivalent.
Definition: Seq_id.hpp:1065
TRange GetTotalRange(void) const
Definition: Seq_loc.hpp:913
SAnnotSelector & SetCollectNames(bool value=true)
Collect available annot names rather than annots.
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:998
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
position_type GetLength(void) const
Definition: range.hpp:158
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static bool StringToBool(const CTempString str)
Convert string to bool.
Definition: ncbistr.cpp:2821
static string SizetToString(size_t value, TNumToStringFlags flags=0, int base=10)
Convert size_t to string.
Definition: ncbistr.cpp:2751
#define kEmptyStr
Definition: ncbistr.hpp:123
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
Definition: ncbistr.cpp:630
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
Definition: ncbistr.cpp:3461
static SIZE_TYPE FindNoCase(const CTempString str, const CTempString pattern, SIZE_TYPE start, SIZE_TYPE end, EOccurrence which=eFirst)
Find the pattern in the specified range of a string using a case insensitive search.
Definition: ncbistr.cpp:2993
static Uint8 StringToUInt8_DataSize(const CTempString str, TStringToNumFlags flags=0)
Convert string that can contain "software" qualifiers to Uint8.
Definition: ncbistr.cpp:1539
static const string BoolToString(bool value)
Convert bool to string.
Definition: ncbistr.cpp:2815
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate spaces in a string (in-place)
Definition: ncbistr.cpp:3201
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5084
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
Definition: ncbistr.hpp:5353
@ fConvErr_NoThrow
Do not throw an exception on error.
Definition: ncbistr.hpp:285
@ fSplit_Tokenize
All delimiters are merged and trimmed, to get non-empty tokens only.
Definition: ncbistr.hpp:2508
@ fWithCommas
Use commas as thousands separator.
Definition: ncbistr.hpp:254
static const char label[]
void SetFrom(TFrom value)
Assign a value to From data member.
Definition: Range_.hpp:231
void SetTo(TTo value)
Assign a value to To data member.
Definition: Range_.hpp:278
Tdata & Set(void)
Assign a value to data member.
E_Choice
Choice variants.
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
END_EVENT_TABLE()
#define wxT(x)
Definition: muParser.cpp:41
range(_Ty, _Ty) -> range< _Ty >
T max(T x_, T y_)
double f(double x_, const double &y_)
Definition: njn_root.hpp:188
EVT_MENU_RANGE(MID_SHOW_TITLES, MID_HIDE_TITLES, ViewerWindowBase::OnTitleView) EVT_MENU_RANGE(MID_ENABLE_EDIT
ViewerWindowBase::OnEditMenu ViewerWindowBase::OnJustification EVT_MENU(MID_SHOW_GEOM_VLTNS, ViewerWindowBase::OnShowGeomVltns) EVT_MENU(MID_FIND_PATTERN
#define row(bind, expected)
Definition: string_bind.c:73
A help struct for storing information about a icon.
extra parameter for initializing a track.
string m_RemotePath
Track remote path.
bool m_Adaptive
Adaptive/Exact selector.
TAnnots m_Annots
particular annotations the track will be looking at.
string m_SortBy
potential track-specific sort_by.
int m_Level
layout level that limits feature retrieving used by annotation selector.
string m_TrackProfile
Track setting profile for additionial parameters.
bool m_FastConfig
when set to true, indicates that that the factory is used by seqconfig this means that some operation...
bool m_SkipGenuineCheck
Flag indicating if track verification is required.
bool m_CoverageGraphCheck
Flag indicating if checking coverage graph is necessary.
SAnnotSelector –.
Template structure SStaticPair is simlified replacement of STL pair<> Main reason of introducing this...
Definition: static_set.hpp:60
Definition: type.c:6
#define _ASSERT
else result
Definition: token2.c:20
void UseDefaultMarginWidth(wxMenu &menu)
Using default menu item margin width.
Definition: wx_utils.cpp:693
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
Modified on Sun Apr 14 05:24:57 2024 by modify_doxy.py rev. 669887