Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DP_Matrix.hh
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file src/core/sequence/DP_Matrix.hh
11 /// @brief class for holding information on a dynamic programming matrix.
12 /// @author James Thompson
13 
14 #ifndef INCLUDED_core_sequence_DP_Matrix_hh
15 #define INCLUDED_core_sequence_DP_Matrix_hh
16 
17 #include <core/types.hh>
18 #include <utility/pointer/owning_ptr.hh>
19 #include <utility/pointer/ReferenceCount.hh>
20 
21 #include <utility/vector1_bool.hh>
22 
23 ///////////////////////////////////////////////////////////////////////////////
24 
25 namespace core {
26 namespace sequence {
27 
28 enum AlignMove {
29  diagonal = 1,
33 };
34 
35 // simple little class to hold scores and store pointers to other Cells. forward declaration
36 // for holding onto CellOPs
37 class Cell;
40 
41 public:
42  Cell() :
43  score_( 0.0 ), type_( diagonal ), coords_( 2, 0 )
44  {}
45 
47  Real const & sc,
48  AlignMove const & ty = end
49  ) :
50  score_( 0.0 ), type_( ty ), coords_( 2, 0 )
51  {
52  score( sc );
53  came_from( ty );
54  backptr_ = 0;
55  }
56 
57  virtual ~Cell();
58 
59  void score( const Real & score ) {
60  score_ = score;
61  }
62 
63  Real score() const {
64  return score_;
65  }
66 
67  Cell & operator =( Cell const & c ) {
68  score( c.score() );
69  return *this ;
70  }
71 
72  void next( CellOP n ) {
73  backptr_ = n;
74  }
75 
77  return backptr_;
78  }
79 
81  return type_;
82  }
83 
84  void came_from( AlignMove const & type ) {
85  type_ = type;
86  }
87 
88  void x( Size const & s ) {
89  coords_[1] = s;
90  }
91 
92  void y( Size const & s ) {
93  coords_[2] = s;
94  }
95 
96  Size x() {
97  return coords_[1];
98  }
99 
100  Size y() {
101  return coords_[2];
102  }
103 
104 private:
109 }; // class Cell
110 
112 
116 
117 public:
118  DP_Matrix( Size rs, Size cs ) {
119  for ( Size i = 1; i <= rs; ++i ) {
120  Row temp;
121  for ( Size j = 1; j <= cs; ++j ) {
122  CellOP c = new Cell( 0.0, end );
123  c->x( i );
124  c->y( j );
125  temp.push_back( c );
126  }
127  scoring_matrix_.push_back( temp );
128  }
129  }
130  virtual ~DP_Matrix();
131 
132  void clear();
133 
134  CellOP
135  operator ()( Size row, Size col ) const;
136 
137  Size rows() const;
138 
139  Size cols() const;
140 
141  void xlab( utility::vector1< char > const & xs );
142 
143  void ylab( utility::vector1< char > const & ys );
144 
146 
148 
149  friend std::ostream & operator<<( std::ostream & out, const DP_Matrix & m );
150 
151 private:
154 }; // DP_Matrix
155 
156 
157 } // sequence
158 } // core
159 
160 #endif