Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
match.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 apps/public/match.cc
11 /// @brief
12 /// @author Andrew Leaver-Fay (aleaverfay@gmail.com), porting to mini
13 
14 
15 #include <devel/init.hh>
16 
17 #include <core/chemical/ChemicalManager.hh>
18 #include <core/conformation/ResidueFactory.hh>
19 #include <core/chemical/ResidueType.hh>
20 #include <core/chemical/ResidueTypeSet.hh>
21 
22 #include <core/id/AtomID.hh>
23 
24 #include <basic/options/option.hh>
25 
26 #include <basic/options/keys/match.OptionKeys.gen.hh>
27 #include <basic/options/keys/run.OptionKeys.gen.hh>
28 
29 #include <core/pose/Pose.hh>
30 //#include <core/scoring/ScoreFunctionFactory.hh>
31 
32 #include <basic/options/util.hh>
33 
34 #include <protocols/match/Matcher.hh>
35 #include <protocols/match/MatcherMover.hh>
36 #include <protocols/match/MatcherTask.hh>
37 
38 #include <protocols/match/output/ProcessorFactory.hh>
39 #include <protocols/match/output/MatchProcessor.hh>
40 
41 
42 #include <core/pack/rotamers/SingleLigandRotamerLibrary.hh>
43 #include <core/pack/rotamers/SingleResidueRotamerLibraryFactory.hh>
44 
45 #include <basic/Tracer.hh>
46 
47 #include <utility/string_util.hh>
48 
49 #include <core/import_pose/import_pose.hh>
50 #include <utility/vector1.hh>
51 
53 
54 #if defined(WIN32) || defined(__CYGWIN__)
55 #include <ctime>
56 #endif
57 
58 
59 void
60 match_main();
61 
62 /* moved to protocols/match/MatcherMover.cc as one step toward integrating match app with MatcherMover */
63 //void
64 //set_ligpose_rotamer( core::pose::Pose & ligpose );
65 
66 int main( int argc, char * argv [] )
67 {
68  try {
69  using namespace basic::options;
70  using namespace basic::options::OptionKeys;
71 
72  devel::init( argc, argv );
73 
74  match_main();
75  } catch ( utility::excn::EXCN_Base const & e ) {
76  std::cout << "caught exception " << e.msg() << std::endl;
77  return -1;
78  }
79 }
80 
81 void
83 {
84  using namespace core;
85  using namespace core::chemical;
86  using namespace core::id;
87  using namespace core::io::pdb;
88  using namespace core::pose;
89  using namespace protocols::match;
90  using namespace protocols::match::downstream;
91  using namespace protocols::match::output;
92  using namespace protocols::match::upstream;
93 
94  using namespace basic::options;
95  using namespace basic::options::OptionKeys;
96 
97  basic::Tracer T( "apps.public.match.match" );
98 
99  //we need this for the output to be correct
100  option[OptionKeys::run::preserve_header ].value(true);
101 
102  MatcherTaskOP mtask( new MatcherTask );
103 
105  if ( input_jobs.size() == 0 ) utility_exit_with_message("No input scaffold structures specified for matcher. Check for -s <pdbfile> in arguments.");
106 
107 
108  pose::Pose scaffold;
109  core::import_pose::pose_from_pdb( scaffold, input_jobs[ 1 ] );
110  scaffold.update_residue_neighbors();
111 
112  pose::Pose ligpose;
113  core::conformation::ResidueOP ligres = core::conformation::ResidueFactory::create_residue(
114  core::chemical::ChemicalManager::get_instance()->residue_type_set( FA_STANDARD )->name_map(
115  option[ basic::options::OptionKeys::match::lig_name ] )
116  );
117  ligpose.append_residue_by_jump( *ligres, 1 );
118 
119  if ( option[ OptionKeys::match::ligand_rotamer_index ].user() ) {
120  set_ligpose_rotamer( ligpose );
121  }
122 
123 
124  Size cent, nbr1, nbr2;
125  ligres->select_orient_atoms( cent, nbr1, nbr2 );
126 
127  T << "Selecting orientation atoms:";
128  T << " " << ligres->atom_name( cent );
129  T << " " << ligres->atom_name( nbr1 );
130  T << " " << ligres->atom_name( nbr2 ) << std::endl;
131 
132  mtask->set_upstream_pose( scaffold );
133 
135  oats[ 1 ] = AtomID( nbr2, 1 ); oats[ 2 ] = AtomID( nbr1, 1 ); oats[ 3 ] = AtomID( cent, 1 );
136 
137  mtask->set_downstream_pose( ligpose, oats );
138  mtask->initialize_from_command_line();
139  //task->consolidate_matches( false );
140 
141  time_t matcher_start_time = time(NULL), find_hits_end_time( time( NULL ) );
142  long processing_time(0);
143  MatcherOP matcher( new Matcher );
144  matcher->initialize_from_task( *mtask );
145  MatchProcessorOP processor = ProcessorFactory::create_processor( matcher, mtask );
146 
147  if ( matcher->find_hits() ) {
148  find_hits_end_time = time(NULL);
149  time_t process_start_time( time(NULL) );
150  matcher->process_matches( *processor );
151  processing_time = (long) (time(NULL) - process_start_time);
152 
153  } else {
154  find_hits_end_time = time(NULL);
155  }
156  long find_hits_time = (long)(find_hits_end_time - matcher_start_time );
157  time_t matcher_end_time = time(NULL);
158  T << "Matcher ran for " << (long)(matcher_end_time - matcher_start_time) << " seconds, where finding hits took " << find_hits_time << " seconds and processing the matches took " << processing_time << " seconds." << std::endl;
159 
160 }
161 
#define utility_exit_with_message(m)
Exit with file + line + message.
Definition: exit.hh:47
virtual std::string const msg() const
Definition: EXCN_Base.hh:70
int main(int argc, char *argv[])
Definition: match.cc:66
void init(int argc, char *argv[])
Command line init() version.
Definition: init.cc:23
BooleanOptionKey const user("options:user")
Definition: OptionKeys.hh:40
core::pose::Pose Pose
Definition: supercharge.cc:101
string output
Definition: contacts.py:31
common derived classes for thrown exceptions
Tracer IO system.
rule< Scanner, options_closure::context_t > options
Definition: Tag.cc:377
void match_main()
Definition: match.cc:82
ocstream cout(std::cout)
Wrapper around std::cout.
Definition: ocstream.hh:287
vector1: std::vector with 1-based indexing
Class for handling user debug/warnings/errors. Use instance of this class instead of 'std::cout' for ...
Definition: Tracer.hh:134
utility::vector1< std::string > start_files()
Definition: util.cc:53
Some std::string helper functions.
Program options global and initialization function.
platform::Size Size
Definition: random.fwd.hh:30
rule< Scanner, option_closure::context_t > option
Definition: Tag.cc:378