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

Go to the SVN repository for this file.

1 /* $Id: feature_ds.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
27  *
28  */
29 #include <ncbi_pch.hpp>
30 
49 
52 
53 #include <objmgr/util/feature.hpp>
54 #include <objmgr/util/sequence.hpp>
58 
59 // for gene_by_loc reply
63 
65 
66 #include <serial/serial.hpp>
67 #include <connect/ncbi_types.h>
69 #include <serial/objistr.hpp>
70 
73 
74 // the maximal number of objects allowed to show without smearing
75 static const int kMaxObjNum = 250000;
76 
77 // the maximal number of children in parent/child situations dictated by approximation of screen size limits
78 static const size_t kMaxChildNum = 500;
79 // the zoom level that allows to show sequence
80 static const float kSeqZoomLevel = 0.125;
81 // unique group for 'unsorted' (no sorting is needed) features
82 static const char* kUnsortedGroupName = "--unsorted--";
83 
84 // create feature product mapping if scale (m_Window) is less than this value
85 static const float kMinScaleForMapping = 16.;
86 
87 
88 ///////////////////////////////////////////////////////////////////////////////
89 /// CSGFeatureJob: a job class for loading annotated features from a given
90 /// sequence and visible range.
91 ///////////////////////////////////////////////////////////////////////////////
92 class CSGFeatureJob : public CSGAnnotJob
93 {
94 public:
95  typedef pair<string, CLinkedFeature::TLinkedFeats> TSortedFeats;
96  typedef vector<TSortedFeats> TFeatGroups;
98 
100  {
101  float score;
103  };
104 
105  CSGFeatureJob(const string& desc, CBioseq_Handle handle,
106  const SAnnotSelector& sel, const TSeqRange& range,
107  TModelUnit window, TJobToken token);
108 
109  CSGFeatureJob(const string& desc, CBioseq_Handle handle,
110  const SAnnotSelector& sel, const TSeqRange& range,
111  TModelUnit window, int max_feat, ELinkedFeatDisplay LinkedFeatDisplay,
112  TJobToken token, ICoordMapper* mapper = NULL);
113 
114  void SetFilter(const string& filter)
115  { m_Filter = filter; }
116 
117  void SetSortBy(const string& sortby);
118 
119  void SetBigBedCacheKey(const string& cache_key)
120  {
121  m_BigBedCacheKey = cache_key;
122  }
123 
124  void SetVcfCacheKey(const string& cache_key)
125  {
126  m_VcfCacheKey = cache_key;
127  }
128 
129 
130  static void GetAnnotNames(const CBioseq_Handle& handle,
132 
133  static void GetAnnotNames_var(const CBioseq_Handle& handle,
135 
136 
137 protected:
138  virtual EJobState x_Execute();
139 
140  /// @name feature glyph creators.
141  /// Using different function names to get by hide-by-name semantics.
142  /// Maybe should consider using 'using scope' directive in the
143  /// derived class.
144  /// @{
145  /// shared creator.
147  CSeqGlyph* parent_glyph = NULL,
148  const char* label_prefix = NULL);
149 
150  /// overridable creator.
152  const CMappedFeat& feat, const CSeq_loc& loc,
153  const char* label_prefix = NULL);
154  /// @}
155 
157  const CSeq_loc& loc);
158 
161 
163  CSeqGlyph::TObjects& objs);
164 
165  void x_CalcIntervals(CFeatGlyph& feat);
166 
168  CSGJobResult* result, const string& title);
169 
171  CSGJobResult* result, const string& title);
172 
174  int level, const string& title);
175 
177  CSGJobResult* result, const string& title);
178 
181  CFeatureFilter& filter);
182 
184  TFeatGroups& feat_groups);
185 
187  TFeatGroupMap& group_map);
188 
192 
193  bool x_ProcessCachedBigBed();
195 
196 
197 protected:
198  TModelUnit m_Window; ///< current window for smear bars
199  /// the maximum number of features allowed.
200  /// -2: pack all features into one smear line
201  /// -1: theoretically unlimited, practically there is one (kMaxObjNum)
202  /// -0: pack all features into a histogram
203  /// >0: any limit set from a user
205 
206  /// controls creation of parent or child features
208 
209  string m_Filter;
211 
213 
216 
217 };
218 
219 
220 ///////////////////////////////////////////////////////////////////////////////
221 /// CGeneModelFeatJob: a job class for loading annotated main features,
222 /// including genes, RNAs, CDSs and exons from a given sequence and a given
223 /// visible range.
224 ///////////////////////////////////////////////////////////////////////////////
226 {
227 public:
230  eFilter_dbref_all = 0, ///< any dbref
231  eFilter_dbref, ///< one specific dbref
232  eFilter_CCDS, ///< genes with Consensus CDS
236  };
237 
238  typedef int TFilterType;
239 
240  CGeneModelFeatJob(const string& desc,
241  CBioseq_Handle handle,
242  const SAnnotSelector& lm_feat_sel,
243  const SAnnotSelector& m_feat_sel,
244  TJobToken lm_token, TJobToken main_token,
245  bool landmark_feat,
246  const TSeqRange& range, TModelUnit window,
247  const CGeneModelConfig& conf,
248  ICoordMapper* mapper);
249 
250  static vector<string> GetFilters(const CBioseq_Handle& handle,
251  const TSeqRange& range, SAnnotSelector& sel, const string& filter);
252 
253 protected:
254  virtual EJobState x_Execute();
255 
257  const CMappedFeat& feat, const CSeq_loc& loc,
258  const char* label_prefix = NULL);
259 
260 private:
262  CRef<CSeqGlyph>& hist_obj, CSeqGlyph::TObjects& comment_objs);
263 
264  /// Link features into a hierarchical list. This function will transform a
265  /// linear, feature-order-sorted list of CLayoutFeat objects into a
266  /// hierarchically arranged list in which genes are linked to mRNAs, mRNAs
267  /// to CDSs, etc.
269 
270  /// create features when there is a filter set up.
272 
273  /// Check if transcript passes Config filters
274  bool x_IsTranscriptAcceptable(const CLinkedFeature& feat);
275 
276  static TFilterType x_FilterStrToValue(const string& filter);
277 
278  static bool x_IsDbref(const string& db, const CSeq_feat& feat)
279  {
280  if (feat.IsSetDbxref()) {
281  ITERATE (CSeq_feat::TDbxref, iter, feat.GetDbxref()) {
282  if (NStr::EqualNocase(db, (*iter)->GetDb())) {
283  return true;
284  }
285  }
286  }
287  return false;
288  }
289 
290  static bool x_IsDbref(const string& db, const CLinkedFeature& linked_feat) {
291  const CSeq_feat& feat = linked_feat.GetFeature();
292  if (x_IsDbref(db, feat)) {
293  return true;
294  }
295 
296  ITERATE (CLinkedFeature::TLinkedFeats, iter, linked_feat.GetChildren()) {
297  if (x_IsDbref(db, **iter)) {
298  return true;
299  }
300  }
301 
302  return false;
303  }
304 
305  static bool x_IsCCDS(const CLinkedFeature& linked_feat) {
306  const CSeq_feat& feat = linked_feat.GetFeature();
307  if (feat.GetData().IsGene()) {
308  ITERATE (CLinkedFeature::TLinkedFeats, iter, linked_feat.GetChildren()) {
309  const CSeq_feat& c_feat = (*iter)->GetFeature();
310  if (c_feat.GetData().IsRna()) {
311  ITERATE (CLinkedFeature::TLinkedFeats, c_iter, (*iter)->GetChildren()) {
312  if (x_IsDbref("CCDS", (*c_iter)->GetFeature())) {
313  return true;
314  }
315  }
316  } else if (c_feat.GetData().IsCdregion()) {
317  if (x_IsDbref("CCDS", c_feat)) {
318  return true;
319  }
320  }
321  }
322  }
323  return false;
324  }
325 
326  static bool x_IsPseudoGene(const CSeq_feat& feat)
327  {
328  return (feat.IsSetPseudo() && feat.GetPseudo());
329  }
330 
331  static bool x_IsncRNA(const CLinkedFeature& linked_feat) {
332  const CSeq_feat& feat = linked_feat.GetFeature();
333  bool has_rna = false;
334  bool has_cds = false;
335  if (feat.GetData().IsGene()) {
336  ITERATE (CLinkedFeature::TLinkedFeats, iter, linked_feat.GetChildren()) {
337  const CSeq_feat& c_feat = (*iter)->GetFeature();
338  if (c_feat.GetData().IsRna()) {
339  has_rna = true;
340  if (!(*iter)->GetChildren().empty()) {
341  has_cds = true;
342  }
343  }
344  }
345  } else if (feat.GetData().IsRna()) {
346  has_rna = true;
347  if (!linked_feat.GetChildren().empty()) {
348  has_cds = true;
349  }
350  }
351  return has_rna && !has_cds;
352  }
353 
354  static bool x_IsnpcGene(const CLinkedFeature& linked_feat) {
355  const CSeq_feat& feat = linked_feat.GetFeature();
356  if (feat.GetData().IsGene()) {
357  ITERATE (CLinkedFeature::TLinkedFeats, iter, linked_feat.GetChildren()) {
358  const CSeq_feat& c_feat = (*iter)->GetFeature();
359  if ( (c_feat.GetData().IsRna() && !(*iter)->GetChildren().empty()) ||
360  c_feat.GetData().IsCdregion()) {
361  return false;
362  }
363  }
364  }
365  return true;
366  }
367 
368 private:
369  SAnnotSelector m_MainFeatSel; ///< annotation selector for all main features.
370  TJobToken m_MainFeatToken; ///< Job token for loading main features.
371  bool m_LandmarkFeats; ///< is overview mode?
373 };
374 
375 
376 ///////////////////////////////////////////////////////////////////////////////
377 /// CBatchFeatJob: a job class for loading annotated features from a given
378 /// a set of sequences within the corresponding visible ranges.
379 ///////////////////////////////////////////////////////////////////////////////
381 {
382 public:
383  CBatchFeatJob(const string& desc, CBioseq_Handle handle,
384  const TSeqRange& range, TModelUnit window, TJobToken token,
385  const TFeatBatchJobRequests& requests);
386 
387 protected:
388  virtual EJobState x_Execute();
389 
390 private:
392  const SAnnotSelector& sel);
393 
394 private:
396 };
397 
398 
399 ///////////////////////////////////////////////////////////////////////////////
400 /// CSGCalcFeatHistJob
401 ///////////////////////////////////////////////////////////////////////////////
403 {
404 public:
405  CSGCalcFeatHistJob(const string& desc, const CSeqGlyph::TObjects& objs,
406  const TSeqRange& range, TModelUnit window, TJobToken token)
407  : CSeqGraphicJob(desc)
408  , m_Objects(objs)
409  , m_Range(range)
410  , m_Window(window)
411  {
412  SetToken(token);
413  }
414 
415 protected:
416  virtual EJobState x_Execute();
417 
418 private:
420  CDensityMap<float>& the_map);
421 
422 private:
424  TSeqRange m_Range; ///< target range
425  TModelUnit m_Window; ///< current window for smear bars
426 };
427 
428 
429 ///////////////////////////////////////////////////////////////////////////////
430 /// CSGFeatureDS
431 ///////////////////////////////////////////////////////////////////////////////
433  : CSGGenBankDS(scope, id)
434 {}
435 
437  const TSeqRange& range, TModelUnit window,
438  TJobToken token, int max_feat,
439  ELinkedFeatDisplay LinkedFeat,
440  const string& extra_filter)
441 {
444  new CSGFeatureJob("Feature", m_Handle, sel, range, window,
445  max_feat, LinkedFeat,
446  token, m_Mapper));
447  job->SetGraphLevel(CGraphUtils::GetNearestLevel(m_GraphLevels, window));
448  string filter = m_Filter;
449  if (!extra_filter.empty()) {
450  if (!filter.empty()) filter += " and ";
451  filter += extra_filter;
452  }
453  job->SetFilter(filter);
454  job->SetSortBy(m_SortBy);
455  if (IsBigBed())
456  job->SetBigBedCacheKey(m_GraphCacheKey);
457  else if (IsVcfTabix())
458  job->SetVcfCacheKey(m_GraphCacheKey);
459  x_LaunchJob(*job);
460 }
461 
462 
464  TModelUnit window,
465  TJobToken token,
466  const TFeatBatchJobRequests& requests)
467 {
468  //CSeqUtils::SetResolveDepth(sel, m_Adaptive, m_Depth);
470  "Feature", m_Handle, range, window, token, requests));
471  job->SetGraphLevel(CGraphUtils::GetNearestLevel(m_GraphLevels, window));
472  if (IsBigBed())
473  job->SetBigBedCacheKey(m_GraphCacheKey);
474  else if (IsVcfTabix())
475  job->SetVcfCacheKey(m_GraphCacheKey);
476 
477  // no progress report
478  x_LaunchJob(*job, -1);
479 }
480 
481 
483  SAnnotSelector& lm_feat_sel,
484  SAnnotSelector& m_feat_sel,
485  TJobToken lm_token, TJobToken main_token,
486  bool landmark_feat, const TSeqRange& range, TModelUnit window,
487  const CRef<CGeneModelConfig>& conf)
488 {
492  "Feature", m_Handle, lm_feat_sel, m_feat_sel, lm_token,
493  main_token, landmark_feat, range, window,
494  *conf, m_Mapper));
495  job->SetFilter(m_Filter);
496  job->SetSortBy(m_SortBy);
497  x_LaunchJob(*job);
498 }
499 
500 
501 
503  const TSeqRange& range,
504  TModelUnit window, TJobToken token)
505 {
507  "Calculate feature histogram", objs,
508  range, window, token));
509  x_LaunchJob(*job);
510 }
511 
512 
514  const TSeqRange& range,
515  TAnnotNameTitleMap& names) const
516 {
519 }
520 
521 
523  const TSeqRange& range,
524  TAnnotNameTitleMap& names) const
525 {
528 }
529 
530 
531 vector<string> CSGFeatureDS::GetFilters(const string& annot_name,
532  const TSeqRange& range) const
533 {
535  CSeqUtils::SetAnnot(sel, annot_name);
537 }
538 
539 
540 ///////////////////////////////////////////////////////////////////////////////
541 /// CSGFeatureDSType
542 ///////////////////////////////////////////////////////////////////////////////
543 
546 {
547  const CSeq_id& id = dynamic_cast<const CSeq_id&>(object.object.GetObject());
548 // cerr << "Creating DS for seq-id" << endl <<
549 // MSerial_AsnText << id << endl;
550  return new CSGFeatureDS(object.scope.GetObject(), id);
551 }
552 
553 
555 {
556  static string sid("seqgraphic_feature_ds_type");
557  return sid;
558 }
559 
560 
562 {
563  static string slabel("Graphical View Feature Data Source Type");
564  return slabel;
565 }
566 
567 
569 {
570  return false;
571 }
572 
573 //
574 //void CFeatFilter::x_AddToList(const string& type, bool shown)
575 //{
576 // TFeatTypeIdx idx = CCustomFeatureColor::eDefault;
577 // if (type == "cnv") {
578 // idx = CCustomFeatureColor::eCNV;
579 // } else if (type == "other") {
580 // idx = CCustomFeatureColor::eOther;
581 // } else if (type == "inversion") {
582 // idx = CCustomFeatureColor::eInversion;
583 // } else if (type == "loss") {
584 // idx = CCustomFeatureColor::eLoss;
585 // } else if (type == "gain") {
586 // idx = CCustomFeatureColor::eGain;
587 // } else if (type == "insertion") {
588 // idx = CCustomFeatureColor::eInsertion;
589 // } else if (type == "complex") {
590 // idx = CCustomFeatureColor::eComplex;
591 // } else if (type == "unknown") {
592 // idx = CCustomFeatureColor::eUnknown;
593 // } else if (type == "loh") {
594 // idx = CCustomFeatureColor::eLOH;
595 // } else if (type == "everted") {
596 // idx = CCustomFeatureColor::eEverted;
597 // } else if (type == "translocation") {
598 // idx = CCustomFeatureColor::eTranschr;
599 // } else if (type == "upd") {
600 // idx = CCustomFeatureColor::eUPD;
601 // }
602 // if (idx != CCustomFeatureColor::eDefault) {
603 // if (shown) {
604 // m_ShowList.insert(idx);
605 // m_HideList.clear();
606 // } else {
607 // m_HideList.insert(idx);
608 // m_ShowList.clear();
609 // }
610 // }
611 //}
612 
613 
614 ///////////////////////////////////////////////////////////////////////////////
615 /// CSGFeatureJob implementation
616 ///////////////////////////////////////////////////////////////////////////////
618 {
620  const CSGFeatureJob::SLandmarkFeat& f2) const
621  {
622  return f1.score > f2.score;
623  }
624 };
625 
627 {
629  const CSGFeatureJob::SLandmarkFeat& f2) const
630  {
631  return f1.obj->LessBySeqPos(*f2.obj);
632  }
633 };
634 
635 
636 CSGFeatureJob::CSGFeatureJob(const string& desc, CBioseq_Handle handle,
637  const SAnnotSelector& sel,
638  const TSeqRange& range, TModelUnit window,
639  TJobToken token)
640  : CSGAnnotJob(desc, handle, sel, range)
641  , m_Window(window)
642  , m_FeatLimit(-1)
643  , m_LinkedFeat(ELinkedFeatDisplay::eLFD_Default)
644 {
645  SetToken(token);
646 }
647 
648 
649 CSGFeatureJob::CSGFeatureJob(const string& desc, CBioseq_Handle handle,
650  const SAnnotSelector& sel,
651  const TSeqRange& range, TModelUnit window,
652  int max_feat, ELinkedFeatDisplay LinkedFeatDisplay,
653  TJobToken token, ICoordMapper* mapper)
654  : CSGAnnotJob(desc, handle, sel, range)
655  , m_Window(window)
656  , m_FeatLimit(max_feat)
657  , m_LinkedFeat(LinkedFeatDisplay)
658  , m_Mapper(mapper)
659 {
660  SetToken(token);
661 }
662 
663 
664 void CSGFeatureJob::SetSortBy(const string& sortby)
665 {
666  if (sortby.empty()) {
667  m_Sorter.Reset(nullptr);
668  return;
669  }
670 
671  size_t found = sortby.find_first_of('|');
672  string sorter_type = NStr::TruncateSpaces(sortby.substr(0, found));
673  string sort_str = kEmptyStr;
674  if (found != string::npos) {
675  sort_str = sortby.substr(found + 1);
676  }
678  m_Sorter.Reset(new CCloneConcordancySorter(sort_str));
679  } else if (NStr::EqualNocase(sorter_type, CDbvarQualitySorter::GetID())) {
680  m_Sorter.Reset(new CDbvarQualitySorter(sort_str));
681  } else if (NStr::EqualNocase(sorter_type, CDbvarPilotSorter::GetID())) {
682  m_Sorter.Reset(new CDbvarPilotSorter(sort_str));
683  } else if (NStr::EqualNocase(sorter_type, CDbvarClinicalAsstSorter::GetID())) {
684  m_Sorter.Reset(new CDbvarClinicalAsstSorter(sort_str));
685  } else if (NStr::EqualNocase(sorter_type, CDbvarSamplesetTypeSorter::GetID())) {
687  } else if (NStr::EqualNocase(sorter_type, CDbvarValidationSorter::GetID())) {
688  m_Sorter.Reset(new CDbvarValidationSorter(sort_str));
689  } else if (NStr::EqualNocase(sorter_type, CGRCStatusSorter::GetID())) {
690  m_Sorter.Reset(new CGRCStatusSorter(sort_str));
691  } else if (NStr::EqualNocase(sorter_type, CFeatStrandSorter::GetID())) {
692  m_Sorter.Reset(new CFeatStrandSorter(sort_str));
693  }
694 }
695 
696 
698  const TSeqRange& range,
699  SAnnotSelector& sel,
701 {
702  sel.SetCollectNames();
703  CFeat_CI feat_iter(handle, range, sel);
704  ITERATE (CFeat_CI::TAnnotNames, iter, feat_iter.GetAnnotNames()) {
705  if (iter->IsNamed()) {
706  if (iter->GetName().find("@@") == string::npos) {
707  names.insert(TAnnotNameTitleMap::value_type(iter->GetName(), ""));
708  }
709  } else {
711  }
712  }
713 }
714 
715 
717  const TSeqRange& range,
718  SAnnotSelector& sel,
720 {
721  sel.SetCollectNames();
722  CFeat_CI feat_iter(handle, range, sel);
723  ITERATE (CFeat_CI::TAnnotNames, iter, feat_iter.GetAnnotNames()) {
724  if (iter->IsNamed()) {
725  if (iter->GetName().find("@@") == string::npos) {
726  names.insert(TAnnotNameTitleMap::value_type(iter->GetName(), ""));
727  }
728  } else {
730  }
731  }
732  /// TODO: look at the real feature for each annotaton to verify
733  /// it is really structural variants, not SNP.
734 }
735 
737 {
738 
739  features.clear();
740  for ( ; feature_iter; ++feature_iter) {
741  if (IsCanceled()) return;
742  const CMappedFeat& feat = *feature_iter;
743  features.emplace_back(new CLinkedFeature(feat));
744  }
745  // filtering features
746  if (!m_Filter.empty()) {
747  CFeatureFilter filter;
748  filter.Init(m_Filter);
749  if (filter.NeedFiltering()) {
750  if (IsCanceled()) return;
752  }
753  }
754 }
755 
757 {
759  x_GetLinkedFeatures(feature_iter, features);
760  return x_LinkFeatures(features, objs);
761  }
762 
763 
764 
766 {
767  SetTaskName("Linking features...");
768  // linking features
769  if ( !CSeqUtils::LinkFeatures(features, feature::CFeatTree::eFeatId_always, this) ) {
770  return eCanceled;
771  }
772  TFeatGroups feat_groups;
773  x_SortFeatures(features, feat_groups);
774  SetTaskName("Creating feature glyphs...");
775  SetTaskCompleted(0);
776 
777  NON_CONST_ITERATE (TFeatGroups, grp_iter, feat_groups) {
778  if (IsCanceled()) {
779  return eCanceled;
780  }
781  CLinkedFeature::TLinkedFeats& curr_feats = grp_iter->second;
782  NON_CONST_ITERATE (CLinkedFeature::TLinkedFeats, iter, curr_feats) {
783  if(m_LinkedFeat == ELinkedFeatDisplay::eLFD_Hidden && !(*iter)->GetChildren().empty() ) {
784  (*iter)->GetChildren().clear();
785  }
786  }
788 
789  EJobState state = x_CreateFeature_Recursive(curr_feats, group.GetPointer(), 0);
790  if (state != eCompleted) {
791  return state;
792  }
793 
794  if (curr_feats.size() == group->GetChildrenNum()) {
795  // For most cases, we don't need the group container
796  // added earlier. Instead, take the children only.
797  if (grp_iter->first == kUnsortedGroupName) {
798  // Sorting features is not needed in this case.
799  // That means there should be only one group.
800  _ASSERT(feat_groups.size() == 1);
801  objs.swap(group->SetChildren());
802  } else {
803  // created a group with a title
804  CRef<CNamedGroup> named_group((new CNamedGroup(grp_iter->first)));
805  named_group->Set(group->SetChildren());
806  objs.emplace_back(named_group.GetPointer());
807  }
808  } else {
809  // There is one case we need to group the features:
810  // When all the features are linked together as one
811  // feature group with parent and child relationship.
812  // After x_CreateFeature_Recursive step, the parent
813  // feature and child feature(s) are put in one group
814  // which is this group container. We need it to hold
815  // them as a linked group.
816  if (grp_iter->first == kUnsortedGroupName) {
817  // Sorting features is not needed in this case.
818  // That means there should be only one group.
819  _ASSERT(feat_groups.size() == 1);
820  objs.emplace_back(group.GetPointer());
821  } else {
822  // created a group with a title
823  CRef<CNamedGroup> named_group((new CNamedGroup(grp_iter->first)));
824  named_group->PushBack(group);
825  objs.emplace_back(named_group.GetPointer());
826  }
827  }
828  }
829 
830  return eCompleted;
831 }
832 
833 
835 {
836  _ASSERT(m_Result);
837  if (!m_Result)
838  return false;
839  auto result = dynamic_cast<CSGJobResult*>(m_Result.GetPointer());
840  if (!result)
841  return false;
843  if (!data)
844  return false;
846  m_Range.GetTo(),
847  (float)m_Window,
849  data->GetData(the_map);
850 
852  annots = m_Sel.GetIncludedAnnotsNames();
853  for(const auto& annot : annots) {
854  if(annot.IsNamed()) {
855  result->m_Desc = annot.GetName();
856  break;
857  }
858  }
859  CRef<CHistogramGlyph> histogram(new CHistogramGlyph(the_map, result->m_Desc));
860  result->m_ExtraObj.Reset(histogram.GetPointer());
861  SetTaskCompleted(1);
862  return true;
863 }
864 
866 {
867  _ASSERT(m_Result);
868  if (!m_Result)
869  return false;
870  auto result = dynamic_cast<CSGJobResult*>(m_Result.GetPointer());
871  if (!result)
872  return false;
874  if (!data)
875  return false;
876  vector<TSeqRange> ranges;
877  data->GetData(m_Range, ranges);
879  m_Range.GetTo(),
880  (float)m_Window,
882  for (const auto& r : ranges) {
883  the_map.AddRange(r, 1);
884  }
885 
887  annots = m_Sel.GetIncludedAnnotsNames();
888  for(const auto& annot : annots) {
889  if(annot.IsNamed()) {
890  result->m_Desc = annot.GetName();
891  break;
892  }
893  }
894  CRef<CHistogramGlyph> histogram(new CHistogramGlyph(the_map, result->m_Desc));
895  result->m_ExtraObj.Reset(histogram.GetPointer());
896  SetTaskCompleted(1);
897  return true;
898 }
899 
900 
902 {
905 
907  m_Handle.GetRangeSeq_loc(m_Range.GetFrom(), m_Range.GetTo()) );
908 
909  SetTaskName("Loading features...");
910  SetTaskTotal(0);
911  SetTaskCompleted(0);
912 
913  try {
914  bool glyph_created = false;
915  if (!m_BigBedCacheKey.empty())
916  glyph_created = x_ProcessCachedBigBed();
917  else if (!m_VcfCacheKey.empty())
918  glyph_created = x_ProcessCachedVcfTabix();
919 
920  if (!glyph_created) {
921  bool has_coverage_graph = GetGraphLevel() > 0;
922  if (m_FeatLimit == 0 && has_coverage_graph) {
923  // use coverage graph instead to inprove performance
925  if (state != eCompleted)
926  return state;
927  } else {
928  CFeat_CI feature_iter(m_Handle.GetScope(), *loc, m_Sel);
929  int size = (int)feature_iter.GetSize();
931  if (feature_iter) {
932  // Get a more meaningful name
933  result->m_Desc = CSeqUtils::GetAnnotName(feature_iter->GetAnnot());
934  }
935 
936  // use the real feature limit
937  if (m_FeatLimit > 0) {
938  // we may want to adjust feature limit based on the
939  // actual screen size (in pixels) for this case
940  int new_limit = (int)(m_FeatLimit * m_Range.GetLength() / (1024 * m_Window));
941  //ERR_POST(Error << "FL adjusted from " << m_FeatLimit << " to " << new_limit << ",w:" << m_Window << ",r:" << m_Range.GetLength());
942  m_FeatLimit = max(m_FeatLimit, new_limit);
943  } else if (m_FeatLimit == -1) {
944  // unlimited, but still set a upper limit to guard against problem.
946  }
947 
948  // based on different limit settings to create different glyphs
949  if (m_FeatLimit == -2) {
950  // pack features into one line
951  SetTaskName("Packing features...");
952  EJobState state = x_CreateFeatSmear(feature_iter, result, result->m_Desc);
953  if (state != eCompleted)
954  return state;
955  } else if (m_FeatLimit >= 0) {
957  // in adaptive mode (m_FeatLimit != 0) and if number of feature is relatively small
958  // return both hstogram and feat glyphs and let feature track decide what to show
959  // based on the height of resulting track
961  if (m_FeatLimit != 0) {
962  if (size < m_FeatLimit || !m_Filter.empty()) {
963  x_GetLinkedFeatures(feature_iter, features);
964  size = static_cast<int>(features.size());
965  }
966  if (size < m_FeatLimit) { //m_FeatLimit == 0 is packed mode
967  CSeqGlyph::TObjects objs;
968  auto state = x_LinkFeatures(features, objs);
969  if (state != eCompleted)
970  return state;
971  result->m_ObjectList.swap(objs);
972  }
973  }
974  if (size > 0) {
975  // pack features into a histogram
976  if (has_coverage_graph) {
978  } else {
979  if (feature_iter)
980  state = x_CreateFeatHist(feature_iter, result, result->m_Desc);
981  else
983  }
984  } else {
985  state = eCompleted;
986  }
987  if (state != eCompleted)
988  return state;
989 
990  } else {
991  CSeqGlyph::TObjects objs;
992  auto state = x_LinkFeatures(feature_iter, objs);
993  if (state != eCompleted)
994  return state;
995  result->m_ObjectList.swap(objs);
996  }
998  }
999  }
1000  } catch (CException& ex) {
1001  m_Error.Reset(new CAppJobError(ex.GetMsg()));
1002  return eFailed;
1003  } catch (std::exception& ex) {
1004  m_Error.Reset(new CAppJobError(ex.what()));
1005  return eFailed;
1006  }
1007 
1008  result->m_Token = m_Token;
1009  return eCompleted;
1010 }
1011 
1012 
1015  CFeatureFilter& filter)
1016 {
1017  bool passed = false;
1018  CLinkedFeature::TLinkedFeats::iterator p_iter = features.begin();
1019  while (p_iter != features.end()) {
1020  if (IsCanceled()) {
1021  return passed;
1022  }
1023 
1024  bool is_leaf = (*p_iter)->GetChildren().empty();
1025 
1026  // For features with child(ren), it will be treated as
1027  // passed if any of its children is passed.
1028  if ( (!is_leaf && x_FilterFeature_recursive((*p_iter)->GetChildren(), filter)) ||
1029  filter.Pass(&(*p_iter)->GetMappedFeature())) {
1030  ++p_iter;
1031  passed = true;
1032  } else {
1033  p_iter = features.erase(p_iter);
1034  }
1035  }
1036 
1037  return passed;
1038 }
1039 
1040 
1043  TFeatGroups& feat_groups)
1044 {
1045  feat_groups.clear();
1046  if (!m_Sorter) {
1047  feat_groups.emplace_back(kUnsortedGroupName, feats);
1048  return;
1049  }
1050 
1051  TFeatGroupMap group_map;
1052  x_SortFeature_recursive(feats, group_map);
1053  NON_CONST_ITERATE (TFeatGroupMap, grp_iter, group_map) {
1054  feat_groups.emplace_back(m_Sorter->GroupIdxToName(grp_iter->first), grp_iter->second);
1055  }
1056 }
1057 
1058 
1061  TFeatGroupMap& group_map)
1062 {
1063  CLinkedFeature::TLinkedFeats::iterator p_iter = feats.begin();
1064  while (p_iter != feats.end()) {
1065  if (IsCanceled()) {
1066  break;
1067  }
1068 
1069  bool is_leaf = (*p_iter)->GetChildren().empty();
1070  int idx = m_Sorter->GetGroupIdx((*p_iter)->GetMappedFeature());
1071 
1072  TFeatGroupMap child_group_map;
1073  if ( !is_leaf && m_Sorter->ChildFeatureFirst() ) {
1074  // sort the child features first
1075  x_SortFeature_recursive((*p_iter)->GetChildren(), child_group_map);
1076  }
1077 
1078  size_t grp_num = child_group_map.size();
1079  if (grp_num > 1) {
1080  // Child features fall in different groups, we need to clone
1081  // the parent feature to go with each group of chilren
1082  NON_CONST_ITERATE (TFeatGroupMap, grp_iter, child_group_map) {
1083  CRef<CLinkedFeature> p_feat(new CLinkedFeature((*p_iter)->GetMappedFeature()));
1084  p_feat->GetChildren() = grp_iter->second;
1085  group_map[grp_iter->first].push_back(p_feat);
1086  }
1087  ++p_iter;
1088  } else if (idx > -1 || grp_num == 1) {
1089  if (grp_num == 1) {
1090  // only one group of children, using child's group idx
1091  idx = child_group_map.begin()->first;
1092  }
1093  // else {
1094  // there is no child or no child falls in any target group,
1095  // and the parent feature (this feature) is good.
1096  // }
1097  group_map[idx].push_back(*p_iter);
1098  ++p_iter;
1099  } else {
1100  // unwanted feature, remove it
1101  p_iter = feats.erase(p_iter);
1102  }
1103  }
1104 }
1105 
1106 
1109  CLayoutGroup* group,
1110  int Level)
1111 {
1112  group->SetLevel(Level);
1113 
1114  bool need_group = features.size() > 1;
1116  if (IsCanceled()) return eCanceled;
1117 
1118  CRef<CSeqGlyph> glyph = x_CreateFeature1((*iter)->GetMappedFeature());
1119  glyph->SetLevel(Level);
1120  if ( !glyph ) continue;
1121 
1122  size_t num_children = (*iter)->GetChildren().size();
1124 
1125  // cut-off more than kMaxChildNum children, modifying the last glyph to show that cut-off
1126  if(num_children >= kMaxChildNum) {
1127  (*iter)->GetChildren().resize(kMaxChildNum);
1128  glyph->SetTearlineText(" (" + NStr::NumericToString(num_children - kMaxChildNum) + " features not shown)");
1129  }
1130  if (num_children == 0 ) {
1131  group->PushBack(glyph);
1132  if(Level == 0) {
1133  group->SetAsMaster(glyph);
1134  }
1135  } else if (num_children == 1 && m_LinkedFeat == ELinkedFeatDisplay::eLFD_ParentHidden) {
1136  // skip the parent feature (the created glyph)
1137  state = x_CreateFeature_Recursive((*iter)->GetChildren(), group, Level + 1);
1138  } else {
1139  CLayoutGroup* p_group = group;
1140  if (need_group) {
1141  CLayoutGroup* c_group = new CLayoutGroup(m_LinkedFeat);
1142  p_group->PushBack(c_group);
1143  p_group = c_group;
1144  }
1146  p_group->PushBack(glyph);
1147  if(Level == 0) {
1148  p_group->SetAsMaster(glyph);
1149  }
1150  }
1151 
1152  if (num_children > 1 && m_LinkedFeat != ELinkedFeatDisplay::eLFD_Expandable) {
1153  CLayoutGroup* cc_group = new CLayoutGroup(m_LinkedFeat);
1154  p_group->PushBack(cc_group);
1155  p_group = cc_group;
1156  }
1157 
1158  state = x_CreateFeature_Recursive((*iter)->GetChildren(), p_group, Level + 1);
1159  }
1160  if (state != eCompleted) {
1161  return state;
1162  }
1163 
1164  AddTaskCompleted(1);
1165  }
1166  return eCompleted;
1167 }
1168 
1169 
1171  CSeqGlyph::TObjects& objs)
1172 {
1173  SetTaskName("Creating feature glyphs...");
1174  SetTaskTotal((int)feature_iter.GetSize());
1175  SetTaskCompleted(0);
1176  for (; feature_iter ; ++feature_iter) {
1177  if (IsCanceled()) {
1178  return eCanceled;
1179  }
1180  CRef<CSeqGlyph> glyph = x_CreateFeature1(*feature_iter);
1181  if (glyph) {
1182  objs.push_back(glyph);
1183  }
1184  AddTaskCompleted(1);
1185  }
1186  return eCompleted;
1187 }
1188 
1189 
1191  CSeqGlyph* parent_glyph /*=NULL*/,
1192  const char* label_prefix /*=NULL*/)
1193 {
1194  CConstRef<CSeq_loc> loc;
1195  if (m_Mapper) {
1196  try {
1197  loc = m_Mapper->Map(feat.GetLocation());
1198  } catch (std::exception&) {
1199  // ignore loc mapping exception.
1200  }
1201  } else {
1202  const CSeq_loc& loc_obj = feat.GetLocation();
1203  if (loc_obj.GetId()) {
1204  loc.Reset(&loc_obj);
1205  } else {
1206  // Very likely, we get a seq-loc with multiple seq-ids.
1207  // Extract the parts that matches with the viewed sequence
1208  loc = CSeqUtils::MixLocToLoc(loc_obj, m_Handle);
1209  }
1210  }
1211 
1212  auto GetCDSFrame = [&]() {
1213  if (feat.GetData().Which() != CSeqFeatData::e_Cdregion)
1214  return 0;
1215  if (feat.GetData().GetCdregion().IsSetFrame() && feat.GetData().GetCdregion().GetFrame() > 1)
1216  {
1217  int offset = feat.GetData().GetCdregion().GetFrame() - 1;
1218  const CSeq_loc& orig_loc = feat.GetLocation();
1219  ENa_strand q_strand = sequence::GetStrand(orig_loc, &m_Handle.GetScope());
1220  return (q_strand == eNa_strand_minus) ? -offset : offset;
1221  }
1222  return 0;
1223  };
1224  CRef<CSeqGlyph> glyph;
1225  if (loc) {
1226  if (loc->Which() != CSeq_loc::e_Null &&
1227  loc->Which() != CSeq_loc::e_Empty) {
1228  glyph = x_CreateFeature2(feat, *loc, label_prefix);
1229 
1230  // Try to find out if there is more accurate mapping
1231  // information available than the feature location itself.
1232  // For some features, such as RNA and CDS features, the
1233  // feature location might not be able to give the accureate mapping
1234  // between the RNA/CDS product sequence and the viewed sequence.
1235  // The inaccuracy prevent us from accurately showing the ruler
1236  // for the product sequence on the feature and mapping the
1237  // protein sequence or translated sequence to the feature intervals.
1238  // For performance consideration, we only do this when:
1239  // - the zoom level is at the sequence level,
1240  // - the feature has product sequence set,
1241  // - the feature is not projected from other sequences, and
1242  // - the feature is RNA or CDS feature.
1243  if (glyph && m_Window < kMinScaleForMapping && !m_Mapper && CSeqUtils::IsSameStrands(*loc)) {
1244 
1247  CSeqFeatData::ESubtype subtype = feat.GetData().GetSubtype();
1248 
1249  if (feat.IsSetProduct()) {
1250  const CSeq_loc& product = feat.GetProduct();
1251  const CSeq_id& product_id = *product.GetId();
1252 
1253  if (feat.GetData().IsRna()) {
1255  } else if (type == CSeqFeatData::e_Cdregion) {
1256  auto offset = GetCDSFrame();
1257  if (nullptr != parent_glyph) {
1258  // For CDS feature, we do this only when:
1259  // - the parent feature is a RNA feature, and
1260  // - the parent has mapping info set
1261  CFeatGlyph* parent_feat = dynamic_cast<CFeatGlyph*>(parent_glyph);
1262  if (parent_feat && !parent_feat->GetMappingInfo().empty() &&
1263  parent_feat->GetFeature().GetData().IsRna() && parent_feat->GetFeature().IsSetProduct()) {
1264 
1266  parent_feat->GetMappedFeature().GetMappedFeature(),
1267  feat, *loc, m_Handle.GetScope(), offset);
1268  }
1269  else {
1270  info = CSeqUtils::GetMappingInfoFromLocation(*loc, product_id, offset);
1271  }
1272  }
1273  else {
1274  info = CSeqUtils::GetMappingInfoFromLocation(*loc, product_id, offset);
1275  }
1276  }
1277  } else {
1278  // no product
1279  if ((type == CSeqFeatData::e_Cdregion) || (subtype == CSeqFeatData::eSubtype_V_segment) || feat.GetData().IsRna()) {
1280  static unsigned id_num{ 0 };
1281  CRef<CSeq_id> prod_id(new CSeq_id("lcl|pseudo" + NStr::IntToString(++id_num)));
1282  auto offset = GetCDSFrame();
1284  }
1285  }
1286 
1287  if ( !info.empty() ) {
1288  CFeatGlyph* feat_glyph = dynamic_cast<CFeatGlyph*>(glyph.GetPointer());
1289  if (feat_glyph) {
1290  feat_glyph->SetMappingInfo(info);
1291  }
1292  }
1293  }
1294  }
1295  } else {
1296  LOG_POST(Error << "CSGFeatureJob::x_CreateFeature1()"
1297  << "Failed to get seq-loc with unique seq-id!");
1298  }
1299 
1300  return glyph;
1301 }
1302 
1303 
1306  const CSeq_loc& loc,
1307  const char* label_prefix /*=NULL*/)
1308 {
1309  const CSeqFeatData& data = feat.GetData();
1310  if (data.GetSubtype() == CSeqFeatData::eSubtype_user) {
1311  const string& object_type = data.GetUser().GetType().GetStr();
1312  if (object_type == "clone placement") {
1313  return x_CreateCloneFeature(feat, loc);
1314  }
1315  }
1316 
1317  if (data.GetSubtype() == CSeqFeatData::eSubtype_clone) {
1318  return x_CreateCloneFeature(feat, loc);
1319  }
1320 
1321  CRef<CSeqGlyph> glyph;
1322  unique_ptr<CFeatGlyph> feat_glyph;
1323  if (data.GetSubtype() == CSeqFeatData::eSubtype_intron) {
1324  feat_glyph.reset(new CIntronGlyph(feat, loc, m_LinkedFeat));
1325  } else {
1326  feat_glyph.reset(new CFeatGlyph(feat, loc, m_LinkedFeat));
1327  }
1328  // cerr << "CFeatGlyph created: " << (void *) feat_glyph << endl;
1329  feat_glyph->SetFilter(m_Filter);
1330  if (label_prefix) {
1331  feat_glyph->SetTopLabelPrefix(label_prefix);
1332  }
1333  x_CalcIntervals(*feat_glyph);
1334  glyph.Reset(feat_glyph.release());
1335  return glyph;
1336 }
1337 
1338 
1341  const CSeq_loc& loc)
1342 {
1343  CRef<CSeqGlyph> glyph;
1344  CClonePlacementGlyph* cp = new CClonePlacementGlyph(feat, loc);
1345  glyph.Reset(cp);
1347  if (feat.GetLocation().IsMix()) {
1348  const CSeq_loc_mix::Tdata& seq_locs = feat.GetLocation().GetMix().Get();
1349  ITERATE (CSeq_loc_mix::Tdata, iter, seq_locs) {
1350  intervals.push_back((*iter)->GetTotalRange());
1351  }
1352  } else {
1353  intervals.push_back(feat.GetLocation().GetTotalRange());
1354  }
1355  return glyph;
1356 }
1357 
1358 
1359 
1362  const string& title)
1363 {
1364  if (features.empty()) return eCompleted;
1365 
1366  SetTaskName("Packing features...");
1368  for (const auto& f : features) {
1369  if (IsCanceled()) return eCanceled;
1370  try {
1371  the_map.AddRange(f->GetMappedFeature().GetLocation().GetTotalRange(), 1, false);
1372  } catch (CException&) {
1373  /// skip the feature with mix location and multiple seq-ids.
1374  }
1375  AddTaskCompleted(1);
1376  }
1377  CSeqFeatData::ESubtype subtype = features.front()->GetFeature().GetData().GetSubtype();
1378  result->m_ExtraObj.Reset(new CHistogramGlyph(the_map, subtype, title));
1379  return eCompleted;
1380 }
1381 
1382 
1384 {
1385  if (!feat_iter) return eCompleted;
1386  SetTaskName("Packing features...");
1387  CSeqFeatData::ESubtype subtype = feat_iter->GetOriginalFeature().GetData().GetSubtype();
1389  CFeatureFilter filter;
1390  filter.Init(m_Filter);
1391  for (; feat_iter; ++feat_iter) {
1392  if (IsCanceled()) {
1393  return eCanceled;
1394  }
1395  if (!filter.NeedFiltering() || filter.Pass(&(*feat_iter))) {
1396  try {
1397  the_map.AddRange(feat_iter->GetLocation().GetTotalRange(), 1, false);
1398  }
1399  catch (CException&) {
1400  /// skip the feature with mix location and multiple seq-ids.
1401  }
1402  }
1403  AddTaskCompleted(1);
1404  }
1405  result->m_ExtraObj.Reset(new CHistogramGlyph(the_map, subtype, title));
1406  return eCompleted;
1407 }
1408 
1411  int level,
1412  const string& title)
1413 {
1414  CSeqGlyph::TObjects glyphs;
1415  TAxisLimits tal;
1416  tal.min = 0.0;
1417  tal.max = 0.0;
1418  EJobState state = x_LoadCoverageGraph(glyphs, level, m_Window, title, false, tal);
1419  if (state == eCompleted && !glyphs.empty()) {
1420  _ASSERT(glyphs.size() == 1);
1421  result->m_ExtraObj = glyphs.front();
1422  }
1423  return state;
1424 }
1425 
1426 
1429  const string& title)
1430 {
1431  if ( !feat_iter ) return eCompleted;
1432 
1433  CHistogramGlyph::TMaps the_maps;
1434  for (; feat_iter ; ++feat_iter) {
1435  if (IsCanceled()) {
1436  return eCanceled;
1437  }
1438 
1439  size_t idx =
1441  string idx_str = NStr::IntToString((int)idx);
1442  CHistogramGlyph::TMaps::iterator iter = the_maps.find(idx_str);
1443  if (iter == the_maps.end()) {
1444  iter = the_maps.insert(
1446  idx_str,
1448  m_Range.GetFrom(),
1449  m_Range.GetTo(),
1450  (float)m_Window))).first;
1451  }
1452 
1453  try {
1454  iter->second.AddRange(
1455  feat_iter->GetLocation().GetTotalRange(), 1, false);
1456  } catch (CException&) {
1457  /// skip the feature with mix location and multiple seq-ids.
1458  }
1459  AddTaskCompleted(1);
1460  }
1461 
1462  if ( !the_maps.empty() ) {
1463  CRef<CHistogramGlyph> histogram(new CHistogramGlyph(the_maps, title));
1464  result->m_ExtraObj.Reset(histogram.GetPointer());
1465  }
1466 
1467  return eCompleted;
1468 }
1469 
1470 
1472 {
1473  CFeatGlyph::TIntervals& intervals = feat.SetIntervals();
1474  const CSeq_loc& loc = feat.GetLocation();
1475  intervals.clear();
1476  bool multi_ids = loc.IsMix() && loc.GetId() == NULL;
1477  CSeq_loc_CI iter(loc);
1478  if (multi_ids) {
1479  if (m_Handle) {
1480  for ( ; iter; ++iter) {
1481  if (m_Handle.IsSynonym(iter.GetSeq_id())) {
1482  intervals.push_back(iter.GetRange());
1483  }
1484  }
1485  }
1486  } else {
1487  bool rsite = false;
1488  if (feat.GetFeature().CanGetData())
1489  rsite = CSeqFeatData::eSubtype_rsite == feat.GetFeature().GetData().GetSubtype();
1490  TSeqRange rsiteRange;
1491  bool rsiteRangeFromSet = false;
1492  for ( ; iter; ++iter) {
1493  if (rsite) { // Assemble one range from the two points of the restriction site
1494  CConstRef<CSeq_loc> curr_loc = iter.GetRangeAsSeq_loc();
1495 
1496  if (curr_loc->IsPnt() && curr_loc->GetPnt().CanGetFuzz()) {
1497  const CSeq_point_Base::TFuzz &fuzz = curr_loc->GetPnt().GetFuzz();
1498  if (fuzz.IsLim() && (CInt_fuzz_Base::eLim_tl == fuzz.GetLim())) {
1499  if (!rsiteRangeFromSet) {
1500  rsiteRange.SetFrom(curr_loc->GetPnt().GetPoint());
1501  rsiteRangeFromSet = true;
1502  }
1503  else {
1504  rsiteRange.SetToOpen(curr_loc->GetPnt().GetPoint());
1505  intervals.push_back(rsiteRange);
1506  rsiteRangeFromSet = false;
1507  }
1508  }
1509  continue;
1510  }
1511  }
1512  intervals.push_back(iter.GetRange());
1513  }
1514  }
1515 }
1516 
1517 
1518 ///////////////////////////////////////////////////////////////////////////////
1519 /// CGeneModelFeatJob
1520 ///////////////////////////////////////////////////////////////////////////////
1521 
1522 
1524 CGeneModelFeatJob(const string& desc, CBioseq_Handle handle,
1525  const SAnnotSelector& lm_feat_sel,
1526  const SAnnotSelector& m_feat_sel,
1527  TJobToken lm_token, TJobToken main_token,
1528  bool landmark_feat, const TSeqRange& range, TModelUnit window,
1529  const CGeneModelConfig& conf, ICoordMapper* mapper)
1530  : CSGFeatureJob(desc, handle, lm_feat_sel, range, window, conf.m_LandmarkFeatLimit, ELinkedFeatDisplay::eLFD_Default, lm_token, mapper)
1531  , m_MainFeatSel(m_feat_sel)
1532  , m_MainFeatToken(main_token)
1533  , m_LandmarkFeats(landmark_feat)
1534  , m_Config(conf)
1535 {}
1536 
1537 
1539 {
1540  SetTaskName("Loading features...");
1541  CSGJobResult* result = new CSGJobResult();
1543 
1544  try {
1545  CConstRef<CSeq_loc> loc(
1546  m_Handle.GetRangeSeq_loc(m_Range.GetFrom(), m_Range.GetTo()) );
1547  // cerr << "Features for " << loc->GetId()->GetSeqIdString(true) << endl;
1548 // cerr << "using loc " << endl <<
1549 // MSerial_AsnText << *loc << endl;
1551  SAnnotSelector sel;
1552  if (m_LandmarkFeats) {
1553  sel = m_Sel;
1554  result->m_Token = m_Token;
1555  } else {
1556  sel = m_MainFeatSel;
1557  result->m_Token = m_MainFeatToken;
1558  }
1559 
1560  CFeat_CI feature_iter(m_Handle.GetScope(), *loc, sel);
1561 
1562  // if the visible genes are less than a certain number, we change the mode
1563  // to show all main features.
1564  if (m_LandmarkFeats &&
1565  feature_iter.GetSize() < (size_t)m_Config.m_OverviewFeatCutoff) {
1566  feature_iter = CFeat_CI(m_Handle.GetScope(), *loc, m_MainFeatSel);
1567  result->m_Token = m_MainFeatToken;
1568  m_LandmarkFeats = false;
1569  }
1570 
1571  // linking the features if not only landmark features are shown
1572  if (m_LandmarkFeats) {
1574  switch (f_type) {
1575  case eFilter_CCDS:
1578  feature_iter = CFeat_CI(m_Handle.GetScope(), *loc, sel);
1579  break;
1580  case eFilter_ncRNAs:
1581  case eFilter_dbref:
1585  feature_iter = CFeat_CI(m_Handle.GetScope(), *loc, sel);
1586  break;
1587  case eFilter_npcGenes:
1590  feature_iter = CFeat_CI(m_Handle.GetScope(), *loc, sel);
1591  break;
1592  default:
1593  break;
1594  }
1595 
1596  EJobState state;
1597  if (f_type != eFilter_invalid) {
1598  state = x_CreateFeaturesWithFilter(feature_iter, tmp, f_type);
1599  } else {
1600  state = x_CreateFeatures(feature_iter, tmp);
1601  }
1602  if (state != eCompleted) {
1603  return state;
1604  }
1605 
1606  // if feature number is more than the limit, we need to create a gene
1607  // distribution histogram and pick the most significant ones.
1608  if(m_FeatLimit > -1) {
1609  state = x_ProcessLandMarkFeatures(tmp, result->m_ExtraObj, result->m_CommentObjs);
1610  if (state != eCompleted) {
1611  return state;
1612  }
1613  }
1614  } else {
1615 
1617 // cerr << "got features: " << feature_iter.GetSize() << endl;
1618  for ( ; feature_iter; ++feature_iter) {
1619  const CMappedFeat& feat = *feature_iter;
1620 // cerr << "Got feature" << endl <<
1621 // MSerial_AsnText << feat.GetOriginalFeature() << endl;
1622  //CRef<CLinkedFeature> fref( new CLinkedFeature(feat) );
1623  features.emplace_back(new CLinkedFeature(feat) );
1624  }
1625 
1626  if ( !CSeqUtils::LinkFeatures(features, feature::CFeatTree::eFeatId_by_type, this) )
1627  return eCanceled;
1628 
1629  bool transcripts_filtered = false;
1630  EJobState state = x_CreateGeneModels(features, tmp, transcripts_filtered);
1631  if (state != eCompleted) {
1632  return state;
1633  }
1634  if (transcripts_filtered) {
1635  result->m_FilterDescr = "Some track data has been hidden";
1636  }
1637  }
1638  result->m_ObjectList.swap(tmp);
1639  } catch (CException& ex) {
1640  m_Error.Reset(new CAppJobError(ex.GetMsg()));
1641  return eFailed;
1642  } catch (std::exception& ex) {
1643  m_Error.Reset(new CAppJobError(ex.what()));
1644  return eFailed;
1645  }
1646 
1647  return eCompleted;
1648 }
1649 
1650 
1651 
1653  const CMappedFeat& feat, const CSeq_loc& loc, const char* label_prefix /*= NULL*/)
1654 {
1655  CFeatGlyph* feat_glyph;
1656  if (feat.GetData().IsCdregion()) {
1657  feat_glyph = new CCdsGlyph(feat, loc);
1658  } else {
1659  feat_glyph = new CFeatGlyph(feat, loc, m_LinkedFeat);
1660  }
1661  if (label_prefix) {
1662  feat_glyph->SetTopLabelPrefix(label_prefix);
1663  }
1664  CRef<CSeqGlyph> glyph(feat_glyph);
1665  x_CalcIntervals(*feat_glyph);
1666  return glyph;
1667 }
1668 
1669 static
1671 {
1672  ITERATE(CSeq_feat::TXref, xit, feat.GetXref()) {
1673  if ((*xit)->IsSetData() && (*xit)->GetData().Which() == choice) {
1674  return true;
1675  }
1676  }
1677  return false;
1678 }
1679 
1680 static
1681 bool s_HasCDS(const CLinkedFeature& linked_feat)
1682 {
1683  for (const auto& it : linked_feat.GetChildren()) {
1684  if (it->GetFeature().GetData().IsCdregion())
1685  return true;
1686  }
1687  return false;
1688 }
1689 
1690 static
1691 bool s_IsGnomonModel(const CSeq_feat& feat)
1692 {
1693 /* Alternative method (needs scope)
1694  if (feat.IsSetProduct()) {
1695  const CSeq_id* product_id = feat.GetProduct().GetId();
1696  if (product_id) {
1697  string acc = sequence::GetAccessionForId(*product_id, m_Handle.GetScope());
1698  auto acc_info = CSeq_id::IdentifyAccession(acc);
1699  if (acc_info == CSeq_id::eAcc_refseq_mrna_predicted || CSeq_id::eAcc_refseq_ncrna_predicted)
1700  break;
1701  }
1702  }
1703 */
1704  if (!feat.IsSetExt()) {
1705  return false;
1706  }
1707  const CUser_object & ext = feat.GetExt();
1708  if (!ext.IsSetType() || !ext.IsSetData()) {
1709  return false;
1710  }
1711  const CUser_object_Base::TType & ext_type = ext.GetType();
1712  if (!ext_type.IsStr() || ext_type.GetStr() != "CombinedFeatureUserObjects") {
1713  return false;
1714  }
1715  const CUser_object::TData & ext_data = ext.GetData();
1716  ITERATE(CUser_object::TData, field_iter, ext_data) {
1717  const CUser_field & field = **field_iter;
1718  if (!field.IsSetLabel() || !field.IsSetData())
1719  continue;
1720  const CUser_field::TLabel & field_label = field.GetLabel();
1721  const CUser_field::TData & field_data = field.GetData();
1722  if (!field_label.IsStr() || !field_data.IsObject() || field_label.GetStr() != "ModelEvidence")
1723  continue;
1724  const CUser_object & evidence_object = field_data.GetObject();
1725  if (!evidence_object.IsSetData() ||
1726  !evidence_object.IsSetType() ||
1727  !evidence_object.GetType().IsStr() ||
1728  evidence_object.GetType().GetStr() != "ModelEvidence")
1729  continue;
1730  const CUser_object::TData & evidence_data = evidence_object.GetData();
1731  ITERATE(CUser_object::TData, evidence_iter, evidence_data) {
1732  const CUser_field & evidence_field = **evidence_iter;
1733  if (!evidence_field.IsSetLabel() || !evidence_field.GetLabel().IsStr()
1734  || evidence_field.GetLabel().GetStr() != "Method" ||
1735  !evidence_field.IsSetData() ||
1736  !evidence_field.GetData().IsStr())
1737  continue;
1738  return NStr::FindNoCase(evidence_field.GetData().GetStr(), "Gnomon") != NPOS;
1739  }
1740  }
1741  return false;
1742 }
1743 
1744 static
1745 bool s_HasTag(const CSeq_feat& feat, const set<string>& tags)
1746 {
1747  if (tags.empty() || !feat.IsSetQual())
1748  return false;
1749  for (const auto& iter : feat.GetQual()) {
1750  if (iter->GetQual() == "tag" && iter->IsSetVal()) {
1751  const string& val = iter->GetVal();
1752  if (tags.count(val) > 0)
1753  return true;
1754  }
1755  }
1756  return false;
1757 }
1758 
1759 static
1760 bool s_IsSelect(const CLinkedFeature& feat)
1761 {
1762  return s_HasTag(feat.GetFeature(), {"MANE Select", "RefSeq Select"});
1763 }
1764 
1765 static bool s_IsCCDS(const CLinkedFeature& linked_feat) {
1766  const CSeq_feat& feat = linked_feat.GetFeature();
1767  if (feat.GetData().IsCdregion())
1768  return feat.GetNamedDbxref("CCDS") || s_HasTag(feat, {"CCDS"});
1769  ITERATE(CLinkedFeature::TLinkedFeats, iter, linked_feat.GetChildren()) {
1770  if (s_IsCCDS(**iter))
1771  return true;
1772  }
1773  return false;
1774 }
1775 
1777 {
1778  _ASSERT(feat.GetFeature().GetData().IsRna());
1779  if (!feat.GetFeature().GetData().IsRna())
1780  return true;
1781 
1782  if (m_Config.m_HideNonCoding && s_HasCDS(feat) == false)
1783  return false;
1784 
1786  return false;
1787 
1788  if (m_Config.m_CCDSOnly && !s_IsCCDS(feat))
1789  return false;
1790 
1791  if (m_Config.m_SelectOnly && !s_IsSelect(feat))
1792  return false;
1793 
1794  return true;
1795 }
1796 
1799 {
1800  SetTaskName("Creating feature glyphs and gene models...");
1801  SetTaskTotal((int)feats.size());
1802  SetTaskCompleted(0);
1803  transcripts_filtered = false;
1805 
1806  // Create glyph for each feature, and put the linked features
1807  // into right group according to the feature merging style
1809  AddTaskCompleted(1);
1810  if (IsCanceled()) return eCanceled;
1811 
1812  bool skip = false;
1813  switch (f_type) {
1814  case eFilter_dbref:
1815  if (!x_IsDbref(m_Filter, **iter)) {
1816  skip = true;
1817  }
1818  break;
1819  case eFilter_CCDS:
1820  if (!x_IsCCDS(**iter)) {
1821  skip = true;
1822  }
1823  break;
1824  case eFilter_pseudo_genes:
1825  if (!x_IsPseudoGene((*iter)->GetFeature())) {
1826  skip = true;
1827  }
1828  break;
1829  case eFilter_ncRNAs:
1830  if (!x_IsncRNA(**iter)) {
1831  skip = true;
1832  }
1833  break;
1834  case eFilter_npcGenes:
1835  if (!x_IsnpcGene(**iter)) {
1836  skip = true;
1837  }
1838  break;
1839  default:
1840  break;
1841  }
1842 
1843  if (skip) continue;
1844 
1845  CRef<CSeqGlyph> glyph = x_CreateFeature1((*iter)->GetMappedFeature());
1846  if ( !glyph ) continue;
1847 
1848  CSeqFeatData::ESubtype subtype = (*iter)->GetFeature().GetData().GetSubtype();
1849 
1850  if ((*iter)->GetChildren().empty()) {
1851  if (m_Config.m_ShowGenes == false && subtype == CSeqFeatData::eSubtype_gene && x_IsPseudoGene((*iter)->GetFeature())) {
1852  bool is_filtered = (m_Config.m_HideNonCoding || m_Config.m_CCDSOnly || m_Config.m_SelectOnly);
1853  if (is_filtered) {
1854  transcripts_filtered = true;
1855  continue;
1856  }
1857  }
1858  if (m_Config.m_HideNonCoding) {
1859  switch (subtype) {
1862  continue;
1863  default:
1864  break;
1865  }
1866  }
1867  objs.push_back(glyph);
1868  continue;
1869  }
1870  if (subtype == CSeqFeatData::eSubtype_gene) {
1871  if (m_Config.m_ShowGenes == false && x_IsPseudoGene((*iter)->GetFeature())) {
1872  bool is_filtered = (m_Config.m_HideNonCoding || m_Config.m_CCDSOnly || m_Config.m_SelectOnly);
1873  if (is_filtered) {
1874  transcripts_filtered = true;
1875  continue;
1876  }
1877  }
1878 
1879  CRef<CLayoutGroup> misc_group(new CLayoutGroup);
1880  CRef<CLinkedFeatsGroup> rnacds_group(new CLinkedFeatsGroup);
1881  CRef<CLayoutGroup> exon_group;
1882  string label_prefix;
1883  feature::GetLabel((*iter)->GetFeature(), &label_prefix, feature::fFGL_Content);
1884  size_t num_filtered = 0;
1885  NON_CONST_ITERATE (CLinkedFeature::TLinkedFeats, g_iter, (*iter)->GetChildren()) {
1886  CRef<CSeqGlyph> g_glyph = x_CreateFeature1((*g_iter)->GetMappedFeature(), 0, label_prefix.c_str());
1887  if ( !g_glyph ) continue;
1888 
1889  CSeqFeatData::E_Choice s_type = (*g_iter)->GetFeature().GetData().Which();
1890  CSeqFeatData::ESubtype s_subtype = (*g_iter)->GetFeature().GetData().GetSubtype();
1891  if (s_subtype == CSeqFeatData::eSubtype_exon) {
1892  if ( !exon_group )
1893  exon_group.Reset(new CLayoutGroup);
1894  exon_group->PushBack(g_glyph);
1895  } else if (s_subtype == CSeqFeatData::eSubtype_cdregion) {
1896  rnacds_group->PushBack(g_glyph);
1897  }
1898  else if ((s_type != CSeqFeatData::e_Rna && s_subtype != CSeqFeatData::eSubtype_misc_RNA)
1899  && (s_subtype != CSeqFeatData::eSubtype_V_segment) && (s_subtype != CSeqFeatData::eSubtype_D_segment)
1900  && (s_subtype != CSeqFeatData::eSubtype_J_segment) && (s_subtype != CSeqFeatData::eSubtype_C_region)) {
1901  misc_group->PushBack(g_glyph);
1902  } else { /// must be RNA
1903  if (x_IsTranscriptAcceptable(**g_iter)) {
1904  bool has_children = !(*g_iter)->GetChildren().empty() || s_HasFeatXref((*g_iter)->GetFeature(), CSeqFeatData::e_Cdregion);
1905  if (m_Config.m_MergeStyle == CGeneModelConfig::eMerge_Pairs && has_children) {
1906  CLinkedFeatsGroup* rna_group = new CLinkedFeatsGroup();
1907  rnacds_group->PushBack(rna_group);
1908  rna_group->PushBack(g_glyph);
1909  NON_CONST_ITERATE(CLinkedFeature::TLinkedFeats, r_iter, (*g_iter)->GetChildren()) {
1910  CRef<CSeqGlyph> r_glyph = x_CreateFeature1((*r_iter)->GetMappedFeature(), g_glyph.GetPointer(), label_prefix.c_str());
1911  if (r_glyph) {
1912  rna_group->PushBack(r_glyph);
1913  }
1914  }
1915  } else { // eMerge_All, eMerge_No, eMerge_OneLine, and eMerge_Pairs when no CDSs present
1916  rnacds_group->PushBack(g_glyph);
1917  NON_CONST_ITERATE(CLinkedFeature::TLinkedFeats, r_iter, (*g_iter)->GetChildren()) {
1918  CRef<CSeqGlyph> r_glyph = x_CreateFeature1((*r_iter)->GetMappedFeature(), g_glyph.GetPointer(), label_prefix.c_str());
1919  if (r_glyph) {
1920  rnacds_group->PushBack(r_glyph);
1921  }
1922  }
1923  }
1924  } else {
1925  num_filtered += 1;
1926  transcripts_filtered = true;
1927  }
1928  }
1929  }
1930  bool is_filtered = (num_filtered > 0 && num_filtered == (*iter)->GetChildren().size());
1931  // no gene bar if all children were filtered out and rendering options indicate sno gene bar
1932  if (m_Config.m_ShowGenes || is_filtered == false) {
1933 
1934  CGeneGroup* group = new CGeneGroup();
1935  objs.emplace_back(group);
1936  group->PushBack(glyph);
1937 
1938  if (!misc_group->GetChildren().empty() && m_Config.m_MergeStyle != CGeneModelConfig::eMerge_OneLine) {
1939  if (misc_group->GetChildren().size() > 1) {
1940  group->PushBack(misc_group);
1941  } else {
1942  group->Append(misc_group->SetChildren());
1943  }
1944  }
1945  if (!rnacds_group->GetChildren().empty()) {
1946  if (rnacds_group->GetChildren().size() == 1 ||
1949  {
1950  // Merge group children, dissolve the group
1951  group->Append(rnacds_group->SetChildren());
1952  } else {
1953  // Add as a group
1954  group->PushBack(rnacds_group);
1955  }
1956  }
1957  if (exon_group &&
1958  (m_Config.m_MergeStyle != CGeneModelConfig::eMerge_OneLine || rnacds_group->GetChildren().empty()))
1959  {
1960  if (exon_group->GetChildren().size() > 1) {
1961  group->PushBack(exon_group);
1962  } else {
1963  group->Append(exon_group->SetChildren());
1964  }
1965  }
1966  }
1967 
1968  } else { // must be RNA or other misc features: VDJ segments, C regions, and enhancers
1969  if ((*iter)->GetChildren().empty()) {
1970  // no need to put it into a group
1971  objs.push_back(glyph);
1972  } else {
1973  CLayoutGroup* group = NULL;
1975  group = new CLayoutGroup();
1976  objs.push_back(CRef<CSeqGlyph>(group));
1977  } else {
1978  CLinkedFeatsGroup* rc_group = new CLinkedFeatsGroup();
1979  objs.push_back(CRef<CSeqGlyph>(rc_group));
1980  group = &rc_group->SetGroup();
1981  }
1982  group->PushBack(glyph);
1984  (*iter)->GetChildren()) {
1985  CRef<CSeqGlyph> r_glyph =
1986  x_CreateFeature1((*r_iter)->GetMappedFeature(), glyph.GetPointer());
1987  if (r_glyph) {
1988  group->PushBack(r_glyph);
1989  }
1990  }
1991  }
1992  }
1993  }
1994 
1995  return eCompleted;
1996 }
1997 
1998 
2001  CSeqGlyph::TObjects& objs,
2002  TFilterType filter)
2003 {
2004  if (filter == eFilter_pseudo_genes) {
2005  SetTaskName("Creating feature glyphs...");
2006  SetTaskTotal((int)feature_iter.GetSize());
2007  SetTaskCompleted(0);
2008  for (; feature_iter ; ++feature_iter) {
2009  if (IsCanceled()) {
2010  return eCanceled;
2011  }
2012 
2013  AddTaskCompleted(1);
2014  if ( !x_IsPseudoGene(feature_iter->GetOriginalFeature()) ) {
2015  continue;
2016  }
2017 
2018  CRef<CSeqGlyph> glyph = x_CreateFeature1(*feature_iter);
2019  if (glyph) {
2020  objs.push_back(glyph);
2021  }
2022  }
2023  } else {
2025  for ( ; feature_iter; ++feature_iter) {
2026  const CMappedFeat& feat = *feature_iter;
2027  CRef<CLinkedFeature> fref( new CLinkedFeature(feat) );
2028  features.push_back(fref);
2029  }
2031  feature::CFeatTree::eFeatId_by_type, this) ) {
2032  return eCanceled;
2033  }
2034 
2035  SetTaskName("Creating feature glyphs...");
2036  SetTaskTotal((int)features.size());
2037  SetTaskCompleted(0);
2039  AddTaskCompleted(1);
2040 
2041  if ( !(*iter)->GetFeature().GetData().IsGene() ) continue;
2042 
2043  if (IsCanceled()) return eCanceled;
2044 
2045  bool skip = false;
2046  switch (filter) {
2047  case eFilter_dbref:
2048  if ( !x_IsDbref(m_Filter, **iter) ) {
2049  skip = true;
2050  }
2051  break;
2052  case eFilter_CCDS:
2053  if ( !x_IsCCDS(**iter) ) {
2054  skip = true;
2055  }
2056  break;
2057  case eFilter_ncRNAs:
2058  if ( !x_IsncRNA(**iter) ) {
2059  skip = true;
2060  }
2061  break;
2062  case eFilter_npcGenes:
2063  if ( !x_IsnpcGene(**iter) ) {
2064  skip = true;
2065  }
2066  break;
2067  default:
2068  break;
2069  }
2070 
2071  if (skip) continue;
2072 
2073  CRef<CSeqGlyph> glyph = x_CreateFeature1((*iter)->GetMappedFeature());
2074  if (glyph) {
2075  objs.push_back(glyph);
2076  }
2077  }
2078  }
2079  return eCompleted;
2080 }
2081 
2082 
2083 //float s_GetGeneDocsumWeight(const CEntrez2_docsum& ds)
2084 //{
2085 // float score = 0;
2086 // try {
2087 // string val = ds.GetValue("GeneWeight");
2088 // score = (float)NStr::StringToDouble(val);
2089 // }
2090 // catch (CException&) {
2091 // }
2092 // return score;
2093 //}
2094 
2095 
2097 
2098 static const char* kGeneByLocUrl =
2099 "http://www.ncbi.nlm.nih.gov/gutils/fgenes_by_loc.fcgi?sort=weight&retmode=asnb";
2100 
2102  TGi gi, const TSeqRange& r, size_t retmax)
2103 {
2104  STimeout timeout;
2105  timeout.sec = 4;
2106  timeout.usec = 0;
2107 
2108  string url = kGeneByLocUrl;
2109  url += "&gi=" + NStr::NumericToString(gi);
2110  url += "&retmax=" + NStr::NumericToString(retmax);
2111  url += "&start=" + NStr::NumericToString(r.GetFrom());
2112  url += "&stop=" + NStr::NumericToString(r.GetTo());
2113  CConn_HttpStream stream(url, fHTTP_AutoReconnect, &timeout);
2114 
2115  unique_ptr<CObjectIStream> obj_stream(CObjectIStream::Open(eSerial_AsnBinary, stream));
2116  try {
2117  CGBL_Reply gbl_reply;
2118  //NcbiStreamCopy(cout, stream);
2119  *obj_stream >> gbl_reply;
2120  if (gbl_reply.IsError()) {
2121  NCBI_THROW(CException, eUnknown, gbl_reply.GetError());
2122  }
2123  const CGBL_Data& data = gbl_reply.GetData();
2124  if (data.CanGetGenes()) {
2125  int weight = data.GetReturned();
2126  ITERATE (CGBL_Data::TGenes, iter, data.GetGenes()) {
2127  genes.insert(map<int, int>::value_type((*iter)->GetGeneid(), weight--));
2128  }
2129  }
2130  } catch (CException& e) {
2131  LOG_POST(Error << "Failed to retrieve genes by location for gi|"
2132  << gi << ", error: " << e.GetMsg());
2133  return false;
2134  }
2135 
2136  return true;
2137 }
2138 
2139 
2141  CSeqGlyph::TObjects& objs, CRef<CSeqGlyph>& hist_obj, CSeqGlyph::TObjects& comment_objs)
2142 {
2143  SetTaskName("Packing features...");
2144  SetTaskTotal((int)objs.size());
2145  SetTaskCompleted(0);
2146 
2147 
2148  vector<SLandmarkFeat> landmark_feats;
2149 
2150  ///
2151  /// determine scores for landmark features
2152  ///
2153 
2154 #if 0
2155  ///
2156  /// option 1: brain-dead calculation
2157  ///
2158  NON_CONST_ITERATE(CSeqGlyph::TObjects, iter, objs) {
2159  if (m_StopRequested) {
2160  return eCanceled;
2161  }
2162 
2163  CSeqGlyph* tmp = *iter;
2164  CFeatGlyph* feat = dynamic_cast<CFeatGlyph*>(tmp);
2165 
2166  TSeqRange range = tmp->GetRange();
2167 
2168  float score = (float)range.GetLength();
2169  string s;//s.erase();
2171  score /= s.length();
2172 
2173  SLandmarkFeat f;
2174  f.score = score;
2175  f.obj = *iter;
2176 
2177  landmark_feats.push_back(f);
2178  }
2179 
2180  ///
2181  /// end option 1
2182  ///
2183 #endif
2184 
2185 #if 0
2186  /// option 2: use gene weights
2187  /// NB: this currently uses an ineffective method, in that it
2188  /// queries Entrez for the information on the fly
2189  vector<int> gene_uids;
2190  NON_CONST_ITERATE(CSeqGlyph::TObjects, iter, objs) {
2191  if (m_StopRequested) {
2192  return eCanceled;
2193  }
2194 
2195  CSeqGlyph* tmp = *iter;
2196  CFeatGlyph* feat = dynamic_cast<CFeatGlyph*>(tmp);
2197  const CSeq_feat& seqfeat = feat->GetFeature();
2198  CConstRef<CDbtag> gene_tag = seqfeat.GetNamedDbxref("GeneID");
2199  if ( !gene_tag ) {
2200  gene_tag = seqfeat.GetNamedDbxref("LocusID");
2201  }
2202  if (gene_tag && gene_tag->GetTag().IsId()) {
2203  gene_uids.push_back(gene_tag->GetTag().GetId());
2204  }
2205  }
2206 
2207  typedef map<int, float> TScoreMap;
2208  TScoreMap gene_scores;
2209 
2210  /// screen for already retrieved gene IDs
2211  CEntrezCache& cache = CEntrezCache::GetInstance();
2212  {{
2213  vector<int>::iterator iter = gene_uids.begin();
2214  string db("gene");
2215  for ( ; iter != gene_uids.end(); ) {
2216  CConstRef<CEntrez2_docsum> ds = cache.Get(db, *iter);
2217  if (ds) {
2218  gene_scores[ds->GetUid()] =
2219  s_GetGeneDocsumWeight(*ds);
2220  iter = gene_uids.erase(iter);
2221  } else {
2222  ++iter;
2223  }
2224  }
2225  }}
2226 
2227  /// retrieve any new gene IDs
2228  if (gene_uids.size()) {
2229  CEntrez2Client cli;
2230  CRef<CEntrez2_docsum_list> ds = cli.GetDocsums(gene_uids, "gene");
2231  if (ds && ds->IsSetList()) {
2232  cache.Put("gene", *ds);
2233  ITERATE (CEntrez2_docsum_list::TList, iter, ds->GetList()) {
2234  gene_scores[(*iter)->GetUid()] =
2235  s_GetGeneDocsumWeight(**iter);
2236  }
2237  }
2238  }
2239 
2240  NON_CONST_ITERATE(CSeqGlyph::TObjects, iter, objs) {
2241  if (m_StopRequested) {
2242  return eCanceled;
2243  }
2244 
2245  CSeqGlyph* tmp = *iter;
2246  CFeatGlyph* feat = dynamic_cast<CFeatGlyph*>(tmp);
2247  const CSeq_feat& seqfeat = feat->GetFeature();
2248  float score = 0;
2249 
2250  CConstRef<CDbtag> gene_tag = seqfeat.GetNamedDbxref("GeneID");
2251  if ( !gene_tag ) {
2252  gene_tag = seqfeat.GetNamedDbxref("LocusID");
2253  }
2254  if (gene_tag && gene_tag->GetTag().IsId()) {
2255  int uid = gene_tag->GetTag().GetId();
2256  TScoreMap::iterator it = gene_scores.find(uid);
2257  if (it != gene_scores.end()) {
2258  score = it->second;
2259  }
2260  }
2261 
2262  SLandmarkFeat f;
2263  f.score = score;
2264  f.obj = *iter;
2265 
2266  landmark_feats.push_back(f);
2267  }
2268 
2269  ///
2270  /// end option 2
2271  ///
2272 #endif
2273 
2274  TId2Wt gene_weights;
2275 #if 0
2276  // Gene weights are available for current live gis only
2277  if (m_Handle.GetState() == CBioseq_Handle::fState_none) {
2278  // try to get the sorted (by weight) gene list
2279  CSeq_id_Handle idh = m_Handle.GetSeq_id_Handle();
2280  idh = sequence::GetId(idh, m_Handle.GetScope(), sequence::eGetId_ForceGi);
2281  if (idh && idh.GetGi() > 0) {
2282  TGi gi = idh.GetGi();
2283  int number_genes = m_FeatLimit > 0 ? m_FeatLimit : (int)objs.size();
2284  typedef map<int, int> TId2Wt; // gene id to gene weight map
2285  if (number_genes > 0) {
2286  s_GetGeneWeight(gene_weights, gi, m_Range, number_genes);
2287  }
2288  }
2289  }
2290 #endif
2291 
2292 #if 1
2293  ///
2294  /// option 4: use gene weights from user objects
2295  ///
2296  NON_CONST_ITERATE(CSeqGlyph::TObjects, iter, objs) {
2297  if (IsCanceled()) {
2298  return eCanceled;
2299  }
2300 
2301  CSeqGlyph* tmp = *iter;
2302  CFeatGlyph* feat = dynamic_cast<CFeatGlyph*>(tmp);
2303  const CSeq_feat& seqfeat = feat->GetFeature();
2304  float score = 0.0f;
2305 
2306  if (gene_weights.empty()) {
2307 // weight use removed per SV-4623
2308 /* if (seqfeat.IsSetExt()) {
2309  const CUser_object& obj = seqfeat.GetExt();
2310  CConstRef<CUser_field> field = obj.GetFieldRef("GeneWeight");
2311  if (field) {
2312  if (field->GetData().IsInt()) {
2313  score = (float)field->GetData().GetInt();
2314  } else if (field->GetData().IsReal()) {
2315  score = (float)field->GetData().GetReal();
2316  }
2317  }
2318  }
2319 */
2320  if ( !score ) {
2321  string s;
2323  TSeqRange range = tmp->GetRange();
2324 
2325  score = (float)range.GetLength();
2326  score /= s.length();
2327  score -= 1e6f;
2328  }
2329  } else if (CConstRef<CDbtag> tag = seqfeat.GetNamedDbxref("GeneID")) {
2330  if (tag->GetTag().IsId()) {
2331  TId2Wt::const_iterator g_iter = gene_weights.find(tag->GetTag().GetId());
2332  if (g_iter != gene_weights.end()) {
2333  score = (float)g_iter->second;
2334  }
2335  }
2336  }
2337 
2338  SLandmarkFeat f;
2339  f.score = score;
2340  f.obj = *iter;
2341 
2342  landmark_feats.push_back(f);
2343  }
2344 
2345  ///
2346  /// end option 3
2347  ///
2348 #endif
2349 
2350  if (landmark_feats.empty()) return eCompleted;
2351 
2352  ///
2353  ///
2354  ///
2355  /// sort and filter
2356  std::sort(landmark_feats.begin(), landmark_feats.end(),
2358 
2359  // Add Gene Histogram when there are genes that are not shown
2360  if ((int)landmark_feats.size() > m_FeatLimit && m_Config.m_ShowHistogram) {
2361  const CFeatGlyph* feat =
2362  dynamic_cast<const CFeatGlyph*>(landmark_feats.front().obj.GetPointer());
2363  string title = CSeqUtils::GetAnnotName(feat->GetMappedFeature().GetAnnot());
2364 
2365  CHistogramGlyph::TMap the_map(
2366  m_Range.GetFrom(), m_Range.GetTo(), (float)m_Window);
2367  ITERATE (vector<SLandmarkFeat>, iter, landmark_feats) {
2368  if (IsCanceled()) {
2369  return eCanceled;
2370  }
2371 
2372  TSeqRange range = iter->obj->GetRange();
2373  the_map.AddRange(range);
2374  AddTaskCompleted(1);
2375  }
2376 
2377  hist_obj.Reset(new CHistogramGlyph(the_map, CSeqFeatData::eSubtype_gene, title));
2378  }
2379 
2380  size_t len = landmark_feats.size() - 1;
2381  vector<SLandmarkFeat>::iterator prev =
2382  landmark_feats.begin() + ((int)len < m_FeatLimit ? len : m_FeatLimit);
2383  vector<SLandmarkFeat>::iterator s_iter = prev;
2384  vector<SLandmarkFeat>::iterator end = landmark_feats.end();
2385  //for (++iter; iter != end; ++iter) {
2386  // if (iter->score != prev->score) {
2387  // break;
2388  // }
2389  // prev = iter;
2390  //}
2391  if (IsCanceled()) {
2392  return eCanceled;
2393  }
2394 
2395  landmark_feats.erase(s_iter, end);
2396 
2397  int highlight_num = (int)(10 * m_Range.GetLength() / (1400 * m_Window));
2398  if (highlight_num > 40) {
2399  highlight_num = 40;
2400  } else if (highlight_num < 10) {
2401  highlight_num = 10;
2402  }
2403 
2404  if (m_Config.m_HighlightMode == 1) {
2405  // highlight the top most important genes
2406  s_iter = landmark_feats.begin();
2407  while (highlight_num > 0 && s_iter != landmark_feats.end()) {
2408  s_iter->obj->SetHighlighted(true);
2409  --highlight_num;
2410  ++s_iter;
2411  }
2412  } else if (m_Config.m_HighlightMode == 2) {
2413  // render label and feature independently
2414  s_iter = landmark_feats.begin();
2415  while (highlight_num > 0 && s_iter != landmark_feats.end()) {
2416  CFeatGlyph* feat = dynamic_cast<CFeatGlyph*>(s_iter->obj.GetPointer());
2417  string label;
2419  CCommentGlyph* comment = new CCommentGlyph(label, s_iter->obj);
2420  CRef<CSeqGlyph> glyph(comment);
2421  TSeqRange range = feat->GetRange();
2422  comment->SetTargetPos(TModelPoint((range.GetFrom() + range.GetTo()) * 0.5, 0.0));
2423  comment_objs.push_back(glyph);
2424  --highlight_num;
2425  ++s_iter;
2426  }
2427  }
2428 
2429  std::sort(landmark_feats.begin(), landmark_feats.end(),
2431 
2432  if (IsCanceled()) {
2433  return eCanceled;
2434  }
2435 
2436  objs.clear();
2437  ITERATE (vector<SLandmarkFeat>, l_iter, landmark_feats) {
2438  objs.push_back(l_iter->obj);
2439  }
2440 
2441  return eCompleted;
2442 }
2443 
2444 
2445 vector<string> CGeneModelFeatJob::GetFilters(const CBioseq_Handle& handle,
2446  const TSeqRange& range,
2447  SAnnotSelector& sel,
2448  const string& filter)
2449 {
2450  vector<string> filters;
2451  TFilterType f_type = x_FilterStrToValue(filter);
2452  switch (f_type) {
2453  case eFilter_dbref_all:
2455  break;
2456  case eFilter_dbref:
2457  {{
2461  CFeat_CI feat_iter(handle, range, sel);
2462  while (feat_iter) {
2463  if (x_IsDbref(filter, feat_iter->GetOriginalFeature())) {
2464  filters.push_back(filter);
2465  break;
2466  }
2467  ++feat_iter;
2468  }
2469  break;
2470  }}
2471  case eFilter_CCDS:
2472  {{
2474  CFeat_CI feat_iter(handle, range, sel);
2475  while (feat_iter) {
2476  if (x_IsDbref(filter, feat_iter->GetOriginalFeature())) {
2477  filters.push_back(filter);
2478  break;
2479  }
2480  ++feat_iter;
2481  }
2482  break;
2483  }}
2484  case eFilter_pseudo_genes:
2485  {{
2487  CFeat_CI feat_iter(handle, range, sel);
2488  while (feat_iter) {
2489  if (x_IsPseudoGene(feat_iter->GetOriginalFeature())) {
2490  filters.push_back(filter);
2491  break;
2492  }
2493  ++feat_iter;
2494  }
2495  break;
2496  }}
2497  case eFilter_ncRNAs:
2498  {{
2502  CFeat_CI feat_iter(handle, range, sel);
2504  for (; feat_iter; ++feat_iter) {
2505  const CMappedFeat& feat = *feat_iter;
2506  CRef<CLinkedFeature> fref( new CLinkedFeature(feat) );
2507  features.push_back(fref);
2508  }
2510  feature::CFeatTree::eFeatId_by_type, NULL);
2512  if (x_IsncRNA(**iter)) {
2513  filters.push_back(filter);
2514  break;
2515  }
2516  }
2517  break;
2518  }}
2519  case eFilter_npcGenes:
2520  {{
2523  CFeat_CI feat_iter(handle, range, sel);
2525  for (; feat_iter; ++feat_iter) {
2526  const CMappedFeat& feat = *feat_iter;
2527  CRef<CLinkedFeature> fref( new CLinkedFeature(feat) );
2528  features.push_back(fref);
2529  }
2531  feature::CFeatTree::eFeatId_by_type, NULL);
2533  if (x_IsnpcGene(**iter)) {
2534  filters.push_back(filter);
2535  break;
2536  }
2537  }
2538  break;
2539  }}
2540  default:
2541  break;
2542  }
2543  return filters;
2544 }
2545 
2546 
2549 {
2550  /// anything unrecognizable will be treated as dbref
2552  if (NStr::EqualNocase(filter, "dbref")) {
2554  } else if (NStr::EqualNocase(filter, "CCDS")) {
2555  type = eFilter_CCDS;
2556  } else if (NStr::EqualNocase(filter, "PseudoGenes")) {
2558  } else if (NStr::EqualNocase(filter, "ncRNAs")) {
2559  type = eFilter_ncRNAs;
2560  } else if (NStr::EqualNocase(filter, "npcGenes")) {
2562  } else if ( !filter.empty() ) {
2563  type = eFilter_dbref;
2564  }
2565 
2566  return type;
2567 }
2568 
2569 
2570 ///////////////////////////////////////////////////////////////////////////////
2571 /// CBatchFeatJob
2572 ///////////////////////////////////////////////////////////////////////////////
2573 CBatchFeatJob::CBatchFeatJob(const string& desc,
2574  CBioseq_Handle handle,
2575  const TSeqRange& range, TModelUnit window,
2576  TJobToken token, const TFeatBatchJobRequests& requests)
2577  : CSGFeatureJob(desc, handle, SAnnotSelector(), range, window, token)
2578  , m_Requests(requests)
2579 {
2580 }
2581 
2582 
2584 {
2585  try {
2588  result->m_Token = m_Token;
2589 
2591  if (IsCanceled()) {
2592  return eCanceled;
2593  }
2594  CRef<CSGJobResult> single_res =
2595  x_LoadFeatProducts(iter->m_Feat, iter->m_Sel);
2596  if (single_res) {
2597  result->m_Results.push_back(single_res);
2598  }
2599  }
2600  } catch (CException& ex) {
2601  m_Error.Reset(new CAppJobError(ex.GetMsg()));
2602  return eFailed;
2603  } catch (std::exception& ex) {
2604  m_Error.Reset(new CAppJobError(ex.what()));
2605  return eFailed;
2606  }
2607 
2608  return eCompleted;
2609 }
2610 
2611 
2614  const SAnnotSelector& sel)
2615 {
2618  CRef<CSeqGlyph> dmap;
2619 
2620  const CSeq_loc& loc = feat->GetLocation();
2621  const CSeq_loc& product = feat->GetFeature().GetProduct();
2622  try {
2623  // map visible range to product feature
2624  CSeq_loc_Mapper prot_range_mapper(loc, product, &GetScope());
2625 
2627  range.IntersectWith(loc.GetTotalRange());
2628  CRef<CSeq_loc> tmp_loc(new CSeq_loc());
2629  tmp_loc->SetInt().SetFrom(range.GetFrom());
2630  tmp_loc->SetInt().SetTo (range.GetTo());
2631  tmp_loc->SetId(*loc.GetId());
2632 
2633  // our new location for feature iterator
2634  CRef<CSeq_loc> prot_loc = prot_range_mapper.Map(tmp_loc.GetObject());
2635  prot_loc->SetId(*product.GetId());
2636 
2637 
2638  // might be slow if number of visible features in the frame are more than a 100
2639  // if slow, try not to recreate seq_mapper for each feature
2640  CRef<CSeq_loc_Mapper> mapper;
2641  CAlign_CI align_iter(GetScope(), loc, sel);
2642 
2643  while (align_iter && !mapper) {
2644  // find the first seq-align that matches the current feature product sequence
2645  const CSeq_align& align = *align_iter;
2646  CSeq_align::TDim num_row = align.CheckNumRows();
2647  for (CSeq_align::TDim row = 0; row < num_row; ++row) {
2648  if (product.GetId()->Match(align.GetSeq_id(row))) {
2649  mapper.Reset(
2650  new CSeq_loc_Mapper(align, *loc.GetId(), &GetScope()));
2651  break;
2652  }
2653  }
2654  ++align_iter;
2655  }
2656 
2657  if ( !mapper ) {
2658  mapper.Reset( new CSeq_loc_Mapper(product, loc, &GetScope()) );
2659  }
2660 
2661  // use newly created location to get the features
2662  CFeat_CI feat_iter(GetScope(), prot_loc.GetObject(), sel);
2663  size_t size = feat_iter.GetSize();
2664 
2665  // Only show variation in packed form in non-sequence level
2666  bool packed = feat_iter &&
2668  m_Window > kSeqZoomLevel &&
2669  size * 1024 * m_Window / range.GetLength() > 50.0;
2670 
2671  if (packed) {
2672  CHistogramGlyph::TMap the_map(feat->GetRange().GetFrom(),
2673  feat->GetRange().GetTo(), (float)m_Window);
2674 
2675  for ( ; feat_iter; ++feat_iter) {
2676  CConstRef<CSeq_loc> mapped_loc =
2677  mapper->Map(feat_iter->GetLocation());
2678  the_map.AddRange( mapped_loc->GetTotalRange() );
2679  }
2680  dmap.Reset(new CHistogramGlyph(
2683 
2684  } else if (size > 0) {
2685  for ( ; feat_iter; ++feat_iter) {
2686  // see the comment about performance above
2687  CConstRef<CSeq_loc> mapped_loc = mapper->Map(feat_iter->GetLocation());
2688  if (mapped_loc->Which() != CSeq_loc::e_Null &&
2689  mapped_loc->Which() != CSeq_loc::e_Empty) {
2690  const CMappedFeat mapped_feat = *feat_iter;
2691  tmp.push_back(x_CreateFeature2(mapped_feat, *mapped_loc));
2692  }
2693  }
2694  }
2695  }
2696  catch (CAnnotMapperException&) {
2697  /// ignore errors from location mapping
2698  return result;
2699  }
2700 
2701  result.Reset(new CSGJobResult());
2702  if (dmap) result->m_ExtraObj.Reset(dmap);
2703  if ( !tmp.empty() ) result->m_ObjectList.swap(tmp);
2704  result->m_Token = m_Token;
2705  result->m_Owner = CRef<CSeqGlyph>(feat.GetPointer());
2706  return result;
2707 }
2708 
2709 
2710 
2711 ///////////////////////////////////////////////////////////////////////////////
2712 /// CSGCalcFeatHistJob
2713 ///////////////////////////////////////////////////////////////////////////////
2715 {
2716  try {
2717  CSGJobResult* result = new CSGJobResult();
2719 
2721  the_map(m_Range.GetFrom(), m_Range.GetTo(), (float)m_Window);
2723  if (IsCanceled()) {
2724  EJobState state = x_CalcFeatHistRecursive(*iter, the_map);
2725  if (state != eCompleted) {
2726  return state;
2727  }
2728  }
2729  }
2730 
2731  CRef<CSeqGlyph> dmap;
2733 
2734  result->m_ExtraObj.Reset(dmap);
2735  result->m_Token = m_Token;
2736  } catch (CException& ex) {
2737  m_Error.Reset(new CAppJobError(ex.GetMsg()));
2738  return eFailed;
2739  } catch (std::exception& ex) {
2740  m_Error.Reset(new CAppJobError(ex.what()));
2741  return eFailed;
2742  }
2743 
2744  return eCompleted;
2745 }
2746 
2747 
2750  CDensityMap<float>& the_map)
2751 {
2752  CLayoutGroup* group = dynamic_cast<CLayoutGroup*>(obj.GetPointer());
2753  if (group) {
2754  ITERATE (CLayoutGroup::TObjectList, iter, group->GetChildren()) {
2755  if (IsCanceled()) {
2756  EJobState state = x_CalcFeatHistRecursive(*iter, the_map);
2757  if (state != eCompleted) {
2758  return state;
2759  }
2760  }
2761  }
2762  return eCompleted;
2763  }
2764 
2765  CFeatGlyph* feat = dynamic_cast<CFeatGlyph*>(obj.GetPointer());
2766  if (feat) {
2767  const CSeqFeatData& data = feat->GetFeature().GetData();
2768  if ( data.GetSubtype() == CSeqFeatData::eSubtype_mRNA ||
2770  // collect intervals
2771  ITERATE (CFeatGlyph::TIntervals, iter, feat->GetIntervals()) {
2772  TSeqRange range = *iter;
2773 
2774  if (IsCanceled()) {
2775  return eCanceled;
2776  }
2777 
2778  the_map.AddRange(range);
2779  }
2780  }
2781  }
2782 
2783  return eCompleted;
2784 }
2785 
2786 
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
CAlign_CI –.
Definition: align_ci.hpp:63
Seq-loc and seq-align mapper exceptions.
const TAnnotNames & GetAnnotNames(void) const
size_t GetSize(void) const
CAppJobError Default implementation for IAppJobError - encapsulates a text error message.
CBatchFeatJob: a job class for loading annotated features from a given a set of sequences within the ...
Definition: feature_ds.cpp:381
virtual CRef< CSGJobResult > x_LoadFeatProducts(CRef< CFeatGlyph > feat, const SAnnotSelector &sel)
virtual EJobState x_Execute()
method truly doing the job.
TFeatBatchJobRequests m_Requests
Definition: feature_ds.cpp:395
CBatchFeatJob(const string &desc, CBioseq_Handle handle, const TSeqRange &range, TModelUnit window, TJobToken token, const TFeatBatchJobRequests &requests)
CBatchFeatJob.
CBatchJobResult – the data structure holding the seqgraphic job results for a batch job processing.
CBioseq_Handle –.
CCloneConcordancySorter is a feature sorter used to sort clone features based on clone concordancy.
static const string & GetID()
CClonePlacementGlyph is similar to CFeatureGlyph, but with different rendering style and settings.
TIntervals & SetIntervals()
CClonePlacementGlyph inline implementations.
CCommentGlyph – utility class for having comments in graphical glyphs.
void SetTargetPos(const TModelPoint &pos)
This stream exchanges data with an HTTP server located at the URL: http[s]://host[:port]/path[?...
CDbvarClinicalAsstSorter is a feature sorter used to sort variant features based on variant quality.
static const string & GetID()
CDbvarPilotSorter is a feature sorter used to sort variant features based on variant pilot number.
static const string & GetID()
CDbvarQualitySorter is a feature sorter used to sort variant features based on variant quality.
static const string & GetID()
CDbvarSamplesetTypeSorter is a feature sorter used to sort variant features based on variant quality.
static const string & GetID()
CDbvarValidationSorter is a feature sorter used to sort variant features based on variant quality.
static const string & GetID()
CRef< CEntrez2_docsum_list > GetDocsums(const vector< TUid > &uids, const string &db)
Retrieve the docsums for a set of UIDs.
void SetMappingInfo(const TMappingInfo &info)
TIntervals & SetIntervals()
CFeatGlyph inline implementations.
const TMappingInfo & GetMappingInfo() const
virtual const objects::CSeq_loc & GetLocation(void) const
access the position of this object.
void SetTopLabelPrefix(const char *prefix)
Set prefix to prepend to labels on top.
const objects::CMappedFeat & GetMappedFeature(void) const
Access a new, fully remapped feature.
virtual TSeqRange GetRange(void) const
get the total range of this object.
virtual const TIntervals & GetIntervals(void) const
access sub-intervals (if any).
const objects::CSeq_feat & GetFeature(void) const
Access the original feature.
static size_t GetCustomColorIdx(const objects::CSeq_feat &feat)
Get the customized color idx for a given feature.
void GetLabel(string &label, CLabel::ELabelType type) const
retrieve feature label for a given type
static const string & GetID()
Definition: feature_ds.hpp:140
CFeat_CI –.
Definition: feat_ci.hpp:64
class CFeatureFilter
bool NeedFiltering() const
bool Pass(const objects::CMappedFeat *feat)
void Init(const string &filter)
CGBL_Data –.
Definition: GBL_Data.hpp:66
CGBL_Reply –.
Definition: GBL_Reply.hpp:66
CGRCStatusSorter is a feature sorter used to sort GRC issue features based on resolving status stored...
static const string & GetID()
CGeneGroup is a subclass of CLayoutGroup contains gene, RNA, cds, and Exon features.
bool m_CCDSOnly
Show only CCDS variants.
EMergeStyle m_MergeStyle
the way on how to merge CDSs and RNAs.
bool m_SelectOnly
Show only Select/MANE variants.
bool m_HideNonCoding
Hide transcripts without associated CDS.
bool m_ShowHistogram
show gene distribution histogram.
@ eMerge_OneLine
merge into one line
@ eMerge_Pairs
merge each transcript and CDS pair
@ eMerge_No
show all feature individually
bool m_HideModels
Hide Model RefSeqs.
CGeneModelFeatJob: a job class for loading annotated main features, including genes,...
Definition: feature_ds.cpp:226
static vector< string > GetFilters(const CBioseq_Handle &handle, const TSeqRange &range, SAnnotSelector &sel, const string &filter)
static bool x_IsncRNA(const CLinkedFeature &linked_feat)
Definition: feature_ds.cpp:331
static bool x_IsDbref(const string &db, const CSeq_feat &feat)
Definition: feature_ds.cpp:278
virtual CRef< CSeqGlyph > x_CreateFeature2(const CMappedFeat &feat, const CSeq_loc &loc, const char *label_prefix=NULL)
overridable creator.
IAppJob::EJobState x_CreateFeaturesWithFilter(CFeat_CI &feature_iter, CSeqGlyph::TObjects &objs, TFilterType filter)
create features when there is a filter set up.
static bool x_IsnpcGene(const CLinkedFeature &linked_feat)
Definition: feature_ds.cpp:354
static TFilterType x_FilterStrToValue(const string &filter)
static bool x_IsCCDS(const CLinkedFeature &linked_feat)
Definition: feature_ds.cpp:305
static bool x_IsDbref(const string &db, const CLinkedFeature &linked_feat)
Definition: feature_ds.cpp:290
bool x_IsTranscriptAcceptable(const CLinkedFeature &feat)
Check if transcript passes Config filters.
IAppJob::EJobState x_CreateGeneModels(CLinkedFeature::TLinkedFeats &feats, CSeqGlyph::TObjects &objs, bool &transcripts_filtered)
Link features into a hierarchical list.
SAnnotSelector m_MainFeatSel
annotation selector for all main features.
Definition: feature_ds.cpp:369
EJobState x_ProcessLandMarkFeatures(CSeqGlyph::TObjects &objs, CRef< CSeqGlyph > &hist_obj, CSeqGlyph::TObjects &comment_objs)
TJobToken m_MainFeatToken
Job token for loading main features.
Definition: feature_ds.cpp:370
CGeneModelConfig m_Config
Definition: feature_ds.cpp:372
CGeneModelFeatJob(const string &desc, CBioseq_Handle handle, const SAnnotSelector &lm_feat_sel, const SAnnotSelector &m_feat_sel, TJobToken lm_token, TJobToken main_token, bool landmark_feat, const TSeqRange &range, TModelUnit window, const CGeneModelConfig &conf, ICoordMapper *mapper)
CGeneModelFeatJob.
@ eFilter_dbref
one specific dbref
Definition: feature_ds.cpp:231
@ eFilter_dbref_all
any dbref
Definition: feature_ds.cpp:230
@ eFilter_CCDS
genes with Consensus CDS
Definition: feature_ds.cpp:232
bool m_LandmarkFeats
is overview mode?
Definition: feature_ds.cpp:371
static bool x_IsPseudoGene(const CSeq_feat &feat)
Definition: feature_ds.cpp:326
virtual EJobState x_Execute()
method truly doing the job.
CRef< TData > GetData(const string &data_key)
Retrieves TData from in-memory cache or if not found calls TData::Init to initialize new TData instan...
static CGraphCache & GetInstance()
Definition: graph_cache.hpp:97
CRef< TData > GetCachedData(const string &data_key)
Retrieves TData from in-memory cache.
static int GetNearestLevel(const set< int > &levels, double zoom)
Definition: graph_utils.cpp:47
CLayoutGroup is a container of CSeqGlyphs (layout objects).
void PushBack(CSeqGlyph *obj)
Append a layout object to the end.
TObjectList & SetChildren()
const TObjectList & GetChildren() const
CLayoutGroup inline methods.
void SetAsMaster(CRef< CSeqGlyph > master)
master glyph has some special meaning (e.g.
void Append(TObjectList &objs)
size_t GetChildrenNum() const
Get total number of children.
ILayoutPolicy::TObjectList TObjectList
CLinkedFeatsGroup is a container class contains related features.
CLayoutGroup & SetGroup()
void PushBack(CSeqGlyph *obj)
CMappedFeat –.
Definition: mapped_feat.hpp:59
CTitleGroup is a layout group with a title.
Definition: named_group.hpp:45
objects::SAnnotSelector m_Sel
our annotation selector
objects::CScope & GetScope(void) const
CSGAnnotJob inline methods.
int GetGraphLevel() const
TSeqRange m_Range
target range
objects::CBioseq_Handle m_Handle
target sequence
IAppJob::EJobState x_LoadCoverageGraph(CSeqGlyph::TObjects &glyphs, int level, TModelUnit window, const string &title, bool fixed_scale, const TAxisLimits &y_limits)
CSGCalcFeatHistJob.
Definition: feature_ds.cpp:403
TSeqRange m_Range
target range
Definition: feature_ds.cpp:424
TModelUnit m_Window
current window for smear bars
Definition: feature_ds.cpp:425
EJobState x_CalcFeatHistRecursive(CRef< CSeqGlyph > obj, CDensityMap< float > &the_map)
CSGCalcFeatHistJob(const string &desc, const CSeqGlyph::TObjects &objs, const TSeqRange &range, TModelUnit window, TJobToken token)
Definition: feature_ds.cpp:405
const CSeqGlyph::TObjects & m_Objects
Definition: feature_ds.cpp:423
virtual EJobState x_Execute()
CSGCalcFeatHistJob.
virtual ISGDataSource * CreateDS(SConstScopedObject &object) const
create an instance of the layout track type using default settings.
Definition: feature_ds.cpp:545
virtual string GetExtensionLabel() const
returns a displayable label for this extension ( please capitalize the key words - "My Extension" )
Definition: feature_ds.cpp:561
virtual bool IsSharable() const
check if the data source can be shared.
Definition: feature_ds.cpp:568
virtual string GetExtensionIdentifier() const
returns the unique human-readable identifier for the extension the id should use lowercase letters se...
Definition: feature_ds.cpp:554
CSGFeatureDS.
Definition: feature_ds.hpp:49
string m_Filter
Definition: feature_ds.hpp:110
CSGFeatureDS(objects::CScope &scope, const objects::CSeq_id &id)
CSGFeatureDS.
Definition: feature_ds.cpp:432
void LoadGeneModelFeatures(objects::SAnnotSelector &lm_feat_sel, objects::SAnnotSelector &m_feat_sel, TJobToken lm_token, TJobToken main_token, bool landmark_feat, const TSeqRange &range, TModelUnit window, const CRef< CGeneModelConfig > &conf)
load features for gene model.
Definition: feature_ds.cpp:482
void GetAnnotNames(objects::SAnnotSelector &sel, const TSeqRange &range, TAnnotNameTitleMap &names) const
Definition: feature_ds.cpp:513
string m_GraphCacheKey
Definition: feature_ds.hpp:112
void CalcFeatHistogram(const CSeqGlyph::TObjects &objs, const TSeqRange &range, TModelUnit window, TJobToken token=-1)
Definition: feature_ds.cpp:502
bool IsVcfTabix() const
Definition: feature_ds.hpp:210
string m_SortBy
Definition: feature_ds.hpp:111
bool IsBigBed() const
Definition: feature_ds.hpp:204
virtual void LoadFeatures(objects::SAnnotSelector &sel, const TSeqRange &range, TModelUnit window, TJobToken token=-1, int max_feat=-1, ELinkedFeatDisplay LinkedFeatDisplay=ELinkedFeatDisplay::eLFD_Default, const string &extra_filter="")
void GetAnnotNames_var(objects::SAnnotSelector &sel, const TSeqRange &range, TAnnotNameTitleMap &names) const
Definition: feature_ds.cpp:522
vector< string > GetFilters(const string &annot_name, const TSeqRange &range) const
Definition: feature_ds.cpp:531
CSGFeatureJob: a job class for loading annotated features from a given sequence and visible range.
Definition: feature_ds.cpp:93
CRef< CSeqGlyph > x_CreateCloneFeature(const CMappedFeat &feat, const CSeq_loc &loc)
bool x_FilterFeature_recursive(CLinkedFeature::TLinkedFeats &features, CFeatureFilter &filter)
void x_GetLinkedFeatures(CFeat_CI &feature_iter, CLinkedFeature::TLinkedFeats &features)
Definition: feature_ds.cpp:736
IAppJob::EJobState x_CreateFeatSmear(CFeat_CI &feat_iter, CSGJobResult *result, const string &title)
int m_FeatLimit
the maximum number of features allowed.
Definition: feature_ds.cpp:204
void SetVcfCacheKey(const string &cache_key)
Definition: feature_ds.cpp:124
void x_SortFeatures(CLinkedFeature::TLinkedFeats &feats, TFeatGroups &feat_groups)
bool x_ProcessCachedVcfTabix()
Definition: feature_ds.cpp:865
IAppJob::EJobState x_LinkFeatures(CLinkedFeature::TLinkedFeats &feats, CSeqGlyph::TObjects &objs)
Definition: feature_ds.cpp:765
bool x_ProcessCachedBigBed()
Definition: feature_ds.cpp:834
void x_CalcIntervals(CFeatGlyph &feat)
CSGFeatureJob(const string &desc, CBioseq_Handle handle, const SAnnotSelector &sel, const TSeqRange &range, TModelUnit window, TJobToken token)
Definition: feature_ds.cpp:636
vector< TSortedFeats > TFeatGroups
Definition: feature_ds.cpp:96
EJobState x_CreateFeatHist(CLinkedFeature::TLinkedFeats &features, CSGJobResult *result, const string &title)
CRef< CSeqGlyph > x_CreateFeature1(const CMappedFeat &feat, CSeqGlyph *parent_glyph=NULL, const char *label_prefix=NULL)
CIRef< ICoordMapper > m_Mapper
Definition: feature_ds.cpp:212
string m_VcfCacheKey
Definition: feature_ds.cpp:215
void x_SortFeature_recursive(CLinkedFeature::TLinkedFeats &feats, TFeatGroupMap &group_map)
ELinkedFeatDisplay m_LinkedFeat
controls creation of parent or child features
Definition: feature_ds.cpp:207
TModelUnit m_Window
current window for smear bars
Definition: feature_ds.cpp:198
static void GetAnnotNames_var(const CBioseq_Handle &handle, const TSeqRange &range, SAnnotSelector &sel, TAnnotNameTitleMap &names)
Definition: feature_ds.cpp:716
IAppJob::EJobState x_CreateFeature_Recursive(CLinkedFeature::TLinkedFeats &features, CLayoutGroup *group, int Level)
CIRef< IFeatSorter > m_Sorter
Definition: feature_ds.cpp:210
map< int, CLinkedFeature::TLinkedFeats > TFeatGroupMap
Definition: feature_ds.cpp:97
string m_BigBedCacheKey
Definition: feature_ds.cpp:214
void SetBigBedCacheKey(const string &cache_key)
Definition: feature_ds.cpp:119
IAppJob::EJobState x_CreateFeatures(CFeat_CI &feature_iter, CSeqGlyph::TObjects &objs)
static void GetAnnotNames(const CBioseq_Handle &handle, const TSeqRange &range, SAnnotSelector &sel, TAnnotNameTitleMap &names)
Definition: feature_ds.cpp:697
EJobState x_CreateFeatHistFromGraph(CSGJobResult *result, int level, const string &title)
pair< string, CLinkedFeature::TLinkedFeats > TSortedFeats
Definition: feature_ds.cpp:95
void SetSortBy(const string &sortby)
Definition: feature_ds.cpp:664
virtual EJobState x_Execute()
method truly doing the job.
Definition: feature_ds.cpp:901
virtual CRef< CSeqGlyph > x_CreateFeature2(const CMappedFeat &feat, const CSeq_loc &loc, const char *label_prefix=NULL)
overridable creator.
void SetFilter(const string &filter)
Definition: feature_ds.cpp:114
CIRef< ICoordMapper > m_Mapper
coordinate mapper between mapped features coord. and sequence coord.
TJobID x_LaunchJob(IAppJob &job, int report_period=1, const string &pool="ObjManagerEngine")
Launch either a background or foreground job.
bool m_Adaptive
adaptive/exact annot selector
int m_Depth
annotation resolving depth
TGraphLevels m_GraphLevels
Existing coverage graph levels.
objects::CBioseq_Handle m_Handle
CSGJobResult – the data structure holding the seqgraphic job results.
CScope –.
Definition: scope.hpp:92
ESubtype GetSubtype(void) const
class CSeqGlyph defines an interface that wraps a rectilinear abstract object.
Definition: seq_glyph.hpp:82
virtual bool LessBySeqPos(const CSeqGlyph &obj) const
compare this object to another based on glyph sequence position.
Definition: seq_glyph.hpp:534
void SetLevel(int Level)
Definition: seq_glyph.hpp:287
void SetTearlineText(const string &sTearlineText)
tearline text – if set, is appended to the glyph name (does not naffect processing otherwise)
Definition: seq_glyph.hpp:277
list< CRef< CSeqGlyph > > TObjects
Definition: seq_glyph.hpp:85
CSeqGraphicJob – the base class of seqgraphic job for handling the job status such as reporting the p...
CRef< CObject > m_Result
virtual void SetTaskTotal(int total)
map< string, string > TAnnotNameTitleMap
List of annotations with the corresponding titles.
virtual void SetTaskName(const string &name)
virtual void SetTaskCompleted(int completed)
set total finished task number.
void SetToken(TJobToken token)
CSeqGraphicJob inline methods.
virtual void AddTaskCompleted(int delta)
set to add newly finished task number.
TJobToken m_Token
Job token recognizable by job listener.
CRef< CAppJobError > m_Error
TDim CheckNumRows(void) const
Validatiors.
Definition: Seq_align.cpp:73
const CSeq_id & GetSeq_id(TDim row) const
Get seq-id (the first one if segments have different ids).
Definition: Seq_align.cpp:317
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
CConstRef< CDbtag > GetNamedDbxref(const CTempString &db) const
Return a specified DB xref.
Definition: Seq_feat.cpp:415
Seq-loc iterator class – iterates all intervals from a seq-loc in the correct order.
Definition: Seq_loc.hpp:453
CSeq_loc_Mapper –.
ICoordMapper interface for converting location between two coordinate systems.
vector< TSeqRange > TIntervals
File Description:
void erase(iterator pos)
Definition: map.hpp:167
size_type size() const
Definition: map.hpp:148
container_type::const_iterator const_iterator
Definition: map.hpp:53
const_iterator begin() const
Definition: map.hpp:151
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
const_iterator find(const key_type &key) const
Definition: map.hpp:153
Definition: map.hpp:338
bool empty() const
Definition: set.hpp:133
static const struct name_t names[]
static DLIST_TYPE *DLIST_NAME() prev(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
Definition: dlist.tmpl.h:61
static bool s_HasCDS(const CLinkedFeature &linked_feat)
static bool s_HasFeatXref(const CSeq_feat &feat, CSeqFeatData_Base::E_Choice choice)
USING_SCOPE(objects)
static const char * kGeneByLocUrl
map< int, int > TId2Wt
static bool s_IsGnomonModel(const CSeq_feat &feat)
static const float kMinScaleForMapping
Definition: feature_ds.cpp:85
static const char * kUnsortedGroupName
Definition: feature_ds.cpp:82
static bool s_HasTag(const CSeq_feat &feat, const set< string > &tags)
static bool s_IsSelect(const CLinkedFeature &feat)
static const size_t kMaxChildNum
Definition: feature_ds.cpp:78
static const int kMaxObjNum
Definition: feature_ds.cpp:75
static bool s_IsCCDS(const CLinkedFeature &linked_feat)
bool s_GetGeneWeight(TId2Wt &genes, TGi gi, const TSeqRange &r, size_t retmax)
static const float kSeqZoomLevel
Definition: feature_ds.cpp:80
ELinkedFeatDisplay
@ eLFD_Default
@ eLFD_Expandable
@ eLFD_ParentHidden
@ eLFD_Hidden
static int type
Definition: getdata.c:31
#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
@ fHTTP_AutoReconnect
See HTTP_CreateConnectorEx()
#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
virtual const char * what(void) const noexcept
Standard report (includes full backlog).
Definition: ncbiexpt.cpp:342
static TMappingInfo GetMappingInfoFromLocation(const objects::CSeq_loc &feat_loc, const objects::CSeq_id &product_id, const int feat_offset=0)
Definition: utils.cpp:2199
static TMappingInfo GetRnaMappingInfo(const objects::CSeq_loc &feat_loc, const objects::CMappedFeat &feat, const objects::CBioseq_Handle &handle)
Helper function to generate mapping info between the specified product sequence and genomic sequence ...
Definition: utils.cpp:1900
const objects::CSeq_feat & GetFeature() const
Definition: utils.hpp:87
static bool LinkFeatures(CLinkedFeature::TLinkedFeats &feats, TFeatLinkingMode mode=1, ISeqTaskProgressCallback *p_cb=NULL)
Link features into a hierarchical list.
Definition: utils.cpp:452
static objects::SAnnotSelector GetAnnotSelector(TAnnotFlags flags=0)
request an annotation selector for a given type
Definition: utils.cpp:167
list< CRef< CLinkedFeature > > TLinkedFeats
Definition: utils.hpp:80
static TMappingInfo GetCdsMappingInfoFromRna(const TMappingInfo &rna_mapping_info, const objects::CSeq_feat &rna_feat, const objects::CMappedFeat &mapped_cds_feat, const objects::CSeq_loc &feat_loc, objects::CScope &scope, const int feat_offset=0)
Derive the CDS feature mapping information based on its parent RNA feature mapping info.
Definition: utils.cpp:2036
static string GetAnnotName(const objects::CSeq_annot_Handle &annot_handle)
static CRef< objects::CSeq_loc > MixLocToLoc(const objects::CSeq_loc &mix_loc, const objects::CBioseq_Handle &handle)
Create a new seq-loc with a unique seq-id from a "mixed" loc.
Definition: utils.cpp:661
static const string & GetUnnamedAnnot()
Get the commonly used symbol representing a unnnamed annotation.
Definition: utils.hpp:531
static bool IsSameStrands(const objects::CSeq_loc &loc)
Definition: utils.cpp:948
static void SetAnnot(objects::SAnnotSelector &sel, const string &annot)
help function for setting up an annotation.
Definition: utils.cpp:320
vector< TMappedInt > TMappingInfo
Definition: utils.hpp:165
const TLinkedFeats & GetChildren() const
Definition: utils.hpp:89
static void SetResolveDepth(objects::SAnnotSelector &sel, bool adaptive, int depth=-1)
help function for setting selector resolve depth.
Definition: utils.cpp:405
GLdouble TModelUnit
Definition: gltypes.hpp:48
CGlPoint< TModelUnit > TModelPoint
Definition: gltypes.hpp:51
virtual bool IsCanceled() const override
virtual void AddRange(TSeqRange range, CntType score=1, bool expand=false)
EJobState
Job states (describe FSM)
Definition: app_job.hpp:86
@ eUnknown
Definition: app_popup.hpp:72
@ eCanceled
Definition: app_job.hpp:91
@ eCompleted
Definition: app_job.hpp:89
@ eFailed
Definition: app_job.hpp:90
@ eContent
Definition: label.hpp:62
@ eSerial_AsnBinary
ASN.1 binary.
Definition: serialdef.hpp:74
bool Match(const CSeq_id &sid2) const
Match() - TRUE if SeqIds are equivalent.
Definition: Seq_id.hpp:1033
string GetLabel(const CSeq_id &id)
TGi GetGi(void) const
void SetId(CSeq_id &id)
set the 'id' field in all parts of this location
Definition: Seq_loc.cpp:3474
TRange GetTotalRange(void) const
Definition: Seq_loc.hpp:913
CConstRef< CSeq_loc > GetRangeAsSeq_loc(void) const
Get seq-loc for the current iterator position.
Definition: Seq_loc.cpp:2585
void SetInt(TInt &v)
Definition: Seq_loc.hpp:983
const CSeq_id * GetId(void) const
Get the id of the location return NULL if has multiple ids or no id at all.
Definition: Seq_loc.hpp:941
TRange GetRange(void) const
Get the range.
Definition: Seq_loc.hpp:1042
const CSeq_id & GetSeq_id(void) const
Get seq_id of the current location.
Definition: Seq_loc.hpp:1028
static CObjectIStream * Open(ESerialDataFormat format, CNcbiIstream &inStream, bool deleteInStream)
Create serial object reader and attach it to an input stream.
Definition: objistr.cpp:195
@ fFGL_Content
Include its content if there is any.
Definition: feature.hpp:73
const CSeq_id & GetId(const CSeq_loc &loc, CScope *scope)
If all CSeq_ids embedded in CSeq_loc refer to the same CBioseq, returns the first CSeq_id found,...
ENa_strand GetStrand(const CSeq_loc &loc, CScope *scope=0)
Returns eNa_strand_unknown if multiple Bioseqs in loc Returns eNa_strand_other if multiple strands in...
@ eGetId_ForceGi
return only a gi-based seq-id
Definition: sequence.hpp:99
CRef< CSeq_loc > Map(const CSeq_loc &src_loc)
Map seq-loc.
const CSeq_annot_Handle & GetAnnot(void) const
Get handle to seq-annot for this feature.
const CSeqFeatData & GetData(void) const
bool IsSetProduct(void) const
CSeqFeatData::ESubtype GetFeatSubtype(void) const
SAnnotSelector & SetFeatType(TFeatType type)
Set feature type (also set annotation type to feat)
vector< CAnnotName > TAnnotsNames
Object manager recognizes several fields of Seq-annot as annot name.
const CSeq_loc & GetLocation(void) const
const CSeq_feat & GetOriginalFeature(void) const
Get original feature with unmapped location/product.
SAnnotSelector & SetCollectNames(bool value=true)
Collect available annot names rather than annots.
SAnnotSelector & IncludeFeatType(TFeatType type)
Include feature type in the search.
const CSeq_loc & GetProduct(void) const
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:998
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:1439
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
TObjectType & GetObject(void)
Get object.
Definition: ncbiobj.hpp:1011
position_type GetLength(void) const
Definition: range.hpp:158
TThisType & SetToOpen(position_type toOpen)
Definition: range.hpp:175
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define kEmptyStr
Definition: ncbistr.hpp:123
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 IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5083
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
static string TruncateSpaces(const string &str, ETrunc where=eTrunc_Both)
Truncate spaces in a string.
Definition: ncbistr.cpp:3182
unsigned int usec
microseconds (modulo 1,000,000)
Definition: ncbi_types.h:78
unsigned int sec
seconds
Definition: ncbi_types.h:77
static const char label[]
void SetFrom(TFrom value)
Assign a value to From data member.
Definition: Range_.hpp:231
TTo GetTo(void) const
Get the To member data.
Definition: Range_.hpp:269
TFrom GetFrom(void) const
Get the From member data.
Definition: Range_.hpp:222
list< CRef< CEntrez2_docsum > > TList
const TStr & GetStr(void) const
Get the variant data.
bool IsSetData(void) const
the object itself Check if a value has been assigned to Data data member.
bool IsStr(void) const
Check if variant Str is selected.
Definition: Object_id_.hpp:291
bool IsSetType(void) const
type of object within class Check if a value has been assigned to Type data member.
bool IsLim(void) const
Check if variant Lim is selected.
Definition: Int_fuzz_.hpp:636
const TTag & GetTag(void) const
Get the Tag member data.
Definition: Dbtag_.hpp:267
bool IsId(void) const
Check if variant Id is selected.
Definition: Object_id_.hpp:264
const TData & GetData(void) const
Get the Data member data.
TLim GetLim(void) const
Get the variant data.
Definition: Int_fuzz_.hpp:642
bool IsStr(void) const
Check if variant Str is selected.
bool IsSetLabel(void) const
field label Check if a value has been assigned to Label data member.
const TStr & GetStr(void) const
Get the variant data.
Definition: Object_id_.hpp:297
const TData & GetData(void) const
Get the Data member data.
const TObject & GetObject(void) const
Get the variant data.
const TLabel & GetLabel(void) const
Get the Label member data.
const TType & GetType(void) const
Get the Type member data.
bool IsObject(void) const
Check if variant Object is selected.
bool IsSetData(void) const
Check if a value has been assigned to Data data member.
vector< CRef< CUser_field > > TData
TId GetId(void) const
Get the variant data.
Definition: Object_id_.hpp:270
@ eLim_tl
space to left of position
Definition: Int_fuzz_.hpp:214
TReturned GetReturned(void) const
Get the Returned member data.
Definition: GBL_Data_.hpp:304
list< CRef< CGBL_Gene > > TGenes
Definition: GBL_Data_.hpp:91
const TData & GetData(void) const
Get the variant data.
Definition: GBL_Reply_.cpp:103
bool IsError(void) const
Check if variant Error is selected.
Definition: GBL_Reply_.hpp:270
const TError & GetError(void) const
Get the variant data.
Definition: GBL_Reply_.hpp:276
bool CanGetGenes(void) const
Check if it is safe to call GetGenes method.
Definition: GBL_Data_.hpp:338
const TGenes & GetGenes(void) const
Get the Genes member data.
Definition: GBL_Data_.hpp:344
vector< CRef< CDbtag > > TDbxref
Definition: Seq_feat_.hpp:123
bool IsSetQual(void) const
qualifiers Check if a value has been assigned to Qual data member.
Definition: Seq_feat_.hpp:1135
E_Choice Which(void) const
Which variant is currently selected.
bool IsSetExt(void) const
user defined structure extension Check if a value has been assigned to Ext data member.
Definition: Seq_feat_.hpp:1207
bool IsCdregion(void) const
Check if variant Cdregion is selected.
const TQual & GetQual(void) const
Get the Qual member data.
Definition: Seq_feat_.hpp:1147
E_Choice
Choice variants.
bool IsGene(void) const
Check if variant Gene is selected.
TFrame GetFrame(void) const
Get the Frame member data.
Definition: Cdregion_.hpp:534
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_feat_.hpp:925
const TUser & GetUser(void) const
Get the variant data.
const TDbxref & GetDbxref(void) const
Get the Dbxref member data.
Definition: Seq_feat_.hpp:1333
const TCdregion & GetCdregion(void) const
Get the variant data.
TPseudo GetPseudo(void) const
Get the Pseudo member data.
Definition: Seq_feat_.hpp:1365
bool IsSetPseudo(void) const
annotated on pseudogene? Check if a value has been assigned to Pseudo data member.
Definition: Seq_feat_.hpp:1346
const TXref & GetXref(void) const
Get the Xref member data.
Definition: Seq_feat_.hpp:1308
vector< CRef< CSeqFeatXref > > TXref
Definition: Seq_feat_.hpp:122
bool IsSetDbxref(void) const
support for xref to other databases Check if a value has been assigned to Dbxref data member.
Definition: Seq_feat_.hpp:1321
const TExt & GetExt(void) const
Get the Ext member data.
Definition: Seq_feat_.hpp:1219
bool IsRna(void) const
Check if variant Rna is selected.
bool IsSetFrame(void) const
Check if a value has been assigned to Frame data member.
Definition: Cdregion_.hpp:509
bool IsMix(void) const
Check if variant Mix is selected.
Definition: Seq_loc_.hpp:552
ENa_strand
strand of nucleic acid
Definition: Na_strand_.hpp:64
const TPnt & GetPnt(void) const
Get the variant data.
Definition: Seq_loc_.cpp:238
TPoint GetPoint(void) const
Get the Point member data.
Definition: Seq_point_.hpp:303
list< CRef< CSeq_loc > > Tdata
const TFuzz & GetFuzz(void) const
Get the Fuzz member data.
Definition: Seq_point_.hpp:420
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seq_loc_.hpp:475
const Tdata & Get(void) const
Get the member data.
bool CanGetFuzz(void) const
Check if it is safe to call GetFuzz method.
Definition: Seq_point_.hpp:414
const TMix & GetMix(void) const
Get the variant data.
Definition: Seq_loc_.cpp:282
bool IsPnt(void) const
Check if variant Pnt is selected.
Definition: Seq_loc_.hpp:540
@ eNa_strand_minus
Definition: Na_strand_.hpp:67
@ e_Null
not placed
Definition: Seq_loc_.hpp:98
@ e_Empty
to NULL one Seq-id in a collection
Definition: Seq_loc_.hpp:99
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
n font weight
int len
static MDB_envinfo info
Definition: mdb_load.c:37
range(_Ty, _Ty) -> range< _Ty >
constexpr auto sort(_Init &&init)
const struct ncbi::grid::netcache::search::fields::SIZE size
const char * tag
T max(T x_, T y_)
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
double f(double x_, const double &y_)
Definition: njn_root.hpp:188
static char tmp[2048]
Definition: utf8.c:42
struct named_group named_group
int offset
Definition: replacements.h:160
vector< SFeatBatchJobRequest > TFeatBatchJobRequests
SAnnotSelector –.
CSGFeatureJob implementation.
Definition: feature_ds.cpp:618
bool operator()(const CSGFeatureJob::SLandmarkFeat &f1, const CSGFeatureJob::SLandmarkFeat &f2) const
Definition: feature_ds.cpp:619
bool operator()(const CSGFeatureJob::SLandmarkFeat &f1, const CSGFeatureJob::SLandmarkFeat &f2) const
Definition: feature_ds.cpp:628
Timeout structure.
Definition: ncbi_types.h:76
TEMPLATE STRUCT max.
Definition: density_map.hpp:88
TEMPLATE STRUCT max.
Definition: density_map.hpp:70
Definition: type.c:6
#define _ASSERT
else result
Definition: token2.c:20
static const char *const features[]
Modified on Thu Sep 21 03:45:03 2023 by modify_doxy.py rev. 669887