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

Go to the SVN repository for this file.

1 #ifndef OBJTOOLS_ALNMGR___ALN_SEQID__HPP
2 #define OBJTOOLS_ALNMGR___ALN_SEQID__HPP
3 /* $Id: aln_seqid.hpp 91306 2020-10-08 11:57:15Z gouriano $
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 * Author: Kamen Todorov, NCBI
29 *
30 * File Description:
31 * Alignment Seq-id
32 *
33 * ===========================================================================
34 */
35 
36 
37 #include <corelib/ncbistd.hpp>
38 #include <corelib/ncbiobj.hpp>
39 
40 #include <objects/seq/Seq_inst.hpp>
42 #include <objmgr/bioseq_handle.hpp>
43 
44 
47 
48 
49 /// Wrapper interface for seq-ids used in alignments. In addition to seq-id
50 /// must provide the corresponding sequence type and base width.
51 /// For implementation see CAlnSeqId.
52 /// @sa CAlnSeqId
54 {
55 public:
56  /// Comparison operators
57  virtual bool operator== (const IAlnSeqId& id) const = 0;
58  virtual bool operator!= (const IAlnSeqId& id) const = 0;
59  virtual bool operator< (const IAlnSeqId& id) const = 0;
60 
61  /// Get CSeq_id
62  virtual const CSeq_id& GetSeqId(void) const = 0;
63 
64  /// Get string representation of the seq-id
65  virtual string AsString(void) const = 0;
66 
68  /// Check sequence type
69  virtual TMol GetSequenceType(void) const = 0;
70  bool IsProtein(void) const;
71  bool IsNucleotide(void) const;
72 
73  /// Get base width for the sequence.
74  /// @return 1 for nucleotides, 3 for proteins
75  virtual int GetBaseWidth(void) const = 0;
76  /// Set base width for the sequence.
77  virtual void SetBaseWidth(int base_width) = 0;
78 
79  /// Virtual destructor
80  virtual ~IAlnSeqId(void)
81  {
82  }
83 };
84 
85 
87 
88 
90 {
91  bool operator()(const TAlnSeqIdIRef& l_id_ref,
92  const TAlnSeqIdIRef& r_id_ref) const
93  {
94  return *l_id_ref < *r_id_ref;
95  }
96 };
97 
98 
100 {
101  bool operator()(const TAlnSeqIdIRef& l_id_ref,
102  const TAlnSeqIdIRef& r_id_ref) const
103  {
104  return *l_id_ref == *r_id_ref;
105  }
106 };
107 
108 
109 /// Default IAlnSeqId implementation based on CSeq_id_Handle.
110 /// @sa CAlnSeqIdConverter
111 /// @sa CAlnSeqIdsExtract
113  public CObject,
114  public CSeq_id_Handle,
115  public IAlnSeqId
116 {
117 public:
118  /// Constructor
119  CAlnSeqId(const CSeq_id& id)
120  : CSeq_id_Handle(CSeq_id_Handle::GetHandle(id)),
121  m_Seq_id(&id),
122  m_Mol(CSeq_inst::eMol_not_set),
123  m_BaseWidth(1)
124  {
125  }
126 
127  virtual const CSeq_id& GetSeqId(void) const;
128 
129  /// Sequence label - same as CSeq_id_Handle::AsString()
130  virtual string AsString(void) const;
131 
132  /// Comparison operators
133  virtual bool operator== (const IAlnSeqId& id) const;
134  virtual bool operator!= (const IAlnSeqId& id) const;
135  virtual bool operator< (const IAlnSeqId& id) const;
136 
137  /// Store bioseq handle for the id.
138  virtual void SetBioseqHandle(const CBioseq_Handle& handle);
139 
140  /// Check sequence type
141  virtual TMol GetSequenceType(void) const;
142 
143  /// Base Width - 1 = nucleotide, 3 = protein.
144  virtual int GetBaseWidth(void) const;
145  virtual void SetBaseWidth(int base_width);
146 
147 private:
150  mutable TMol m_Mol;
152 };
153 
154 
156 
157 #endif // OBJTOOLS_ALNMGR___ALN_SEQID__HPP
bool operator!=(const _Ht_iterator< _Val, _Nonconst_traits< _Val >, _Key, _HF, _ExK, _EqK, _All > &__x, const _Ht_iterator< _Val, _Const_traits< _Val >, _Key, _HF, _ExK, _EqK, _All > &__y)
Definition: _hashtable.h:173
USING_SCOPE(objects)
CIRef< IAlnSeqId > TAlnSeqIdIRef
Definition: aln_seqid.hpp:86
Default IAlnSeqId implementation based on CSeq_id_Handle.
Definition: aln_seqid.hpp:116
CBioseq_Handle m_BioseqHandle
Definition: aln_seqid.hpp:149
int m_BaseWidth
Definition: aln_seqid.hpp:151
TMol m_Mol
Definition: aln_seqid.hpp:150
CAlnSeqId(const CSeq_id &id)
Constructor.
Definition: aln_seqid.hpp:119
CConstRef< CSeq_id > m_Seq_id
Definition: aln_seqid.hpp:148
CBioseq_Handle –.
CObject –.
Definition: ncbiobj.hpp:180
Wrapper interface for seq-ids used in alignments.
Definition: aln_seqid.hpp:54
virtual const CSeq_id & GetSeqId(void) const =0
Get CSeq_id.
virtual string AsString(void) const =0
Get string representation of the seq-id.
virtual void SetBaseWidth(int base_width)=0
Set base width for the sequence.
virtual ~IAlnSeqId(void)
Virtual destructor.
Definition: aln_seqid.hpp:80
virtual int GetBaseWidth(void) const =0
Get base width for the sequence.
virtual TMol GetSequenceType(void) const =0
Check sequence type.
CSeq_inst::TMol TMol
Definition: aln_seqid.hpp:67
Include a standard set of the NCBI C++ Toolkit most basic headers.
bool operator<(const CEquivRange &A, const CEquivRange &B)
bool operator==(const CEquivRange &A, const CEquivRange &B)
#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_XALNMGR_EXPORT
Definition: ncbi_export.h:1065
EMol
molecule class in living organism
Definition: Seq_inst_.hpp:108
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
static bool GetSeqId(const T &d, set< string > &labels, const string name="", bool detect=false, bool found=false)
Uint4 GetSequenceType(const CBioseq_Handle &bsh)
Return a (corrected) set of flags identifying the sequence type.
Definition: sequtils.cpp:42
bool operator()(const TAlnSeqIdIRef &l_id_ref, const TAlnSeqIdIRef &r_id_ref) const
Definition: aln_seqid.hpp:91
bool operator()(const TAlnSeqIdIRef &l_id_ref, const TAlnSeqIdIRef &r_id_ref) const
Definition: aln_seqid.hpp:101
Modified on Thu Feb 22 17:06:47 2024 by modify_doxy.py rev. 669887