Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
NeighborTypeFilter.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/simple_filters/NeighborTypeFilter.cc
11 /// @brief
12 /// @author Sarel Fleishman (sarelf@u.washington.edu), Jacob Corn (jecorn@u.washington.edu)
13 
16 
18 #include <core/pose/Pose.hh>
21 #include <basic/Tracer.hh>
22 #include <utility/tag/Tag.hh>
24 #include <core/pose/selection.hh>
25 
26 namespace protocols {
27 namespace simple_filters {
28 
29 static basic::Tracer neighbor_type_filter_tracer( "protocols.simple_filters.NeighborTypeFilter" );
30 
33 
35 NeighborTypeFilterCreator::keyname() const { return "NeighborType"; }
36 
38 
39 void
41 {
43  utility::vector0< utility::tag::TagPtr > const neighbor_type_tags( tag->getTags() );
44  for( utility::vector0< utility::tag::TagPtr >::const_iterator nt_it=neighbor_type_tags.begin(); nt_it!=neighbor_type_tags.end(); ++nt_it ) {
45  utility::tag::TagPtr const nt_tag_ptr = *nt_it;
46  if( nt_tag_ptr->getName() == "Neighbor" ) {
47  std::string const type( nt_tag_ptr->getOption<std::string>( "type" ) );
49  }
50  }
52  distance_threshold_ = tag->getOption<core::Real>( "distance", 8.0 );
53 
54  neighbor_type_filter_tracer<<"NeighborTypeFilter with distance threshold of "<<distance_threshold_<<" around residue "<<target_residue_<<std::endl;
55 }
56 
57 bool
59 {
60  std::vector< core::Size > neighbors = compute( pose );
61  if( neighbors.size() == 0 ) return false;
62  neighbor_type_filter_tracer<<"neighbours of residue "<<pose.residue( target_residue_ ).name3()<<target_residue_<<": ";
63  for( std::vector< core::Size >::const_iterator n_it=neighbors.begin(); n_it!=neighbors.end(); ++n_it ) {
64  neighbor_type_filter_tracer<<pose.residue( *n_it ).name3()<<*n_it<<" ";
65  }
66  neighbor_type_filter_tracer<<std::endl;
67  return true;
68 }
69 
70 void
71 NeighborTypeFilter::report( std::ostream & out, core::pose::Pose const & pose ) const
72 {
73  std::vector< core::Size > neighbors = compute( pose );
74  out<<"neighbours of residue "<<pose.residue( target_residue_ ).name3()<<target_residue_<<": ";
75  for( std::vector< core::Size >::const_iterator n_it=neighbors.begin(); n_it!=neighbors.end(); ++n_it ) {
76  out<<pose.residue( *n_it ).name3()<<*n_it<<" ";
77  }
78  out<<'\n';
79 }
80 
83 {
84  std::vector< core::Size > neighbors = compute( pose );
85  return( neighbors.size() != 0 );
86 }
87 
88 std::vector< core::Size >
90 {
91  std::vector< core::Size > neighbors;
92 
93  core::Size const chain2begin( pose.conformation().chain_begin( 2 ) );
94  core::Size const residue_num( pose.total_residue() );
95 
96  core::Size const start( target_residue_ < chain2begin ? chain2begin : 1 );
97  core::Size const end( target_residue_ < chain2begin ? residue_num : chain2begin-1 );
98  core::conformation::Residue const res_target( pose.residue( target_residue_ ) );
99 
100  runtime_assert( target_residue_ <= residue_num );
101  for( core::Size res=start; res<=end; ++res ) {
102  core::conformation::Residue const resi( pose.residue( res ) );
103  if( !residue_types_[ resi.aa() ] ) continue;
104 
105  core::Real const distance( res_target.xyz( res_target.nbr_atom() ).distance( resi.xyz( resi.nbr_atom() )) );
107  neighbors.push_back( res );
108  }
109  return neighbors;
110 }
111 
112 }
113 }