From f5fddcca43bd54ffd2bb25a64373694405e46c2a Mon Sep 17 00:00:00 2001
From: marco <marco@5a81b35b-ba03-0410-adc8-b2c5c5119f08>
Date: Thu, 19 Aug 2010 11:00:44 +0000
Subject: [PATCH] added RemoveSequence

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2655 5a81b35b-ba03-0410-adc8-b2c5c5119f08
---
 modules/seq/base/pymod/export_sequence.cc       | 1 +
 modules/seq/base/src/alignment_handle.cc        | 6 ++++++
 modules/seq/base/src/alignment_handle.hh        | 4 +++-
 modules/seq/base/src/impl/sequence_list_impl.cc | 8 +++++++-
 modules/seq/base/src/impl/sequence_list_impl.hh | 2 ++
 5 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/modules/seq/base/pymod/export_sequence.cc b/modules/seq/base/pymod/export_sequence.cc
index e0104a51c..b6c500cf2 100644
--- a/modules/seq/base/pymod/export_sequence.cc
+++ b/modules/seq/base/pymod/export_sequence.cc
@@ -304,6 +304,7 @@ void export_sequence()
     .def("AttachView", attach_view_b)
     .def("Cut", &AlignmentHandle::Cut)
     .def("MakeRegion", &AlignmentHandle::MakeRegion)
+    .def("RemoveSequence", &AlignmentHandle::RemoveSequence)
     .def("Replace",&AlignmentHandle::Replace)
     .def("__getitem__", &slice_aln)
     .def("__getitem__", &AlignmentHandle::operator[])
diff --git a/modules/seq/base/src/alignment_handle.cc b/modules/seq/base/src/alignment_handle.cc
index d4611b562..edc54340b 100644
--- a/modules/seq/base/src/alignment_handle.cc
+++ b/modules/seq/base/src/alignment_handle.cc
@@ -82,6 +82,12 @@ String AlignmentHandle::ToString(int width) const
   return impl_->ToString(width);
 }
 
+void AlignmentHandle::RemoveSequence(int seq_index)
+{
+  this->CheckValidity();
+  impl_->RemoveSequence(seq_index);
+}
+
 int AlignmentHandle::GetLength() const
 {
   this->CheckValidity();
diff --git a/modules/seq/base/src/alignment_handle.hh b/modules/seq/base/src/alignment_handle.hh
index 998618b52..8c66888f1 100644
--- a/modules/seq/base/src/alignment_handle.hh
+++ b/modules/seq/base/src/alignment_handle.hh
@@ -80,7 +80,9 @@ public:
   /// \brief     Get sequence with given index.
   /// \return    sequence or invalid handle if the index is out of bounds
   ConstSequenceHandle GetSequence(int seq_id) const;
-
+  
+  /// \brief remove sequence at seq_index from alignment
+  void RemoveSequence(int seq_index);
   /// \brief   Convert multiple sequence alignment to string.
   String ToString(int width=80) const;
 
diff --git a/modules/seq/base/src/impl/sequence_list_impl.cc b/modules/seq/base/src/impl/sequence_list_impl.cc
index 01f22c779..e1e152059 100644
--- a/modules/seq/base/src/impl/sequence_list_impl.cc
+++ b/modules/seq/base/src/impl/sequence_list_impl.cc
@@ -96,7 +96,13 @@ String SequenceListImpl::ToString(int width) const
   return buffer.str();
 }
 
-
+void SequenceListImpl::RemoveSequence(int index)
+{
+  if (index<0 || index>=static_cast<int>(list_.size())) {
+    return;
+  }
+  list_.erase(list_.begin()+index);
+}
 int SequenceListImpl::GetMinLength() const
 {
   int min_length=std::numeric_limits<int>::max();
diff --git a/modules/seq/base/src/impl/sequence_list_impl.hh b/modules/seq/base/src/impl/sequence_list_impl.hh
index 3f1970f51..66bedd61f 100644
--- a/modules/seq/base/src/impl/sequence_list_impl.hh
+++ b/modules/seq/base/src/impl/sequence_list_impl.hh
@@ -57,6 +57,8 @@ public:
     throw std::out_of_range("Index not covered SequenceList");
   }
   
+  
+  void RemoveSequence(int index);
   int GetPos(int seq_index, int residue_index) const;
 
   int GetResidueIndex(int seq_index, int pos) const;
-- 
GitLab