31 #include <utility/tag/Tag.hh>
32 #include <utility/vector1.hh>
33 #include <utility/io/ozstream.hh>
35 #include <basic/Tracer.hh>
37 #include <numeric/xyzVector.hh>
44 #include <utility/vector0.hh>
47 #include <utility/excn/Exceptions.hh>
51 namespace contact_map {
53 using namespace utility::tag;
59 static basic::Tracer
TR(
"protocols.moves.ContactMap");
83 output_prefix_(
"contact_map_"),
85 distance_cutoff_(10.0),
95 contacts_(contact_map.contacts_),
96 output_matrix_(contact_map.output_matrix_),
97 column_names_(contact_map.column_names_),
98 row_names_(contact_map.row_names_),
99 output_prefix_(contact_map.output_prefix_),
100 n_poses_(contact_map.n_poses_),
101 distance_cutoff_(contact_map.distance_cutoff_),
102 models_per_file_(contact_map.models_per_file_),
103 reset_count_(contact_map.reset_count_),
104 row_format_(contact_map.row_format_)
138 if(reset_count_tag ==
"false") {
142 if (reset_count_tag !=
"true")
throw utility::excn::EXCN_RosettaScriptsOption(
"'reset_count' option must be true or false");
153 if (row_format_tag !=
"false")
throw utility::excn::EXCN_RosettaScriptsOption(
"'row_format' option must be true or false");
162 if (tag->hasOption(
"region1")){
164 region1_begin, region1_end, pose);
167 if (tag->hasOption(
"region2")){
170 region2_begin, region2_end, pose);
171 fill_contacts(region1_begin, region1_end, region2_begin, region2_end, pose);
174 else if (tag->hasOption(
"ligand")){
177 ligand_begin, ligand_end, pose);
178 fill_contacts(region1_begin, region1_end, ligand_begin, pose);
192 if (region_def.size() == 1 && isalpha(region_def.at(0)) ){
204 std::istringstream region_defstr(region_def);
205 region_defstr >> region_begin;
207 if (region_defstr.eof()){
208 region_end = region_begin;
211 region_defstr.seekg(1, std::ios_base::cur);
212 region_defstr >> region_end;
215 if(region_defstr.fail() || ! region_defstr.eof() )
216 utility_exit_with_message(
"Unable to parse region '" + region_def +
"'!");
219 if(region_begin > region_end){
221 region_begin = region_end;
226 if (region_begin < 1 || region_end > pose.
n_residue()) {
227 utility_exit_with_message(
"Specified region '" + region_def +
"' is out of bounds!");
274 (2 * length - i) * (i - 1) / 2 - i + j :
275 (2 * length - j) * (j - 1) / 2 - j + i);
291 if(ligand_seqpos == begin) ++begin;
295 if(i==ligand_seqpos)
continue;
359 using namespace pose;
372 it->add_distance(distance);
412 TR.Info <<
"Writing ContactMap to '" << filename
413 <<
"', ContactMap includes " <<
n_poses_ <<
" structure(s)."
417 utility::io::ozstream output_stream;
418 output_stream.open(filename, std::ios_base::out);
419 output_stream <<
"# Number of Models: " <<
n_poses_ << std::endl
424 output_stream << it->long_string_rep() << std::endl;
432 output_stream << std::endl;
441 output_stream <<
"\t"
442 <<
contacts_.at(pos_in_contacts).string_rep();
444 output_stream << std::endl;
448 output_stream.close();
455 std::ostringstream oss;
456 oss << resname_ << seqpos_;
459 if (atomname_ !=
"CA" && atomname_ !=
"CB")
460 oss<<
"-"<<atomname_;
479 std::ostringstream oss;
487 std::ostringstream oss;
497 stringrep = partner1_.string_rep() +
"\t"+ partner2_.string_rep() +
"\t";
498 stringrep = stringrep + ( (n_poses==0) ? string_rep() :string_rep(n_poses));