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

Go to the SVN repository for this file.

1 /* $Id: User_object.hpp 97948 2022-09-12 13:25:40Z kans $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Author: .......
27  *
28  * File Description:
29  * .......
30  *
31  * Remark:
32  * This code was originally generated by application DATATOOL
33  * using specifications from the ASN data definition file
34  * 'general.asn'.
35  */
36 
37 #ifndef OBJECTS_GENERAL_USER_OBJECT_HPP
38 #define OBJECTS_GENERAL_USER_OBJECT_HPP
39 
40 
41 // generated includes
43 
44 // generated classes
45 
47 
48 BEGIN_objects_SCOPE // namespace ncbi::objects::
49 
51 {
53 public:
54  /// constructor
55  CUser_object(void);
56  /// destructor
57  ~CUser_object(void);
58 
59  /// how to interpret the value in the AddField() conversion functions below.
60  enum EParseField {
61  eParse_String, ///< Add string even if all numbers
62  eParse_Number ///< Parse a real or integer number, otherwise string
63  };
64 
65  /// add a data field to the user object that holds a given value
66  CUser_object& AddField(const string& label, const string& value,
67  EParseField parse = eParse_String);
68  CUser_object& AddField(const string& label, const char* value,
69  EParseField parse = eParse_String);
70  CUser_object& AddField(const string& label, int value);
71  CUser_object& AddField(const string& label, Int8 value);
72  CUser_object& AddField(const string& label, double value);
73  CUser_object& AddField(const string& label, bool value);
74 #ifdef NCBI_STRICT_GI
75  CUser_object& AddField(const string& label, TGi value);
76 #endif
77 
78  CUser_object& AddField(const string& label, const vector<string>& value);
79  CUser_object& AddField(const string& label, const vector<int>& value);
80  CUser_object& AddField(const string& label, const vector<double>& value);
81 
82  CUser_object& AddField(const string& label, CUser_object& value);
83  CUser_object& AddField(const string& label,
84  const vector< CRef<CUser_object> >& value);
85  CUser_object& AddField(const string& label,
86  const vector< CRef<CUser_field> >& value);
87 
88  /// Access a named field in this user object. This is a little
89  /// sneaky in that it interprets a delimiter for recursion.
90  /// This version will throw an exception if the field
91  /// doesn't exist.
92  const CUser_field& GetField(const string& str,
93  const string& delim = ".",
94  NStr::ECase use_case = NStr::eCase) const;
95  CConstRef<CUser_field> GetFieldRef(const string& str,
96  const string& delim = ".",
97  NStr::ECase use_case = NStr::eCase) const;
98 
99  /// Access a named field in this user object. This is a little
100  /// sneaky in that it interprets a delimiter for recursion. The
101  /// 'obj_subtype' parameter is used to set the subtype of a
102  /// sub-object if a new sub-object needs to be created
103  CUser_field& SetField(const string& str,
104  const string& delim = ".",
105  const string& obj_subtype = kEmptyStr,
106  NStr::ECase use_case = NStr::eCase);
107  CRef<CUser_field> SetFieldRef(const string& str,
108  const string& delim = ".",
109  const string& obj_subtype = kEmptyStr,
110  NStr::ECase use_case = NStr::eCase);
111 
112  /// Verify that a named field exists
113  bool HasField(const string& str,
114  const string& delim = ".",
115  NStr::ECase use_case = NStr::eCase) const;
116 
117  /// enum controlling what to return for a label
118  /// this mirrors a request inside of feature::GetLabel()
122  eBoth
123  };
124 
125  /// Append a label to label. The type defaults to content for
126  /// backward compatibility
127  void GetLabel(string* label, ELabelContent mode = eContent) const;
128 
129  ///
130  /// enums for implicit typing of user objects
131  ///
132 
133  /// general category
134  enum ECategory {
135  eCategory_Unknown = -1,
136  eCategory_Experiment
137  };
138 
139  /// sub-category experiment
140  enum EExperiment {
141  eExperiment_Unknown = -1,
142  eExperiment_Sage
143  };
144 
145  /// accessors: classify a given user object
146  ECategory GetCategory(void) const;
147 
148  /// sub-category accessors:
149  EExperiment GetExperimentType(void) const;
150  const CUser_object& GetExperiment(void) const;
151 
152  /// format a user object as a given type. This returns a user-object
153  /// that is suitable for containing whatever specifics might be needed
154  CUser_object& SetCategory(ECategory category);
155 
156  /// format a user object as a given type. This returns a user-object
157  /// that is suitable for containing whatever specifics might be needed
158  CUser_object& SetExperiment(EExperiment category);
159 
160  /// Object Type
161  enum EObjectType {
162  eObjectType_Unknown = -1,
172  eObjectType_Unreviewed
173  };
174 
175  EObjectType GetObjectType() const;
176  void SetObjectType(EObjectType obj_type);
177  bool IsDBLink() const { return GetObjectType() == eObjectType_DBLink; }
178  bool IsStructuredComment() const { return GetObjectType() == eObjectType_StructuredComment; }
179  bool IsOriginalId() const { return GetObjectType() == eObjectType_OriginalId; }
180  bool IsUnverified() const { return GetObjectType() == eObjectType_Unverified; }
181  bool IsValidationSuppression() const { return GetObjectType() == eObjectType_ValidationSuppression; }
182  bool IsCleanup() const { return GetObjectType() == eObjectType_Cleanup; }
183  bool IsAutodefOptions() const { return GetObjectType() == eObjectType_AutodefOptions; }
184  bool IsFileTrack() const { return GetObjectType() == eObjectType_FileTrack; }
185  bool IsRefGeneTracking() const { return GetObjectType() == eObjectType_RefGeneTracking; }
186  bool IsUnreviewed() const { return GetObjectType() == eObjectType_Unreviewed; }
187 
188  // for Unverified User-objects: Can have Organism and/or Feature and/or Misassembled
189  bool IsUnverifiedOrganism() const;
190  void AddUnverifiedOrganism();
191  void RemoveUnverifiedOrganism();
192  bool IsUnverifiedFeature() const;
193  void AddUnverifiedFeature();
194  void RemoveUnverifiedFeature();
195  bool IsUnverifiedMisassembled() const;
196  void AddUnverifiedMisassembled();
197  void RemoveUnverifiedMisassembled();
198  bool IsUnverifiedContaminant() const;
199  void AddUnverifiedContaminant();
200  void RemoveUnverifiedContaminant();
201 
202  // for Unreviewed User-objects: Can have Unannotated
203  bool IsUnreviewedUnannotated() const;
204  void AddUnreviewedUnannotated();
205  void RemoveUnreviewedUnannotated();
206 
207  void UpdateNcbiCleanup(int version);
208 
209  // returns true if one or more matching fields were removed
210  bool RemoveNamedField(const string& field_name, NStr::ECase ecase = NStr::eCase);
211 
212  // Set FileTrack URL
213  void SetFileTrackURL(const string& url);
214  void SetFileTrackUploadId(const string& upload_id);
215 
216  // For RefGeneTracking
217  // See https://confluence.ncbi.nlm.nih.gov/display/REF/RefGeneTracking+user+object?focusedCommentId=94310717#comment-94310717 for spec
218  // JIRA:MSS-677
220  eRefGeneTrackingStatus_Error = -1,
228  eRefGeneTrackingStatus_WGS
229  };
230  void SetRefGeneTrackingStatus(ERefGeneTrackingStatus status);
231  ERefGeneTrackingStatus GetRefGeneTrackingStatus() const;
232  void ResetRefGeneTrackingStatus();
234  {
235  ERefGeneTrackingStatus val = GetRefGeneTrackingStatus();
236  return (val != eRefGeneTrackingStatus_NotSet && val != eRefGeneTrackingStatus_Error);
237  }
238 
239  void SetRefGeneTrackingGenomicSource(const string& genomic_source);
240  const string& GetRefGeneTrackingGenomicSource() const;
241  void ResetRefGeneTrackingGenomicSource();
242  bool IsSetRefGeneTrackingGenomicSource() const { return !GetRefGeneTrackingGenomicSource().empty(); }
243 
244  void SetRefGeneTrackingGenerated(bool val = true);
245  bool GetRefGeneTrackingGenerated() const;
246  void ResetRefGeneTrackingGenerated();
247 
248  // Collaborator field in RefGeneTracking User-object
249  void SetRefGeneTrackingCollaborator(const string& collaborator);
250  const string& GetRefGeneTrackingCollaborator() const;
251  void ResetRefGeneTrackingCollaborator();
252  bool IsSetRefGeneTrackingCollaborator() const { return !GetRefGeneTrackingCollaborator().empty(); }
253 
254 
255  // CollaboratorURL field in RefGeneTracking User-object
256  void SetRefGeneTrackingCollaboratorURL(const string& collaborator_url);
257  const string& GetRefGeneTrackingCollaboratorURL() const;
258  void ResetRefGeneTrackingCollaboratorURL();
259  bool IsSetRefGeneTrackingCollaboratorURL() const { return !GetRefGeneTrackingCollaboratorURL().empty(); }
260 
262  {
263  public:
264  enum EErrCode {
268  eBadStatus
269  };
270 
271  virtual const char* GetErrCodeString() const override
272  {
273  switch (GetErrCode()) {
274  case eUserFieldWithoutLabel: return "User field without label";
275  case eBadUserFieldData: return "Unexpected data type";
276  default: return CException::GetErrCodeString();
277  }
278  }
279 
281  };
282 
284  public:
286  CRefGeneTrackingAccession(const string& accession,
287  TGi gi = ZERO_GI,
288  TSeqPos from = kInvalidSeqPos,
289  TSeqPos to = kInvalidSeqPos,
290  const string& comment = kEmptyStr,
291  const string& acc_name = kEmptyStr) :
292  m_Accession(accession),
293  m_GI(gi),
294  m_From(from),
295  m_To(to),
296  m_Comment(comment),
297  m_Name(acc_name) {}
298 
300 
301  const string& GetAccession() const { return m_Accession; }
302  bool IsSetAccession() const { return !m_Accession.empty(); }
303  const string& GetComment() const { return m_Comment; }
304  bool IsSetComment() const { return !m_Comment.empty(); }
305  const string& GetName() const { return m_Name; }
306  bool IsSetName() const { return !m_Name.empty(); }
307  TGi GetGI() const { return m_GI; }
308  bool IsSetGI() const { return m_GI > ZERO_GI; }
309  TSeqPos GetFrom() const { return m_From; }
310  bool IsSetFrom() const { return m_From != kInvalidSeqPos; }
311  TSeqPos GetTo() const { return m_To; }
312  bool IsSetTo() const { return m_To != kInvalidSeqPos; }
313 
314  bool IsEmpty() const { return !(IsSetAccession() || IsSetComment() ||
315  IsSetName() || IsSetGI() ||
316  IsSetFrom() || IsSetTo()); }
317 
318  CRef<CUser_field> MakeAccessionField() const;
319  static CRef<CRefGeneTrackingAccession> MakeAccessionFromUserField(const CUser_field& field);
320 
321  private:
322  string m_Accession;
326  string m_Comment;
327  string m_Name;
328 
329  /// Prohibit copy constructor and assignment operator
332  };
333 
334  typedef vector<CConstRef<CRefGeneTrackingAccession> > TRefGeneTrackingAccessions;
335 
336  // "IdenticalTo" field in RefGeneTracking User-object: can have only one accession
337  void SetRefGeneTrackingIdenticalTo(const CRefGeneTrackingAccession& accession);
338  CConstRef<CRefGeneTrackingAccession> GetRefGeneTrackingIdenticalTo() const;
339  void ResetRefGeneTrackingIdenticalTo();
340  bool IsSetRefGeneTrackingIdenticalTo() const { return GetRefGeneTrackingIdenticalTo() != CConstRef<CRefGeneTrackingAccession>(NULL); }
341 
342  // "Assembly" field in RefGeneTracking User-object: can have one or more accessions
343  void SetRefGeneTrackingAssembly(const TRefGeneTrackingAccessions& acc_list);
344  TRefGeneTrackingAccessions GetRefGeneTrackingAssembly() const;
345  void ResetRefGeneTrackingAssembly();
346  bool IsSetRefGeneTrackingAssembly() const { return GetRefGeneTrackingAssembly().size() > 0; }
347 
348 private:
349  /// Prohibit copy constructor and assignment operator
352 
353  bool x_IsUnverifiedType(const string& val) const;
354  bool x_IsUnverifiedType(const string& val, const CUser_field& field) const;
355  void x_AddUnverifiedType(const string& val);
356  void x_RemoveUnverifiedType(const string& val);
357 
358  bool x_IsUnreviewedType(const string& val) const;
359  bool x_IsUnreviewedType(const string& val, const CUser_field& field) const;
360  void x_AddUnreviewedType(const string& val);
361  void x_RemoveUnreviewedType(const string& val);
362 
363  // for RefGeneTracking
364  void x_SetRefGeneTrackingField(const string& field_name, const string& value);
365  const string& x_GetRefGeneTrackingField(const string& field_name) const;
366 };
367 
368 
369 
370 /////////////////// CUser_object inline methods
371 
372 // constructor
373 inline
375 {
376 }
377 
378 
379 /////////////////// end of CUser_object inline methods
380 
381 
382 END_objects_SCOPE // namespace ncbi::objects::
383 
385 
386 #endif // OBJECTS_GENERAL_USER_OBJECT_HPP
Data storage class.
@ eBoth
Both preliminary and traceback stages.
Definition: blast_def.h:332
CObject –.
Definition: ncbiobj.hpp:180
CRefGeneTrackingAccession(const CRefGeneTrackingAccession &cpy)=delete
Prohibit copy constructor and assignment operator.
CRefGeneTrackingAccession & operator=(const CRefGeneTrackingAccession &value)=delete
CRefGeneTrackingAccession(const string &accession, TGi gi=ZERO_GI, TSeqPos from=kInvalidSeqPos, TSeqPos to=kInvalidSeqPos, const string &comment=kEmptyStr, const string &acc_name=kEmptyStr)
virtual const char * GetErrCodeString() const override
Get error code interpreted as text.
NCBI_EXCEPTION_DEFAULT(CRefGeneTrackingException, CException)
**** User-object ********************************************** * * a general object for a user defin...
@ eRefGeneTrackingStatus_INFERRED
@ eRefGeneTrackingStatus_VALIDATED
@ eRefGeneTrackingStatus_PREDICTED
@ eRefGeneTrackingStatus_NotSet
@ eRefGeneTrackingStatus_PROVISIONAL
@ eRefGeneTrackingStatus_PIPELINE
@ eRefGeneTrackingStatus_REVIEWED
bool IsRefGeneTracking() const
ECategory
enums for implicit typing of user objects
bool IsSetRefGeneTrackingIdenticalTo() const
bool IsSetRefGeneTrackingGenomicSource() const
bool IsDBLink() const
bool IsCleanup() const
EObjectType
Object Type.
@ eObjectType_RefGeneTracking
@ eObjectType_StructuredComment
@ eObjectType_AutodefOptions
@ eObjectType_ValidationSuppression
bool IsOriginalId() const
bool IsSetRefGeneTrackingCollaboratorURL() const
bool IsValidationSuppression() const
vector< CConstRef< CRefGeneTrackingAccession > > TRefGeneTrackingAccessions
bool IsAutodefOptions() const
bool IsSetRefGeneTrackingStatus() const
CUser_object_Base Tparent
Definition: User_object.hpp:52
CUser_object(const CUser_object &value)
Prohibit copy constructor and assignment operator.
ELabelContent
enum controlling what to return for a label this mirrors a request inside of feature::GetLabel()
EExperiment
sub-category experiment
bool IsUnverified() const
bool IsFileTrack() const
CUser_object(void)
constructor
bool IsSetRefGeneTrackingCollaborator() const
EParseField
how to interpret the value in the AddField() conversion functions below.
Definition: User_object.hpp:60
@ eParse_String
Add string even if all numbers.
Definition: User_object.hpp:61
bool IsUnreviewed() const
bool IsSetRefGeneTrackingAssembly() const
bool IsStructuredComment() const
CUser_object & operator=(const CUser_object &value)
static const char * str(char *buf, int n)
Definition: stats.c:84
void SetField(objects::CUser_object &user, const string &field_name, const string &val)
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
const TSeqPos kInvalidSeqPos
Define special value for invalid sequence position.
Definition: ncbimisc.hpp:878
#define ZERO_GI
Definition: ncbimisc.hpp:1088
#define NULL
Definition: ncbistd.hpp:225
EErrCode
Error types that an application can generate.
Definition: ncbiexpt.hpp:884
virtual const char * GetErrCodeString(void) const
Get error code interpreted as text.
Definition: ncbiexpt.cpp:444
string GetLabel(const CSeq_id &id)
@ eContent
Definition: feature.hpp:87
int64_t Int8
8-byte (64-bit) signed integer
Definition: ncbitype.h:104
#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
ECase
Which type of string comparison.
Definition: ncbistr.hpp:1204
@ eCase
Case sensitive compare.
Definition: ncbistr.hpp:1205
#define NCBI_GENERAL_EXPORT
Definition: ncbi_export.h:512
static const char label[]
static int version
Definition: mdb_load.c:29
mdb_mode_t mode
Definition: lmdb++.h:38
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
bool IsUnverifiedMisassembled(const CBioseq &seq)
bool IsUnverifiedOrganism(const CBioseq &seq)
bool IsUnverifiedContaminant(const CBioseq &seq)
bool IsUnverifiedFeature(const CBioseq &seq)
static void SetRefGeneTrackingStatus(CRef< CSeq_entry > entry, string status)
Modified on Tue May 28 05:54:12 2024 by modify_doxy.py rev. 669887