Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
NamedStubID.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/id/NamedAtomID.cc
11 /// @brief Kinematics Atom identifier
12 /// @author Phil Bradley
13 
14 
15 // Unit headers
16 #include <core/id/NamedStubID.hh>
17 
18 #include <utility/exit.hh>
19 
20 
21 // AUTO-REMOVED #include <basic/Tracer.hh>
22 
23 // C++ headers
24 #include <ostream>
25 #include <string>
26 
27 #include <utility/vector1.hh>
28 #include <sstream>
29 
30 
31 namespace core {
32 namespace id {
33 
34 // convienience c'stor if the residue is the same for all atoms
35 NamedStubID::NamedStubID( std::string const& a1, std::string const& a2, std::string const& a3, core::Size rsd ) :
36  center_( a1, rsd ),
37  atom1( a1, rsd ),
38  atom2( a2, rsd ),
39  atom3( a3, rsd )
40 {}
41 
42 NamedStubID::NamedStubID( std::string const& c, std::string const& a1, std::string const& a2, std::string const& a3, core::Size rsd ) :
43  center_( c, rsd ),
44  atom1( a1, rsd ),
45  atom2( a2, rsd ),
46  atom3( a3, rsd )
47 {}
48 
49 // convienience c'stor
50 NamedStubID::NamedStubID( std::string const& a1, Size rsd1, std::string const& a2, Size rsd2, std::string a3, Size rsd3 ) :
51  center_( a1, rsd1 ),
52  atom1( a1, rsd1 ),
53  atom2( a2, rsd2 ),
54  atom3( a3, rsd3 )
55 {}
56 
58  assert( atoms.size() == 3 || atoms.size() == 4 );
59  Size ind;
60  if ( atoms.size() == 4 ) {
61  center_.atom() = atoms[ 1 ];
62  center_.rsd() = rsd;
63  ind = 2;
64  } else ind = 1;
65  atom1.atom() = atoms[ ind++ ];
66  atom2.atom() = atoms[ ind++ ];
67  atom3.atom() = atoms[ ind++ ];
68  atom1.rsd() = rsd;
69  atom2.rsd() = rsd;
70  atom3.rsd() = rsd;
71 }
72 
73 NamedAtomID const &
74 NamedStubID::atom( Size const index ) const
75 {
76  switch ( index ) {
77  case 1:
78  return atom1;
79  case 2:
80  return atom2;
81  case 3:
82  return atom3;
83  default:
84  utility_exit_with_message("StubID's have exactly three atoms, 1-3");
85  }
86  return atom1; // won't get here
87 }
88 
89 /// @brief stream << NamedStubID
90 std::ostream &
91 operator <<( std::ostream& os, NamedStubID const & a )
92 {
93  os << "STUB: " << a.center_ << ' ' << a.atom1 << ' ' << a.atom2 << ' ' << a.atom3 << ' ';
94  return os;
95 }
96 
97 /////////////////////////////////////////////////////////////////////////////
98 /// @brief input operator >> NamedAtomID
99 std::istream &
100 operator >>( std::istream & is, NamedStubID& s )
101 {
102  std::string tag;
103  is >> tag;
104  if ( tag != "STUB:" ) {
105  is.setstate( std::ios_base::failbit );
106  return is;
107  }
108  is >> s.center_ >> s.atom1 >> s.atom2 >> s.atom3;
109  return is;
110 }
111 
112 
113 
114 
115 } // namespace id
116 } // namespace core