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_SEQ_SEQUENCE_LIST_IMPL_HH 00020 #define OST_SEQ_SEQUENCE_LIST_IMPL_HH 00021 00022 /* 00023 Author: Marco Biasini 00024 */ 00025 #include <vector> 00026 #include <boost/shared_ptr.hpp> 00027 #include <ost/seq/impl/sequence_list_impl_fw.hh> 00028 #include <ost/seq/impl/sequence_impl.hh> 00029 00030 namespace ost { namespace seq { namespace impl { 00031 00033 class DLLEXPORT_OST_SEQ SequenceListImpl { 00034 public: 00035 typedef SequenceImplListConstIterator ConstIterator; 00036 typedef SequenceImplListIterator Iterator; 00037 SequenceListImpl() { } 00038 00040 void AddSequence(const SequenceImplPtr& sequence); 00042 int GetCount() const { return list_.size(); } 00043 00044 SequenceImplPtr& GetSequence(int i) { 00045 unsigned int index = static_cast<unsigned int>(i); 00046 if (index<list_.size()) { 00047 return list_[index]; 00048 } 00049 throw std::out_of_range("Index not covered SequenceList"); 00050 } 00051 00052 const SequenceImplPtr& GetSequence(unsigned int i) const { 00053 unsigned int index = static_cast<unsigned int>(i); 00054 if (index<list_.size()) { 00055 return list_[index]; 00056 } 00057 throw std::out_of_range("Index not covered SequenceList"); 00058 } 00059 00060 00061 void RemoveSequence(int index); 00062 int GetPos(int seq_index, int residue_index) const; 00063 00064 int GetResidueIndex(int seq_index, int pos) const; 00065 00066 SequenceImplPtr FindSequence(const String& name) const; 00067 00068 int FindSequenceIndex(const String& name) const; 00069 00070 String ToString(int width=80) const; 00071 00072 SequenceListImplPtr Slice(int first, int n) const; 00073 int GetMinLength() const; 00074 00075 00076 int GetMaxLength() const; 00077 00078 bool SequencesHaveEqualLength() const 00079 { 00080 return this->GetMaxLength()==this->GetMinLength(); 00081 } 00082 00083 Real GetCoverage(int seq_index) const; 00084 00085 SequenceListImplPtr Copy() const; 00086 00087 Iterator Begin() { return list_.begin(); } 00088 Iterator End() { return list_.end(); } 00089 ConstIterator Begin() const { return list_.begin(); } 00090 ConstIterator End() const { return list_.end(); } 00091 00092 00093 private: 00094 std::vector<SequenceImplPtr> list_; 00095 }; 00096 00097 #if(OST_INFO_ENABLED) 00100 void DLLEXPORT_OST_SEQ 00101 SequenceListImplToInfo(const SequenceListImplPtr& seq_list, 00102 info::InfoGroup& group); 00103 00106 SequenceListImplPtr DLLEXPORT_OST_SEQ 00107 SequenceListImplFromInfo(info::InfoGroup& group); 00108 #endif 00109 00110 }}} 00111 00112 #endif