Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DisulfPairingsList.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 /// @brief
11 /// @detailed
12 ///
13 ///
14 ///
15 /// @author Oliver Lange
16 
17 // Unit Headers
19 
20 // Package Headers
21 
22 // Project Headers
23 
24 // ObjexxFCL Headers
25 #include <ObjexxFCL/format.hh>
26 #include <ObjexxFCL/FArray1A.hh>
27 
28 
29 // Utility headers
30 #include <utility/vector1.fwd.hh>
31 #include <utility/io/izstream.hh>
32 #include <utility/exit.hh>
33 
34 #include <basic/Tracer.hh>
35 
36 // #include <basic/options/option.hh>
37 // #include <basic/options/keys/OptionKeys.hh>
38 
39 // numeric headers
40 // #include <numeric/random/random.hh>
41 
42 //// C++ headers
43 // AUTO-REMOVED #include <cstdlib>
44 #include <string>
45 
46 #include <utility/vector1.hh>
47 
48 
49 static basic::Tracer tr("protocols.jumping");
50 
51 using core::Real;
52 using namespace core;
53 using namespace basic;
54 using namespace ObjexxFCL;
55 //using namespace basic::options;
56 
57 namespace protocols {
58 namespace jumping {
59 
60 DisulfPairing::DisulfPairing( ObjexxFCL::FArray1A_int data) {
61  pos1 = data(1);
62  pos2 = data(2);
63  seq_sep = data(3);
64  ss_type = data(4);
65 }
66 
67 //static numeric::random::RandomGenerator RG(132238); // <- Magic number, do not change it, huaah hah ha!
68 void read_pairing_list( std::string disulf_pairing_file, DisulfPairingsList& disulf_pairings)
69 {
70  utility::io::izstream disulf_pairing_stream( disulf_pairing_file );
71  if ( !disulf_pairing_stream ) {
72  tr.Fatal << "can't open disulf_pairings file!!!" << disulf_pairing_file << std::endl;
73  disulf_pairing_stream.close();
74  utility::exit( EXIT_FAILURE, __FILE__, __LINE__);
75  }
76  read_disulf_pairing_list( disulf_pairing_stream, disulf_pairings );
77  disulf_pairing_stream.close();
78 }
79 
80 void read_disulf_pairing_list( std::istream& disulf_pairing_stream, DisulfPairingsList& disulf_pairings) {
81  std::string line;
82  Size a,b,c,d;
83  while ( getline( disulf_pairing_stream, line ) ) {
84  std::istringstream line_stream( line );
85  // a=i, b=j, c=orientation(1 or 2), d=pleating(1 or 2)
86  std::string o, pleat;
87  line_stream >> a >> b >> c >> d;
88  if ( line_stream.fail() ) {
89  std::cout << "[ERROR] unable to parse " << line << std::endl;
90  continue;
91  }
92 
93  DisulfPairing p( a, b, c, d);
94  //if ( a > b ) p.reverse();
95  disulf_pairings.push_back( p );
96 
97  }
98 } // read_disulf_pairings
99 
100 std::ostream& operator<< ( std::ostream& out, DisulfPairing const& p) {
101  out << fmt::RJ(5, p.pos1 ) << fmt::RJ(5, p.pos2 ) << " "
102  << fmt::RJ(5, p.seq_sep) << fmt::RJ(5, p.ss_type );
103  return out;
104 }
105 
106 std::ostream& operator<< ( std::ostream& out, DisulfPairingsList const& p) {
107  for (DisulfPairingsList::const_iterator it= p.begin(),
108  eit = p.end(); it!=eit; ++it ) {
109  out << (*it) << "\n";
110  }
111  return out;
112 }
113 
114 } // jumping
115 } // protocols