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

Go to the SVN repository for this file.

1 /* $Id: Seq_feat.hpp 97464 2022-07-20 12:28:40Z 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  * 'seqfeat.asn'.
35  */
36 
37 #ifndef OBJECTS_SEQFEAT_SEQ_FEAT_HPP
38 #define OBJECTS_SEQFEAT_SEQ_FEAT_HPP
39 
40 
41 // generated includes
49 
50 // generated classes
51 
53 
54 BEGIN_objects_SCOPE /// namespace ncbi::objects::
55 
57  public ISeq_feat
58 {
60 public:
61  /// constructor
62  CSeq_feat(void);
63  /// destructor
64  ~CSeq_feat(void);
65 
66  //
67  /// See related function in util/feature.hpp
68  //
69  /// void GetLabel (const CSeq_feat&, string*, ELabelType, CScope*)
70  //
71 
72  /// get gene (if present) from Seq-feat.xref list
73  const CGene_ref* GetGeneXref(void) const;
74  void SetGeneXref(CGene_ref& value);
75  CGene_ref& SetGeneXref(void);
76 
77  /// get protein (if present) from Seq-feat.xref list
78  const CProt_ref* GetProtXref(void) const;
79  void SetProtXref(CProt_ref& value);
80  CProt_ref& SetProtXref(void);
81 
82  bool HasSeqFeatXref(const CSeqFeatXref::TId& id) const;
83  bool AddSeqFeatXref(const CSeqFeatXref::TId& id);
84 
85  /// Add a qualifier to this feature
86  void AddQualifier(const string& qual_name, const string& qual_val);
87 
88  /// Add a qualifier to this feature, or replace the value for the first
89  /// one if it already exists.
90  void AddOrReplaceQualifier(const string& qual_name, const string& qual_val);
91 
92  /// Remove all qualifiers with the given name; do nothing if
93  /// no such qualifier exists. Complexity is linear in the number of quals,
94  /// which is the best that can be done since quals may not be sorted.
95  void RemoveQualifier(const string& qual_name);
96 
97  /// add a DB xref to this feature
98  void AddDbxref(const string& db_name, const string& db_key);
99  void AddDbxref(const string& db_name, int db_key);
100 
101  /// Add the given exception_text and set the except flag to true.
102  /// If the exception_text is already there, it just sets the except flag.
103  void AddExceptText(const string & exception_text);
104 
105  /// Remove all instances of the given exception text in this feature,
106  /// and reset the except flag if there are no exception texts left.
107  void RemoveExceptText(const string & exception_text);
108 
109  /// Produces the list of legal exceptions. Note that more than one of
110  /// these values might occur in Seq-feat.exception_text, separated by
111  /// commas, however RefSeq-only exceptions should only appear alone.
112  static vector<string> GetListOfLegalExceptions(bool include_refseq);
113 
114  /// Indicates whether this specific text occurs in the list of legal exceptions
115  static bool IsExceptionTextInLegalList(const string& exception_text, bool allow_refseq);
116 
117  /// Indicates whether this specific text is a RefSeq-only exception
118  static bool IsExceptionTextRefSeqOnly(const string& exception_text);
119 
120  /// Return a specified DB xref. This will find the *first* item in the
121  /// given referenced database. If no item is found, an empty CConstRef<>
122  /// is returned.
124 
125  /// Return a named qualifier. This will return the first item matching the
126  /// qualifier name. If no such qualifier is found, an empty string is
127  /// returned.
128  const string& GetNamedQual(const CTempString& qual_name) const;
129 
130  /// Warning: This is invalidated if the underlying except_text is
131  /// changed in any way.
133 
134  /// Returns a case-insensitive set of exception texts.
135  /// Warning: The returned contents are invalidated
136  /// if the underlying exception_text is changed in any way.
137  AutoPtr<TExceptionTextSet> GetTempExceptionTextSet(void) const;
138 
139  /// Returns whether or not the given exception_text is set for this
140  /// feature. Note that it always returns false if IsExcept is set,
141  /// even if there is exception text.
142  ///
143  /// @param exception_text
144  /// The exception text to search for.
145  bool HasExceptionText(const string & exception_text ) const;
146 
147  /// Compare relative order of this feature and feature f2,
148  /// ordering first by features' coordinates, by importance of their type,
149  /// by complexity of location, and by some other fields depending on
150  /// their types.
151  /// Return a value < 0 if this feature should come before f2.
152  /// Return a value > 0 if this feature should come after f2.
153  /// Return zero if the features are unordered.
154  /// Note, that zero value doesn't mean that the features are identical.
155  int Compare(const CSeq_feat& f2) const;
156  int Compare(const CSeq_feat& f2,
157  const CSeq_loc& mapped1, const CSeq_loc& mapped2) const;
158  /// Compare features more thoroughly than Compare() - return zero only
159  /// if the features are identical, otherwise use ASN.1 text representation
160  /// to compare features.
161  int CompareStrict(const CSeq_feat& f2) const;
162 
163  /// Compare relative order of this feature and feature f2 similarily
164  /// to the Compare() method, assuming their locations are already
165  /// compared as unordered.
166  /// The features' locations are still needed because the order depends
167  /// also on complexity of location (mix or not, etc).
168  /// The features are assumed to have location as given in arguments:
169  /// loc1 - location of this feature, loc2 - location of feature f2.
170  /// This method is useful if features are mapped to a master sequence,
171  /// so their location are changed after mapping.
172  /// Return a value < 0 if this feature should come before f2.
173  /// Return a value > 0 if this feature should come after f2.
174  /// Return zero if the features are unordered.
175  /// Note, that zero value doesn't mean that the features are identical.
176  int CompareNonLocation(const CSeq_feat& f2,
177  const CSeq_loc& loc1, const CSeq_loc& loc2) const;
178 
179  /// Return relative importance order of features by their type.
180  /// These methods are used by Compare() and CompareNonLocation() methods.
181  int GetTypeSortingOrder(void) const;
182  static int GetTypeSortingOrder(CSeqFeatData::E_Choice type);
183 
184  /// Find extension by type in exts container.
185  /// @param ext_type
186  /// String id of the extension to find.
187  /// @result
188  /// User-object of the requested type or NULL.
189  CConstRef<CUser_object> FindExt(const string& ext_type) const;
190  /// Non-const version of FindExt().
191  CRef<CUser_object> FindExt(const string& ext_type);
192 
193  enum EAddExt {
194  fAddExt_ReplaceAll = 1 << 0 ///< Before adding, remove all previous
195  };
196  typedef int TAddExt; ///< binary OR of EAddExt
197 
198  /// Add an extension by type in exts container. Note that it's
199  /// always added to the Exts field, never the Ext field.
200  /// Also, it does not check for dups.
201  ///
202  /// @param ext
203  /// The ext to be added. It will NOT be copied.
204  void AddExt(CRef<CUser_object> ext, TAddExt add_flags = 0);
205 
206  /// Remove all Exts with the given type. Note: Runs in linear time
207  /// relative to the number of Exts total.
208  ///
209  /// @param ext_type
210  /// String id of the extension to find.
211  void RemoveExt(const string& ext_type);
212 
213 private:
214 
215  /// Prohibit copy constructor and assignment operator
218 };
219 
220 
221 /////////////////// CSeq_feat inline methods
222 
223 // constructor
224 inline
226 {
227 }
228 
229 
230 // Corresponds to SortFeatItemListByPos from the C toolkit
231 inline
233  const CSeq_loc& loc1, const CSeq_loc& loc2) const
234 {
235  int diff = loc1.Compare(loc2, CSeq_loc::fCompare_Default);
236  return diff != 0? diff: CompareNonLocation(f2, loc1, loc2);
237 }
238 
239 
240 // Corresponds to SortFeatItemListByPos from the C toolkit
241 inline
242 int CSeq_feat::Compare(const CSeq_feat& f2) const
243 {
244  return Compare(f2, GetLocation(), f2.GetLocation());
245 }
246 
247 
248 inline
250 {
251  return GetTypeSortingOrder(GetData().Which());
252 }
253 
254 
256 inline
257 bool operator< (const CSeq_feat& f1, const CSeq_feat& f2)
258 {
259  return f1.Compare(f2) < 0;
260 }
261 
262 /////////////////// end of CSeq_feat inline methods
263 
264 
265 END_objects_SCOPE /// namespace ncbi::objects::
266 
268 
269 
270 #endif /// OBJECTS_SEQFEAT_SEQ_FEAT_HPP
271 /* Original file checksum: lines: 90, chars: 2388, CRC32: c285198b */
User-defined methods of the data storage class.
bool operator<(const CSeq_feat &f1, const CSeq_feat &f2)
Definition: Seq_feat.hpp:257
Data storage class.
AutoPtr –.
Definition: ncbimisc.hpp:401
CFeat_id –.
Definition: Feat_id.hpp:66
*** Seq-feat ******************************************* * sequence feature generalization
Definition: Seq_feat_.hpp:89
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
int GetTypeSortingOrder(void) const
Return relative importance order of features by their type.
Definition: Seq_feat.hpp:249
CSeq_feat(void)
constructor
Definition: Seq_feat.hpp:225
int CompareNonLocation(const CSeq_feat &f2, const CSeq_loc &loc1, const CSeq_loc &loc2) const
Compare relative order of this feature and feature f2 similarily to the Compare() method,...
Definition: Seq_feat.cpp:103
CSeq_feat_Base Tparent
Definition: Seq_feat.hpp:59
CSeq_feat & operator=(const CSeq_feat &value)
int TAddExt
binary OR of EAddExt
Definition: Seq_feat.hpp:196
int Compare(const CSeq_feat &f2) const
Compare relative order of this feature and feature f2, ordering first by features' coordinates,...
Definition: Seq_feat.hpp:242
CSeq_feat(const CSeq_feat &value)
Prohibit copy constructor and assignment operator.
set< CTempStringEx, PNocase > TExceptionTextSet
Warning: This is invalidated if the underlying except_text is changed in any way.
Definition: Seq_feat.hpp:132
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
Definition: tempstr.hpp:65
virtual const string & GetNamedQual(const CTempString &qual_name) const =0
Return a named qualifier.
virtual const CProt_ref * GetProtXref(void) const =0
get protein (if present) from Seq-feat.xref list
virtual CConstRef< CDbtag > GetNamedDbxref(const CTempString &db) const =0
Return a specified DB xref.
virtual const CGene_ref * GetGeneXref(void) const =0
get gene (if present) from Seq-feat.xref list
Definition: set.hpp:45
int Compare(const CSeq_loc &loc) const
Definition: Seq_loc.cpp:590
@ fCompare_Default
Definition: Seq_loc.hpp:245
sequence::ECompare Compare(const CSeq_loc &loc1, const CSeq_loc &loc2, CScope *scope)
Returns the sequence::ECompare containment relationship between CSeq_locs.
#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
const TLocation & GetLocation(void) const
Get the Location member data.
Definition: Seq_feat_.hpp:1117
E_Choice
Choice variants.
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_feat_.hpp:925
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Definition: type.c:6
Modified on Wed Apr 24 14:15:33 2024 by modify_doxy.py rev. 669887