Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RandomSheetBuilder.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
11 /// @brief secondary structure will hold statistics about secondary structure predictions
12 /// sources can be from
13 /// - fragments
14 /// - psipred files ? other stuff
15 ///
16 /// @detailed
17 /// from converting jumping_pairings.cc of rosetta++ into mini
18 ///
19 ///
20 ///
21 /// @author Oliver Lange
22 
23 
24 // Unit Headers
27 
28 // Package Headers
29 //#include <protocols/jumping/SecondaryStructure.hh>
30 //#include <protocols/jumping/SameStrand.hh>
31 //#include <core/scoring/dssp/PairingsList.hh>
32 
33 // Project Headers
34 #include <core/types.hh>
35 
36 //#include <core/kinematics/FoldTree.hh>
37 
38 
39 // Utility headers
40 #include <basic/Tracer.hh>
41 //#include <utility/io/izstream.hh>
42 #include <utility/io/util.hh>
43 
44 // ObjexxFCL Headers
45 //#include <ObjexxFCL/FArray1D.hh>
46 //#include <ObjexxFCL/FArray1A.hh>
47 //#include <ObjexxFCL/FArray2A.hh>
48 //#include <ObjexxFCL/FArray3D.hh>
49 
50 //#include <ObjexxFCL/StaticIndexRange.hh>
51 
52 //#include <ObjexxFCL/format.hh>
53 
54 // numeric headers
55 #include <numeric/random/random.hh>
56 #include <numeric/random/random_permutation.hh>
57 //#include <numeric/numeric.functions.hh>
58 
59 //// C++ headers
60 #include <cstdlib>
61 
63 #include <utility/vector0.hh>
64 #include <utility/vector1.hh>
65 
66 //#include <string>
67 //#include <vector>
68 
69 
70 static basic::Tracer tr("protocols.jumping");
71 static numeric::random::RandomGenerator RG(1422934); // <- Magic number, do not change
72 
73 namespace protocols {
74 namespace jumping {
75 
76 using namespace ObjexxFCL;
77 using namespace core;
78 
79 
80 //////////////////////////////////////////////////////////////////////////////
81 //////////////////////////////////////////////////////////////////////////////
82 // NOTES ( old comment copied from jumping_pairings )
83 //
84 ////////////////////////
85 // PAIRINGS FILE FORMAT:
86 //
87 // one line per pairing, 4 numbers per line, white-space delimited
88 //
89 // format: "pos1 pos2 orientation pleating"
90 //
91 // pos1 and pos2 are the sequence numbers of the beta-paired positions
92 //
93 // orientation is the beta-strand orientation:
94 // "1" for antiparallel, "2" for parallel
95 // or just "A" or "P"
96 //
97 // pleating determines the pleat of the beta-carbons
98 // "1" if the N and O of pos1 are pointed away from pos2
99 // "2" if the N and O of pos1 are pointed toward pos2
100 //
101 // eg, in the antiparallel case, a pleat of 2 would mean that
102 // there are two backbone-backbone hydrogen bonds between pos1 and pos2
103 // In the parallel case a pleat of 2 means that pos1 is Hbonding with
104 // pos2-1 and pos2+1
105 //
106 // if you check out rosetta_benchmarks, in the directory 1d3z/
107 // is a pairing file "pairings.dat" with two pairings in it.
108 // These are native pairings, ie they match the pdb structure
109 // 1d3z.pdb in the same directory. In Fortran you had to tell
110 // Rosetta how many pairings to expect; that's why the first line
111 // has a "2" on it. This is no longer necessary.
112 
113 //////////////////////
114 // COMMAND LINE SYNTAX
115 //
116 // for ab initio folding with pairings: the usual "xx 1xyz _ -silent"
117 // plus:
118 //
119 // -pairing_file <pairings-file>
120 //
121 // with no other arguments and it will try to build decoys with
122 // *all* the pairings in the file. You can also specify what
123 // kind of sheet topology Rosetta should try to construct:
124 //
125 // -sheet1 <N1> -sheet2 <N2> ... -sheetk <Nk>
126 //
127 // Here Nj is the number of strands in sheet number j. So the
128 // number of forced pairings will be (Nj-1). The sheet can
129 // get other strands during the folding simulation -- this is
130 // just specifying how many Rosetta should actual build from
131 // the start using the broken chain stuff.
132 //
133 // So the total number of forced pairings will be:
134 // N1-1 + N2-1 + N3-1 + ... + Nk-1
135 //
136 // For example, to specify two strand pairings in two different
137 // sheets, use the args "-sheet1 2 -sheet2 2"
138 //
139 //
140 //////////////////////////////////////////////////////////////////////////////
141 //////////////////////////////////////////////////////////////////////////////
142 //////////////////////////////////////////////////////////////////////////////
143 
144 
146  SheetBuilder( ss, pairings, sheet_topol ),
147  input_sheet_sizes_( sheet_topol )
148 {
149  //...
150 }
151 
152 
153 //default do nothing always use input_sheet_sizes_ as sheet_sizes_.
155 {
156  Size num_sheets = std::max( 1, static_cast< int >( RG.uniform() * (input_sheet_sizes_.size() + 1) ) );
157  tr.Debug << "random choice: num_sheets: " << num_sheets << std::endl;
158 
159  // generate random sequence from 1 .. N
160  utility::vector1< Size > strand_ids;
161  for ( Size i = 1; i <= input_sheet_sizes_.size(); i ++ ) {
162  strand_ids.push_back( i );
163  }
164 
165  numeric::random::random_permutation( strand_ids, RG );
166  numeric::random::random_permutation( strand_ids, RG ); //want it really random
167 
168  tr.Debug << "strand_ids.size(): "
169  << strand_ids.size() << " ";
170  utility::io::write_vector( tr.Debug, strand_ids );
171  tr.Debug << std::endl;
172 
173  SheetTopology new_sheet_sizes;
174  Size trials = 20;
175  while ( new_sheet_sizes.size() < num_sheets && trials-- > 0 ) {
176  for ( Size i = 1; i<=strand_ids.size() && new_sheet_sizes.size()<num_sheets; i++ ) {
177  int nr( static_cast< int >( RG.uniform() * input_sheet_sizes_[ strand_ids[ i ] ] ) + 1 );
178  if ( nr > 0 ) {
179  new_sheet_sizes.push_back( nr );
180  }
181  }
182  }
183 
184  tr.Debug << "chosen sheet parameters: ";
185  utility::io::write_vector( tr.Debug, new_sheet_sizes );
186  tr.Debug << std::endl;
187 
188  return new_sheet_sizes;
189 }
190 
191 } //protocols
192 } //jumping