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

Go to the SVN repository for this file.

1 /* $Id: seqlocinfo.hpp 45453 2010-04-15 13:44:21Z satskyse $
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: Christiam Camacho, Vahram Avagyan
27 *
28 */
29 
30 #ifndef OBJECTS_SEQ___SEQLOCINFO__HPP
31 #define OBJECTS_SEQ___SEQLOCINFO__HPP
32 
35 #include <util/range.hpp> // For TSeqRange
36 
38 
40  class CSeq_loc;
41  class CPacked_seqint;
43 
44 //Note: The following types have been refactored
45 // from algo/blast/api/blast_aux.hpp
46 
47 ///structure for seqloc info
49 public:
51  eFramePlus1 = 1,
52  eFramePlus2 = 2,
53  eFramePlus3 = 3,
54  eFrameMinus1 = -1,
55  eFrameMinus2 = -2,
56  eFrameMinus3 = -3,
57  eFrameNotSet = 0
58  };
59 
60  CSeqLocInfo(objects::CSeq_interval* interval, int frame)
61  : m_Interval(interval)
62  { SetFrame(frame); }
63 
64  CSeqLocInfo(objects::CSeq_id& id, TSeqRange& range, int frame)
65  : m_Interval(new objects::CSeq_interval(id, range.GetFrom(),
66  range.GetToOpen()))
67  { SetFrame(frame); }
68 
69  const objects::CSeq_interval& GetInterval() const { return *m_Interval; }
70 
71  const objects::CSeq_id& GetSeqId() const { return m_Interval->GetId(); }
72 
73  void SetInterval(objects::CSeq_interval* interval)
74  { m_Interval.Reset(interval); }
75 
76  /// Convert the frame to a strand
78 
79  int GetFrame() const { return (int) m_Frame; }
80 
81  void SetFrame(int frame); // Throws exception on out-of-range input
82 
83  operator TSeqRange() const {
84  return TSeqRange(m_Interval->GetFrom(), m_Interval->GetTo()-1);
85  }
86 
87  operator pair<TSeqPos, TSeqPos>() const {
88  return make_pair<TSeqPos, TSeqPos>(m_Interval->GetFrom(),
89  m_Interval->GetTo());
90  }
91 
92  friend ostream& operator<<(ostream& out, const CSeqLocInfo& rhs) {
93  out << "CSeqLocInfo = { " << MSerial_AsnText << *rhs.m_Interval
94  << "ETranslationFrame = " << rhs.m_Frame << "\n}";
95  return out;
96  }
97 
98  bool operator==(const CSeqLocInfo& rhs) const;
99 
100  bool operator!=(const CSeqLocInfo& rhs) const {
101  return ! (*this == rhs);
102  }
103 
104 private:
106  ETranslationFrame m_Frame; // For translated nucleotide sequence
107 };
108 
109 typedef list< CRef<CSeqLocInfo> > TSeqLocInfoCRefList;
110 
111 /// Collection of masked regions for a single query sequence
113 {
114 public:
115  /// Return a new instance of this object that is restricted to the location
116  /// specified
117  /// @param location location describing the range to restrict. Note that
118  /// only the provided range is examined, the Seq-id and strand of the
119  /// location (if assigned and different from unknown) is copied verbatim
120  /// into the return value of this method [in]
121  /// @return empty TMaskedQueryRegions if this object is empty, otherwise
122  /// the intersection of location and this object
124  RestrictToSeqInt(const objects::CSeq_interval& location) const;
125 
126  /// Converts this object to a CPacked_seqint (this is the convention used
127  /// to encode masking locations in the network BLAST 4 protocol)
128  CRef<objects::CPacked_seqint> ConvertToCPacked_seqint() const;
129 
130  /// Returns true if there are masks on the negative strand
131  bool HasNegativeStrandMasks() const;
132 };
133 
134 /// TMaskedSubjRegions defined as synonym to TMaskedQueryRegions
136 
137 /// Collection of masked regions for all queries in a BLAST search
138 /// @note this supports tra
139 typedef vector< TMaskedQueryRegions > TSeqLocInfoVector;
140 
142 
143 #endif /* OBJECTS_SEQ___SEQLOCINFO__HPP */
CObject –.
Definition: ncbiobj.hpp:180
structure for seqloc info
Definition: seqlocinfo.hpp:48
const objects::CSeq_id & GetSeqId() const
Definition: seqlocinfo.hpp:71
bool operator!=(const CSeqLocInfo &rhs) const
Definition: seqlocinfo.hpp:100
friend ostream & operator<<(ostream &out, const CSeqLocInfo &rhs)
Definition: seqlocinfo.hpp:92
ETranslationFrame m_Frame
Definition: seqlocinfo.hpp:106
CRef< objects::CSeq_interval > m_Interval
Definition: seqlocinfo.hpp:105
CSeqLocInfo(objects::CSeq_interval *interval, int frame)
Definition: seqlocinfo.hpp:60
void SetInterval(objects::CSeq_interval *interval)
Definition: seqlocinfo.hpp:73
CSeqLocInfo(objects::CSeq_id &id, TSeqRange &range, int frame)
Definition: seqlocinfo.hpp:64
const objects::CSeq_interval & GetInterval() const
Definition: seqlocinfo.hpp:69
int GetFrame() const
Definition: seqlocinfo.hpp:79
Collection of masked regions for a single query sequence.
Definition: seqlocinfo.hpp:113
static const char location[]
Definition: config.c:97
bool operator==(const CEquivRange &A, const CEquivRange &B)
std::ofstream out("events_result.xml")
main entry point for tests
#define MSerial_AsnText
I/O stream manipulators –.
Definition: serialbase.hpp:696
ENa_strand GetStrand(const CSeq_loc &loc, CScope *scope=0)
Returns eNa_strand_unknown if multiple Bioseqs in loc Returns eNa_strand_other if multiple strands in...
CRange< TSeqPos > TSeqRange
typedefs for sequence ranges
Definition: range.hpp:419
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
#define NCBI_SEQ_EXPORT
Definition: ncbi_export.h:825
ENa_strand
strand of nucleic acid
Definition: Na_strand_.hpp:64
range(_Ty, _Ty) -> range< _Ty >
TMaskedQueryRegions TMaskedSubjRegions
TMaskedSubjRegions defined as synonym to TMaskedQueryRegions.
Definition: seqlocinfo.hpp:135
vector< TMaskedQueryRegions > TSeqLocInfoVector
Collection of masked regions for all queries in a BLAST search.
Definition: seqlocinfo.hpp:139
list< CRef< CSeqLocInfo > > TSeqLocInfoCRefList
Definition: seqlocinfo.hpp:109
Modified on Fri Mar 01 10:09:03 2024 by modify_doxy.py rev. 669887