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

Go to the SVN repository for this file.

1 /* $Id: Bioseq.hpp 90544 2020-06-26 12:56:10Z grichenk $
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  * 'seq.asn'.
35  *
36  */
37 
38 #ifndef OBJECTS_SEQ_BIOSEQ_HPP
39 #define OBJECTS_SEQ_BIOSEQ_HPP
40 
41 
42 // generated includes
43 #include <objects/seq/Bioseq_.hpp>
44 #include <map>
45 
46 // generated classes
47 
48 
49 #include <objects/seq/Seqdesc.hpp>
50 
51 
53 
54 BEGIN_objects_SCOPE // namespace ncbi::objects::
55 
56 class CSeq_entry;
57 class CBioseq_set;
58 class CSeq_loc;
59 class CDelta_ext;
60 class CSeq_id;
61 
63 {
65 public:
66  // constructor
67  CBioseq(void);
68  // destructor
69  ~CBioseq(void);
70 
71  // Manage Seq-entry tree structure
72  // get parent Seq-entry.
73  // NULL means that either there is no parent Seq-entry,
74  // or CSeq_entry::Parentize() was never called.
75  CSeq_entry* GetParentEntry(void) const;
76 
77  // Convenience function to directly get reference to parent Bioseq-set.
78  // 0 means that either there is no parent Seq-entry or Bioseq-set,
79  // or CSeq_entry::Parentize() was never called.
80  CConstRef<CBioseq_set> GetParentSet(void) const;
81 
82  // Convenience function that looks for the closest descriptor, first on
83  // the Bioseq, then on its parent Bioseq-set, then on its grandparent, etc.
84  // 0 means that either there is no parent Seq-entry or Bioseq-set,
85  // or CSeq_entry::Parentize() was never called. Optional level argument
86  // is 0 if packaged on Bioseq, 1 if on parent, 2 if on grandparent, etc.
87  CConstRef<CSeqdesc> GetClosestDescriptor (CSeqdesc::E_Choice choice, int* level = NULL) const;
88 
89  // see GetTitle in util/sequence.hpp
90  // string GetTitle(const CBioseq_Handle&, TGetTitleFlags);
91 
92  // Construct bioseq from seq-loc. The constructed bioseq
93  // has id = "local|"+str_id or "local|constructed###", where
94  // ### is a generated number; inst::repr = const,
95  // inst::mol = other (since it is impossible to check sequence
96  // type by seq-loc). The location is splitted into simple
97  // locations (intervals, points, whole-s etc.) and put into
98  // ext::delta.
99  explicit CBioseq(const CSeq_loc& loc, const string& str_id = kEmptyStr);
100 
101  enum ELabelType {
104  eBoth
105  };
106 
107  // Append a label to label for a CBioseq based on type, content or both
108  void GetLabel(string* label, ELabelType type, bool worst = false) const;
109 
110  const CSeq_id* GetFirstId() const;
111 
112  /// Find a non-local ID if present, consulting assembly details if
113  /// all IDs for the overall sequence are local.
114  const CSeq_id* GetNonLocalId() const;
115 
116  /// Find a local ID if present
117  const CSeq_id* GetLocalId() const;
118 
119  // check molecule type for nucleotide or protein
120  bool IsNa(void) const;
121  bool IsAa(void) const;
122 
123  /// Determine the tax-id for this bioseq
124  TTaxId GetTaxId() const;
125 
126  // convenience functions for access to Bioseq length
127  bool IsSetLength(void) const;
128  TSeqPos GetLength(void) const;
129 
130  /// Convert a raw nucleotide sequence with occasional ambiguities
131  /// or gaps into a tighter (but somewhat more complex) delta-seq
132  /// representation.
133  void PackAsDeltaSeq(bool gaps_ok = false);
134 
135 protected:
136  // From CSerialUserOp
137  virtual void UserOp_Assign(const CSerialUserOp& source);
138  virtual bool UserOp_Equals(const CSerialUserOp& object) const;
139 
140 private:
141  // Prohibit copy constructor and assignment operator
144 
145  // Seq-entry containing the Bioseq
146  void SetParentEntry(CSeq_entry* entry);
148 
149  static void x_SeqLoc_To_DeltaExt(const CSeq_loc& loc, CDelta_ext& ext);
150 
151  static int sm_ConstructedId;
152 
153  friend class CSeq_entry;
154 };
155 
156 
157 
158 /////////////////// CBioseq inline methods
159 
160 // constructor
161 inline
163  : m_ParentEntry(0)
164 {
165 }
166 
167 inline
169 {
170  m_ParentEntry = entry;
171 }
172 
173 inline
175 {
176  return m_ParentEntry;
177 }
178 
179 /////////////////// end of CBioseq inline methods
180 
181 
182 END_objects_SCOPE // namespace ncbi::objects::
183 
185 
186 #endif // OBJECTS_SEQ_BIOSEQ_HPP
187 /* Original file checksum: lines: 85, chars: 2191, CRC32: 21fd3921 */
Data storage class.
@ eBoth
Both preliminary and traceback stages.
Definition: blast_def.h:332
*** Sequence ******************************** *
Definition: Bioseq_.hpp:82
CSeq_entry * m_ParentEntry
Definition: Bioseq.hpp:147
CSeq_entry * GetParentEntry(void) const
Definition: Bioseq.hpp:174
void SetParentEntry(CSeq_entry *entry)
Definition: Bioseq.hpp:168
ELabelType
Definition: Bioseq.hpp:101
@ eContent
Definition: Bioseq.hpp:103
@ eType
Definition: Bioseq.hpp:102
static int sm_ConstructedId
Definition: Bioseq.hpp:151
CBioseq(const CBioseq &value)
CBioseq(void)
Definition: Bioseq.hpp:162
CBioseq_Base Tparent
Definition: Bioseq.hpp:64
Definition: Seq_entry.hpp:56
CSeq_entry * m_ParentEntry
Definition: Seq_entry.hpp:117
Base class for user-defined serializable classes to allow for objects assignment and comparison.
Definition: serialbase.hpp:319
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
SStrictId_Tax::TId TTaxId
Taxon id type.
Definition: ncbimisc.hpp:1048
#define NULL
Definition: ncbistd.hpp:225
virtual bool UserOp_Equals(const CSerialUserOp &object) const =0
Will be called after comparing the datatool-generated members.
virtual void UserOp_Assign(const CSerialUserOp &source)=0
Will be called after copying the datatool-generated members.
string GetLabel(const CSeq_id &id)
ELabelType
For compatibility with legacy code.
Definition: feature.hpp:85
TSeqPos GetLength(const CSeq_id &id, CScope *scope)
Get sequence length if scope not null, else return max possible TSeqPos.
TTaxId GetTaxId(const CBioseq_Handle &handle)
return the tax-id associated with a given sequence.
Definition: sequence.cpp:274
#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_SEQ_EXPORT
Definition: ncbi_export.h:825
static const char label[]
E_Choice
Choice variants.
Definition: Seqdesc_.hpp:109
CBioseq_Base & operator=(const CBioseq_Base &)
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
const CharType(& source)[N]
Definition: pointer.h:1149
Definition: type.c:6
Modified on Tue Apr 23 07:38:41 2024 by modify_doxy.py rev. 669887