Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SecondaryStructurePool.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 protocols/frag_picker/quota/SecondaryStructurePool.hh
11 /// @brief provides a quota selector based on difefrent secondary structure predicitons
12 /// @author Dominik Gront (dgront@chem.uw.edu.pl)
13 
15 
16 // package headers
21 
22 // utility headers
23 #include <utility/vector1.hh>
24 #include <core/types.hh>
25 #include <basic/Tracer.hh>
26 
27 //C++
28 #include <sstream>
29 
30 namespace protocols {
31 namespace frag_picker {
32 namespace quota {
33 
34 static basic::Tracer trSecondaryStructurePool(
35  "protocols.frag_picker.quota.SecondaryStructurePool");
36 
37 /// @brief Creates a pool of a given size and name
38 /// @param total_size - how many fragments will be selected (in total in all pools)
39 /// @param name - name assigned to this pool. This in general may be any string that
40 /// later allows one control pool's behavior from a flag file
41 /// @param ss_type - what is the type of secondary structur this pool is accepting
42 /// @param fraction - fraction of the total number of fragments that goes into this pool
44  utility::vector1<Size> & which_components,utility::vector1<Real> & weights,
45  Real fraction,Size n_scores,Size buffer_factor = 5) : QuotaPool(pool_name,fraction) {
46 
47  assert ( which_components.size() == weights.size() );
48  for(Size i=1;i<=which_components.size();i++) {
49  components_.push_back( which_components[i] );
50  weights_.push_back( weights[i] );
51  }
53  this_size_ = (Size)(fraction * total_size);
54  if(this_size_<20)
55  this_size_ = 20;
56  buffer_factor_ = buffer_factor;
57  ss_type_ = ss_type;
59  storage_ = new BoundedQuotaContainer(ordering,this_size_,this_size_*buffer_factor);
60  FragmentCandidateOP worst_f = new FragmentCandidate(1,1,0,1);
62  storage_->set_worst(std::pair<FragmentCandidateOP, scores::FragmentScoreMapOP>(worst_f,worst_s));
63  for(Size i=1;i<=n_scores;i++)
64  worst_s->set_score_component(99999.9999,i);
65 
66  trSecondaryStructurePool.Debug<< "Creating a pool >"<<pool_name<<"< for "<<ss_type_<<" holding "<<this_size_<<" candidates, quota fraction is: "<<fraction<<std::endl;
67  trSecondaryStructurePool.Debug<< "Score IDs and weights to sort this pool:\n\t";
68  for(Size i=1;i<=components_.size();i++)
69  trSecondaryStructurePool.Debug<< " "<<components_[i]<<":"<<weights_[i];
70  trSecondaryStructurePool.Debug<<std::endl;
71 }
72 
73 
75 
77 {
78  if( candidate.first->get_middle_ss() == ss_type_ ) return true;
79  return false;
80 }
81 
82 
84 {
85  if( candidate.first->get_middle_ss() == ss_type_ ) {
86  return storage_->push( candidate );
87  }
88  return false;
89 }
90 
92  std::ostream & out,
94 ) const
95 {
96  out << get_pool_name() << " collected "<<current_size()<<" candidates of type "<<ss_type_<<std::endl;
97 }
98 
99 
100 } // quota
101 } // frag_picker
102 } // protocols
103