Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FormFactor.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/FormFactor.cc
11 /// @brief Represents an atomic scattering form factor
12 /// @author Dominik Gront (dgront@chem.uw.edu.pl)
13 
15 
16 // utility headers
17 #include <core/types.hh>
18 #include <basic/Tracer.hh>
19 #include <utility/vector1.hh>
20 
21 #include <numeric/interpolation/spline/Interpolator.hh>
22 #include <numeric/interpolation/spline/SplineGenerator.hh>
23 
24 #include <utility/io/izstream.hh>
25 
26 namespace core {
27 namespace scoring {
28 namespace saxs {
29 
30 /// @details Auto-generated virtual destructor
32 
33 static basic::Tracer trFormFactor(
34  "core.scoring.saxs.FormFactor");
35 
37 
38  name_ = atom_name;
41  Real minX = 100000000000.0;
42  Real minY = 100000000000.0;
43  Real maxX = -100000000000.0;
44  Real maxY = -100000000000.0;
45  Real tX,tY;
46  trFormFactor.Debug << "Opening: "<<file_name<<std::endl;
47  utility::io::izstream input(file_name.c_str());
48  std::string line;
49  while( getline( input, line ) ) {
50  if ( line.substr(0,1) == "#" ) continue;
51  std::istringstream line_stream( line );
52  trFormFactor.Trace << "line " << line << std::endl;
53  line_stream >> tX >> tY;
54  if(tX<minX) minX = tX;
55  if(tY<minY) minY= tY;
56  if(tX>maxX) maxX = tX;
57  if(tY>maxY) maxY= tY;
58  x.push_back(tX);
59  y.push_back(tY);
60  }
61  trFormFactor.Debug << x.size() << " data points loaded for "<<atom_name<<" atomic form factor"<<std::endl;
62  Real delta = 0.1;
63  numeric::interpolation::spline::SplineGenerator gen( minX-delta, minY-delta, 0, maxX+delta, maxY+delta, 0 );
64  for (Size i = 1; i <= x.size(); ++i)
65  gen.add_known_value( x[i],y[i] );
66  spline_interpolator_ = gen.get_interpolator();
67 }
68 
70 
71  ff_values_.clear();
72  for(Size i_s=1;i_s<=q.size();++i_s) {
73  ff_values_.push_back(ff(q[i_s]));
74  }
75 }
76 
77 } // saxs
78 } // scoring
79 } // core
80