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

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_EDIT___MACRO_EDITOR_CONTEXT__HPP
2 #define GUI_WIDGETS_EDIT___MACRO_EDITOR_CONTEXT__HPP
3 /* $Id: macro_editor_context.hpp 46860 2021-11-10 22:54:31Z 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 
31 #include <corelib/ncbistd.hpp>
32 #include <objects/seq/Seqdesc.hpp>
35 #include <wx/string.h>
36 #include <boost/bimap.hpp>
37 #include <boost/bimap/set_of.hpp>
38 
40 
49  eCds,
51  eDBLink,
54  eGene,
57  eMolinfo,
64  eOther,
65  eProtein,
66  ePubAffil,
71  ePubTitle,
72  ePubStatus,
73  ePubdesc,
74  eRNA,
75  eSetFrom,
76  eSetTo,
78  eSeqID,
79  eNotSet
80 };
81 
82 enum class EMSection
83 {
84  eDoSection,
86 };
87 
88 // CMacroEditorContext - a singleton
90 {
91 public:
93  static CMacroEditorContext instance;
94  return instance;
95  }
96 
97  using TBimapStrings = boost::bimap<boost::bimaps::set_of<string, PNocase>,
98  boost::bimaps::set_of<string, PNocase>>;
99 
100  static string FindInBimapOrEmpty(const string& type, const TBimapStrings& str_bimap);
101 
102  vector<string> GetFieldNames(EMacroFieldType type) const;
103  string GetAsnPathToFieldName(const string& field, EMacroFieldType type, const string& target = kEmptyStr);
104  string GetAsnPathToFieldName(const string& feat, const string& qual);
105  string GetAsnPathToFeature(const string& feat_name) const;
106 
107  string GetAsnPathToAuthorFieldName(const string& author_name);
108 
109  string GetAsnMolinfoValue(const string& molinfo_field, const string& choice);
110 
111  vector<string> GetFeatureTypes(bool for_removal = false, bool to_create = false, bool include_all = false) const;
112  vector<string> GetFeatQualifiers() const;
113  pair<int, int> GetFeatureType(const string& name) const;
114  // returns the list of legal qualifiers for a feature type
115  vector<string> GetLegalQualifiers(const string& feat_name) const;
116 
117  vector<string> GetRNATypes() const;
118  vector<string> GetncRNAClassTypes(bool include_any = true) const;
119  vector<string> GetRNAProductnames(const string& rna_type) const;
120  vector<string> GetBondTypes() const;
121  vector<string> GetSiteTypes() const;
122  string GetConversionDescr(const string& from_feat, const string& to_feat);
123  const vector<string>& GetBsrcKeywords() const { return m_SourceKeywords; }
124  const vector<string>& GetParseToBsrcKeywords() const { return m_ParseToBsrcKeywords; }
125  const vector<string>& GetParseToCdsGeneProtKeywords() const { return m_ParseTpCdsGeneProtKeywords; }
126 
127  string GetGUIFieldName(const string& macro_field, const string& target, EMacroFieldType& type, EMSection clause = EMSection::eDoSection);
128  string GetGUIMolinfoValue(const string& macro_field, const string& molinfo_field);
129  string GetGUIAuthorName(const string& author_part);
130  string GetGUIPubField(CPubFieldType::EPubFieldType);
131  string GetGUIAffilField(const string& macro_field);
132  string GetGUIDateField(const string& macro_field);
133  string GetGUIDescriptor(const string& macro_field);
134 
135  // Returns feature qualifier's name for ApplyFeature macro
136  string GetGUIFeatQualifier(const string& macro_field);
137 
138  // delete the copy constructor & assignment operator
141 
142  const vector<string>& GetKeywords(EMacroFieldType type) const;
143 
144  static string s_GetGUIMappedMiscDescr(const string& value);
145  static string s_GetGUIMappedStructCommField(const string& value);
146  static bool s_IsGeneQualifier(const string& field);
147 private:
149 
150  vector<string> x_GetProteinFieldnames() const;
151  vector<string> x_GetBsrcTextFieldnames(bool complete = false) const;
152  vector<string> x_GetBsrcTaxFieldnames() const;
153  vector<string> x_GetAllBsrcFieldnames() const;
154  vector<string> x_GetSetClassFieldnames(bool all = true) const;
155  vector<string> x_GetDescriptorFieldnames() const;
156  vector<string> x_GetStrCommFieldnames() const;
157 
158  // These functions check the content of m_Field
159  string x_GetAsnPathToBsrcTax();
160  string x_GetAsnPathToBsrcText();
161  string x_GetAsnPathToAllBsrc();
162  string x_GetAsnPathToMolinfo(const string& target);
163  string x_GetAsnPathToPub();
164  string x_GetAsnPathToAffilFields();
165  string x_GetAsnPathToMiscDescr(const string& target);
166  string x_GetAsnPathToDescriptors();
167  string x_GetAsnPathToSet();
168  string x_GetAsnPathToMiscFields();
169  string x_GetAsnPathToDBLinkField(const string& target);
170 
171  string x_GetAsnPathtoGene();
172  string x_GetAsnPathToCDS();
173  string x_GetAsnPathToRna();
174  string x_GetAsnPathToProtein();
175  string x_GetAsnPathToCdsGeneProt();
176  string x_GetAsnPathToFeatQuals();
177  string x_GetAsnPathToFeatQuals(const string& feat, const string& qual);
178  string x_GetAsnPathToRnaFieldName(const string& rna_type, const string& field);
179 
180  bool x_GetGUIFieldForBsrcTax(string& field_name, EMacroFieldType& type);
181  bool x_GetGUIFieldForBsrcText(string& field_name, EMacroFieldType& type);
182  bool x_GetGUIFieldForStructComm(string& field_name, EMacroFieldType& type, EMSection clause = EMSection::eDoSection);
183  bool x_GetGUIFieldForMolinfo(string& field_name, EMacroFieldType& type);
184  bool x_GetGUIFieldForDBLink(string& field_name, EMacroFieldType& type);
185  bool x_GetGUIFieldForPubdesc(string& field_name, EMacroFieldType& type);
186  bool x_GetGUIFieldForMiscDescr(string& field_name, EMacroFieldType& type);
187  bool x_IsDescriptor(string& field_name, EMacroFieldType& type);
188  bool x_GetGUIFieldForCdsGeneProtRna(string& field_name, EMacroFieldType& type);
189 
190  string x_GetGUIFieldForGene();
191  string x_GetGUIFieldForProtein();
192  string x_GetGUIFieldForRNA();
193  string x_GetGUIFieldForCDS();
194 
195  string m_Field; // GUI field - coming from the macro editor panel
196  string m_MacroField; // field coming from the macro
197 
199 
201  vector<string> m_Featuretypes;
202  vector<string> m_SourceTextKeys{"strain", "host", "isolate", "isolation-source"};
203  vector<string> m_SourceTaxKeys{ "taxname", "common", "lineage" };
204  vector<string> m_SourceKeywords;
205  vector<string> m_MolinfoKeywords;
206  vector<string> m_PubdescKeywords;
207  vector<string> m_DBLinkKeywords;
208  vector<string> m_MiscKeywords{ "Definition line", "Comment descriptor", "Keyword" };
209  vector<string> m_MiscKeywordsToRmv{ "Definition line", "Comment descriptor", "Keyword", "Genome Project ID"};
210  vector<string> m_DescrKeywords{ "Biosource", "molinfo", "publication", "structured comment", "title" };
211  vector<string> m_GeneKeywords{ "gene locus", "gene description", "gene comment",
212  "gene allele", "gene maploc", "gene locus tag", "gene synonym" };
213  vector<string> m_RnaKeywords{ "rna product", "product name", "rna comment", "ncRNA class", "rna codons-recognized",
214  "rna tag-peptide", "rna anticodon", "gene locus"};
215  vector<string> m_ProteinKeywords{ "product name", "protein name", "product description", "protein description",
216  "EC number", "protein activity", "product comment", "protein comment" };
217  vector<string> m_FeatQualKeywords{ "cds product", "product name", "cds interference", "anticodon", "note", "EC", "rna", "misc-feature", "gene" };
218  vector<string> m_CdsGeneProtKeywords;
219  vector<string> m_ParseToBsrcKeywords{ "local id", "definition line", "defline", "taxname", "strain", "isolate"};
220  vector<string> m_ParseTpCdsGeneProtKeywords{ "local id", "definition line", "cds comment", "gene locus", "protein name", "mRNA product", "mat_peptide" };
221  vector<string> m_BsrcAutodefWords{ "clone", "cultivar", "culture-collection", "haplogroup", "isolate", "strain", "specimen-voucher" };
222  vector<string> m_EmptyKeywords;
223 };
224 
226 {
227  string m_Column; // field's column number in the table
228  string m_MacroName; // referencing the field in the macro
229  string m_GUIName; // name of the field as it appears in the dialog
230  bool m_UseMacroName{ false }; // true, if the m_MacroName should be used in the macro
231 
233  SFieldFromTable(const string& col, const string& macro_name, const string& label, bool use_macro_name)
234  : m_Column(col), m_MacroName(macro_name), m_GUIName(label), m_UseMacroName(use_macro_name) {}
235  const string& GetFieldName() const
236  {
237  return (m_UseMacroName) ? m_MacroName : m_GUIName;
238  }
239  void Reset()
240  {
241  m_Column = m_MacroName = m_GUIName = kEmptyStr;
242  m_UseMacroName = false;
243  }
244 };
245 
247 
248 #endif
249  // GUI_WIDGETS_EDIT___MACRO_EDITOR_CONTEXT__HPP
CMacroEditorContext & operator=(const CMacroEditorContext &)=delete
boost::bimap< boost::bimaps::set_of< string, PNocase >, boost::bimaps::set_of< string, PNocase > > TBimapStrings
vector< string > m_EmptyKeywords
const vector< string > & GetParseToBsrcKeywords() const
vector< string > m_DBLinkKeywords
vector< string > m_Featuretypes
const vector< string > & GetParseToCdsGeneProtKeywords() const
vector< string > m_SourceKeywords
static CMacroEditorContext & GetInstance()
CMacroEditorContext(const CMacroEditorContext &)=delete
map< string, pair< int, int > > m_FeatureMap
vector< string > m_PubdescKeywords
vector< string > m_CdsGeneProtKeywords
const vector< string > & GetBsrcKeywords() const
vector< string > m_MolinfoKeywords
Definition: map.hpp:338
char value[7]
Definition: config.c:431
Include a standard set of the NCBI C++ Toolkit most basic headers.
#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 kEmptyStr
Definition: ncbistr.hpp:123
#define NCBI_GUIWIDGETS_EDIT_EXPORT
Definition: gui_export.h:526
static const char label[]
Macro engine for macro execution.
const string & GetFieldName() const
SFieldFromTable(const string &col, const string &macro_name, const string &label, bool use_macro_name)
Definition: type.c:6
Modified on Thu Dec 07 10:06:12 2023 by modify_doxy.py rev. 669887