Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
StepWiseFilterer.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 StepWiseFilterer
11 /// @brief Not particularly fancy, just filters a list of poses.
12 /// @detailed
13 /// @author Rhiju Das
14 
15 
16 //////////////////////////////////
18 
19 //////////////////////////////////
20 #include <core/types.hh>
21 #include <core/pose/Pose.hh>
22 #include <core/scoring/Energies.hh>
25 
26 #include <list>
27 
28 #include <utility/vector1.hh>
29 
30 //Auto Headers
31 
32 
33 
34 using namespace core;
35 using core::Real;
36 
37 namespace protocols {
38 namespace swa {
39 
40 
41  //////////////////////////////////////////////////////////////////////////
42  //constructor!
43  StepWiseFilterer::StepWiseFilterer():
44  final_number_( 400 )
45  {
46  }
47 
48  //////////////////////////////////////////////////////////////////////////
49  //destructor
51  {}
52 
53  //////////////////////////////////////////////////////////////////////////
54  void
55  StepWiseFilterer::filter( PoseList & pose_list, PoseList & filter_pose_list ) const
56  {
57 
58  using namespace core::scoring;
59  using namespace core::pose;
60 
61  static ScoreFunctionOP fa_scorefxn = core::scoring::getScoreFunction();
62 
63  typedef std::list < std::pair< Real, std::string > > ScoreList;
64  ScoreList score_list;
65 
66  for ( PoseList::iterator iter = pose_list.begin(); iter != pose_list.end(); iter++ ) {
67  PoseOP & pose_op( iter->second );
68  Pose & pose( *pose_op );
69  Real score = (*fa_scorefxn)( pose );
70 
71  /////////////////////////////////////////////////////////////////////////////
72  /////////////////////////////////////////////////////////////////////////////
73  score -= pose.energies().total_energies()[ fa_rep ]; /*downweight fa_rep */
74  /////////////////////////////////////////////////////////////////////////////
75  /////////////////////////////////////////////////////////////////////////////
76 
77  std::string const & tag( iter->first );
78 
79  score_list.push_back( std::make_pair( score, tag ) );
80  }
81 
82  // std::cout << "LIST OF POSES " << pose_list.size() << " " << score_list.size() << std::endl;
83 
84  score_list.sort();
85 
86  Size count( 0 );
87  for ( ScoreList::const_iterator iter=score_list.begin(); iter != score_list.end(); iter++ ) {
88  count++;
89  if ( count > final_number_ ) break;
90  std::string const & tag = iter->second;
91  filter_pose_list[ tag ] = pose_list[ tag ];
92  }
93 
94  }
95 
96 }
97 }