10 #ifndef INCLUDED_protocols_frags_RMSVallData_hh
11 #define INCLUDED_protocols_frags_RMSVallData_hh
24 #include <utility/vector1.hh>
27 #include <ObjexxFCL/FArray1A.hh>
28 #include <utility/io/izstream.hh>
30 #include <numeric/model_quality/rms.hh>
31 #include <numeric/random/random.fwd.hh>
32 #include <utility/exit.hh>
38 namespace ObjexxFCL { }
using namespace ObjexxFCL;
53 Size const big_size( 100000 );
54 sequence_.reserve( big_size );
55 secstruct_.reserve( big_size );
56 phi_.reserve( big_size );
57 psi_.reserve( big_size );
58 omega_.reserve( big_size );
61 exclude_cys_peptides =
false;
67 Size const big_size( 100000 );
69 sequence_.reserve( big_size );
70 secstruct_.reserve( big_size );
71 phi_.reserve( big_size );
72 psi_.reserve( big_size );
73 omega_.reserve( big_size );
76 exclude_cys_peptides =
false;
78 read_file( filename );
95 utility::io::izstream data ( filename );
97 utility_exit_with_message(
"cant open vall file: " + filename );
103 bool const new_format( filename.find(
"trimmed" ) != std::string::npos );
106 std::cerr <<
"Unsupported format for RMSVallData!!!\n";
113 data.getline( line, 250 );
114 if ( data.eof() )
break;
116 std::sscanf( line+6 ,
"%1c", &seq);
117 std::sscanf( line+8 ,
"%1c", &ss);
119 std::sscanf( line+25 ,
"%9f", &x);
120 std::sscanf( line+34 ,
"%9f", &y);
121 std::sscanf( line+43 ,
"%9f", &z);
123 std::sscanf( line+52,
"%9f", &phi);
124 std::sscanf( line+61,
"%9f", &psi);
125 std::sscanf( line+70,
"%9f", &omega);
127 add_line( seq, ss, x, y, z, phi, psi, omega );
142 sequence_.push_back( sq );
143 secstruct_.push_back( ss );
147 phi_.push_back( ph );
148 psi_.push_back( ps );
149 omega_.push_back( om );
162 int size()
const {
return sequence_.size(); }
175 Size const frag_size( templ.size() );
176 assert( frag_size == pref_seq.length() );
180 Size bucket1_size( (
Size)std::ceil(oversample*nfrags) );
181 if (oversample<=0) { bucket1_size = my_size - frag_size + 1; }
182 FArray1D_int heap( bucket1_size + 2 );
183 FArray1D_float coheap( bucket1_size + 2 );
187 ObjexxFCL::FArray2D< core::Real > tmpl_pos( 3,frag_size ), tgt_pos( 3,frag_size );
189 for (
int i = 1; i <= (
int)frag_size; ++i ) {
192 for (
int k = 0; k < 3; ++k ) tmpl_pos(k+1,i) = x_i[k];
194 tmpl_com /= frag_size;
195 for (
int i=1; i<=(
int)frag_size; ++i)
196 for (
int k = 0; k < 3; ++k ) tmpl_pos(k+1,i) -= tmpl_com[k];
199 ObjexxFCL::FArray1D< numeric::Real > ww( frag_size, 1.0 );
203 for (
Size vall_pos=1; vall_pos <= my_size - frag_size + 1; ++vall_pos ) {
206 bool bad_frag(
false );
212 for (
Size k=0; k< frag_size; ++k ) {
213 Real const phi ( phi_ [ vall_pos+k ] );
214 Real const psi ( psi_ [ vall_pos+k ] );
215 Real const omega( omega_ [ vall_pos+k ] );
216 char const seq ( sequence_ [ vall_pos+k ] );
217 char const ss ( secstruct_[ vall_pos+k ] );
218 if ( ( std::abs( phi ) < 0.01 ) ||
219 ( std::abs( psi ) + std::abs( omega ) < 0.01 ) ||
220 ( seq ==
'G' && exclude_gly ) ||
221 ( seq ==
'P' && exclude_pro ) ||
222 ( std::abs( omega ) < 90.0 && exclude_cys_peptides ) ||
223 ( ss != force_ss && (force_ss ==
'H' || force_ss ==
'E' || force_ss ==
'L') ) ) {
228 if ( seq != pref_seq[k] ) seq_score++;
232 for (
int j = 0; j < 3; ++j ) tgt_pos(j+1,k+1) = xx[j];
235 if ( bad_frag )
continue;
238 tgt_com /= frag_size;
239 for (
int i=1; i<=(
int)frag_size; ++i)
240 for (
int j = 0; j < 3; ++j ) tgt_pos(j+1,i) -= tgt_com[j];
255 FArray1D_int rmsheap( nfrags + 2 );
256 FArray1D_float rmscoheap( nfrags + 2 );
259 Size exact_matches(0);
260 Real worst_score(999), best_score(999);
262 for (
Size nn = bucket1_size; nn >=1; --nn ) {
270 if ( score == 0 ) ++exact_matches;
274 for (
Size k=0; k< frag_size; ++k ) {
277 for (
int j = 0; j < 3; ++j ) tgt_pos(j+1,k+1) = xx[j];
281 tgt_com /= frag_size;
282 for (
int i=1; i<=(
int)frag_size; ++i)
283 for (
int j = 0; j < 3; ++j ) tgt_pos(j+1,i) -= tgt_com[j];
287 rms_out = numeric::model_quality::rms_wrapper( frag_size, tgt_pos, tmpl_pos);
290 rms_out += randomness * numeric::random::uniform();
297 for (
Size nn = nfrags; nn >=1; --nn ) {
305 if ( nn == nfrags ) worst_score = -score;
306 else if ( nn == 1 ) best_score = -score;
309 for (
Size k=0; k< frag_size; ++k ) {
312 res_torsions->set_torsion ( 1, phi_ [ vall_pos + k ] );
313 res_torsions->set_torsion ( 2, psi_ [ vall_pos + k ] );
314 res_torsions->set_torsion ( 3, omega_ [ vall_pos + k ] );
315 res_torsions->set_secstruct ( secstruct_[ vall_pos + k ] );
316 current_fragment->add_residue( res_torsions );
320 if (current_fragment->size() == frag_size) current_fragment->set_valid();
323 if ( !frame->add_fragment( current_fragment ) ) {
324 std::cerr <<
"Incompatible fragment!" << std::endl;
325 utility::exit( EXIT_FAILURE, __FILE__, __LINE__);
330 std::cerr <<
"rms-frags: " <<
331 nfrags <<
" of " << bucket1_size <<
332 " exact_matches: " << exact_matches <<
333 " best_score: " << best_score <<
334 " worst_score: " << worst_score << std::endl;