00001 //------------------------------------------------------------------------------ 00002 // This file is part of the OpenStructure project <www.openstructure.org> 00003 // 00004 // Copyright (C) 2008-2010 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_SEQ_SEQUENCE_HANDLE_HH 00020 #define OST_SEQ_SEQUENCE_HANDLE_HH 00021 00022 /* 00023 Author: Marco Biasini 00024 */ 00025 00026 #include <ost/base.hh> 00027 #include <ost/generic_property.hh> 00028 #include <ost/info/info_fw.hh> 00029 #include <ost/seq/module_config.hh> 00030 00031 #include <ost/mol/residue_view.hh> 00032 #include <ost/mol/entity_view.hh> 00033 00034 #include <ost/seq/impl/sequence_impl_fw.hh> 00035 00036 namespace ost { namespace seq { 00037 00038 class SequenceHandle; 00039 class AlignmentHandle; 00040 00045 class DLLEXPORT_OST_SEQ ConstSequenceHandle : 00046 public ConstGenericPropContainer<ConstSequenceHandle> { 00047 public: 00048 friend class ConstGenericPropContainer<ConstSequenceHandle>; 00049 friend class AlignmentHandle; 00050 friend class ConstSequenceList; 00051 friend class SequenceList; 00055 ConstSequenceHandle(); 00056 00060 int GetResidueIndex(int pos) const; 00061 00064 int GetPos(int residue_index) const; 00065 00067 int GetFirstNonGap() const; 00068 00070 int GetLastNonGap() const; 00071 00075 const String& GetName() const; 00076 00080 const String& GetString() const; 00081 00083 String GetGaplessString() const; 00084 00088 int GetSequenceOffset() const; 00089 00091 int GetLength() const; 00092 00094 char GetOneLetterCode(int position) const; 00095 00101 mol::ResidueView GetResidue(int position) const; 00102 00105 mol::EntityView GetAttachedView() const; 00106 00109 SequenceHandle Copy() const; 00110 00114 bool HasAttachedView() const; 00115 00116 bool operator==(const ConstSequenceHandle& rhs) const; 00117 bool operator!=(const ConstSequenceHandle& rhs) const; 00118 00119 char operator[](int index) const; 00120 00122 bool IsValid() const; 00124 protected: 00125 GenericPropContainerImpl* GpImpl(); 00126 00127 const GenericPropContainerImpl* GpImpl() const; 00128 public: 00129 ConstSequenceHandle(const impl::SequenceImplPtr& impl); 00130 impl::SequenceImplPtr& Impl() const; 00131 private: 00132 void CheckValidity() const; 00133 mutable impl::SequenceImplPtr impl_; 00134 }; 00135 00149 // 00158 class DLLEXPORT_OST_SEQ SequenceHandle : 00159 public GenericPropContainer<SequenceHandle> { 00160 public: 00161 friend class GenericPropContainer<SequenceHandle>; 00162 friend class SequenceList; 00163 00164 friend class AlignmentHandle; 00165 friend class ConstSequenceList; 00166 00170 int GetResidueIndex(int pos) const; 00171 00174 int GetPos(int residue_index) const; 00175 00177 int GetFirstNonGap() const; 00178 00180 int GetLastNonGap() const; 00181 00185 const String& GetName() const; 00186 00190 const String& GetString() const; 00191 00193 String GetGaplessString() const; 00194 00198 int GetSequenceOffset() const; 00199 00201 int GetLength() const; 00202 00204 char GetOneLetterCode(int position) const; 00205 00211 mol::ResidueView GetResidue(int position) const; 00212 00215 mol::EntityView GetAttachedView() const; 00216 00219 SequenceHandle Copy() const; 00220 00224 bool HasAttachedView() const; 00225 00226 bool operator==(const SequenceHandle& rhs) const; 00227 bool operator!=(const SequenceHandle& rhs) const; 00228 00230 bool IsValid() const; 00231 00235 SequenceHandle(); 00236 00238 void SetName(const String& name); 00239 00241 void SetString(const String& seq); 00242 00248 void SetSequenceOffset(int offset); 00249 00253 void AttachView(const mol::EntityView& view); 00254 00255 operator ConstSequenceHandle() const; 00259 void AttachView(const mol::EntityView& view, const String& chain_name); 00260 00262 SequenceHandle(const impl::SequenceImplPtr& impl); 00263 00264 impl::SequenceImplPtr& Impl() const; 00265 00266 GenericPropContainerImpl* GpImpl(); 00267 00268 const GenericPropContainerImpl* GpImpl() const; 00269 private: 00270 void CheckValidity() const; 00271 mutable impl::SequenceImplPtr impl_; 00272 }; 00273 00274 SequenceHandle DLLEXPORT_OST_SEQ CreateSequence(const String& name, 00275 const String& seq); 00276 00278 void DLLEXPORT_OST_SEQ SequenceToInfo(const ConstSequenceHandle& sequence, 00279 info::InfoGroup& group); 00280 00282 SequenceHandle DLLEXPORT_OST_SEQ SequenceFromInfo(info::InfoGroup& group); 00283 00284 DLLEXPORT_OST_SEQ std::ostream& operator<<(std::ostream& os, 00285 const ConstSequenceHandle& sequence); 00286 }} 00287 00288 #endif
1.5.8