Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EnzdesLoopsFile.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 protocols/toolbox/match_enzdes_util/EnzdesLoopsFile.cc
11 ///
12 /// @brief
13 /// @author Florian Richter, floric@u.washington.edu, april 2009
14 
15 
16 
18 
20 
21 #include <basic/Tracer.hh>
22 
23 #include <utility/exit.hh>
24 #include <utility/string_util.hh>
25 #include <utility/io/izstream.hh>
26 #include <utility/LexicographicalIterator.hh>
27 
28 #include <sstream>
29 
30 #include <utility/vector1.hh>
31 
32 
33 
34 static basic::Tracer tr("protocols.enzdes.EnzdesLoopsFile");
35 
36 namespace protocols {
37 namespace toolbox {
38 namespace match_enzdes_util {
39 
40 /// @details Auto-generated virtual destructor
42 
43 /// @details Auto-generated virtual destructor
45 
46 
48  targ_res_(0), num_interactions_(1),
49  dis_(NULL), loop_ang_(NULL), targ_ang_(NULL),
50  loop_dih_(NULL), targ_dih_(NULL), lt_dih_(NULL)
51 {
52  targ_atom_names_.push_back( "CA" );
53  loopres_atom_names_.push_back( "CA" );
54 }
55 
57 
58 /// @details returns false if the file fails to specify the target residue number
59 bool
60 ResInteractions::read_data( utility::io::izstream & data )
61 {
62 
64  tokens.push_back("");
65 
66  bool block_end(false);
67 
68  while( !block_end ){
69 
70  if( data.eof() ){
71  tr << "Error: end of file reached before RES_CONTACT_END tag was found." << std::endl;
72  return false;
73  }
74 
75  std::string line;
76  getline( data, line );
77 
78  tokens.clear(); tokens.push_back(""); //weird utilvec1 copy behaviour makes this necessary
79 
80  tokens = utility::split( line );
81 
82  if( tokens.size() < 1 ) continue;
83 
84  if( tokens[1] == "RES_CONTACT_END" ){
85  block_end = true;
86  }
87 
88  else if( !process_input_line_tokens( tokens ) ) return false;
89 
90  } //file reading
91 
92  if( targ_res_ == 0 ) return false;
93 
94  return true;
95 }
96 
97 void
99 
100  tr << "target_res " << targ_res_ << std::endl;
101  tr << "num_contacts " << num_interactions_ << std::endl;
102  //tr << "distance " << dist_ << std::endl;
103  //tr << "tolerance " << tolerance_ << std::endl;
104 
105  tr << "targ_atom_names ";
106  for( core::Size i = 1; i <= targ_atom_names_.size(); ++i ) tr << targ_atom_names_[i] << " ";
107  tr << std::endl;
108 
109  tr << "loopres_atom_names ";
110  for( core::Size i = 1; i <= loopres_atom_names_.size(); ++i ) tr << loopres_atom_names_[i] << " ";
111  tr << std::endl;
112 
113 }
114 
117  return dis_; }
118 
121  return loop_ang_; }
122 
125  return targ_ang_; }
126 
129  return loop_dih_; }
130 
133  return targ_dih_; }
134 
137  return lt_dih_; }
138 
139 bool
141  utility::vector1< std::string > const & tokens )
142 {
143  using namespace toolbox::match_enzdes_util;
144 
145  bool to_return(false);
146  core::Real const generic_force_K(100.0);
147  core::Real const generic_period(360.0);
148 
149  if( ( tokens.size() < 2 ) || (tokens[2] == "" ) ){
150  tr << "Error when processing res_interactions block. Line containing " << tokens[1] << " seems to have no useable data." << std::endl;
151 
152  return false;
153  }
154 
155  if( tokens[1] == "target_res" ){
156  targ_res_ = (core::Size) atoi( tokens[2].c_str() );
157  to_return = true;
158  }
159  else if( tokens[1] == "num_contacts" ){
160  num_interactions_ = (core::Size) atoi( tokens[2].c_str() );
161  to_return = true;
162  }
163  //else if( tokens[1] == "distance" ){
164  // dist_ = (core::Real) atof( tokens[2].c_str() );
165  // to_return = true;
166  //}
167  //else if( tokens[1] == "tolerance" ) {
168  // tolerance_ = (core::Real) atof( tokens[2].c_str() );
169  // to_return = true;
170  //}
171  else if( tokens[1] == "targ_atom_names" ){
172  targ_atom_names_.clear();
173  for( core::Size i = 2; i <= tokens.size(); ++i ) targ_atom_names_.push_back( tokens[ i ] );
174  to_return = true;
175  }
176  else if( tokens[1] == "targ_base_atom_names" ){
177  targ_base_atom_names_.clear();
178  for( core::Size i = 2; i <= tokens.size(); ++i ) targ_base_atom_names_.push_back( tokens[ i ] );
179  to_return = true;
180  }
181  else if( tokens[1] == "targ_base2_atom_names" ){
182  targ_base2_atom_names_.clear();
183  for( core::Size i = 2; i <= tokens.size(); ++i ) targ_base2_atom_names_.push_back( tokens[ i ] );
184  to_return = true;
185  }
186  else if( tokens[1] == "loopres_atom_names" ){
187  loopres_atom_names_.clear();
188  for( core::Size i = 2; i <= tokens.size(); ++i ) loopres_atom_names_.push_back( tokens[ i ] );
189  to_return = true;
190  }
191  else if( tokens[1] == "loopres_base_atom_names" ){
192  loopres_base_atom_names_.clear();
193  for( core::Size i = 2; i <= tokens.size(); ++i ) loopres_base_atom_names_.push_back( tokens[ i ] );
194  to_return = true;
195  }
196  else if( tokens[1] == "loopres_base2_atom_names" ){
198  for( core::Size i = 2; i <= tokens.size(); ++i ) loopres_base2_atom_names_.push_back( tokens[ i ] );
199  to_return = true;
200  }
201  else if( tokens[1] == "distance" ){
202  if( tokens.size() < 3 ){ tr << "too little information given for distance_LT." << std::endl;
203  return false;
204  }
205  if( tokens.size() == 3 ) dis_ = new GeomSampleInfo( atof( tokens[2].c_str() ), atof( tokens[3].c_str() ), generic_force_K, 0.0 );
206  else dis_ = new GeomSampleInfo( atof( tokens[2].c_str() ), atof( tokens[3].c_str() ), atof( tokens[4].c_str() ), 0.0 );
207  to_return = true;
208  }
209  else if( tokens[1] == "angle_loop" ){
210  if( tokens.size() < 3 ){ tr << "too little information given for angle_loop." << std::endl;
211  return false;
212  }
213  if( tokens.size() == 3 ) loop_ang_ = new GeomSampleInfo( atof( tokens[2].c_str() ), atof( tokens[3].c_str() ), generic_force_K, generic_period );
214  else loop_ang_ = new GeomSampleInfo( atof( tokens[2].c_str() ), atof( tokens[3].c_str() ), atof( tokens[4].c_str() ), generic_period );
215  to_return = true;
216  }
217  else if( tokens[1] == "angle_targ" ){
218  if( tokens.size() < 3 ){ tr << "too little information given for angle_targ." << std::endl;
219  return false;
220  }
221  if( tokens.size() == 3 ) targ_ang_ = new GeomSampleInfo( atof( tokens[2].c_str() ), atof( tokens[3].c_str() ), generic_force_K, generic_period );
222  else targ_ang_ = new GeomSampleInfo( atof( tokens[2].c_str() ), atof( tokens[3].c_str() ), atof( tokens[4].c_str() ), generic_period );
223  to_return = true;
224  }
225  else if( tokens[1] == "dih_loop" ){
226  if( tokens.size() < 3 ){ tr << "too little information given for dih_loop." << std::endl;
227  return false;
228  }
229  if( tokens.size() == 3 ) loop_dih_ = new GeomSampleInfo( atof( tokens[2].c_str() ), atof( tokens[3].c_str() ), generic_force_K, generic_period );
230  else if( tokens.size() == 4 ) loop_dih_ = new GeomSampleInfo( atof( tokens[2].c_str() ), atof( tokens[3].c_str() ), atof( tokens[4].c_str() ), generic_period );
231  else loop_dih_ = new GeomSampleInfo( atof( tokens[2].c_str() ), atof( tokens[3].c_str() ), atof( tokens[4].c_str() ), atof( tokens[5].c_str() ) );
232  to_return = true;
233  }
234  else if( tokens[1] == "dih_targ" ){
235  if( tokens.size() < 3 ){ tr << "too little information given for dih_loop." << std::endl;
236  return false;
237  }
238  if( tokens.size() == 3 ) targ_dih_ = new GeomSampleInfo( atof( tokens[2].c_str() ), atof( tokens[3].c_str() ), generic_force_K, generic_period );
239  else if( tokens.size() == 4 ) targ_dih_ = new GeomSampleInfo( atof( tokens[2].c_str() ), atof( tokens[3].c_str() ), atof( tokens[4].c_str() ), generic_period );
240  else targ_dih_ = new GeomSampleInfo( atof( tokens[2].c_str() ), atof( tokens[3].c_str() ), atof( tokens[4].c_str() ), atof( tokens[5].c_str() ) );
241  to_return = true;
242  }
243  else if( tokens[1] == "dih_LT" ){
244  if( tokens.size() < 3 ){ tr << "too little information given for dih_loop." << std::endl;
245  return false;
246  }
247  if( tokens.size() == 3 ) lt_dih_ = new GeomSampleInfo( atof( tokens[2].c_str() ), atof( tokens[3].c_str() ), generic_force_K, generic_period );
248  else if( tokens.size() == 4 ) lt_dih_ = new GeomSampleInfo( atof( tokens[2].c_str() ), atof( tokens[3].c_str() ), atof( tokens[4].c_str() ), generic_period );
249  else lt_dih_ = new GeomSampleInfo( atof( tokens[2].c_str() ), atof( tokens[3].c_str() ), atof( tokens[4].c_str() ), atof( tokens[5].c_str() ) );
250  to_return = true;
251  }
252 
253 
254  if( !to_return ) tr << "Unspecified error when processing res_interactions block line containing " << tokens[1] << std::endl;
255 
256  return to_return;
257 }
258 
260  ResInteractions(),
261  resA_(false), cst_block_(0)
262 {}
263 
264 
265 bool
266 CstResInteractions::read_data( utility::io::izstream & data )
267 {
268 
270  tokens.push_back("");
271 
272  bool cst_line_encountered(false), block_end(false);
273 
274  while( !block_end ){
275 
276  //std::cerr << "reading CstResInp, token[1] is: '" << tokens[1] << "'" << std::endl;
277  if( data.eof() ){
278  tr << "Error: end of file reached before CST_TARGET_END tag was found." << std::endl;
279  this->write_data();
280  return false;
281  }
282 
283  std::string line;
284  getline( data, line );
285 
286  //std::cerr << "reading CstResInteractions, line: " << line << std::endl;
287  tokens.clear(); tokens.push_back(""); //weird utilvec1 copy behaviour makes this necessary
288 
289  tokens = utility::split( line );
290 
291  if( tokens.size() < 1 ) continue;
292 
293  if( tokens[1] == "CST_TARGET_END" ){
294  block_end = true;
295  }
296 
297  else if( tokens[1] == "cst_target" ){
298 
299  cst_block_ = (core::Size ) atoi( tokens[2].c_str() );
300 
301  if( tokens[3] == "A" ) resA_ = true;
302  else if( tokens[3] == "B" ) resA_ = false;
303  else{
304  tr << "When specifing a cst_target line, the 3rd element has to be either A or B, corresponding to which of the two residues in the cstfile is desired." << std::endl;
305  return false;
306  }
307 
308  cst_line_encountered = true;
309 
310  } //if cst_target
311 
312  else if( !process_input_line_tokens( tokens ) ) return false;
313 
314  } //file reading
315  //std::cerr << "reading CstResInp after while, token[1] is: '" << tokens[1] << "'" << std::endl;
316 
317  if( !cst_line_encountered ){
318  tr << "Did not find 'cst_target' line in CST block." << std::endl;
319  return false;
320  }
321 
322  if( this->targ_res() != 0 ){
323 
324  tr << "An explicit residue number has been specified in a CST_TARGET block" << std::endl;
325  return false;
326  }
327 
328  return true;
329 }
330 
331 void
333 
335 
336  tr << "cst_target " << cst_block_ << " ";
337 
338  if( resA_ ) tr << "A";
339  else tr << "B";
340 
341  tr << std::endl;
342 }
343 
345  loop_start_(0), loop_end_(0),
346  loop_start_pdb_(0), loop_end_pdb_(0),
347  loop_start_pdb_chain_(' '), loop_end_pdb_chain_(' '),
348  pose_numb_(false), pdb_numb_(false),
349  min_length_(0), max_length_(0),
350  preserve_buried_contacts_(false), contact_buried_problematic_res_(false)
351 {
352  ss_strings_.clear();
353  res_interactions_.clear();
354  cstres_interactions_.clear();
355 }
356 
357 bool
359  utility::io::izstream & data
360 ){
361 
362  ss_strings_.clear();
363  res_interactions_.clear();
364  cstres_interactions_.clear();
365  core::Size linenum(0);
366 
368  tokens.push_back("");
369 
370  bool loop_end( false );
371 
372  bool min_length_tag_found(false), max_length_tag_found(false);
373 
374  utility::vector1< std::string > ss_blueprints;
375 
376  while( !loop_end ){
377 
378  if( data.eof() ){
379  tr << "Error: end of file reached before LOOP_END tag was found." << std::endl;
380  return false;
381  }
382  linenum++;
383 
384  std::string line;
385  getline( data, line );
386 
387  tokens.clear(); tokens.push_back(""); //weird utilvec1 copy behaviour makes this necessary
388 
389  tokens = utility::split( line );
390 
391  if( tokens.size() < 1 ) continue;
392 
393  //std::cerr << "eli line is '" << line << "' , tokens[1] is '" << tokens[1] << "'" << std::endl;
394 
395  if( tokens[1] == "LOOP_END" ) loop_end = true;
396 
397  else if( tokens[1] == "start" ) {
398 
399  loop_start_ = (core::Size) atoi( tokens[2].c_str() );
400  pose_numb_ = true;
401 
402  } else if( tokens[1] == "stop" ) {
403 
404  loop_end_ = (core::Size) atoi( tokens[2].c_str() );
405  pose_numb_ = true;
406 
407  } else if( tokens[1] == "pdb_start" ) {
408 
409  loop_start_pdb_chain_ = tokens[2][0];
410  loop_start_pdb_ = (core::Size) atoi( tokens[3].c_str() );
411  pdb_numb_ = true;
412 
413  } else if( tokens[1] == "pdb_stop" ) {
414 
415  loop_end_pdb_chain_ = tokens[2][0];
416  loop_end_pdb_ = (core::Size) atoi( tokens[3].c_str() );
417  pdb_numb_ = true;
418 
419  } else if( tokens[1] == "min_length" ){
420  min_length_ = (core::Size) atoi( tokens[2].c_str() );
421  min_length_tag_found = true;
422  }
423 
424  else if( tokens[1] == "max_length" ){
425  max_length_ = (core::Size) atoi( tokens[2].c_str() );
426  max_length_tag_found = true;
427  }
428 
429  else if( tokens[1] == "ss_string" ){
430  for( core::Size i = 2; i <= tokens.size(); ++i ) ss_strings_.push_back( tokens[ i ] );
431  }
432 
433  else if( tokens[1] == "ss_blueprint" ){
434  for( core::Size i = 2; i <= tokens.size(); ++i ) ss_blueprints.push_back( tokens[i] );
435  }
436 
437  else if( tokens[1] == "CST_TARGET_BEGIN" ){
438 
439  //std::cerr << "detected CST_TARG block on line " << linenum << ", tokens[1] is " << tokens[1] << std::endl;
441 
442  if( ! cstres_interactions_[ cstres_interactions_.size() ].read_data( data ) ) {
443  tr << "Error occured when processing a CST_TARGET_BEGIN block." << std::endl;
444  return false;
445  }
446  //std::cerr << "successfully read CST_TARGET block " << std::endl;
447  }
448 
449  else if( tokens[1] == "RES_CONTACT_BEGIN" ){
450 
451  res_interactions_.push_back( ResInteractions() );
452 
453  if( ! res_interactions_[ res_interactions_.size() ].read_data( data ) ){
454  tr << "Error occured when processing a RES_CONTACT_BEGIN block." << std::endl;
455  return false;
456  }
457  }
458 
459  else if( tokens[1] == "instruction" ){
460  //unimplemented for now
461  }
462 
463 
464  } //file reading loop
465 
466  tr << res_interactions_.size() << " residue contact blocks and " << cstres_interactions_.size() << " cst residue contact blocks were read in. " << std::endl;
467 
468  for( core::Size i = 1; i <= ss_blueprints.size(); ++i ) generate_ss_strings_from_blueprint( ss_blueprints[i] );
469 
470  //in case the user forgot these tags, we take this to mean that the loop length isn't changing
471  if( !min_length_tag_found ){
473  tr << "No min_length tag found, min_length_ set to " << min_length_ << "." << std::endl;
474  }
475  if( !max_length_tag_found ){
477  tr << "No max_length tag found, max_length_ set to " << max_length_ << "." << std::endl;
478  }
479 
480  return check_data_consistency( true );
481 
482 } //read_loops_file_block
483 
484 bool
486  bool report
487 ) const
488 {
489  if( loop_start_ == 0 && loop_start_pdb_ == 0){
490  if( report ) tr << "file didn't seem to specify loop start" << std::endl;
491  return false;
492  }
493 
494  if( loop_end_ == 0 && loop_start_pdb_ == 0){
495  if( report ) tr << "file didn't seem to specify loop stop" << std::endl;
496  return false;
497  }
498 
499  if( pose_numb_ && pdb_numb_){
500  if( report ) tr << "specify loop start and stop by PDB or pose numbering" << std::endl;
501  return false;
502  }
503 
504  if( min_length_ == 0 ){
505  if( report ) tr << "file specified illegal minimum loop length (min_length tag) of 0" << std::endl;
506  return false;
507  }
508 
509  if( max_length_ == 0 ){
510  if( report ) tr << "file specified illegal maximum loop length (max_length tag) of 0" << std::endl;
511  return false;
512  }
513 
515  if( report ) tr << "specified start of loop is after stop of loop. go work at mcdonalds." << std::endl;
516  return false;
517  }
518 
519  if( min_length_ > max_length_ ){
520  tr << "min_length of loop is larger than max_length of loop. go work at mcdonalds" << std::endl;
521  return false;
522  }
523 
524  if( min_length_ < 4 ){
525  if( report ) tr << "min length of loop is too short, has to be at least 4." << std::endl;
526  return false;
527  }
528 
529  for( core::Size i = 1; i <= ss_strings_.size(); ++i ){
530 
531  if( ss_strings_[i].length() < min_length_ ) tr << "WARNING: secondary structure string " << i << ", " << ss_strings_[i] << ", specified in the enzdes loops file is shorter than min_length for the loop. This overrides the specified min_length." << std::endl;
532 
533  if( ss_strings_[i].length() > max_length_ ) tr << "WARNING: secondary structure string " << i << ", " << ss_strings_[i] << ", specified in the enzdes loops file is longer than max_length for the loop. This overrides the specified max_length." << std::endl;
534  }
535 
536  return true;
537 } //check_data_consistency
538 
539 
540 void
542  std::string const & ss_blueprint )
543 {
544 
545  utility::vector1< std::string > blueprint_elements = utility::string_split( ss_blueprint, ')' );
546 
547  utility::vector1< char > blueprint_element_ss_chars;
548  utility::vector1< core::Size > blueprint_element_num_lengths;
549  utility::vector1< core::Size > blueprint_element_min_lengths;
550  core::Size num_previous_ss_strings( ss_strings_.size() );
551  core::Size num_combos(1);
552 
553  for(utility::vector1< std::string >::iterator ble_it = blueprint_elements.begin(); ble_it != blueprint_elements.end(); ++ble_it ){
554 
555  if( *ble_it == "" ) continue;
556 
557  std::string ble_length_info = ble_it->substr(2);
558  utility::vector1< std::string > min_max_strings( utility::string_split( ble_length_info, '-' ) );
559 
560  if( ( (min_max_strings.size() != 1 ) && (min_max_strings.size() != 2 ) ) || ( (*ble_it)[1] != '(' ) ){
561  utility_exit_with_message("SS_blueprint "+ *ble_it + " could not be understood when trying to generate ss_strings from it.");
562  }
563 
564  blueprint_element_ss_chars.push_back( (*ble_it)[0] );
565 
566  if( min_max_strings.size() == 1 ){
567  blueprint_element_num_lengths.push_back(1);
568  blueprint_element_min_lengths.push_back( (core::Size) atoi( min_max_strings[1].c_str() ) );
569  }
570  else{ //implies min_max_strings.size() == 2, see above check
571  core::Size ble_min_length( (core::Size) atoi( min_max_strings[1].c_str() ) );
572  core::Size ble_max_length( (core::Size) atoi(min_max_strings[2].c_str() ) );
573  //runtime_assert( ble_min_length <= ble_max_length );
574  blueprint_element_num_lengths.push_back( ble_max_length - ble_min_length + 1);
575  blueprint_element_min_lengths.push_back( ble_min_length );
576  }
577 
578  num_combos = num_combos * blueprint_element_num_lengths[ blueprint_element_num_lengths.size() ];
579  }
580  core::Size num_elements( blueprint_element_num_lengths.size() );
581  //using LexicographicalIterator to go through all the length combinations
582  core::Size too_long_strings(0), too_short_strings(0);
583 
584  utility::LexicographicalIterator lex( blueprint_element_num_lengths );
585  std::set< std::string > observed_ss_strings; //safeguard to prevent the same string appearing more than once
586  core::Size redundant_strings(0);
587  while( !lex.at_end() ){
588 
589  core::Size length_this_string(0);
590 
591  for( core::Size i = 1; i <= num_elements; ++i){
592  length_this_string += lex[i]+blueprint_element_min_lengths[i] - 1;
593  }
594  if( length_this_string < min_length_ ){
595  too_short_strings++;
596  ++lex;
597  continue;
598  }
599  if( length_this_string > max_length_ ){
600  too_long_strings++;
601  ++lex;
602  continue;
603  }
604 
605  //ok, this particular string is within the desired range. now let's build it
606  std::string ss_string("");
607  for( core::Size i = 1; i <= num_elements; ++i){
608 
609  core::Size length_this_element( lex[i]+blueprint_element_min_lengths[i] - 1 );
610  for( core::Size j = 1; j <= length_this_element; ++j ){
611  ss_string.push_back( blueprint_element_ss_chars[i] );
612  }
613  }
614  //runtime_assert( ss_string.size() == length_this_string );
615  if( observed_ss_strings.find( ss_string ) == observed_ss_strings.end() ){
616  ss_strings_.push_back( ss_string );
617  observed_ss_strings.insert( ss_string );
618  }
619  else redundant_strings++;
620 
621  ++lex;
622  }
623 
624  tr << "SS blueprint string " << ss_blueprint << " led to the following " << ss_strings_.size() - num_previous_ss_strings << " secondary structure strings out of a total of " << num_combos << " possible combinations: " << std::endl;
625 
626  for( core::Size i = num_previous_ss_strings + 1; i <= ss_strings_.size(); ++i ) tr << ss_strings_[i] << ", ";
627 
628  tr << std::endl << "A total of " << too_long_strings << " ss_strings were ignored because they were too long, a total of " << too_short_strings << " ss_strings were ignored because they were too short, and a total of " << redundant_strings << " ss_strings were ignored because they were redundant." << std::endl;
629 
630 }
631 
632 
634  : file_read_(false )
635 {
636  enzloops_.clear();
637 }
638 
639 bool
642 {
643 
644  utility::io::izstream data( filename.c_str() );
645  std::istringstream line_stream;
646 
647  enzloops_.clear();
648 
649  if ( !data ) {
650  std::cerr << "ERROR:: Unable to open enzdes loops file: "
651  << filename << std::endl;
652  std::exit( 1 );
653  }
654  tr.Info << "reading enzdes loops from " << filename << " ..." << std::endl;
655 
656  core::Size counted_loops(0);
657 
658  while( !data.eof() ) {
659 
660  std::string key, line;
661  getline(data,line);
662  line_stream.clear();
663  line_stream.str(line);
664  line_stream >> key;
665 
666  if( key == "LOOP_BEGIN" ){
667 
668  counted_loops++;
669  tr << "reading loop block " << counted_loops << "... " << std::endl;
670 
671  EnzdesLoopInfoOP el = new EnzdesLoopInfo();
672 
673  if( el->read_loops_file_block( data ) ){
674 
675  enzloops_.push_back( el );
676 
677  tr << "Data read: start(" << el->start() << "), stop(" << el->stop() << "), min_length(" << el->min_length() << "),";
678  tr << " max_length(" << el->max_length() << ") " << std::endl;
679  tr << el->ss_strings().size() << " secstruct strings, " << el->res_interactions().size() << " res interactions" << std::endl;
680  tr << " ... done reading block " << counted_loops << "." << std::endl;
681  }
682 
683  else {
684  tr << "Error when reading file " << filename << ". Block " << counted_loops << " or the info therein was corrupted." << std::endl;
685  return false;
686  }
687  }
688  }
689 
690  file_read_ = true;
691 
692  return true;
693 
694 } //read_loops_file
695 
696 
699 {
700  assert( l <= enzloops_.size() );
701 
702  return enzloops_[l];
703 
704 }
705 
706 void
708 {
709  file_read_ = false;
710  enzloops_.clear();
711 }
712 
713 } //match_enzdes_util
714 } //toolbox
715 } //protocols
716