Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DockDesignFilterFactory.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/protein_interface_design/DockDesignFilterFactory.cc
11 /// @brief
12 /// @author ashworth
16 
17 
18 #include <utility/exit.hh> // runtime_assert, utility_exit_with_message
19 #include <utility/tag/Tag.hh>
20 
21 #include <utility/vector0.hh>
22 #include <utility/vector1.hh>
23 
24 
25 namespace protocols {
26 namespace protein_interface_design {
27 using namespace protocols::filters;
28 
30  : utility::pointer::ReferenceCount()
31 {
32  // no Filters are registered by default
33  // they must be registered using the add_type method
34 }
35 
37 
38 ///@brief add a Filter prototype, using its default type name as the map key
39 void
41 {
42  runtime_assert( dock_design_filter );
43  std::string const type( dock_design_filter->get_type() );
44  if ( type == "UNDEFINED TYPE" ) {
45  utility_exit_with_message("Can't map derived Filter with undefined type name.");
46  }
47  dock_design_filter_map_[ type ] = dock_design_filter;
48 }
49 
50 ///@brief add a Filter prototype, using an arbitrary type name as the map key
51 void
52 DockDesignFilterFactory::add_type( std::string const & type, FilterOP dock_design_filter )
53 {
54  runtime_assert( dock_design_filter );
55  dock_design_filter_map_[ type ] = dock_design_filter;
56 }
57 
58 ///@brief return new Filter by key lookup in dock_design_filter_map_ (new Filter parses Tag if provided)
61 {
62  filters::Filters_map::const_iterator iter( dock_design_filter_map_.find( type ) );
63  if ( iter != dock_design_filter_map_.end() ) {
64  if ( ! iter->second ) {
65  utility_exit_with_message( "Error: FilterOP prototype for " + type + " is NULL!" );
66  }
67  return iter->second->fresh_instance();
68  }
69  else {
70  utility_exit_with_message( type + " is not known to the FilterFactory. Was it registered via the add_type method?" );
71  return NULL;
72  }
73 }
74 
75 ///@brief return new Filter by Tag parsing
78  TagPtr const tag,
79  moves::DataMap & data,
80  filters::Filters_map const & filters,
81  moves::Movers_map const & movers,
82  Pose const & pose )
83 {
84  FilterOP filter( newFilter( tag->getName() ) );
85  runtime_assert( filter );
86  if ( ! tag->hasOption("name") )
87  utility_exit_with_message("Can't define unnamed Filter");
88  filter->set_user_defined_name( tag->getOption<std::string>("name") );
89  filter->parse_my_tag( tag, data, filters, movers, pose );
90  // if confidence specified, link to StochasticFilter and wrap inside CompoundFilter
91  core::Real const confidence( tag->getOption< core::Real >( "confidence", 1.0 ) );
92  if ( confidence < 0.999 ) { // fuzzy logic
93  CompoundFilter::CompoundStatement fuzzy_statement;
94  FilterCOP stochastic_filter( new StochasticFilter( confidence ) );
95  fuzzy_statement.push_back( std::make_pair( stochastic_filter->clone(), OR ) );
96  fuzzy_statement.push_back( std::make_pair( filter->clone(), OR ) );
97  FilterOP compound_filter( new CompoundFilter( fuzzy_statement ) );
98  compound_filter->set_user_defined_name( tag->getOption<std::string>("name") );
99  return compound_filter;
100  }
101  return filter;
102 }
103 
104 } //namespace protein_interface_design
105 } //namespace protocols