18 #include <ObjexxFCL/format.hh>
19 #include <numeric/xyz.functions.hh>
22 #include <utility/vector1.hh>
23 #include <utility/io/ozstream.hh>
37 using namespace numeric;
45 poses.push_back(pose_in);
46 init_clash_check( poses, clash_dis, ignore );
52 poses.push_back(pose_in);
54 init_clash_check( poses, clash_dis, ignore );
63 init_clash_check(poses_in,clash_dis,ignore);
71 typedef numeric::xyzTriple< Size > CubeDim;
72 typedef numeric::xyzTriple< Size >
CubeKey;
74 neighbor_cutoff_ = neighbor_cutoff;
75 neighbor_cutoff_sq_ = ( neighbor_cutoff*neighbor_cutoff);
80 for(
Size i = 0; i < pi->n_residue(); ++i) {
81 if( std::find(ignore.begin(),ignore.end(),i+1) != ignore.end() )
continue;
83 Size const natom = pi->residue(i+1).nheavyatoms();
84 for(
Size j = 1; j <= natom; ++j) {
86 points_.push_back( pi->xyz(
AtomID(j,i+1)) );
87 resno_ .push_back( i+1 );
88 atomno_.push_back( j );
93 Vec bbu( points_[ 1 ] );
95 for (
Size ii = 2; ii <= points_.size(); ++ii ) { bbl_.min( points_[ ii ] ); bbu.max( points_[ ii ] ); }
96 bbl_ -= 10 * std::numeric_limits< Real >::epsilon();
97 bbu += 10 * std::numeric_limits< Real >::epsilon();
98 Real const side( neighbor_cutoff );
99 assert( side >
Real( 0 ) );
100 side_inv_ = (
Real( 1 ) / side );
102 Size( std::ceil( ( bbu.x() - bbl_.x() ) * side_inv_ ) ),
103 Size( std::ceil( ( bbu.y() - bbl_.y() ) * side_inv_ ) ),
104 Size( std::ceil( ( bbu.z() - bbl_.z() ) * side_inv_ ) )
107 cubes_.dimension( cube_dim_.x(), cube_dim_.y(), cube_dim_.z() );
109 for (
Size i = 1; i <= points_.size(); ++i ) {
110 Vec const pp( points_[ i ]);
111 CubeKey
const cube_key(
112 Size( ( pp.x() - bbl_.x() ) * side_inv_ ) + 1,
113 Size( ( pp.y() - bbl_.y() ) * side_inv_ ) + 1,
114 Size( ( pp.z() - bbl_.z() ) * side_inv_ ) + 1
116 assert( cube_key.x() <= cube_dim_.x() );
117 assert( cube_key.y() <= cube_dim_.y() );
118 assert( cube_key.z() <= cube_dim_.z() );
119 Size i_index = cubes_.index( cube_key.x(), cube_key.y(), cube_key.z() );
120 cubes_[ i_index ].push_back( i );
125 Size const icx(
Size( ( pp.x() - bbl_.x() ) * side_inv_ ) + 1 );
126 Size const icy(
Size( ( pp.y() - bbl_.y() ) * side_inv_ ) + 1 );
127 Size const icz(
Size( ( pp.z() - bbl_.z() ) * side_inv_ ) + 1 );
128 for (
Size ix = max( icx,
Size( 2 ) ) - 1, ixe = min( icx + 1, cube_dim_.x() ); ix <= ixe; ++ix ) {
129 for (
Size iy = max( icy,
Size( 2 ) ) - 1, iye = min( icy + 1, cube_dim_.y() ); iy <= iye; ++iy ) {
130 for (
Size iz = max( icz,
Size( 2 ) ) - 1, ize = min( icz + 1, cube_dim_.z() ); iz <= ize; ++iz ) {
131 Size cube_index = cubes_.index( ix, iy, iz );
132 if ( cubes_[ cube_index ].
size() != 0 ) {
134 Vec const j( points_[*ia] );
135 Real const d_sq( pp.distance_squared( j ) );
136 if ( d_sq <= neighbor_cutoff_sq_ ) {
150 Size const icx(
Size( ( pp.x() - bbl_.x() ) * side_inv_ ) + 1 );
151 Size const icy(
Size( ( pp.y() - bbl_.y() ) * side_inv_ ) + 1 );
152 Size const icz(
Size( ( pp.z() - bbl_.z() ) * side_inv_ ) + 1 );
153 for (
Size ix = max( icx,
Size( 2 ) ) - 1, ixe = min( icx + 1, cube_dim_.x() ); ix <= ixe; ++ix ) {
154 for (
Size iy = max( icy,
Size( 2 ) ) - 1, iye = min( icy + 1, cube_dim_.y() ); iy <= iye; ++iy ) {
155 for (
Size iz = max( icz,
Size( 2 ) ) - 1, ize = min( icz + 1, cube_dim_.z() ); iz <= ize; ++iz ) {
156 Size cube_index = cubes_.index( ix, iy, iz );
157 if ( cubes_[ cube_index ].
size() != 0 ) {
159 Vec const j( points_[*ia] );
160 Real const d_sq( pp.distance_squared( j ) );
161 if ( d_sq <= neighbor_cutoff_sq_ ) {
173 Size const icx(
Size( ( pp.x() - bbl_.x() ) * side_inv_ ) + 1 );
174 Size const icy(
Size( ( pp.y() - bbl_.y() ) * side_inv_ ) + 1 );
175 Size const icz(
Size( ( pp.z() - bbl_.z() ) * side_inv_ ) + 1 );
176 for (
Size ix = max( icx,
Size( 2 ) ) - 1, ixe = min( icx + 1, cube_dim_.x() ); ix <= ixe; ++ix ) {
177 for (
Size iy = max( icy,
Size( 2 ) ) - 1, iye = min( icy + 1, cube_dim_.y() ); iy <= iye; ++iy ) {
178 for (
Size iz = max( icz,
Size( 2 ) ) - 1, ize = min( icz + 1, cube_dim_.z() ); iz <= ize; ++iz ) {
179 Size cube_index = cubes_.index( ix, iy, iz );
180 if ( cubes_[ cube_index ].
size() != 0 ) {
182 Vec const j( points_[*ia] );
187 if( resno == resno_[*ia] && (atomno_[*ia]==2 || atomno_[*ia]==5) ) {
191 Real const d_sq( pp.distance_squared( j ) );
195 if ( d_sq <= neighbor_cutoff_sq_ ) {
228 if(i > 9)
if( ! clash_check( stubl.local2global(stub1.global2local(pose.
xyz(
AtomID(i,refrsd+0*pose_->n_residue())))) ) )
return false;
229 if( ! clash_check( stubl.local2global(stub1.global2local(pose.
xyz(
AtomID(i,refrsd+1*pose_->n_residue())))) ) )
return false;
230 if( ! clash_check( stubl.local2global(stub1.global2local(pose.
xyz(
AtomID(i,refrsd+2*pose_->n_residue())))) ) )
return false;
232 Vec cen = stubl.local2global(stub1.global2local(
Vec(0,0,0)));
233 Vec axs = stubl.local2global(stub1.global2local(
Vec(0,0,1)));
235 Mat rot = numeric::rotation_matrix_degrees(axs,120.0);
237 if( ! clash_check( rot*(*i-cen)+cen ) )
return false;
243 using namespace ObjexxFCL::fmt;
244 for(
Size i = 1; i <= points_.size(); ++i) {
246 std::string rname = pose_->residue(resno_[i]).name3();
247 std::string aname = pose_->residue(resno_[i]).atom_name(atomno_[i]);
248 out <<
"HETATM" + I( 5, i ) +
" "+aname+
" "+rname+
" "+chain
249 + I( 4, resno_[i] ) +
" "
253 + F( 6, 2, 0.0 ) +
' '
255 out <<
"" << std::endl;
260 utility::io::ozstream out(fname);
261 dump_debug_pdb(out,stub,chain);
268 for( i = points_.begin(); i != points_.end(); ++i ) {
269 Real const d_sq( pp.distance_squared( *i ) );
270 if ( d_sq <= neighbor_cutoff_sq_ ) {
277 bool clash = clash_check(pp);
279 if(clash != bclash) utility_exit_with_message(
"clash check test fails!!!");