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

Go to the SVN repository for this file.

1 /* $Id: component_track.cpp 34291 2015-12-08 23:38:49Z rudnev $
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  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 
38 
41 
42 
43 ///////////////////////////////////////////////////////////////////////////////
44 /// CComponentTrack
45 ///////////////////////////////////////////////////////////////////////////////
46 
48  "Component track");
49 
50 static string kDefTrackTitle = "Component Map";
51 
53  : CSegmentMapTrack(ds, r_cntx)
54 {}
55 
56 
58 {}
59 
60 
62 {
63  return m_TypeInfo;
64 }
65 
66 
68 {
69  if (GetTitle().empty()) {
70  return kDefTrackTitle;
71  }
72  return GetTitle();
73 }
74 
75 
76 ///////////////////////////////////////////////////////////////////////////////
77 /// CComponentTrackFactory
78 ///////////////////////////////////////////////////////////////////////////////
81  ISGDataSourceContext* ds_context,
82  CRenderingContext* r_cntx,
83  const SExtraParams& params,
84  const TAnnotMetaDataList& /*src_annots*/) const
85 {
86  TTrackMap tracks;
87  CIRef<ISGDataSource> ds = ds_context->GetDS(
88  typeid(CSGSegmentMapDSType).name(), object);
89  CSGSegmentMapDS* segment_ds = dynamic_cast<CSGSegmentMapDS*>(ds.GetPointer());
90  bool is_chromosome = x_IsChromosome(*segment_ds);
91  segment_ds->SetChromosome(is_chromosome);
92 
93  if ( !params.m_Adaptive ) {
94  // In Multi-level layout mode, we need to check if this is
95  // the right level to show the component map.
96 
97  // For multi-level layout, we move segment map one level down.
98  // So we will show level 0 segments (scaffolds) at level 1, and
99  // show leve 1 segments (components) at level 2, and there is
100  // no segment map shown at level 0.
101  if ((is_chromosome && params.m_Level != 2) ||
102  (!is_chromosome && params.m_Level != 1)) {
103  return tracks;
104  }
105  }
106 
107 
109 
110  TSeqRange range = params.m_Range;
111  if (range.Empty()) {
112  range = r_cntx->GetVisSeqRange();
113  }
114  if (range.IsWhole()) {
115  CRef<CSGSequenceDS> seq_ds = r_cntx->GetSeqDS();
116  range.Set(0, seq_ds->GetSequenceLength() - 1);
117  }
118 
119  if (params.m_SkipGenuineCheck || segment_ds->HasComponent(range)) {
120  CRef<CComponentTrack> track(new CComponentTrack(segment_ds, r_cntx));
121  tracks[kDefTrackTitle] = track.GetPointer();
122  }
123  return tracks;
124 }
125 
126 
128 {
130 }
131 
132 
134 {
136 }
137 
138 
140 CComponentTrackFactory::GetSettings(const string& /*profile*/,
141  const TKeyValuePairs& settings,
142  const CTempTrackProxy* track_proxy) const
143 {
144  /// no setting to report
145  CRef<CTrackConfigSet> config_set(new CTrackConfigSet);
147  config_set->Set().push_back(config);
148  config->SetHelp() = "The GenBank sequences are shown in the order that "
149  "they contribute to the assembly. Colors are as follows:<br> Blue:finished sequence<br>"
150  "Orange:Draft sequence<br>Green:WGS<br>Gray:Other<br>Black:Gap<br>"
151  "Beige:Sequence overlap not used to generate chromosome sequence.";
152  config->SetLegend_text("anchor_9");
153  return config_set;
154 }
155 
156 
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 string GetExtensionLabel() const
returns a displayable label for this extension ( please capitalize the key words - "My Extension" )
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...
CComponentTrack –.
static CTrackTypeInfo m_TypeInfo
CComponentTrack.
virtual string GetFullTitle() const
get a more meaningful title.
CComponentTrack(CSGSegmentMapDS *ds, CRenderingContext *r_cntx)
virtual ~CComponentTrack()
virtual const CTrackTypeInfo & GetTypeInfo() const
string GetTitle() const
get the track title.
CRenderingContext offers the basic context and utility methods for rendering layout objects in featur...
CRef< CSGSequenceDS > GetSeqDS() const
const TSeqRange & GetVisSeqRange() const
CSGFeatureDSType.
CSGSegmentMapDS.
bool HasComponent(const TSeqRange &range) const
void SetSegmentLevel(ESegmentLevel level)
Set which segment level to show.
void SetChromosome(bool flag)
TSeqPos GetSequenceLength() const
bool x_IsChromosome(CSGSegmentMapDS &ds) const
CSegmentMapTrack –.
File Description:
CTrackConfigSet –.
CTrackConfig –.
Definition: TrackConfig.hpp:66
CTrackTypeInfo - holds description of a layout track type.
const string & GetDescr() const
const string & GetId() const
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.
USING_SCOPE(objects)
static string kDefTrackTitle
struct config config
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:998
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
Tdata & Set(void)
Assign a value to data member.
range(_Ty, _Ty) -> range< _Ty >
constexpr bool empty(list< Ts... >) noexcept
extra parameter for initializing a track.
bool m_Adaptive
Adaptive/Exact selector.
int m_Level
layout level that limits feature retrieving used by annotation selector.
TSeqRange m_Range
The requested range we want to look at.
bool m_SkipGenuineCheck
Flag indicating if track verification is required.
Modified on Mon May 27 04:39:25 2024 by modify_doxy.py rev. 669887