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

Go to the SVN repository for this file.

1 /* $Id: validerror_descr.cpp 101247 2023-11-20 15:20:49Z stakhovv $
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  * Author: Jonathan Kans, Clifford Clausen, Aaron Ucko......
27  *
28  * File Description:
29  * validation of seq_descr
30  * .......
31  *
32  */
33 #include <ncbi_pch.hpp>
34 #include <corelib/ncbistd.hpp>
38 
39 #include <serial/iterator.hpp>
40 
41 #include <objects/seq/Seqdesc.hpp>
43 
44 
47 BEGIN_SCOPE(validator)
48 
49 
51  CValidError_base(imp), m_DescValidator(imp)
52 {
53 }
54 
55 
57 {
58 }
59 
60 
62 {
63  size_t num_sources = 0,
64  num_titles = 0;
65  CConstRef<CSeqdesc> last_source;
66  const CSeqdesc* first_title = nullptr;
67  const char* lastname = kEmptyCStr;
68  bool same_taxnames = false;
69 
70  FOR_EACH_DESCRIPTOR_ON_DESCR (dt, descr) {
71  const CSeqdesc& desc = **dt;
72 
74 
75  switch ( desc.Which() ) {
77  case CSeqdesc::e_Modif:
78  case CSeqdesc::e_Method:
79  // obsolete
80  break;
81 
82  case CSeqdesc::e_Name:
83  break;
84  case CSeqdesc::e_Title:
85  num_titles++;
86  if (num_titles > 1) {
88  "Undesired multiple title descriptors", ctx, *first_title);
89  } else {
90  first_title = *dt;
91  }
92  break;
93 
95  break;
96 
97  case CSeqdesc::e_Num:
98  break;
99  case CSeqdesc::e_Maploc:
100  break;
101 
102  case CSeqdesc::e_Pir:
103  break;
104 
105  case CSeqdesc::e_Genbank:
106  break;
107 
108  case CSeqdesc::e_Pub:
109  break;
110 
111  case CSeqdesc::e_Region:
112  break;
113  case CSeqdesc::e_User:
114  break;
115 
116  case CSeqdesc::e_Sp:
117  break;
118 
119  case CSeqdesc::e_Dbxref:
120  break;
121 
122  case CSeqdesc::e_Embl:
123  break;
124 
126  break;
128  break;
129 
130  case CSeqdesc::e_Prf:
131  break;
132 
133  case CSeqdesc::e_Pdb:
134  break;
135 
136  case CSeqdesc::e_Het:
137  break;
138  case CSeqdesc::e_Source: {
139  num_sources++;
140  last_source = &desc;
141  const CBioSource& src = desc.GetSource();
142  if ( src.IsSetTaxname() ) {
143  const string& currname = src.GetTaxname();
144  if ( lastname != kEmptyCStr && NStr::EqualNocase (currname, lastname) ) {
145  same_taxnames = true;
146  }
147  lastname = currname.c_str();
148  }
149  } break;
150  case CSeqdesc::e_Org:
151  break;
152  case CSeqdesc::e_Molinfo:
153  break;
154 
155  default:
156  break;
157  }
158  }
159 
160  if ( num_sources > 1 && same_taxnames ) {
162  "Undesired multiple source descriptors", ctx, *last_source);
163  }
164 }
165 
166 
168 {
170 }
171 
172 
173 END_SCOPE(validator)
@ eErr_SEQ_DESCR_MultipleBioSources
@ eErr_SEQ_DESCR_MultipleTitles
const string & GetTaxname(void) const
Definition: BioSource.cpp:340
bool IsSetTaxname(void) const
Definition: BioSource.cpp:335
@Seq_descr.hpp User-defined methods of the data storage class.
Definition: Seq_descr.hpp:55
Definition: Seq_entry.hpp:56
void PostErr(EDiagSev sv, EErrType et, const string &msg, const CSerialObject &obj)
void ValidateSeqDesc(const CSeqdesc &desc, const CSeq_entry &ctx)
Validate descriptors as stand alone objects (no context)
bool ValidateStructuredCommentInternal(const CSeqdesc &desc, bool report=true)
void ValidateSeqDescr(const CSeq_descr &descr, const CSeq_entry &ctx)
~CValidError_descr() override
bool ValidateStructuredComment(const CSeqdesc &desc, bool report)
CValidError_desc m_DescValidator
Include a standard set of the NCBI C++ Toolkit most basic headers.
CS_CONTEXT * ctx
Definition: t0006.c:12
@ eDiag_Error
Error message.
Definition: ncbidiag.hpp:653
#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
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
Definition: ncbistr.hpp:5353
const char *const kEmptyCStr
Empty "C" string (points to a '\0').
Definition: ncbistr.cpp:68
const TSource & GetSource(void) const
Get the variant data.
Definition: Seqdesc_.cpp:566
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seqdesc_.hpp:903
@ e_Embl
EMBL specific information.
Definition: Seqdesc_.hpp:127
@ e_Het
cofactor, etc associated but not bound
Definition: Seqdesc_.hpp:132
@ e_Org
if all from one organism
Definition: Seqdesc_.hpp:116
@ e_Num
a numbering system
Definition: Seqdesc_.hpp:118
@ e_User
user defined object
Definition: Seqdesc_.hpp:124
@ e_Update_date
date of last update
Definition: Seqdesc_.hpp:129
@ e_Pub
a reference to the publication
Definition: Seqdesc_.hpp:122
@ e_Pir
PIR specific info.
Definition: Seqdesc_.hpp:120
@ e_Genbank
GenBank specific info.
Definition: Seqdesc_.hpp:121
@ e_Prf
PRF specific information.
Definition: Seqdesc_.hpp:130
@ e_Mol_type
type of molecule
Definition: Seqdesc_.hpp:111
@ e_Sp
SWISSPROT specific info.
Definition: Seqdesc_.hpp:125
@ e_Dbxref
xref to other databases
Definition: Seqdesc_.hpp:126
@ e_Comment
a more extensive comment
Definition: Seqdesc_.hpp:117
@ e_Method
sequencing method
Definition: Seqdesc_.hpp:113
@ e_Region
overall region (globin locus)
Definition: Seqdesc_.hpp:123
@ e_Molinfo
info on the molecule and techniques
Definition: Seqdesc_.hpp:134
@ e_Modif
modifiers
Definition: Seqdesc_.hpp:112
@ e_Maploc
map location of this sequence
Definition: Seqdesc_.hpp:119
@ e_Create_date
date entry first created/released
Definition: Seqdesc_.hpp:128
@ e_Title
a title for this sequence
Definition: Seqdesc_.hpp:115
@ e_Pdb
PDB specific information.
Definition: Seqdesc_.hpp:131
@ e_Name
a name for this sequence
Definition: Seqdesc_.hpp:114
@ e_Source
source of materials, includes Org-ref
Definition: Seqdesc_.hpp:133
#define FOR_EACH_DESCRIPTOR_ON_DESCR
Definition: seq_macros.hpp:680
Modified on Thu Mar 28 17:07:16 2024 by modify_doxy.py rev. 669887