Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DnaChains.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 DnaChains.cc
11 /// @author ashworth
12 
14 
16 #include <core/pose/Pose.hh>
17 #include <core/pose/PDBInfo.hh>
18 
19 #include <ObjexxFCL/format.hh> // I()
20 
21 #include <utility/vector1.hh>
22 
23 
24 using utility::vector1;
25 
26 namespace protocols {
27 namespace dna {
28 
29 using namespace ObjexxFCL::fmt;
30 using namespace core;
31 
32 DnaChains::DnaChains() : utility::pointer::ReferenceCount() {}
33 
35 
37  : utility::pointer::ReferenceCount()
38 {
39  positions_ = other.positions();
40 }
41 
43 {
44  return new DnaChains( *this );
45 }
46 
47 bool
48 DnaChains::contains( Size index ) const
49 {
50  if ( is_top(index) ) {
51  runtime_assert( (*this)[ index ].top() == index );
52  return true;
53  }
54  // bottom strand check
55  for ( DnaPositions::const_iterator pos( positions_.begin() );
56  pos != positions_.end(); ++pos ) {
57  if ( index == pos->second.bottom() ) return true;
58  }
59  return false;
60 }
61 
62 void
64  pose::Pose const & pose,
65  std::ostream & os
66 ) const
67 {
68  os << "There are " << positions_.size() << " dna positions:" << '\n';
69  for ( DnaPositions::const_iterator iter( positions_.begin() );
70  iter != positions_.end(); ++iter ) {
71 
72  Size const top_i( iter->first );
73  DnaPosition const & pos( iter->second );
74  runtime_assert( top_i == pos.top() );
75  os << I( 4, top_i );
76  if ( pose.pdb_info() ) {
77  os << " (pdb " << pose.pdb_info()->chain( top_i ) << " "
78  << I( 4, pose.pdb_info()->number( top_i ) ) << ")";
79  }
80  os << pose.residue_type( top_i ).name3();
81  if ( pos.paired() ) {
82  Size const bot_i( pos.bottom() );
83  os << " <=>" << pose.residue_type( bot_i ).name3() << " " << I( 4, bot_i );
84  if ( pose.pdb_info() ) {
85  os << " (pdb " << pose.pdb_info()->chain( bot_i ) << " "
86  << I( 4, pose.pdb_info()->number( bot_i ) ) << ")";
87  }
88  }
89  else os << " (unpaired)";
90  os << '\n';
91  }
92  os << std::endl;
93 }
94 
95 } // namespace dna
96 } // namespace protocols