00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef OST_ATOM_IMPL_HH
00020 #define OST_ATOM_IMPL_HH
00021
00022 #include <boost/enable_shared_from_this.hpp>
00023
00024 #include <ost/mol/module_config.hh>
00025 #include <ost/geom/geom.hh>
00026 #include <ost/mol/entity_visitor_fw.hh>
00027 #include <ost/mol/impl/atom_prop.hh>
00028
00029 #include <ost/mol/impl/atom_impl_fw.hh>
00030 #include <ost/mol/impl/residue_impl_fw.hh>
00031 #include <ost/mol/impl/connector_impl_fw.hh>
00032 #include <ost/mol/impl/fragment_impl_fw.hh>
00033 #include <ost/mol/impl/entity_impl_fw.hh>
00034
00035 #include <ost/generic_property.hh>
00036 #include <ost/mol/property_id.hh>
00037
00038 namespace ost { namespace mol { namespace impl {
00039
00049 class AtomImpl: public GenericPropContainerImpl,
00050 public boost::enable_shared_from_this<AtomImpl> {
00051 public:
00052 AtomImpl(const EntityImplPtr& ent, const ResidueImplPtr& res,
00053 const String& name, const geom::Vec3& pos, const String& ele,
00054 unsigned long index);
00055
00056 ~AtomImpl();
00057 void Apply(EntityVisitor& h);
00058
00059
00060
00061
00062 const String& Name() const {return name_;}
00063 String& Name() {return name_;}
00064
00065
00066 const String& GetName() const {return name_;}
00067
00068 const geom::Vec3& TransformedPos() const {return tf_pos_;}
00069 geom::Vec3& TransformedPos() {return tf_pos_;}
00070
00071 const geom::Vec3& OriginalPos() const {return pos_;}
00072 geom::Vec3& OriginalPos() {return pos_;}
00073
00074 ResidueImplPtr GetResidue() const;
00075
00076 void SetPrimaryConnector(const ConnectorImplP& bp) {
00077 prim_connector_=bp;
00078 }
00079
00080 const ConnectorImplP& GetPrimaryConnector() const {
00081 return prim_connector_;
00082 }
00083
00084 const ConnectorImplList& GetSecondaryConnectors() const {
00085 return connector_list_;
00086 }
00087
00088 void AddSecondaryConnector(const ConnectorImplP& bp);
00089
00090
00091 void UpdateFromICS();
00092
00093
00094 void UpdateFromXCS();
00095
00096 String GetQualifiedName() const;
00097
00098 EntityImplPtr GetEntity() const;
00099
00100 int GetConnectorCount() const {
00101 return connector_list_.size()+(prim_connector_ ? 1 : 0);
00102 }
00103
00104 void SetVisited(bool f) {set_state_bit(0,f);}
00105 bool IsVisited() const {return get_state_bit(0);}
00106
00107 void SetTraced(bool f) {set_state_bit(1,f);}
00108 bool IsTraced() const {return get_state_bit(1);}
00109
00110
00111 Real GetBFactor() const { return b_factor_; }
00112
00113 const String& GetElement() const { return element_; }
00114
00115 void SetElement(const String& ele)
00116 {
00117 if (element_!=ele) {
00118 element_=ele;
00119 prop_=impl::AtomProp::GetDefaultProps(element_);
00120 }
00121 }
00122 bool HasDefaultProps() const { return prop_->is_default; }
00123 void SetAnisou(const geom::Mat3& anisou)
00124 {
00125 if (prop_->is_default && prop_->anisou!=anisou) {
00126 prop_=new AtomProp(*prop_);
00127 prop_->is_default=false;
00128 prop_->has_anisou=true;
00129 }
00130
00131 prop_->anisou=anisou;
00132 }
00133
00134 const geom::Mat3& GetAnisou() const
00135 {
00136 return prop_->anisou;
00137 }
00138 void SetBFactor(Real factor)
00139 {
00140 b_factor_=factor;
00141 }
00142
00143 void SetOccupancy(Real occ)
00144 {
00145 occupancy_=occ;
00146 }
00147
00148 Real GetOccupancy() const
00149 {
00150 return occupancy_;
00151 }
00152
00153 Real GetRadius() const { return prop_->radius; }
00154
00155 Real GetMass() const { return prop_->mass; }
00156 Real GetCharge() const { return prop_->charge; }
00157
00158 bool IsHetAtom() { return is_hetatm_; }
00159
00160 void SetHetAtom(bool het) { is_hetatm_=het; }
00161
00162 void SetMass(Real mass)
00163 {
00164 if (prop_->is_default && prop_->mass!=mass) {
00165 prop_=new AtomProp(*prop_);
00166 prop_->is_default=false;
00167 }
00168 prop_->mass=mass;
00169 }
00170
00171 void SetRadius(Real radius)
00172 {
00173 if (prop_->is_default && prop_->radius!=radius) {
00174 prop_=new AtomProp(*prop_);
00175 prop_->is_default=false;
00176 }
00177 prop_->radius=radius;
00178 }
00179
00180 void SetCharge(Real charge)
00181 {
00182 if (prop_->is_default && prop_->charge!=charge) {
00183 prop_=new AtomProp(*prop_);
00184 prop_->is_default=false;
00185 }
00186 prop_->charge=charge;
00187 }
00188
00189
00190 unsigned int GetState() const
00191 {
00192 return state_;
00193 }
00194
00195 void SetState(int state)
00196 {
00197 state_=state;
00198 }
00199
00200 void ClearDirectionality();
00202 void TraceDirectionality(FragmentImplP frag, ConnectorImplP conn,
00203 int n, unsigned int& c);
00204
00205 bool HasPrevious() const {return prim_connector_.get()!=NULL;}
00206
00207 void DeleteAllConnectors();
00208
00209 void DeleteConnector(const ConnectorImplP& conn,
00210 bool delete_other=true);
00211
00212 void DeleteAllTorsions();
00213
00214 String GetStringProperty(Prop::ID prop_id) const;
00215
00216 Real GetFloatProperty(Prop::ID prop_id) const;
00217
00218 int GetIntProperty(Prop::ID prop_id) const;
00219
00220 unsigned long GetIndex() const {return index_;}
00221 void SetIndex(unsigned long index) {index_=index;}
00222
00223 private:
00224 ResidueImplW res_;
00225 String name_;
00226 geom::Vec3 pos_;
00227 geom::Vec3 tf_pos_;
00228 Real occupancy_;
00229 Real b_factor_;
00230 AtomProp* prop_;
00231 bool is_hetatm_;
00232 String element_;
00233 ConnectorImplP prim_connector_;
00234 ConnectorImplList connector_list_;
00235 FragmentImplP fragment_;
00236
00239 geom::Mat3 total_rot_;
00240
00243 unsigned int state_;
00244
00245 void set_state_bit(unsigned int bit, bool state)
00246 {
00247 unsigned int mask = 0x1<<bit;
00248 if(state) {
00249 state_ |= mask;
00250 } else {
00251 state_ &= ~mask;
00252 }
00253 }
00254
00255 bool get_state_bit(unsigned int bit) const {
00256 unsigned int mask = 0x1<<bit;
00257 return (state_ & mask)!=0;
00258 }
00259
00260 unsigned long index_;
00261 };
00262
00264 std::ostream& operator<<(std::ostream& o, const AtomImplPtr ap);
00265
00267 bool ConnectorExists(const AtomImplPtr& a, const AtomImplPtr& b);
00268
00270 ConnectorImplP GetConnector(const AtomImplPtr& a, const AtomImplPtr& b);
00271
00272 }}}
00273
00274 #endif
00275