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

Go to the SVN repository for this file.

1 /* $Id: OrgMod.hpp 102650 2024-06-20 15:35:55Z kans $
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  */
27 
28 /// @OrgMod.hpp
29 /// User-defined methods of the data storage class.
30 ///
31 /// This file was originally generated by application DATATOOL
32 /// using the following specifications:
33 /// 'seqfeat.asn'.
34 ///
35 /// New methods or data members can be added to it if needed.
36 /// See also: OrgMod_.hpp
37 
38 
39 #ifndef OBJECTS_SEQFEAT_ORGMOD_HPP
40 #define OBJECTS_SEQFEAT_ORGMOD_HPP
41 
42 
43 // generated includes
45 
46 // generated classes
47 
49 
50 BEGIN_objects_SCOPE // namespace ncbi::objects::
51 
52 /////////////////////////////////////////////////////////////////////////////
54 {
56 public:
57  // constructor
58  COrgMod(void);
59  COrgMod(TSubtype subtype, const TSubname& subname);
60  COrgMod(const string& subtype, const TSubname& subname);
61  // destructor
62  ~COrgMod(void);
63 
64  // Find the enumerated subtype value.
65  // does case-insesitive search and '_' are converted to '-'.
66  // Throws an exception on failure.
67  enum EVocabulary {
68  eVocabulary_raw, // per ASN.1, except eSubtype_other <-> "note"
69  eVocabulary_insdc // per GB/DDBJ/EMBL qualifier names
70  };
71  static TSubtype GetSubtypeValue(const string& str,
72  EVocabulary vocabulary = eVocabulary_raw);
73  static string GetSubtypeName(TSubtype stype,
74  EVocabulary vocabulary = eVocabulary_raw);
75 
76  // returns false if GetSubtypeName is expected to throw an exception. True otherwise.
77  static bool IsValidSubtypeName(const string& str,
78  EVocabulary vocabulary = eVocabulary_raw);
79 
80  static bool IsDiscouraged(const TSubtype stype, bool indexer=false);
81  static bool IsMultipleValuesAllowed(TSubtype);
82 
83  /// This indicates if the given Org-mod subtype is supposed to hold an
84  /// institution code (Example: "ATCC:27305")
85  static bool HoldsInstitutionCode(const TSubtype stype);
86 
87  static bool ParseStructuredVoucher(const string& str, string& inst, string& coll, string& id);
88 
89  static bool IsInstitutionCodeValid(const string& inst_coll, string &voucher_type, bool& is_miscapitalized, string& correct_cap, bool& needs_country, bool& erroneous_country);
90  static string IsCultureCollectionValid(const string& culture_collection);
91  static string IsSpecimenVoucherValid(const string& specimen_voucher);
92  static string IsBiomaterialValid(const string& biomaterial);
93  static string IsStructuredVoucherValid(const string& val, const string& voucher_type);
94  static string MakeStructuredVoucher(const string& inst, const string& coll, const string& id);
95  static bool FixStructuredVoucher(string& val, const string& voucher_type);
96  static bool AddStructureToVoucher(string& val, const string& voucher_type);
97  static bool RescueInstFromParentheses(string& val, const string& voucher_type);
98  static string CheckMultipleVouchers(const vector<string>&);
99 
100  //e.g. "DMNS:Bird" to "Denver Museum of Nature and Science, Ornithology Collections"
101  // returns empty string if not found
102  static const string &GetInstitutionFullName( const string &short_name );
103  static const string &GetInstitutionShortName( const string &full_name );
104 
105  static string FixStrain( const string& strain);
106  static bool FuzzyStrainMatch( const string& strain1, const string& strain2 );
107  static bool IsStrainValid(const string& strain);
108 
109  static string FixHost(const string& value);
110  static string FixHostCapitalization(const string& value);
111  static string FixCapitalization(TSubtype subtype, const string& value);
112  void FixCapitalization();
113 
114  static string AutoFix(TSubtype subtype, const string& value);
115  void AutoFix();
116 
117  // Remove "subsp. " and "serovar " from start of strain
118  // Remove "subsp. " and "serovar " from start of serovar
119  // Remove "subsp. " from start of sub-species qualifier
120  bool RemoveAbbreviation();
121 
122  static bool IsUnexpectedViralOrgModQualifier(TSubtype subtype);
124 
125  // for type material
126  static bool IsValidTypeMaterial(const string& type_material);
127  // note that the INSDC definition is currently lagging behind what is considered
128  // valid for taxonomy
129  static bool IsINSDCValidTypeMaterial(const string& type_material);
130 
132 
133  // Allows instant transition when quarantine period ends.
134  static bool NCBI_ValidateForMultipleIsolates(void);
135 
136 private:
137  // Prohibit copy constructor and assignment operator
140 
141  static TInstitutionCodeMap::iterator FindInstitutionCode(const string& inst_coll, TInstitutionCodeMap& code_map,
142  bool& is_miscapitalized, string& correct_cap, bool& needs_country, bool& erroneous_country);
143 
144 };
145 
146 /////////////////// COrgMod inline methods
147 
148 // constructor
149 inline
151 {
152 }
153 
154 inline
156 {
157  SetSubtype(subtype);
159 }
160 
161 
162 inline
163 COrgMod::COrgMod(const string& subtype, const TSubname& subname)
164 {
165  SetSubtype(GetSubtypeValue(subtype));
167 }
168 
169 /////////////////// end of COrgMod inline methods
170 
171 
172 END_objects_SCOPE // namespace ncbi::objects::
173 
175 
176 #endif // OBJECTS_SEQFEAT_ORGMOD_HPP
177 /* Original file checksum: lines: 94, chars: 2521, CRC32: 79cf88de */
Data storage class.
static string GetSubtypeName(const CSubSource &qual)
COrgMod_Base –.
Definition: OrgMod_.hpp:73
@OrgMod.hpp User-defined methods of the data storage class.
Definition: OrgMod.hpp:54
COrgMod_Base Tparent
Definition: OrgMod.hpp:55
COrgMod(const COrgMod &value)
map< string, string, PNocase > TInstitutionCodeMap
Definition: OrgMod.hpp:131
EVocabulary
Definition: OrgMod.hpp:67
@ eVocabulary_raw
Definition: OrgMod.hpp:68
COrgMod(void)
Definition: OrgMod.hpp:150
static TSubtype GetSubtypeValue(const string &str, EVocabulary vocabulary=eVocabulary_raw)
Definition: OrgMod.cpp:62
COrgMod & operator=(const COrgMod &value)
static const char * str(char *buf, int n)
Definition: stats.c:84
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_SEQFEAT_EXPORT
Definition: ncbi_export.h:768
TSubname & SetSubname(void)
Assign a value to Subname data member.
Definition: OrgMod_.hpp:370
string TSubname
Definition: OrgMod_.hpp:133
TSubtype & SetSubtype(void)
Assign a value to Subtype data member.
Definition: OrgMod_.hpp:323
static char * subname
Definition: mdb_load.c:26
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
static bool FixCapitalization(string &name, bool apostroph)
Definition: pub_tests.cpp:1147
static bool IsUnexpectedViralOrgModQualifier(COrgMod::TSubtype subtype)
Modified on Fri Sep 20 14:57:26 2024 by modify_doxy.py rev. 669887