Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ShortestPathInFoldTree.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 core/kinematics/ShortestPathInFoldTree.hh
11 /// @brief Fold tree helper class
12 /// @author Oliver Lange
13 
14 
15 #ifndef INCLUDED_core_kinematics_ShortestPathInFoldTree_hh
16 #define INCLUDED_core_kinematics_ShortestPathInFoldTree_hh
17 
18 
19 // Unit headers
21 
22 // Package Headers
24 
25 // Rosetta Headers
26 // AUTO-REMOVED #include <core/kinematics/Edge.hh>
27 // AUTO-REMOVED #include <core/types.hh>
28 
29 // Utility headers
30 #include <utility/vector1.fwd.hh>
31 #include <utility/pointer/ReferenceCount.hh>
32 
33 // ObjexxFCL Headers
34 // AUTO-REMOVED #include <ObjexxFCL/FArray1D.hh>
35 #include <ObjexxFCL/FArray2D.hh>
36 
37 // C++ Headers
38 #include <map>
39 
41 
42 
43 
44 namespace core {
45 namespace kinematics {
46 
47 /// @brief A helper class that can tell the shortest distance of residues in a given Foldtree
48 /// The fold-tree is parsed only in the beginning such that individual queries are fast
49 class ShortestPathInFoldTree;
51 
53 public:
54  ///@brief Automatically generated virtual destructor for class deriving directly from ReferenceCount
55  virtual ~ShortestPathInFoldTree();
56 
57  // types
59 
60  /// @brief cs-tor, parses fold-tree and caches important distances:
61  /// memory N^2+M*5 N: 2 x number of jumps M: number of residues
63 
64  /// @brief returns the shortest distance of two residues going along Fold-Tree edges.
65  Size dist( Size pos1, Size pos2 ) const;
66 
67  /// @brief returns the shortest distance for the two residues that are furthest apart
68  Size max_dist() const {
69  return max_dist_;
70  }
71 
72 private:
73 
74  /// @brief build table that gives for each residue the distance to the next jump(s) (1 or 2)
76 
77  /// @brief build N^2 table of distances between jump-residues
79 
80  /// @brief if seqpos is a jump_res resturn its internal number
81  int get_jump( Size seqpos ) const {
82  std::map< Size, Size >::const_iterator fit = jump_res_.find ( seqpos );
83  if ( fit != jump_res_.end() ) {
84  return fit->second;
85  } else {
86  return -1;
87  }
88  }
89 
90  /// @brief helper of build_jumpres_distmap
92  void init_dist_map( EdgeList const& );
93 
94  /// private data ===============================
95 
96  /// @brief map from pose-numbering to internal numbering --> jump_res are counted from 1...N
97  /// first: pose-numbering, second internal number
98  std::map< Size, Size > jump_res_;
99 
100  /// @brief 2D array for distances between each pair of jump_residues
101  ObjexxFCL::FArray2D_int node_dist_;
102 
103  /// @brief 1D array for distances of residue j to
104  /// each of max 2 jump_residues that are on the same peptide edge in the fold-tree
105  /// --> for each residue 1+2x2 entries.
106  /// < edgenr > <jump1> <dist1> <jump2> <dist2>
107  /// jump1 upstream jump_residue (internal numbering) jump2 downstream jump-residues
108  /// no up/downstream jumps --> -1
109  ObjexxFCL::FArray2D_int res2jumps_;
110 
111  /// @brief for error checking what is nres_ in the fold-tree
113 
114  /// @brief if fold-tree is simple (no jumps) don't compute anything.
116 
117  /// @brief the furthest distance a query to dist() can return
118  mutable Size max_dist_;
119 };
120 
121 
122 } // kinematics
123 } // core
124 
125 #endif