Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SequenceMapping.hh
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file
11 /// @brief
12 /// @author
13 
14 #ifndef INCLUDED_core_id_SequenceMapping_hh
15 #define INCLUDED_core_id_SequenceMapping_hh
16 
17 // Unit headers
19 
20 // Project headers
22 #include <core/types.hh>
23 
24 // Utility headers
25 #include <utility/pointer/ReferenceCount.hh>
26 #include <utility/exit.hh>
27 
28 // C++ headers
29 // AUTO-REMOVED #include <iostream>
30 #include <string>
31 
32 #include <utility/vector1_bool.hh>
33 
34 
35 namespace core {
36 namespace id {
37 
39 
40 public:
41 // constructors, destructors and assignment operator
42  /// @brief ctor
44  size2_(0)
45  {}
46 
47  /// @brief ctor
48  SequenceMapping( Size const s1, Size const s2 ) :
49  size2_(s2),
50  mapping_(s1,0)
51  {}
52 
53  /// @brief ctor
55 
56  /// @brief convenience constructor from LengthEvent
58 
59  /// @brief dtor
60  virtual ~SequenceMapping();
61 
62  /// @brief copy constructor
63  SequenceMapping( SequenceMapping const & src );
64 
66  operator=( SequenceMapping const & src );
67 
68 public:
69 
70  /// @brief resize
71  void resize( Size const s1, Size const s2 );
72 
73  /// @brief go from an A->B mapping to a B->A mapping
74  void reverse();
75 
76  /// @brief Apply a B->C mapping to the current A->B mapping to get an A->C mapping
77  /// i.e. smap[j] becomes smap_to_add[ smap[j] ]
78  void downstream_combine( core::id::SequenceMapping const & smap_to_add );
79 
80  /// @brief Apply a C->A mapping to the current A->B mapping to get a C->B mapping
81  /// i.e. smap[j] becomes smap[ smap_to_add[ j ] ]
82  void upstream_combine( core::id::SequenceMapping const & smap_to_add );
83 
84  ///@brief size of target sequence
85  Size size1() const;
86 
87  ///@brief size of aligned sequence ???
88  Size size2() const;
89 
90  //@brief the pose might have a missing N-terminal offset the sequence mapping accordingly
91  //NOTE: set_offset( 5) followed by set_offset( -5 ) might not be an identity operation:
92  //if residues are pushed below zero... there is no coming back.
93  void set_offset( int setting );
94 
95  bool all_aligned() const;
96 
97  bool is_identity() const;
98  bool is_identity_ignore_gaps() const;
99 
100  void size2( Size const s2 );
101 
102  void push_back( Size const al );
103 
104  void delete_source_residue( Size const pos1 );
105 
106  void show() const;
107 
108  void show( std::ostream & output ) const;
109 
110  void insert_source_residue( Size const pos1 );
111 
112  void insert_aligned_residue( Size const pos1, Size const pos2 );
113 
114  /// @brief same as insert_aligned_residue, but a couple of extra checks on size1 and size2.
115  void insert_aligned_residue_safe( Size const pos1, Size const pos2 );
116 
117  void insert_target_residue( Size const pos );
118 
119  void delete_target_residue( Size const pos );
120 
121  void clear();
122 
123  // residue of aligned sequence at target position pos1
124  Size operator[]( Size const pos1 ) const;
125  Size & operator[]( Size const pos1 );
126 
127  /// @brief Equality operator.
128  bool operator==( SequenceMapping const & other ) const;
129 
130  /// @brief Construct an identity mapping, which means that for all positions,
131  /// i in seq1 maps to i in seq2.
132  inline
133  static
135  identity( Size const size )
136  {
137  SequenceMapping id( size, size );
138  for ( Size i=1; i<= size; ++i ) {
139  id[i] = i;
140  }
141  runtime_assert( id.is_identity() && id.size1() == size );
142  return id;
143  }
144 
146  return mapping_;
147  }
148 
150  mapping_ = mapping;
151  }
152 
153  std::string to_string() const;
154 
155 private:
156  Size size2_; // length of second sequence
157  utility::vector1< Size > mapping_; // mapping_[ residue_i ] = residue_j
158 }; // class SequenceMapping
159 
160 inline std::ostream & operator<< (
161  std::ostream & out,
162  SequenceMapping const & map
163 ) {
164  map.show( out );
165  return out;
166 }
167 
168 /// @brief make one sequence mapping out of all input ones
169 /// utility function added by flo, feb 2011
173 );
174 
175 /// @brief combine the input sequence mappings into one
176 /// utility function added by flo, feb 2011
177 void
180  core::id::SequenceMapping const & smap_to_add
181 );
182 
183 } // id
184 } // core
185 
186 #endif