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

Go to the SVN repository for this file.

1 /* $Id: fingp_seqid.cpp 27635 2013-03-15 19:33:00Z katargir@NCBI.NLM.NIH.GOV $
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
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 #include <util/checksum.hpp>
35 
39 
44 
47 
49  CChecksum& checksum, const CObject& object,
50  CScope* /*scope*/, const CObjFingerprint&)
51 {
52  _ASSERT(dynamic_cast<const CObject_id*>(&object));
53  const CObject_id& obj = static_cast<const CObject_id&>(object);
54 
55  CObject_id::E_Choice choice = obj.Which();
56  CKSUM_ADD_INTEGER(checksum, choice);
57  switch(choice) {
58  case CObject_id::e_Id:
59  {
60  CObject_id::TId id = obj.GetId();
61  CKSUM_ADD_INTEGER(checksum, id);
62  }
63  break;
64  case CObject_id::e_Str:
65  checksum.AddLine(obj.GetStr());
66  break;
68  break;
69  }
70 }
71 
72 static void s_Fingerprint_Dbtag(
73  CChecksum& checksum, const CObject& object,
74  CScope* scope, const CObjFingerprint& fingerP)
75 {
76  _ASSERT(dynamic_cast<const CDbtag*>(&object));
77  const CDbtag& obj = static_cast<const CDbtag&>(object);
78 
79  checksum.AddLine(obj.GetDb());
80  fingerP.Fingerprint(checksum, obj.GetTag(), scope);
81 }
82 
84  CChecksum& checksum, const CObject& object,
85  CScope* /*scope*/, const CObjFingerprint&)
86 {
87  _ASSERT(dynamic_cast<const CGiimport_id*>(&object));
88  const CGiimport_id& obj = static_cast<const CGiimport_id&>(object);
89 
90  CGiimport_id::TId id = obj.GetId();
91  CKSUM_ADD_INTEGER(checksum, id);
92 
93  if (obj.IsSetDb())
94  checksum.AddLine(obj.GetDb());
95  if (obj.IsSetRelease())
96  checksum.AddLine(obj.GetRelease());
97 }
98 
100  CChecksum& checksum, const CObject& object,
101  CScope* /*scope*/, const CObjFingerprint&)
102 {
103  _ASSERT(dynamic_cast<const CTextseq_id*>(&object));
104  const CTextseq_id& obj = static_cast<const CTextseq_id&>(object);
105 
106  if (obj.IsSetAccession())
107  checksum.AddLine(obj.GetAccession());
108  if (obj.IsSetRelease())
109  checksum.AddLine(obj.GetRelease());
110 
112  CKSUM_ADD_INTEGER(checksum, version);
113 }
114 
116  CChecksum& checksum, const CObject& object,
117  CScope* /*scope*/, const CObjFingerprint&)
118 {
119  _ASSERT(dynamic_cast<const CPatent_seq_id*>(&object));
120  const CPatent_seq_id& obj = static_cast<const CPatent_seq_id&>(object);
121 
122  const CId_pat& cit = obj.GetCit();
123 
124  checksum.AddLine(cit.GetCountry());
125 
126  const CId_pat::C_Id& id = cit.GetId();
127  CId_pat::C_Id::E_Choice choice = id.Which();
128  CKSUM_ADD_INTEGER(checksum, choice);
129 
130  switch(choice) {
132  checksum.AddLine(id.GetNumber());
133  break;
135  checksum.AddLine(id.GetApp_number());
136  break;
138  break;
139  }
140 
141  CPatent_seq_id::TSeqid seqid = obj.GetSeqid();
142  CKSUM_ADD_INTEGER(checksum, seqid);
143 }
144 
146  CChecksum& checksum, const CObject& object,
147  CScope* /*scope*/, const CObjFingerprint&)
148 {
149  _ASSERT(dynamic_cast<const CPDB_seq_id*>(&object));
150  const CPDB_seq_id& obj = static_cast<const CPDB_seq_id&>(object);
151 
152  checksum.AddLine(obj.GetMol());
153  CPDB_seq_id::TChain chain = obj.GetChain();
154  CKSUM_ADD_INTEGER(checksum, chain);
155 }
156 
158  CChecksum& checksum, const CObject& object,
159  CScope* scope, const CObjFingerprint& fingerP)
160 {
161  _ASSERT(dynamic_cast<const CSeq_id*>(&object));
162  CSeq_id_Handle idh;
163  {{
164  const CSeq_id& obj = static_cast<const CSeq_id&>(object);
166  }}
167  if ( !idh ) return;
168 
169  CConstRef<CSeq_id> seq_id = idh.GetSeqId();
170  const CSeq_id& obj = *seq_id;
171 
172  CSeq_id::E_Choice choice = obj.Which();
173  CKSUM_ADD_INTEGER(checksum, choice);
174 
175  switch(choice) {
176  case CSeq_id::e_Local:
177  s_Fingerprint_Object_id(checksum, obj.GetLocal(), scope, fingerP);
178  break;
179  case CSeq_id::e_Gibbsq:
180  {
182  CKSUM_ADD_INTEGER(checksum, value);
183  }
184  break;
185  case CSeq_id::e_Gibbmt:
186  {
188  CKSUM_ADD_INTEGER(checksum, value);
189  }
190  break;
191  case CSeq_id::e_Giim:
192  s_Fingerprint_Giimport_id(checksum, obj.GetGiim(), scope, fingerP);
193  break;
194  case CSeq_id::e_Genbank:
195  s_Fingerprint_Textseq_id(checksum, obj.GetGenbank(), scope, fingerP);
196  break;
197  case CSeq_id::e_Embl:
198  s_Fingerprint_Textseq_id(checksum, obj.GetEmbl(), scope, fingerP);
199  break;
200  case CSeq_id::e_Pir:
201  s_Fingerprint_Textseq_id(checksum, obj.GetPir(), scope, fingerP);
202  break;
204  s_Fingerprint_Textseq_id(checksum, obj.GetSwissprot(), scope, fingerP);
205  break;
206  case CSeq_id::e_Patent:
207  s_Fingerprint_Patent_seq_id(checksum, obj.GetPatent(), scope, fingerP);
208  break;
209  case CSeq_id::e_Other:
210  s_Fingerprint_Textseq_id(checksum, obj.GetOther(), scope, fingerP);
211  break;
212  case CSeq_id::e_General:
213  s_Fingerprint_Dbtag(checksum, obj.GetGeneral(), scope, fingerP);
214  break;
215  case CSeq_id::e_Gi:
216  {
217  CSeq_id::TGi value = obj.GetGi();
218  CKSUM_ADD_INTEGER(checksum, value);
219  }
220  break;
221  case CSeq_id::e_Ddbj:
222  s_Fingerprint_Textseq_id(checksum, obj.GetDdbj(), scope, fingerP);
223  break;
224  case CSeq_id::e_Prf:
225  s_Fingerprint_Textseq_id(checksum, obj.GetPrf(), scope, fingerP);
226  break;
227  case CSeq_id::e_Pdb:
228  s_Fingerprint_PDB_seq_id(checksum, obj.GetPdb(), scope, fingerP);
229  break;
230  case CSeq_id::e_Tpg:
231  s_Fingerprint_Textseq_id(checksum, obj.GetTpg(), scope, fingerP);
232  break;
233  case CSeq_id::e_Tpe:
234  s_Fingerprint_Textseq_id(checksum, obj.GetTpe(), scope, fingerP);
235  break;
236  case CSeq_id::e_Tpd:
237  s_Fingerprint_Textseq_id(checksum, obj.GetTpd(), scope, fingerP);
238  break;
239  case CSeq_id::e_Gpipe:
240  s_Fingerprint_Textseq_id(checksum, obj.GetGpipe(), scope, fingerP);
241  break;
242  case CSeq_id::e_not_set:
243  default:
244  break;
245  }
246 }
247 
249 {
250  CObjFingerprint::Register(CObject_id::GetTypeInfo(), s_Fingerprint_Object_id);
251  CObjFingerprint::Register(CDbtag::GetTypeInfo(), s_Fingerprint_Dbtag);
252  CObjFingerprint::Register(CGiimport_id::GetTypeInfo(), s_Fingerprint_Giimport_id);
253  CObjFingerprint::Register(CTextseq_id::GetTypeInfo(), s_Fingerprint_Textseq_id);
254  CObjFingerprint::Register(CPatent_seq_id::GetTypeInfo(), s_Fingerprint_Patent_seq_id);
255  CObjFingerprint::Register(CPDB_seq_id::GetTypeInfo(), s_Fingerprint_PDB_seq_id);
256  CObjFingerprint::Register(CSeq_id::GetTypeInfo(), s_Fingerprint_Seq_id);
257 }
258 
260 
User-defined methods of the data storage class.
Checksum and hash calculation classes.
CChecksum – Checksum calculator.
Definition: checksum.hpp:302
Definition: Dbtag.hpp:53
CGiimport_id –.
Definition: Giimport_id.hpp:66
void Fingerprint(CChecksum &checksum, const CObject &obj, objects::CScope *scope) const
static void Register(TTypeInfo type_info, TFingerPFunc func)
CObject –.
Definition: ncbiobj.hpp:180
CScope –.
Definition: scope.hpp:92
USING_SCOPE(objects)
static void s_Fingerprint_Giimport_id(CChecksum &checksum, const CObject &object, CScope *, const CObjFingerprint &)
Definition: fingp_seqid.cpp:83
static void s_Fingerprint_Dbtag(CChecksum &checksum, const CObject &object, CScope *scope, const CObjFingerprint &fingerP)
Definition: fingp_seqid.cpp:72
void init_Seq_idFP()
static void s_Fingerprint_Object_id(CChecksum &checksum, const CObject &object, CScope *, const CObjFingerprint &)
Definition: fingp_seqid.cpp:48
static void s_Fingerprint_Textseq_id(CChecksum &checksum, const CObject &object, CScope *, const CObjFingerprint &)
Definition: fingp_seqid.cpp:99
static void s_Fingerprint_Seq_id(CChecksum &checksum, const CObject &object, CScope *scope, const CObjFingerprint &fingerP)
static void s_Fingerprint_Patent_seq_id(CChecksum &checksum, const CObject &object, CScope *, const CObjFingerprint &)
static void s_Fingerprint_PDB_seq_id(CChecksum &checksum, const CObject &object, CScope *, const CObjFingerprint &)
void AddLine(const char *line, size_t len)
Definition: checksum.hpp:609
CConstRef< CSeq_id > GetSeqId(void) const
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_Seq_id_BestRank
use CSeq_id::BestRank() as the scoring function
Definition: sequence.hpp:107
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
E_Choice
Choice variants.
Definition: Id_pat_.hpp:104
const TId & GetId(void) const
Get the Id member data.
Definition: Id_pat_.hpp:525
const TCountry & GetCountry(void) const
Get the Country member data.
Definition: Id_pat_.hpp:478
@ e_App_number
Patent Doc Appl Number.
Definition: Id_pat_.hpp:107
@ e_not_set
No variant selected.
Definition: Id_pat_.hpp:105
@ e_Number
Patent Document Number.
Definition: Id_pat_.hpp:106
const TTag & GetTag(void) const
Get the Tag member data.
Definition: Dbtag_.hpp:267
const TDb & GetDb(void) const
Get the Db member data.
Definition: Dbtag_.hpp:220
E_Choice Which(void) const
Which variant is currently selected.
Definition: Object_id_.hpp:235
const TStr & GetStr(void) const
Get the variant data.
Definition: Object_id_.hpp:297
E_Choice
Choice variants.
Definition: Object_id_.hpp:88
TId GetId(void) const
Get the variant data.
Definition: Object_id_.hpp:270
@ e_not_set
No variant selected.
Definition: Object_id_.hpp:89
const TRelease & GetRelease(void) const
Get the Release member data.
NCBI_NS_NCBI::TGi TGi
Definition: Seq_id_.hpp:180
TChain GetChain(void) const
Get the Chain member data.
const TEmbl & GetEmbl(void) const
Get the variant data.
Definition: Seq_id_.cpp:259
const TPdb & GetPdb(void) const
Get the variant data.
Definition: Seq_id_.cpp:435
TGibbsq GetGibbsq(void) const
Get the variant data.
Definition: Seq_id_.hpp:787
TId GetId(void) const
Get the Id member data.
bool IsSetAccession(void) const
Check if a value has been assigned to Accession data member.
const TTpe & GetTpe(void) const
Get the variant data.
Definition: Seq_id_.cpp:479
bool IsSetRelease(void) const
the release Check if a value has been assigned to Release data member.
const TGenbank & GetGenbank(void) const
Get the variant data.
Definition: Seq_id_.cpp:237
const TTpd & GetTpd(void) const
Get the variant data.
Definition: Seq_id_.cpp:501
const TTpg & GetTpg(void) const
Get the variant data.
Definition: Seq_id_.cpp:457
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seq_id_.hpp:746
TGi GetGi(void) const
Get the variant data.
Definition: Seq_id_.hpp:889
TVersion GetVersion(void) const
Get the Version member data.
bool CanGetVersion(void) const
Check if it is safe to call GetVersion method.
bool IsSetRelease(void) const
Check if a value has been assigned to Release data member.
const TRelease & GetRelease(void) const
Get the Release member data.
const TMol & GetMol(void) const
Get the Mol member data.
TSeqid GetSeqid(void) const
Get the Seqid member data.
E_Choice
Choice variants.
Definition: Seq_id_.hpp:93
const TOther & GetOther(void) const
Get the variant data.
Definition: Seq_id_.cpp:347
const TGiim & GetGiim(void) const
Get the variant data.
Definition: Seq_id_.cpp:215
const TSwissprot & GetSwissprot(void) const
Get the variant data.
Definition: Seq_id_.cpp:303
const TDdbj & GetDdbj(void) const
Get the variant data.
Definition: Seq_id_.cpp:391
const TLocal & GetLocal(void) const
Get the variant data.
Definition: Seq_id_.cpp:193
const TPir & GetPir(void) const
Get the variant data.
Definition: Seq_id_.cpp:281
const TGpipe & GetGpipe(void) const
Get the variant data.
Definition: Seq_id_.cpp:523
const TGeneral & GetGeneral(void) const
Get the variant data.
Definition: Seq_id_.cpp:369
const TPatent & GetPatent(void) const
Get the variant data.
Definition: Seq_id_.cpp:325
TGibbmt GetGibbmt(void) const
Get the variant data.
Definition: Seq_id_.hpp:814
const TPrf & GetPrf(void) const
Get the variant data.
Definition: Seq_id_.cpp:413
bool IsSetDb(void) const
dbase used in Check if a value has been assigned to Db data member.
const TCit & GetCit(void) const
Get the Cit member data.
const TDb & GetDb(void) const
Get the Db member data.
const TAccession & GetAccession(void) const
Get the Accession member data.
@ e_Gibbmt
Geninfo backbone moltype.
Definition: Seq_id_.hpp:97
@ e_Giim
Geninfo import id.
Definition: Seq_id_.hpp:98
@ e_Other
for historical reasons, 'other' = 'refseq'
Definition: Seq_id_.hpp:104
@ e_Gpipe
Internal NCBI genome pipeline processing ID.
Definition: Seq_id_.hpp:113
@ e_Tpe
Third Party Annot/Seq EMBL.
Definition: Seq_id_.hpp:111
@ e_Tpd
Third Party Annot/Seq DDBJ.
Definition: Seq_id_.hpp:112
@ e_Gibbsq
Geninfo backbone seqid.
Definition: Seq_id_.hpp:96
@ e_General
for other databases
Definition: Seq_id_.hpp:105
@ e_Ddbj
DDBJ.
Definition: Seq_id_.hpp:107
@ e_Gi
GenInfo Integrated Database.
Definition: Seq_id_.hpp:106
@ e_Prf
PRF SEQDB.
Definition: Seq_id_.hpp:108
@ e_not_set
No variant selected.
Definition: Seq_id_.hpp:94
@ e_Tpg
Third Party Annot/Seq Genbank.
Definition: Seq_id_.hpp:110
@ e_Local
local use
Definition: Seq_id_.hpp:95
@ e_Pdb
PDB sequence.
Definition: Seq_id_.hpp:109
static int version
Definition: mdb_load.c:29
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
#define CKSUM_ADD_INTEGER(cksum, value)
#define _ASSERT
Modified on Wed Jun 19 17:07:38 2024 by modify_doxy.py rev. 669887