Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FormFactorManager.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 core/scoring/saxs/FormFactorManager.cc
11 /// @brief Loads and manages atomic form factors
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 <basic/database/open.hh>
22 
23 // C++
24 #include <string>
25 // AUTO-REMOVED #include <utility>
26 #include <map>
27 
28 #include <utility/vector1.hh>
29 
30 
31 namespace core {
32 namespace scoring {
33 namespace saxs {
34 
35 static basic::Tracer trFormFactorManager(
36  "core.scoring.saxs.FormFactorManager");
37 
38 FormFactorManager* FormFactorManager::singleton_;
39 
41 
42  if(singleton_==0)
44 
45  return singleton_;
46 }
47 
49 
50  utility::io::izstream input(file_name.c_str());
51  std::string line;
52 
53  while( getline( input, line ) ) {
54  if ( line.substr(0,1) == "#" ) continue;
55  std::istringstream line_stream( line );
56  trFormFactorManager.Debug << "line: " << line << std::endl;
57  std::string n,f;
58  bool g;
59  line_stream >> n >> f >> g;
60  FormFactorOP c = new FormFactor(n,f);
61  c->is_glob(g);
62  trFormFactorManager.Debug << "Form factor for atom >"<<n<<"< loaded from a file: "<<f<<std::endl;
63  register_ff( n,c);
64  }
65 }
66 
68 
69  utility::io::izstream input(file_name.c_str());
70  std::string line;
71 
72  while( getline( input, line ) ) {
73  if ( line.substr(0,1) == "#" ) continue;
74  std::istringstream line_stream( line );
75  trFormFactorManager.Debug << "line " << line << std::endl;
76  std::string n,f;
77  bool g;
78  line_stream >> n >> f >> g;
79  FormFactorOP c = new FormFactor( n, basic::database::full_name("scoring/score_functions/saxs/"+f) );
80  c->is_glob(g);
81  trFormFactorManager.Warning << "Form factor for atom >"<<n<<"< loaded from a minirosetta database file: "<<f<<std::endl;
82  register_ff( n,c);
83  }
84 }
85 
86 
88 
89  Size n = known_atoms_.size() + 1;
90  new_ff->id_ = n;
91  if (ff_map_.find(atom_name) == ff_map_.end() ) {
92  ff_map_.insert( std::pair<std::string,FormFactorOP> (atom_name,new_ff) );
93  known_atoms_.push_back( atom_name );
94  names_to_indexes_.insert( std::pair<std::string,Size> (atom_name, n) );
95  ff_vector_.push_back(new_ff);
96  }
97 }
98 
99 /// @brief returns true if the manager has form factor function for a given atom
101 
102  assert( atom_name.size() > 0 );
103  if(ff_map_.find(atom_name) != ff_map_.end()) {
104  return true;
105  }
106  return false;
107 }
108 
109 /// @brief returns form factor function for a given atom
111 
112  if(ff_map_.find(atom_name) != ff_map_.end()) {
113 // trFormFactorManager.Debug << "Returning FF for this atom: "<<atom_name<<std::endl;
114  return ff_map_.find(atom_name)->second;
115  }
116 
117  trFormFactorManager.Debug << "The manager knows nothing about this atom: "<<atom_name<<std::endl;
118  return 0;
119 }
120 
121 
122 } // saxs
123 } // scoring
124 } // core
125