NCBI C++ ToolKit
seqgraphic_genbank_ds.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_SEQ_GRAPHIC___SEQGRAPHIC_GENBANK_DS__HPP
2 #define GUI_WIDGETS_SEQ_GRAPHIC___SEQGRAPHIC_GENBANK_DS__HPP
3 
4 /* $Id: seqgraphic_genbank_ds.hpp 38204 2017-04-10 20:46:50Z rudnev $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Vlad Lebedev, Liangshou Wu
30  *
31  * File Description:
32  *
33  */
34 
35 #include <corelib/ncbimtx.hpp>
36 #include <objmgr/bioseq_handle.hpp>
37 #include <objmgr/seq_vector.hpp>
38 
39 #include <gui/gui_export.h>
41 #include <gui/utils/extension.hpp>
42 
45 
46 
48 
49 ///////////////////////////////////////////////////////////////////////////////
50 /// CSGGenBankDS
51 ///
53  public CSGDataSource
54 {
55 public:
57  typedef int TJobToken;
58 
59  CSGGenBankDS(objects::CScope& scope, const objects::CSeq_id& id);
60 
61  virtual ~CSGGenBankDS();
62 
63  bool IsRefSeq() const;
64 
65  /// Set the annotation selector resolving depth.
66  void SetDepth(int depth);
67  int GetDepth() const;
68 
69  void SetAdaptive(bool flag);
70  bool GetAdaptive() const;
71 
72  /// Get the underlying bioseq handle.
73  objects::CBioseq_Handle& GetBioseqHandle(void);
74 
75  const objects::CBioseq_Handle& GetBioseqHandle(void) const;
76 
77  /// Get the scope from the handle.
78  objects::CScope& GetScope(void) const;
79 
80  /// Set JobDispatcher listener.
81  void SetJobListener(CEventHandler* listener);
82 
83  virtual void ClearJobID(TJobID job_id);
84  bool IsJobNeeded(TJobID job_id) const;
85  virtual bool AllJobsFinished() const;
86  /// Remove waiting jobs from queue or cancel the unfinished jobs.
87  virtual void DeleteAllJobs();
88 
89  void SetCoordMapper(ICoordMapper* mapper);
90 
91  /// @name help methods about coverage graph levels.
92  /// @{
93  /// Return the nearest level available for a given zoom level.
94  /// @param zoom is measured as number of bases per screen pixel
95  /// Initialize levels on which coverage graphs are avaiable.
96  /// @param annot the original annotation name
97  void SetGraphLevels(const string& annot);
98  /// @}
99 
100 protected:
101 
102  void x_ForegroundJob(IAppJob& job);
103 
104  /// Jobs on thread pool.
105  TJobID x_BackgroundJob(IAppJob& job, int report_period, const string& pool);
106 
107  /// Launch either a background or foreground job.
108  /// The pool is used only for background jobs.
109  TJobID x_LaunchJob(IAppJob& job, int report_period = 1,
110  const string& pool = "ObjManagerEngine");
111 
112 private:
113  /// @name Forbidden methods
114  /// @{
117  /// @}
118 
119 protected:
120 
122 
123  objects::CBioseq_Handle m_Handle;
124  CEventHandler* m_JobListener; ///< our listener to JobDispatcher events
125  vector<TJobID> m_ActiveJobs; ///< all currently active jobs for this DS
126  int m_Depth; ///< annotation resolving depth
127  bool m_Adaptive; ///< adaptive/exact annot selector
128  /// coordinate mapper between mapped features coord. and sequence coord.
130 
131  /// Existing coverage graph levels.
132  /// There is a feature in ID2 to store multiple zoom level
133  /// representations for the same annotation track. This is
134  /// used to avoid retrieving all the annotation details while
135  /// exploring data at a high level. Viewer should be able to
136  /// decide data for what zoom level to request depending on
137  /// its current resolution.
138  /// m_GraphLevels stores a list of available zoom levels
139  /// sorted from low to high.
141 };
142 
143 
144 ///////////////////////////////////////////////////////////////////////////////
145 /// CSGSequenceDS
146 ///
148  public CObjectEx,
149  public ISGDataSource
150 {
151 public:
152  CSGSequenceDS(objects::CScope& scope, const objects::CSeq_id& id);
153  virtual ~CSGSequenceDS();
154 
155  /// Get the underlying bioseq handle.
156  objects::CBioseq_Handle GetBioseqHandle(void) const;
157 
158  objects::CSeq_id_Handle GetBestIdHandle() const;
159 
160  /// Get the scope from the handle.
161  objects::CScope& GetScope(void) const;
162 
163  const objects::CSeqVector& GetSeqVector(void) const;
164 
165  TSeqPos GetSequenceLength() const;
166 
167  /// retrieve a string representing the IUPAC characters for the sequence [from to].
168  void GetSequence(TSeqPos from, TSeqPos to, string& buffer) const;
169 
170  string GetTitle() const;
171 
172  /// this is more suitable for display purposes since the returned string will not always be good
173  /// to reconstruct the CSeq_id back (in case of gnl| or lcl|, see SV-2982)
174  string GetAcc_Best() const;
175  /// all accession info we can get in FASTA format
176  string GetAcc_All() const;
177 
178  bool IsAccGenomic(objects::CSeq_id::EAccessionInfo acc_info) const;
179  bool IsTraceAssembly() const;
180  bool IsPopSet() const;
181  bool IsRefSeq() const;
182  bool IsRefSeqGene() const;
183 
184 
185 private:
186  objects::CBioseq_Handle m_Handle;
187  objects::CSeq_id_Handle m_Best_idh; ///< best id handle (obtained with sequence::GetId(..., sequence::eGetId_Best))
189 };
190 
191 ///////////////////////////////////////////////////////////////////////////////
192 /// CSGSequenceDSType
193 ///
195  public CObject,
196  public ISGDataSourceType,
197  public IExtension
198 {
199 public:
200  /// create an instance of the layout track type using default settings.
201  virtual ISGDataSource* CreateDS(SConstScopedObject& object) const;
202 
203  /// @name IExtension interface implementation
204  /// @{
205  virtual string GetExtensionIdentifier() const;
206  virtual string GetExtensionLabel() const;
207  /// @}
208 
209  /// check if the data source can be shared.
210  virtual bool IsSharable() const;
211 };
212 
213 
214 ///////////////////////////////////////////////////////////////////////////////
215 // CSGGenBankDS inline methods
216 ///
217 inline
219 {
220  m_Depth = depth;
221 }
222 
223 inline
225 {
226  return m_Depth;
227 }
228 
229 inline
231 {
232  m_Adaptive = flag;
233 }
234 
235 inline
237 {
238  return m_Adaptive;
239 }
240 
241 inline
242 objects::CBioseq_Handle& CSGGenBankDS::GetBioseqHandle(void)
243 {
244  return m_Handle;
245 }
246 
247 inline
248 const objects::CBioseq_Handle& CSGGenBankDS::GetBioseqHandle(void) const
249 {
250  return m_Handle;
251 }
252 
253 inline
254 objects::CScope& CSGGenBankDS::GetScope(void) const
255 {
256  return m_Handle.GetScope();
257 }
258 
259 inline
261 {
262  m_JobListener = listener;
263 }
264 
265 inline
267 {
268  return find(m_ActiveJobs.begin(), m_ActiveJobs.end(), job_id)
269  != m_ActiveJobs.end();
270 }
271 
272 inline
274 {
275  return m_ActiveJobs.empty();
276 }
277 
278 inline
280 {
281  m_Mapper.Reset(mapper);
282 }
283 
284 
285 ///////////////////////////////////////////////////////////////////////////////
286 // CSGSequenceDS inline methods
287 ///
288 inline
289 objects::CBioseq_Handle CSGSequenceDS::GetBioseqHandle(void) const
290 {
291  return m_Handle;
292 }
293 
294 inline
295 objects::CSeq_id_Handle CSGSequenceDS::GetBestIdHandle() const
296 {
297  return m_Best_idh;
298 }
299 
300 inline
301 objects::CScope& CSGSequenceDS::GetScope(void) const
302 {
303  return m_Handle.GetScope();
304 }
305 
306 
307 inline
308 const objects::CSeqVector& CSGSequenceDS::GetSeqVector(void) const
309 {
310  return *m_SeqVector;
311 }
312 
313 inline
315 {
316  return m_Handle.GetBioseqLength();
317 }
318 
319 
321 
322 #endif /* GUI_WIDGETS_SEQ_GRAPHIC___SEQGRAPHIC_GENBANK_DS__HPP */
CEventHandler.
CObjectEx –.
Definition: ncbiobj.hpp:2531
CObject –.
Definition: ncbiobj.hpp:180
Default seqgraphic data source implementation.
CIRef< ICoordMapper > m_Mapper
coordinate mapper between mapped features coord. and sequence coord.
bool IsJobNeeded(TJobID job_id) const
bool m_Adaptive
adaptive/exact annot selector
int m_Depth
annotation resolving depth
bool GetAdaptive() const
vector< TJobID > m_ActiveJobs
all currently active jobs for this DS
CAppJobDispatcher::TJobID TJobID
void SetCoordMapper(ICoordMapper *mapper)
objects::CScope & GetScope(void) const
Get the scope from the handle.
virtual bool AllJobsFinished() const
CSGGenBankDS(objects::CScope &scope, const objects::CSeq_id &id)
CSGGenBankDS & operator=(const CSGGenBankDS &)
CEventHandler * m_JobListener
our listener to JobDispatcher events
void SetJobListener(CEventHandler *listener)
Set JobDispatcher listener.
objects::CBioseq_Handle & GetBioseqHandle(void)
Get the underlying bioseq handle.
void SetDepth(int depth)
Set the annotation selector resolving depth.
TGraphLevels m_GraphLevels
Existing coverage graph levels.
objects::CBioseq_Handle m_Handle
CSGGenBankDS(const CSGGenBankDS &)
void SetAdaptive(bool flag)
CRef< objects::CSeqVector > m_SeqVector
objects::CScope & GetScope(void) const
Get the scope from the handle.
TSeqPos GetSequenceLength() const
const objects::CSeqVector & GetSeqVector(void) const
objects::CBioseq_Handle m_Handle
objects::CBioseq_Handle GetBioseqHandle(void) const
Get the underlying bioseq handle.
objects::CSeq_id_Handle m_Best_idh
best id handle (obtained with sequence::GetId(..., sequence::eGetId_Best))
objects::CSeq_id_Handle GetBestIdHandle() const
IAppJob.
Definition: app_job.hpp:82
ICoordMapper interface for converting location between two coordinate systems.
IExtension IExtension interface represents an abstract pluggable component.
Definition: extension.hpp:57
ISGDataSourceFactory.
File Description:
static unsigned char depth[2 *(256+1+29)+1]
SBlastSequence GetSequence(const objects::CSeq_loc &sl, EBlastEncoding encoding, objects::CScope *scope, objects::ENa_strand strand=objects::eNa_strand_plus, ESentinelType sentinel=eSentinels, std::string *warnings=NULL)
Retrieves a sequence using the object manager.
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
NCBI_XOBJUTIL_EXPORT string GetTitle(const CBioseq_Handle &hnd, TGetTitleFlags flags=0)
Definition: seqtitle.cpp:106
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_GUIWIDGETS_SEQGRAPHIC_EXPORT
Definition: gui_export.h:536
Defines to provide correct exporting from DLLs in Windows.
static bool IsRefSeqGene(const CBioseq_Handle &bsh)
Multi-threading – mutexes; rw-locks; semaphore.
static uint8_t * buffer
Definition: pcre2test.c:1016
CScope & GetScope()
Modified on Wed Sep 04 15:00:19 2024 by modify_doxy.py rev. 669887