Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TorsionFilter.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 /// @author Sarel Fleishman (sarelf@uw.edu)
13 #include <sstream>
15 #include <core/pose/PDBInfo.hh>
16 #include <core/pose/Pose.hh>
17 #include <utility/tag/Tag.hh>
19 // AUTO-REMOVED #include <protocols/moves/DataMap.hh>
20 #include <basic/Tracer.hh>
22 #include <core/pose/selection.hh>
23 #include <boost/foreach.hpp>
24 #define foreach BOOST_FOREACH
25 //Auto Headers
26 #include <utility/vector0.hh>
27 #include <utility/vector1.hh>
29 
30 
31 namespace protocols {
32 namespace protein_interface_design{
33 namespace filters {
34 
35 static basic::Tracer TR( "protocols.protein_interface_design.filters.Torsion" );
36 static basic::Tracer TR_database( "protocols.protein_interface_design.filters.Torsion_database" );
37 
38 ///@brief default ctor
40  parent( "Torsion" ),
41  lower_( false ),
42  upper_( true ),
43  resnum_( 0 ),
44  torsion_( "" ),
45  task_factory_( NULL ),
46  task_factory_set_( false )
47 {}
48 
49 bool
50 Torsion::apply(core::pose::Pose const & pose ) const
51 {
52  if( task_factory_set() ){
53  utility::vector1< core::Size > designable( protocols::rosetta_scripts::residue_packer_states( pose, task_factory(), true/*designable*/, false/*packable*/ ) );
54  std::sort( designable.begin(), designable.end() );
55  core::Size const start( designable[ 1 ] );
56  core::Size const stop( designable[ designable.size() ] );
57  for( core::Size i = start; i<=stop; ++i )
58  TR_database<<pose.phi( i )<<" "<<pose.psi( i )<<" "<<pose.omega( i )<<" "<<pose.residue( i ).name3()<<" ";
59  TR_database<<std::endl;
60  return true;
61  }
62  else if( resnum() == 0 ){ // just print all torsions
63  std::stringstream s("");
64  for( core::Size i = 1; i <= pose.total_residue(); ++i ){
65  if( i % 5 == 0 ) s << pose.residue( i ).name1()<<pose.pdb_info()->number( i )<<pose.pdb_info()->chain( i )<<'\t';
66  TR<<"Residue "<<pose.residue( i ).name1()<<pose.pdb_info()->number( i )<<pose.pdb_info()->chain( i )<<'\t';
67  if( torsion() == "phi" || torsion() == "" ){
68  TR<<" phi "<<pose.phi( i )<<'\t';
69  s<<pose.phi( i )<<' ';
70  }
71  if( torsion() == "psi" || torsion() == "" ){
72  TR<<" psi "<<pose.psi( i )<<'\t';
73  s<<pose.psi( i )<<' ';
74  }
75  if( torsion() == "omega" || torsion() == "" ){
76  TR<<" omega "<<pose.omega( i )<<std::endl;
77  s<<pose.omega( i )<<' ';
78  }
79  }
80  TR<<s.str()<<std::endl;
81  return true;
82  }
83  else{
84  TR<<"Residue "<<pose.residue( resnum() ).name1()<<pose.pdb_info()->number( resnum() )<<pose.pdb_info()->chain( resnum() )<<'\t';
85  if( torsion() == "phi" || torsion() == "" ){
86  core::Real const phi( pose.phi( resnum() ) );
87  TR<<" phi "<<phi<<std::endl;
88  if( torsion() == "phi" )
89  return( phi>=lower() && phi<=upper() );
90  }
91  if( torsion() == "psi" || torsion() == "" ){
92  core::Real const psi( pose.psi( resnum() ) );
93  TR<<" psi "<<pose.psi( resnum() )<<std::endl;
94  if( torsion() == "psi" )
95  return( psi>=lower() && psi<=upper() );
96  }
97  }
98 
99  return false;
100 }
101 
104  if( resnum() > 0 ){
105  if( torsion() == "phi" ) return p.phi( resnum() );
106  if( torsion() == "psi" ) return p.psi( resnum() );
107  if( torsion() == "omega" ) return p.omega( resnum() );
108  }
109  return 0.; // You gotta return something!
110 }
111 
114 {
115  return( compute( pose ) );
116 }
117 
118 void
119 Torsion::report( std::ostream & out, core::pose::Pose const & pose ) const
120 {
121  out<<"Torsion returns "<<compute( pose )<<std::endl;
122 }
123 
124 void
129  core::pose::Pose const & pose )
130 {
131  task_factory_set( false );
132  if( tag->hasOption( "task_operations" ) )
133  task_factory_set( true );
134  runtime_assert( task_factory_set_ != tag->hasOption( "resnum" ) );
135  lower( tag->getOption< core::Real >( "lower", 0 ) );
137  upper( tag->getOption< core::Real >( "upper", 0 ) );
138  torsion( tag->getOption< std::string >( "torsion", "" ) );
139  if( tag->hasOption( "resnum" ))
140  resnum( core::pose::parse_resnum( tag->getOption< std::string >( "resnum" ), pose ) );
141  else resnum( 0 );
142  TR<<"resnum: "<<resnum()<<" lower "<<lower()<<" upper: "<<upper()<<std::endl;
143 }
144 
147  return new Torsion();
148 }
149 
151 
154  return new Torsion( *this );
155 }
156 
158 TorsionCreator::create_filter() const { return new Torsion; }
159 
161 TorsionCreator::keyname() const { return "Torsion"; }
162 
165 
166 void
168  task_factory_ = tf;
169 }
170 
171 } // filters
172 } // protein_interface_design
173 } // protocols