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 47754 2024-07-19 18:12:25Z 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,
75  eRNA,
76  eSetFrom,
77  eSetTo,
79  eSeqID,
80  eNotSet
81 };
82 
83 enum class EMSection
84 {
85  eDoSection,
87 };
88 
89 // CMacroEditorContext - a singleton
91 {
92 public:
94  static CMacroEditorContext instance;
95  return instance;
96  }
97 
98  using TBimapStrings = boost::bimap<boost::bimaps::set_of<string, PNocase>,
99  boost::bimaps::set_of<string, PNocase>>;
100 
101  static string FindInBimapOrEmpty(const string& type, const TBimapStrings& str_bimap);
102 
103  vector<string> GetFieldNames(EMacroFieldType type) const;
104  string GetAsnPathToFieldName(const string& field, EMacroFieldType type, const string& target = kEmptyStr);
105  string GetAsnPathToFieldName(const string& feat, const string& qual);
106  string GetAsnPathToFeature(const string& feat_name) const;
107 
108  string GetAsnPathToAuthorFieldName(const string& author_name);
109 
110  string GetAsnMolinfoValue(const string& molinfo_field, const string& choice);
111 
112  vector<string> GetFeatureTypes(bool for_removal = false, bool to_create = false, bool include_all = false) const;
113  vector<string> GetFeatQualifiers() const;
114  pair<int, int> GetFeatureType(const string& name) const;
115  // returns the list of legal qualifiers for a feature type
116  vector<string> GetLegalQualifiers(const string& feat_name) const;
117 
118  vector<string> GetRNATypes() const;
119  vector<string> GetncRNAClassTypes(bool include_any = true) const;
120  vector<string> GetRNAProductnames(const string& rna_type) const;
121  vector<string> GetBondTypes() const;
122  vector<string> GetSiteTypes() const;
123  string GetConversionDescr(const string& from_feat, const string& to_feat);
124  const vector<string>& GetBsrcKeywords() const { return m_SourceKeywords; }
125  const vector<string>& GetParseToBsrcKeywords() const { return m_ParseToBsrcKeywords; }
126  const vector<string>& GetParseToCdsGeneProtKeywords() const { return m_ParseTpCdsGeneProtKeywords; }
127 
128  string GetGUIFieldName(const string& macro_field, const string& target, EMacroFieldType& type, EMSection clause = EMSection::eDoSection);
129  string GetGUIMolinfoValue(const string& macro_field, const string& molinfo_field);
130  string GetGUIAuthorName(const string& author_part);
131  string GetGUIPubField(CPubFieldType::EPubFieldType);
132  string GetGUIAffilField(const string& macro_field);
133  string GetGUIDateField(const string& macro_field);
134  string GetGUIDescriptor(const string& macro_field);
135 
136  // Returns feature qualifier's name for ApplyFeature macro
137  string GetGUIFeatQualifier(const string& macro_field);
138 
139  // delete the copy constructor & assignment operator
142 
143  const vector<string>& GetKeywords(EMacroFieldType type) const;
144 
145  static string s_GetGUIMappedMiscDescr(const string& value);
146  static string s_GetGUIMappedStructCommField(const string& value);
147  static bool s_IsGeneQualifier(const string& field);
148 private:
150 
151  vector<string> x_GetProteinFieldnames() const;
152  vector<string> x_GetBsrcTextFieldnames(bool complete = false) const;
153  vector<string> x_GetBsrcTaxFieldnames() const;
154  vector<string> x_GetAllBsrcFieldnames() const;
155  vector<string> x_GetSetClassFieldnames(bool all = true) const;
156  vector<string> x_GetDescriptorFieldnames() const;
157  vector<string> x_GetStrCommFieldnames() const;
158 
159  // These functions check the content of m_Field
160  string x_GetAsnPathToBsrcTax();
161  string x_GetAsnPathToBsrcText();
162  string x_GetAsnPathToAllBsrc();
163  string x_GetAsnPathToMolinfo(const string& target);
164  string x_GetAsnPathToPub();
165  string x_GetAsnPathToAffilFields();
166  string x_GetAsnPathToMiscDescr(const string& target);
167  string x_GetAsnPathToDescriptors();
168  string x_GetAsnPathToSet();
169  string x_GetAsnPathToMiscFields();
170  string x_GetAsnPathToDBLinkField(const string& target);
171 
172  string x_GetAsnPathtoGene();
173  string x_GetAsnPathToCDS();
174  string x_GetAsnPathToRna();
175  string x_GetAsnPathToProtein();
176  string x_GetAsnPathToCdsGeneProt();
177  string x_GetAsnPathToFeatQuals();
178  string x_GetAsnPathToFeatQuals(const string& feat, const string& qual);
179  string x_GetAsnPathToRnaFieldName(const string& rna_type, const string& field);
180 
181  bool x_GetGUIFieldForBsrcTax(string& field_name, EMacroFieldType& type);
182  bool x_GetGUIFieldForBsrcText(string& field_name, EMacroFieldType& type);
183  bool x_GetGUIFieldForStructComm(string& field_name, EMacroFieldType& type, EMSection clause = EMSection::eDoSection);
184  bool x_GetGUIFieldForMolinfo(string& field_name, EMacroFieldType& type);
185  bool x_GetGUIFieldForDBLink(string& field_name, EMacroFieldType& type);
186  bool x_GetGUIFieldForPubdesc(string& field_name, EMacroFieldType& type);
187  bool x_GetGUIFieldForMiscDescr(string& field_name, EMacroFieldType& type);
188  bool x_IsDescriptor(string& field_name, EMacroFieldType& type);
189  bool x_GetGUIFieldForCdsGeneProtRna(string& field_name, EMacroFieldType& type);
190 
191  string x_GetGUIFieldForGene();
192  string x_GetGUIFieldForProtein();
193  string x_GetGUIFieldForRNA();
194  string x_GetGUIFieldForCDS();
195 
196  string m_Field; // GUI field - coming from the macro editor panel
197  string m_MacroField; // field coming from the macro
198 
200 
202  vector<string> m_Featuretypes;
203  vector<string> m_SourceTextKeys{"strain", "host", "isolate", "isolation-source"};
204  vector<string> m_SourceTaxKeys{ "taxname", "common", "lineage" };
205  vector<string> m_SourceKeywords;
206  vector<string> m_MolinfoKeywords;
207  vector<string> m_PubdescKeywords;
208  vector<string> m_DBLinkKeywords;
209  vector<string> m_MiscKeywords{ "Definition line", "Comment descriptor", "Keyword" };
210  vector<string> m_MiscKeywordsToRmv{ "Definition line", "Comment descriptor", "Keyword", "Genome Project ID"};
211  vector<string> m_DescrKeywords{ "Biosource", "molinfo", "publication", "structured comment", "title" };
212  vector<string> m_GeneKeywords{ "gene locus", "gene description", "gene comment",
213  "gene allele", "gene maploc", "gene locus tag", "gene synonym" };
214  vector<string> m_RnaKeywords{ "rna product", "product name", "rna comment", "ncRNA class", "rna codons-recognized",
215  "rna tag-peptide", "rna anticodon", "gene locus"};
216  vector<string> m_ProteinKeywords{ "product name", "protein name", "product description", "protein description",
217  "EC number", "protein activity", "product comment", "protein comment" };
218  vector<string> m_FeatQualKeywords{ "cds product", "product name", "cds interference", "anticodon", "note", "EC", "rna", "misc-feature", "gene" };
219  vector<string> m_CdsGeneProtKeywords;
220  vector<string> m_ParseToBsrcKeywords{ "local id", "definition line", "defline", "taxname", "strain", "isolate"};
221  vector<string> m_ParseTpCdsGeneProtKeywords{ "local id", "definition line", "cds comment", "gene locus", "protein name", "mRNA product", "mat_peptide" };
222  vector<string> m_BsrcAutodefWords{ "clone", "cultivar", "culture-collection", "haplogroup", "isolate", "strain", "specimen-voucher" };
223  vector<string> m_EmptyKeywords;
224 };
225 
227 {
228  string m_Column; // field's column number in the table
229  string m_MacroName; // referencing the field in the macro
230  string m_GUIName; // name of the field as it appears in the dialog
231  bool m_UseMacroName{ false }; // true, if the m_MacroName should be used in the macro
232 
234  SFieldFromTable(const string& col, const string& macro_name, const string& label, bool use_macro_name)
235  : m_Column(col), m_MacroName(macro_name), m_GUIName(label), m_UseMacroName(use_macro_name) {}
236  const string& GetFieldName() const
237  {
238  return (m_UseMacroName) ? m_MacroName : m_GUIName;
239  }
240  void Reset()
241  {
242  m_Column = m_MacroName = m_GUIName = kEmptyStr;
243  m_UseMacroName = false;
244  }
245 };
246 
248 
249 #endif
250  // 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
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 GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
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 Fri Sep 20 14:57:19 2024 by modify_doxy.py rev. 669887