43 #include <basic/options/option.hh>
46 #include <basic/options/keys/edensity.OptionKeys.gen.hh>
49 #include <basic/Tracer.hh>
54 #include <utility/vector1.hh>
55 #include <numeric/xyz.functions.hh>
63 namespace electron_density {
65 static basic::Tracer
TR(
"protocols.electron_density.util");
67 using namespace protocols;
76 runtime_assert( nres > (
int)N );
79 int start_res = allow_termini? 1 : 6;
80 int stop_res = allow_termini? nres : nres-5;
83 for (
int i=start_res+1; i<= stop_res-(
int)N; i++) {
85 bool contains_cut =
false;
86 for (
int j=i; j<i+(
int)N; ++j)
88 if (contains_cut)
continue;
93 for (
int j=i; j<i+(
int)N; ++j)
102 for (
int i=0; i<(
int)nloops; ++i) {
104 int worst_match_idx = -1;
105 for (
int j=0; j<nres; ++j) {
106 if (scores[j] > worst_match) {
107 worst_match = scores[j];
113 for (
int j=worst_match_idx; j<worst_match_idx+(
int)N; ++j)
127 ObjexxFCL::FArray1D< char > dssp_pose( nres );
134 dockindens->apply( pose );
141 for (
int r=1; r<=nres; ++r) {
143 bool isMissingDens =
false;
147 isMissingDens =
true;
167 smoothPerResCC[1] = 0.67*perResCC[1] + 0.33*perResCC[2];
168 for (
int r=2; r<=nres-1; ++r) {
169 smoothPerResCC[r] = 0.25*perResCC[r+1] + 0.5*perResCC[r] + 0.25*perResCC[r];
171 smoothPerResCC[nres] = 0.67*perResCC[nres] + 0.33*perResCC[nres-1];
174 for (
int r=1; r<=nres; ++r) {
175 if (perResCC[r] == 0) smoothPerResCC[r] = 0.0;
176 if (r != 1 && perResCC[r-1] == 0) smoothPerResCC[r] = 0.0;
177 if (r != nres && perResCC[r+1] == 0) smoothPerResCC[r] = 0.0;
182 for (
int r=1; r<=nres; ++r) {
183 bool in_strand = (max_strand_melt >= 0), in_helix = (max_helix_melt >= 0);
185 for (
int i=std::max(1,r-max_strand_melt), i_end=std::min(nres,r+max_strand_melt); i<= i_end; ++i) {
186 in_strand &= (dssp_pose(i) ==
'E');
188 for (
int i=std::max(1,r-max_helix_melt), i_end=std::min(nres,r+max_helix_melt); i<= i_end; ++i) {
189 in_helix &= (dssp_pose(i) ==
'H');
191 if ( in_strand || in_helix ) {
192 if ( smoothPerResCC[ r ] > 0.0 )
193 smoothPerResCC[ r ] = 2;
198 std::sort( sortPerResCC.begin(), sortPerResCC.end() );
199 core::Real CCcutoff = sortPerResCC[ (
int)std::floor(frac*nres + 0.5) ];
200 for (
int r=1; r<=nres; ++r) {
201 loopMarker[r] = (smoothPerResCC[r] < CCcutoff);
205 for (
int r=2; r<=nres-1; ++r) {
206 if ( loopMarker[r+1] && loopMarker[r-1] ) {
207 loopMarker[r] =
true;
209 if ( !loopMarker[r+1] && !loopMarker[r-1] ) {
210 if ( perResCC[r] > 0 ) {
211 loopMarker[r] =
false;
213 loopMarker[r+1] = loopMarker[r-1] =
true;
221 for (
int i=1; i<=(
int)cuts.size(); ++i) {
223 if (j <= nres-4 && (loopMarker[j+4] || loopMarker[j+3] || loopMarker[j+2] || loopMarker[j+1] ) ) {
224 loopMarker[j+4] = loopMarker[j+3] = loopMarker[j+2] = loopMarker[j+1] =
true;
226 if (j >= 3 && (loopMarker[j] || loopMarker[j-3] || loopMarker[j-2] || loopMarker[j-1]) ) {
227 loopMarker[j] = loopMarker[j-3] = loopMarker[j-2] = loopMarker[j-1] =
true;
235 for (
int r=1; r<=nres; ++r) {
236 if ( loopMarker[r] && !inloop ) {
240 }
else if ( loopMarker[r] && inloop ) {
242 }
else if ( !loopMarker[r] && inloop ) {
269 using namespace basic::options;
272 if (align.length() == 0)
273 align = option[ OptionKeys::edensity::realign ]();
302 if (align !=
"no" && align !=
"random" && dens_score_sum==0 ) {
312 if (align ==
"random") {
317 for (
int i=1; i<=(
int)root_edges.size(); ++i) {
322 dens_score = (*scorefxn_dens)( pose );
328 if ( align.substr(0,8) ==
"membrane") {
339 if ( align.length() >= 3 && align.substr( align.length()-3 ) ==
"min" ) {
347 rbmm->set_bb(
false ); rbmm->set_chi(
false );
352 TR <<
"RBminimizing pose into density alongs jump(s)";
353 for (
core::Size i=1; i<=root_edges.size(); ++i) {
354 TR <<
" " << root_edges[i].label();
355 rbmm->set_jump ( root_edges[i].label() ,
true );
367 min_mover->apply( pose );
370 symmscorefxn_dens->show(
TR, pose );
TR<<std::endl;
371 dens_score = (*symmscorefxn_dens)( pose );
377 min_mover->apply( pose );
379 dens_score = (*scorefxn_dens)( pose );
392 for (
int i=1; i<= nres; ++i ) {
396 for (
Size j=1; j<= rsd.nheavyatoms(); ++j ) {
398 massSum += atom.
xyz();
418 for (
int i=1; i<= nres; ++i ) {
422 for (
Size j=1; j<= rsd.natoms(); ++j ) {
431 if (axis !=
"X" && axis !=
"Y" && axis !=
"Z") {
432 TR.Error <<
"Unrecognized membrane-normal axis '" << axis <<
"'" << std::endl;
433 TR.Error <<
"Not aligning!" << std::endl;
439 for (
int i=1; i<= nres; ++i ) {
442 for (
Size j=1; j<= rsd.nheavyatoms(); ++j ) {
444 massSum += atom.
xyz();
454 for (
int i=1; i<= nres; ++i ) {
457 for (
Size j=1; j<= rsd.natoms(); ++j ) {