diff --git a/modules/seq/base/pymod/export_sequence.cc b/modules/seq/base/pymod/export_sequence.cc index 581c5494c2ad3386d672dda08223e8d0e45706f4..3f8636fe5ff64b7378ccbfa5d2eda6b2cde27170 100644 --- a/modules/seq/base/pymod/export_sequence.cc +++ b/modules/seq/base/pymod/export_sequence.cc @@ -250,6 +250,7 @@ void export_sequence() .add_property("sequences", &AlignmentHandle::GetSequences) .def("SetSequenceName", &AlignmentHandle::SetSequenceName) .def("SetSequenceOffset", &AlignmentHandle::SetSequenceOffset) + .def("GetSequenceOffset", &AlignmentHandle::GetSequenceOffset) ; class_<AlignedColumn>("AlignedColumn", no_init) .def("GetIndex", &AlignedColumn::GetIndex) diff --git a/modules/seq/base/src/alignment_handle.cc b/modules/seq/base/src/alignment_handle.cc index 48bb07af5fb0dad628d188aa32ccbeb722e99fc4..ee21b144c3d3674b6dd3dc17bb8fb20e2b1ad252 100644 --- a/modules/seq/base/src/alignment_handle.cc +++ b/modules/seq/base/src/alignment_handle.cc @@ -62,7 +62,7 @@ int AlignmentHandle::GetResidueIndex(int seq_index, int pos) const void AlignmentHandle::AddSequence(const ConstSequenceHandle& sequence) { this->CheckValidity(); - if (impl_->GetCount()>0 && + if (impl_->GetCount()>0 && impl_->GetSequence(0)->GetLength()!=sequence.GetLength()) { throw InvalidAlignment(); } @@ -143,7 +143,7 @@ void AlignmentHandle::AttachView(int seq_index, const mol::EntityView& view) impl_->GetSequence(seq_index)->AttachView(view); } -void AlignmentHandle::AttachView(int seq_index, const mol::EntityView& view, +void AlignmentHandle::AttachView(int seq_index, const mol::EntityView& view, const String& chain_name) { this->CheckValidity(); @@ -160,7 +160,7 @@ ConstSequenceHandle AlignmentHandle::FindSequence(const String& name) const void AlignmentHandle::Cut(int start, int end) { this->CheckValidity(); - for (impl::SequenceListImpl::Iterator i=impl_->Begin(), + for (impl::SequenceListImpl::Iterator i=impl_->Begin(), e=impl_->End(); i!=e; ++i) { (*i)->Cut(start, end-start); } @@ -183,12 +183,12 @@ void AlignmentHandle::Replace(const AlignedRegion& aln_r, int start, int end){ } } -void AlignmentHandle::ShiftRegion(int start, int end, int amount, +void AlignmentHandle::ShiftRegion(int start, int end, int amount, int master) { this->CheckValidity(); int cnt=0; - for (impl::SequenceListImpl::Iterator i=impl_->Begin(), + for (impl::SequenceListImpl::Iterator i=impl_->Begin(), e=impl_->End(); i!=e; ++i, ++cnt) { if (master==-1 || cnt==master) { (*i)->ShiftRegion(start, end, amount); @@ -216,7 +216,7 @@ char AlignmentHandle::GetOneLetterCode(int seq_index, int pos) const AlignedColumnIterator AlignmentHandle::begin() const { - // no need to check for validity here + // no need to check for validity here return AlignedColumnIterator(*this, 0, this->GetLength()); } @@ -244,4 +244,9 @@ void AlignmentHandle::SetSequenceOffset(int seq_index, int offset) impl_->GetSequence(seq_index)->SetSequenceOffset(offset); } +int AlignmentHandle::GetSequenceOffset(int seq_index) +{ + this->CheckValidity(); + return impl_->GetSequence(seq_index)->GetSequenceOffset(); +} }} diff --git a/modules/seq/base/src/alignment_handle.hh b/modules/seq/base/src/alignment_handle.hh index 7e6ba856767795ae3ef7882f898b7cfffb0559e2..e007b4fb3797cabc72c0da1316c79ffd11f6a96f 100644 --- a/modules/seq/base/src/alignment_handle.hh +++ b/modules/seq/base/src/alignment_handle.hh @@ -35,27 +35,27 @@ class AlignedRegion; class AlignedColumn; class AlignedColumnIterator; -/// \brief representation of a multiple sequence alignemnt consisting of two or +/// \brief representation of a multiple sequence alignemnt consisting of two or /// more sequences /// -/// A sequence alignment consists of two or more sequences. The number of -/// sequences in the alignment can be obtained by #GetCount(). +/// A sequence alignment consists of two or more sequences. The number of +/// sequences in the alignment can be obtained by #GetCount(). /// All sequences are of length #GetLength(). -/// -/// Typically sequence alignments are used column-based, i.e by looking at an -/// aligned columns in the sequence alignment. To get a row-based (sequence) -/// view on the sequence list, use AlignmentHandle::GetSequenceList(). For an +/// +/// Typically sequence alignments are used column-based, i.e by looking at an +/// aligned columns in the sequence alignment. To get a row-based (sequence) +/// view on the sequence list, use AlignmentHandle::GetSequenceList(). For an /// overview of how to use the sequence module, see \ref module_seq "here" -/// -/// All operators that operate on an alignment will again produce a valid -/// alignment. This mean that it is not possible to change the length of one +/// +/// All operators that operate on an alignment will again produce a valid +/// alignment. This mean that it is not possible to change the length of one /// sequence, without adjusting the other sequences, too. class DLLEXPORT_OST_SEQ AlignmentHandle { public: typedef AlignedColumnIterator iterator; AlignmentHandle(); - + /// \brief Get position in sequence with index seq_index that corresponds to /// the given residue index. /// @@ -68,19 +68,19 @@ public: int GetResidueIndex(int seq_index, int pos) const; mol::ResidueView GetResidue(int seq_index, int pos) const; - + char GetOneLetterCode(int seq_index, int pos) const; - + /// \brief Add new sequence to multiple sequence alignment. - /// - /// If the sequence length does not match with the length of the other + /// + /// If the sequence length does not match with the length of the other /// sequences in the alignment, an InvalidSequence() exception is thrown. void AddSequence(const ConstSequenceHandle& sequence); /// \brief Get sequence with given index. /// \return sequence or invalid handle if the index is out of bounds - ConstSequenceHandle GetSequence(int seq_id) const; - + ConstSequenceHandle GetSequence(int seq_id) const; + /// \brief Convert multiple sequence alignment to string. String ToString(int width=80) const; @@ -88,87 +88,88 @@ public: int GetLength() const; /// \brief deep-copy multi sequence alignment - AlignmentHandle Copy() const; - + AlignmentHandle Copy() const; + /// \brief find sequence by name. - /// - /// If several sequences have the same name, the first matching sequence will + /// + /// If several sequences have the same name, the first matching sequence will /// be returned. ConstSequenceHandle FindSequence(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); - + /// \brief attach view to given sequence - /// \sa SequenceHandle::AttachView(const mol::EntityView&, const String&) - void AttachView(int seq_index, const mol::EntityView& view, + /// \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); - - void SetSequenceOffset(int seq_index, int offset); + + void SetSequenceOffset(int seq_index, int offset); + int GetSequenceOffset(int seq_index); /// \brief Get list of sequences (read-only) ConstSequenceList GetSequences() const; - + /// \brief create an aligned region. - /// + /// /// \param start is the index of the first column /// \param n is the length of the sequence - /// \param master is the reference system for operations such as shifting. - /// If set to -1, no master sequence is defined and the operations will + /// \param master is the reference system for operations such as shifting. + /// If set to -1, no master sequence is defined and the operations will /// affect all sequences - /// - /// This method does not throw any exceptions, even if the aligned region is + /// + /// This method does not throw any exceptions, even if the aligned region is /// out of bounds. AlignedRegion MakeRegion(int start, int n, int master=-1) const; - + /// \brief get number of sequences in alignment int GetCount() const; - + bool operator==(const AlignmentHandle& rhs) const; - bool operator!=(const AlignmentHandle& rhs) const; - + bool operator!=(const AlignmentHandle& rhs) const; + /// \brief get aligned column at index - /// - /// This method does not throw any exception. Upon accessing methods of the - /// aligned column, exceptions might be thrown when the index is out of + /// + /// This method does not throw any exception. Upon accessing methods of the + /// aligned column, exceptions might be thrown when the index is out of /// bounds. AlignedColumn operator[](int index) const; - - AlignmentHandle(const impl::SequenceListImplPtr& impl); - + + AlignmentHandle(const impl::SequenceListImplPtr& impl); + /// \brief cut out half-closed interval start, end void Cut(int start, int end); - + ///\brief Replace part of an alignment void Replace(const AlignedRegion& rhs, int start, int end); /// \brief shift half-closed interval by amount - /// + /// /// if master is -1, all sequences of the alignment will be shifted. Otherwise /// only the sequence with given index is affected. void ShiftRegion(int start, int end, int amount, int master=-1); - + /// \brief Column iterator start-point iterator begin() const; /// \brief Column iterator end-point iterator end() const; - + private: void CheckValidity() const; - impl::SequenceListImplPtr impl_; + impl::SequenceListImplPtr impl_; }; AlignmentHandle DLLEXPORT_OST_SEQ CreateAlignment(); /// \brief convert alignment from sequence list -/// -/// If the sequences in the SequenceList have different lengths, an +/// +/// If the sequences in the SequenceList have different lengths, an /// InvalidAlignment exception is thrown. -/// +/// /// \return alignment consisting of the sequences in seq_list. -AlignmentHandle DLLEXPORT_OST_SEQ +AlignmentHandle DLLEXPORT_OST_SEQ AlignmentFromSequenceList(const SequenceList& seq_list); typedef std::vector<AlignmentHandle> AlignmentList;