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_SEQUENCE_HH 00020 #define OST_SEQUENCE_HH 00021 00022 /* 00023 Author: Marco Biasini 00024 */ 00025 #include <ost/message.hh> 00026 #include <list> 00027 00028 #include <boost/shared_ptr.hpp> 00029 #include <ost/generic_property.hh> 00030 #include <ost/info/info_fw.hh> 00031 #include <ost/mol/residue_prop.hh> 00032 #include <ost/mol/entity_view.hh> 00033 #include <ost/mol/residue_view.hh> 00034 00035 #include <ost/seq/module_config.hh> 00036 #include <ost/seq/invalid_sequence.hh> 00037 namespace ost { namespace seq { namespace impl { 00038 00040 class SequenceImpl; 00041 00043 typedef boost::shared_ptr<SequenceImpl> SequenceImplPtr; 00044 00046 class DLLEXPORT_OST_SEQ SequenceImpl : public GenericPropContainerImpl { 00047 public: 00049 static SequenceImplPtr FromString(const String& seq_name, 00050 const String& sequence_string); 00051 00055 int GetResidueIndex(int pos) const; 00056 00059 int GetPos(int residue_index) const; 00060 00062 int GetFirstNonGap() const; 00063 00065 int GetLastNonGap() const; 00066 00067 const String& GetName() const; 00068 00069 void SetName(const String& name); 00070 00071 void Cut(int start, int n); 00072 00073 void ShiftRegion(int start, int end, int amount); 00074 const String& GetString() const { 00075 return seq_string_; 00076 } 00078 void SetString(const String& seq); 00079 00081 void Replace(const String& str,int start, int end); 00082 00084 String GetGaplessString() const; 00085 00089 int GetSequenceOffset() const; 00090 00096 void SetSequenceOffset(int offset); 00097 00099 int GetLength() const; 00104 SequenceImpl(const String& seq_name, const String& sequence_string); 00105 00107 char GetOneLetterCode(int position) const; 00108 00114 mol::ResidueView GetResidue(int position) const; 00115 00117 mol::EntityView GetAttachedView() const; 00118 00122 void AttachView(const mol::EntityView& view); 00123 00127 SequenceImplPtr Copy() const; 00131 void AttachView(const mol::EntityView& view, const String& chain_name); 00132 00134 bool HasAttachedView() const; 00135 private: 00136 00142 void ShiftsFromSequence(); 00143 00144 00145 int GetPosNoBounds(int index) const; 00146 00147 static bool IsSequenceStringSane(const String& seq_string); 00148 00149 typedef struct { 00150 int start; 00151 int shift; 00152 } Shift; 00153 String seq_name_; 00154 String seq_string_; 00155 std::list<Shift> shifts_; 00156 bool editing_; 00157 int sequence_offset_; 00158 mol::EntityView attached_view_; 00159 }; 00160 00162 typedef std::vector<SequenceImplPtr> SequenceList; 00163 00165 void DLLEXPORT_OST_SEQ SequenceImplToInfo(const SequenceImplPtr& sequence, 00166 info::InfoGroup& group); 00168 SequenceImplPtr DLLEXPORT_OST_SEQ 00169 00171 SequenceImplFromInfo(const info::InfoGroup& group); 00172 00173 }}} //ns 00174 #endif 00175
1.5.8