Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FixedBBInteractionGraph.cc
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 core/pack/interaction_graph/FixedBBInteractionGraph.cc
11 /// @brief Precomputed interaction graph class
12 /// @author Andrew Leaver-Fay (leaverfa@email.unc.edu)
13 
14 // Rosetta Headers
16 
17 // ObjexxFCL Headers
18 #include <ObjexxFCL/FArray2D.hh>
19 
20 // Utility headers
21 #include <utility/exit.hh>
22 
23 // STL Headers
24 #include <iostream>
25 
26 using namespace ObjexxFCL;
27 
28 namespace core {
29 namespace pack {
30 namespace interaction_graph {
31 
32 /// @param node1 - [in] - the index of the smaller-indexed node
33 /// @param node2 - [in] - the index of the larger-indexed node
34 /// @param sparse_conn_info - [in] - the boolean 2-D array of amino-acid neighbor info
35 void FixedBBInteractionGraph::set_sparse_aa_info_for_edge(
36  int node1,
37  int node2,
38  FArray2_bool const & sparse_conn_info)
39 {
40  FixedBBEdge* edge = get_fixedbb_edge( node1, node2 );
41  if (edge == NULL)
42  { std::cerr <<
43  "WARNING:: you've input sparse aa info for an edge that does not exist"
44  << std::endl;
45  return;
46  }
47  edge->set_sparse_aa_info( sparse_conn_info );
48  return;
49 }
50 
51 
52 /// @param node1 - [in] - the index of the smaller-indexed node
53 /// @param node2 - [in] - the index of the larger-indexed node
54 /// @param aa_node1 - [in] - the amino acid type for the node with the smaller index
55 /// @param aa_node2 - [in] - the amino acid type for the node with the larger index
56 bool FixedBBInteractionGraph::get_sparse_aa_info_for_edge(
57  int node1,
58  int node2,
59  int node1aa,
60  int node2aa
61 )
62 {
63  FixedBBEdge* edge = get_fixedbb_edge( node1, node2 );
64  if (edge == NULL) {
65  std::cerr << "WARNING:: you've requested sparse aa info for an edge that does not exist" << std::endl;
66  return false;
67  }
68 
69  return edge->get_sparse_aa_info( node1aa, node2aa );
70 }
71 
72 
73 /// @param node1 - [in] - the index of the smaller-indexed node
74 /// @param node2 - [in] - the index of the larger-indexed node
75 /// @param aa_node1 - [in] - the amino acid type for the node with the smaller index
76 /// @param aa_node2 - [in] - the amino acid type for the node with the larger index
77 void FixedBBInteractionGraph::force_aa_neighbors_for_edge
78 (
79  int node1,
80  int node2,
81  int aa_node1,
82  int aa_node2
83 )
84 {
85  FixedBBEdge* edge = get_fixedbb_edge( node1, node2 );
86  if (edge == NULL) {
87  return;
88  }
89  edge->force_aa_neighbors(aa_node1, aa_node2);
90  return;
91 }
92 
93 
94 
95 /// @param node1 - [in] - the index of the smaller-indexed node
96 /// @param node2 - [in] - the index of the larger-indexed node
97 /// @param aa_node1 - [in] - the amino acid type for the node with the smaller index
98 /// @param aa_node2 - [in] - the amino acid type for the node with the larger index
99 void FixedBBInteractionGraph::force_all_aa_neighbors_for_edge
100 (
101  int node1,
102  int node2
103 )
104 {
105  FixedBBEdge* edge = get_fixedbb_edge( node1, node2 );
106  if (edge == NULL) {
107  add_edge( node1, node2 );
108  edge = (FixedBBEdge*) find_edge(node1, node2);
109 
110  FArray2D_bool all_aa_neighbors( get_num_aatypes() , get_num_aatypes(), true);
111  edge->set_sparse_aa_info( all_aa_neighbors );
112  } else {
113  edge->force_all_aa_neighbors();
114  }
115  return;
116 }
117 
118 /// @param node1 - [in] - the index of the smaller-indexed node
119 /// @param node2 - [in] - the index of the larger-indexed node
120 /// @param state_node1 - [in] - state on smaller-indexed node
121 /// @param state_node2 - [in] - state on larger-indexed node
123 FixedBBInteractionGraph::get_two_body_energy_for_edge(
124  int node1,
125  int node2,
126  int state_node1,
127  int state_node2
128 ) const
129 {
130  FixedBBEdge const * edge = get_fixedbb_edge( node1, node2 );
131  if (edge == NULL) {
132  return 0;
133  }
134  return edge->get_two_body_energy( state_node1, state_node2 );
135 }
136 
137 /// @details Base class provides no implementation for this functionality
138 bool
139 FixedBBInteractionGraph::aa_submatrix_energies_retrievable() const
140 {
141  return false;
142 }
143 
144 /// @details Derived classes wishing to respond to the get_aa_submatrix_energies_for_edge
145 /// must implement this function as well, which allows the mapping between states
146 /// and their on-node amino-acid index (which may very well represent something other
147 /// than the index of the enumeration element for the rotamer's "aa()").
148 int
149 FixedBBInteractionGraph::aatype_for_node_state( int, int ) const
150 {
151  utility_exit_with_message("Unimplemented aatype_for_node_state" );
152  return 0;
153 }
154 
155 /// @details Do not call this function unless it is implemented in the derived
156 /// class, as should be indicated by the "aa_submatrix_energies_retrivable" method.
157 ObjexxFCL::FArray2D< core::PackerEnergy >
158 FixedBBInteractionGraph::get_aa_submatrix_energies_for_edge(
159  int ,
160  int ,
161  int ,
162  int
163 ) const
164 {
165  utility_exit_with_message("Unimplemented get_aa_submatrix_energies_for_edge" );
166  return ObjexxFCL::FArray2D< core::PackerEnergy >();
167 }
168 
169 
170 } //end namespace interaction_graph
171 } //end namespace pack
172 } //end namespace core