Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AtomicContactFilter.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 sw=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 devel/protein_interface_design/filters/DisulfideFilter.hh
11 /// @brief Filters for interfaces which could form a disulfide bond between
12 /// docking partners.
13 /// @author Sarel Fleishman (sarelf@uw.edu)
14 
17 
18 
19 // Project Headers
20 #include <core/types.hh>
21 #include <core/pose/Pose.hh>
22 
23 //parsing
24 #include <utility/tag/Tag.hh>
26 // AUTO-REMOVED #include <protocols/moves/DataMap.hh>
28 #include <protocols/moves/Mover.fwd.hh> //Movers_map
30 #include <core/pose/selection.hh>
31 #include <basic/Tracer.hh>
32 
33 #include <utility/vector0.hh>
34 #include <utility/vector1.hh>
35 
36 namespace protocols {
37 namespace simple_filters {
38 
39 static basic::Tracer TR( "protocols.filters.AtomicContactFilter" );
40 
41 ///@brief default ctor
43  parent( "AtomicContact" ),
44  protocols::moves::ResId( 0 )
45 {}
46 
47 ///@brief Constructor with a single target residue
48 AtomicContactFilter::AtomicContactFilter( core::Size const res1, core::Size const res2, core::Real const distance, bool const sidechain, bool const backbone, bool const protons ) :
49  parent( "AtomicContact" ),
50  protocols::moves::ResId( res2 ),
51  residue1_( res1 ),
52  distance_( distance ),
53  sidechain_( sidechain ),
54  backbone_( backbone ),
55  protons_( protons )
56 {
57  range1_.push_back( residue1_ );
58 }
59 
60 /// @return Whether a disulfide bond is possible between any of the targets
62 {
63  core::Real const dist( compute( pose ) );
64  report( TR.Debug, pose );
65  if( dist <= distance_ ) return true;
66  return false;
67 }
68 
71 {
72  using namespace core::conformation;
73 
74  if( !get_resid() ){
75  TR.Error<<"ERROR: residue2 has not been defined"<<std::endl;
76  runtime_assert( get_resid() );
77  }
78  core::Real nearest_distance( 10000 );
79  Residue const res2( pose.residue( get_resid() ) );
80  for ( utility::vector1< core::Size >::const_iterator it=range1_.begin(); it!=range1_.end(); ++it ) {
81  core::Size residue1=*it;
82  Residue const res1( pose.residue( residue1 ) );
83 
84  Atoms::const_iterator atom1_begin( res1.atom_begin() ), atom1_end( res1.atom_end() ), atom2_begin( res2.atom_begin() ), atom2_end( res2.atom_end() );
85  if( sidechain_ && !backbone_ ){
86  atom1_begin = res1.sidechainAtoms_begin();
87  atom2_begin = res2.sidechainAtoms_begin();
88  }
89  if( !sidechain_ && backbone_ ){
90  atom1_end = res1.sidechainAtoms_begin();
91  atom2_end = res2.sidechainAtoms_begin();
92  }
93  if( !protons_ ){
94  atom1_end = res1.heavyAtoms_end();
95  atom2_end = res2.heavyAtoms_end();
96  }
97  for( Atoms::const_iterator atom1=atom1_begin; atom1!=atom1_end; ++atom1 ){
98  for( Atoms::const_iterator atom2=atom2_begin; atom2!=atom2_end; ++atom2 ){
99  core::Real const dist( atom1->xyz().distance( atom2->xyz() ) );
100  if( dist <= nearest_distance ) nearest_distance = dist;
101  }//foreach atom2
102  }//foreach atom1
103  }
104  return( nearest_distance );
105 }
106 
109 {
110  core::Real const dist( compute( pose ) );
111  return( dist );
112 }
113 
114 void AtomicContactFilter::report( std::ostream & out, core::pose::Pose const & pose ) const
115 {
116  core::Real const dist( compute( pose ) );
117  out<<"Minimal distance between residues "<<residue1_<<" and "<<get_resid()<<" is "<<dist<<std::endl;
118 }
119 
124  core::pose::Pose const & pose)
125 {
126  distance_ = tag->getOption< core::Real >( "distance", 4.0 );
127  if ( tag->hasOption("range1") ) {
128  residue1_ = 0;
129  std::istringstream range_str( tag->getOption< std::string >( "range1" ) );
130  core::Size num1, num2;
131  range_str >> num1 >> num2;
132  if ( !range_str.good() ) TR << "cannot read parameter range1" << std::endl;
133  for ( core::Size i=num1; i<=num2; ++i ) {
134  range1_.push_back( i );
135  }
136  }
137  if ( range1_.size() == 0 ) {
138  std::string const res1( tag->getOption< std::string >( "residue1" ) );
139  residue1_ = core::pose::parse_resnum( res1, pose );
140  range1_.push_back( residue1_ );
141  }
142  if( tag->hasOption( "residue2" ) ){
143  std::string const res2( tag->getOption< std::string >( "residue2" ) );
144  set_resid( core::pose::parse_resnum( res2, pose ) );
145  modifiable( false );
146  }
147  else{
148  modifiable( true );
149  TR<<"AtomicContact: residue2 was not defined. A mover/filter will have to set it during the protocol\n";
150  }
151  sidechain_ = tag->getOption< bool >( "sidechain", 1 );
152  backbone_ = tag->getOption< bool >( "backbone", 0 );
153  protons_ = tag->getOption< bool >( "protons", 0 );
154 
155  TR<<"AtomicContact filter between residues "<<residue1_<<" and "<<get_resid()<<" with distance cutoff of "<<distance_<<std::endl;
156 }
157 
160 
162 AtomicContactFilterCreator::keyname() const { return "AtomicContact"; }
163 
164 
165 
166 } // filters
167 } // protocols