00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00024
00025 #ifndef BTK_ATOM_H
00026 #define BTK_ATOM_H
00027
00028 #include "atom_group_concept.h"
00029 #include "atom_types.h"
00030 #include "element_types.h"
00031 #include "group_types.h"
00032 #include "linear_algebra.h"
00033
00034 #include <iosfwd>
00035 #include <string>
00036
00037
00038 namespace BTK {
00039
00046 class Atom {
00047 typedef Atom self_type;
00048 typedef AtomGroupConcept group_type;
00049 public:
00051 Atom(ATOM::index_t index = ATOM::UNKNOWN,
00052 ELEMENT::index_t element = ELEMENT::UNKNOWN,
00053 group_type * group = 0) :
00054 _atom_index(index), _element(element),
00055 _group(group), _pos(new_vector()),
00056 _is_selected(false) {}
00057
00059 Atom(BTKVector const & pos,
00060 ATOM::index_t index = ATOM::UNKNOWN,
00061 ELEMENT::index_t element = ELEMENT::UNKNOWN,
00062 group_type * group = 0) :
00063 _atom_index(index), _element(element),
00064 _group(group), _pos(pos),
00065 _is_selected(false) {}
00066
00068 Atom(double X, double Y, double Z,
00069 ATOM::index_t index = ATOM::UNKNOWN,
00070 ELEMENT::index_t element = ELEMENT::UNKNOWN,
00071 group_type * group = 0) :
00072 _atom_index(index), _element(element),
00073 _group(group), _pos(new_vector(X,Y,Z)),
00074 _is_selected(false) {}
00075
00076 virtual ~Atom() {};
00077
00079 ATOM::index_t atom_index() const { return _atom_index; }
00080
00082 void set_atom_index(ATOM::index_t x) {
00083 _atom_index = x;
00084 set_element(ATOM::atom_index_to_element_index(_atom_index));
00085 }
00086
00088 virtual const std::string& atom_name() const {
00089 return ATOM::atom_index_to_pdbname(atom_index());
00090 }
00091
00093 ELEMENT::index_t element() const {return _element;}
00094
00096 void set_element(ELEMENT::index_t element) {
00097 _element = element;
00098 }
00099
00100 std::string element_name() const { return ELEMENT::name(element()); };
00101
00103 virtual int group_num() const {
00104 if(_group){
00105 return _group->group_num();
00106 } else {
00107 return 0;
00108 }
00109 }
00110
00112 virtual const std::string& group_name3() const {
00113 static std::string s("XXX");
00114 if(_group){
00115 return _group->group_name3();
00116 } else {
00117 return s;
00118 }
00119 }
00120
00122 GROUP::index_t group_index() const {
00123 if(_group) {
00124 return _group->group_index();
00125 } else {
00126 return GROUP::UNKNOWN;
00127 }
00128 }
00129
00131 void set_group(group_type& a) { _group = &a; }
00132
00133 const BTKVector& position() const {return _pos;}
00134 void set_position(const BTKVector& position) {_pos = position;}
00135
00136 void print_pdb_line(int atom_num,
00137 char chain_id,
00138 std::ostream& os) const;
00139
00140 bool is_selected() const { return _is_selected; }
00141 void set_is_selected(const bool is_selected) { _is_selected = is_selected; }
00142
00143 private:
00144 ATOM::index_t _atom_index;
00145 ELEMENT::index_t _element;
00146 group_type* _group;
00147 BTKVector _pos;
00148
00149 bool _is_selected;
00150 };
00151
00152
00153 typedef class Atom Atom;
00154
00155
00156 void print_pdb_atom_line(int atom_num,
00157 const std::string& atom_name,
00158 const std::string& res_name,
00159 char chain_id,
00160 int res_num,
00161 const BTKVector& pos,
00162 std::ostream& os);
00163
00164
00165 inline void Atom::print_pdb_line(int atom_num,
00166 char chain_id,
00167 std::ostream& os) const {
00168 print_pdb_atom_line(atom_num,atom_name(),group_name3(),chain_id,group_num(),position(),os);
00169 }
00170
00171 std::ostream& operator<<(std::ostream& os,
00172 const BTK::Atom& a);
00173
00174 }
00175
00176
00177 #endif