1 /* $Id: BioSource.hpp 546450 2017-09-18 18:15:29Z 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  * Author:  .......
27  *
28  * File Description:
29  *   .......
30  *
31  * Remark:
32  *   This code was originally generated by application DATATOOL
33  *   using specifications from the data definition file
34  *   'seqfeat.asn'.
35  */
36 
37 #ifndef OBJECTS_SEQFEAT_BIOSOURCE_HPP
38 #define OBJECTS_SEQFEAT_BIOSOURCE_HPP
39 
40 
41 // generated includes
42 #include <objects/seqfeat/BioSource_.hpp>
43 #include <objects/seqfeat/SubSource.hpp>
44 
45 // generated classes
46 
47 BEGIN_NCBI_SCOPE
48 
49 BEGIN_objects_SCOPE // namespace ncbi::objects::
50 
51 class COrgName;
52 class CFieldDiff;
53 class CSubSource;
54 
55 typedef vector< CRef<CFieldDiff> > TFieldDiffList;
56 
57 
58 class NCBI_SEQFEAT_EXPORT CBioSource : public CBioSource_Base
59 {
60     typedef CBioSource_Base Tparent;
61 public:
62     // constructor
63     CBioSource(void);
64     // destructor
65     ~CBioSource(void);
66 
67     // Get the appropriate gene code from this BioSource.
68     int GetGenCode(int def = 1) const;
69 
70     // function for getting genome value from organelle name
71     static CBioSource::EGenome GetGenomeByOrganelle (const string& organelle, NStr::ECase use_case = NStr::eCase, bool starts_with = false);
72 
73     // function for getting organelle name from genome value
74     static string GetOrganelleByGenome (unsigned int genome);
75 
76     // function for getting origin value from origin name
77     static CBioSource::EOrigin GetOriginByString (const string& origin, NStr::ECase use_case = NStr::eCase, bool starts_with = false);
78 
79     // function for getting organelle name from genome value
80     static string GetStringFromOrigin (unsigned int origin);
81 
82 
83     // shortcut access to selected Org-ref and OrgName methods
84     bool IsSetTaxname(void) const;
85     const string& GetTaxname(void) const;
86 
87     bool IsSetCommon(void) const;
88     const string& GetCommon(void) const;
89 
90     bool IsSetLineage(void) const;
91     const string& GetLineage(void) const;
92 
93     bool IsSetGcode(void) const;
94     int GetGcode(void) const;
95 
96     bool IsSetMgcode(void) const;
97     int GetMgcode(void) const;
98 
99     bool IsSetPgcode(void) const;
100     int GetPgcode(void) const;
101 
102     bool IsSetDivision(void) const;
103     const string& GetDivision(void) const;
104 
105     bool IsSetOrgname(void) const;
106     const COrgName& GetOrgname(void) const;
107 
108     bool IsSetOrgMod(void) const;
109 
110     // for GenColl
111     string GetRepliconName (void) const;
112     string GetBioprojectType (void) const;
113     string GetBioprojectLocation (void) const;
114 
115     // for Taxonomy
116     void SetDisableStrainForwarding(bool val);
117     bool GetDisableStrainForwarding() const;
118 
119     // for BioSample
120     void UpdateWithBioSample(const CBioSource& biosample, bool force, bool is_local_copy = false);
121     static bool ShouldIgnoreConflict(const string& label, string src_val, string sample_val, bool is_local_copy = false);
122 
123     TFieldDiffList GetBiosampleDiffs(const CBioSource& biosample, bool is_local_copy = false) const;
124     bool BiosampleDiffsOkForUpdate(const TFieldDiffList& diffs) const;
125 
126     typedef pair<string, string> TNameVal;
127     typedef vector<TNameVal> TNameValList;
128 
129     TNameValList GetNameValPairs() const;
130 
131     static bool IsStopWord(const string& value);
132 
133     void AutoFix();
134     void RemoveCultureNotes(bool is_species_level = true);
135     bool RemoveLineageSourceNotes();
136 
137     bool RemoveSubSource(int subtype);
138     bool RemoveSubSource(int subtype, const string& val);
139     bool RemoveOrgMod(int subtype);
140     bool RemoveOrgMod(int subtype, const string& val);
141 
142     //If taxname starts with uncultured, set environmental-sample to true
143     //If metagenomic, set environmental_sample
144     //    Add environmental_sample to BioSource if BioSource.org.orgname.div == "ENV"
145     //    Add metagenomic(and environmental_sample) if BioSource.org.orgname.lineage contains "metagenomes"
146     //    Add metagenomic(and environmental_sample) if BioSource has / metagenome_source qualifier
147     // returns true if change was made
148     bool FixEnvironmentalSample();
149 
150     // Remove null terms from SubSource values and OrgMod values
151     bool RemoveNullTerms();
152 
153     // do not allow sex qualifier if virus, bacteria, Archaea, or fungus
154     static bool AllowSexQualifier(const string& lineage);
155     bool AllowSexQualifier() const;
156 
157     // do not allow mating_type qualifier if animal, plant, or virus
158     static bool AllowMatingTypeQualifier(const string& lineage);
159     bool AllowMatingTypeQualifier() const;
160 
161     //Remove /sex qualifier from virus, bacteria, archaea, fungus organisms
162     //Remove /mating_type qualifier from animal, plant, and virus organisms
163     //Move /mating_type qualifier that is valid /sex qualifier word to /sex qualifier
164     bool FixSexMatingTypeInconsistencies();
165 
166     //Remove qualifiers not appropriate for virus organisms from Virus organisms
167     bool RemoveUnexpectedViralQualifiers();
168 
169     bool FixGenomeForQualifiers();
170 
171     static bool IsViral(const string& lineage);
172     bool IsViral() const;
173 
174     bool HasSubtype(CSubSource::TSubtype subtype) const;
175 
176     CRef<CBioSource> MakeCommon( const CBioSource& other) const;
177     CRef<CBioSource> MakeCommonExceptOrg(const CBioSource& other) const;
178 
179 private:
180     // Prohibit copy constructor and assignment operator
181     CBioSource(const CBioSource& value);
182     CBioSource& operator=(const CBioSource& value);
183 
184     void x_ClearCoordinatedBioSampleSubSources();
185     void x_ClearCoordinatedBioSampleOrgMods();
186     TNameValList x_GetOrgModNameValPairs() const;
187     TNameValList x_GetSubtypeNameValPairs() const;
188     void x_RemoveNameElementDiffs(const CBioSource& biosample, TFieldDiffList& diff_list) const;
189     bool x_ShouldIgnoreNoteForBiosample() const;
190 
191     // for handling StopWords from BioSample
192     static void x_InitStopWords(void);
193 
194     static void x_RemoveStopWords(COrg_ref& org_ref);
195 };
196 
197 
198 
199 /////////////////// CBioSource inline methods
200 
201 // constructor
202 inline
CBioSource(void)203 CBioSource::CBioSource(void)
204 {
205 }
206 
207 
208 /////////////////// end of CBioSource inline methods
209 
210 
211 // =============================================================================
212 //      For representing differences between BioSample and BioSource
213 // =============================================================================
214 
215 class NCBI_SEQFEAT_EXPORT CFieldDiff : public CObject
216 {
217 public:
CFieldDiff()218     CFieldDiff() {};
CFieldDiff(string field_name,string src_val,string sample_val)219     CFieldDiff(string field_name, string src_val, string sample_val) :
220         m_FieldName(field_name), m_SrcVal(src_val), m_SampleVal(sample_val)
221         {};
222 
~CFieldDiff(void)223     ~CFieldDiff(void) {};
224 
GetFieldName() const225     const string& GetFieldName() const { return m_FieldName; };
GetSrcVal() const226     const string& GetSrcVal() const { return m_SrcVal; };
GetSampleVal() const227     const string& GetSampleVal() const { return m_SampleVal; };
228 
229 private:
230     string m_FieldName;
231     string m_SrcVal;
232     string m_SampleVal;
233 };
234 
235 
236 
237 
238 
239 END_objects_SCOPE // namespace ncbi::objects::
240 
241 END_NCBI_SCOPE
242 
243 #endif // OBJECTS_SEQFEAT_BIOSOURCE_HPP
244 /* Original file checksum: lines: 93, chars: 2400, CRC32: 29efac3b */
245