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

Go to the SVN repository for this file.

1 /* $Id: neutral_seqalign.hpp 83266 2018-08-07 18:29:39Z 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: Christiam Camacho
27  *
28  */
29 
30 /** @file neutral_seqalign.hpp
31  * Neutral representation of a sequence alignment produced by BLAST
32  */
33 
34 #ifndef _NEUTRAL_SEQALIGN_HPP_
35 #define _NEUTRAL_SEQALIGN_HPP_
36 
37 #include <vector>
38 #include <list>
39 #include <util/range.hpp>
40 #include <corelib/ncbimisc.hpp>
42 
44 BEGIN_SCOPE(blast)
45 BEGIN_SCOPE(qa)
46 
48 
49 struct SeqLoc {
50  size_t id;
53 };
54 
55 typedef std::list<SeqLoc> TSeqLocList;
56 
57 const int kInvalidIntValue = -1;
58 const double kInvalidDoubleValue = -1.0;
59 
60 /// Class to contain the gis of the aligned sequences
61 class CAlignedGis {
62 public:
63 
65  : m_Gis(make_pair<TGi, TGi>(INVALID_GI, INVALID_GI)) {}
66 
67  CAlignedGis(TGi query_gi, TGi subj_gi)
68  : m_Gis(make_pair(query_gi, subj_gi)) {}
69 
70  CAlignedGis(std::pair<TGi, TGi> gis)
71  : m_Gis(gis) {}
72 
73  TGi GetQuery() const { return m_Gis.first; }
74  TGi GetSubject() const { return m_Gis.second; }
75  void SetQuery(TGi gi) { m_Gis.first = gi; }
76  void SetSubject(TGi gi) { m_Gis.second = gi; }
77 
78 private:
79  std::pair<TGi, TGi> m_Gis;
80 };
81 
82 /// Neutral sequence alignment (for representing an HSP in BLAST)
83 struct SeqAlign {
84 
85  /// Number of dimensions expected in the alignments
86  enum { kNumDimensions = 2 };
87 
88  int score; ///< HSP score
89  int num_ident; ///< Number of identical residues
90  double evalue; ///< HSP evalue
91  double bit_score; ///< HSP bit score
92  std::vector<int> starts; ///< Query/Subject starting offsets
93  std::vector<TSeqPos> lengths; ///< Lengths of aligned segments
94  int query_strand; ///< Strand of the query sequence
95  int subject_strand; ///< Strand of the subject sequence
96  CAlignedGis sequence_gis; ///< Gis of the aligned sequences
97 
99 
100  /// Default constructor, initializes all fields to kInvalid*Value or empty
106  starts (0),
107  lengths (0),
108  query_strand (0),
109  subject_strand(0),
110  sequence_gis (),
111  loc_list (0)
112  {}
113 
114  /// Return the number of segments in the HSP
115  int GetNumSegments() const;
116 };
117 
118 /// Vector of neutral sequence alignments
119 typedef std::vector<SeqAlign> TSeqAlignSet;
120 
127 };
128 
129 
130 inline int
132 {
133  return lengths.size();
134 }
135 
136 END_SCOPE(qa)
137 END_SCOPE(blast)
139 
140 #endif /* _NEUTRAL_SEQALIGN_HPP_ */
Class to contain the gis of the aligned sequences.
CAlignedGis(std::pair< TGi, TGi > gis)
TGi GetSubject() const
void SetQuery(TGi gi)
CAlignedGis(TGi query_gi, TGi subj_gi)
std::pair< TGi, TGi > m_Gis
void SetSubject(TGi gi)
TGi GetQuery() const
#define INVALID_GI
Definition: ncbimisc.hpp:1089
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
ENa_strand
strand of nucleic acid
Definition: Na_strand_.hpp:64
Magic spell ;-) needed for some weird compilers... very empiric.
Miscellaneous common-use basic types and functionality.
const int kInvalidIntValue
std::vector< SeqAlign > TSeqAlignSet
Vector of neutral sequence alignments.
std::list< SeqLoc > TSeqLocList
ncbi::objects::ENa_strand TStrand
@ eScore_Generic
@ eScore_Evalue
@ eScore_Ignore
@ eScore_BitScore
@ eScore_NumIdent
const double kInvalidDoubleValue
Neutral sequence alignment (for representing an HSP in BLAST)
int GetNumSegments() const
Return the number of segments in the HSP.
std::vector< TSeqPos > lengths
Lengths of aligned segments.
TSeqLocList loc_list
double bit_score
HSP bit score.
int num_ident
Number of identical residues.
double evalue
HSP evalue.
CAlignedGis sequence_gis
Gis of the aligned sequences.
SeqAlign()
Default constructor, initializes all fields to kInvalid*Value or empty.
std::vector< int > starts
Query/Subject starting offsets.
int score
HSP score.
int query_strand
Strand of the query sequence.
int subject_strand
Strand of the subject sequence.
TSeqRange range
TStrand strand
Modified on Fri Sep 20 14:57:55 2024 by modify_doxy.py rev. 669887