00001 //------------------------------------------------------------------------------ 00002 // This file is part of the OpenStructure project <www.openstructure.org> 00003 // 00004 // Copyright (C) 2008-2011 by the OpenStructure authors 00005 // 00006 // This library is free software; you can redistribute it and/or modify it under 00007 // the terms of the GNU Lesser General Public License as published by the Free 00008 // Software Foundation; either version 3.0 of the License, or (at your option) 00009 // any later version. 00010 // This library is distributed in the hope that it will be useful, but WITHOUT 00011 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00012 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00013 // details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public License 00016 // along with this library; if not, write to the Free Software Foundation, Inc., 00017 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 //------------------------------------------------------------------------------ 00019 #ifndef OST_CHAIN_VIEW_HH 00020 #define OST_CHAIN_VIEW_HH 00021 00022 #include <ost/mol/module_config.hh> 00023 #include <ost/geom/geom.hh> 00024 00025 #include <ost/mol/query.hh> 00026 #include <ost/mol/chain_base.hh> 00027 #include <ost/mol/impl/chain_impl_fw.hh> 00028 #include <ost/mol/impl/entity_impl_fw.hh> 00029 #include <ost/mol/view_type_fw.hh> 00030 #include <ost/mol/entity_visitor_fw.hh> 00031 #include <ost/mol/handle_type_fw.hh> 00032 #include <ost/mol/residue_prop.hh> 00033 00034 namespace ost { namespace mol { 00035 00037 class DLLEXPORT_OST_MOL ChainView : public ChainBase { 00038 public: 00039 ChainView(); 00040 00041 ChainView(ChainViewDataPtr data, 00042 impl::ChainImplPtr impl); 00043 00044 ChainView(const EntityView& entity, 00045 const ChainHandle& chain); 00046 public: 00047 00049 00050 00051 00052 00053 00054 00055 00056 operator bool() const { return this->IsValid(); } 00059 bool IsValid() const { return data_.get()!=0; } 00061 00063 EntityView GetEntity() const; 00064 00065 void Apply(EntityVisitor& visitor); 00066 void Apply(EntityViewVisitor& visitor); 00067 00069 int GetResidueCount() const; 00070 00072 int GetAtomCount() const; 00073 00080 int GetBondCount() const; 00081 00082 public: 00094 ResidueView AddResidue(const ResidueHandle& residue_handle, 00095 ViewAddFlags flags=0); 00096 00111 ResidueView AddResidue(const ResidueView& residue_view, 00112 ViewAddFlags flags=0); 00121 AtomView AddAtom(const AtomHandle& atom_handle, 00122 ViewAddFlags flags=0); 00123 00125 ResidueView FindResidue(const ResNum& number) const; 00126 00129 AtomView FindAtom(const AtomHandle& atom) const; 00130 00131 AtomView ViewForHandle(const AtomHandle& atom) const; 00132 AtomView FindAtom(const ResNum& num, const String& name) const; 00134 ResidueView ViewForHandle(const ResidueHandle& handle) const; 00135 00136 ResidueView FindResidue(const ResidueHandle& handle) const; 00138 bool IsResidueIncluded(const ResidueHandle& handle) const; 00139 00141 ChainHandle GetHandle() const; 00142 00147 const ResidueViewList& GetResidueList() const; 00148 00150 void RemoveResidue(ResidueView view); 00151 00152 int GetResidueIndex(const ResNum& number) const; 00153 00157 ResidueView GetResidueByIndex(int index) const; 00158 00159 00161 Real GetMass() const; 00162 00164 geom::Vec3 GetCenterOfMass() const; 00165 00170 geom::Vec3 GetCenterOfAtoms() const; 00171 00173 geom::AlignedCuboid GetBounds() const; 00174 00176 void RemoveResidues(); 00178 00179 00180 ChainViewDataPtr& ViewData() { 00181 return data_; 00182 } 00183 00185 const ChainViewDataPtr& ViewData() const { 00186 return data_; 00187 } 00190 bool InSequence() const; 00191 00194 EntityView Select(const Query& q, QueryFlags flags=0) const; 00195 00198 EntityView Select(const String& query_string, QueryFlags flags=0) const; 00199 00200 bool operator==(const ChainView& rhs) const; 00201 bool operator!=(const ChainView& rhs) const; 00202 bool HasAtoms() const; 00204 private: 00205 ChainViewDataPtr data_; 00206 }; 00207 00208 }} // ns 00209 #endif // OST_CHAIN_VIEW_HH 00210