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

Go to the SVN repository for this file.

1 #ifndef GUI_OBJUTILS___MACRO_FN_LOOKUP__HPP
2 #define GUI_OBJUTILS___MACRO_FN_LOOKUP__HPP
3 /* $Id: macro_fn_lookup.hpp 46420 2021-04-28 19:11:54Z asztalos $
4  * ===========================================================================
5  *
6  * PUBLIC DOMAIN NOTICE
7  * National Center for Biotechnology Information
8  *
9  * This software/database is a "United States Government Work" under the
10  * terms of the United States Copyright Act. It was written as part of
11  * the author's official duties as a United States Government employee and
12  * thus cannot be copyrighted. This software/database is freely available
13  * to the public for use. The National Library of Medicine and the U.S.
14  * Government have not placed any restriction on its use or reproduction.
15  *
16  * Although all reasonable efforts have been taken to ensure the accuracy
17  * and reliability of the software and data, the NLM and the U.S.
18  * Government do not and cannot warrant the performance or results that
19  * may be obtained by using this software or data. The NLM and the U.S.
20  * Government disclaim all warranties, express or implied, including
21  * warranties of performance, merchantability or fitness for any particular
22  * purpose.
23  *
24  * Please cite the author in any work or product based on this material.
25  *
26  * ===========================================================================
27  *
28  * Authors: Andrea Asztalos
29  *
30  * File Description: Macro functions that look up taxnames
31  *
32  */
33 
34 /// @file macro_fn_lookup.hpp
35 
36 #include <corelib/ncbistd.hpp>
39 #include <gui/gui_export.h>
41 
42 
43 /** @addtogroup GUI_MACRO_SCRIPTS_UTIL
44  *
45  * @{
46  */
47 
49 BEGIN_SCOPE(macro)
50 
52 {
53 public:
55  : m_Bsrc(0), m_ConvertNote(false), m_RemoveNote_Sp(false), m_RemoveNote_Univ(false) {}
56 
57  CUnculturedTool(const objects::CBioSource& bsrc)
58  : m_Bsrc(ConstRef(&bsrc)),
59  m_ConvertNote(false),
60  m_RemoveNote_Sp(false),
61  m_RemoveNote_Univ(false) {}
62 
64 
65  void SetBioSource(const objects::CBioSource& bsrc) { m_Bsrc.Reset(&bsrc); }
66  string GetSuggestedCorrection(void);
67 
68  void CorrectBioSource(objects::CBioSource& bsrc, bool& converted_note, bool& removed_note_sp, bool& removed_note_univ);
69 
70  static string s_MakeUnculturedName(const string& taxname, const string& suffix = kEmptyStr);
71  static string s_GetRank(CRef<objects::CT3Reply> reply);
72  static bool s_IsAmbiguous(CRef<objects::CT3Reply> reply);
73  static bool s_OrganismNotFound(CRef<objects::CT3Reply> reply);
74  static string s_GetSuggestion(CRef<objects::CT3Reply> reply);
75  static bool s_CompareOrgnameLineage(CRef<objects::CT3Reply> reply, const string &lineage);
76  static void s_AddEnvironmentalSample(objects::CBioSource& bsrc);
77  static bool s_OkToTaxFix(const string& taxname);
78  static bool s_IsUnculturedName(const string& taxname);
79  static bool s_HasTaxId(const objects::CBioSource& bsrc);
80 private:
81  void x_Reset();
82  bool x_ShouldLookupTaxname(void);
83 
84  string x_GetCorrection();
85  string x_StandardFixes();
86  CRef<objects::CT3Reply> x_GetReply(const string &standard_taxname);
87  bool x_CheckSuggestedFix(string& suggestion);
88  string x_TryRankFix(CRef<objects::CT3Reply> reply, string& name);
89  void x_ConvertNote(objects::CBioSource& biosource, const char* note_list[], const string& new_note);
90 
91 private:
94  /// flag to convert species-specific note
96  /// flag to remove species-specific note
98  /// flag to remove universal note
100 
103 };
104 
105 
106 
108 {
109 public:
111  : m_Bsrc(0) {}
112 
113  CCulturedTool(const objects::CBioSource& bsrc)
114  : m_Bsrc(ConstRef(&bsrc)) {}
115 
117 
118  void SetBioSource(const objects::CBioSource& bsrc) { m_Bsrc.Reset(&bsrc); }
119 
120  void CorrectBioSource(objects::CBioSource& bsrc, bool& remove_note);
121 
122 private:
124 
125  bool x_RemoveIfFoundSubSourceNote(objects::CBioSource &bsrc, const char* note_list[]);
126  bool x_RemoveIfFoundOrgModNote(objects::CBioSource &bsrc, const char* note_list[]);
127 
130 };
131 
132 
133 DECLARE_FUNC_CLASS_WITH_FNCNAME(CMacroFunction_UnculturedTaxLookup)
134 
135 DECLARE_FUNC_CLASS_WITH_FNCNAME(CMacroFunction_CulturedTaxLookup)
136 
137 
138 END_SCOPE(macro)
140 
141 /* @} */
142 
143 #endif // GUI_OBJUTILS___MACRO_FN_LOOKUP__HPP
User-defined methods of the data storage class.
Definition: map.hpp:338
Include a standard set of the NCBI C++ Toolkit most basic headers.
#define false
Definition: bool.h:36
DECLARE_FUNC_CLASS_WITH_FNCNAME(CMacroFunction_SetPubAuthorMI)
bool m_RemoveNote_Sp
flag to remove species-specific note
CUnculturedTool(const objects::CBioSource &bsrc)
CCulturedTool(const objects::CBioSource &bsrc)
bool m_RemoveNote_Univ
flag to remove universal note
bool m_ConvertNote
flag to convert species-specific note
CUnculturedTool(const CUnculturedTool &)
CUnculturedTool & operator=(const CUnculturedTool &)
void SetBioSource(const objects::CBioSource &bsrc)
CConstRef< objects::CBioSource > m_Bsrc
CConstRef< objects::CBioSource > m_Bsrc
void SetBioSource(const objects::CBioSource &bsrc)
CCulturedTool(const CCulturedTool &)
map< string, CRef< objects::CT3Reply > > m_ReplyCache
CCulturedTool & operator=(const CCulturedTool &)
CConstRef< C > ConstRef(const C *object)
Template function for conversion of const object pointer to CConstRef.
Definition: ncbiobj.hpp:2024
#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
#define kEmptyStr
Definition: ncbistr.hpp:123
#define NCBI_GUIOBJUTILS_EXPORT
Definition: gui_export.h:512
Defines to provide correct exporting from DLLs in Windows.
static const char * suffix[]
Definition: pcregrep.c:408
Modified on Sun Jul 14 04:59:01 2024 by modify_doxy.py rev. 669887