Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
prob_util.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 numeric/prob_util.cc
11 /// @author Christopher Miles (cmiles@uw.edu)
12 
13 // Unit header
14 #include <numeric/prob_util.hh>
15 
16 // C/C++ headers
17 #include <fstream>
18 #include <iostream>
19 #include <string>
20 
21 // Utility headers
22 #include <utility/exit.hh>
23 #include <utility/vector1.hh>
24 
25 namespace numeric {
26 
28  using namespace std;
29  assert(probs);
30  probs->clear();
31 
32  ifstream in(filename.c_str());
33  if ( !in.is_open() ) {
34  utility_exit_with_message("Error reading probabilities from " + filename);
35  }
36 
37  double p;
38  in >> p;
39  while ( in.good() ) {
40  probs->push_back(p);
41  in >> p;
42  }
43  in.close();
44 }
45 
46 void print_probabilities(const utility::vector1<double>& probs, std::ostream& out) {
47  for ( unsigned i = 1; i <= probs.size(); ++i ) {
48  out << "P(" << i << ") = " << probs[i] << std::endl;
49  }
50 }
51 
52 } // namespace numeric
#define utility_exit_with_message(m)
Exit with file + line + message.
Definition: exit.hh:47
void print_probabilities(const utility::vector1< double > &probs, std::ostream &out)
Writes probs to the specified ostream.
Definition: prob_util.cc:46
tuple p
Definition: docking.py:9
Program exit functions and macros.
vector1: std::vector with 1-based indexing
void read_probabilities_or_die(const std::string &filename, utility::vector1< double > *probs)
Loads normalized, per-residue probabilities from filename, storing the result in probs. Assumes line i holds the probability of sampling residue i. There must be 1 line for each residue in the pose on which this data will be used.
Definition: prob_util.cc:27