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

Go to the SVN repository for this file.

1 /* $Id: gui_object_info_seq_loc.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 
39 #include <objmgr/util/sequence.hpp>
40 
42 
45 
47 {
48 public:
50 
51  virtual string GetType() const { return "Location"; }
52  virtual string GetSubtype() const { return ""; }
53  virtual string GetLabel() const;
54  virtual void GetToolTip(ITooltipFormatter& tooltip, string& t_title, TSeqPos at_p = (TSeqPos)-1, bool* isGeneratedBySvc = NULL) const;
55  virtual void GetLinks(ITooltipFormatter& /*links*/, bool /*no_ncbi_base*/) const {};
56  virtual string GetIcon() const;
57  virtual string GetViewCategory() const { return "Sequence"; }
58 
59 private:
62 
63  enum ESubtype {
66  kProtein
68 };
69 
71 {
73  typeid(IGuiObjectInfo).name(),
74  CSeq_loc::GetTypeInfo(),
76 }
77 
79  SConstScopedObject& object, ICreateParams* /*params*/)
80 {
82  gui_info->m_Object = object.object;
83  gui_info->m_Scope = object.scope;
84  gui_info->m_Subtype = kUnknown;
85 
86  const CSeq_loc* seqLoc = dynamic_cast<const CSeq_loc*>(object.object.GetPointer());
87  const CSeq_id* seqId = seqLoc->GetId();
88  if (seqId) {
89  try {
90  if (seqId->IsGi())
91  seqId = sequence::GetId(*seqId, *object.scope, sequence::eGetId_Best).GetSeqId();
92 
93  ESubtype subType = kUnknown;
95  if (info == CSeq_id::eAcc_general) {
96  const CSeq_id::TGeneral& gen = seqId->GetGeneral();
97  if (gen.GetDb() == "TRACE_ASSM") {
98  subType = kDNA;
99  }
100  }
101 
102  if (subType == kUnknown) {
103  if (info & CSeq_id::fAcc_nuc)
104  subType = kDNA;
105  else if (info & CSeq_id::fAcc_prot)
106  subType = kProtein;
107  }
108 
109  if (subType == kUnknown) {
110  CBioseq_Handle handle = object.scope->GetBioseqHandle(*seqId);
111  if (handle) {
112  if (handle.IsProtein())
113  subType = kProtein;
114  else if (handle.IsNucleotide())
115  subType = kDNA;
116  }
117  }
118 
119  gui_info->m_Subtype = subType;
120  } NCBI_CATCH("CGuiObjectInfoSeq_loc::CreateObject");
121  }
122 
123  return gui_info;
124 }
125 
127 {
128  switch (m_Subtype) {
129  case kDNA:
130  return "symbol::sequence_id_dna";
131  case kProtein:
132  return "symbol::sequence_id_protein";
133  default:
134  return "symbol::sequence_id";
135  }
136 }
137 
139 {
140  string label;
142  return label;
143 }
144 
145 void CGuiObjectInfoSeq_loc::GetToolTip(ITooltipFormatter& tooltip, string& /*t_title*/, TSeqPos /*at_p*/, bool* isGeneratedBySvc) const
146 {
147  if(isGeneratedBySvc) {
148  *isGeneratedBySvc = false;
149  }
150  string t_text;
152  tooltip.AddRow(t_text);
153 }
154 
CBioseq_Handle –.
Definition: Dbtag.hpp:53
CRef< objects::CScope > m_Scope
static CGuiObjectInfoSeq_loc * CreateObject(SConstScopedObject &object, ICreateParams *params)
virtual string GetViewCategory() const
To share default view between different types.
enum CGuiObjectInfoSeq_loc::ESubtype m_Subtype
virtual string GetIcon() const
virtual string GetSubtype() const
virtual string GetLabel() const
virtual void GetLinks(ITooltipFormatter &, bool) const
Get a set of links.
virtual string GetType() const
virtual void GetToolTip(ITooltipFormatter &tooltip, string &t_title, TSeqPos at_p=(TSeqPos) -1, bool *isGeneratedBySvc=NULL) const
Get tooltip.
CConstRef< CObject > m_Object
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
EAccessionInfo
For IdentifyAccession (below)
Definition: Seq_id.hpp:220
@ fAcc_prot
Definition: Seq_id.hpp:252
@ eAcc_general
Definition: Seq_id.hpp:444
@ fAcc_nuc
Definition: Seq_id.hpp:251
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
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
#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_loc()
static MDB_envinfo info
Definition: mdb_load.c:37
Modified on Sun Jun 23 05:19:09 2024 by modify_doxy.py rev. 669887