OpenStructure
alignment_handle.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2020 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 #ifndef OST_SEQ_ALIGNMENT_HANDLE_HH
20 #define OST_SEQ_ALIGNMENT_HANDLE_HH
21 
22 /*
23  Author: Marco Biasini
24  */
25 #include <ost/seq/module_config.hh>
26 
29 #include <ost/seq/sequence_list.hh>
30 
31 namespace ost { namespace seq {
32 
33 class SequenceList;
34 class AlignedRegion;
35 class AlignedColumn;
36 class AlignedColumnIterator;
37 
54 public:
55 
58 
63  int GetPos(int seq_index, int residue_index) const;
64 
68  int GetResidueIndex(int seq_index, int pos) const;
69 
70  mol::ResidueView GetResidue(int seq_index, int pos) const;
71 
72  char GetOneLetterCode(int seq_index, int pos) const;
73 
78  void AddSequence(const ConstSequenceHandle& sequence);
79 
82  ConstSequenceHandle GetSequence(int seq_id) const;
83 
85  void RemoveSequence(int seq_index);
87  String ToString(int width=80) const;
88 
90  int GetLength() const;
91 
94 
100 
101  int FindSequenceIndex(const String& name) const;
102 
105  void AttachView(int seq_index, const mol::EntityView& view);
106 
109  void AttachView(int seq_index, const mol::EntityView& view,
110  const String& chain_name);
111 
112 
113  mol::EntityViewPair GetMatchingBackboneViews(int idx0=0, int idx1=1) const;
115  void SetSequenceName(int seq_index, const String& name);
116 
117  void SetSequenceOffset(int seq_index, int offset);
118  int GetSequenceOffset(int seq_index);
121 
131  AlignedRegion MakeRegion(int start, int n, int master=-1) const;
132 
134  int GetCount() const;
135 
136  bool operator==(const AlignmentHandle& rhs) const;
137  bool operator!=(const AlignmentHandle& rhs) const;
138 
144  AlignedColumn operator[](int index) const;
145 
147 
149  void Cut(int start, int end);
150 
152  void Replace(const AlignedRegion& rhs, int start, int end);
157  void ShiftRegion(int start, int end, int amount, int master=-1);
158 
160  iterator begin() const;
162  iterator end() const;
163 
164  bool IsValid() const { return impl_.get()!=0; }
165 
171  Real GetCoverage(int seq_index) const;
172 
173 
174  const String& GetSequenceRole(int seq_index);
175 
176  void SetSequenceRole(int seq_index, const String& role);
177 private:
178  void CheckValidity() const;
180 };
181 
183 
192 
193 typedef std::vector<AlignmentHandle> AlignmentList;
194 
195 }}
196 
197 #endif
definition of EntityView
Definition: entity_view.hh:86
Provides access to a column in a aligned region or a sequence alignment.
represents a region in a sequence alignment
representation of a multiple sequence alignemnt consisting of two or more sequences
iterator begin() const
Column iterator start-point.
void RemoveSequence(int seq_index)
remove sequence at seq_index from alignment
void AttachView(int seq_index, const mol::EntityView &view)
attach view to given sequence
AlignmentHandle Copy() const
deep-copy multi sequence alignment
int GetCount() const
get number of sequences in alignment
int FindSequenceIndex(const String &name) const
ConstSequenceList GetSequences() const
Get list of sequences (read-only)
char GetOneLetterCode(int seq_index, int pos) const
AlignedColumnIterator iterator
void SetSequenceRole(int seq_index, const String &role)
AlignmentHandle(const impl::SequenceListImplPtr &impl)
const String & GetSequenceRole(int seq_index)
void Cut(int start, int end)
cut out half-closed interval start, end
int GetPos(int seq_index, int residue_index) const
Get position in sequence with index seq_index that corresponds to the given residue index.
mol::EntityViewPair GetMatchingBackboneViews(int idx0=0, int idx1=1) const
iterator end() const
Column iterator end-point.
int GetResidueIndex(int seq_index, int pos) const
Get residue index for seq_index and alignment position.
void ShiftRegion(int start, int end, int amount, int master=-1)
shift half-closed interval by amount
mol::ResidueView GetResidue(int seq_index, int pos) const
void SetSequenceOffset(int seq_index, int offset)
Real GetCoverage(int seq_index) const
get coverage of a specifi sequence
int GetLength() const
Get length of sequences in alignment.
void AttachView(int seq_index, const mol::EntityView &view, const String &chain_name)
attach view to given sequence
void SetSequenceName(int seq_index, const String &name)
set name of sequence
AlignedColumn operator[](int index) const
get aligned column at index
ConstSequenceHandle FindSequence(const String &name) const
find sequence by name.
void AddSequence(const ConstSequenceHandle &sequence)
Add new sequence to multiple sequence alignment.
AlignedRegion MakeRegion(int start, int n, int master=-1) const
create an aligned region.
String ToString(int width=80) const
Convert multiple sequence alignment to string.
bool operator==(const AlignmentHandle &rhs) const
ConstSequenceHandle GetSequence(int seq_id) const
Get sequence with given index.
void Replace(const AlignedRegion &rhs, int start, int end)
Replace part of an alignment.
bool operator!=(const AlignmentHandle &rhs) const
int GetSequenceOffset(int seq_index)
list of immutable sequences.
list of sequences.
float Real
Definition: base.hh:44
std::string String
Definition: base.hh:54
pointer_it< T > end(const std::vector< T > &values)
std::pair< EntityView, EntityView > EntityViewPair
Definition: entity_view.hh:349
std::vector< SequenceImplPtr > SequenceList
boost::shared_ptr< SequenceListImpl > SequenceListImplPtr
std::vector< AlignmentHandle > AlignmentList
AlignmentHandle DLLEXPORT_OST_SEQ AlignmentFromSequenceList(const SequenceList &seq_list)
convert alignment from sequence list
AlignmentHandle DLLEXPORT_OST_SEQ CreateAlignment()
Definition: base.dox:1
#define DLLEXPORT_OST_SEQ