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

Go to the SVN repository for this file.

1 /* $Id: gui_object_info_seq_id.cpp 41372 2018-07-18 20:45:38Z 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: Roman Katargin
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 
36 #include <gui/objutils/label.hpp>
37 #include <gui/objutils/tooltip.hpp>
38 #include <objmgr/util/sequence.hpp>
39 
41 
44 
46 {
47 public:
49 
50  virtual string GetType() const { return "Sequence ID"; }
51  virtual string GetSubtype() const;
52  virtual string GetLabel() const;
53  virtual void GetToolTip(ITooltipFormatter& tooltip, string& t_title, TSeqPos at_p = (TSeqPos)-1, bool* isGeneratedBySvc = NULL) const;
54  virtual void GetLinks(ITooltipFormatter& /*links*/, bool /*no_ncbi_base*/) const {};
55  virtual string GetIcon() const;
56  virtual string GetViewCategory() const { return "Sequence"; }
57 
58 private:
61 
62  enum ESubtype {
65  kProtein
67 };
68 
70 {
72  typeid(IGuiObjectInfo).name(),
73  CSeq_id::GetTypeInfo(),
75 }
76 
78  SConstScopedObject& object, ICreateParams* /*params*/)
79 {
81  gui_info->m_Object = object.object;
82  gui_info->m_Scope = object.scope;
83 
84  const CSeq_id* seq_id_ptr = dynamic_cast<const CSeq_id*>(object.object.GetPointer());
85  if (seq_id_ptr->IsGi()) {
86  CSeq_id_Handle seh;
87 
88  try {
89  seh = sequence::GetId(*seq_id_ptr, *object.scope, sequence::eGetId_Best);
90  } NCBI_CATCH("CGuiObjectInfoSeq_id::CreateObject");
91 
92  if (seh)
93  seq_id_ptr = seh.GetSeqId();
94  }
95 
96  ESubtype subType = kUnknown;
98  if (info == CSeq_id::eAcc_general) {
99  const CSeq_id::TGeneral& gen = seq_id_ptr->GetGeneral();
100  if (gen.GetDb() == "TRACE_ASSM") {
101  subType = kDNA;
102  }
103  }
104 
105  if (subType == kUnknown) {
106  if (info & CSeq_id::fAcc_nuc)
107  subType = kDNA;
108  else if (info & CSeq_id::fAcc_prot)
109  subType = kProtein;
110  }
111 
112  if (subType == kUnknown) {
113  CBioseq_Handle handle;
114 
115  try {
116  handle = object.scope->GetBioseqHandle(*seq_id_ptr);
117  } NCBI_CATCH("CGuiObjectInfoSeq_id::CreateObject");
118 
119  if (handle) {
120  if (handle.IsProtein())
121  subType = kProtein;
122  else if (handle.IsNucleotide())
123  subType = kDNA;
124  }
125  }
126 
127  gui_info->m_Subtype = subType;
128 
129  return gui_info.Release();
130 }
131 
133 {
134  switch(m_Subtype) {
135  case kDNA:
136  return "DNA";
137  case kProtein:
138  return "Protein";
139  default:
140  return "";
141  }
142 }
143 
145 {
146  switch(m_Subtype) {
147  case kDNA:
148  return "symbol::sequence_id_dna";
149  case kProtein:
150  return "symbol::sequence_id_protein";
151  default:
152  return "symbol::sequence_id";
153  }
154 }
155 
157 {
158  string label;
160  return label;
161 }
162 
163 void CGuiObjectInfoSeq_id::GetToolTip(ITooltipFormatter& tooltip, string& /*t_title*/, TSeqPos /*at_p*/, bool* isGeneratedBySvc) const
164 {
165  if(isGeneratedBySvc) {
166  *isGeneratedBySvc = false;
167  }
168  string t_text;
170  tooltip.AddRow(t_text);
171 }
172 
CBioseq_Handle –.
Definition: Dbtag.hpp:53
CRef< objects::CScope > m_Scope
virtual void GetLinks(ITooltipFormatter &, bool) const
Get a set of links.
virtual string GetLabel() const
virtual void GetToolTip(ITooltipFormatter &tooltip, string &t_title, TSeqPos at_p=(TSeqPos) -1, bool *isGeneratedBySvc=NULL) const
Get tooltip.
virtual string GetType() const
CConstRef< CObject > m_Object
enum CGuiObjectInfoSeq_id::ESubtype m_Subtype
virtual string GetViewCategory() const
To share default view between different types.
static CGuiObjectInfoSeq_id * CreateObject(SConstScopedObject &object, ICreateParams *params)
virtual string GetSubtype() const
virtual string GetIcon() const
static void RegisterFactory(const string &interface_name, IInterfaceFactory *factory)
CObject –.
Definition: ncbiobj.hpp:180
primitive interface to arrange tabular data in the tooltips
Definition: tooltip.hpp:55
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define NULL
Definition: ncbistd.hpp:225
#define NCBI_CATCH(message)
Catch CExceptions as well This macro is deprecated - use *_X or *_XX variant instead of it.
Definition: ncbiexpt.hpp:580
static void GetLabel(const CObject &obj, string *label, ELabelType type=eDefault)
Definition: label.cpp:140
virtual void AddRow(const string &sContents="", unsigned colspan=2)=0
add a row with a cell, spanning across all columns
@ eDescriptionBrief
Definition: label.hpp:67
static EAccessionInfo IdentifyAccession(const CTempString &accession, TParseFlags flags=fParse_AnyRaw)
Deduces information from a bare accession a la WHICH_db_accession; may report false negatives on prop...
Definition: Seq_id.cpp:1634
CConstRef< CSeq_id > GetSeqId(void) const
EAccessionInfo
For IdentifyAccession (below)
Definition: Seq_id.hpp:220
@ fAcc_prot
Definition: Seq_id.hpp:227
@ eAcc_general
Definition: Seq_id.hpp:413
@ fAcc_nuc
Definition: Seq_id.hpp:226
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,...
@ eGetId_Best
return the "best" gi (uses FindBestScore(), with CSeq_id::CalculateScore() as the score function
Definition: sequence.hpp:101
bool IsNucleotide(void) const
bool IsProtein(void) const
TObjectType * Release(void)
Release a reference to the object and return a pointer to the object.
Definition: ncbiobj.hpp:846
#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 const char label[]
const TGeneral & GetGeneral(void) const
Get the variant data.
Definition: Seq_id_.cpp:369
bool IsGi(void) const
Check if variant Gi is selected.
Definition: Seq_id_.hpp:883
USING_SCOPE(objects)
void initCGuiObjectInfoSeq_id()
static MDB_envinfo info
Definition: mdb_load.c:37
Modified on Fri Dec 01 04:49:31 2023 by modify_doxy.py rev. 669887