Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ABEGO_SS_Config.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/frag_picker/quota/ABEGO_SS_Config.hh
11 /// @brief Reads a config file for quota selector
12 /// @author Dominik Gront (dgront@chem.uw.edu.pl)
13 
16 
17 // utility headers
18 #include <core/types.hh>
19 #include <basic/Tracer.hh>
20 #include <utility/io/izstream.hh>
21 #include <utility/exit.hh>
22 
23 
24 // boost
25 #include <boost/tokenizer.hpp>
26 #include <boost/lexical_cast.hpp>
27 
28 #include <utility/vector1.hh>
29 
30 
31 namespace protocols {
32 namespace frag_picker {
33 namespace quota {
34 
35 static basic::Tracer trABEGO_SS_Config(
36  "protocols.frag_picker.quota.ABEGO_SS_Config");
37 
38 ABEGO_SS_Config::ABEGO_SS_Config(std::string & file_name) : source_file_name_(file_name) {
39 
40  utility::io::izstream data(file_name.c_str());
41  trABEGO_SS_Config.Info << "reading SS-ABEGO quota config from " << file_name << std::endl;
42  if (!data)
43  utility_exit_with_message("[ERROR] Unable to open quota config file: "
44  + file_name);
45  std::string line;
46  typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
47  boost::char_separator<char> sep(", :");
48  while (data) {
49  getline(data, line);
50  if(line.length() < 4) continue;
51  if(line[0]=='#') continue;
52  tokenizer tokens(line, sep);
54  for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter)
55  t.push_back(*tok_iter);
56  trABEGO_SS_Config.Trace << "Parsing a line: "<<line<<"\n\t("<<t.size()<<" tokens)"<<std::endl;
57  if(line.find(':')!=line.npos) {
58  //Size pool_id;
60  std::string pool_name;
61  //pool_id = boost::lexical_cast<int>(t[1]); set but never used ~Labonte
62  pool_name = t[2];
63  trABEGO_SS_Config.Trace << "a new pool defined: >"<<pool_name<<"<";
64  for(Size i=3;i<=t.size();i+=2) {
65  bins.push_back( std::pair<Size,Size>(ss_index(t[i][0]),abego_index(t[i+1][0])) );
66  trABEGO_SS_Config.Trace << " "<<bins[bins.size()].first<<" : "<<bins[bins.size()].second;
67  }
68  trABEGO_SS_Config.Trace << std::endl;
69  pool_defs_.push_back( bins );
70  pool_names_.push_back( pool_name );
71  } else {
73  for(Size i=5;i<=t.size();i++)
74  row.push_back( boost::lexical_cast<double>(t[i]) );
75  bin_probs_.push_back(row);
76  }
77  }
78  data.close();
79 
80  trABEGO_SS_Config.Debug << "Loded data from "<<source_file_name_<<
81  " columns: "<<n_columns()<<" rows: " <<n_rows()<<std::endl;
82 
83  assert( pool_defs_.size() == pool_names_.size() ); // the number of pool names doesn't mach pool definitions
84 }
85 
87 
88  Real max = -100000.0;
89  for(Size i=1;i<=bin_probs_[pos].size();i++)
90  if(bin_probs_[pos][i] > max)
91  max = bin_probs_[pos][i];
92  return max;
93 }
94 
96 
97  Real max = -100000.0;
98  Size i_max = 0;
99  for(Size i=1;i<=bin_probs_[pos].size();i++)
100  if(bin_probs_[pos][i] > max) {
101  max = bin_probs_[pos][i];
102  i_max = i;
103  }
104 
105  return i_max;
106 }
107 
108 
109 
110 } // quota
111 } // frag_picker
112 } // protocols
113