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

Go to the SVN repository for this file.

1 /* $Id: fingp_seqfeat.cpp 34076 2015-10-30 12:14:08Z evgeniev $
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 #include <util/checksum.hpp>
35 #include <gui/objutils/label.hpp>
36 
41 
44 
46  CChecksum& checksum, const CObject& object,
47  CScope*, const CObjFingerprint&)
48 {
49  _ASSERT(dynamic_cast<const CGb_qual*>(&object));
50  const CGb_qual& obj = static_cast<const CGb_qual&>(object);
51 
52  checksum.AddLine(obj.GetQual());
53  checksum.AddLine(obj.GetVal());
54 }
55 
56 
57 static void s_Fingerprint_Feat_id(CChecksum& checksum, const CFeat_id& feat_id,
58  CScope* scope, const CObjFingerprint& fingerP)
59 {
60  switch(feat_id.Which()) {
61  case CFeat_id::e_Gibb:
62  {{
63  CFeat_id::TGibb gibb = feat_id.GetGibb();
64  CKSUM_ADD_INTEGER(checksum, gibb);
65  break;
66  }}
67  case CFeat_id::e_Giim:
68  fingerP.Fingerprint(checksum, feat_id.GetGiim(), scope);
69  break;
70  case CFeat_id::e_Local:
71  fingerP.Fingerprint(checksum, feat_id.GetLocal(), scope);
72  break;
74  fingerP.Fingerprint(checksum, feat_id.GetGeneral(), scope);
75  break;
76  default:
77  break;
78  }
79 }
80 
81 
83  CChecksum& checksum, const CObject& object,
84  CScope* scope, const CObjFingerprint& fingerP)
85 {
86  _ASSERT(dynamic_cast<const CSeq_feat*>(&object));
87  const CSeq_feat& obj = static_cast<const CSeq_feat&>(object);
88 
89  const CSeqFeatData& data = obj.GetData();
90  CSeqFeatData::E_Choice choice = data.Which();
91  CKSUM_ADD_INTEGER(checksum, choice);
92 
93  fingerP.Fingerprint(checksum, obj.GetLocation(), scope);
94 
95  if (obj.IsSetId()) {
96  s_Fingerprint_Feat_id(checksum, obj.GetId(), scope, fingerP);
97  } else {
98  // let's use label as the 'unique' id instead
99  string label;
101  if ( !label.empty() ) {
102  checksum.AddLine(label);
103  }
104  }
105 
106  if (obj.IsSetIds()) {
107  ITERATE (CSeq_feat::TIds, iter, obj.GetIds()) {
108  s_Fingerprint_Feat_id(checksum, **iter, scope, fingerP);
109  }
110  }
111 
112  if (obj.IsSetProduct())
113  fingerP.Fingerprint(checksum, obj.GetProduct(), scope);
114 
115  // some STS features are placed on the wrong sequence,
116  // causing a dublicate fingerprints
117  if (data.GetSubtype() == CSeqFeatData::eSubtype_STS) {
118  if (obj.IsSetQual()) {
119  ITERATE (CSeq_feat::TQual, it, obj.GetQual())
120  s_Fingerprint_Gb_qual(checksum, **it, scope, fingerP);
121  }
122  if (obj.IsSetDbxref()) {
124  fingerP.Fingerprint(checksum, **it, scope);
125  }
126  if (obj.IsSetComment())
127  checksum.AddLine(obj.GetComment());
128  }
129 
130  // stream dbxref's for variations
131  if (((data.GetSubtype() == CSeqFeatData::eSubtype_site) || (data.GetSubtype() == CSeqFeatData::eSubtype_variation)) && obj.IsSetDbxref()) {
133  fingerP.Fingerprint(checksum, **it, scope);
134  }
135 
136  if (data.GetSubtype() == CSeqFeatData::eSubtype_misc_feature) {
137  if (obj.IsSetQual()) {
138  ITERATE (CSeq_feat::TQual, it, obj.GetQual())
139  s_Fingerprint_Gb_qual(checksum, **it, scope, fingerP);
140  }
141  }
142 }
143 
145 {
146  CObjFingerprint::Register(CSeq_feat::GetTypeInfo(), s_Fingerprint_Seq_feat);
147  CObjFingerprint::Register(CGb_qual::GetTypeInfo(), s_Fingerprint_Gb_qual);
148 }
149 
User-defined methods of the data storage class.
Checksum and hash calculation classes.
CChecksum – Checksum calculator.
Definition: checksum.hpp:302
CFeat_id –.
Definition: Feat_id.hpp:66
@Gb_qual.hpp User-defined methods of the data storage class.
Definition: Gb_qual.hpp:61
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
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
USING_SCOPE(objects)
static void s_Fingerprint_Feat_id(CChecksum &checksum, const CFeat_id &feat_id, CScope *scope, const CObjFingerprint &fingerP)
static void s_Fingerprint_Gb_qual(CChecksum &checksum, const CObject &object, CScope *, const CObjFingerprint &)
static void s_Fingerprint_Seq_feat(CChecksum &checksum, const CObject &object, CScope *scope, const CObjFingerprint &fingerP)
void init_Seq_FeatFP()
char data[12]
Definition: iconv.c:80
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
void AddLine(const char *line, size_t len)
Definition: checksum.hpp:609
static void GetLabel(const CObject &obj, string *label, ELabelType type=eDefault)
Definition: label.cpp:140
@ eContent
Definition: label.hpp:62
#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 TVal & GetVal(void) const
Get the Val member data.
Definition: Gb_qual_.hpp:259
bool IsSetComment(void) const
Check if a value has been assigned to Comment data member.
Definition: Seq_feat_.hpp:1037
vector< CRef< CDbtag > > TDbxref
Definition: Seq_feat_.hpp:123
bool IsSetQual(void) const
qualifiers Check if a value has been assigned to Qual data member.
Definition: Seq_feat_.hpp:1135
const TIds & GetIds(void) const
Get the Ids member data.
Definition: Seq_feat_.hpp:1452
E_Choice Which(void) const
Which variant is currently selected.
Definition: Feat_id_.hpp:291
const TQual & GetQual(void) const
Get the Qual member data.
Definition: Seq_feat_.hpp:1147
const TId & GetId(void) const
Get the Id member data.
Definition: Seq_feat_.hpp:904
const TLocal & GetLocal(void) const
Get the variant data.
Definition: Feat_id_.cpp:134
const TLocation & GetLocation(void) const
Get the Location member data.
Definition: Seq_feat_.hpp:1117
E_Choice
Choice variants.
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_feat_.hpp:925
const TGeneral & GetGeneral(void) const
Get the variant data.
Definition: Feat_id_.cpp:156
const TDbxref & GetDbxref(void) const
Get the Dbxref member data.
Definition: Seq_feat_.hpp:1333
const TGiim & GetGiim(void) const
Get the variant data.
Definition: Feat_id_.cpp:112
list< CRef< CFeat_id > > TIds
Definition: Seq_feat_.hpp:126
bool IsSetIds(void) const
set of Ids; will replace 'id' field Check if a value has been assigned to Ids data member.
Definition: Seq_feat_.hpp:1440
bool IsSetId(void) const
Check if a value has been assigned to Id data member.
Definition: Seq_feat_.hpp:892
const TProduct & GetProduct(void) const
Get the Product member data.
Definition: Seq_feat_.hpp:1096
const TComment & GetComment(void) const
Get the Comment member data.
Definition: Seq_feat_.hpp:1049
vector< CRef< CGb_qual > > TQual
Definition: Seq_feat_.hpp:117
const TQual & GetQual(void) const
Get the Qual member data.
Definition: Gb_qual_.hpp:212
TGibb GetGibb(void) const
Get the variant data.
Definition: Feat_id_.hpp:326
bool IsSetDbxref(void) const
support for xref to other databases Check if a value has been assigned to Dbxref data member.
Definition: Seq_feat_.hpp:1321
bool IsSetProduct(void) const
product of process Check if a value has been assigned to Product data member.
Definition: Seq_feat_.hpp:1084
@ e_Giim
geninfo import
Definition: Feat_id_.hpp:93
@ e_General
for use by various databases
Definition: Feat_id_.hpp:95
@ e_Gibb
geninfo backbone
Definition: Feat_id_.hpp:92
@ e_Local
for local software use
Definition: Feat_id_.hpp:94
#define CKSUM_ADD_INTEGER(cksum, value)
#define _ASSERT
Modified on Thu Apr 25 08:22:04 2024 by modify_doxy.py rev. 669887