Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JumpingFrame.cc
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 core/fragments/Frame.cc
11 /// @brief set of fragments for a certain alignment frame
12 /// @author Oliver Lange (olange@u.washington.edu)
13 /// @date Wed Oct 20 12:08:31 2007
14 
15 
16 // Unit Headers
18 
19 // Package Headers
20 
21 // Project Headers
23 //#include <core/chemical/ChemicalManager.hh>
24 //#include <core/chemical/ResidueTypeSet.hh>
25 //#include <core/conformation/ResidueFactory.hh>
26 
27 // ObjexxFCL Headers
28 #include <ObjexxFCL/format.hh>
29 
30 #include <utility/vector1.hh>
31 
32 
33 // Utility headers
34 #include <utility/excn/Exceptions.hh>
35 
36 
37 namespace core {
38 namespace fragment {
39 
40 using namespace ObjexxFCL::format;
41 
42 // FragDataOP generate_fragdata( SingleResidueFragDataOP frag_res_type, SingleResidueFragDataOP jump_frag_type ) {
43 // if ( nr_frags() ) return frag_data_.front()->clone();
44 // Size const length( bWithTorsion ? 3 : 1 );
45 // if ( bWithTorsion ) {
46 // BBTorsionSRFDOP start = new BBTorsionSRFD( 3, 'E', 'X' );
47 // start->set_torsion( 1, it->phi( iStart ) );
48 // start->set_torsion( 2, it->psi( iStart ) );
49 // start->set_torsion( 3, it->omega( iStart ) );
50 
51 // frags.back()->add_residue( start );
52 // }
53 // frags.back()->add_residue( new JumpSRFD( it->rt_, it->atoms_downstream_, it->atoms_upstream_, 'X' ) );
54 // if ( bWithTorsion ) {
55 // BBTorsionSRFDOP stop = new BBTorsionSRFD( 3, 'E', 'X' );
56 // stop->set_torsion( 1, it->phi( iStop ) );
57 // stop->set_torsion( 2, it->psi( iStop ) );
58 // stop->set_torsion( 3, it->omega( iStop ) );
59 
60 // frags.back()->add_residue( stop );
61 // }
62 
63 // }
64 bool
66  bool success = Parent::align( map );
67  for ( PosList::iterator it = pos_.begin(),
68  eit = pos_.end(); it!=eit && success; ++it ) {
69  Size newpos( map[ *it ] );
70  if ( newpos > 0 ) {
71  *it = newpos;
72  } else return false;
73  }
74  return success;
75 }
76 
77 void NonContinuousFrame::show( std::ostream &out ) const {
78  using namespace ObjexxFCL::format;
79  out << type() << " ";
80  show_pos( out );
81  out << std::endl;
82  show_fragments( out );
83 }
84 
85 void NonContinuousFrame::read( std::istream &in ) {
86  using namespace ObjexxFCL::format;
87  Size pos;
88  pos_.clear();
89  std::string line;
90  getline( in, line );
91  std::istringstream line_stream( line );
92  while ( line_stream >> pos ) {
93  pos_.push_back( pos );
94  }
95  init_length( pos_.front(), pos_.back(), pos_.size() );
96 }
97 
98 void NonContinuousFrame::show_pos( std::ostream &out ) const {
99  for ( PosList::const_iterator it = pos_.begin(),
100  eit = pos_.end(); it!=eit; ++it ) {
101  out << RJ( 3, *it ) << " ";
102  }
103 }
104 
106  using core::Size;
107  int offset = setting-pos_.front();
108  shift_by( offset );
109 }
110 
111 void NonContinuousFrame::shift_by( int offset ) {
112  Parent::shift_by( offset );
113  for ( PosList::iterator it = pos_.begin(),
114  eit = pos_.end(); it!=eit; ++it ) {
115  int new_pos = *it + offset;
116  if ( new_pos < 1 ) {
117  std::ostringstream msg;
118  msg << "offset " << offset << " would shift at least one position of Frame " << *this << " to negative or zero" << std::endl;
119  throw utility::excn::EXCN_RangeError( msg.str() );
120  }
121  *it = new_pos;
122  }
123 }
124 
125 
126 // --- cloning with frags is taken care of correctly by base-class
127 // it is enough that clone() itself is virtually overloaded
128 /// @brief clone method, new frame with same alignment position, fragments are not copied!
130  return FrameOP( new NonContinuousFrame( start(), end(), length() ) );
131 }
132 
133 // /// @brief clone method, new frame with same alignment position, fragments are not copied!
134 // NonContinuousFrameOP NonContinuousFrame::clone_with_frags() const {
135 // NonContinuousFrameOP newFrame = clone();// new Frame( start(), end(), length() );
136 // *newFrame = *this; //usually that is enough
137 // return newFrame;
138 // }
139 
140 // /// @brief clone method, new frame with same alignment position, one fragments is copied as template ( valid() == false )
141 // NonContinuousFrameOP NonContinuousFrame::clone_with_template() {
142 // NonContinuousFrameOP newFrame = clone();// new Frame( start(), end(), length() );
143 // if ( nr_frags() ) {
144 // newFrame->frag_list_.push_back( frag_list_[ 1 ]->clone() );
145 // newFrame->frag_list_[ 1 ]->set_valid( false );
146 // }
147 // return newFrame;
148 // }
149 
150 
151 }
152 }
virtual bool align(core::id::SequenceMapping const &map)
change frames residue numbers accoriding to map
Definition: JumpingFrame.cc:65
virtual void read(std::istream &)
Definition: JumpingFrame.cc:85
virtual void shift_by(int offset)
shift frame by offset relative to current start position ( change end accordingly ) ...
platform::Size Size
Definition: types.hh:30
JumpingFrame is a discontinuous frame i.e, the SRFDs stored in the FragData objects can be applied to...
Definition: JumpingFrame.hh:54
void show_pos(std::ostream &out) const
Definition: JumpingFrame.cc:98
utility::pointer::shared_ptr< Frame > FrameOP
Definition: Frame.fwd.hh:28
virtual void show(std::ostream &) const
Definition: JumpingFrame.cc:77
virtual FrameOP clone() const
clone method, new frame with same alignment position, fragments are not copied!
virtual void shift_to(core::Size setting)
shift to new start position ( change end accordingly )