Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AtomTreeDiffJobInputter.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/AtomTreeDiffJobInputter.cc
11 /// @brief
12 /// @author Gordon Lemmon (gordon.h.lemmon@vanderbilt.edu); Rocco Moretti (rmoretti@u.washington.edu)
13 
14 ///Unit headers
17 #include <protocols/jd2/Job.hh>
19 
20 ///Project headers
21 
22 #include <core/pose/Pose.hh>
24 
25 ///Utility headers
26 #include <basic/Tracer.hh>
27 #include <basic/options/option.hh>
28 #include <utility/vector1.hh>
29 #include <utility/file/FileName.hh>
30 
31 // Boost Headers
32 #include <boost/foreach.hpp>
33 #define foreach BOOST_FOREACH
34 
35 ///C++ headers
36 #include <string>
37 
38 // option key includes
39 #include <basic/options/keys/in.OptionKeys.gen.hh>
40 
41 
42 
43 static basic::Tracer tr("protocols.jd2.AtomTreeDiffJobInputter");
44 
45 namespace protocols {
46 namespace jd2 {
47 
49  // silent_files_( option[ in::file::silent ]() ) {
50 {
51  tr.Debug << "Instantiate AtomTreeDiffJobInputter" << std::endl;
52 }
53 
55 
56 /// @details This function will first see if the pose already exists in the Job.
57 /// If not, it will read it into the pose reference, and hand a COP cloned from
58 /// that pose to the Job. If the pose pre-exists it just copies the COP's pose
59 /// into it.
61  core::pose::Pose & pose,
62  JobOP job
63 ) {
64  tr.Debug << "AtomTreeDiffJobInputter::pose_from_job" << std::endl;
65 
66  if ( !job->inner_job()->get_pose() ) {
67  //core::import_pose::pose_from_pdb( pose, job->inner_job()->input_tag() );
68  // core::io::silent::SilentStructOP ss = atom_tree_diff_[ job->inner_job()->input_tag() ];
69  tr.Debug << "filling pose from AtomTree (tag = " << job->input_tag() << ")" << std::endl;
70  pose.clear();
71 
72  if ( atom_tree_diff_.has_ref_tag( job->input_tag() ) ) {
73  atom_tree_diff_.read_pose(job->input_tag(), pose);
74  } else if( basic::options::option[ basic::options::OptionKeys::in::file::native ].user() ) {
75  // A "native" pose for the diff reference point.
76  // This used to be required but will be rarely used now.
77  tr << "Using -in:file:native for reference pose with AtomTreeDiff input format.";
78  core::pose::Pose native_pose;
79  core::import_pose::pose_from_pdb( native_pose, basic::options::option[ basic::options::OptionKeys::in::file::native ]().name() );
80  atom_tree_diff_.read_pose(job->input_tag(), pose, native_pose);
81  } else {
82  utility_exit_with_message("Can't find the reference structure for job with input tag " + job->input_tag());
83  }
84  load_pose_into_job( pose, job );
85  } else {
86  pose.clear();
87 
88  pose = *(job->inner_job()->get_pose());
89  tr.Debug << "filling pose from saved copy (tag = " << job->input_tag() << ")" << std::endl;
90  }
91 }
92 
93 /// @details this function determines what jobs exist -in:file:atom_tree_diff
94 
96  tr.Debug << "AtomTreeDiffJobInputter::fill_jobs" << std::endl;
97 
98  jobs.clear(); //should already be empty anyway
99 
100  using std::string;
102  using utility::vector1;
103  using namespace basic::options;
104  using namespace basic::options::OptionKeys;
105 
106  utility::vector1< FileName > const atom_tree_diff_files( option[ in::file::atom_tree_diff ]() );
107 
108  runtime_assert( atom_tree_diff_files.size() > 0 );// getting here should be impossible
109 
110  if( atom_tree_diff_files.size() != 1 ){
111  utility_exit_with_message( "Code currently deals with only one input atom_tree_diff file" );
112  }
113  FileName file_name= atom_tree_diff_files.at(1);
114  tr.Debug << "reading " << file_name << std::endl;
115 
116  atom_tree_diff_.read_file( file_name );
117 
118  core::Size const nstruct( get_nstruct() );
119 
121 
122  if ( option[ in::file::tags ].user() ) {
123  core::import_pose::atom_tree_diffs::TagScoreMap const & atd_tsm= atom_tree_diff_.get_tag_score_map();
124  foreach(string tag, option[ in::file::tags ]()){
125  if ( ! atom_tree_diff_.has_tag(tag) ) {
126  utility_exit_with_message("Input AtomTreeDiff file does not have tag "+tag);
127  }
128  core::import_pose::atom_tree_diffs::TagScoreMap::const_iterator tag_score_iter(atd_tsm.find(tag));
129  assert( tag_score_iter != atd_tsm.end() ); // Shouldn't happen - we've checked it was present
130  tags[tag] = tag_score_iter->second;
131  }
132  } else {
133  tags = atom_tree_diff_.get_tag_score_map();
134  }
135 
136  if ( ! tags.size() ) {
137  utility_exit_with_message("No valid input structures found for AtomTreeDiff file.");
138  }
139 
140  core::import_pose::atom_tree_diffs::ScoresPairList const & all_scores( atom_tree_diff_.scores() );
141  foreach(core::import_pose::atom_tree_diffs::TagScorePair tag_score, tags){
142  InnerJobOP ijob( new InnerJob( tag_score.first, nstruct ) );
143 
144  //second entry in tag_score is index to entry in ScoresPairList
145  assert( tag_score.first == all_scores[tag_score.second].first );
146  core::import_pose::atom_tree_diffs::Scores scores= all_scores[tag_score.second].second;
147 
148  for(core::Size j=1; j<=nstruct; ++j){
149  JobOP job = new Job( ijob, j);
150  if( basic::options::option[ basic::options::OptionKeys::in::file::keep_input_scores ] ) {
151  foreach(core::import_pose::atom_tree_diffs::ScorePair score, scores){
152  job->add_string_real_pair(score.first, score.second);
153  }
154  }
155  jobs.push_back( job );
156  }
157  }
158 
159 } // fill_jobs
160 
161 /// @brief Return the type of input source that the AtomTreeDiffJobInputter is currently
162 /// using.
163 /// @return Always <em>ATOM_TREE_FILE</em>.
166 }
167 
168 /// @brief Utility function to allow mutatable (!) access to the reference
169 /// poses of the undelying AtomTreeDiff object. Use with caution.
170 ///
171 /// @details This exists to allow setup on stored reference poses for properties that
172 /// don't get saved/restored in PDB format, like covalent constraints for enzyme design.
175  return atom_tree_diff_.all_ref_poses();
176 }
177 
178 //CREATOR SECTION
181 {
182  return "AtomTreeDiffJobInputter";
183 }
184 
187  return new AtomTreeDiffJobInputter;
188 }
189 
190 } // jd2
191 } // protocols