Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DimerPairing.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 // This file is made available under the Rosetta Commons license.
5 // See http://www.rosettacommons.org/license
6 // (C) 199x-2007 University of Washington
7 // (C) 199x-2007 University of California Santa Cruz
8 // (C) 199x-2007 University of California San Francisco
9 // (C) 199x-2007 Johns Hopkins University
10 // (C) 199x-2007 University of North Carolina, Chapel Hill
11 // (C) 199x-2007 Vanderbilt University
12 
13 /// @file
14 /// @brief
15 /// @author Nobuyasu Koga ( nobuyasu@uw.edu )
16 
17 
20 #include <ObjexxFCL/format.hh>
21 
22 #include <utility/vector1.hh>
23 
24 
25 
26 namespace protocols {
27 namespace fldsgn {
28 namespace topology {
29 
30 /// @details Auto-generated virtual destructor
32 
33 
34 /// @brief
36  Size const res1,
37  Size const res2,
38  Real const dist,
39  Real const phi,
40  Real const theta,
41  Real const sigma,
42  Real const dp,
43  Size const sign1,
44  Size const sign2,
45  Real const score
46 ): res1_( res1 ),
47  res2_( res2 ),
48  dist_( dist ),
49  phi_( phi ),
50  theta_( theta ),
51  sigma_( sigma ),
52  dp_( dp ),
53  sign1_( sign1 ),
54  sign2_( sign2 ),
55  score_( score ),
56  orient_( 'N' ),
57  valid_( true )
58 {
59  if( is_parallel( phi, theta ) ) {
60  orient_ = 'P';
61  } else {
62  orient_ = 'A';
63  }
64 }
65 
66 
67 /// @brief the pairing is parallel ?
68 bool
69 DimerPairing::is_parallel( Real const phi, Real const theta )
70 {
71  if( phi <= 0.0 ){
72  if( theta <= 70.0 ){
73  return true;
74  }else{
75  return false;
76  }
77  }else{
78  if( theta <= 110 ){
79  return true;
80  }else{
81  return false;
82  }
83  }
84  runtime_assert( false );
85 } // is_parallel
86 
87 std::ostream& operator<<( std::ostream & out, const DimerPairing & dp )
88 {
89  using ObjexxFCL::fmt::I;
90  using ObjexxFCL::fmt::F;
91  using ObjexxFCL::fmt::A;
92  out << I( 4, dp.res1() ) << ' ' << I( 4, dp.res2() ) << ' '
93  << F( 9, 3, dp.dist() ) << ' ' << F( 9, 3, dp.sigma() ) << ' '
94  << F( 9, 3, dp.phi() ) << ' ' << F( 9, 3, dp.theta() ) << ' ' << F( 9, 3, dp.dp() ) << ' '
95  << I( 2, dp.sign1() ) << ' ' << I( 2, dp.sign2() ) << ' ' << A( 2, dp.orient() ) << ' '
96  << F( 9, 3, dp.score() ) << std::endl;
97  return out;
98 }
99 
100 /// @brief
102 {
103  return ( a->score() < b->score() );
104 }
105 
106 /// @brief
107 void
109 {
110  std::sort( begin(), end(), pointer_sorter );
111 
112  for ( iterator it=begin(), ite=end(); it!=ite ; ++it ){
113 
114  DimerPairing const & pairing( **it );
115  if( !pairing.valid() ) continue;
116 
117  Size const res1( pairing.res1() );
118  Size const res2( pairing.res2() );
119  runtime_assert( res2 > res1 );
120 
121  Size const sign1( pairing.sign1() );
122  Size const sign2( pairing.sign2() );
123 
124  Size const strand1( ss_info.strand_id( pairing.res1() ) );
125  Size const strand2( ss_info.strand_id( pairing.res2() ) );
126  runtime_assert( strand2 > strand1 );
127 
128  iterator it2( it );
129  ++it2;
130  for ( ; it2 != ite; ++it2 ) {
131 
132  DimerPairing & other( **it2 );
133  if ( !other.valid() ) continue;
134 
135  Size const other_strand1( ss_info.strand_id( other.res1() ) );
136  Size const other_strand2( ss_info.strand_id( other.res2() ) );
137 
138  //car if dimer1 and ss2 interact favorably and ss2 and dimer2 are in different strands
139  //car and ss2 is on the same side of dimer1 as dimer2 is... then mark this pair as dissallowed
140  if ( ( other.res1() == res1 && other_strand2 != strand2 && other.sign1() == sign1 ) ||
141  ( other.res2() == res1 && other_strand1 != strand2 && other.sign2() == sign1 ) ||
142  ( other.res1() == res2 && other_strand2 != strand1 && other.sign1() == sign2 ) ||
143  ( other.res2() == res2 && other_strand1 != strand1 && other.sign2() == sign2 ) ) {
144  other.valid( false );
145  }
146 
147  } // it2
148  } // it
149 
150 } // finalize
151 
152 
153 
154 std::ostream& operator<<( std::ostream & out, const DimerPairings &dps )
155 {
156  using ObjexxFCL::fmt::I;
157  using ObjexxFCL::fmt::LJ;
158  using ObjexxFCL::fmt::RJ;
159  out << LJ(4, "#" ) << ' '
160  << LJ(4, "res1" ) << ' ' << LJ(4, "res2" ) << ' '
161  << RJ(9, "dist" ) << ' ' << RJ(9, "sigma" ) << ' '
162  << RJ(9, "phi" ) << ' ' << RJ(9, "theta" ) << ' ' << RJ(9, "dp" ) << ' '
163  << LJ(2, "s1" ) << ' ' << LJ(2, "s2" ) << ' ' << LJ(2, "pr" ) << ' '
164  << RJ(9, "score") << std::endl;
165 
166  core::Size count( 0 );
167  for ( DimerPairings::const_iterator it=dps.begin(), eit=dps.end(); it!=eit; ++it ) {
168  if( !( **it).valid() ) continue;
169  out << I( 4, count++ ) << ' ' ;
170  out << (**it);
171  }
172  return out;
173 }
174 
175 
176 
177 } // ns topology
178 } // ns fldsgn
179 } // ns protocols