Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SheetFilter.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 SheetFilter.cc
11 /// @brief runs reject or accept filters on pose
12 /// @detailed
13 /// Contains currently: SheetFilter
14 ///
15 ///
16 /// @author Robert Vernon
17 
18 // Unit Headers
20 
21 // Package Headers
22 
23 // Project Headers
24 #include <core/pose/Pose.hh>
26 #include <core/types.hh>
27 
28 // ObjexxFCL Headers
29 #include <ObjexxFCL/FArray1D.hh>
30 #include <ObjexxFCL/FArray2D.hh>
31 #include <ObjexxFCL/FArray1A.hh>
32 #include <ObjexxFCL/FArray2A.hh>
33 
34 // Utility headers
35 #include <utility/vector1.fwd.hh>
36 #include <utility/pointer/ReferenceCount.hh>
37 #include <basic/Tracer.hh>
38 
39 // Numeric headers
40 #include <numeric/xyzVector.hh>
41 
42 //// C++ headers
43 #include <cstdlib>
44 #include <string>
45 
46 #include <utility/vector1.hh>
47 
48 
49 
50 
51 
52 
53 
54 
55 static basic::Tracer tr("protocols.simple_filters.SheetFilter");
56 
57 using core::Real;
58 using namespace core;
59 using namespace basic;
60 using namespace ObjexxFCL;
61 
62 namespace protocols {
63 namespace simple_filters {
64 
65 
66 bool SheetFilter::apply( core::pose::Pose const & pose ) const {
67  if ( !AbinitioBaseFilter::apply( pose ) ) return false;
68  if ( sstype_ == "fail" ) return true;
69  //car sheet_filter disable
70  if ( beta_ < 20 || beta_ratio_ <= 0.2 ) return true;
71 
72 // now the ss-type is read in apply():
73 // and the disable decision is made here
74 // std::string sstype = get_protein_sstype( pose );
75 // if ( disable_sheet_filter_ ) {
76 // return true;
77 // }
78 
79  //SHEET FILTER
80  float const distance_cutoff = { 6.5 };
81  //std::string protein_sstype;
82 
83  //bool sheet_filter (true);
84 
85  float min_dotprod;
86  float max_distance;
87  //float handedness_score_;
88  int nstrands,nsheets;
89  int local_pairs,nonlocal_pairs;
90 
91  //protein_sstype = get_protein_sstype();
92 
93  FArray1D_int isN;
94  FArray1D_int isCA;
95  FArray1D_int isC;
96  FArray1D_int res_num;
97 
98  int const max_pos(5);
99  int const max_res(pose.total_residue());
100 
101  FArray2D_float position( 3, max_pos*max_res );
102 
103  for ( int i = 1; i <= max_res; i += 1) {
104  int const itemp = max_pos*(i-1)+1;
105  pose.residue(i).atom("N").xyz().x();
106  position(1,itemp) = pose.residue(i).xyz("N").x();
107  position(2,itemp) = pose.residue(i).xyz("N").y();
108  position(3,itemp) = pose.residue(i).xyz("N").z();
109  position(1,itemp+1) = pose.residue(i).xyz("CA").x();
110  position(2,itemp+1) = pose.residue(i).xyz("CA").y();
111  position(3,itemp+1) = pose.residue(i).xyz("CA").z();
112  //position(1,itemp+2) = pose.residue(i).xyz("CB").x();
113  //position(2,itemp+2) = pose.residue(i).xyz("CB").y();
114  //position(3,itemp+2) = pose.residue(i).xyz("CB").z();
115  position(1,itemp+3) = pose.residue(i).xyz("C").x();
116  position(2,itemp+3) = pose.residue(i).xyz("C").y();
117  position(3,itemp+3) = pose.residue(i).xyz("C").z();
118  position(1,itemp+4) = pose.residue(i).xyz("O").x();
119  position(2,itemp+4) = pose.residue(i).xyz("O").y();
120  position(3,itemp+4) = pose.residue(i).xyz("O").z();
121  }
122 
123  res_num = FArray1D_int( max_pos * max_res );
124  isN = FArray1D_int( max_pos * max_res );
125  isC = FArray1D_int( max_pos * max_res );
126  isCA = FArray1D_int( max_pos * max_res );
127 
128  for ( int i = 1, e = max_pos*max_res; i<= e; i+= max_pos ) {
129  isN(i) = 1;
130  isN(i+1) = 0;
131  isN(i+2) = 0;
132  isN(i+3) = 0;
133  isN(i+4) = 0;
134 
135  isCA(i) = 0;
136  isCA(i+1) = 1;
137  isCA(i+2) = 0;
138  isCA(i+3) = 0;
139  isCA(i+4) = 0;
140 
141  isC(i) = 0;
142  isC(i+1) = 0;
143  isC(i+2) = 0;
144  isC(i+3) = 1;
145  isC(i+4) = 0;
146 
147  for ( int j = 0; j < max_pos; ++j ) {
148  res_num(i+j) = (i/max_pos) + 1;
149  }
150  }
151 
152  FArray1D_int ss( max_res );
153 
154  for ( int i = 1; i <= max_res; ++i ) {
155 
156  if ( pose.secstruct(i) == 'H') {
157  ss(i) = 1;
158  } else if ( pose.secstruct(i) == 'E' ) {
159  ss(i) = 2;
160  } else {
161  ss(i) = 3;
162  }
163  }
164 
165  handedness_score_ = 0.0;
166 
167  int result = 0;
168 
169  ingo_sheet_stuff(max_res, ss, max_res*max_pos, position, isN, isCA, isC,
170  res_num, distance_cutoff, nstrands, nsheets, max_distance,
171  min_dotprod, local_pairs, nonlocal_pairs, result);
172 
173 //$$$ if ( result > 0 ) sheet_filter = false;
174 //$$$ if ( result == 2 ) sheet_filter = true; // pass toblerone (not possible)
175 //$$$ if ( result == 5 ) sheet_filter = true; // pass dotprod (not possible)
176 //$$$ if ( result == 8 ) sheet_filter = true; // pass large barrels
177 
178  if ( result == 3 ) return false;
179  if ( result == 4 ) return false;
180  if ( result == 6 ) return false;
181  if ( result == 7 ) return false;
182  if ( result == 9 ) return false;
183 
184  return true;
185 }
186 
187 // std::string SheetFilter::get_protein_sstype() {
188 // return "misc::sstype::sstype??";
189 // }
190 
191 
192 ////////////////////////
193 /// Private: Methods ///
194 ////////////////////////
195 
196 ////////////////////////////////////////////////////////////////////////////////
197 /// @begin ingo_diamers
198 ///
199 /// @brief
200 /// THIS PROGRAM IDENTIFIES THE STRAND DIAMERS
201 ///
202 /// @detailed
203 ///
204 /// @param nres - [in/out]? -
205 /// @param strnm - [in/out]? -
206 /// @param natm - [in/out]? -
207 /// @param atmps - [in/out]? -
208 /// @param rnm - [in/out]? -
209 /// @param indC - [in/out]? -
210 /// @param indN - [in/out]? -
211 /// @param strdm - [in/out]? -
212 /// @param inddm - [in/out]? -
213 ///
214 /// @global_read
215 ///
216 /// @global_write
217 ///
218 /// @remarks
219 ///
220 /// @references
221 ///
222 /// @authors
223 ///
224 /// @last_modified 10/31/00
225 /////////////////////////////////////////////////////////////////////////////////
226 void
227 SheetFilter::ingo_diamers(
228  int const & nres,
229  FArray1A_int strnm,
230  int natm,
231  FArray2D_float const & atmps,
232  FArray1D_int & rnm,
233  FArray1D_int & indC,
234  FArray1D_int & indN,
235  FArray2A_float strdm,
236  FArray1A_int inddm
237 ) const
238 {
239  strnm.dimension( nres );
240 // atmps.dimension( 3, natm );
241  rnm.dimension( natm );
242  indC.dimension( natm );
243  indN.dimension( natm );
244  strdm.dimension( nres, 3 );
245  inddm.dimension( nres );
246 
247 
248  for ( int k = 1; k <= nres; ++k ) {
249  strdm(k,1) = 0.0;
250  strdm(k,2) = 0.0;
251  strdm(k,3) = 0.0;
252  inddm(k) = 0;
253  }
254 
255  for ( int k = 1; k <= natm; ++k ) {
256  if ( rnm(k) < nres ) {
257  if ( ( strnm(rnm(k)) > 0 ) && ( strnm(rnm(k)+1) > 0 ) ) {
258  if ( indN(k) == 1 ) {
259  float x1 = atmps(1,k);
260  float y1 = atmps(2,k);
261  float z1 = atmps(3,k);
262  int next_carbon = 0;
263  int i = 3;
264  while ( next_carbon == 0 ) {
265  if ( indC(k+i) == 1 ) {
266  float x2 = atmps(1,k+i);
267  float y2 = atmps(2,k+i);
268  float z2 = atmps(3,k+i);
269  strdm(rnm(k),1) = 0.5*(x1+x2);
270  strdm(rnm(k),2) = 0.5*(y1+y2);
271  strdm(rnm(k),3) = 0.5*(z1+z2);
272  inddm(rnm(k)) = 1;
273  next_carbon = 1;
274  } else {
275  ++i;
276  }
277  }
278  }
279  }
280  }
281  }
282 
283 }
284 
285 ////////////////////////////////////////////////////////////////////////////////
286 /// @begin ingo_find_dir
287 ///
288 /// @brief
289 /// THIS PROGRAM FINDS THE DIRECTIONS OF THE STRANDS IN THE SHEETS
290 ///
291 /// @detailed
292 ///
293 /// @param shnm - [in/out]? -
294 /// @param hm - [in/out]? -
295 /// @param nstr - [in/out]? -
296 /// @param slct - [in/out]? -
297 /// @param order - [in/out]? -
298 /// @param strlbl - [in/out]? -
299 /// @param strdr - [in/out]? -
300 /// @param proper - [in/out]? - Not used
301 /// @param directions - [in/out]? -
302 ///
303 /// @global_read
304 ///
305 /// @global_write
306 ///
307 /// @remarks
308 ///
309 /// @references
310 ///
311 /// @authors
312 ///
313 /// @last_modified 11/26/01
314 /////////////////////////////////////////////////////////////////////////////////
315 void
316 SheetFilter::ingo_find_dir(
317  int shnm,
318  int hm,
319  int & nstr,
320  FArray1A_int slct,
321  FArray1A_int order,
322  FArray1A_int strlbl,
323  FArray2A_float strdr,
324  // int & proper, // Not used
325  FArray1A_int directions
326 ) const
327 {
328 
329  slct.dimension( hm );
330  order.dimension( hm );
331  strlbl.dimension( nstr );
332  strdr.dimension( nstr, 3 );
333  directions.dimension( hm );
334 
335  FArray2D_float centers( max_nstr, 3 );
336  int cnt = 0;
337 
338 //js finding strands that are in the sheet
339 
340  for ( int j = 1; j <= nstr; ++j ) {
341  if ( strlbl(j) == shnm ) {
342 //js count them
343  ++cnt;
344 //js put them in an array
345  slct(cnt) = j;
346  }
347  }
348 //js centers holds the vectors from the start to stop
349 //js of each strand.
350  for ( int i = 1; i <= hm; ++i ) {
351  for ( int j = 1; j <= 3; ++j ) {
352  centers(i,j) = strdr(slct(i),j);
353  }
354  }
355 
356 //js pretty sure this order thing is screwing things up in ingo_hand.
357 //js The directions array is later accessed according the strand
358 //js number, but it is being filled according to the order of the strands
359 //js in the sheet.
360 //js Easiest fix seems to me to be to put the order(i) in reference to
361 //js directions here. Then later calls to directions should do the
362 //js right thing?
363 //rhiju Double checked -- jack's fix look ok!
364  directions(order(1)) = 0;
365 
366  for ( int i = 2; i <= hm; ++i ) {
367  float dot_prod =
368  centers(order(i),1) * centers(order(i-1),1) +
369  centers(order(i),2) * centers(order(i-1),2) +
370  centers(order(i),3) * centers(order(i-1),3);
371  if ( dot_prod < 0.0 ) {
372  int const dir1 = directions(order(i-1)) - 1;
373  directions(order(i)) = dir1 * dir1;
374  } else {
375  directions(order(i)) = directions(order(i-1));
376  }
377  }
378 
379 }
380 
381 ////////////////////////////////////////////////////////////////////////////////
382 /// @begin ingo_find_ord
383 ///
384 /// @brief
385 /// THIS PROGRAM FINDS THE ORDER OF THE STRANDS IN THE SHEETS
386 ///
387 /// @detailed
388 ///
389 /// @param shnm - [in/out]? -
390 /// @param hm - [in/out]? -
391 /// @param nstr - [in/out]? -
392 /// @param strlbl - [in/out]? -
393 /// @param dstrmin - [in/out]? -
394 /// @param ngbhct - [in/out]? -
395 /// @param order - [in/out]? -
396 /// @param sequence - [in/out]? -
397 /// @param slct - [in/out]? -
398 /// @param rubbish - [in/out]? -
399 ///
400 /// @global_read
401 ///
402 /// @global_write
403 ///
404 /// @remarks
405 ///
406 /// @references
407 ///
408 /// @authors
409 ///
410 /// @last_modified 11/26/01
411 /////////////////////////////////////////////////////////////////////////////////
412 void
413 SheetFilter::ingo_find_ord(
414  int shnm,
415  int hm,
416  int & nstr,
417  FArray1A_int strlbl,
418  FArray2A_float dstrmin,
419  float ngbhct,
420  FArray1A_int order,
421  FArray1A_int sequence,
422  FArray1A_int slct,
423  int & rubbish
424 ) const
425 {
426 
427  strlbl.dimension( nstr );
428  dstrmin.dimension( nstr, nstr );
429  order.dimension( hm );
430  sequence.dimension( hm );
431  slct.dimension( hm );
432 
433 //---- local:
434  int cnt,cnt1,cnt2,i,j,proper,token;
435  FArray1D_int nghbrs_cnt( max_nstr );
436  FArray1D_int taken( max_nstr );
437  FArray2D_float nghbrs( max_nstr, max_nstr );
438  FArray2D_float nghbrs_d( max_nstr, max_nstr );
439 //------------------------------------------------------------------------------
440 
441  cnt = 0;
442  for ( j = 1; j <= nstr; ++j ) {
443  if ( strlbl(j) == shnm ) {
444  ++cnt;
445  slct(cnt) = j;
446  }
447  }
448 
449 // std::cout << "slc " << slct << std::endl;
450 
451  for ( i = 1; i <= hm; ++i ) {
452  nghbrs_cnt(i) = 0;
453  taken(i) = 0;
454  for ( j = 1; j <= hm; ++j ) {
455  nghbrs_d(i,j) = dstrmin(slct(i),slct(j));
456  nghbrs(i,j) = 0;
457  if ( nghbrs_d(i,j) <= ngbhct ) {
458  nghbrs(i,j) = 1;
459  ++nghbrs_cnt(i);
460  }
461  }
462  }
463 
464  cnt1 = 0;
465  cnt2 = 0;
466  proper = 0;
467  for ( j = 1; j <= hm; ++j ) {
468  if ( nghbrs_cnt(j) == 1 ) {
469  ++cnt1;
470 
471  } else if ( nghbrs_cnt(j) == 2 ) {
472  ++cnt2;
473  }
474  }
475 
476  if ( cnt1 == 2 && cnt2 == hm-2 ) {
477  cnt = 0;
478  token = 0;
479  proper = 1;
480  while ( token == 0 ) {
481  ++cnt;
482  if ( nghbrs_cnt(cnt) == 1 ) token = 1;
483  }
484  order(1) = cnt;
485  taken(cnt) = 1;
486  while ( token < hm ) {
487  for ( j = 1; j <= hm; ++j ) {
488  if ( nghbrs(order(token),j) == 1 && taken(j) == 0 ) {
489  taken(j) = 1;
490  ++token;
491  order(token) = j;
492  }
493  }
494  }
495  token = 0;
496  while ( token < hm ) {
497  ++token;
498  for ( j = 1; j <= hm; ++j ) {
499  if ( order(j) == token ) sequence(token) = j;
500  }
501  }
502  }
503 
504 // std::cout << "ord" << std::endl;
505 // std::cout << order << std::endl;
506 // std::cout << sequence << std::endl;
507 
508  if ( proper != 1 ) rubbish = 7;
509 // addition to distinguish between barrel-types
510 //car a quick fix per ingo:
511 //car assigns the value 8 to the rubbish variable for all non-open sheets
512 //car (ie they don't have 2 strands with only one neighbour, and the other
513 //car strands all have 2).
514  if ( ( proper != 1 ) && ( hm > 4 ) ) rubbish = 8;
515 
516 }
517 
518 ////////////////////////////////////////////////////////////////////////////////
519 /// @begin ingo_hand
520 ///
521 /// @brief
522 /// THIS PROGRAM CHECKS THE HANDEDNESS OF A SHEET
523 ///
524 /// @detailed
525 ///
526 /// @param k - [in/out]? -
527 /// @param shnm - [in/out]? -
528 /// @param hm - [in/out]? -
529 /// @param stpppt - [in/out]? -
530 /// @param strtpt - [in/out]? -
531 /// @param str1 - [in/out]? -
532 /// @param str2 - [in/out]? -
533 /// @param order - [in/out]? -
534 /// @param strdr - [in/out]? -
535 /// @param nstr - [in/out]? -
536 /// @param nres - [in/out]? -
537 /// @param sequence - [in/out]? -
538 /// @param directions - [in/out]? -
539 /// @param scstr - [in/out]? -
540 /// @param lctn - [in/out]? -
541 /// @param rubbish - [in/out]? -
542 ///
543 /// @global_read
544 ///
545 /// @global_write
546 ///
547 /// @remarks
548 ///
549 /// @references
550 ///
551 /// @authors
552 ///
553 /// @last_modified 11/26/01
554 /////////////////////////////////////////////////////////////////////////////////
555 void
556 SheetFilter::ingo_hand(
557  int const k,
558  int const hm,
559  FArray1A_int stpppt,
560  FArray1A_int strtpt,
561  int const str1,
562  int const str2,
563  FArray1A_int order,
564  FArray2A_float strdr,
565  int const nstr,
566  int const nres,
567  FArray1A_int sequence,
568  FArray1A_int directions,
569  FArray1A_int scstr,
570  FArray2A_float lctn,
571  bool const use_whole_helix,
572  int & rubbish
573 ) const
574 {
575  stpppt.dimension( nstr );
576  strtpt.dimension( nstr );
577  order.dimension( hm );
578  strdr.dimension( nstr, 3 );
579  sequence.dimension( hm );
580  directions.dimension( hm );
581  scstr.dimension( nres );
582  lctn.dimension( nres, 3 );
583 
584 //---- local:
585  int cnt, /*hel_ib,*/ i, j, ll, str_ib;
586  float dot_prod;
587 // float dpr,ln1,ln2;
588  FArray1D_float midpoint( 3 );
589  FArray1D_float midpoint_loop( 3 );
590  FArray1D_float vector0( 3 );
591  FArray1D_float vector1( 3 );
592  FArray1D_float vector2( 3 );
593  FArray1D_float vector3( 3 );
594 //------------------------------------------------------------------------------
595 
596 
597 // - loop length between strands has to be at least 5 residues
598  ll = strtpt(str2) - stpppt(str1) - 1;
599 
600 
601  if ( ll < 5 ) return;
602 
603 // std::cout << ll << std::endl;
604 
605 
606 // - strands must be parallel
607 // std::cout << SS( shnm ) << SS( k ) << SS( directions(sequence(k-1)) ) <<
608 // SS( directions(sequence(k)) ) << SS( sequence(k-1) ) <<
609 // SS( sequence(k) ) << std::endl;
610 // if ( directions(sequence(k-1))/=directions(sequence(k)) ) return;
611  if ( directions(k-1) != directions(k) ) return;
612 
613 // if ( directions(order(k-1))/=directions(order(k)) ) return;
614 
615 // - straight dot-product between the two strands
616 // did not work well to define handedness
617 // goto L2222:
618 // dpr = strdr(str1,1)*strdr(str2,1)+strdr(str1,2)*strdr(str2,2)+
619 // strdr(str1,3)*strdr(str2,3);
620 // ln1 = std::sqrt(square( strdr(str1,1) )+square( strdr(str1,2) )+square( strdr(str1,3) ));
621 // ln2 = std::sqrt(square( strdr(str2,1) )+square( strdr(str2,2) )+square( strdr(str2,3) ));
622 // dpr /= (ln1*ln2);
623 // L2222:;
624 
625 // - check for helix or strands from other sheets in between strands
626 // must be consecutive strands
627  //hel_ib = 0; // js helix in between
628  str_ib = 0; // js strand in between
629  for ( j = stpppt(str1) + 1; j <= strtpt(str2) - 1; ++j ) {
630  //if ( scstr(j) == 1 ) hel_ib = 1; // set but never used ~Labonte
631  if ( scstr(j) == 2 ) str_ib = 1;
632  }
633  if ( str_ib == 1 ) return;
634 
635 //js finding position of the intervening segment
636 
637  if (!use_whole_helix) {
638  //default behavior is to just look at regions near strands ("takeoff" points)
639  for ( i = 1; i <= 3; ++i ) {
640  midpoint_loop(i) = 0.0;
641  cnt = 0;
642  for ( j = stpppt(str1) + 1; j <= stpppt(str1) + 3; ++j ) {
643  //js first 3 residues after first strand
644  midpoint_loop(i) += lctn(j,i);
645  ++cnt;
646  }
647  //js last 3 residues before the second strand
648  for ( j = strtpt(str2) - 3; j < strtpt(str2); ++j ) {
649  midpoint_loop(i) += lctn(j,i);
650  ++cnt;
651  }
652  midpoint_loop(i) /= cnt;
653  }
654  }else {
655  for ( i = 1; i <= 3; ++i ) {
656  midpoint_loop(i) = 0.0;
657  cnt = 0;
658  // Look at whole intervening loop (helix).
659  for ( j = stpppt(str1) + 1; j <= stpppt(str2) - 1; ++j ) {
660  midpoint_loop(i) += lctn(j,i);
661  ++cnt;
662  }
663  midpoint_loop(i) /= cnt;
664  }
665  }
666 
667  for ( i = 1; i <= 3; ++i ) {
668 //js last residue of the first strand,
669 //js first residue of the second strand
670  midpoint(i) = lctn(strtpt(str1),i) + lctn(strtpt(str2),i) +
671  lctn(stpppt(str1),i) + lctn(stpppt(str2),i);
672  midpoint(i) /= 4.0;
673 //js vector0 is the difference between the center of mass of
674 //js the CA postions of 3 residues at either end of the loop (midpoint_loop)
675 //js and the center of mass of the CA positions of the start and stop
676 //js residues of each strand.
677  vector0(i) = midpoint_loop(i)-midpoint(i);
678  }
679 
680  for ( i = 1; i <= 3; ++i ) {
681  vector1(i) = lctn(stpppt(str1),i) + lctn(stpppt(str2),i) -
682  lctn(strtpt(str1),i) - lctn(strtpt(str2),i);
683  vector1(i) /= 2.0;
684  vector2(i) = lctn(strtpt(str2),i) + lctn(stpppt(str2),i) -
685  lctn(strtpt(str1),i) - lctn(stpppt(str1),i);
686  vector2(i) /= 2.0;
687  }
688 
689  vector3(1) = vector2(2)*vector1(3)-vector2(3)*vector1(2);
690  vector3(2) = vector2(3)*vector1(1)-vector2(1)*vector1(3);
691  vector3(3) = vector2(1)*vector1(2)-vector2(2)*vector1(1);
692 
693  dot_prod = vector0(1)*vector3(1)+vector0(2)*vector3(2)+vector0(3)*vector3(3);
694 
695 // hand = 0;
696 // if ( dot_prod > 0 ) hand = 1;
697  if ( dot_prod < 0 ) rubbish = 6;
698 
699  if (dot_prod < 0 && use_whole_helix) {
700  rubbish = 9;
701  handedness_score_ += 0.1*std::fabs(dot_prod); // Arbitrary penalty for wrong handedness.
702  }
703 }
704 
705 ////////////////////////////////////////////////////////////////////////////////
706 /// @begin ingo_ident_sheets
707 ///
708 /// @brief
709 /// THIS PROGRAM IDENTIFIES THE SHEETS
710 ///
711 /// @detailed
712 ///
713 /// @param nres - [in/out]? -
714 /// @param nstr - [in/out]? -
715 /// @param dstrmin - [in/out]? -
716 /// @param ngbhct - [in/out]? -
717 /// @param strprs - [in/out]? -
718 /// @param nsht - [in/out]? -
719 /// @param strsht - [in/out]? -
720 /// @param strlbl - [in/out]? -
721 /// @param rubbish - [in/out]? -
722 ///
723 /// @global_read
724 ///
725 /// @global_write
726 ///
727 /// @remarks
728 ///
729 /// @references
730 ///
731 /// @authors
732 ///
733 /// @last_modified 11/26/01
734 /////////////////////////////////////////////////////////////////////////////////
735 void
736 SheetFilter::ingo_ident_sheets(
737  int & nstr,
738  FArray2A_float dstrmin,
739  float ngbhct,
740  FArray2A_int strprs,
741  int & nsht,
742  FArray1A_int strsht,
743  FArray1A_int strlbl,
744  int & rubbish
745 ) const
746 {
747 
748  dstrmin.dimension( nstr, nstr );
749  strprs.dimension( nstr, nstr );
750  strsht.dimension( nstr );
751  strlbl.dimension( nstr );
752 
753 //---- local:
754  int cnt,lb1,lb2,lbmn,memo,strsm,smm;
755  FArray1D_int fnlbl( max_nstr, 0 );
756  FArray1D_int fncnt( max_nstr, 0 );
757  FArray1D_int strlblord( nstr, 0 );
758 //------------------------------------------------------------------------------
759 
760  strprs = 0;
761 
762  for ( int i = 1; i <= nstr; ++i ) {
763  strlbl(i) = i;
764  for ( int j = 1; j <= nstr; ++j ) {
765  if ( dstrmin(i,j) < ngbhct ) strprs(i,j) = 1;
766  }
767  }
768 
769  rubbish = 0;
770  for ( int i = 1; i <= nstr; ++i ) {
771  smm = 0;
772  for ( int j = 1; j <= nstr; ++j ) {
773  smm += strprs(i,j);
774  }
775 //js commenting out filter number 2. It checks whether strands
776 //js have more than 3 neighbors. This should not be a filter,
777 //js because native proteins can have strands with 3 neighbors.
778 //js *Dimers* shouldn't be able to have more than 2 strands as
779 //js neighbors. That would require more work to fix. For now
780 //js we just comment out this filter.
781 //js if ( smm > 2 ) {
782 //js rubbish = 2;
783 //js goto L1234;
784 //js }
785  }
786 
787 
788 
789 // rubbish = 0
790 // for ( int i = 1; i <= nstr; ++i ) {
791 // if ( SUM(strprs(i,1:nstr)) > 2 ) {
792 // rubbish = 2;
793 // goto L1234;
794 // }
795 // }
796 
797  nsht = nstr;
798  for ( int j = 1; j <= nstr; ++j ) {
799  strsht(j) = 1;
800  }
801 
802  for ( int i = 1; i <= (nstr-1); ++i ) {
803  for ( int j = (i+1); j <= nstr; ++j ) {
804  if ( strprs(i,j) == 1 ) {
805  if ( strlbl(i) != strlbl(j) ) {
806  --nsht;
807  strsm = strsht(i)+strsht(j);
808  lb1 = strlbl(i);
809  lb2 = strlbl(j);
810  lbmn = std::min(strlbl(i),strlbl(j));
811  for ( int k = 1; k <= nstr; ++k ) {
812  if ( strlbl(k) == lb1 || strlbl(k) == lb2 ) {
813  strlbl(k) = lbmn;
814  strsht(k) = strsm;
815  }
816  }
817  }
818  }
819  }
820  }
821 
822 
823 // --- SORTING
824 
825  for ( int j = 1; j <= nstr; ++j ) {
826  fnlbl(j) = 0;
827  fncnt(j) = 0;
828  }
829  for ( int j = 1; j <= nstr; ++j ) {
830  fnlbl(strlbl(j)) = 1;
831  ++fncnt(strlbl(j));
832  }
833 
834  cnt = 0;
835  for ( int j = 1; j <= nstr; ++j ) {
836  strsht(j) = 0;
837  if ( fnlbl(j) == 1 ) {
838  ++cnt;
839  strsht(cnt) = fncnt(j);
840  }
841  }
842 
843  cnt = 0;
844  for ( int j = 1; j <= nstr; ++j ) {
845  strlblord(j) = 0;
846  }
847 
848  for ( int j = 1; j <= (nstr-1); ++j ) {
849  if ( (strlbl(j) > 0) && (strlblord(j) == 0) ) {
850  ++cnt;
851  strlblord(j) = cnt;
852  for ( int k = j+1; k <= nstr; ++k ) {
853  if ( strlbl(j) == strlbl(k) ) {
854  strlblord(k) = cnt;
855  }
856  }
857  }
858  }
859 
860  memo = 0;
861  if ( nsht > 1 ) {
862  cnt = 1;
863  while ( cnt < nsht ) {
864  for ( int j = 1; j <= nstr; ++j ) {
865  if ( strlbl(j) > cnt ) {
866  memo = strlbl(j);
867  goto L1212;
868  }
869  }
870 L1212:
871  ++cnt;
872  for ( int j = 1; j <= nstr; ++j ) {
873  if ( strlbl(j) == memo ) strlbl(j) = cnt;
874  }
875  }
876  }
877 
878 }
879 
880 ////////////////////////////////////////////////////////////////////////////////
881 /// @begin ingo_lnl
882 ///
883 /// @brief
884 /// THIS PROGRAM DETERMINES THE NUMBER OF LOCALS AND NONLOCAL
885 /// STRAND PAIRS
886 ///
887 /// @detailed
888 ///
889 /// @param hm - [in/out]? -
890 /// @param order - [in/out]? -
891 /// @param nloc - [in/out]? -
892 /// @param nnloc - [in/out]? -
893 ///
894 /// @global_read
895 ///
896 /// @global_write
897 ///
898 /// @remarks
899 ///
900 /// @references
901 ///
902 /// @authors
903 ///
904 /// @last_modified 11/26/01
905 /////////////////////////////////////////////////////////////////////////////////
906 void
907 SheetFilter::ingo_lnl(
908  int hm,
909  FArray1A_int order,
910  int & nloc,
911  int & nnloc
912 ) const
913 {
914  order.dimension( hm );
915 
916  for ( int i = 2; i <= hm; ++i ) {
917  if ( std::abs(order(i)-order(i-1)) > 1 ) {
918  ++nnloc;
919  } else {
920  ++nloc;
921  }
922  }
923 }
924 
925 ////////////////////////////////////////////////////////////////////////////////
926 /// @begin ingo_locations
927 ///
928 /// @brief
929 /// THIS FUNCTION DETERMINES THE CA LOCATION OF EACH RESIDUE
930 ///
931 /// @detailed
932 ///
933 /// @param nres - [in/out]? -
934 /// @param natm - [in/out]? -
935 /// @param indCA - [in/out]? -
936 /// @param atmps - [in/out]? -
937 /// @param lctn - [in/out]? -
938 ///
939 /// @global_read
940 ///
941 /// @global_write
942 ///
943 /// @remarks
944 ///
945 /// @references
946 ///
947 /// @authors
948 ///
949 /// @last_modified 11/26/00
950 /////////////////////////////////////////////////////////////////////////////////
951 void
952 SheetFilter::ingo_locations(
953  int const & nres,
954  int natm,
955  FArray1D_int & indCA,
956  FArray2D_float const & atmps,
957  FArray2A_float lctn
958 ) const
959 {
960  indCA.dimension( natm );
961 // atmps.dimension( 3, natm );
962  lctn.dimension( nres, 3 );
963 
964  int cnt = 0;
965  for ( int j = 1; j <= natm; ++j ) {
966  if ( indCA(j) == 1 ) {
967  ++cnt;
968  for ( int k = 1; k <= 3; ++k ) {
969  lctn(cnt,k) = atmps(k,j);
970  }
971  }
972  }
973 }
974 
975 ////////////////////////////////////////////////////////////////////////////////
976 /// @begin ingo_number_of_strands
977 ///
978 /// @brief
979 /// THIS FUNCTION COUNTS THE NUBER OF STRANDS IN THE
980 /// PROTEIN/DECOY
981 ///
982 /// @detailed
983 ///
984 /// @param nres - [in/out]? -
985 /// @param scstr - [in/out]? -
986 /// @param nstr - [in/out]? -
987 ///
988 /// @global_read
989 ///
990 /// @global_write
991 ///
992 /// @remarks
993 ///
994 /// @references
995 ///
996 /// @authors
997 ///
998 /// @last_modified 11/26/01
999 /////////////////////////////////////////////////////////////////////////////////
1000 void
1001 SheetFilter::ingo_number_of_strands(
1002  int const & nres,
1003  FArray1A_int scstr,
1004  int & nstr
1005 ) const
1006 {
1007  scstr.dimension( nres );
1008 
1009  nstr = 0;
1010  for ( int j = 1; j <= (nres-1); ++j ) {
1011  if ( scstr(j) == 2 && scstr(j+1) != 2 ) ++nstr;
1012  }
1013  if ( scstr(nres) == 2 ) ++nstr;
1014 
1015 }
1016 
1017 ////////////////////////////////////////////////////////////////////////////////
1018 /// @begin ingo_proper_sheets
1019 ///
1020 /// @brief
1021 /// THIS PROGRAM CHECKS THE CONFIGURATION OF THE STRANDS FROM
1022 /// THE SECONDARY STRUCTURE PREDICTION
1023 ///
1024 /// @detailed
1025 ///
1026 /// @param nstr - [in/out]? -
1027 /// @param nsht - [in/out]? -
1028 /// @param ngbhct - [in/out]? -
1029 /// @param dotcut - [in/out]? -
1030 /// @param dstrmin - [in/out]? -
1031 /// @param strdr - [in/out]? -
1032 /// @param strsht - [in/out]? -
1033 /// @param strlbl - [in/out]? -
1034 /// @param rubbish - [in/out]? -
1035 /// @param maxdist - [in/out]? -
1036 /// @param mindotprodabs - [in/out]? -
1037 /// @param strtpt - [in/out]? -
1038 /// @param stpppt - [in/out]? -
1039 /// @param locdsm - [in/out]? -
1040 /// @param lctn - [in/out]? -
1041 /// @param nres - [in/out]? -
1042 ///
1043 /// @global_read
1044 ///
1045 /// @global_write
1046 ///
1047 /// @remarks
1048 ///
1049 /// @references
1050 ///
1051 /// @authors
1052 ///
1053 /// @last_modified 11/26/01
1054 /////////////////////////////////////////////////////////////////////////////////
1055 void
1056 SheetFilter::ingo_proper_sheets(
1057  int & nstr,
1058  int & nsht,
1059  float ngbhct,
1060  FArray2A_float dstrmin,
1061  FArray2A_float strdr,
1062  FArray1A_int strsht,
1063  FArray1A_int strlbl,
1064  int & rubbish,
1065  float & maxdist,
1066  float & mindotprodabs,
1067  FArray1A_int strtpt,
1068  FArray1A_int stpppt,
1069  FArray2A_int locdsm,
1070  FArray2A_float lctn,
1071  int const & nres
1072 ) const
1073 {
1074  dstrmin.dimension( nstr, nstr );
1075  strdr.dimension( nstr, 3 );
1076  strsht.dimension( nstr );
1077  strlbl.dimension( nstr );
1078  strtpt.dimension( nstr );
1079  stpppt.dimension( nstr );
1080  locdsm.dimension( nstr, nstr );
1081  lctn.dimension( nres, 3 );
1082 
1083  float dot_prod, ln1, ln2;
1084  int pick1,pick2;
1085  FArray1D_float dir1( 3 );
1086  FArray1D_float dir2( 3 );
1087 
1088 //------------------------------------------------------------------------------
1089 
1090  rubbish = 0;
1091 
1092 // std::cout << SS( nstr ) << SS( nsht ) << std::endl;
1093  if ( nstr < 2 ) rubbish = 3;
1094 
1095 // std::cout << strsht(1:nsht) << std::endl;
1096 
1097  for ( int j = 1; j <= nsht; ++j ) {
1098  if ( strsht(j) < 2 ) rubbish = 4;
1099  }
1100 
1101  if ( rubbish == 0 ) {
1102  mindotprodabs = 1.0;
1103  maxdist = 0.0;
1104 
1105  for ( int i = 1; i <= nsht; ++i ) {
1106  int lbbl = i;
1107  for ( int j = 1; j <= (nstr-1); ++j ) {
1108  if ( strlbl(j) != lbbl ) goto L7777;
1109  if ( stpppt(j)-strtpt(j) < 6 ) goto L7777;
1110  for ( int k = (j+1); k <= nstr; ++k ) {
1111  if ( strlbl(k) != lbbl ) goto L8888;
1112  if ( stpppt(k)-strtpt(k) < 6 ) goto L8888;
1113  if ( dstrmin(j,k) < ngbhct ) {
1114  maxdist = std::max(dstrmin(j,k),maxdist);
1115  dot_prod = 0.0;
1116  for ( int l = 1; l <= 3; ++l ) {
1117 // std::cout << SS( locdsm(j,k) ) << SS( nres ) << std::endl;
1118 // std::cout << SS( locdsm(k,j) ) << SS( nres ) << std::endl;
1119  pick1 = locdsm(j,k);
1120  pick2 = locdsm(k,j);
1121  if ( locdsm(j,k) <= 3 ) pick1 = 4;
1122  if ( locdsm(j,k) >= nres-3 ) pick1 = nres-4;
1123  if ( locdsm(k,j) <= 3 ) pick2 = 4;
1124  if ( locdsm(k,j) >= nres-3 ) pick2 = nres-4;
1125  dir1(l) = lctn(pick1+3,l)-lctn(pick1-3,l);
1126  dir2(l) = lctn(pick2+3,l)-lctn(pick2-3,l);
1127  }
1128  dot_prod = dir1(1)*dir2(1) + dir1(2)*dir2(2) + dir1(3)*dir2(3);
1129  ln1 = std::sqrt(
1130  ( dir1(1) * dir1(1) ) +
1131  ( dir1(2) * dir1(2) ) +
1132  ( dir1(3) * dir1(3) ) );
1133  ln2 = std::sqrt(
1134  ( dir2(1) * dir2(1) ) +
1135  ( dir2(2) * dir2(2) ) +
1136  ( dir2(3) * dir2(3) ) );
1137  dot_prod /= (ln1*ln2);
1138  if ( std::abs(dot_prod) < mindotprodabs ) {
1139  mindotprodabs = std::abs(dot_prod);
1140  }
1141 // std::cout << SS( dot_prod ) << std::endl;
1142 // if ( dot_prod > -dotcut && dot_prod < dotcut ) rubbish = 5;
1143  }
1144 L8888:;
1145  }
1146 L7777:;
1147  }
1148  }
1149 
1150  }
1151 
1152 // std::cout << "rub " << rubbish << std::endl;
1153 
1154 }
1155 
1156 ////////////////////////////////////////////////////////////////////////////////
1157 /// @begin ingo_sheet_stuff
1158 ///
1159 /// @brief
1160 /// THIS FUNCTION SPITS OUT THE BETA SHEET INFORMATION
1161 ///
1162 /// @detailed
1163 ///
1164 /// @param nres - [in/out]? -
1165 /// @param scstr - [in/out]? -
1166 /// @param natm - [in/out]? -
1167 /// @param atmps - [in/out]? -
1168 /// @param indN - [in/out]? -
1169 /// @param indCA - [in/out]? -
1170 /// @param indC - [in/out]? -
1171 /// @param rnm - [in/out]? -
1172 /// @param ngbhct - [in/out]? -
1173 /// @param dotcut - [in/out]? -
1174 /// @param nstr - [in/out]? -
1175 /// @param nsht - [in/out]? -
1176 /// @param maxdt - [in/out]? -
1177 /// @param mindp - [in/out]? -
1178 /// @param nloc - [in/out]? -
1179 /// @param nnloc - [in/out]? -
1180 /// @param rubbish - [in/out]? -
1181 ///
1182 /// @global_read
1183 ///
1184 /// @global_write
1185 ///
1186 /// @remarks
1187 ///
1188 /// @references
1189 ///
1190 /// @authors
1191 ///
1192 /// @last_modified 11/23/01
1193 /////////////////////////////////////////////////////////////////////////////////
1194 void
1195 SheetFilter::ingo_sheet_stuff(
1196  int const & nres,
1197  FArray1A_int scstr,
1198  int natm,
1199  FArray2D_float const & atmps,
1200  FArray1D_int & indN,
1201  FArray1D_int & indCA,
1202  FArray1D_int & indC,
1203  FArray1D_int & rnm,
1204  float ngbhct,
1205  int & nstr,
1206  int & nsht,
1207  float & maxdt,
1208  float & mindp,
1209  int & nloc,
1210  int & nnloc,
1211  int & rubbish
1212 ) const
1213 {
1214  //using namespace param;
1215 
1216  scstr.dimension( nres );
1217 // atmps.dimension( 3, natm );
1218  indN.dimension( natm );
1219  indCA.dimension( natm );
1220  indC.dimension( natm );
1221  rnm.dimension( natm );
1222 
1223 //------------------------------------------------------------------------------
1224 // atmps array of atom positions
1225 // directions directions of the strands in a sheet
1226 // dotcut cutoff for minimum dotproduct in proper sheets
1227 // dstrmin matrix of (minimum diamer) distances of strands
1228 // ind* vector of indicators (0/1) for type of atom
1229 // inddm vector of indicators (0/1) for strand diamers
1230 // lctn array of residue (CA) positions
1231 // locdsm matrix of locations of (minimum diamer) distances of strands
1232 // maxdt maximum distance between two neighbour strands
1233 // mindp minimum dotproduct between two neighbour strands
1234 // natm number of atoms in the protein
1235 // ngbhct cutoff for strand distances that define neighbours
1236 // nloc number of local strand pairs (one sheet proteins only)
1237 // nmamac name of amino acid (single letter abbrev)
1238 // nmatom name of atom (standard abbrev)
1239 // nnloc number of non-local strand pairs (one sheet proteins only)
1240 // nres number of residues in the protein
1241 // nsht number of sheets in the protein
1242 // nstr number of strands in the protein
1243 // order order of the strands in a sheet
1244 // proper indicator sheet violations (1 no, 0 yes)
1245 // rnm vector of residue numbers of atoms
1246 // rubbish indicator (0 good structure; bigger 0 not)
1247 // scstr vector of secondary structure information
1248 // (1 helix, 2 strand, 3 turn)
1249 // slct array of strand numbers (in sequence) that are
1250 // involved in the sheet under consideration
1251 // sequence sequence of the strands in a sheet
1252 // stpppt vector of positions of strand ends
1253 // strdm array of diamer positions
1254 // strdr array of strand directions (3D)
1255 // strlbl labels of strands, indicating which sheet they belong to
1256 // strnm vector of strand number of residues
1257 // strprs matrix indicating which strands are neighbours (1 yes, 0 no)
1258 // strsht vector with numbers of strands in sheets
1259 // (is of length nstr for simplicity, but actually only the
1260 // first nsh integers are considered, rest is 0)
1261 // strtpt vector of positions of strand starts
1262 // indN vector of 0/1 for each atom in atmps 0=not N, 1=is N
1263 // indCA,indC like indN
1264 
1265 // rubbish filter indicator, note that if a structure fails at
1266 // one level, higher level filters are never evaluated
1267 //$$$ 0: passed
1268 //$$$ 1: no strands
1269 //$$$ 2: a strand with more than 2 neighbours
1270 //$$$ 3: a decoy with only one strand
1271 //$$$ 4: a one-stranded sheet
1272 //$$$ 5: bad dotproduct // no longer a possible result
1273 //$$$ 6: left handed connection between parallel neighbours
1274 //$$$ 7: barrel type sheet
1275 //------------------------------------------------------------------------------
1276 
1277  nstr = 0;
1278  nsht = 0;
1279  maxdt = 0;
1280  mindp = 0;
1281  rubbish = 0;
1282  nloc = 0;
1283  nnloc = 0;
1284 
1285  ingo_clean_ss(nres,scstr);
1286  ingo_number_of_strands(nres,scstr,nstr);
1287  if ( nstr == 0 ) {
1288  rubbish = 1;
1289  } else if ( nstr == 1 ) {
1290  rubbish = 3;
1291  } else {
1292  FArray1D_int inddm( nres, 0 );
1293  FArray1D_int strnm( nres, 0 );
1294  FArray1D_int directions( nstr );
1295  FArray1D_int order( nstr );
1296  FArray1D_int slct( nstr );
1297  FArray1D_int sequence( nstr );
1298  FArray1D_int strlbl( nstr, 0 );
1299  FArray1D_int strsht( nstr, 0 );
1300  FArray1D_int strtpt( nstr, 0 );
1301  FArray1D_int stpppt( nstr, 0 );
1302  FArray2D_int locdsm( nstr, nstr, 0 );
1303  FArray2D_int strprs( nstr, nstr, 0 );
1304  FArray2D_float dstrmin( nstr, nstr, 0.0 );
1305  FArray2D_float lctn( nres, 3, 0.0 );
1306  FArray2D_float strdm( nres, 3, 0.0 );
1307  FArray2D_float strdr( nstr, 3, 0.0 );
1308 
1309  ingo_start_stop(nres,scstr,nstr,strnm,strtpt,stpppt);
1310  ingo_diamers(nres,strnm,natm,atmps,rnm,indC,indN,strdm,inddm);
1311  ingo_locations(nres,natm,indCA,atmps,lctn);
1312  ingo_strand_dirs(nres,nstr,strtpt,stpppt,lctn,strdr);
1313  ingo_strand_dists_min(nres,nstr,inddm,strnm,strdm,dstrmin,locdsm);
1314  ingo_ident_sheets(nstr,dstrmin,ngbhct,strprs,nsht,strsht,strlbl,
1315  rubbish);
1316  //rhiju Rather than escape, want handedness to always be evaluated...
1317  //if ( rubbish > 0 ) goto L1234;
1318  ingo_proper_sheets(nstr,nsht,ngbhct,dstrmin,strdr,strsht,strlbl,
1319  rubbish,maxdt,mindp,strtpt,stpppt,locdsm,lctn,nres);
1320  //rhiju Rather than escape, want handedness to always be evaluated...
1321  //if ( rubbish > 0 ) goto L1234;
1322 
1323  for ( int j = 1; j <= nsht; ++j ) {
1324 //js possible bug causing spurious rejections of native structures with
1325 //js code 7: sends strsht (an array) but expects hm, an integer.
1326 //js logically it looks like it should be strsh(j), the number of strands
1327 //js in sheet j.
1328 //js I am adding index (j) to strsht:
1329  int const hm = strsht(j);
1330  for ( int k = 1; k <= hm; ++k ) {
1331  order(k) = 0;
1332  sequence(k) = 0;
1333  slct(k) = 0;
1334  directions(k) = 0;
1335  }
1336  ingo_find_ord(j,hm,nstr,strlbl,dstrmin,ngbhct,order,sequence,slct,
1337  rubbish);
1338  //rhiju ingo_find_ord doesn't assign strand order and directions if the sheet
1339  //rhiju forms a barrel. this might be worth fixing in the future, since we'd like to check
1340  //rhiju handedness of BAB's in the barrel.
1341  if ( rubbish > 6 ) goto L1234;
1342  ingo_lnl(hm,order,nloc,nnloc);
1343  ingo_find_dir(j,hm,nstr,slct,order,strlbl,strdr,directions);
1344  bool use_whole_helix (false);
1345  for ( int k = 2; k <= hm; ++k ) {
1346  ingo_hand(k,hm,stpppt,strtpt,slct(k-1),slct(k),order,strdr,
1347  nstr,nres,sequence,directions,scstr,lctn,use_whole_helix,rubbish);
1348  }
1349  // Following is new; slightly different computation of handedness, where
1350  // the whole body of the helix (rather than just the regions closest to
1351  // the strand takeoff points) is used to calculate beta-alpha-beta handedness.
1352  // For native PDBs, the usual definition is OK, but need a more robust definition
1353  // for Rosetta decoys (especially those encountered during jumping).
1354  use_whole_helix = true;
1355  for ( int k = 2; k <= hm; ++k ) {
1356  ingo_hand(k,hm,stpppt,strtpt,slct(k-1),slct(k),order,strdr,
1357  nstr,nres,sequence,directions,scstr,lctn,use_whole_helix,rubbish);
1358  }
1359  }
1360 L1234:;
1361  }
1362 
1363 }
1364 
1365 ////////////////////////////////////////////////////////////////////////////////
1366 /// @begin ingo_start_stop
1367 ///
1368 /// @brief
1369 /// THIS FUNCTION IDENTIFIES THE START AND END POINTS OF THE
1370 /// STRANDS
1371 ///
1372 /// @detailed
1373 ///
1374 /// @param nres - [in/out]? -
1375 /// @param scstr - [in/out]? -
1376 /// @param nstr - [in/out]? -
1377 /// @param strnm - [in/out]? -
1378 /// @param strtpt - [in/out]? -
1379 /// @param stpppt - [in/out]? -
1380 ///
1381 /// @global_read
1382 ///
1383 /// @global_write
1384 ///
1385 /// @remarks
1386 ///
1387 /// @references
1388 ///
1389 /// @authors
1390 ///
1391 /// @last_modified 11/26/01
1392 /////////////////////////////////////////////////////////////////////////////////
1393 void
1394 SheetFilter::ingo_start_stop(
1395  int const & nres,
1396  FArray1A_int scstr,
1397  int & nstr,
1398  FArray1A_int strnm,
1399  FArray1A_int strtpt,
1400  FArray1A_int stpppt
1401 ) const
1402 {
1403  scstr.dimension( nres );
1404  strnm.dimension( nres );
1405  strtpt.dimension( nstr );
1406  stpppt.dimension( nstr );
1407 
1408  int cnt = 0;
1409  int start = 0;
1410  int stopp = 0;
1411  if ( scstr(1) == 2 ) start = 1;
1412  int j = 0;
1413  while ( j < (nres-1) ) {
1414  ++j;
1415  strnm(j) = 0;
1416  if ( scstr(j) == 2 ) {
1417  if ( start == 0 ) start = j;
1418  strnm(j) = cnt+1;
1419  if ( scstr(j) != scstr(j+1) ) {
1420  ++cnt;
1421  stopp = j;
1422  strtpt(cnt) = start;
1423  stpppt(cnt) = stopp;
1424  start = 0;
1425  stopp = 0;
1426  }
1427  }
1428  }
1429 
1430  if ( scstr(nres) == 2 ) {
1431  ++cnt;
1432  strtpt(cnt) = start;
1433  stpppt(cnt) = nres;
1434  }
1435 }
1436 
1437 ////////////////////////////////////////////////////////////////////////////////
1438 /// @begin ingo_strand_dirs
1439 ///
1440 /// @brief
1441 /// THIS PROGRAM DETERMINES THE STRAND DIRECTIONS
1442 ///
1443 /// @detailed
1444 ///
1445 /// @param nres - [in/out]? -
1446 /// @param nstr - [in/out]? -
1447 /// @param strtpt - [in/out]? -
1448 /// @param stpppt - [in/out]? -
1449 /// @param lctn - [in/out]? -
1450 /// @param strdr - [in/out]? -
1451 ///
1452 /// @global_read
1453 ///
1454 /// @global_write
1455 ///
1456 /// @remarks
1457 ///
1458 /// @references
1459 ///
1460 /// @authors
1461 ///
1462 /// @last_modified 10/31/00
1463 /////////////////////////////////////////////////////////////////////////////////
1464 void
1465 SheetFilter::ingo_strand_dirs(
1466  int const & nres,
1467  int & nstr,
1468  FArray1A_int strtpt,
1469  FArray1A_int stpppt,
1470  FArray2A_float lctn,
1471  FArray2A_float strdr
1472 ) const
1473 {
1474  strtpt.dimension( nstr );
1475  stpppt.dimension( nstr );
1476  lctn.dimension( nres, 3 );
1477  strdr.dimension( nstr, 3 );
1478 
1479  for ( int i = 1; i <= nstr; ++i ) {
1480  for ( int j = 1; j <= 3; ++j ) {
1481  strdr(i,j) = lctn(stpppt(i),j)-lctn(strtpt(i),j);
1482  }
1483  }
1484 }
1485 
1486 ////////////////////////////////////////////////////////////////////////////////
1487 /// @begin ingo_strand_dists_min
1488 ///
1489 /// @brief
1490 /// THIS PROGRAM DETERMINES THE MINIMUM STRAND DISTANCES
1491 ///
1492 /// @detailed
1493 ///
1494 /// @param nres - [in/out]? -
1495 /// @param nstr - [in/out]? -
1496 /// @param inddm - [in/out]? -
1497 /// @param strnm - [in/out]? -
1498 /// @param strdm - [in/out]? -
1499 /// @param dstrmin - [in/out]? -
1500 /// @param locdsm - [in/out]? -
1501 ///
1502 /// @global_read
1503 ///
1504 /// @global_write
1505 ///
1506 /// @remarks
1507 ///
1508 /// @references
1509 ///
1510 /// @authors
1511 ///
1512 /// @last_modified 11/26/01
1513 /////////////////////////////////////////////////////////////////////////////////
1514 void
1515 SheetFilter::ingo_strand_dists_min(
1516  int const & nres,
1517  int & nstr,
1518  FArray1A_int inddm,
1519  FArray1A_int strnm,
1520  FArray2A_float strdm,
1521  FArray2A_float dstrmin,
1522  FArray2A_int locdsm
1523 ) const
1524 {
1525  inddm.dimension( nres );
1526  strnm.dimension( nres );
1527  strdm.dimension( nres, 3 );
1528  dstrmin.dimension( nstr, nstr );
1529  locdsm.dimension( nstr, nstr );
1530 
1531  for ( int i = 1; i <= nstr; ++i ) {
1532  for ( int j = 1; j <= nstr; ++j ) {
1533  locdsm(i,j) = 0;
1534  dstrmin(i,j) = 10000.0;
1535  }
1536  }
1537 
1538  for ( int i = 1; i <= nres; ++i ) {
1539  if ( inddm(i) > 0 ) {
1540  float const si1 = strdm(i,1);
1541  float const si2 = strdm(i,2);
1542  float const si3 = strdm(i,3);
1543  for ( int j = 1; j <= nres; ++j ) {
1544  if ( (inddm(j) > 0) && (strnm(j) != strnm(i)) ) {
1545  float const sd1 = si1 - strdm(j,1);
1546  float const sd2 = si2 - strdm(j,2);
1547  float const sd3 = si3 - strdm(j,3);
1548  float const dist =
1549  std::sqrt( ( sd1 * sd1 ) + ( sd2 * sd2 ) + ( sd3 * sd3 ) );
1550  if ( dist < dstrmin(strnm(i),strnm(j)) ) {
1551  dstrmin(strnm(i),strnm(j)) = dist;
1552  locdsm(strnm(i),strnm(j)) = i;
1553  locdsm(strnm(j),strnm(i)) = j;
1554  }
1555  }
1556  }
1557  }
1558  }
1559 
1560 // std::cout << std::endl;
1561 // for ( int i = 1; i <= nstr; ++i ) {
1562 // for ( int j = 1; j <= nstr; ++j ) {
1563 // std::cout << F( 9, 2, dstrmin(i,j) );
1564 // } std::cout << std::endl;
1565 // }
1566 // std::cout << std::endl;
1567 // for ( int i = 1; i <= nstr; ++i ) {
1568 // for ( int j = 1; j <= nstr; ++j ) {
1569 // std::cout << I( 5, locdsm(i,j) );
1570 // } std::cout << std::endl;
1571 // }
1572 // std::cout << std::endl;
1573 
1574 }
1575 
1576 ////////////////////////////////////////////////////////////////////////////////
1577 /// @begin ingo_clean_ss
1578 ///
1579 /// @brief
1580 /// THIS PROGRAM CLEANS THE SECONDARY STRUCTURE OF DECOYS
1581 ///
1582 /// @detailed
1583 ///car notes from ingo
1584 ///
1585 ///$$$ If I understand my notes
1586 ///$$$correctly, the big trouble makers were mostly the single strand residue
1587 ///$$$that popped up quite frequently. So they are cleaned up. Also, if a strand
1588 ///$$$is interrupted by one non-strand residue, that gets turned into a strand
1589 ///$$$residue too, so two short strands get turned into one long strand. That
1590 ///$$$worked the best, according to my notes.
1591 ///
1592 ///$$$The secstr cleanup doesn't contain one of the issues that David had
1593 ///$$$mentioned: if you have strands like that:
1594 ///$$$
1595 ///$$$ xxxxxxxx xxxxxxxx
1596 ///$$$ xxxxxxxxxxxxxxxxxx
1597 ///$$$
1598 ///$$$That is, there's a hole in one strand and it pops up as two strands,
1599 ///$$$paired up with another strand. A single residue missing gets cought by the
1600 ///$$$secstr cleaner, so I think most cases are taken care of in the beginning.
1601 ///$$$There should be something in there as well that catches two or three
1602 ///$$$residues missing. But that couldn't occur of course before you identified
1603 ///$$$sheets. I didn't see anything in the ident_sheets function (the most
1604 ///$$$obvious place where something like that could be).
1605 ///
1606 /// @param nres - [in/out]? -
1607 /// @param scstr - [in/out]? -
1608 ///
1609 /// @global_read
1610 ///
1611 /// @global_write
1612 ///
1613 /// @remarks
1614 ///
1615 /// @references
1616 ///
1617 /// @authors
1618 ///
1619 /// @last_modified 12/10/01
1620 /////////////////////////////////////////////////////////////////////////////////
1621 void
1622 SheetFilter::ingo_clean_ss(
1623  int const & nres,
1624  FArray1A_int scstr
1625 ) const
1626 {
1627  scstr.dimension( nres );
1628 
1629 // --- first and last residue strand check
1630  if ( scstr(nres) == 2 && scstr(nres-1) != 2 ) {
1631  scstr(nres) = 3;
1632  }
1633  if ( scstr(1) == 2 && scstr(2) != 2 ) {
1634  scstr(1) = 3;
1635  }
1636 
1637 // --- single residue strand checks
1638  for ( int j = 2; j <= (nres-1); ++j ) {
1639  if ( scstr(j-1) == 2 && scstr(j) != 2 && scstr(j+1) == 2 ) {
1640  scstr(j) = 2;
1641  }
1642  }
1643  for ( int j = 2; j <= (nres-1); ++j ) {
1644  if ( scstr(j-1) != 2 && scstr(j) == 2 && scstr(j+1) != 2 ) {
1645  scstr(j) = scstr(j-1);
1646  }
1647  }
1648 }
1649 
1650 } // filters
1651 } // protocols