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

Go to the SVN repository for this file.

1 /* $Id$
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  */
27 
28 /// @file Genetic_code_.hpp
29 /// Data storage class.
30 ///
31 /// This file was generated by application DATATOOL
32 /// using the following specifications:
33 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/seqfeat/seqfeat.asn">seqfeat.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/seqfeat/seqfeat.def">seqfeat.def</a>
36 ///
37 /// ATTENTION:
38 /// Don't edit or commit this file into CVS as this file will
39 /// be overridden (by DATATOOL) without warning!
40 
41 #ifndef OBJECTS_SEQFEAT_GENETIC_CODE_BASE_HPP
42 #define OBJECTS_SEQFEAT_GENETIC_CODE_BASE_HPP
43 
44 // standard includes
45 #include <serial/serialbase.hpp>
46 
47 // generated includes
48 #include <list>
49 #include <string>
50 #include <vector>
51 
53 
54 #ifndef BEGIN_objects_SCOPE
55 # define BEGIN_objects_SCOPE BEGIN_SCOPE(objects)
56 # define END_objects_SCOPE END_SCOPE(objects)
57 #endif
58 BEGIN_objects_SCOPE // namespace ncbi::objects::
59 
60 
61 // generated classes
62 
63 
64 /** @addtogroup dataspec_NCBI_Seqfeat
65  *
66  * @{
67  */
68 
69 /////////////////////////////////////////////////////////////////////////////
70 /// each code is 64 cells long, in the order where
71 /// T=0,C=1,A=2,G=3, TTT=0, TTC=1, TCA=4, etc
72 /// NOTE: this order does NOT correspond to a Seq-data
73 /// encoding. It is "natural" to codon usage instead.
74 /// the value in each cell is the AA coded for
75 /// start= AA coded only if first in peptide
76 /// in start array, if codon is not a legitimate start
77 /// codon, that cell will have the "gap" symbol for
78 /// that alphabet. Otherwise it will have the AA
79 /// encoded when that codon is used at the start.
80 ///
81 /// CGenetic_code_Base --
82 ///
83 
85 {
87 public:
88  // constructor
89  CGenetic_code_Base(void);
90  // destructor
91  virtual ~CGenetic_code_Base(void);
92 
93  // type info
95 
96  /////////////////////////////////////////////////////////////////////////////
97  ///
98  /// C_E --
99  ///
100 
102  {
104  public:
105  // constructor
106  C_E(void);
107  // destructor
108  ~C_E(void);
109 
110  // type info
112 
113 
114  /// Choice variants.
115  enum E_Choice {
116  e_not_set = 0, ///< No variant selected
117  e_Name, ///< name of a code
118  e_Id, ///< id in dbase
119  e_Ncbieaa, ///< indexed to IUPAC extended
120  e_Ncbi8aa, ///< indexed to NCBI8aa
121  e_Ncbistdaa, ///< indexed to NCBIstdaa
122  e_Sncbieaa, ///< start, indexed to IUPAC extended
123  e_Sncbi8aa, ///< start, indexed to NCBI8aa
124  e_Sncbistdaa ///< start, indexed to NCBIstdaa
125  };
126  /// Maximum+1 value of the choice variant enumerator.
128  e_MaxChoice = 9 ///< == e_Sncbistdaa+1
129  };
130 
131  /// Reset the whole object
132  void Reset(void);
133 
134  /// Reset the selection (set it to e_not_set).
135  void ResetSelection(void);
136 
137  /// Which variant is currently selected.
138  ///
139  /// @return
140  /// Choice state enumerator.
141  E_Choice Which(void) const;
142 
143  /// Verify selection, throw exception if it differs from the expected.
144  ///
145  /// @param index
146  /// Expected selection.
147  void CheckSelected(E_Choice index) const;
148 
149  /// Throw 'InvalidSelection' exception.
150  ///
151  /// @param index
152  /// Expected selection.
153  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
154 
155  /// Retrieve selection name (for diagnostic purposes).
156  ///
157  /// @param index
158  /// One of possible selection states.
159  /// @return
160  /// Name string.
161  static string SelectionName(E_Choice index);
162 
163  /// Select the requested variant if needed.
164  ///
165  /// @param index
166  /// New selection state.
167  /// @param reset
168  /// Flag that defines the resetting of the variant data. The data will
169  /// be reset if either the current selection differs from the new one,
170  /// or the flag is set to eDoResetVariant.
172  /// Select the requested variant if needed,
173  /// allocating CObject variants from memory pool.
174  void Select(E_Choice index,
175  EResetVariant reset,
176  CObjectMemoryPool* pool);
177 
178  // types
179  typedef string TName;
180  typedef int TId;
181  typedef string TNcbieaa;
182  typedef vector< char > TNcbi8aa;
183  typedef vector< char > TNcbistdaa;
184  typedef string TSncbieaa;
185  typedef vector< char > TSncbi8aa;
186  typedef vector< char > TSncbistdaa;
187 
188  // getters
189  // setters
190 
191 
192  /// Check if variant Name is selected.
193  ///
194  /// Name type is defined as 'typedef string TName'.
195  /// @return
196  /// - true, if the variant is selected.
197  /// - false, otherwise.
198  bool IsName(void) const;
199 
200  /// Get the variant data.
201  ///
202  /// @return
203  /// Reference to the data.
204  const TName& GetName(void) const;
205 
206  /// Select the variant.
207  ///
208  /// @return
209  /// Reference to the variant data.
210  TName& SetName(void);
211 
212  /// Select the variant and set its data.
213  ///
214  /// @param value
215  /// Variant data.
216  void SetName(const TName& value);
217 
218 
219  /// Check if variant Id is selected.
220  ///
221  /// Id type is defined as 'typedef int TId'.
222  /// @return
223  /// - true, if the variant is selected.
224  /// - false, otherwise.
225  bool IsId(void) const;
226 
227  /// Get the variant data.
228  ///
229  /// @return
230  /// Copy of the variant data.
231  TId GetId(void) const;
232 
233  /// Select the variant.
234  ///
235  /// @return
236  /// Reference to the variant data.
237  TId& SetId(void);
238 
239  /// Select the variant and set its data.
240  ///
241  /// @param value
242  /// Variant data.
243  void SetId(TId value);
244 
245 
246  /// Check if variant Ncbieaa is selected.
247  ///
248  /// Ncbieaa type is defined as 'typedef string TNcbieaa'.
249  /// @return
250  /// - true, if the variant is selected.
251  /// - false, otherwise.
252  bool IsNcbieaa(void) const;
253 
254  /// Get the variant data.
255  ///
256  /// @return
257  /// Reference to the data.
258  const TNcbieaa& GetNcbieaa(void) const;
259 
260  /// Select the variant.
261  ///
262  /// @return
263  /// Reference to the variant data.
264  TNcbieaa& SetNcbieaa(void);
265 
266  /// Select the variant and set its data.
267  ///
268  /// @param value
269  /// Variant data.
270  void SetNcbieaa(const TNcbieaa& value);
271 
272 
273  /// Check if variant Ncbi8aa is selected.
274  ///
275  /// Ncbi8aa type is defined as 'typedef vector< char > TNcbi8aa'.
276  /// @return
277  /// - true, if the variant is selected.
278  /// - false, otherwise.
279  bool IsNcbi8aa(void) const;
280 
281  /// Get the variant data.
282  ///
283  /// @return
284  /// Reference to the data.
285  const TNcbi8aa& GetNcbi8aa(void) const;
286 
287  /// Select the variant.
288  ///
289  /// @return
290  /// Reference to the variant data.
291  TNcbi8aa& SetNcbi8aa(void);
292 
293 
294  /// Check if variant Ncbistdaa is selected.
295  ///
296  /// Ncbistdaa type is defined as 'typedef vector< char > TNcbistdaa'.
297  /// @return
298  /// - true, if the variant is selected.
299  /// - false, otherwise.
300  bool IsNcbistdaa(void) const;
301 
302  /// Get the variant data.
303  ///
304  /// @return
305  /// Reference to the data.
306  const TNcbistdaa& GetNcbistdaa(void) const;
307 
308  /// Select the variant.
309  ///
310  /// @return
311  /// Reference to the variant data.
312  TNcbistdaa& SetNcbistdaa(void);
313 
314 
315  /// Check if variant Sncbieaa is selected.
316  ///
317  /// Sncbieaa type is defined as 'typedef string TSncbieaa'.
318  /// @return
319  /// - true, if the variant is selected.
320  /// - false, otherwise.
321  bool IsSncbieaa(void) const;
322 
323  /// Get the variant data.
324  ///
325  /// @return
326  /// Reference to the data.
327  const TSncbieaa& GetSncbieaa(void) const;
328 
329  /// Select the variant.
330  ///
331  /// @return
332  /// Reference to the variant data.
333  TSncbieaa& SetSncbieaa(void);
334 
335  /// Select the variant and set its data.
336  ///
337  /// @param value
338  /// Variant data.
339  void SetSncbieaa(const TSncbieaa& value);
340 
341 
342  /// Check if variant Sncbi8aa is selected.
343  ///
344  /// Sncbi8aa type is defined as 'typedef vector< char > TSncbi8aa'.
345  /// @return
346  /// - true, if the variant is selected.
347  /// - false, otherwise.
348  bool IsSncbi8aa(void) const;
349 
350  /// Get the variant data.
351  ///
352  /// @return
353  /// Reference to the data.
354  const TSncbi8aa& GetSncbi8aa(void) const;
355 
356  /// Select the variant.
357  ///
358  /// @return
359  /// Reference to the variant data.
360  TSncbi8aa& SetSncbi8aa(void);
361 
362 
363  /// Check if variant Sncbistdaa is selected.
364  ///
365  /// Sncbistdaa type is defined as 'typedef vector< char > TSncbistdaa'.
366  /// @return
367  /// - true, if the variant is selected.
368  /// - false, otherwise.
369  bool IsSncbistdaa(void) const;
370 
371  /// Get the variant data.
372  ///
373  /// @return
374  /// Reference to the data.
375  const TSncbistdaa& GetSncbistdaa(void) const;
376 
377  /// Select the variant.
378  ///
379  /// @return
380  /// Reference to the variant data.
381  TSncbistdaa& SetSncbistdaa(void);
382 
383 
384  private:
385  // copy constructor and assignment operator
386  C_E(const C_E& );
387  C_E& operator=(const C_E& );
388  // choice state
390  // helper methods
391  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
392 
393  static const char* const sm_SelectionNames[];
394  // data
395  union {
397  NCBI_NS_NCBI::CUnionBuffer<TNcbi8aa> m_Ncbi8aa;
398  NCBI_NS_NCBI::CUnionBuffer<TNcbistdaa> m_Ncbistdaa;
399  NCBI_NS_NCBI::CUnionBuffer<TSncbi8aa> m_Sncbi8aa;
400  NCBI_NS_NCBI::CUnionBuffer<TSncbistdaa> m_Sncbistdaa;
401  NCBI_NS_NCBI::CUnionBuffer<NCBI_NS_STD::string> m_string;
403  };
404  };
405  // types
406  typedef list< CRef< C_E > > Tdata;
407 
408  // getters
409  // setters
410 
411  /// Check if a value has been assigned to data member.
412  ///
413  /// Data member is mandatory;
414  /// its type is defined as 'typedef list< CRef< C_E > > Tdata'
415  /// @return
416  /// - true, if a value has been assigned.
417  /// - false, otherwise.
418  bool IsSet(void) const;
419 
420  /// Check if it is safe to call Get method.
421  ///
422  /// @return
423  /// - true, if the data member is getatable.
424  /// - false, otherwise.
425  bool CanGet(void) const;
426 
427  /// Reset data member.
428  void Reset(void);
429 
430  /// Get the member data.
431  ///
432  /// @return
433  /// Reference to the member data.
434  const Tdata& Get(void) const;
435 
436  /// Assign a value to data member.
437  ///
438  /// @return
439  /// Reference to the data value.
440  Tdata& Set(void);
441 
442  /// Conversion operator to 'const Tdata' type.
443  operator const Tdata& (void) const;
444  /// Conversion operator to 'Tdata' type.
445  operator Tdata& (void);
446 
447 
448 
449 private:
450  // Prohibit copy constructor and assignment operator
453 
454  // data
455  Uint4 m_set_State[1];
456  list< CRef< C_E > > m_data;
457 };
458 
459 /* @} */
460 
461 
462 
463 
464 
465 ///////////////////////////////////////////////////////////
466 ///////////////////// inline methods //////////////////////
467 ///////////////////////////////////////////////////////////
468 inline
470 {
471  return m_choice;
472 }
473 
474 inline
476 {
477  if ( m_choice != index )
478  ThrowInvalidSelection(index);
479 }
480 
481 inline
482 void CGenetic_code_Base::C_E::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
483 {
484  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
485  if ( m_choice != e_not_set )
486  ResetSelection();
487  DoSelect(index, pool);
488  }
489 }
490 
491 inline
493 {
494  Select(index, reset, 0);
495 }
496 
497 inline
499 {
500  return m_choice == e_Name;
501 }
502 
503 inline
505 {
506  CheckSelected(e_Name);
507  return *m_string;
508 }
509 
510 inline
512 {
513  Select(e_Name, NCBI_NS_NCBI::eDoNotResetVariant);
514  return *m_string;
515 }
516 
517 inline
519 {
520  return m_choice == e_Id;
521 }
522 
523 inline
525 {
526  CheckSelected(e_Id);
527  return m_Id;
528 }
529 
530 inline
532 {
533  Select(e_Id, NCBI_NS_NCBI::eDoNotResetVariant);
534  return m_Id;
535 }
536 
537 inline
539 {
540  Select(e_Id, NCBI_NS_NCBI::eDoNotResetVariant);
541  m_Id = value;
542 }
543 
544 inline
546 {
547  return m_choice == e_Ncbieaa;
548 }
549 
550 inline
552 {
553  CheckSelected(e_Ncbieaa);
554  return *m_string;
555 }
556 
557 inline
559 {
560  Select(e_Ncbieaa, NCBI_NS_NCBI::eDoNotResetVariant);
561  return *m_string;
562 }
563 
564 inline
566 {
567  return m_choice == e_Ncbi8aa;
568 }
569 
570 inline
572 {
573  CheckSelected(e_Ncbi8aa);
574  return *m_Ncbi8aa;
575 }
576 
577 inline
579 {
580  Select(e_Ncbi8aa, NCBI_NS_NCBI::eDoNotResetVariant);
581  return *m_Ncbi8aa;
582 }
583 
584 inline
586 {
587  return m_choice == e_Ncbistdaa;
588 }
589 
590 inline
592 {
593  CheckSelected(e_Ncbistdaa);
594  return *m_Ncbistdaa;
595 }
596 
597 inline
599 {
600  Select(e_Ncbistdaa, NCBI_NS_NCBI::eDoNotResetVariant);
601  return *m_Ncbistdaa;
602 }
603 
604 inline
606 {
607  return m_choice == e_Sncbieaa;
608 }
609 
610 inline
612 {
613  CheckSelected(e_Sncbieaa);
614  return *m_string;
615 }
616 
617 inline
619 {
620  Select(e_Sncbieaa, NCBI_NS_NCBI::eDoNotResetVariant);
621  return *m_string;
622 }
623 
624 inline
626 {
627  return m_choice == e_Sncbi8aa;
628 }
629 
630 inline
632 {
633  CheckSelected(e_Sncbi8aa);
634  return *m_Sncbi8aa;
635 }
636 
637 inline
639 {
640  Select(e_Sncbi8aa, NCBI_NS_NCBI::eDoNotResetVariant);
641  return *m_Sncbi8aa;
642 }
643 
644 inline
646 {
647  return m_choice == e_Sncbistdaa;
648 }
649 
650 inline
652 {
653  CheckSelected(e_Sncbistdaa);
654  return *m_Sncbistdaa;
655 }
656 
657 inline
659 {
660  Select(e_Sncbistdaa, NCBI_NS_NCBI::eDoNotResetVariant);
661  return *m_Sncbistdaa;
662 }
663 
664 inline
666 {
667  return ((m_set_State[0] & 0x3) != 0);
668 }
669 
670 inline
672 {
673  return true;
674 }
675 
676 inline
678 {
679  return m_data;
680 }
681 
682 inline
684 {
685  m_set_State[0] |= 0x1;
686  return m_data;
687 }
688 
689 inline
690 CGenetic_code_Base::operator const CGenetic_code_Base::Tdata& (void) const
691 {
692  return m_data;
693 }
694 
695 inline
696 CGenetic_code_Base::operator CGenetic_code_Base::Tdata& (void)
697 {
698  m_set_State[0] |= 0x1;
699  return m_data;
700 }
701 
702 ///////////////////////////////////////////////////////////
703 ////////////////// end of inline methods //////////////////
704 ///////////////////////////////////////////////////////////
705 
706 
707 
708 
709 
710 END_objects_SCOPE // namespace ncbi::objects::
711 
713 
714 
715 #endif // OBJECTS_SEQFEAT_GENETIC_CODE_BASE_HPP
each code is 64 cells long, in the order where T=0,C=1,A=2,G=3, TTT=0, TTC=1, TCA=4,...
Base class for all serializable objects.
Definition: serialbase.hpp:150
EResetVariant
Definition: serialbase.hpp:76
@ eDoResetVariant
Definition: serialbase.hpp:77
@ eDoNotResetVariant
Definition: serialbase.hpp:78
const CSeq_id & GetId(const CSeq_loc &loc, CScope *scope)
If all CSeq_ids embedded in CSeq_loc refer to the same CBioseq, returns the first CSeq_id found,...
uint32_t Uint4
4-byte (32-bit) unsigned integer
Definition: ncbitype.h:103
#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 NCBI_SEQFEAT_EXPORT
Definition: ncbi_export.h:768
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
list< CRef< C_E > > m_data
bool IsSncbistdaa(void) const
Check if variant Sncbistdaa is selected.
TName & SetName(void)
Select the variant.
TId GetId(void) const
Get the variant data.
TNcbi8aa & SetNcbi8aa(void)
Select the variant.
TId & SetId(void)
Select the variant.
Tdata & Set(void)
Assign a value to data member.
CGenetic_code_Base & operator=(const CGenetic_code_Base &)
const TNcbieaa & GetNcbieaa(void) const
Get the variant data.
const TSncbieaa & GetSncbieaa(void) const
Get the variant data.
bool IsNcbi8aa(void) const
Check if variant Ncbi8aa is selected.
const TNcbistdaa & GetNcbistdaa(void) const
Get the variant data.
bool CanGet(void) const
Check if it is safe to call Get method.
bool IsSncbi8aa(void) const
Check if variant Sncbi8aa is selected.
bool IsSncbieaa(void) const
Check if variant Sncbieaa is selected.
E_Choice Which(void) const
Which variant is currently selected.
CGenetic_code_Base(const CGenetic_code_Base &)
const TSncbistdaa & GetSncbistdaa(void) const
Get the variant data.
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
NCBI_NS_NCBI::CUnionBuffer< TSncbi8aa > m_Sncbi8aa
list< CRef< C_E > > Tdata
CSerialObject Tparent
const Tdata & Get(void) const
Get the member data.
NCBI_NS_NCBI::CUnionBuffer< NCBI_NS_STD::string > m_string
const TName & GetName(void) const
Get the variant data.
bool IsNcbieaa(void) const
Check if variant Ncbieaa is selected.
bool IsSet(void) const
Check if a value has been assigned to data member.
TSncbieaa & SetSncbieaa(void)
Select the variant.
NCBI_NS_NCBI::CUnionBuffer< TNcbi8aa > m_Ncbi8aa
NCBI_NS_NCBI::CUnionBuffer< TSncbistdaa > m_Sncbistdaa
TSncbistdaa & SetSncbistdaa(void)
Select the variant.
const TSncbi8aa & GetSncbi8aa(void) const
Get the variant data.
TNcbieaa & SetNcbieaa(void)
Select the variant.
bool IsName(void) const
Check if variant Name is selected.
C_E & operator=(const C_E &)
vector< char > TSncbistdaa
bool IsId(void) const
Check if variant Id is selected.
TSncbi8aa & SetSncbi8aa(void)
Select the variant.
TNcbistdaa & SetNcbistdaa(void)
Select the variant.
bool IsNcbistdaa(void) const
Check if variant Ncbistdaa is selected.
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
E_Choice
Choice variants.
NCBI_NS_NCBI::CUnionBuffer< TNcbistdaa > m_Ncbistdaa
const TNcbi8aa & GetNcbi8aa(void) const
Get the variant data.
@ e_Sncbieaa
start, indexed to IUPAC extended
@ e_Ncbi8aa
indexed to NCBI8aa
@ e_Sncbi8aa
start, indexed to NCBI8aa
@ e_Ncbistdaa
indexed to NCBIstdaa
@ e_Ncbieaa
indexed to IUPAC extended
@ e_not_set
const TYPE & Get(const CNamedParameterList *param)
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Fri Sep 20 14:57:31 2024 by modify_doxy.py rev. 669887