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

Go to the SVN repository for this file.

1 #ifndef GUI_OBJUTILS___MACRO_UTIL__HPP
2 #define GUI_OBJUTILS___MACRO_UTIL__HPP
3 /* $Id: macro_util.hpp 47274 2022-12-06 16:17:02Z 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, Colleen Bollin
29  *
30  * File Description: Utility functions used by macro functions
31  *
32  */
33 
34 /// @file macro_util.hpp
35 
36 #include <corelib/ncbistd.hpp>
41 #include <gui/objutils/label.hpp>
42 
43 
44 /** @addtogroup GUI_MACRO_SCRIPTS_UTIL
45  *
46  * @{
47  */
48 
51  class CName_std;
52  class CAuth_list;
54 BEGIN_SCOPE(macro)
55 
56 namespace NMacroUtil
57 {
58  using TVecFeatList = vector<CConstRef<objects::CSeq_feat>>;
59 
61 
63 
64  objects::CSeq_entry_Handle NCBI_GUIOBJUTILS_EXPORT GetParentEntryForBioSource(const objects::CBioSource& bsrc, const objects::CSeq_entry_Handle& tse);
65 
67 
69 
71 
73 
75 
77 
78  void RemoveGeneXref(objects::CSeq_feat& feat);
79 
80  void RemoveEmptyDescriptors(objects::CBioseq& bseq);
81 
82  /// converts ints and doubles into string, by changing the type of the value
84 
85  objects::CSeqFeatData::ESubtype NCBI_GUIOBJUTILS_EXPORT GetFeatSubtype(const string& feat_type);
86 
87  bool NCBI_GUIOBJUTILS_EXPORT StringsAreEquivalent(const string& name1, const string& name2);
88 
89  bool NCBI_GUIOBJUTILS_EXPORT GetLocusTagFromGene(const objects::CGene_ref& gene, string& locus_tag);
90 
91  bool NCBI_GUIOBJUTILS_EXPORT GetLocusTagFromProtRef(const objects::CSeq_feat& prot_feat, objects::CScope& scope, string& locus_tag);
92 
94 
95  bool NCBI_GUIOBJUTILS_EXPORT FindNcbiAutofixUserObject(const objects::CSeq_entry_Handle& tse);
96 
97  objects::CRNA_ref::EType NCBI_GUIOBJUTILS_EXPORT GetRNAType(const string& rna_type);
98 
99  bool NCBI_GUIOBJUTILS_EXPORT IsBiosourceModifier(const string& field);
100 
102 
104 
106 
107  bool NCBI_GUIOBJUTILS_EXPORT ApplyFirstName(objects::CName_std& std_name, const string& newValue, objects::edit::EExistingText existing_text);
108 
109  bool NCBI_GUIOBJUTILS_EXPORT RemoveFirstName(objects::CName_std& std_name);
110 
111  bool NCBI_GUIOBJUTILS_EXPORT ApplyMiddleInitial(objects::CName_std& std_name, const string& newValue, objects::edit::EExistingText existing_text);
112 
113  bool NCBI_GUIOBJUTILS_EXPORT RemoveMiddleInitial(objects::CName_std& std_name);
114 
115  unsigned NCBI_GUIOBJUTILS_EXPORT ApplyAuthorNames(objects::CAuth_list& auth_list, const string& newValue);
116 
118 
119  EStructVoucherPart GetSVPartFromString(const string voucher_part);
120 
121  bool NCBI_GUIOBJUTILS_EXPORT IsStructVoucherPart(const string& field);
122  /// replace any instance of 2 or more spaces with a single instance of 'delimiter'
123  void NCBI_GUIOBJUTILS_EXPORT ConvertMultiSpaces(string& line, const string& delimiter);
124 
125  string NCBI_GUIOBJUTILS_EXPORT TransformForCSV(const string& str);
126 
127  CLabel::ELabelType NameToLabelType(const string& name);
128 
129  bool NCBI_GUIOBJUTILS_EXPORT IsSatelliteSubfield(const string& field);
130 
131  bool NCBI_GUIOBJUTILS_EXPORT IsMobileElementTSubfield(const string& field);
132 
139  };
140 
142 }
143 
144 NCBI_GUIOBJUTILS_EXPORT extern const char* kInst_suffix;
145 NCBI_GUIOBJUTILS_EXPORT extern const char* kColl_suffix;
146 NCBI_GUIOBJUTILS_EXPORT extern const char* kSpecid_suffix;
147 NCBI_GUIOBJUTILS_EXPORT extern const char* kSatelliteType;
148 NCBI_GUIOBJUTILS_EXPORT extern const char* kSatelliteName;
153 NCBI_GUIOBJUTILS_EXPORT extern const char* kStrCommDbname;
154 NCBI_GUIOBJUTILS_EXPORT extern const char* kStrCommFieldName;
155 
156 
158 {
159 public:
160  enum EMatchType {
161  eNone = 0,
164  eLetters
165  };
166 
167  CRemoveTextOptions(EMatchType before_match, const string& before_text, bool remove_before_match,
168  EMatchType after_match, const string& after_text, bool remove_after_match,
169  bool case_insensitive = false, bool whole_word = false)
170  : m_BeforeMatch(before_match), m_BeforeText(before_text),
171  m_RemoveBeforeMatch(remove_before_match),
172  m_AfterMatch(after_match), m_AfterText(after_text),
173  m_RemoveAfterMatch(remove_after_match),
174  m_CaseInsensitive(case_insensitive),
175  m_WholeWord(whole_word)
176  {};
178  bool EditText(string& str) const;
179 
180 private:
182  string m_BeforeText;
185  string m_AfterText;
189 };
190 
191 END_SCOPE(macro)
193 
194 /* @} */
195 
196 #endif // GUI_OBJUTILS___MACRO_UTIL__HPP
@Auth_list.hpp User-defined methods of the data storage class.
Definition: Auth_list.hpp:57
Subclass of the IQueryParseUserObject which is held as the user-defined object in each CQueryParseNod...
Definition: macro_exec.hpp:71
@Name_std.hpp User-defined methods of the data storage class.
Definition: Name_std.hpp:56
CObjectInfo –.
Definition: objectinfo.hpp:597
CObject –.
Definition: ncbiobj.hpp:180
Base class for all serializable objects.
Definition: serialbase.hpp:150
Include a standard set of the NCBI C++ Toolkit most basic headers.
static const char * str(char *buf, int n)
Definition: stats.c:84
objects::ECapChange ConvertStringtoCapitalOption(const string &cap_name)
Definition: macro_util.cpp:105
CConstRef< objects::CBioseq > GetBioseqForSeqdescObject(const CSerialObject *obj, const objects::CSeq_entry_Handle &tse)
bool StringsAreEquivalent(const string &name1, const string &name2)
Definition: macro_util.cpp:397
bool RemoveFirstName(objects::CName_std &std_name)
CLabel::ELabelType NameToLabelType(const string &name)
Definition: macro_util.cpp:893
bool ApplyMiddleInitial(objects::CName_std &std_name, const string &newValue, objects::edit::EExistingText existing_text)
void ConvertMultiSpaces(string &line, const string &delimiter)
replace any instance of 2 or more spaces with a single instance of 'delimiter'
Definition: macro_util.cpp:833
EMatchType m_AfterMatch
Definition: macro_util.hpp:184
const char * kColl_suffix
Definition: macro_util.cpp:933
objects::CSeqFeatData::ESubtype GetFeatSubtype(const string &feat_type)
Definition: macro_util.cpp:350
const char * kMobileElementTType
Definition: macro_util.cpp:938
CMQueryNodeValue::EType GetPrimitiveFromRef(CMQueryNodeValue &node)
Definition: macro_util.cpp:274
bool FindNcbiAutofixUserObject(const objects::CSeq_entry_Handle &tse)
list< SResolvedField > TObs
Definition: macro_exec.hpp:92
void GetPrimitiveObjInfosWithContainers(CMQueryNodeValue::TObs &objs, const CMQueryNodeValue::SResolvedField &info)
Definition: macro_util.cpp:252
const char * kStrCommFieldValue
Definition: macro_util.cpp:940
bool IsStructVoucherPart(const string &field)
Definition: macro_util.cpp:826
void RemoveGeneXref(objects::CSeq_feat &feat)
string GetStringValue(CRef< CMQueryNodeValue > &value)
converts ints and doubles into string, by changing the type of the value
Definition: macro_util.cpp:330
unsigned ApplyAuthorNames(objects::CAuth_list &auth_list, const string &newValue)
const char * kSatelliteType
Definition: macro_util.cpp:935
const char * kSatelliteName
Definition: macro_util.cpp:936
CObjectInfo GetPrimitiveObjInfo(const CObjectInfo &info)
Definition: macro_util.cpp:199
void CleanupForTaxnameChange(CMQueryNodeValue::SResolvedField &res, CObjectInfo oi)
Definition: macro_util.cpp:535
const char * kStrCommFieldName
Definition: macro_util.cpp:942
void GetPrimitiveObjectInfos(CMQueryNodeValue::TObs &objs, const CMQueryNodeValue::SResolvedField &info)
Definition: macro_util.cpp:212
objects::CRNA_ref::EType GetRNAType(const string &rna_type)
Definition: macro_util.cpp:484
string TransformForCSV(const string &str)
Definition: macro_util.cpp:864
EStructVoucherPart GetSVPartFromString(const string voucher_part)
Definition: macro_util.cpp:815
CRemoveTextOptions(EMatchType before_match, const string &before_text, bool remove_before_match, EMatchType after_match, const string &after_text, bool remove_after_match, bool case_insensitive=false, bool whole_word=false)
Definition: macro_util.hpp:167
bool IsTaxname(CMQueryNodeValue::SResolvedField &res)
Definition: macro_util.cpp:513
bool RemoveMiddleInitial(objects::CName_std &std_name)
const char * kInst_suffix
Definition: macro_util.cpp:932
objects::edit::EExistingText ActionTypeToExistingTextOption(const string &action_type, const string &delimiter)
Definition: macro_util.cpp:64
bool GetLocusTagFromProtRef(const objects::CSeq_feat &prot_feat, objects::CScope &scope, string &locus_tag)
bool IsSatelliteSubfield(const string &field)
Definition: macro_util.cpp:903
EMatchType m_BeforeMatch
Definition: macro_util.hpp:181
bool IsMobileElementTSubfield(const string &field)
Definition: macro_util.cpp:908
const char * kMobileElementTQual
Definition: macro_util.cpp:937
bool ApplyFirstName(objects::CName_std &std_name, const string &newValue, objects::edit::EExistingText existing_text)
bool GetLocusTagFromGene(const objects::CGene_ref &gene, string &locus_tag)
bool IsBiosourceModifier(const string &field)
Definition: macro_util.cpp:505
const char * kSpecid_suffix
Definition: macro_util.cpp:934
void SwapGbQualWithValues(CMQueryNodeValue::TObs &objs)
Definition: macro_util.cpp:282
CRef< objects::CSeqdesc > MakeNcbiAutofixUserObject()
Definition: macro_util.cpp:457
const char * kMobileElementTName
Definition: macro_util.cpp:939
EUnverifiedType GetUnverifiedType(const string &value)
Definition: macro_util.cpp:913
vector< CConstRef< objects::CSeq_feat > > TVecFeatList
Definition: macro_util.hpp:58
void RemoveEmptyDescriptors(objects::CBioseq &bseq)
const char * kStrCommDbname
Definition: macro_util.cpp:941
objects::CSeq_entry_Handle GetParentEntryForBioSource(const objects::CBioSource &bsrc, const objects::CSeq_entry_Handle &tse)
@ eUnVer_Misassembled
Definition: macro_util.hpp:136
@ eUnVer_Contaminant
Definition: macro_util.hpp:137
ELabelType
Definition: label.hpp:60
#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 NCBI_GUIOBJUTILS_EXPORT
Definition: gui_export.h:512
static MDB_envinfo info
Definition: mdb_load.c:37
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
static const char delimiter[]
EExistingText
Modified on Mon Jul 22 05:07:17 2024 by modify_doxy.py rev. 669887