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

Go to the SVN repository for this file.

1 #ifndef GUI_OBJUTILS___MACRO_FN_AECR__HPP
2 #define GUI_OBJUTILS___MACRO_FN_AECR__HPP
3 /* $Id: macro_fn_aecr.hpp 47198 2022-10-31 03:16:22Z 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:
31  * Macro editing functions that correspond to the operations from the AECR dialog
32  *
33  */
34 
35 /// @file macro_fn_aecr.hpp
36 
37 #include <corelib/ncbistd.hpp>
39 #include <objmgr/seqdesc_ci.hpp>
45 
46 /** @addtogroup GUI_MACRO_SCRIPTS_UTIL
47  *
48  * @{
49  */
50 
52 
54  class CScope;
55  class CSeq_feat;
56  class CSeq_entry_Handle;
57  class CBioseq_set_Handle;
59 BEGIN_SCOPE(macro)
60 
61 DECLARE_FUNC_CLASS_WITH_FNCNAME(CMacroFunction_SwapRelatedFeaturesQual_Depr)
62 
63 DECLARE_FUNC_CLASS_WITH_FNCNAME(CMacroFunction_SetRnaProduct)
64 
65 DECLARE_FUNC_CLASS_WITH_FNCNAME(CMacroFunction_GetRnaProduct)
66 
67 DECLARE_FUNC_CLASS_WITH_FNCNAME(CMacroFunction_RemoveRnaProduct)
68 
69 DECLARE_FUNC_CLASS_WITH_FNCNAME(CMacroFunction_EditSubfield)
70 
71 DECLARE_FUNC_CLASS_WITH_FNCNAME(CMacroFunction_RemoveSubfield)
72 
73 DECLARE_FUNC_CLASS_WITH_FNCNAME(CMacroFunction_SetCodonsRecognized)
74 
75 DECLARE_FUNC_CLASS_WITH_FNCNAME(CMacroFunction_SetStructCommField)
76 
77 DECLARE_FUNC_CLASS_WITH_FNCNAME(CMacroFunction_RmvRelFeatQual)
78 
79 DECLARE_FUNC_CLASS_WITH_FNCNAME(CMacroFunction_LocalID)
80 
81 DECLARE_FUNC_CLASS_WITH_FNCNAME(CMacroFunction_RemoveModifier)
82 
83 DECLARE_FUNC_CLASS_WITH_FNCNAME(CMacroFunction_ValueFromTable)
84 
85 DECLARE_FUNC_CLASS_WITH_FNCNAME(CMacroFunction_GeneQual)
86 
87 DECLARE_FUNC_CLASS_WITH_FNCNAME(CMacroFunction_ParseToDBLink)
88 
89 DECLARE_FUNC_CLASS_WITH_FNCNAME(CMacroFunction_SetAutodefOption)
90 
91 DECLARE_FUNC_CLASS_WITH_FNCNAME(CMacroFunction_AddUnverified)
92 
94 {
95 public:
97  : IEditMacroFunction(func_scope) {}
98 
100  virtual void TheFunction();
102 
103  static bool s_SwapFields(CObjectInfo& src, CObjectInfo& dest);
104 protected:
105  virtual bool x_ValidArguments() const;
106  bool x_DoFieldsExist(CObjectInfo oi, CMQueryNodeValue::TObs& result, size_t index);
107  bool x_SetFields(CObjectInfo oi, CMQueryNodeValue::TObs& result, size_t index);
108  bool x_SwapFields(CObjectInfo& src, CObjectInfo& dest);
109  void x_CopyFields(CMQueryNodeValue::TObs& src_objs, CMQueryNodeValue::TObs& dest_objs);
110  bool x_CopyFields(CObjectInfo& src, CObjectInfo& dest);
111 
112  void x_SetField(CConstRef<CObject>& obj, const string& fieldname, CMQueryNodeValue::TObs& result);
113 };
114 
116 {
117 public:
119  : CMacroFunction_SwapQual(func_scope) {}
120 
121  virtual void TheFunction();
123 protected:
124  virtual bool x_ValidArguments(void) const;
125  bool x_DoDestFeatFieldsExist(
126  const objects::CSeq_feat& src_feat, CMQueryNodeValue::TObs& result, const string& dest_feattype, const string& dest_field);
127  void x_SetOrCreateDestFeatFields(const objects::CSeq_feat& src_feat, CMQueryNodeValue::TObs& result, size_t index);
128 
129  CConstRef<objects::CSeq_feat> m_ConstDestFeat{ nullptr };
130  CRef<objects::CSeq_feat> m_EditDestFeat{ nullptr };
131  CRef<objects::CSeq_feat> m_CreatedFeat{ nullptr };
132 };
133 
135 {
136 public:
138  : IEditMacroFunction(func_scope) {}
139 
141  virtual void TheFunction();
143 
144 protected:
145  virtual bool x_ValidArguments(void) const;
146  void x_SetFields(CMQueryNodeValue::TObs& objs, const string& newValue,
147  objects::edit::EExistingText existing_text, vector<string>& new_values);
148  void x_SetNewPrimitiveValue(CObjectInfo& oi, const string& newValue,
149  objects::edit::EExistingText existing_text, vector<string>& new_values);
150 };
151 
153 {
154 public:
156  : IEditMacroFunction(func_scope) {}
157 
159  virtual void TheFunction();
161  // changes the state of the data iterator
162  static Int4 s_RemoveFields(CIRef<IMacroBioDataIter>& dataiter, CMQueryNodeValue::TObs& objs);
163 protected:
164  virtual bool x_ValidArguments(void) const;
165 };
166 
167 
169 {
170 public:
171  enum ESearchLoc {
172  eAnywhere, // default value
174  eEnd
175  };
176 
178  : IEditMacroFunction(func_scope) {}
179 
181  virtual void TheFunction();
182  static bool s_EditText(string& str, const string& find, const string& repl, ESearchLoc loc, bool case_sensitive, bool is_regex = false);
183  static ESearchLoc s_GetLocFromName(const string& name);
185 protected:
186  virtual bool x_ValidArguments(void) const;
187  void x_EditFields(CMQueryNodeValue::TObs& resolved_objs, const string& find_txt, const string& repl_txt, ESearchLoc loc, bool case_sensitive, bool is_regex);
188 };
189 
191 {
192 public:
194  : CMacroFunction_SetStringQual(func_scope) {}
195 
196  virtual void TheFunction();
198 protected:
199  virtual bool x_ValidArguments(void) const;
200 };
201 
203 {
204 public:
206  : IEditMacroFunction(func_scope) {}
207 
208  virtual void TheFunction();
210 protected:
211  virtual bool x_ValidArguments(void) const;
212 };
213 
215 {
216 public:
218  : IEditMacroFunction(func_scope) {}
219 
220  virtual void TheFunction();
222 protected:
223  virtual bool x_ValidArguments(void) const;
224 };
225 
227 {
228 public:
230  : CMacroFunction_EditStringQual(func_scope) {}
231 
232  virtual void TheFunction();
233  static const char* sm_FunctionName;
234 protected:
235  virtual bool x_ValidArguments(void) const;
236 };
237 
239 {
240 public:
241  virtual ~IOperateOnTwoQuals() {}
242  void ChangeFields(CMQueryNodeValue::TObs& src_objs, CMQueryNodeValue::TObs& dest_objs);
243 protected:
245  : IEditMacroFunction(func_scope) {}
246 
248  bool x_GetDestFields(CObjectInfo oi, size_t index, CMQueryNodeValue::TObs& result);
249  string x_GetSourceString(CObjectInfo& src);
252 private:
253  virtual bool x_ChangeFields(CObjectInfo& src, CObjectInfo& dest) = 0;
254 };
255 
257 {
258 public:
260  : IOperateOnTwoQuals(func_scope) {}
261 
263  virtual void TheFunction();
265 protected:
266  virtual bool x_ValidArguments(void) const;
267  string x_GetSourceString(CObjectInfo& src);
268 private:
269  virtual bool x_ChangeFields(CObjectInfo& src, CObjectInfo& dest);
270 };
271 
273 {
274 public:
276  : CMacroFunction_ConvertStringQual(func_scope) {}
277 
278  virtual void TheFunction();
280 protected:
281  virtual bool x_ValidArguments(void) const;
282 };
283 
285 {
286 public:
288  : CMacroFunction_ConvertStringQual(func_scope) {}
289 
290  virtual void TheFunction();
292 protected:
293  virtual bool x_ValidArguments(void) const;
294 };
295 
297 {
298 public:
300  : IOperateOnTwoQuals(func_scope) {}
301 
303  virtual void TheFunction();
305 protected:
306  virtual bool x_ValidArguments(void) const;
307  string x_GetSourceString(CObjectInfo& src);
308 private:
309  virtual bool x_ChangeFields(CObjectInfo& src, CObjectInfo& dest);
310 };
311 
313 {
314 public:
316  : CMacroFunction_ParseStringQual(func_scope) {}
317 
318  virtual void TheFunction();
320 protected:
321  virtual bool x_ValidArguments(void) const;
322 };
323 
325 {
326 public:
328  : CMacroFunction_ParseStringQual(func_scope) {}
329 
330  virtual void TheFunction();
332 protected:
333  virtual bool x_ValidArguments(void) const;
334 };
335 
337 {
338 public:
340  : IEditMacroFunction(func_scope) {}
341 
343  virtual void TheFunction();
345 protected:
346  virtual bool x_ValidArguments() const;
347  void x_ParseFields(CMQueryNodeValue::TObs& dest_objs, const string& text_portion, objects::edit::EExistingText existing_text);
348 };
349 
350 
352 {
353 public:
355  : CMacroFunction_AddParsedText(func_scope) {}
356 
357  virtual void TheFunction();
359 protected:
360  virtual bool x_ValidArguments(void) const;
361 };
362 
364 {
365 public:
367  : IEditMacroFunction(func_scope) {}
368 
370  virtual void TheFunction();
372 protected:
373  virtual bool x_ValidArguments() const;
374  bool x_GetSpecialField(const string& field, CMQueryNodeValue::TObs& objs, objects::CScope& scope);
375  CRef<objects::edit::CParseTextOptions> x_GetParseOptions(size_t start_index);
376  vector<pair<objects::CSeqdesc_CI, CRef<objects::CSeqdesc>>> m_ChangedDescriptors;
377 };
378 
380 {
381 public:
383  : CMacroFunction_ParsedText(func_scope) {}
384 
385  virtual void TheFunction();
387 protected:
388  virtual bool x_ValidArguments() const;
389 };
390 
392 {
393 public:
395  : IEditMacroFunction(func_scope) {}
396 
397  virtual void TheFunction();
399 
400 protected:
401  virtual bool x_ValidArguments(void) const;
402 private:
403  enum EFieldType {
407  eFieldError
408  };
409 
410  void x_SetFieldType(const string& strcomm_field);
412 };
413 
415 {
416 public:
418  : IOperateOnTwoQuals(func_scope) {}
419 
421  virtual void TheFunction();
423 protected:
424  virtual bool x_ValidArguments(void) const;
425 private:
426  virtual bool x_ChangeFields(CObjectInfo& src, CObjectInfo& dest);
427 };
428 
430 {
431 public:
433  : CMacroFunction_CopyStringQual(func_scope) {}
434 
435  virtual void TheFunction();
437 protected:
438  virtual bool x_ValidArguments(void) const;
439 };
440 
442 {
443 public:
445  : CMacroFunction_CopyStringQual(func_scope) {}
446 
447  virtual void TheFunction();
449 protected:
450  virtual bool x_ValidArguments(void) const;
451 };
452 
453 
455 {
456 public:
458  : IEditMacroFunction(func_scope) {}
459 
461  virtual void TheFunction();
463 protected:
464  virtual bool x_ValidArguments() const;
465 
466  void x_RmvOutsideFields(CMQueryNodeValue::TObs& resolved_objs, const CRemoveTextOptions& options);
467  CRef<CRemoveTextOptions> x_GetRemoveTextOptions(size_t start_index) const;
468  bool x_CheckArguments(size_t index) const;
469 };
470 
472 {
473 public:
475  : CMacroFunction_RemoveOutside(func_scope) {}
476 
477  virtual void TheFunction();
479 protected:
480  virtual bool x_ValidArguments(void) const;
481 };
482 
484 {
485 public:
487 
488  virtual void TheFunction();
489  static bool s_AddSrcOrgMod(objects::CBioSource& bsrc, int subtype, const string& value);
490  static bool s_AddSrcSubSource(objects::CBioSource& bsrc, int subtype, const string& value);
491  static int s_AddGBQualifier(objects::CSeq_feat& feat, const string& qual_name, const string& newValue);
492 protected:
494  : IEditMacroFunction(func_scope), m_IsBiosrc(is_bsrc) {}
495 
496  virtual bool x_ValidArguments() const;
497  void x_AddBioSrcModifier(const string& subtype, const string& newValue);
499 };
500 
502 {
503 public:
505  : CMacroFunction_AddorSetContElement(func_scope, true) {}
506 
508 };
509 
511 {
512 public:
514  : CMacroFunction_AddorSetContElement(func_scope, false) {}
515 
517 };
518 
520 {
521 public:
523  : IEditMacroFunction(func_scope) {}
524 
525  virtual void TheFunction();
527  static int s_UpdateStructCommentDb(objects::CSeqdesc& seqdesc, const string& field, const string& db_name, objects::edit::EExistingText existing_text);
528  static int s_UpdateStructCommentDb(objects::CUser_object& user, const string& field, const string& db_name, objects::edit::EExistingText existing_text);
529  static void s_MoveSuffixToTheEnd(objects::CUser_object& user_object);
530 protected:
531  virtual bool x_ValidArguments() const;
532  // creates a new user object descriptor
533  bool x_MakeNewStructuredComment(const string& db_name, const string& kPrefix, const string& kSuffix);
534 };
535 
537 {
538 public:
542  };
543 
545  virtual void TheFunction();
546  static string s_GetSatelliteType(const string& value);
547  static string s_GetSatelliteName(const string& value);
548  static string s_MakeSatellite(const string& type, const string& name);
549 
550 protected:
552  : IEditMacroFunction(func_scope), m_FieldType(type) {}
553 
554  virtual bool x_ValidArguments() const;
556 };
557 
559 {
560 public:
562  : CMacroFunction_SatelliteFields(func_scope, CMacroFunction_SatelliteFields::eSatelliteType) {}
564 };
565 
567 {
568 public:
570  : CMacroFunction_SatelliteFields(func_scope, CMacroFunction_SatelliteFields::eSatelliteName) {}
572 };
573 
574 
576 {
577 public:
580  eMobileElemTName
581  };
582 
584  virtual void TheFunction();
585  static string s_GetMobileElemTType(const string& value);
586  static string s_GetMobileElemTName(const string& value);
587  static string s_MakeMobileElementT(const string& type, const string& name);
588 
589 protected:
591  : IEditMacroFunction(func_scope), m_FieldType(type) {}
592 
593  virtual bool x_ValidArguments() const;
595 };
596 
598 {
599 public:
603 };
604 
606 {
607 public:
611 };
612 
614 {
615 public:
617  : IEditMacroFunction(func_scope) {}
618 
619  virtual void TheFunction();
621 
622 protected:
623  virtual bool x_ValidArguments() const;
624  void x_ApplyPart(objects::COrgMod& orgmod, NMacroUtil::EStructVoucherPart part, const string& newValue, objects::edit::EExistingText existing_text);
625  void x_RemovePart(objects::COrgMod& orgmod, NMacroUtil::EStructVoucherPart part);
626  CRef<objects::COrgMod> x_AddNewQual(objects::COrgMod::TSubtype subtype, NMacroUtil::EStructVoucherPart part, const string& newValue);
627 };
628 
629 END_SCOPE(macro)
631 
632 /* @} */
633 
634 #endif
635  // GUI_OBJUTILS___MACRO_FN_AECR__HPP
#define true
Definition: bool.h:35
#define false
Definition: bool.h:36
CBioseq_set_Handle –.
CObjectInfo –.
Definition: objectinfo.hpp:597
CScope –.
Definition: scope.hpp:92
CSeq_entry_Handle –.
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
Definition: tempstr.hpp:65
Base class for any user function that performs editing operations on ASN.1 data.
@ eCapChange_none
char value[7]
Definition: config.c:431
Include a standard set of the NCBI C++ Toolkit most basic headers.
CMacroFunction_AddParsedText(EScopeEnum func_scope)
static CTempString GetFuncName()
CMacroFunction_SwapQual(EScopeEnum func_scope)
DECLARE_FUNC_CLASS_WITH_FNCNAME(CMacroFunction_SetPubAuthorMI)
CMacroFunction_SatelliteType(EScopeEnum func_scope)
static CTempString GetFuncName()
CMacroFunction_ParseRNARelQual(EScopeEnum func_scope)
CMacroFunction_AddDBLink(EScopeEnum func_scope)
static CTempString GetFuncName()
CMacroFunction_RemoveOutside(EScopeEnum func_scope)
virtual void TheFunction()
class CMacroFunction_SatelliteFields SATELLITE_NAME() SATELLITE_TYPE()
CMacroFunction_CopyStringQual(EScopeEnum func_scope)
static CTempString GetFuncName()
static CTempString GetFuncName()
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
static CTempString GetFuncName()
CMacroFunction_AddorSetBsrcModifier(EScopeEnum func_scope)
static CTempString GetFuncName()
CMacroFunction_ParseStringQual(EScopeEnum func_scope)
static bool s_AddSrcSubSource(objects::CBioSource &bsrc, int subtype, const string &value)
bool x_GetSourceFields(CObjectInfo oi, size_t index, CMQueryNodeValue::TObs &result)
virtual bool x_ChangeFields(CObjectInfo &src, CObjectInfo &dest)=0
static CTempString GetFuncName()
static CTempString GetFuncName()
CMacroFunction_CopyRNARelQual(EScopeEnum func_scope)
list< SResolvedField > TObs
Definition: macro_exec.hpp:92
CMacroFunction_MobileElementTypeFields(EScopeEnum func_scope, EMobileElemTFieldType type)
CMacroFunction_ParseFeatQual(EScopeEnum func_scope)
CMacroFunction_ParsedTextFrom(EScopeEnum func_scope)
static CTempString GetFuncName()
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
bool x_SetFields(CObjectInfo oi, CMQueryNodeValue::TObs &result, size_t index)
void ChangeFields(CMQueryNodeValue::TObs &src_objs, CMQueryNodeValue::TObs &dest_objs)
static CTempString GetFuncName()
virtual void TheFunction()
class CMacroFunction_SwapQual SwapQual(src_fieldname, dest_fieldname) Swaps the content of two fields...
CMacroFunction_MobileElementName(EScopeEnum func_scope)
void x_AddBioSrcModifier(const string &subtype, const string &newValue)
static CTempString GetFuncName()
CMacroFunction_MobileElementType(EScopeEnum func_scope)
CMacroFunction_AddorSetContElement(EScopeEnum func_scope, bool is_bsrc)
CMacroFunction_EditRelFeatQual(EScopeEnum func_scope)
CMacroFunction_SatelliteName(EScopeEnum func_scope)
bool x_GetDestFields(CObjectInfo oi, size_t index, CMQueryNodeValue::TObs &result)
CMacroFunction_ParsedText(EScopeEnum func_scope)
static CTempString GetFuncName()
virtual ~IOperateOnTwoQuals()
CMacroFunction_ConvertFeatQual(EScopeEnum func_scope)
CMacroFunction_RmvOutsideRelFeatQual(EScopeEnum func_scope)
CMacroFunction_RemoveQual(EScopeEnum func_scope)
virtual ~CMacroFunction_SwapQual()
static string s_MakeSatellite(const string &type, const string &name)
CMacroFunction_EditStringQual(EScopeEnum func_scope)
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
static CTempString GetFuncName()
static CTempString GetFuncName()
static string s_GetSatelliteName(const string &value)
CMacroFunction_ApplyStrucVoucherPart(EScopeEnum func_scope)
static int s_AddGBQualifier(objects::CSeq_feat &feat, const string &qual_name, const string &newValue)
static CTempString GetFuncName()
CMacroFunction_SwapRelFeatQual(EScopeEnum func_scope)
static CTempString GetFuncName()
static CTempString GetFuncName()
static CTempString GetFuncName()
CMacroFunction_ParseToStructComm(EScopeEnum func_scope)
static CTempString GetFuncName()
static CTempString GetFuncName()
static CTempString GetFuncName()
static CTempString GetFuncName()
static int s_UpdateStructCommentDb(objects::CSeqdesc &seqdesc, const string &field, const string &db_name, objects::edit::EExistingText existing_text)
objects::ECapChange m_CapChange
virtual void TheFunction()
Function implementation.
static CTempString GetFuncName()
static int s_UpdateStructCommentDb(objects::CUser_object &user, const string &field, const string &db_name, objects::edit::EExistingText existing_text)
CMacroFunction_ConvertRNARelQual(EScopeEnum func_scope)
static CTempString GetFuncName()
static CTempString GetFuncName()
CMacroFunction_ConvertStringQual(EScopeEnum func_scope)
static CTempString GetFuncName()
CMacroFunction_SetRelFeatQual(EScopeEnum func_scope)
CMacroFunction_SatelliteFields(EScopeEnum func_scope, ESatelliteFieldType type)
static CTempString GetFuncName()
static const char * sm_FunctionName
EditRelatedFeatureQual(feat_type, field_name, find_text, repl_text, location, case_sensitive,...
static CTempString GetFuncName()
string x_GetSourceString(CObjectInfo &src)
IOperateOnTwoQuals(EScopeEnum func_scope)
static CTempString GetFuncName()
static bool s_AddSrcOrgMod(objects::CBioSource &bsrc, int subtype, const string &value)
CMacroFunction_SetQual(EScopeEnum func_scope)
vector< pair< objects::CSeqdesc_CI, CRef< objects::CSeqdesc > > > m_ChangedDescriptors
objects::edit::EExistingText m_ExistingText
CMacroFunction_AddorSetGbQual(EScopeEnum func_scope)
CMacroFunction_CopyFeatQual(EScopeEnum func_scope)
ESatelliteFieldType m_FieldType
CMacroFunction_SetStringQual(EScopeEnum func_scope)
static string s_GetSatelliteType(const string &value)
CMacroFunction_AddParsedToFeatQual(EScopeEnum func_scope)
CMacroFunction_SetStructCommDb(EScopeEnum func_scope)
int32_t Int4
4-byte (32-bit) signed integer
Definition: ncbitype.h:102
#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 string kPrefix
Definition: id2info.cpp:146
const string kSuffix
static const char * str(char *buf, int n)
Definition: stats.c:84
EExistingText
@ eExistingText_cancel
Definition: type.c:6
else result
Definition: token2.c:20
Modified on Sat Mar 02 10:53:32 2024 by modify_doxy.py rev. 669887