Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JobInputterFactory.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/jd2/JobInputterFactory.cc
11 /// @brief JobInputterFactory
12 /// @author Steven Lewis smlewi@gmail.com, Brian Weitzner brian.weitzner@gmail.com
13 
17 
18 #include <basic/options/option.hh>
19 #include <basic/options/keys/in.OptionKeys.gen.hh>
20 #include <basic/options/keys/jd2.OptionKeys.gen.hh>
21 #include <basic/options/keys/parser.OptionKeys.gen.hh>
22 #include <basic/options/keys/enzdes.OptionKeys.gen.hh>
23 
24 // Utility headers
25 #include <utility/exit.hh> // runtime_assert, utility_exit_with_message
26 #include <basic/Tracer.hh>
27 
28 namespace protocols {
29 namespace jd2 {
30 
31 static basic::Tracer TR( "protocols.jd2.JobInputterFactory" );
32 
33 JobInputterFactory * JobInputterFactory::instance_( 0 );
34 
36 {}
37 
39 
42  if ( ! instance_ ) {
43  JobInputterFactory * instance_local = new JobInputterFactory;
44  instance_ = instance_local;
45  }
46  return instance_;
47 }
48 
49 ///@brief add a JobInputter prototype, using its default type name as the map key
50 void
52 {
53  runtime_assert( creator );
54  std::string const job_inputter_type( creator->keyname() );
55  if ( job_inputter_creator_map_.find( job_inputter_type ) != job_inputter_creator_map_.end() ) {
56  utility_exit_with_message("JobInputterFactory::factory_register already has a mover creator with name \"" + job_inputter_type + "\". Conflicting JobInputter names" );
57  }
58  job_inputter_creator_map_[ job_inputter_type ] = creator;
59 }
60 
61 ///@details return new JobInputter by key lookup in map
64 {
65  //get pointer to Creator
66  JobInputterMap::const_iterator iter( job_inputter_creator_map_.find( job_inputter_type ) );
67  if ( iter != job_inputter_creator_map_.end() ) { //if Creator has an entry
68  if ( ! iter->second ) { //if Creator inexplicably fails to exist, crash
69  utility_exit_with_message( "Error: JobInputterCreatorOP for " + job_inputter_type + " is NULL, you should never have been able to get here!" );
70  }
71 
72  //if creator exists, return a JobInputter from it (this is good)
73  return iter->second->create_JobInputter();
74  }
75  else { //else, a non-existent JobInputter has been requested. Print existing ones and exit.
76  TR << "Available : ";
77  for( JobInputterMap::const_iterator mover_it = job_inputter_creator_map_.begin(); mover_it != job_inputter_creator_map_.end(); ++mover_it ) {
78  TR << mover_it->first<<", ";
79  }
80  TR << std::endl;
81  utility_exit_with_message( job_inputter_type + " is not known to the JobInputterFactory. Was it registered via a JobInputterRegistrator in one of the init.cc files (devel/init.cc or protocols/init.cc)?" );
82  return NULL;
83  }
84 }
85 
86 ///@brief return new JobInputter from logic of option system plus compilation options. All the logic for determining job input type lives here.
89 {
90  //initial copy of this code copied at XRW2 by SML+BDW from about SVN:46190 from JobDistributorFactory.cc
91 
92  if ( basic::options::option[ basic::options::OptionKeys::jd2::pose_input_stream ]() ) {
93  return get_JobInputter_from_string( "PoseInputStreamJobInputter" );
94  }
95 
96  if( basic::options::option[ basic::options::OptionKeys::jd2::resource_definition_files ].user() ){
97  return get_JobInputter_from_string("JD2ResourceManagerJobInputter" );
98  }
99 
100  //PDB input block
101  if ( basic::options::option[ basic::options::OptionKeys::in::file::s ].user() || basic::options::option[ basic::options::OptionKeys::in::file::l ].user() || basic::options::option[ basic::options::OptionKeys::in::file::list ].user() || basic::options::option[ basic::options::OptionKeys::in::file::screening_list ].user() ) {
102  if ( basic::options::option[ basic::options::OptionKeys::enzdes::parser_read_cloud_pdb ].user() ){
103  return get_JobInputter_from_string( "EnzdesJobInputter" );
104  }
105  if ( basic::options::option[ basic::options::OptionKeys::jd2::dd_parser ].user() && basic::options::option[ basic::options::OptionKeys::parser::patchdock ].user() ){
106  return get_JobInputter_from_string( "ParserJobInputter" );
107  }
108  else{
109  return get_JobInputter_from_string( "PDBJobInputter" ); //SML override until we have other child classes
110  }
111  //silent file block
112  } else if ( basic::options::option[ basic::options::OptionKeys::in::file::silent ].user() ) {
113  if ( basic::options::option[ basic::options::OptionKeys::jd2::lazy_silent_file_reader ].user() ){
114  return get_JobInputter_from_string( "LazySilentFileJobInputter" );
115  } else {
116  return get_JobInputter_from_string( "SilentFileJobInputter" );
117  }
118 
119  } else if (basic::options::option[basic::options::OptionKeys::in::file::atom_tree_diff].user() ){
120  return get_JobInputter_from_string( "AtomTreeDiffJobInputter" );
121  } else if ( basic::options::option[ basic::options::OptionKeys::in::file::template_pdb ].user() || basic::options::option[ basic::options::OptionKeys::in::file::template_silent ].user() ) {
122  return get_JobInputter_from_string( "ThreadingJobInputter" );
123  } else if (basic::options::option[basic::options::OptionKeys::in::use_database].user() ){
124  return get_JobInputter_from_string( "DatabaseJobInputter" );
125  } else {
126  return get_JobInputter_from_string( "GenericJobInputter" ); //handles -nstruct alone; works for abinitio with no structure input
127  }
128 }
129 
130 } //namespace jd2
131 } //namespace protocols