Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MatchProcessor.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 // :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 protocols/match/output/MatchProcessor.cc
12 /// @brief
13 /// @author Alex Zanghellini (zanghell@u.washington.edu)
14 /// @author Andrew Leaver-Fay (aleaverfay@gmail.com), porting to mini
15 /// @author Florian Richter( floric@u.washington.edu)
16 
17 // Unit headers
19 
20 // package headers
24 // AUTO-REMOVED #include <protocols/match/Hit.hh> // REQUIRED FOR WINDOWS
25 // AUTO-REMOVED #include <protocols/match/downstream/DownstreamBuilder.hh> // REQUIRED FOR WINDOWS
26 
27 //Project headers
28 #include <basic/Tracer.hh>
29 // AUTO-REMOVED #include <core/id/AtomID.hh> // REQUIRED FOR WINDOWS
30 
31 
32 // Utility headers
33 #include <utility/exit.hh>
34 
35 #include <utility/vector1.hh>
36 
37 
38 namespace protocols {
39 namespace match {
40 namespace output {
41 
42 static basic::Tracer TR( "protocols.match.output.MatchProcessor" );
43 
45  : match_processing_successful_(false), writer_(NULL),
46  num_matches_processed_(0), up_down_filt_(NULL), up_coll_filt_(NULL)
47 {
48  filter_failcounts_.clear();
49 }
50 
51 
53 {}
54 
55 void
57 {
58  runtime_assert( writer_ );
61  filter_failcounts_.clear();
62  writer_->prepare_for_output_writing();
63 }
64 
65 void
67 {
68 
69  TR << "A total of " << num_matches_processed_ << " matches were processed." << std::endl;
70  core::Size total_filter_fails(0);
71  if( filter_failcounts_.size() != 0 ){
72  for( std::map< std::string, core::Size >::const_iterator map_it( filter_failcounts_.begin() ), map_end( filter_failcounts_.end() ); map_it != map_end; ++map_it){
73  TR << map_it->second << " matches did not pass filter " << map_it->first << ".\n" ;
74  total_filter_fails += map_it->second;
75  }
76  if( num_matches_processed_ == total_filter_fails ) TR << "Apparently no matches passed all filters." << std::endl;
77  }
78  else TR << "No matches failed any filter.\n";
79 
80  if( num_matches_processed_ > total_filter_fails ){
82  }
83  TR.flush();
84  writer_->end_output_writing();
85 }
86 
87 void
89 {
90  writer_ = writer;
91 }
92 
95 {
96  return writer_;
97 }
98 
99 void
101 {
102  std::map< std::string, core::Size >::iterator map_it( filter_failcounts_.find( filter_name ) );
103  if( map_it == filter_failcounts_.end() ){
104  filter_failcounts_.insert( std::pair< std::string, core::Size >( filter_name, 1 ) );
105  }
106  else map_it->second++;
107 }
108 
109 void
111 {
113 }
114 
115 bool
117  match const & m
118 )
119 {
120 
121  for ( std::list< MatchFilterOP >::const_iterator
122  iter = filters_.begin(), iter_end = filters_.end();
123  iter != iter_end; ++iter ) {
124  if ( ! (*iter)->passes_filter( m ) ) {
125  note_filter_fail( (*iter)->filter_name() );
126  return false;
127  }
128  }
129 
130  for ( std::list< StateAccumulatingMatchFilterOP >::const_iterator
131  iter = filters_with_state_.begin(), iter_end = filters_with_state_.end();
132  iter != iter_end; ++iter ) {
133  (*iter)->note_match_accepted( m );
134  }
135  return true;
136 }
137 
138 bool
140  match_dspos1 const & m
141 )
142 {
143  for ( std::list< MatchFilterOP >::const_iterator
144  iter = filters_.begin(), iter_end = filters_.end();
145  iter != iter_end; ++iter ) {
146  if ( ! (*iter)->passes_filter( m ) ) {
147  note_filter_fail( (*iter)->filter_name() );
148  return false;
149  }
150  }
151 
152  for ( std::list< StateAccumulatingMatchFilterOP >::const_iterator
153  iter = filters_with_state_.begin(), iter_end = filters_with_state_.end();
154  iter != iter_end; ++iter ) {
155  (*iter)->note_match_accepted( m );
156  }
157  return true;
158 }
159 
160 
161 void
163 {
164 
166  dynamic_cast< UpstreamCollisionFilter * > ( filter.get() ) );
167  if( up_coll_filt ){
169  return; //upstream collision filter not happening at match enumeration stage anymore
170  }
171 
172  filters_.push_back( filter );
173 
174  /// Is this a state-accululating filter?
175  StateAccumulatingMatchFilterOP filter_with_state(
176  dynamic_cast< StateAccumulatingMatchFilter * > ( filter.get() ) );
177  if ( filter_with_state ) {
178  filters_with_state_.push_back( filter_with_state );
179  }
180 
182  dynamic_cast< UpstreamDownstreamCollisionFilter * > ( filter.get() ) );
183  if( up_down_filt ) up_down_filt_ = up_down_filt;
184 
185 }
186 
187 
188 void
190 {
191  for ( std::list< StateAccumulatingMatchFilterOP >::const_iterator
192  iter = filters_with_state_.begin(), iter_end = filters_with_state_.end();
193  iter != iter_end; ++iter ) {
194  (*iter)->reset();
195  }
196 }
197 
198 void
200 {
201  filters_.clear();
202 }
203 
206 {
207  return up_down_filt_;
208 }
209 
212 {
213  return up_coll_filt_;
214 }
215 
216 
217 }
218 }
219 }