diff --git a/modules/seq/base/pymod/export_sequence.cc b/modules/seq/base/pymod/export_sequence.cc index 407633775e07924713162f7a7034d97358eb3584..7b76310412d75cb42818846ad1305422aee29b8f 100644 --- a/modules/seq/base/pymod/export_sequence.cc +++ b/modules/seq/base/pymod/export_sequence.cc @@ -337,6 +337,7 @@ void export_sequence() .def("GetResidue", &AlignmentHandle::GetResidue) .def("AddSequence", &AlignmentHandle::AddSequence) .def("FindSequence", &AlignmentHandle::FindSequence) + .def("FindSequenceIndex", &AlignmentHandle::FindSequenceIndex) .def("Copy", &AlignmentHandle::Copy) .def("ToString", &AlignmentHandle::ToString) .def("GetLength", &AlignmentHandle::GetLength) diff --git a/modules/seq/base/src/alignment_handle.cc b/modules/seq/base/src/alignment_handle.cc index 3e4ed4256f05bcef1128cdccef5585a3b1d8e582..8432d3c9035e7bfacce6d77f2244df05c4d37358 100644 --- a/modules/seq/base/src/alignment_handle.cc +++ b/modules/seq/base/src/alignment_handle.cc @@ -166,6 +166,11 @@ ConstSequenceHandle AlignmentHandle::FindSequence(const String& name) const return ConstSequenceHandle(impl_->FindSequence(name)); } +int AlignmentHandle::FindSequenceIndex(const String& name) const +{ + this->CheckValidity(); + return impl_->FindSequenceIndex(name); +} void AlignmentHandle::Cut(int start, int end) { diff --git a/modules/seq/base/src/alignment_handle.hh b/modules/seq/base/src/alignment_handle.hh index 9a109215b7236dd7ccd3b7a9acf9ea838df48532..5a59cef72240dcce57f6ba5f28b24e3663dc33dc 100644 --- a/modules/seq/base/src/alignment_handle.hh +++ b/modules/seq/base/src/alignment_handle.hh @@ -97,7 +97,9 @@ public: /// If several sequences have the same name, the first matching sequence will /// be returned. ConstSequenceHandle FindSequence(const String& name) const; - + + int FindSequenceIndex(const String& name) const; + /// \brief attach view to given sequence /// \sa SequenceHandle::AttachView(const mol::EntityView&) void AttachView(int seq_index, const mol::EntityView& view); diff --git a/modules/seq/base/src/impl/sequence_list_impl.cc b/modules/seq/base/src/impl/sequence_list_impl.cc index f0ef01531e91cedb69c0039d78edfc9673e6c1fb..bd332872bb1c2b1d531d50a3aa820e7fb5f083ac 100644 --- a/modules/seq/base/src/impl/sequence_list_impl.cc +++ b/modules/seq/base/src/impl/sequence_list_impl.cc @@ -58,6 +58,18 @@ SequenceImplPtr SequenceListImpl::FindSequence(const String& name) const return SequenceImplPtr(); } + +int SequenceListImpl::FindSequenceIndex(const String& name) const +{ + for (size_t i=0; i<list_.size(); ++i) { + if (list_[i]->GetName()==name) { + return int(i); + } + } + return -1; +} + + String SequenceListImpl::ToString(int width) const { std::stringstream buffer; diff --git a/modules/seq/base/src/impl/sequence_list_impl.hh b/modules/seq/base/src/impl/sequence_list_impl.hh index 7be941f730778218dfda4d7a54b1dead9f8c45f0..52443dcd64178222c688918aae9ee94dd27267f7 100644 --- a/modules/seq/base/src/impl/sequence_list_impl.hh +++ b/modules/seq/base/src/impl/sequence_list_impl.hh @@ -65,6 +65,8 @@ public: SequenceImplPtr FindSequence(const String& name) const; + int FindSequenceIndex(const String& name) const; + String ToString(int width=80) const; SequenceListImplPtr Slice(int first, int n) const;