From 7bd977aea884b1163b9685c0b2fb9bb699b9aa0c Mon Sep 17 00:00:00 2001 From: marco <marco@5a81b35b-ba03-0410-adc8-b2c5c5119f08> Date: Thu, 1 Apr 2010 14:27:09 +0000 Subject: [PATCH] added indexing access to ConstSequenceHandle, SetSequenceName for AlignmentHandle git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@1913 5a81b35b-ba03-0410-adc8-b2c5c5119f08 --- modules/seq/base/pymod/export_sequence.cc | 5 ++++- modules/seq/base/src/aligned_region.hh | 4 +++- modules/seq/base/src/alignment_handle.cc | 7 +++++++ modules/seq/base/src/alignment_handle.hh | 5 ++++- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/modules/seq/base/pymod/export_sequence.cc b/modules/seq/base/pymod/export_sequence.cc index ce9d50ad2..fe3502c1b 100644 --- a/modules/seq/base/pymod/export_sequence.cc +++ b/modules/seq/base/pymod/export_sequence.cc @@ -97,7 +97,8 @@ void export_sequence() .def("GetPos", &ConstSequenceHandle::GetPos) .def("GetLength", &ConstSequenceHandle::GetLength) .def("GetResidue", &ConstSequenceHandle::GetResidue) - .def("GetOneLetterCode", &ConstSequenceHandle::GetOneLetterCode) + .def("GetOneLetterCode", &ConstSequenceHandle::GetOneLetterCode) + .def("__getitem__", &ConstSequenceHandle::GetOneLetterCode) .def("GetSequenceOffset", &ConstSequenceHandle::GetSequenceOffset) .def("Copy", &ConstSequenceHandle::Copy) .def("GetFirstNonGap", &ConstSequenceHandle::GetFirstNonGap) @@ -158,6 +159,7 @@ void export_sequence() .def("Copy", &AlignmentHandle::Copy) .def("ToString", &AlignmentHandle::ToString) .def("GetLength", &AlignmentHandle::GetLength) + .def("__len__", &AlignmentHandle::GetLength) .def("GetSequences", &AlignmentHandle::GetSequences) .def("AttachView", attach_view_a) .def("AttachView", attach_view_b) @@ -167,6 +169,7 @@ void export_sequence() .def("__getitem__", &AlignmentHandle::operator[]) .def("__iter__", iterator<AlignmentHandle>()) .add_property("sequences", &AlignmentHandle::GetSequences) + .def("SetSequenceName", &AlignmentHandle::SetSequenceName) ; class_<AlignedColumn>("AlignedColumn", no_init) .def("GetIndex", &AlignedColumn::GetIndex) diff --git a/modules/seq/base/src/aligned_region.hh b/modules/seq/base/src/aligned_region.hh index cfd6f757d..ca8166ee1 100644 --- a/modules/seq/base/src/aligned_region.hh +++ b/modules/seq/base/src/aligned_region.hh @@ -49,8 +49,10 @@ public: void SetMaster(int master); /// \brief delete interval and update length of AlignedRegion void Delete(); - ///\brief replace region with content of AlignedRegion and set length to length of \p aln_r + /// \brief replace region with content of AlignedRegion and set length to + /// length of \p aln_r void Replace(const AlignedRegion& aln_r); + /// \brief shift the aligned region of the master sequence to the left by /// n characters. void ShiftLeft(int n); diff --git a/modules/seq/base/src/alignment_handle.cc b/modules/seq/base/src/alignment_handle.cc index 6d6d5bb63..0c9d312d2 100644 --- a/modules/seq/base/src/alignment_handle.cc +++ b/modules/seq/base/src/alignment_handle.cc @@ -231,4 +231,11 @@ AlignedColumn AlignmentHandle::operator[](int index) return AlignedColumn(*this, index); } +void AlignmentHandle::SetSequenceName(int seq_index, const String& name) + +{ + this->CheckValidity(); + impl_->GetSequence(seq_index)->SetName(name); +} + }} diff --git a/modules/seq/base/src/alignment_handle.hh b/modules/seq/base/src/alignment_handle.hh index 893ec4cf8..d097d90bd 100644 --- a/modules/seq/base/src/alignment_handle.hh +++ b/modules/seq/base/src/alignment_handle.hh @@ -104,7 +104,10 @@ public: /// \sa SequenceHandle::AttachView(const mol::EntityView&, const String&) void AttachView(int seq_index, const mol::EntityView& view, const String& chain_name); - + + /// \brief set name of sequence + void SetSequenceName(int seq_index, const String& name); + /// \brief Get list of sequences (read-only) ConstSequenceList GetSequences() const; -- GitLab