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

Go to the SVN repository for this file.

1 #ifndef SEQREF__HPP_INCLUDED
2 #define SEQREF__HPP_INCLUDED
3 /* */
4 
5 /* $Id: seqref.hpp 93710 2021-05-14 15:54:29Z vasilche $
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 * Author: Eugene Vasilchenko
29 *
30 * File Description: Base data reader interface
31 *
32 */
33 
34 #include <corelib/ncbiobj.hpp>
36 #include <utility>
37 #include <string>
38 
41 
43 {
44 public:
45  enum EBlobFlags {
46  fPossible = 1 << 16,
47  fPrivate = 1 << 17
48  };
50 
51  enum ESat {
52  eSat_ANNOT_CDD = 10,
53  eSat_ANNOT = 26,
54  eSat_TRACE = 28,
55  eSat_TRACE_ASSM = 29,
56  eSat_TR_ASSM_CH = 30,
57  eSat_TRACE_CHGR = 31
58  };
59 
60  enum ESubSat {
61  eSubSat_main = 0,
62  eSubSat_SNP = 1<<0,
63  eSubSat_SNP_graph = 1<<2,
64  eSubSat_CDD = 1<<3,
65  eSubSat_MGC = 1<<4,
66  eSubSat_HPRD = 1<<5,
67  eSubSat_STS = 1<<6,
68  eSubSat_tRNA = 1<<7,
69  eSubSat_microRNA = 1<<8,
70  eSubSat_Exon = 1<<9
71  };
72  typedef Int4 TSat;
73  typedef Int4 TSubSat;
74  typedef Int4 TSatKey;
75  typedef Int4 TVersion;
76 
77  CSeqref(void);
78  CSeqref(TGi gi, TSat sat, TSatKey satkey);
79  CSeqref(TGi gi, TSat sat, TSatKey satkey, TSubSat subsat, TFlags flags);
80  virtual ~CSeqref(void);
81 
82  const string print(void) const;
83  const string printTSE(void) const;
84  typedef pair<pair<TSat, TSubSat>, TSatKey> TKeyByTSE;
85  static const string printTSE(const TKeyByTSE& key);
86 
87  TGi GetGi() const
88  {
89  return m_Gi;
90  }
91  TSat GetSat() const
92  {
93  return m_Sat;
94  }
96  {
97  return m_SubSat;
98  }
100  {
101  return m_SatKey;
102  }
103 
104  TKeyByTSE GetKeyByTSE(void) const
105  {
106  return TKeyByTSE(pair<TSat, TSubSat>(m_Sat, m_SubSat), m_SatKey);
107  }
108 
109  bool SameTSE(const CSeqref& seqRef) const
110  {
111  return
112  m_Sat == seqRef.m_Sat &&
113  m_SubSat == seqRef.m_SubSat &&
114  m_SatKey == seqRef.m_SatKey;
115  }
116  bool SameSeq(const CSeqref& seqRef) const
117  {
118  return m_Gi == seqRef.m_Gi && SameTSE(seqRef);
119  }
120  bool LessByTSE(const CSeqref& seqRef) const
121  {
122  if ( m_Sat != seqRef.m_Sat ) {
123  return m_Sat < seqRef.m_Sat;
124  }
125  if ( m_SubSat != seqRef.m_SubSat ) {
126  return m_SubSat < seqRef.m_SubSat;
127  }
128  return m_SatKey < seqRef.m_SatKey;
129  }
130  bool LessBySeq(const CSeqref& seqRef) const
131  {
132  if ( m_Gi != seqRef.m_Gi ) {
133  return m_Gi < seqRef.m_Gi;
134  }
135  return LessByTSE(seqRef);
136  }
137  bool operator<(const CSeqref& seqRef) const
138  {
139  if ( GetSat() != seqRef.GetSat() )
140  return GetSat() < seqRef.GetSat();
141  if ( GetSatKey() != seqRef.GetSatKey() )
142  return GetSatKey() < seqRef.GetSatKey();
143  return GetVersion() < seqRef.GetVersion();
144  }
145 
146  TFlags GetFlags(void) const
147  {
148  return m_Flags;
149  }
151  {
152  m_Flags = flags;
153  }
154 
155  bool IsEmpty(void) const
156  {
157  return m_Sat < 0 && m_SatKey < 0;
158  }
159 
160  bool IsMainBlob(void) const
161  {
162  return (GetFlags() & fBlobHasCore) != 0;
163  }
164 
165  TVersion GetVersion(void) const
166  {
167  return m_Version;
168  }
170  {
171  m_Version = version;
172  }
173 
174 protected:
176 
179  TSubSat m_SubSat; // external features mask
182 };
183 
184 
187 
188 #endif//SEQREF__HPP_INCLUDED
CObject –.
Definition: ncbiobj.hpp:180
bool LessBySeq(const CSeqref &seqRef) const
Definition: seqref.hpp:130
TSubSat m_SubSat
Definition: seqref.hpp:179
EBlobFlags
Definition: seqref.hpp:45
pair< pair< TSat, TSubSat >, TSatKey > TKeyByTSE
Definition: seqref.hpp:84
TBlobContentsMask TFlags
Definition: seqref.hpp:49
TSatKey m_SatKey
Definition: seqref.hpp:180
bool SameSeq(const CSeqref &seqRef) const
Definition: seqref.hpp:116
bool IsEmpty(void) const
Definition: seqref.hpp:155
bool IsMainBlob(void) const
Definition: seqref.hpp:160
TFlags GetFlags(void) const
Definition: seqref.hpp:146
TGi m_Gi
Definition: seqref.hpp:177
Int4 TSat
Definition: seqref.hpp:72
void SetVersion(TVersion version)
Definition: seqref.hpp:169
TGi GetGi() const
Definition: seqref.hpp:87
bool SameTSE(const CSeqref &seqRef) const
Definition: seqref.hpp:109
Int4 TSubSat
Definition: seqref.hpp:73
TVersion m_Version
Definition: seqref.hpp:181
void SetFlags(TFlags flags)
Definition: seqref.hpp:150
bool LessByTSE(const CSeqref &seqRef) const
Definition: seqref.hpp:120
TSubSat GetSubSat() const
Definition: seqref.hpp:95
TVersion GetVersion(void) const
Definition: seqref.hpp:165
Int4 TSatKey
Definition: seqref.hpp:74
bool operator<(const CSeqref &seqRef) const
Definition: seqref.hpp:137
TSatKey GetSatKey() const
Definition: seqref.hpp:99
TFlags m_Flags
Definition: seqref.hpp:175
TKeyByTSE GetKeyByTSE(void) const
Definition: seqref.hpp:104
Int4 TVersion
Definition: seqref.hpp:75
TSat m_Sat
Definition: seqref.hpp:178
TSat GetSat() const
Definition: seqref.hpp:91
static uch flags
int32_t Int4
4-byte (32-bit) signed integer
Definition: ncbitype.h:102
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
#define NCBI_XREADER_EXPORT
Definition: ncbi_export.h:1371
static int version
Definition: mdb_load.c:29
const struct ncbi::grid::netcache::search::fields::KEY key
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
int TBlobContentsMask
Definition: blob_id.hpp:188
@ fBlobHasCore
Definition: blob_id.hpp:141
Modified on Thu Dec 07 10:12:11 2023 by modify_doxy.py rev. 669887