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

Go to the SVN repository for this file.

1 /* $Id: all_other_features_track.cpp 42431 2019-02-22 16:04:19Z katargir $
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 
30 #include <ncbi_pch.hpp>
34 
35 
38 
40 CAllOtherFeaturesTrack::m_TypeInfo("all_other_features_track", "All Other Features Track");
41 static const string kDefTrackTitle = "All other features";
42 
44  CFeaturePanelDS* ds,
45  const set<string>& usedFeatureSubkeys)
46  : CTrackContainer(r_cntx, ds)
47  , m_UsedFeatureSubkeys(usedFeatureSubkeys)
48 {}
49 
50 
52 {}
53 
54 
56 {
57  bool no_track = GetChildren().empty();
59  int seq_len = seq_ds->GetSequenceLength();
60  int off = (int)(seq_len * 0.0001);
61  TSeqRange total_range(off, seq_len - off);
62  if (no_track) {
64  if (this_proxy.NotNull()) {
65  no_track =
66  this_proxy->GetVisitedRange().IntersectionWith(total_range) == total_range;
67  }
68  }
69  TTrackProxies::const_iterator iter = m_TrackProxies.begin();
70  while(no_track && iter != m_TrackProxies.end()) {
71  no_track = ((*iter)->GetTrack() == NULL);
72  ++iter;
73  }
74  return no_track;
75 }
76 
77 
79 {
80  return m_TypeInfo;
81 }
82 
83 
85 {
86  if (GetTitle().empty()) {
87  return kDefTrackTitle;
88  }
89  return GetTitle();
90 }
91 
92 
94 {
95  // update the visited range by including the previous visited range
96  // if both intersect to each other
97  TSeqRange vis_range = m_Context->GetVisSeqRange();
99  if (this_proxy.NotNull()) {
100  if (vis_range.IntersectingWith(this_proxy->GetVisitedRange())) {
101  vis_range.CombineWith(this_proxy->GetVisitedRange());
102  }
103  this_proxy->SetVisitedRange(vis_range);
104  }
105 
107 }
108 
109 
111 {
112  const TSeqRange& curr_range = m_Context->GetVisSeqRange();
113  // visited range covers the current visible range,
114  // no need to reinitialize the track.
116  if (this_proxy.IsNull() ||
117  this_proxy->GetVisitedRange().IntersectionWith(curr_range) == curr_range) {
118  return;
119  }
120 
121  for (const auto& item : *CSeqFeatData::GetFeatList()) {
122  string storagekey = item.GetStoragekey();
125  continue;
126 
127  CRef<CTempTrackProxy> track_proxy =
128  this_proxy->GetChildTempTrack(item.GetDescription());
129 
131  track_proxy->SetSubkey(storagekey);
132 
133  x_ReinitFeatureTrack(track_proxy);
134  }
135 }
136 
137 void CAllOtherFeaturesTrack::ReinitNASubtracks(TAnnotMetaDataList& annots, bool makeContainersVisible)
138 {
140  if (this_proxy.IsNull())
141  return;
142 
143  for (const auto& item : *CSeqFeatData::GetFeatList()) {
144  string storagekey = item.GetStoragekey();
147  continue;
148 
149  CRef<CTempTrackProxy> track_proxy =
150  this_proxy->GetChildTempTrack(item.GetDescription());
151 
153  track_proxy->SetSubkey(storagekey);
154 
155  x_ReinitNATrack(track_proxy, annots, makeContainersVisible);
156  }
157 }
158 
160 {
161  const string& key = t_proxy->GetKey();
162  const string& subkey = t_proxy->GetSubkey();
163 
165  if (factory) {
166  int depth = GetAnnotLevel();
169  m_DS->CreateTrack("creating " + t_proxy->GetName() + " track",
170  factory, this, t_proxy, params);
171  SetTrackInitDone(false);
172  SetMsg(", Initializing subtracks...");
173  }
174 }
175 
176 ///////////////////////////////////////////////////////////////////////////////
177 /// CAllOtherFeaturesTrackFactory
178 ///////////////////////////////////////////////////////////////////////////////
181  ISGDataSourceContext* ds_context,
182  CRenderingContext* r_cntx,
183  const SExtraParams& params,
184  const TAnnotMetaDataList& /*src_annots*/) const
185 {
186  TTrackMap tracks;
187 
189  ds_context->GetDS(typeid(CFeaturePanelDSType).name(), object);
190  CFeaturePanelDS* fp_ds = dynamic_cast<CFeaturePanelDS*>(ds.GetPointer());
191  fp_ds->SetDSContext(ds_context);
192  fp_ds->SetRenderingContext(r_cntx);
194  tracks[kDefTrackTitle] = track.GetPointer();
195  track->SetAnnotLevel(params.m_Level);
196  track->SetAdaptive(params.m_Adaptive);
197  track->SetSkipGenuineCheck(params.m_SkipGenuineCheck);
198  return tracks;
199 }
200 
201 
203 {
205 }
206 
207 
209 {
211 }
212 
213 
216  const TKeyValuePairs& /*settings*/,
217  const CTempTrackProxy* track_proxy) const
218 {
219  CRef<CTrackConfigSet> config_set(new CTrackConfigSet);
220  if (!track_proxy) {
221  return config_set;
222  }
223  // must be data-independent
224  if (!track_proxy->GetTrack()) {
226  config_set->Set().push_back(config);
227  return config_set;
228  }
229 
230  const CFeatList* feats = CSeqFeatData::GetFeatList();
231  const string& key = CFeatureTrackFactory::GetTypeInfo().GetId();
232  bool shown = track_proxy->GetShown();
233  CFeatureTrackFactory feature_factory;
234 
235  ITERATE (CTempTrackProxy::TTrackProxies, t_iter, track_proxy->GetChildren()) {
236  const CTempTrackProxy* track = *t_iter;
237  if ( !track->GetTrack() ) continue;
238 
239  CRef<CTrackConfigSet> configs;
240  TKeyValuePairs empty_settings;
241  string empty_profile = "";
242  configs = feature_factory.GetSettings(empty_profile, empty_settings, track);
243  CRef<CTrackConfig> config = configs->Set().front();
244  config->SetName() = track->GetName();
245  config->SetKey() = key;
246  config->SetShown() = shown;
247 
248  if (track->GetChildren().size() < 2) {
249  const CFeatureTrack* feat_track =
250  dynamic_cast<const CFeatureTrack*>(track->GetTrack());
251  _ASSERT(feat_track);
252  config->SetSubkey() = feats->GetStoragekey(feat_track->GetFeatSubtype());
253  config->SetAnnots().push_back(track->GetSource());
254  } else {
255  const CFeatureTrack* feat_track =
256  dynamic_cast<const CFeatureTrack*>(track->GetChildren().front()->GetTrack());
257  _ASSERT(feat_track);
258  config->SetSubkey() = feats->GetStoragekey(feat_track->GetFeatSubtype());
260  string annot_name = (*iter)->GetName();
261  if (CSeqUtils::IsNAA(annot_name)) {
262  NStr::ReplaceInPlace(annot_name, "_", ".");
263  }
264  config->SetAnnots().push_back(annot_name);
265  }
266  }
267  config_set->Set().insert(config_set->Set().end(),
268  configs->Get().begin(), configs->Get().end());
269  }
270 
271  return config_set;
272 }
273 
274 
USING_SCOPE(objects)
static const string kDefTrackTitle
virtual string GetExtensionLabel() const
returns a displayable label for this extension ( please capitalize the key words - "My Extension" )
virtual TTrackMap CreateTracks(SConstScopedObject &object, ISGDataSourceContext *ds_context, CRenderingContext *r_cntx, const SExtraParams &params=SExtraParams(), const TAnnotMetaDataList &src_annots=TAnnotMetaDataList()) const
create a layout track based on the input objects and extra parameters.
virtual CRef< objects::CTrackConfigSet > GetSettings(const string &profile, const TKeyValuePairs &settings, const CTempTrackProxy *track_proxy) const
virtual string GetExtensionIdentifier() const
returns the unique human-readable identifier for the extension the id should use lowercase letters se...
virtual const CTrackTypeInfo & GetTypeInfo() const
static CTrackTypeInfo m_TypeInfo
CLayoutTrack required track type info.
CWeakRef< CTrackProxy > m_ThisProxy
track proxy for all other features track.
void x_ReinitFeatureTrack(CTempTrackProxy *t_proxy)
CAllOtherFeaturesTrack(CRenderingContext *r_cntx, CFeaturePanelDS *ds, const set< string > &usedFeatureSubkeys)
virtual void x_ReinitSubtracks()
reinitialize all subtracks if necessary.
virtual void x_OnAllJobsFinished()
actions to take on all job finished.
virtual void ReinitNASubtracks(TAnnotMetaDataList &annots, bool makeContainersVisible)
virtual string GetFullTitle() const
get a more meaningful title.
virtual bool NoSubtrackEver() const
override method in CTrackContainer.
CConfigurableItems - a static list of items that can be configured.
string GetStoragekey(int type, int subtype) const
Get the key used to store this type of feature.
CFeaturePanelDSType.
CFeaturePanelDS.
void CreateTrack(const string &desc, const ILayoutTrackFactory *factory, CTrackContainer *parent, CTempTrackProxy *params, const ILayoutTrackFactory::SExtraParams &extra_param)
void SetDSContext(ISGDataSourceContext *ds_context)
void SetRenderingContext(CRenderingContext *r_cntx)
CFeatureTrackFactory.
static const CTrackTypeInfo & GetTypeInfo()
virtual CRef< objects::CTrackConfigSet > GetSettings(const string &profile, const TKeyValuePairs &settings, const CTempTrackProxy *track_proxy) const
CFeatureTrack –.
int GetFeatSubtype() const
const CLayoutGroup::TObjectList & GetChildren() const
string GetTitle() const
get the track title.
const string & GetId() const
void SetMsg(const string &msg)
CRenderingContext offers the basic context and utility methods for rendering layout objects in featur...
CRef< CSGSequenceDS > GetSeqDS() const
const TSeqRange & GetVisSeqRange() const
TSeqPos GetSequenceLength() const
static const CFeatList * GetFeatList()
CRenderingContext * m_Context
the rendering context
Definition: seq_glyph.hpp:346
File Description:
const string & GetSubkey() const
list< CRef< CTempTrackProxy > > TTrackProxies
const string & GetKey() const
void SetKey(const string &key)
const TTrackProxies & GetChildren() const
const string & GetName() const
const CLayoutTrack * GetTrack() const
const string & GetSource() const
void SetSubkey(const string &sub_key)
const ILayoutTrackFactory * GetTrackFactory(const string &key) const
static bool ValidFeatureTrack(const objects::CFeatListItem &item)
CTrackConfigSet –.
CTrackConfig –.
Definition: TrackConfig.hpp:66
CTrackContainer - a track container in the form of layout track.
CTrackConfigManager * GetConfigMgr()
CRef< CFeaturePanelDS > m_DS
void x_ReinitNATrack(CTempTrackProxy *t_proxy, TAnnotMetaDataList &annots, bool makeContainersVisible)
TTrackProxies m_TrackProxies
all the tracks including on and off.
virtual void x_OnAllJobsFinished()
actions to take on all job finished.
bool GetSkipGenuineCheck() const
CTrackTypeInfo - holds description of a layout track type.
const string & GetDescr() const
const string & GetId() const
CWeakRef –.
Definition: ncbiobj.hpp:2658
ILayoutTrackFactory.
ISGDSManager is seqgraphic data source manage that serves as an data source context.
virtual CIRef< ISGDataSource > GetDS(const string &type, SConstScopedObject &object)=0
Get a seqgraphic data source instance of the specified type.
Definition: map.hpp:338
const_iterator find(const key_type &key) const
Definition: set.hpp:137
const_iterator end() const
Definition: set.hpp:136
struct config config
static unsigned char depth[2 *(256+1+29)+1]
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NULL
Definition: ncbistd.hpp:225
static bool IsNAA(const string &annot, bool isStrict=false)
check if a given annotation is a named annotation accession[.version][number] when isSctrict == false...
Definition: utils.cpp:796
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:998
TRefType Lock(void) const
Lock the object and return reference to it.
Definition: ncbiobj.hpp:2713
bool IntersectingWith(const TThisType &r) const
Definition: range.hpp:331
TThisType & CombineWith(const TThisType &r)
Definition: range.hpp:345
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static string & ReplaceInPlace(string &src, const string &search, const string &replace, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
Definition: ncbistr.cpp:3405
const Tdata & Get(void) const
Get the member data.
Tdata & Set(void)
Assign a value to data member.
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
constexpr bool empty(list< Ts... >) noexcept
const struct ncbi::grid::netcache::search::fields::KEY key
const struct ncbi::grid::netcache::search::fields::SUBKEY subkey
extra parameter for initializing a track.
bool m_Adaptive
Adaptive/Exact selector.
set< string > m_UsedFeatureSubkeys
Already used feature track subkeys To be used by CAllOtherFeaturesTrack container.
int m_Level
layout level that limits feature retrieving used by annotation selector.
bool m_SkipGenuineCheck
Flag indicating if track verification is required.
#define _ASSERT
Modified on Wed Apr 17 13:08:11 2024 by modify_doxy.py rev. 669887