Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FragsToAtomDist.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 // :noTabs=false:tabSize=4:indentSize=4:
4 //
5 // (c) Copyright Rosetta Commons Member Institutions.
6 // (c) This file is part of the Rosetta software suite and is made available under license.
7 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
8 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
9 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
10 
11 /// @file core/fragments/FragstoAtomDist.fwd.hh
12 /// @brief simulate fragments and recored atom distances
13 /// @author Zaiyong Zhang (zaiyong.zhang@tum.de)
14 /// @date Thr NOV 22 13:22:31 2012
15 ///
16 
17 #ifndef INCLUDED_protocols_noesy_assign_FragsToAtomDist_HH
18 #define INCLUDED_protocols_noesy_assign_FragsToAtomDist_HH
19 
20 //unit headers
22 
23 //package headers
24 
25 //project headers
26 #include <core/types.hh>
27 #include <core/fragment/FragSet.hh>
28 #include <core/pose/Pose.fwd.hh>
29 #include <core/id/AtomID.hh>
30 #include <core/id/NamedAtomID.hh>
31 
32 //utility headers
33 #include <utility/pointer/ReferenceCount.hh>
34 
35 //C++ headers
36 #include <map>
37 #include <cmath>
38 
39 namespace protocols {
40 namespace noesy_assign {
41 
43 public:
45  public:
47  : cum_dist6_( 0 ), cum_dist_( 0 ), min_dist_( 1000 ), count_( 0 ) {};
49  cum_dist6_( std::pow( dist6, -6.0 ) ), cum_dist_( dist ), min_dist_( min_dist ), count_( count ) {};
50 
51  void record( core::Real );
52  void record_inv6( core::Real );
53  bool is_valid() const { return count_; }
54 
55  core::Real average_dist6() const { return std::pow( cum_dist6_ / count_, -1.0/6.0 ); }
56  core::Real average_dist() const { return cum_dist_ / count_; }
57  core::Real min_dist() const { return min_dist_; }
58  core::Real popular_bin() const ;
59 
60  private:
65  std::map< core::Real, core::Size > hist_dist_;
66  std::map< core::Real, core::Size > hist_dist6_;
67  };
68 
69  typedef std::map< core::id::NamedAtomID, DistanceRecord > NamedInnerMap;
70  typedef std::map< core::id::NamedAtomID, NamedInnerMap > NamedDistanceMap;
71 
73  //( 100.0, 100.0, 100.0, 1 );
74 public:
77  read_from_file( filename );
78  }
79  // read/write from stream
80  void read_from_stream( std::istream& );
81  void write_to_stream( std::ostream& ) const;
82 
83  // wrapper for read/write from file
84  void read_from_file( std::string const& filename ); // open stream call read_from_stream
85  void write_to_file( std::string const& filename ) const; //open output file, call write_to_stream
86 
87  // generate distance data from fragments
89  core::fragment::FragSetOP fragments,
90  std::string const& sequence,
91  // bool r6_averaging,
92  core::Size cycles,
93  core::Size dump_freq
94  );
95 
96  // generate distance data from fragments
98  std::string const& filename,
99  std::string const& sequence,
100  // bool r6_averaging,
101  core::Size cycles,
102  core::Size dump_freq
103  ); //read fragments, call generate_from_fragments
104 
105  // query distance between two atoms
108  core::id::NamedAtomID atom1,
109  core::id::NamedAtomID atom2,
110  bool r6_averaged = true
111  ) const {
112  return r6_averaged
113  ? distance_record( atom1, atom2 ).average_dist6()
114  : distance_record( atom1, atom2 ).average_dist();
115  }
116 
117 
118 
119  // compare sequence of fragment data
120  bool check_sequence( std::string const& other_sequence ) const;
121  std::string const& sequence() const { return sequence_; };
122 
123  // has r6_everaging been used to prudecd
124  // bool r6_averaged() const { return r6_averaged_; }
125 
126 
127 private:
128  // small helper function: swap atoms to have always the smaller residue number/atom number first.
129  void swap_atoms( core::id::NamedAtomID& atom1, core::id::NamedAtomID& atom2) const;
130 
133  }
134  // void set_r6_averaged( bool r6_averaged ) {
135  // r6_averaged_=r6_averaged;
136  // }
137 
138  //main helper function -- computes the distance map
140 
141  //fill vector with natoms() of each residue
142  // void initialize_atom_number_of_each_residue( Size, utility::vector1< core::Size >&, core::pose::Pose const& );
143  // void initialize_maps(Size, DistanceMap&, DistanceMap&, utility::vector1< core::Size >, core::pose::Pose const& );
144  // void initialize_atomid_all(Size, AtomIDMap&, utility::vector1< core::Size > );
145 
146  // void average_distmap( DistanceMap&,DistanceMap );
147 
149  // bool r6_averaged_;
152 
153 };// class FragstoAtomDist
154 
155 std::ostream& operator<< ( std::ostream&, FragsToAtomDist::DistanceRecord const& );
156 std::istream& operator>> ( std::istream&, FragsToAtomDist::DistanceRecord const& );
157 
158 }// namespace noesy_assign
159 }// namespace protocols
160 #endif