1 /* $Id: OrgMod.hpp 535708 2017-05-11 10:58:04Z bollin $
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
44 #include <objects/seqfeat/OrgMod_.hpp>
45 
46 // generated classes
47 
48 BEGIN_NCBI_SCOPE
49 
50 BEGIN_objects_SCOPE // namespace ncbi::objects::
51 
52 /////////////////////////////////////////////////////////////////////////////
53 class NCBI_SEQFEAT_EXPORT COrgMod : public COrgMod_Base
54 {
55     typedef COrgMod_Base Tparent;
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);
123     bool IsUnexpectedViralOrgModQualifier() const;
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 
131     typedef map<string, string, PNocase> TInstitutionCodeMap;
132     private:
133     // Prohibit copy constructor and assignment operator
134     COrgMod(const COrgMod& value);
135     COrgMod& operator=(const COrgMod& value);
136 
137     static TInstitutionCodeMap::iterator FindInstitutionCode(const string& inst_coll, TInstitutionCodeMap& code_map,
138         bool& is_miscapitalized, string& correct_cap, bool& needs_country, bool& erroneous_country);
139 
140 };
141 
142 /////////////////// COrgMod inline methods
143 
144 // constructor
145 inline
COrgMod(void)146 COrgMod::COrgMod(void)
147 {
148 }
149 
150 inline
COrgMod(TSubtype subtype,const TSubname & subname)151 COrgMod::COrgMod(TSubtype subtype, const TSubname& subname)
152 {
153     SetSubtype(subtype);
154     SetSubname(subname);
155 }
156 
157 
158 inline
COrgMod(const string & subtype,const TSubname & subname)159 COrgMod::COrgMod(const string& subtype, const TSubname& subname)
160 {
161     SetSubtype(GetSubtypeValue(subtype));
162     SetSubname(subname);
163 }
164 
165 /////////////////// end of COrgMod inline methods
166 
167 
168 END_objects_SCOPE // namespace ncbi::objects::
169 
170 END_NCBI_SCOPE
171 
172 #endif // OBJECTS_SEQFEAT_ORGMOD_HPP
173 /* Original file checksum: lines: 94, chars: 2521, CRC32: 79cf88de */
174