Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FadeFunc.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/FadeFunc.hh
11 /// @brief Definition for functions used in definition of constraints.
12 /// @author Rhiju Das
13 
14 
16 
17 #include <core/types.hh>
18 
19 #include <utility/pointer/ReferenceCount.hh>
20 
21 // AUTO-REMOVED #include <ObjexxFCL/format.hh>
22 
23 // C++ Headers
24 #include <iostream>
25 
26 #include <utility/vector1.hh>
27 
28 
29 namespace core {
30 namespace scoring {
31 namespace constraints {
32 
33 FuncOP
35 {
38  well_offset_ );
39 }
40 
41 Real
42 FadeFunc::func( Real const z ) const
43 {
44 
45  Real fade_value( 1.0 );
46 
47  if (z < cutoff_lower_ || z > cutoff_upper_ ){
48  fade_value = 0.0;
49  } else if ( z < cutoff_lower_ + fade_zone_ ) {
50  //Check little strip near lower cutoff.
51  Real const b = -1.0 * ( z - (cutoff_lower_ + fade_zone_) )/ fade_zone_;
52  Real const b2 = b*b;
53  Real const b3 = b2*b;
54  fade_value = ( 2 * b3 - 3 * b2 + 1 );
55  // fade_deriv = -1.0 * (6 * b2 - 6 * b ) / fade_zone_;
56  } else if ( z > cutoff_upper_ - fade_zone_ ) {
57  //Check little strip near upper cutoff.
58  Real const b = ( z - (cutoff_upper_ - fade_zone_) )/ fade_zone_;
59  Real const b2 = b*b;
60  Real const b3 = b2*b;
61  fade_value = ( 2 * b3 - 3 * b2 + 1 );
62  // fade_deriv = (6 * b2 - 6 * b ) / fade_zone_;
63  }
64 
65 
66  return well_depth_ * fade_value + well_offset_;
67 }
68 
69 Real
70 FadeFunc::dfunc( Real const z ) const
71 {
72 
73  Real fade_deriv( 0.0 );
74 
75  if (z < cutoff_lower_ || z > cutoff_upper_ ){
76  fade_deriv = 0.0;
77  } else if ( z < cutoff_lower_ + fade_zone_ ) {
78  //Check little strip near lower cutoff.
79  Real const b = -1.0 * ( z - (cutoff_lower_ + fade_zone_) )/ fade_zone_;
80  Real const b2 = b*b;
81  // Real const b3 = b2*b;
82  //fade_value = ( 2 * b3 - 3 * b2 + 1 );
83  fade_deriv = -1.0 * (6 * b2 - 6 * b ) / fade_zone_;
84  } else if ( z > cutoff_upper_ - fade_zone_ ) {
85  //Check little strip near upper cutoff.
86  Real const b = ( z - (cutoff_upper_ - fade_zone_) )/ fade_zone_;
87  Real const b2 = b*b;
88  // Real const b3 = b2*b;
89  // fade_value = ( 2 * b3 - 3 * b2 + 1 );
90  fade_deriv = (6 * b2 - 6 * b ) / fade_zone_;
91  }
92 
93  return well_depth_ * fade_deriv;
94 }
95 
96 void
97 FadeFunc::read_data( std::istream& in ) {
99 
100  well_offset_ = 0.0;
101  if( in.good() ) in >> well_offset_;
102 
103 }
104 
105 void
106 FadeFunc::show_definition( std::ostream &out ) const {
107  out << "FADE " <<
108  ' ' << cutoff_lower_ <<
109  ' ' << cutoff_upper_ <<
110  ' ' << fade_zone_ <<
111  ' ' << well_depth_ <<
112  ' ' << well_offset_ << std::endl;
113 }
114 
115 Size
116 FadeFunc::show_violations( std::ostream& out, Real x, Size verbose_level, Real threshold) const {
117  if (verbose_level > 100 ) {
118  out << "FADE " << ( x < cutoff_lower_ || x > cutoff_upper_ ) << std::endl;
119  }
120  return Func::show_violations( out, x, verbose_level, threshold);
121 }
122 
123 
124 } // namespace constraints
125 } // namespace scoring
126 } // namespace core
127