Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
util.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 protocols/grafting/util.cc
11 /// @brief Utility functions for grafting
12 /// @author Jared Adolf-Bryfogle (jadolfbr@gmail.com)
13 /// @author Steven Lewis (smlewi@gmail.com)
14 
15 //Unit headers
17 
18 
19 //Project headers
20 #include <core/pose/Pose.hh>
21 #include <core/pose/util.hh>
25 #include <core/kinematics/util.hh>
29 //#include <core/chemical/ResidueTypeSet.hh>
30 
31 //Utility headers
32 #include <utility/vector1.hh>
33 
34 //Basic headers
35 #include <basic/Tracer.hh>
36 
37 static basic::Tracer TR("protocols.grafting");
38 
39 namespace protocols {
40 namespace grafting {
41 
42 using core::pose::Pose;
43 
44 void
45 delete_region(Pose & pose, Size const start, Size const end){
46  //Going to remove residues from pose. Resnum changes each time - so...
47  Size const num_residues(end-start+1);
48  TR << "Deleting "<< num_residues << " residues from " << start << " to "<< end << std::endl;
49 
50  for (core::Size i = 1; i <= num_residues; ++i) {
51  //pose_.conformation().delete_polymer_residue(resnum);
52  pose.conformation().delete_residue_slow(start);
53 
54  }
55 }
56 
57 
58 
59 Pose
60 return_region(Pose & pose, Size const start, Size const end){
61 
62  //Copy residues into a new pose. Uses create_subpose.
63  Pose piece;
64  core::kinematics::FoldTree new_foldtree;
65  new_foldtree.clear();
66  Size const length = end - start+1;
67  TR << "Returning "<< length <<" residues from "<< start <<" to " << end <<std::endl;
68 
69  //Get positions.
70  utility::vector1<Size> positions;
71  for (core::Size resnum = start; resnum <= end; ++resnum){
72  positions.push_back(resnum);
73  }
74 
75  //Create the New foldtree to be applied in create_subpose
76  //Simple FT for NOW.
77  new_foldtree.simple_tree(length);
78 
79 
80  core::pose::create_subpose(pose, positions, new_foldtree, piece);
81  return piece;
82 }
83 
84 Pose
85 replace_region(Pose const & to_pose, Pose const & from_pose, Size const from_pose_start_residue, Size const to_pose_start_residue, Size const insertion_length){
86  Pose combined(to_pose);
87  for (core::Size i= 0; i<= insertion_length-1; ++i) {
88  core::Size pose_num = to_pose_start_residue+i;
89  core::Size piece_num = from_pose_start_residue+i;
90  core::conformation::Residue const & piece_rsd = from_pose.residue(piece_num);
91  bool replace_backbone = true;
92 
93  combined.conformation().replace_residue(pose_num, piece_rsd, replace_backbone);
94 
95  }
96  return combined;
97 }
98 
99 ///@author Steven Lewis smlewi@gmail.com
100 ///@details brief inserts one pose into another pose, returning the product as a new value. The insert pose will be added immediately after insert_point and before insert_point_end.
101 Pose
103  Pose const & scaffold_pose,
104  Pose const & insert_pose,
105  core::Size const insert_point,
106  core::Size const insert_point_end
107 ){
108  //local copies
109  core::pose::Pose scaffold(scaffold_pose);
110  core::pose::Pose insert(insert_pose);
111  core::kinematics::FoldTree original_scaffold_tree = scaffold.fold_tree();
112  core::Size const insert_length = insert.total_residue();
113  //strip termini variants from insert if necessary
117 
118  core::Size const insert_start(insert_point+1); //this will be first residue of the inflexible insert
119  core::Size const insert_end(insert_point+insert_length); //this will be the last residue of the inflexible insert
120 
121  //Just in case someone wants to do something crazy and add something to termini on two different chains.
122  //Not that it's been tested...
125 
126 
127 
128  TR << "insert_point " << insert_point << std::endl;
129  TR << "insert_start " << insert_start << std::endl;
130  TR << "insert_end " << insert_end << std::endl;
131  TR << "insert_length " << insert_length << std::endl;
132 
133  //Fold tree allows insertion into scaffold (all via jump)
135  core::pose::Pose combined(scaffold);
136  core::kinematics::FoldTree inserting_tree(combined.total_residue());
137  inserting_tree.clear();
138  inserting_tree.add_edge(Edge(1, insert_point, Edge::PEPTIDE));
139  inserting_tree.add_edge(Edge(insert_point_end, combined.total_residue(), Edge::PEPTIDE));
140  inserting_tree.add_edge(Edge(insert_point, insert_point_end, 1));
141  inserting_tree.reorder(1);
142  TR << inserting_tree << std::endl;
143  combined.fold_tree(inserting_tree);
144 
145  //insert insert residues by jump (just to get them in)
146  for (core::Size i = 1; i <= insert_length; ++i){
147  combined.insert_residue_by_jump(insert.residue(i), insert_point+i, insert_point);
148  }
149 
150  //Set a fold tree.
151  core::kinematics::FoldTree new_tree = core::kinematics::remodel_fold_tree_to_account_for_insertion(original_scaffold_tree, insert_point, insert_length);
152  combined.fold_tree(new_tree);
153  return combined;
154 }
155 
156 
157 
158 }
159 }