diff --git a/modules/seq/alg/src/merge_pairwise_alignments.cc b/modules/seq/alg/src/merge_pairwise_alignments.cc index 664f6ccc6315da166fd169daa20951d4f1b32367..35126c2bdc0d3acbf6d2a0cd21a52325822db1fc 100644 --- a/modules/seq/alg/src/merge_pairwise_alignments.cc +++ b/modules/seq/alg/src/merge_pairwise_alignments.cc @@ -89,7 +89,7 @@ SequenceHandle shift_reference(const SequenceHandle& ref_seq, new_sequence.str()); if (ref_seq.HasAttachedView()) s.AttachView(ref_seq.GetAttachedView()); - s.SetSequenceOffset(s.GetSequenceOffset()); + s.SetOffset(s.GetOffset()); return s; } @@ -123,7 +123,7 @@ SequenceHandle realign_sequence(const AlignmentHandle& aln, SequenceHandle s=CreateSequence(s2.GetName(), new_sequence.str()); if (s2.HasAttachedView()) s.AttachView(s2.GetAttachedView()); - s.SetSequenceOffset(s2.GetSequenceOffset()); + s.SetOffset(s2.GetOffset()); return s; } diff --git a/modules/seq/base/doc/seq.rst b/modules/seq/base/doc/seq.rst index 9d6e8d213f743a6383d4cdaf2a2eaee2a7f132c5..243ec0d49108938923169456f4ba9e9cef8a927f 100644 --- a/modules/seq/base/doc/seq.rst +++ b/modules/seq/base/doc/seq.rst @@ -148,15 +148,15 @@ The SequenceHandle Returns the name of the sequence. Also available as the property :attr:`name` - .. method:: SetSequenceOffset() + .. method:: SetOffset() Set the :ref:`sequence offset <sequence-offset>`. By default, the offset is - 0. Also available as the property :attr:`sequence_offset`. + 0. Also available as the property :attr:`offset`. - .. method:: GetSequenceOffset() + .. method:: GetOffset() Returns the :ref:`sequence offset <sequence-offset>`. Also available as - :attr:`sequence_offset`. + :attr:`offset`. .. method:: GetGaplessString() @@ -181,7 +181,7 @@ The SequenceHandle Shorthand for :meth:`GetAttachedView`. - .. attribute:: sequence_offset + .. attribute:: offset Shorthand for :meth:`GetSequenceOffset`/:meth:`SetSequenceOffset` diff --git a/modules/seq/base/pymod/export_sequence.cc b/modules/seq/base/pymod/export_sequence.cc index c88fe7f27dc5d8e88d5c4eabaa706b1dc66ba210..28543e04d50d5375b102ab67474d96978a912c0e 100644 --- a/modules/seq/base/pymod/export_sequence.cc +++ b/modules/seq/base/pymod/export_sequence.cc @@ -209,7 +209,7 @@ void const_seq_handle_def(O& bp_class) .def("GetResidue", &C::GetResidue) .def("GetOneLetterCode", &C::GetOneLetterCode) .def("__getitem__", &C::GetOneLetterCode) - .def("GetSequenceOffset", &C::GetSequenceOffset) + .def("GetOffset", &C::GetOffset) .def("Copy", &C::Copy) .def("IsValid", &C::IsValid) .def("GetFirstNonGap", &C::GetFirstNonGap) @@ -229,7 +229,7 @@ void const_seq_handle_def(O& bp_class) .add_property("name", make_function(&C::GetName, return_value_policy<copy_const_reference>())) - .add_property("sequence_offset", &C::GetSequenceOffset) + .add_property("offset", &C::GetOffset) .add_property("gapless_string", &C::GetGaplessString) .add_property("string", make_function(&C::GetString, @@ -252,7 +252,7 @@ void export_sequence() seq_handle .def("__setitem__", &SequenceHandle::SetOneLetterCode) .def("SetOneLetterCode", &SequenceHandle::SetOneLetterCode) - .def("SetSequenceOffset", &SequenceHandle::SetSequenceOffset) + .def("SetOffset", &SequenceHandle::SetOffset) .def("AttachView", attach_one) .def("AttachView", attach_two) .def("SetString", &SequenceHandle::SetString) @@ -265,8 +265,8 @@ void export_sequence() make_function(&SequenceHandle::GetName, return_value_policy<copy_const_reference>()), &SequenceHandle::SetName) - .add_property("sequence_offset", &SequenceHandle::GetSequenceOffset, - &SequenceHandle::SetSequenceOffset) + .add_property("offset", &SequenceHandle::GetOffset, + &SequenceHandle::SetOffset) ; implicitly_convertible<SequenceHandle, ConstSequenceHandle>(); diff --git a/modules/seq/base/src/alignment_handle.cc b/modules/seq/base/src/alignment_handle.cc index edc54340b7d4a4ea017035465f7c5c468c53b302..d2a7ab85d387051d43edbadac9419925b5ac7fee 100644 --- a/modules/seq/base/src/alignment_handle.cc +++ b/modules/seq/base/src/alignment_handle.cc @@ -255,12 +255,12 @@ void AlignmentHandle::SetSequenceName(int seq_index, const String& name) void AlignmentHandle::SetSequenceOffset(int seq_index, int offset) { this->CheckValidity(); - impl_->GetSequence(seq_index)->SetSequenceOffset(offset); + impl_->GetSequence(seq_index)->SetOffset(offset); } int AlignmentHandle::GetSequenceOffset(int seq_index) { this->CheckValidity(); - return impl_->GetSequence(seq_index)->GetSequenceOffset(); + return impl_->GetSequence(seq_index)->GetOffset(); } }} diff --git a/modules/seq/base/src/impl/sequence_impl.cc b/modules/seq/base/src/impl/sequence_impl.cc index 64a1c8cc5c1e60aebdf5cd9fdd15eedb12986d40..a99ea9b6389bcc2655db1bdc459ce6e243253aa7 100644 --- a/modules/seq/base/src/impl/sequence_impl.cc +++ b/modules/seq/base/src/impl/sequence_impl.cc @@ -74,7 +74,7 @@ void SequenceImpl::SetString(const String& seq) SequenceImpl::SequenceImpl(const String& seq_name, const String& seq_string) - : seq_name_(seq_name), seq_string_(seq_string), sequence_offset_(0) + : seq_name_(seq_name), seq_string_(seq_string), offset_(0) { this->ShiftsFromSequence(); } @@ -82,7 +82,7 @@ SequenceImpl::SequenceImpl(const String& seq_name, SequenceImplPtr SequenceImpl::Copy() const { SequenceImplPtr new_seq(new SequenceImpl(seq_name_, seq_string_)); - new_seq->sequence_offset_=sequence_offset_; + new_seq->offset_=offset_; new_seq->shifts_=shifts_; new_seq->attached_view_=attached_view_; return new_seq; @@ -139,7 +139,7 @@ int SequenceImpl::GetResidueIndex(int pos) const if (s.start<=pos) shift+=s.shift; } - return pos-shift+sequence_offset_; + return pos-shift+offset_; } void SequenceImpl::SetName(const String& seq_name) @@ -154,7 +154,7 @@ const String& SequenceImpl::GetName() const int SequenceImpl::GetPos(int index) const { - int shifted_index=index-sequence_offset_; + int shifted_index=index-offset_; int pos=this->GetPosNoBounds(shifted_index); if (pos<0 || pos>=static_cast<int>(seq_string_.length())) throw Error("number not covered in sequence"); @@ -174,15 +174,15 @@ int SequenceImpl::GetPosNoBounds(int index) const } /// \brief Set offset for sequence alignment. -void SequenceImpl::SetSequenceOffset(int offset) +void SequenceImpl::SetOffset(int offset) { - sequence_offset_=offset; + offset_=offset; } /// \brief Get sequence offset -int SequenceImpl::GetSequenceOffset() const +int SequenceImpl::GetOffset() const { - return sequence_offset_; + return offset_; } int SequenceImpl::GetLength() const { @@ -259,7 +259,7 @@ void SequenceImplToInfo(const SequenceImplPtr& sequence, info::InfoGroup& group) group.SetTextData(sequence->GetString()); group.SetAttribute("name", sequence->GetName()); std::ostringstream ss; - ss << sequence->GetSequenceOffset(); + ss << sequence->GetOffset(); group.SetAttribute("offset", ss.str()); } @@ -271,7 +271,7 @@ SequenceImplPtr SequenceImplFromInfo(const info::InfoGroup& group) ss >> offset; SequenceImplPtr sequence=SequenceImpl::FromString(group.GetAttribute("name"), text); - sequence->SetSequenceOffset(offset); + sequence->SetOffset(offset); return sequence; } diff --git a/modules/seq/base/src/impl/sequence_impl.hh b/modules/seq/base/src/impl/sequence_impl.hh index f7d1110c98a0bbb315ceaf4e3b2d7f5c925a547c..f89b3c4bf8f939a7b03b2c20f4ccaf37e34d8edf 100644 --- a/modules/seq/base/src/impl/sequence_impl.hh +++ b/modules/seq/base/src/impl/sequence_impl.hh @@ -85,15 +85,15 @@ public: /// \brief Get sequence offset from N-terminus /// - /// \sa #SetSequenceOffset - int GetSequenceOffset() const; + /// \sa #SetOffset + int GetOffset() const; /// \brief Set sequence offset /// /// By default the sequence offset is zero, i.e. the beginning of the sequence /// lies exactly at the N-terminus. Setting the sequence offset to a positive /// number will shift the sequence towards the C-terminus. - void SetSequenceOffset(int offset); + void SetOffset(int offset); /// \brief Get lenght of sequence, including gaps. int GetLength() const; @@ -155,7 +155,7 @@ private: String seq_string_; std::list<Shift> shifts_; bool editing_; - int sequence_offset_; + int offset_; mol::EntityView attached_view_; }; diff --git a/modules/seq/base/src/sequence_handle.cc b/modules/seq/base/src/sequence_handle.cc index 8bf31de26f6cb75396e27f3a61f3c3e6eaa32eae..13063990d6f093947354436e4cc619c546c36639 100644 --- a/modules/seq/base/src/sequence_handle.cc +++ b/modules/seq/base/src/sequence_handle.cc @@ -88,10 +88,10 @@ String ConstSequenceHandle::GetGaplessString() const return Impl()->GetGaplessString(); } -int ConstSequenceHandle::GetSequenceOffset() const +int ConstSequenceHandle::GetOffset() const { this->CheckValidity(); - return Impl()->GetSequenceOffset(); + return Impl()->GetOffset(); } @@ -183,10 +183,10 @@ void SequenceHandle::SetString(const String& seq) return Impl()->SetString(seq); } -void SequenceHandle::SetSequenceOffset(int offset) +void SequenceHandle::SetOffset(int offset) { this->CheckValidity(); - return Impl()->SetSequenceOffset(offset); + return Impl()->SetOffset(offset); } @@ -268,10 +268,10 @@ String SequenceHandle::GetGaplessString() const return Impl()->GetGaplessString(); } -int SequenceHandle::GetSequenceOffset() const +int SequenceHandle::GetOffset() const { this->CheckValidity(); - return Impl()->GetSequenceOffset(); + return Impl()->GetOffset(); } SequenceHandle::operator ConstSequenceHandle() const diff --git a/modules/seq/base/src/sequence_handle.hh b/modules/seq/base/src/sequence_handle.hh index 46004d0a85502c59930652f2d8ea80142cf1e61d..923dec13f217105a13205f334aec02ed5d7289ab 100644 --- a/modules/seq/base/src/sequence_handle.hh +++ b/modules/seq/base/src/sequence_handle.hh @@ -84,8 +84,8 @@ public: /// \brief Get sequence offset from N-terminus /// - /// \sa SequenceHandle::SetSequenceOffset - int GetSequenceOffset() const; + /// \sa SequenceHandle::SetOffset + int GetOffset() const; /// \brief Get lenght of sequence, including gaps. int GetLength() const; @@ -140,7 +140,7 @@ private: /// "multiple sequence alignment". The class allows for fast mapping between /// residue index and position in the sequence. The GetResidueIndex() method /// maps from position in the sequence to residue index, taking the -/// \ref GetSequenceOffset() "sequence offset" into account. The reverse +/// \ref GetOffset() "sequence offset" into account. The reverse /// mapping is done with GetPos(). /// /// Optionally, an entity view may be attached to the sequence with @@ -195,8 +195,8 @@ public: /// \brief Get sequence offset from N-terminus /// - /// \sa SequenceHandle::SetSequenceOffset - int GetSequenceOffset() const; + /// \sa SequenceHandle::GetOffset + int GetOffset() const; /// \brief Get lenght of sequence, including gaps. int GetLength() const; @@ -246,7 +246,7 @@ public: /// By default the sequence offset is zero, i.e. the beginning of the sequence /// lies exactly at the N-terminus. Setting the sequence offset to a positive /// number will shift the sequence towards the C-terminus. - void SetSequenceOffset(int offset); + void SetOffset(int offset); /// \brief attach entity view to sequence /// diff --git a/modules/seq/base/src/views_from_sequences.cc b/modules/seq/base/src/views_from_sequences.cc index 7ab0ff1f6806c1d303baac5e0689f12d06d91f89..dad47106b659bb034f577533333019d2e8653258 100644 --- a/modules/seq/base/src/views_from_sequences.cc +++ b/modules/seq/base/src/views_from_sequences.cc @@ -66,9 +66,9 @@ ViewsFromSequences(const ConstSequenceHandle& seq1, mol::ResidueViewList res_b=src_b.GetResidueList(); int pos=0, index_a=0, index_b=0; while (skip_gaps(seq1, seq2, pos, index_a, index_b)) { - dst_a.AddResidue(res_a.at(seq1.GetSequenceOffset()+index_a), + dst_a.AddResidue(res_a.at(seq1.GetOffset()+index_a), mol::ViewAddFlag::INCLUDE_ATOMS); - dst_b.AddResidue(res_b.at(seq2.GetSequenceOffset()+index_b), + dst_b.AddResidue(res_b.at(seq2.GetOffset()+index_b), mol::ViewAddFlag::INCLUDE_ATOMS); pos+=1; index_a+=1; diff --git a/modules/seq/base/tests/test_seq.py b/modules/seq/base/tests/test_seq.py index 4eed73b1132f82109cc0250807561cb0675db3c0..26abba6896e53f32f19ef43cb4d44e5999bb6c2f 100644 --- a/modules/seq/base/tests/test_seq.py +++ b/modules/seq/base/tests/test_seq.py @@ -113,9 +113,9 @@ class TestSeq(unittest.TestCase): def testViewsFromSequences_09(self): seq_a=seq.CreateSequence("A", "B-D-FGH") seq_a.AttachView(self.ent.Select('rname=A,B,D,F,G,H')) - seq_a.SetSequenceOffset(1) + seq_a.offset=1 seq_b=seq.CreateSequence("B", "B-DEF-H") - seq_b.SetSequenceOffset(1) + seq_b.offset=1 seq_b.AttachView(self.ent.Select('rname=A,B,D,E,F,H')) a, b=seq.ViewsFromSequences(seq_a, seq_b) string_a=''.join([r.one_letter_code for r in a.residues]) diff --git a/modules/seq/base/tests/test_sequence.cc b/modules/seq/base/tests/test_sequence.cc index 21c588a46cfb851b46972eaa26bceced3e55a8d4..e787aafb7c3de95e8d93c2b55de8b3b9bba7c8f4 100644 --- a/modules/seq/base/tests/test_sequence.cc +++ b/modules/seq/base/tests/test_sequence.cc @@ -136,7 +136,7 @@ BOOST_AUTO_TEST_CASE(seq_offset) { SequenceHandle s=CreateSequence("S1", "-afc--de-f"); SequenceHandle s2=CreateSequence("S1", "-afc--de-f"); - s.SetSequenceOffset(2); + s.SetOffset(2); BOOST_CHECK_THROW(s.GetPos(-1), Error); BOOST_CHECK_THROW(s.GetPos(0), Error); BOOST_CHECK_THROW(s.GetPos(1), Error); @@ -155,7 +155,7 @@ BOOST_AUTO_TEST_CASE(seq_offset) BOOST_CHECK_THROW(s.GetResidueIndex(10), std::out_of_range); BOOST_CHECK_THROW(s.GetResidueIndex(-1), std::out_of_range); - s.SetSequenceOffset(-1); + s.SetOffset(-1); BOOST_CHECK_THROW(s.GetPos(-2), Error); BOOST_CHECK_EQUAL(s.GetPos(-1), 1); BOOST_CHECK_EQUAL(s.GetPos(0), 2);