Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ProcessorFactory.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/ProcessorFactory.hh
12 /// @brief Implementation for a factory class responsible for instantiating
13 /// MatchProcessor classes.
14 /// @author Alex Zanghellini (zanghell@u.washington.edu)
15 /// @author Andrew Leaver-Fay (aleaverfay@gmail.com), porting to mini
16 /// @author Roland A Pache
17 
18 // Unit headers
20 
21 // Package headers
42 
43 // Project headers
44 #include <core/types.hh>
46 #include <core/pose/Pose.hh>
47 
48 #include <basic/options/option.hh>
49 #include <basic/options/keys/match.OptionKeys.gen.hh>
50 #include <basic/Tracer.hh>
51 
54 //#include <protocols/toolbox/match_enzdes_util/EnzConstraintParameters.hh>
55 
56 // Utility headers
57 #include <utility/pointer/ReferenceCount.hh>
58 #include <utility/string_util.hh>
59 #include <utility/vector1.hh>
60 
61 // C++ headers
62 #include <list>
63 
64 #include <utility/vector0.hh>
65 
66 
67 namespace protocols {
68 namespace match {
69 namespace output {
70 
71 static basic::Tracer TR( "protocols.match.output.ProcessorFactory" );
72 
74 
76 
79  MatcherCOP matcher,
80  MatcherTaskCOP mtask
81 )
82 {
83  MatchProcessorOP processor;
84 
85  UpstreamHitCacherOP cacher = new UpstreamHitCacher( matcher );
86 
87  if ( mtask->consolidate_matches() ) {
88  TR << "Matches will be consolidated before output." << std::endl;
89  if( mtask->output_writer_name() == "CloudPDB" ) TR << "NOTICE: match consolidation and CloudPDB writing are both active. This is fine but somewhat redundant. In this case, the -output_matches_per_group parameter should be set to a higher number than without cloud pdb writing, say 100 or so." << std::endl;
90  MatchConsolidatorOP consolidator = new MatchConsolidator;
91  consolidator->set_grouper( create_grouper( matcher, mtask, cacher ) );
92  consolidator->set_evaluator( create_evaluator( matcher, mtask, cacher ) );
93  consolidator->set_output_writer( create_output_writer( matcher, mtask, cacher ) );
94  consolidator->set_n_to_output_per_group( mtask->n_to_output_per_group() );
95 
96  processor = consolidator;
97  } else {
98  MatchOutputterOP outputter = new MatchOutputter;
99 
100  outputter->set_output_writer( create_output_writer( matcher, mtask, cacher ) );
101 
102  processor = outputter;
103  }
104 
105  std::list< MatchFilterOP > filters( create_filters( matcher, mtask, cacher ) );
106  for ( std::list< MatchFilterOP >::const_iterator
107  iter = filters.begin(), iter_end = filters.end();
108  iter != iter_end; ++iter ) {
109  processor->add_filter( *iter );
110  }
111  return processor;
112 
113 }
114 
117  MatcherCOP matcher,
118  MatcherTaskCOP mtask,
119  UpstreamHitCacherOP cacher
120 )
121 {
122  if (mtask->grouper_name() == "SameChiBinComboGrouper" ) {
124  chibin_grouper->set_n_geometric_constraints( matcher->n_geometric_constraints() );
125  chibin_grouper->set_hit_cacher( cacher );
126  return chibin_grouper;
127  } else if ( mtask->grouper_name() == "SameSequenceGrouper" ) {
128  SameSequenceGrouperOP seq_grouper = new SameSequenceGrouper;
129  seq_grouper->set_n_geometric_constraints( matcher->n_geometric_constraints() );
130  seq_grouper->set_hit_cacher( cacher );
131  return seq_grouper;
132  }else if ( mtask->grouper_name() == "SameSequenceAndDSPositionGrouper" ) {
134  seq_ds_grouper->set_n_geometric_constraints( matcher->n_geometric_constraints() );
135  seq_ds_grouper->set_hit_cacher( cacher );
136  for ( Size ii = 1; ii <= matcher->n_geometric_constraints() ; ++ii ) {
137  seq_ds_grouper->set_downstream_builder( ii, matcher->downstream_builder( ii ) );
138  }
139  seq_ds_grouper->set_relevant_atom_ids( mtask->relevant_downstream_atoms() );
140  seq_ds_grouper->set_rms_group_cutoff( mtask->grouper_ds_rmsd() );
141  return seq_ds_grouper;
142  } else if ( mtask->grouper_name() == "SameRotamerComboGrouper" ) {
144  rot_grouper->set_n_geometric_constraints( matcher->n_geometric_constraints() );
145  return rot_grouper;
146  } else {
147  utility_exit_with_message( "Could not recognize requested MatchGrouper named: " + mtask->grouper_name() );
148  return 0;
149  }
150 }
151 
152 
153 
156  MatcherCOP matcher,
157  MatcherTaskCOP mtask,
158  UpstreamHitCacherOP /*cacher*/
159 )
160 {
161  if ( mtask->evaluator_name() == "DownstreamRMSEvaluator" ) {
163  rms_eval->set_n_geometric_constraints( matcher->n_geometric_constraints() );
164  for ( Size ii = 1; ii <= matcher->n_geometric_constraints(); ++ii ) {
165  /// HACK -- all RigidLigandBuilders are equivalent -- FIX THIS!
166  rms_eval->set_downstream_builder( ii, matcher->downstream_builder( ii ) );
167  }
168  rms_eval->set_downstream_pose(matcher->downstream_pose());
169  return rms_eval;
170  } else {
171  utility_exit_with_message( "Could not recognize requested MatchEvaluator named: " + mtask->evaluator_name() );
172  return 0;
173  }
174 }
175 
176 std::list< MatchFilterOP >
178  MatcherCOP matcher,
179  MatcherTaskCOP mtask,
180  UpstreamHitCacherOP cacher
181 )
182 {
183  if ( ! mtask->filter_names().empty() ) {
184  std::cerr << "ERROR: match::output::ProcessorFactory currently lacks logic to instantiate any of the desired filters" << std::endl;
185  for ( std::list< std::string >::const_iterator
186  filtiter = mtask->filter_names().begin(),
187  filtiter_end = mtask->filter_names().end();
188  filtiter != filtiter_end; ++filtiter ) {
189  std::cerr << "Requested filter '" << *filtiter << "' cannot be instantiated" << std::endl;
190  }
191  utility_exit_with_message( "Processor factory cannot create requested filter(s)" );
192 
193  }
194 
195  std::list< MatchFilterOP > filter_list;
196  if ( mtask->filter_upstream_residue_collisions() ) {
197  output::UpstreamCollisionFilterOP collfilt = new output::UpstreamCollisionFilter( "UpstreamCollisionFilter", cacher );
198  if ( mtask->filter_upstream_collisions_by_score() ) {
199  collfilt->set_filter_by_lj( true );
200  collfilt->set_lj_cutoff( mtask->upstream_residue_collision_score_cutoff() );
201  collfilt->set_lj_atr_weight( mtask->upstream_residue_collision_Wfa_atr() );
202  collfilt->set_lj_rep_weight( mtask->upstream_residue_collision_Wfa_rep() );
203  collfilt->set_lj_sol_weight( mtask->upstream_residue_collision_Wfa_sol() );
204  } else {
205  collfilt->set_tolerated_overlap( mtask->upstream_residue_collision_tolerance() );
206  }
207  filter_list.push_back( collfilt );
208  }
209 
210  if ( mtask->filter_upstream_downstream_collisions() || matcher->has_upstream_only_geomcsts() ) {
211  output::UpstreamDownstreamCollisionFilterOP collfilt = new output::UpstreamDownstreamCollisionFilter( "UpstreamDownstreamCollisionFilter", cacher );
212  if ( mtask->filter_upstream_downstream_collisions_by_score() ) {
213  collfilt->set_filter_by_lj( true );
214  collfilt->set_lj_cutoff( mtask->upstream_downstream_residue_collision_score_cutoff() );
215  collfilt->set_lj_atr_weight( mtask->upstream_downstream_residue_collision_Wfa_atr() );
216  collfilt->set_lj_rep_weight( mtask->upstream_downstream_residue_collision_Wfa_rep() );
217  collfilt->set_lj_sol_weight( mtask->upstream_downstream_residue_collision_Wfa_sol() );
218  } else {
219  collfilt->set_tolerated_overlap( mtask->upstream_downstream_atom_collision_tolerance() );
220  }
221  collfilt->set_downstream_pose( * matcher->downstream_pose() );
222  collfilt->set_num_geometric_constraints( matcher->n_geometric_constraints() );
223  for ( Size ii = 1; ii <= matcher->n_geometric_constraints(); ++ii ) {
224  collfilt->set_downstream_builder( ii, matcher->downstream_builder( ii ) );
225  if ( mtask->enz_input_data()->mcfi_list( ii )->mcfi(1)->is_covalent() ) {
226  collfilt->set_chemical_bond_from_upstream_to_downstream( ii );
227  }
228  }
229 
230  filter_list.push_back( collfilt );
231  }
232 
233  return filter_list;
234 }
235 
236 
239  MatcherCOP matcher,
240  MatcherTaskCOP mtask,
241  UpstreamHitCacherOP cacher
242 )
243 {
244  using namespace basic::options;
245 
246 
247  if ( mtask->output_writer_name() == "KinWriter" ) {
248 
249 
251  WriteUpstreamHitKinemageOP kin_hit_writer = new WriteUpstreamHitKinemage( mtask->output_file_name() );
252  kin_match_writer->set_n_geomcst( matcher->n_geometric_constraints() );
253  kin_match_writer->set_kin_writer( kin_hit_writer );
254 
255  for ( Size ii = 1; ii <= matcher->n_geometric_constraints() ; ++ii ) {
256  /// DIRTY ASSUMPTION -- SINGLE RESIDUE IN DOWNSTREAM PARTNER
257  if ( matcher->downstream_builder( ii ) ) {
259  downstream_writer->set_restype( & (mtask->downstream_pose()->residue(1).type()) );
260  downstream_writer->set_downstream_builder( matcher->downstream_builder( ii ) );
261  downstream_writer->set_downstream_master( mtask->downstream_pose()->residue(1).name3() );
262 
263  kin_match_writer->set_downstream_writer( ii, downstream_writer );
264  }
265  }
266  kin_match_writer->set_coordinate_cacher( cacher );
267  return kin_match_writer;
268 
269  } else if ( (mtask->output_writer_name() == "PDB" ) || (mtask->output_writer_name() == "pdb" ) || (mtask->output_writer_name() == "CloudPDB" ) || ( mtask->output_writer_name() == "PoseMatchOutputWriter" ) ) {
270  output::PDBWriterOP pdb_writer;
271  if ( (mtask->output_writer_name() == "PDB" ) || (mtask->output_writer_name() == "pdb" ) ){
272  pdb_writer = new output::PDBWriter;
273  }
274  else if( mtask->output_writer_name() == "PoseMatchOutputWriter" ){
275  pdb_writer = new output::PoseMatchOutputWriter( create_grouper( matcher, mtask, cacher) );
276  }
277  else{
278  pdb_writer = new output::CloudPDBWriter( create_grouper( matcher, mtask, cacher) );
279  }
280  pdb_writer->set_coordinate_cacher( cacher );
281  pdb_writer->initialize_from_matcher_task( mtask );
282 
283  if ( option[ OptionKeys::match::ligand_rotamer_index ].user() ) {
284  pdb_writer->set_prefix( "UM_LIGROT_" +
285  utility::to_string( option[ OptionKeys::match::ligand_rotamer_index ]() ) +
286  "_" );
287  }
288 
289  runtime_assert( matcher->downstream_builder( 1 /* wrong */ ) );
290  for ( Size ii = 1; ii <= matcher->n_geometric_constraints() ; ++ii ) {
291  pdb_writer->set_downstream_builder( ii, matcher->downstream_builder( ii ) );
292  }
293  return pdb_writer;
294  }
295 
296  else {
297  utility_exit_with_message( "Could not recognize requested OutputWriter named: '" + mtask->output_writer_name() + "'" );
298  return 0;
299 
300  }
301 
302 }
303 
304 
305 
306 }
307 }
308 }