Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
batch_distances.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
11 /// @brief
12 /// @author James Thompson
13 /// @author Christopher Miles (cmiles@uw.edu)
14 
15 // Unit headers
16 
17 // Project headers
18 #include <core/types.hh>
19 #include <core/chemical/AtomType.hh>
20 #include <core/chemical/util.hh>
21 #include <core/conformation/Residue.hh>
22 #include <core/import_pose/pose_stream/MetaPoseInputStream.hh>
23 #include <core/import_pose/pose_stream/util.hh>
24 #include <core/pose/util.hh>
25 #include <core/pose/Pose.hh>
26 #include <core/pose/PDBInfo.hh>
27 #include <devel/init.hh>
28 
29 // Objexx
30 #include <ObjexxFCL/format.hh>
31 
32 // Utility headers
33 #include <basic/Tracer.fwd.hh>
34 #include <utility/file/FileName.hh>
35 #include <utility/string_util.hh>
36 #include <utility/vector1.hh>
37 
38 // option key includes
39 #include <basic/options/option.hh>
41 
42 // C++ headers
43 #include <cmath>
44 #include <cstddef>
45 #include <iostream>
46 #include <limits>
47 #include <string>
48 
50 
52  core::pose::Pose & mypose,
53  core::Real const dist_cutoff) {
55  burial.resize( mypose.total_residue() );
56 
57  using core::Size;
58  for ( Size i = 1; i <= mypose.total_residue(); ++i ) {
59  for ( Size j = i + 1; j <= mypose.total_residue(); ++j ) {
60  core::conformation::Residue resi = mypose.residue(i);
61  core::conformation::Residue resj = mypose.residue(j);
62 
63  core::Real const dist(
64  resi.xyz( resi.nbr_atom() ).distance( resj.xyz( resj.nbr_atom() ) )
65  );
66  if ( dist < dist_cutoff ) {
67  burial[ i ]++;
68  burial[ j ]++;
69  }
70  }
71  }
72  return burial;
73 }
74 
75 using namespace ObjexxFCL::format;
76 
77 int main( int argc, char* argv [] ) {
78  try {
79 
80  using namespace basic::options;
81  using namespace basic::options::OptionKeys;
82  using namespace core::chemical;
83  using core::Real;
84  using core::Size;
85  using std::string;
87 
88  // options, random initialization
89  devel::init( argc, argv );
90 
91  // maximum Euclidean distance between a pair of atoms to be in contact
93  if ( option[ james::dist_thresholds ].user() ) {
95  }
96 
97  // minimum sequence separation between a pair of atoms to be in contact
99  bool const show_all_atoms( option[ james::debug ]() );
101 
102  std::ostream& output( std::cout );
103 
104  core::import_pose::pose_stream::MetaPoseInputStream input
105  = core::import_pose::pose_stream::streams_from_cmd_line();
106  ResidueTypeSetCOP rsd_set( rsd_set_from_cmd_line() );
107 
108  output << A( 10, "resi_idx" )
109  << A( 10, "resj_idx" )
110  << A( 6, "resi" )
111  << A( 6, "resj" )
112  << A( 8, "atomi" )
113  << A( 8, "atomj" )
114  << A( 10, "burial_i" )
115  << A( 10, "burial_j" )
116  << A( 10, "dist" )
117  << A( 10, "seqsep" )
118  << A( 14, "pose_tag" )
119  << std::endl;
120 
121  while ( input.has_another_pose() ) {
123  input.fill_pose( pose, *rsd_set );
124  string const pose_tag( file_basename( core::pose::tag_from_pose( pose ) ) );
126  for ( Size i = 1; i <= pose.total_residue(); ++i ) {
127  for ( Size j = i+1; j <= pose.total_residue(); ++j ) {
128  const core::conformation::Residue& resi = pose.residue(i);
129  const core::conformation::Residue& resj = pose.residue(j);
130 
131  for ( Size m = 1; m <= resi.natoms(); ++m ) {
132  for ( Size n = 1; n <= resj.natoms(); ++n ) {
133  if ( atoms_wanted.size() > 0 ) {
134  std::string const & atom_m( resi.atom_type(m).name() );
135  std::string const & atom_n( resj.atom_type(n).name() );
137  std::find(atoms_wanted.begin(),atoms_wanted.end(),atom_m)
138  );
140  std::find(atoms_wanted.begin(),atoms_wanted.end(),atom_n)
141  );
142  if ( find_m == atoms_wanted.end() || find_n == atoms_wanted.end() ) {
143  continue;
144  }
145  }
146 
147  // skip hydrogen atoms
148  if ( resi.atom_type(m).is_hydrogen() ||
149  resj.atom_type(n).is_hydrogen() ) {
150  continue;
151  }
152 
153  // skip atoms that don't share a type
154  if ( resi.atom_type(m).name() != resj.atom_type(n).name() &&
155  !show_all_atoms ) {
156  continue;
157  }
158 
159  // determine whether Euclidean distance is below threshold
160  core::Real const distance(
161  pose.residue(i).xyz(m).distance( resj.xyz(n) ));
162  if ( distance > distance_cutoff ) continue;
163 
164  // determine whether sequence separation exceeds threshold
165  Size pos_i = pose.pdb_info()->number(i);
166  Size pos_j = pose.pdb_info()->number(j);
167  Size seqsep = std::abs( int(pos_j) - int(pos_i));
168  if ( seqsep < min_seqsep ) continue;
169 
170  // sometimes pose_tag is too big.
171  Size const pose_tag_width( std::max( pose_tag.length(), (Size)14 ) );
172 
173  output << I( 10, pos_i)
174  << I( 10, pos_j)
175  << A( 6, resi.name1() )
176  << A( 6, resj.name1() )
177  << A( 8, resi.atom_name(m) )
178  << A( 8, resj.atom_name(n) )
179  << I( 10, burial[i] )
180  << I( 10, burial[j] )
181  << F( 10, 4, distance )
182  << I( 10, seqsep)
183  << A( pose_tag_width, pose_tag )
184  << std::endl;
185  }
186  }
187  }
188  }
189  }
190 
191  } catch ( utility::excn::EXCN_Base const & e ) {
192  std::cout << "caught exception " << e.msg() << std::endl;
193  return -1;
194  }
195 
196  return 0;
197 }
virtual std::string const msg() const
Definition: EXCN_Base.hh:70
void init(int argc, char *argv[])
Command line init() version.
Definition: init.cc:23
std::string file_basename(std::string const &filename)
Basename of a File Name.
core::pose::Pose Pose
Definition: supercharge.cc:101
StringVectorOptionKey const atom_names("james:atom_names")
common derived classes for thrown exceptions
std::string file_basename(const std::string &full_path)
Definition: string_util.cc:428
IntegerOptionKey const min_seqsep
FileVectorOptionKey const burial
T abs(T const &x)
std::abs( x ) == | x |
Definition: Fmath.hh:295
File name class supporting Windows and UN*X/Linux format names.
BooleanOptionKey const debug("james:debug")
rule< Scanner, options_closure::context_t > options
Definition: Tag.cc:377
T distance(MathVector< T > const &VECTOR_A, MathVector< T > const &VECTOR_B)
super::const_iterator const_iterator
Definition: vector1.hh:62
RealVectorOptionKey const dist_thresholds("james:dist_thresholds")
double Real
Definition: types.hh:39
IntegerOptionKey const min_seqsep("james:min_seqsep")
std::string F(int const w, int const d, float const &t)
Fixed Point Format: float.
Definition: format.cc:387
T distance(CArray< T > const &a, CArray< T > const &b)
Distance.
utility::vector1< int > calculate_burial(core::pose::Pose &mypose, core::Real const dist_cutoff)
basic::options::OptionKeys collection
ocstream cout(std::cout)
Wrapper around std::cout.
Definition: ocstream.hh:287
vector1: std::vector with 1-based indexing
def dist
Definition: coordlib.py:16
Some std::string helper functions.
Program options global and initialization function.
BooleanOptionKey const chemical
std::string I(int const w, T const &t)
Integer Format.
Definition: format.hh:758
static T max(T x, T y)
Definition: Svm.cc:19
StringOptionKey const output
Definition: contacts.py:31
platform::Size Size
Definition: random.fwd.hh:30
std::string A(int const w, char const c)
char Format
Definition: format.cc:175
rule< Scanner, option_closure::context_t > option
Definition: Tag.cc:378
IntegerOptionKey const j