Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SiteConstraint.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 src/core/scoring/constraints/SiteConstraint.cc
11 /// @brief This class is an AmbiguousConstraint in which the set is comprised of AtomPairConstraints
12 /// @brief of an atom of interest in one chain versus the CA of all residues in another chain.
13 /// @author Brian Weitzner (brian.weitzner@jhu.edu, May 2011)
14 
17 // AUTO-REMOVED #include <core/scoring/constraints/XYZ_Func.hh>
21 
22 #include <core/id/AtomID.hh>
24 #include <core/pose/Pose.hh>
25 #include <core/pose/util.hh>
26 
27 #include <basic/Tracer.hh>
28 
29 #include <utility/vector1.hh>
30 
31 //Auto Headers
33 
34 static basic::Tracer TR("core.scoring.constraints.SiteConstraint");
35 
36 namespace core {
37 namespace scoring {
38 namespace constraints {
39 
40 ////////////////////////////////////////////////////////////////////////////////////////////////////
41 /// @brief Constructor
44 {}
45 ////////////////////////////////////////////////////////////////////////////////////////////////////
46 /// @brief Constructor
48 AmbiguousConstraint( cst_in )
49 {}
50 
51 void
52 SiteConstraint::show( std::ostream& out) const
53 {
54  /// APL -- you cannot show the active constraint in the absence of a Pose.
55  //out << "AmbiguousConstraint Active constraint:" << std::endl;
56  //active_constraint()->show(out);
57  out << "SiteConstraint is an AmbiguousConstraint containing the following " << member_constraints().size() << " constraints: " << std::endl;
58  for( ConstraintCOPs::const_iterator cst_it = member_constraints().begin(); cst_it != member_constraints().end(); cst_it++){
59  (*cst_it)->show(out);
60  }
61 
62  out << " ...all member constraints of this SiteConstraint shown." << std::endl;
63 }
64 
65 
66 void
68  std::istream & data,
69  core::pose::Pose const & pose,
70  FuncFactory const & func_factory
71 ) {
72  TR.Debug << "ConstraintIO::read_site_cst" << std::endl;
73  Size res;
74  std::string tempres;
75  std::string name;
76  std::string chain;
77  std::string func_type;
79  data >> name >> tempres >> chain >> func_type;
80 
81  ConstraintIO::parse_residue( pose, tempres, res );
82  TR.Info << "read: " << name << " " << res << " " << "constrain to chain: " << chain << " func: " << func_type << std::endl;
83 
84 
85 
86  FuncOP aFunc = func_factory.new_func( func_type );
87  aFunc->read_data( data );
88 
89  if ( TR.Debug.visible() ) {
90  aFunc->show_definition( TR.Debug ); TR.Debug<<std::endl;
91  }
92  setup_csts( res, name, chain, pose, aFunc );
93 
94  if ( data.good() ) {
95  //chu skip the rest of line since this is a single line defintion.
96  while( data.good() && (data.get() != '\n') ) {}
97  if ( !data.good() ) data.setstate( std::ios_base::eofbit );
98  }
99 
100  if ( TR.Debug.visible() ) {
101  aFunc->show_definition( TR.Debug );
102  TR.Debug << std::endl;
103  }
104 
105 } // read_def
106 void
108  Size res,
109  std::string name,
110  std::string chain,
111  core::pose::Pose const & pose,
112  FuncOP const & func
113 ) {
114  id::AtomID target_atom( pose.residue_type( res ).atom_index( name ), res );
115  //Size target_chain = pose.chain( res );
116  Size constraint_chain = pose::get_chain_id_from_chain( chain, pose );
117 
118  Size start_res = pose.conformation().chain_begin( constraint_chain );
119  Size end_res = pose.conformation().chain_end( constraint_chain );
120 
121  for (Size j = start_res ; j < end_res ; ++j ) {
122  id::AtomID atom2( pose.residue_type( j ).atom_index( "CA" ), j );
123  runtime_assert( target_atom.valid() && atom2.valid() );
124  add_individual_constraint( new AtomPairConstraint( target_atom, atom2, func ) );
125  }
126 
127 } // setup_csts
128 
129 } // constraints
130 } // scoring
131 } // core
132 
133