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

Go to the SVN repository for this file.

1  /* $Id: snp_track.cpp 46990 2022-04-05 23:46:16Z evgeniev $
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: Melvin Quintos, Dmitry Rudnev
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 
46 
47 #include <gui/objutils/utils.hpp>
48 #include <gui/objutils/label.hpp>
50 
51 #include <objmgr/util/feature.hpp>
52 #include <objmgr/util/sequence.hpp>
53 #include <objmgr/annot_ci.hpp>
54 
59 
61 #include <gui/objutils/snp_gui.hpp>
62 
63 #include <wx/menu.h>
64 
67 
68 ///////////////////////////////////////////////////////////////////////////////
69 /// CSnpTrack
70 ///////////////////////////////////////////////////////////////////////////////
72 static const TLayoutStr s_LayoutStrs[] = {
73  { "Adaptive", CSnpTrack::eLayout_Adaptive },
74  { "Density", CSnpTrack::eLayout_Density },
75  { "Features", CSnpTrack::eLayout_Features },
76  { "Labels", CSnpTrack::eLayout_Labels },
77 };
78 
81 
82 static const string kBaseKey = "GBPlugins.SeqGraphicSNP";
83 static const string kDefProfile = "Default";
84 
86  "Variation features from dbSNP");
87 
88 static CSnpTrack::ELayout s_LayoutStrToValue(const string& layout)
89 {
90  TLayoutMap::const_iterator iter = sm_LayoutMap.find(layout);
91  if (iter != sm_LayoutMap.end()) {
92  return iter->second;
93  }
94  NCBI_THROW(CException, eInvalid, "Invalid layout string: " + layout);
95 }
96 
97 
99 {
101  if (iter->second == layout) {
102  return iter->first;
103  }
104  }
105  return kEmptyStr;
106 }
107 
108 CSnpTrack::CSnpTrack(CSGSnpDS* ds, CRenderingContext* r_cntx, const string& sFilter, const string& sTitle, const string& sLayout)
109  : CDataTrack(r_cntx)
110  , m_eLayout(eLayout_Adaptive)
111  , m_DS(ds)
112  , m_IconLayout(eIcon_Layout, "Layout", true, "track_layout")
113  , m_PreferredTitle(sTitle)
114 {
115  m_DS->SetJobListener(this);
116 
117  // Set layout
119  if(!sLayout.empty()) {
120  try {
121  layout = s_LayoutStrToValue(sLayout);
122  } catch(...) {}
123  }
124  if(layout == eLayout_Density) {
126  } else {
128  }
129  m_eLayout = layout;
130 
132 
133  if(!sFilter.empty())
134  m_Filter.Reset(new SSnpFilter(sFilter));
135 
136  SetTitle(sTitle, sTitle);
137 }
138 
139 
141 {
142  if ( !m_DS->AllJobsFinished() ) {
143  m_DS->DeleteAllJobs();
144  }
145 }
146 
148 {
149  if ( !m_JobResult ) {
150  return;
151  }
152 
153  // Determine if we show labels
154  bool bShowLabels = false;
155 
157  bShowLabels = true;
158  }
159 
160  // Setup feature parameters
162  curr_param->m_LabelPos =
165 
166  if (bShowLabels) {
168  } else {
170  }
171 
172  // add the layout
174  Update(true);
176 }
177 
179 {
181 }
182 
183 /// @name CLayoutTrack reimplemented methods.
184 /// @{
186 {
187  return m_TypeInfo;
188 }
189 
190 
192 {
193  string title = GetTitle();
194  if (title.empty()) {
195  title = m_PreferredTitle.empty() ? m_AnnotName : m_PreferredTitle;
196  }
197  return title;
198 }
199 
200 void CSnpTrack::SetAnnot(const string& name)
201 {
202  m_AnnotName = name;
203 }
204 
206 {
207  bool bIsLayoutOnlyChange = true;
208 
209  if (id == eIcon_Layout) {
210  wxMenu menu;
211  UseDefaultMarginWidth(menu);
212 
213  menu.AppendRadioItem(eLayout_Adaptive, wxT("Adaptive"));
214  menu.AppendRadioItem(eLayout_Density, wxT("Density"));
215  menu.AppendRadioItem(eLayout_Features, wxT("Features"));
216  menu.AppendRadioItem(eLayout_Labels, wxT("Labels"));
217 
218  menu.Check(m_eLayout, true);
219 
220  m_LTHost->LTH_PopupMenu(&menu);
221 
222  wxMenuItemList& item_list = menu.GetMenuItems();
223  ITERATE (wxMenuItemList, iter, item_list) {
224  ELayout new_layout = (ELayout)((*iter)->GetId());
225  if ((*iter)->IsChecked() && id != m_eLayout) {
226  // Reload data if we are changing from FeatGlyphs or HistogramGlyphs
228  if (new_layout==eLayout_Density) {
229  bIsLayoutOnlyChange = false;
230  }
231  }
232  else { // we currently have CHistogramGlyphs
233  if ( (new_layout==eLayout_Labels) ||
234  (new_layout==eLayout_Features) )
235  {
236  bIsLayoutOnlyChange = false;
237  }
238  }
239 
240  if (new_layout==eLayout_Adaptive) {
241  bIsLayoutOnlyChange = false;
242  }
243 
244  m_eLayout = new_layout;
245  break; // stop processing loop
246  }
247  }
248  }
249  else {
250  // use default handlers
252  }
253 
254  if (bIsLayoutOnlyChange) {
255  x_UpdateLayout();
256  }
257  else {
258  Update(false); // if false, reload data
259  }
260 }
261 /// @}
262 
263 void CSnpTrack::x_SaveSettings(const string& preset_style)
264 {
265  TKeyValuePairs settings;
266 
267  if ( !preset_style.empty() ) {
268  settings["profile"] = preset_style;
269  }
270 
271  settings["layout"] = s_LayoutValueToStr( (CSnpTrack::ELayout) m_eLayout );
272 
274 }
275 
276 void CSnpTrack::x_LoadSettings(const string& preset_style,
277  const TKeyValuePairs& settings)
278 {
279  if (preset_style.empty()) {
281  } else {
282  SetProfile(preset_style);
283  }
284 
285  // First load default profile settings
287  CRegistryReadView view =
289 
290  // Now override default settings passed in through profile settings
291  ITERATE (TKeyValuePairs, iter, settings) {
292  try {
293  if (NStr::EqualNocase(iter->first, "layout")) {
294  m_eLayout = s_LayoutStrToValue(iter->second);
295  }
296  else
297  LOG_POST(Warning << "SNP track: the settings are not supported - "
298  << iter->first << ":" << iter->second);
299  } catch (std::exception&) {
300  LOG_POST(Warning << "SNP track: got invalid profile - "
301  << iter->first << ":" << iter->second);
302  }
303  }
304 
306 
307  // initialize specific settings for SNP feature
310  m_Params->Reset(param);
312  curr_param->m_LabelFont.SetFontSize(10);
313 }
314 
315 
316 /// @name CDataTrack pure virtual interfaces
317 /// @{
318 
320 {
321  bool bFetchFeatures = (m_eLayout == eLayout_Features);
322  bool bAdaptive = (m_eLayout == eLayout_Adaptive);
323  m_DS->DeleteAllJobs();
325 
326  if (m_Filter.NotNull() && x_IsOverviewMode()) {
328  //x_SetStatus(", Please zoom in", 100);
329  string msg = "Zoom to see data!";
331  TModelUnit x = (range.GetFrom() + range.GetTo() ) * 0.5;
332  CRef<CSeqGlyph> message_glyph(new CCommentGlyph(msg, TModelPoint(x, 0.0)));
333 
334  if ( !m_JobResult ) {
336  }
337 
338  m_JobResult->listObjs.clear();
340  m_JobResult->listObjs.push_back(message_glyph);
342  } else {
344 
346  p.bPreferFeat = bFetchFeatures ||
349  p.bAdaptive = bAdaptive;
351  p.scale = m_Context->GetScale();
352  p.r_cntx = m_Context;
353 
355  }
356 }
357 
358 
359 
361 {
363 }
364 
366 {
368 }
369 
370 void CSnpTrack::GenerateAsn1(objects::CSeq_entry& seq_entry, TSeqRange range)
371 {
372 #if 1
373  CFeat_CI feature_iter(x_GetFeat_CI(range));
374 // cerr << "got features: " << feature_iter.GetSize() << endl;
375  CRef<CSeq_annot> pAnnot(new CSeq_annot);
376  CSeq_annot::TData::TFtable& ftable(pAnnot->SetData().SetFtable());
377 
378  for ( ; feature_iter; ++feature_iter) {
379  CRef<CSeq_feat> pFeat(new CSeq_feat);
380  const CMappedFeat& feat = *feature_iter;
381 // cerr << "Got feature" << endl <<
382 // MSerial_AsnText << feat.GetMappedFeature() << endl;
383  pFeat->Assign(feat.GetMappedFeature());
384  ftable.push_back(pFeat);
385  }
386 #else
387  CRef<CSeq_annot> pAnnot(new CSeq_annot);
388  CSeq_annot::TData::TGraph& graph(pAnnot->SetData().SetGraph());
389  CGraph_CI graph_iter(x_GetGraph_CI(range));
390  for ( ; graph_iter; ++graph_iter) {
391  CRef<CSeq_graph> pGraph(new CSeq_graph);
392  const CMappedGraph& gr = *graph_iter;
393  pGraph->Assign(gr.GetMappedGraph());
394  graph.push_back(pGraph);
395  }
396 #endif
397 
398  seq_entry.SetAnnot().push_back(pAnnot);
399 }
400 
401 bool CSnpTrack::CheckRange(TSeqRange range, string& sMsg, size_t& nFeats)
402 {
403  // this would have been the easiest, but the time to get the size is about the same as the time to iterate
404  // so prediction is no better than predicted
405  // auto feature_count(x_GetFeat_CI(range).GetSize());
406 
407  // we want to limit downloads to about 30M SNPs to prevent users from downloading whole chromosomes
408  static size_t s_MaxFeatures(30 * 1000 * 1000);
409 
411  if(nFeats > s_MaxFeatures) {
412  sMsg = "You have requested a range that contains approximately " + NStr::NumericToString(nFeats) +
413  " SNP records. We do not support downloads of more than " + NStr::NumericToString(s_MaxFeatures) +
414  " records. Please reduce the range and try again. If you need the whole SNP dataset, you can go to <a href=\"https://ftp.ncbi.nih.gov/snp/\" target=\"_blank\">dbSNP FTP site</a>.";
415  return false;
416  }
417  return true;
418 }
419 
420 
421 
423 {
424  CRef<CObject> res_obj;
425 
426  res_obj = notify.GetResult();
427  m_DS->ClearJobID(notify.GetJobID());
428 
429  m_JobResult.Reset(dynamic_cast<SSnpJobResult*>(&*res_obj));
431 }
432 
433 
435 {
436  if (!m_JobResult) {
437  ERR_POST("CSnpTrack::x_OnJobCompleted() notification for job \
438  does not contain results.");
439  return;
440  }
441 
442  // Depending on view, setup icon
443  if (x_IsOverviewMode()) {
445  }
446  else {
448  }
449 
450  m_Msg = "";
451  if ( !m_JobResult->listObjs.empty() ) {
452  switch (m_JobResult->eDataType) {
453  default:
455  m_Msg += ", density (seq-feats)";
456  break;
458  m_Msg += ", density (seq-graphs)";
459  break;
461  m_Msg += "";
462  break;
464  {
465  unsigned int size = (unsigned int) m_JobResult->listObjs.size();
466  m_Msg += ", " + NStr::UIntToString(size) + " features";
467  }
468  break;
469  }
470  }
471 
472  x_UpdateLayout();
473 }
474 
475 
476 /// @}
478 {
479  const CSeqGlyph::TObjects& objs = result.listObjs;
480 
481  m_Group.Clear();
482  if (m_Filter.NotNull()) {
484  }
485 
486  if (objs.empty()) {
487  m_Attrs |= fNavigable;
488  return;
489  }
490 
491  CRef<CSeqGlyph> first_glyph = objs.front();
492 
493  if (typeid(*first_glyph) == typeid(CHistogramGlyph)) {
494  CHistogramGlyph *hist = dynamic_cast<CHistogramGlyph*> (first_glyph.GetPointer());
495  hist->SetConfig(*x_GetGlobalConfig());
496  Add(first_glyph);
497  } else if (typeid(*first_glyph) == typeid(CCommentGlyph)) {
498  CCommentGlyph* comment =
499  dynamic_cast<CCommentGlyph*>(first_glyph.GetPointer());
500  CRef<CCommentConfig> c_config(new CCommentConfig);
501  c_config->m_ShowBoundary = false;
502  c_config->m_ShowConnection = false;
503  c_config->m_Centered = true;
504  c_config->m_LabelColor.Set(1.0f, 0.0f, 0.0f);
505  c_config->m_LineColor.Set(1.0f, 1.0f, 1.0f);
507  c_config->m_Font.SetFontSize(12);
508  comment->SetConfig(c_config);
509  Add(first_glyph);
510  } else {
512  string sColorTheme(x_GetGlobalConfig()->GetColorTheme());
513  CRegistryReadView ColorView(CSGConfigUtils::GetColorReadView(registry, "GBPlugins.SnpTrack", "Default", sColorTheme));
514  ITERATE(CSeqGlyph::TObjects, it, objs) {
515  CSeqGlyph *glyph = const_cast<CSeqGlyph*> (it->GetPointer());
516  CFeatGlyph *feat = dynamic_cast<CFeatGlyph*>(glyph);
517 
518  // get the SNP feature type and color code the drawn feature accordingly
519  const CSeq_feat& or_feat(feat->GetFeature());
520  feat->SetConfig(m_Params->GetFeatureParams(or_feat, ColorView));
521  Add(glyph);
522  }
523  m_Attrs |= fNavigable;
524  }
525 }
526 
527 
528 
529 ///////////////////////////////////////////////////////////////////////////////
530 /// CSnpTrackFactory
531 ///////////////////////////////////////////////////////////////////////////////
534  ISGDataSourceContext* ds_context,
535  CRenderingContext* r_cntx,
536  const SExtraParams& params,
537  const TAnnotMetaDataList& src_annots) const
538 {
539  TTrackMap tracks;
540 
541  // this is a misnomer
542  // in fact, the key is just a unique combination of annotation and filter
543  // and the value is the annotation
544  TAnnotNameTitleMap annots;
545 
546  TKeyValuePairs track_settings;
547  CSGConfigUtils::ParseProfileString(params.m_TrackProfile, track_settings);
548 
549  if (params.m_SkipGenuineCheck && !params.m_Annots.empty()) {
550  ITERATE (SExtraParams::TAnnots, iter, params.m_Annots) {
551  // when the annotation is "SNP" then the only way to distinguish between
552  // different tracks is the filter which is unique
553  // on the other hand, SNP 2.0 tracks are not supposed to have filter at all,
554  // so it is always empty, but the extended NAs used for them are always unique
555  annots[CSeqUtils::IsExtendedNAA(*iter) ? *iter : params.m_Filter] = *iter;
556  }
557  } else {
558  CSGSnpDS::GetAnnotNames(object, annots, r_cntx->GetVisSeqRange(), params);
559 
560  // collect TMS tracks
561  if ( !src_annots.empty() ) {
562  // Not sure how to distinguish dbSNP from dbVar at this point.
563  // In current SADB, there is only dbVar data, no dbSNP data.
564  GetMatchedAnnots(src_annots, params, annots);
565  }
566  }
567 
568  // create feature tracks
569  ITERATE(TAnnotNameTitleMap, iter, annots) {
570  // Create a new DS object for each track
571  CIRef<ISGDataSource> pre_ds = ds_context->GetDS(typeid(CSGSnpDSType).name(),
572  object);
573  CSGSnpDS* seq_ds = dynamic_cast<CSGSnpDS*>(pre_ds.GetPointer());
574  seq_ds->SetDepth(params.m_Level);
575  seq_ds->SetAdaptive(params.m_Adaptive);
576 
577  // again, only those strings that are not extended NAs are considered
578  // to be filters
579  string sAnnot(iter->second);
580  string sTitle;
581  if(params.m_AnnotNameTitleMap.count(sAnnot)) {
582  sTitle = params.m_AnnotNameTitleMap.at(sAnnot);
583  }
584  CRef<CSnpTrack> feat_track(new CSnpTrack(seq_ds,
585  r_cntx,
586  CSeqUtils::IsExtendedNAA(iter->first) ? "" : iter->first,
587  sTitle,
588  track_settings.count("Layout") ? track_settings["Layout"] : ""));
589 
590  feat_track->SetAnnot(sAnnot);
591 
592  seq_ds->SetJobListener(feat_track.GetPointer());
593  tracks[sAnnot] = feat_track.GetPointer();
594  }
595 
596  return tracks;
597 }
598 
600  const TAnnotMetaDataList& src_annots,
601  const ILayoutTrackFactory::SExtraParams& params,
602  TAnnotNameTitleMap& out_annots) const
603 {
605  ILayoutTrackFactory::GetMatchedAnnots(src_annots, dummy.m_Annots, "ftable", "SNP", out_annots);
606 
607  // currently SNP2.0 annots are captured by the fact that they are extended NAs
608  // this needs to be improved if extended NAs would be used for anything else
609  for(auto& i : src_annots) {
610  if(CSeqUtils::IsExtendedNAA(i.first, true)) {
612  i.first, i.second->m_Title));
613  }
614  }
615 }
616 
617 
619 {
620  return CSnpTrack::m_TypeInfo.GetId();
621 }
622 
624 {
626 }
627 
629 CSnpTrackFactory::GetSettings(const string& /*profile*/,
630  const TKeyValuePairs& settings,
631  const CTempTrackProxy* track_proxy) const
632 {
633  CRef<CTrackConfigSet> config_set(new CTrackConfigSet);
634  if (track_proxy) {
635  bool is_clinvar_track = (NPOS != NStr::FindNoCase(track_proxy->GetSource(), "clinvar"));
636  config_set->Set().push_back(x_GetSettings(settings, track_proxy, is_clinvar_track));
637  } else {
638  config_set->Set().push_back(x_GetSettings(settings, nullptr, false));
639  config_set->Set().push_back(x_GetSettings(settings, nullptr, true));
640  }
641  return config_set;
642 }
643 
645 CSnpTrackFactory::x_GetSettings(const TKeyValuePairs& settings, const CTempTrackProxy* track_proxy, bool is_clinvar_track) const
646 {
648  config->SetHelp() = GetThisTypeInfo().GetDescr();
649  config->SetLegend_text("anchor_4");
650  if (is_clinvar_track) {
651  config->SetLegend_text("anchor_4.2");
652  config->SetSubkey("clinvar");
653  }
654 
655  bool show_only_pathogenic{false};
657  ITERATE (TKeyValuePairs, iter, settings) {
658  try {
659  if (NStr::EqualNocase(iter->first, "layout")) {
660  layout = s_LayoutStrToValue(iter->second);
661  }
662  else if (NStr::EqualNocase(iter->first, "ShowOnlyPathogenic")) {
663  show_only_pathogenic = NStr::StringToBool(iter->second);
664  }
665  } catch (std::exception&) {
666  }
667  }
668 
669  // add layout dropdown list
671  "Layout", "Rendering options", s_LayoutValueToStr(layout),
672  "Controls how variants are displayed");
673  choice->SetValues().push_back(
676  "Show variants for 50 or less",
677  "Show labels if less than 15 variants; Show density bar if greater than 50 variants",
678  "Lines represent the variant features from dbSNP"));
679  choice->SetValues().push_back(
682  "Collapse on single line",
683  "Always show the density bar of variants",
684  "Lines represent the variant features from dbSNP"));
685  choice->SetValues().push_back(
688  "Show all",
689  "Show all variants rendered individually",
690  "Lines represent the variant features from dbSNP"));
691  choice->SetValues().push_back(
694  "Show variants with labels",
695  "Always show the labels of variants",
696  "Lines represent the variant features from dbSNP"));
697  config->SetChoice_list().push_back(choice);
698 
699  config->SetCheck_boxes().push_back(
701  "ShowOnlyPathogenic",
702  "Show only pathogenic/likely pathogenic",
703  "Show only pathogenic/likely pathogenic",
704  "", show_only_pathogenic, true));
705 
706  return config;
707 }
708 
709 
710 // gets a SNP class of a feature
711 // if not a SNP feature or class is unknown, returns CSnpBitfield::eUnknownVariation
713 {
714  return CSnpBitfield(feat).GetVariationClass();
715 }
716 
717 // check whether the feature is a SNP insertion
718 // if not a SNP feature or not an insertion, returns false
720 {
721  CSnpBitfield bf(feat);
723 // LOG_POST(Trace << "<<<< rs" << NSnp::GetRsid(feat));
724 
725  // bitfields pre-SNP 2.0 did not have a specific variation class for insertion, so this information had to be obtained from
726  // neighbors info encoded in the "Extra" field as neighbors
727  if(bf.GetVersion() < 20) {
728  if(feat.IsSetExt()) {
729  const CUser_object& user(feat.GetExt());
730  // according to SV-1896, a SNP feature in an insertion when rc_ngbr - lc_ngbr == 1
731  bool isInsertion(false);
732  CConstRef<CUser_field> field(user.GetFieldRef("Extra"));
733  if(field) {
734  try {
735  // format of the string is "nb=lf_nbgr,rf_ngbr-lf_ngbr,lc_ngbr-asn_from,rc_ngbr-asn_from"
736  // cf. CSnpContigAnnotApp::Run() which writes this value
737  string sExtra(field->GetData().GetStr());
738  vector<string> Ngbrs;
739  // LOG_POST(Trace << "==== Ngbrs: " << sExtra);
740  NStr::Split(sExtra, ",", Ngbrs);
741  if(Ngbrs.size() == 4 &&
742  NStr::StringToNumeric<int>(Ngbrs[3]) - NStr::StringToNumeric<int>(Ngbrs[2]) == 1) {
743  isInsertion = true;
744  }
745  }
746  catch (std::exception&) {
747  }
748  if(isInsertion) {
752  }
753  }
754  }
755  } else if(bf.GetVersion() == 20) {
756  switch(bf.GetVariationClass()) {
759  break;
762  break;
763  default:
764  break;
765  }
766  } else {
767  NCBI_ASSERT(true, "Unexpected SNP bitfield version!");
768  }
769 // LOG_POST(Trace << ">>>> BoxStyle: " << res);
770 // NcbiCerr << MSerial_AsnText << feat << endl;
771 // NcbiCerr << "bf version: " << bf.GetVersion() << ", variation class: " << bf.GetVariationClass() << ", BoxStyle: " << res << endl;
772  return res;
773 }
774 
775 
776 // check that the feature is a known SNP class, return a color that corresponds to it
777 // if not a SNP feature or class is unknown, returns a default color
779 {
781  string sColorKey("Default");
782 
783  switch(VariationClass)
784  {
786  sColorKey = "SingleBase";
787  break;
788  case CSnpBitfield::eDips:
789  sColorKey = "Dips";
790  break;
792  sColorKey = "Insertion";
793  break;
795  sColorKey = "Deletion";
796  break;
798  sColorKey = "Identity";
799  break;
801  sColorKey = "Inversion";
802  break;
804  sColorKey = "MultiBase";
805  break;
807  sColorKey = "Heterozygous";
808  break;
810  sColorKey = "Microsatellite";
811  break;
813  sColorKey = "NamedSNP";
814  break;
816  sColorKey = "NoVariation";
817  break;
819  sColorKey = "Mixed";
820  break;
822  default:
823  break;
824  }
826  CSGConfigUtils::GetColor(ColorView, sColorKey, color);
827  return color;
828 }
829 
830 
831 // create all future params based on the OrigParams
833 {
835 }
836 
838 {
839  return CRef<CSNPFeatureParams> (new CSNPFeatureParams(OrigParams));
840 }
841 
843 {
845  *m_ParamsTemplate = *OrigParams;
847 }
848 
850 {
852  CFeatureParams& param = const_cast<CFeatureParams&>(*iter->second);
854  }
855 }
856 
857 // get parameters for a given SNP feature, they are based on m_ParamsTemplate, but modified according to
858 // the feature contents
859 CConstRef<CFeatureParams> CSNPFeatureParams::GetFeatureParams(const objects::CSeq_feat& feat, const CRegistryReadView& ColorView) const
860 {
862  auto BoxStyle(s_GetBoxStyle(feat));
863  SSNPFeatParamDefiner ParamDefiner(VariationClass, BoxStyle);
864 
865  TParamsCache::iterator iParamsCache(m_ParamsCache.find(ParamDefiner));
866 
867  if(iParamsCache == m_ParamsCache.end()) {
868  CRef<CFeatureParams> feat_params(new CFeatureParams());
869  *feat_params = *m_ParamsTemplate;
870  feat_params->m_fgColor = CSNPColorPicker::GetSNPColor(feat, ColorView);
871  feat_params->m_BoxStyle = BoxStyle;
872 
873  m_ParamsCache[ParamDefiner] = feat_params;
874  return feat_params;
875  }
876  else
877  return iParamsCache->second;
878 }
879 
880 
881 
User-defined methods of the data storage class.
User-defined methods of the data storage class.
static const map< string, CAlignmentTrack::ELayout > sm_LayoutMap
static CBioSource dummy
#define true
Definition: bool.h:35
CAppJobNotification Notification send by CAppJobEventTranslator.
CCommentConfig – help config class for holding a set of settings for a comment glyph.
CRgbaColor m_LineColor
CGlTextureFont m_Font
CRgbaColor m_LabelColor
bool m_Centered
label is centered against the target.
bool m_ShowConnection
display a connection between the comment and target.
CCommentGlyph – utility class for having comments in graphical glyphs.
void SetConfig(CConstRef< CCommentConfig > config)
CDataTrack - a abstract base class for layout tracks which need to deal with background data retrieva...
Definition: data_track.hpp:55
virtual void Update(bool layout_only)
Update content and layout including the bounding box.
Definition: data_track.cpp:52
void SetConfig(CConstRef< CFeatureParams > conf)
const objects::CSeq_feat & GetFeature(void) const
Access the original feature.
CFeat_CI –.
Definition: feat_ci.hpp:64
CFeatureParams: the data structure holding feature rendering parameters.
EBoxStyle m_BoxStyle
CRgbaColor m_fgColor
CGlTextureFont m_LabelFont
ELabelPosition m_LabelPos
EBoxStyle
how the box of the feature is drawn
@ eBox_Insertion
additional decoration for the box
@ eBox_Deletion
add an inverted triangle to mark a deletion
@ ePos_NoLabel
no label
@ ePos_Side
always on 5' side
void Add(CSeqGlyph *obj)
Append a layout object to the end.
CRef< CInlineLayout > m_Inline
CRef< CLayeredLayout > m_Layered
void SetLayoutPolicy(ILayoutPolicy *policy)
Set policy on how to deploy the layout of its children.
CGraph_CI –.
Definition: graph_ci.hpp:234
static CGuiRegistry & GetInstance()
access the application-wide singleton
Definition: registry.cpp:400
void SetConfig(const CSeqGraphicConfig &config)
void x_DeregisterIcon(TIconID id)
deregister an icon if already registered.
void SetTitle(const string &label, const string &default_title=NcbiEmptyString)
@ eIcon_Layout
icon id for setting layout style
ILayoutTrackHost * m_LTHost
Top level host owning the tracks.
string m_Msg
special message need to show on title bar
string GetTitle() const
get the track title.
void x_OnLayoutChanged()
update the layout.
TTrackAttrFlags m_Attrs
various track attributes
virtual void x_OnIconClicked(TIconID id)
Mouse left-click event handler on an icon.
@ fNavigable
Track has navigation controls.
const string & GetProfile() const
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.
void x_RegisterIcon(const SIconInfo &icon)
register track icons.
CMappedFeat –.
Definition: mapped_feat.hpp:59
CMappedGraph –.
Definition: graph_ci.hpp:61
class CRegistryReadView provides a nested hierarchical view at a particular key.
Definition: reg_view.hpp:58
CRenderingContext offers the basic context and utility methods for rendering layout objects in featur...
const TSeqRange & GetVisSeqRange() const
const TModelUnit & GetScale() const
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
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 void ParseProfileString(const string &profile_str, TKeyValuePairs &settings)
static void GetColor(const CRegistryReadView &view, const string &key, CRgbaColor &color)
virtual bool AllJobsFinished() const
void SetJobListener(CEventHandler *listener)
Set JobDispatcher listener.
objects::CBioseq_Handle & GetBioseqHandle(void)
Get the underlying bioseq handle.
virtual void ClearJobID(TJobID job_id)
void SetDepth(int depth)
Set the annotation selector resolving depth.
virtual void DeleteAllJobs()
Remove waiting jobs from queue or cancel the unfinished jobs.
void SetAdaptive(bool flag)
void LoadData(const TSeqRange &range, CSnpJob::SParams &p, SSnpFilter *filter)
Definition: snp_ds.cpp:375
static void GetAnnotNames(SConstScopedObject &object, map< string, string > &annots, const TSeqRange &range, const ILayoutTrackFactory::SExtraParams &params)
Definition: snp_ds.cpp:349
static CRgbaColor GetSNPColor(const objects::CSeq_feat &feat, const CRegistryReadView &ColorView)
Definition: snp_track.cpp:778
CRef< CFeatureParams > SetParamsTemplate()
Definition: snp_track.hpp:274
CRef< CFeatureParams > m_ParamsTemplate
Definition: snp_track.hpp:289
CConstRef< CFeatureParams > GetFeatureParams(const objects::CSeq_feat &feat, const CRegistryReadView &ColorView) const
Definition: snp_track.cpp:859
static CRef< CSNPFeatureParams > CreateSNPFeatureParams()
Definition: snp_track.cpp:832
TParamsCache m_ParamsCache
Definition: snp_track.hpp:290
void Reset(CConstRef< CFeatureParams > OrigParams)
Definition: snp_track.cpp:842
class CSeqGlyph defines an interface that wraps a rectilinear abstract object.
Definition: seq_glyph.hpp:82
CRenderingContext * m_Context
the rendering context
Definition: seq_glyph.hpp:346
const CRenderingContext * GetRenderingContext() const
Get the rendering context.
Definition: seq_glyph.hpp:690
list< CRef< CSeqGlyph > > TObjects
Definition: seq_glyph.hpp:85
int GetObjectSpace() const
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
CSnpBitfield is a facade for representing any version of the SNP bitfield.
int GetWeight() const
int GetVersion() const
EVariationClass GetVariationClass() const
static string s_AdjustAnnotName(const string &sAnnotName)
! this is a temporary function for an interim period when SNP filters are taken from !...
Definition: snp_ds.cpp:99
virtual string GetExtensionIdentifier() const
returns the unique human-readable identifier for the extension the id should use lowercase letters se...
Definition: snp_track.cpp:618
virtual TTrackMap CreateTracks(SConstScopedObject &object, ISGDataSourceContext *ds_context, CRenderingContext *r_cntx, const SExtraParams &params=SExtraParams(), const TAnnotMetaDataList &src_annots=TAnnotMetaDataList()) const
CSnpTrackFactory.
Definition: snp_track.cpp:533
virtual const CTrackTypeInfo & GetThisTypeInfo() const
Definition: snp_track.hpp:200
virtual string GetExtensionLabel() const
returns a displayable label for this extension ( please capitalize the key words - "My Extension" )
Definition: snp_track.cpp:623
virtual void GetMatchedAnnots(const TAnnotMetaDataList &src_annots, const ILayoutTrackFactory::SExtraParams &params, TAnnotNameTitleMap &out_annots) const
Definition: snp_track.cpp:599
CRef< objects::CTrackConfigSet > GetSettings(const string &profile, const TKeyValuePairs &settings, const CTempTrackProxy *track_proxy) const
Definition: snp_track.cpp:629
CRef< objects::CTrackConfig > x_GetSettings(const TKeyValuePairs &settings, const CTempTrackProxy *track_proxy, bool is_clinvar_track) const
Definition: snp_track.cpp:645
static CTrackTypeInfo m_TypeInfo
Definition: snp_track.hpp:153
virtual void x_UpdateData()
update track content.
Definition: snp_track.cpp:319
void SetAnnot(const string &name)
Definition: snp_track.cpp:200
virtual const CTrackTypeInfo & GetTypeInfo() const
Definition: snp_track.cpp:185
virtual string GetFullTitle() const
get a more meaningful title.
Definition: snp_track.cpp:191
virtual bool CheckRange(TSeqRange range, string &sMsg, size_t &nFeats)
Definition: snp_track.cpp:401
objects::CFeat_CI x_GetFeat_CI(const TSeqRange &range)
Definition: snp_track.cpp:360
virtual void x_SaveSettings(const string &preset_style)
save the track settings to a profile string.
Definition: snp_track.cpp:263
string m_AnnotName
Definition: snp_track.hpp:143
CRef< CSNPFeatureParams > m_Params
Definition: snp_track.hpp:146
int m_eLayout
Definition: snp_track.hpp:142
string m_PreferredTitle
Definition: snp_track.hpp:151
virtual void x_LoadSettings(const string &preset_style, const TKeyValuePairs &settings)
load the track settings.
Definition: snp_track.cpp:276
CSnpTrack(CSGSnpDS *ds, CRenderingContext *r_cntx, const string &sFilter, const string &sTitle, const string &sLayout="")
Definition: snp_track.cpp:108
bool x_IsOverviewMode() const
Definition: snp_track.cpp:178
void GenerateAsn1(objects::CSeq_entry &seq_entry, TSeqRange range)
Definition: snp_track.cpp:370
SIconInfo m_IconLayout
Definition: snp_track.hpp:148
objects::CGraph_CI x_GetGraph_CI(const TSeqRange &range)
Definition: snp_track.cpp:365
void x_UpdateLayout()
Definition: snp_track.cpp:147
virtual void x_OnJobCompleted(CAppJobNotification &notify)
Definition: snp_track.cpp:422
CRef< CSGSnpDS > m_DS
Definition: snp_track.hpp:145
void x_ProcessJobResult()
Definition: snp_track.cpp:434
virtual void x_OnIconClicked(TIconID id)
Mouse left-click event handler on an icon.
Definition: snp_track.cpp:205
virtual ~CSnpTrack()
Definition: snp_track.cpp:140
@ eLayout_Features
Show features whenever possible.
Definition: snp_track.hpp:67
@ eLayout_Labels
Show labels and cascade features (CLayeredLayoutPolicy)
Definition: snp_track.hpp:68
@ eLayout_Density
Always show density.
Definition: snp_track.hpp:66
@ eLayout_Adaptive
All SNPs drawn in one line.
Definition: snp_track.hpp:65
CRef< SSnpFilter > m_Filter
Definition: snp_track.hpp:150
void x_AddSnpsLayout(const SSnpJobResult &result)
Definition: snp_track.cpp:477
CRef< SSnpJobResult > m_JobResult
Definition: snp_track.hpp:149
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 & GetSource() 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::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
CConstRef< CUser_field > GetFieldRef(const string &str, const string &delim=".", NStr::ECase use_case=NStr::eCase) const
Definition: User_object.cpp:84
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.
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.
const_iterator end() const
Definition: map.hpp:152
iterator_bool insert(const value_type &val)
Definition: map.hpp:165
bool empty() const
Definition: map.hpp:149
void clear()
Definition: map.hpp:169
const_iterator find(const key_type &key) const
Definition: map.hpp:153
static CMemoryRegistry registry
Definition: cn3d_tools.cpp:81
struct config config
#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 NCBI_ASSERT(expr, mess)
Definition: ncbidbg.hpp:130
#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
#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
void Warning(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1191
static bool IsExtendedNAA(const string &annot, bool isStrict=false)
check if a given annotation is an extended NAA (named accession[.version][number],...
Definition: utils.cpp:850
GLdouble TModelUnit
Definition: gltypes.hpp:48
void SetFontFace(EFontFace face, bool use_bitmap_overrides=true)
void SetFontSize(unsigned int size)
Set/get font size in points.
CGlPoint< TModelUnit > TModelPoint
Definition: gltypes.hpp:51
void Set(float r, float g, float b)
set the color from an Fl_Color
Definition: rgba_color.cpp:226
CRef< CObject > GetResult() const
returns non-null pointer only if Completed or Running and has temporary results available
static size_t EstimateSNPCount(const TSeqRange &range, const string &sAnnotName, CBioseq_Handle &Handle)
Definition: snp_gui.cpp:139
static CGraph_CI GetGraph_CI(const TSeqRange &range, const string &sAnnotName, CBioseq_Handle &Handle)
Definition: snp_gui.cpp:61
static CFeat_CI GetFeat_CI(const TSeqRange &range, const string &sAnnotName, CBioseq_Handle &Handle)
Definition: snp_gui.cpp:114
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
const CSeq_graph & GetMappedGraph(void) const
Graph mapped to the master sequence.
Definition: graph_ci.hpp:100
const CSeq_feat & GetMappedFeature(void) const
Feature mapped to the master sequence.
bool NotNull(void) const THROWS_NONE
Check if pointer is not null – same effect as NotEmpty().
Definition: ncbiobj.hpp:744
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:998
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static bool StringToBool(const CTempString str)
Convert string to bool.
Definition: ncbistr.cpp:2819
#define kEmptyStr
Definition: ncbistr.hpp:123
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:3457
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:2989
#define NPOS
Definition: ncbistr.hpp:133
static string UIntToString(unsigned int value, TNumToStringFlags flags=0, int base=10)
Convert UInt to string.
Definition: ncbistr.hpp:5108
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:5352
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
Definition: ncbistr.hpp:673
const TStr & GetStr(void) const
Get the variant data.
const TData & GetData(void) const
Get the Data member data.
Tdata & Set(void)
Assign a value to data member.
bool IsSetExt(void) const
user defined structure extension Check if a value has been assigned to Ext data member.
Definition: Seq_feat_.hpp:1207
const TExt & GetExt(void) const
Get the Ext member data.
Definition: Seq_feat_.hpp:1219
void SetData(TData &value)
Assign a value to Data data member.
Definition: Seq_annot_.cpp:244
list< CRef< CSeq_graph > > TGraph
Definition: Seq_annot_.hpp:195
list< CRef< CSeq_feat > > TFtable
Definition: Seq_annot_.hpp:193
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
n background color
int i
#define wxT(x)
Definition: muParser.cpp:41
range(_Ty, _Ty) -> range< _Ty >
const struct ncbi::grid::netcache::search::fields::SIZE size
static const TLayoutStr s_LayoutStrs[]
Definition: snp_track.cpp:72
USING_SCOPE(objects)
CStaticArrayMap< string, CSnpTrack::ELayout > TLayoutMap
Definition: snp_track.cpp:79
const string & s_LayoutValueToStr(CSnpTrack::ELayout layout)
Definition: snp_track.cpp:98
static CFeatureParams::EBoxStyle s_GetBoxStyle(const CSeq_feat &feat)
Definition: snp_track.cpp:719
static const string kDefProfile
Definition: snp_track.cpp:83
static CSnpBitfield::EVariationClass s_GetVariationClass(const CSeq_feat &feat)
Definition: snp_track.cpp:712
DEFINE_STATIC_ARRAY_MAP(TLayoutMap, sm_LayoutMap, s_LayoutStrs)
static CSnpTrack::ELayout s_LayoutStrToValue(const string &layout)
Definition: snp_track.cpp:88
SStaticPair< const char *, CSnpTrack::ELayout > TLayoutStr
CSnpTrack.
Definition: snp_track.cpp:71
static const string kBaseKey
Definition: snp_track.cpp:82
TIconID m_Id
must be unique within the context
bool bPreferFeat
Return feat glyphs instead of histogram glyphs.
Definition: snp_ds.hpp:87
TModelUnit scale
Definition: snp_ds.hpp:90
bool bAdaptive
Only return feat glyphs when not overview.
Definition: snp_ds.hpp:86
string sAnnotName
Definition: snp_ds.hpp:93
CRenderingContext * r_cntx
Definition: snp_ds.hpp:92
extra parameter for initializing a track.
bool m_Adaptive
Adaptive/Exact selector.
TAnnots m_Annots
particular annotations the track will be looking at.
string m_Filter
potential track-specific filter.
int m_Level
layout level that limits feature retrieving used by annotation selector.
string m_TrackProfile
Track setting profile for additionial parameters.
bool m_SkipGenuineCheck
Flag indicating if track verification is required.
TAnnotNameTitleMap m_AnnotNameTitleMap
map of known correspondencies between annots and full titles
string name
Definition: snp_filter.hpp:48
SSnpJobResult.
Definition: snp_ds.hpp:66
@ eHistFromGraphs
Definition: snp_ds.hpp:68
@ eHistFromFeats
Definition: snp_ds.hpp:69
EDataType eDataType
Definition: snp_ds.hpp:75
CSeqGlyph::TObjects listObjs
Definition: snp_ds.hpp:76
Template structure SStaticPair is simlified replacement of STL pair<> Main reason of introducing this...
Definition: static_set.hpp:60
else result
Definition: token2.c:20
#define ftable
Definition: utilfeat.h:37
void UseDefaultMarginWidth(wxMenu &menu)
Using default menu item margin width.
Definition: wx_utils.cpp:693
Modified on Sat Dec 09 04:49:23 2023 by modify_doxy.py rev. 669887