Skip to content
Snippets Groups Projects
Commit 73291a94 authored by Niklaus Johner's avatar Niklaus Johner
Browse files

Added a function to find the index of a sequence in an alignment from its name

AlignmentHandle::FindSequenceIndex()
parent f92d3196
Branches
Tags 1.2.0
No related merge requests found
......@@ -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)
......
......@@ -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)
{
......
......@@ -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);
......
......@@ -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;
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment