Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FabConstraint.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 src/core/scoring/constraints/FabConstraint.cc
11 /// @brief This class is specific to antibodies and penalizes presence of non-cdr residues
12 /// @brief at Antigen-Antibody interfaces. It has been ported from Fab constraint in rosetta++
13 /// @brief which uses a constant constraint score of 0.5 for flanking residues)
14 /// @author Krishna Kilambi (kkpraneeth@jhu.edu, April 2012)
15 
22 
23 
24 #include <core/id/AtomID.hh>
26 #include <core/pose/Pose.hh>
27 #include <core/pose/PDBInfo.hh>
28 #include <core/pose/util.hh>
29 
30 #include <basic/Tracer.hh>
31 
32 #include <utility/vector1.hh>
33 
34 //Auto Headers
37 #include <string>
38 
39 static basic::Tracer TR("core.scoring.constraints.FabConstraint");
40 
41 namespace core {
42 namespace scoring {
43 namespace constraints {
44 
45 ////////////////////////////////////////////////////////////////////////////////////////////////////
46 /// @brief Constructor
49 {}
50 ////////////////////////////////////////////////////////////////////////////////////////////////////
51 /// @brief Constructor
53 MultiConstraint(cst_in)
54 {}
55 
56 void
57 FabConstraint::show(std::ostream& out) const
58 {
59  out << "FabConstraint is an AmbiguousConstraint containing the following " << member_constraints().size() << " constraints: " << std::endl;
60  for( ConstraintCOPs::const_iterator cst_it = member_constraints().begin(); cst_it != member_constraints().end(); cst_it++){
61  (*cst_it)->show(out);
62  }
63 
64  out << " ...all member constraints of this FabConstraint shown." << std::endl;
65 }
66 
67 void
69  std::istream & data,
70  core::pose::Pose const & pose,
71  FuncFactory const & /*func_factory*/
72 ) {
77  std::string antchains;
78  Size flag(1);
79 
80 
81  std::string line;
82  while(getline(data, line)){
83  std::string entry1, entry2, entry3, cstname;
84  std::istringstream line_stream(line);
85  if (flag){
86  line_stream >> entry1 >> entry2 >> entry3;
87  flag = 0;
88  }
89  else{
90  line_stream >> cstname >> entry1 >> entry2 >> entry3;
91  }
92  TR.Info << "Entry1:" << entry1 << " Entry2:" << entry2 << " Entry3:" << entry3 << std::endl;
93  tempres1.push_back(entry1);
94  tempres2.push_back(entry2);
95  antchains = entry3;
96  }
97 
98  for (Size n=1; n<= tempres1.size(); ++n){
99  res1.push_back(pose_res_no(pose, tempres1[n]));
100  res2.push_back(pose_res_no(pose, tempres2[n]));
101  }
102 
103  TR.Info << "Penalizing residues which are not in range "
104  << res1[1] << "-" << res2[1] << ", "
105  << res1[2] << "-" << res2[2] << ", "
106  << res1[3] << "-" << res2[3] << ", "
107  << res1[4] << "-" << res2[4] << ", "
108  << res1[5] << "-" << res2[5] << ", "
109  << res1[6] << "-" << res2[6]
110  << " and at interface with antigen chains " << antchains << std::endl;
111 
112  setup_csts(pose, res1, res2, antchains);
113 
114  if (data.good()) {
115  //chu skip the rest of line since this is a single line defintion.
116  while( data.good() && (data.get() != '\n') ) {}
117  if (!data.good()) data.setstate( std::ios_base::eofbit );
118  }
119 } // read_def
120 
121 //return pose residue no
122 Size
124  core::pose::Pose const & pose,
125  std::string tempres
126 ) {
127  Size pose_resnum;
128  Size resnum;
129  std::string residue;
130  char ins_code;
131  char chain = tempres[tempres.length()-1];
132 
133  //check if the residue has an insertion code
134  if (isdigit(tempres[tempres.length()-2])){
135  residue = tempres.substr(0,tempres.length()-1);
136  resnum = atoi(residue.c_str());
137  pose_resnum = pose.pdb_info()->pdb2pose(chain,resnum);
138  }
139  else{
140  ins_code = tempres[tempres.length()-2];
141  residue = tempres.substr(0,tempres.length()-2);
142  resnum = atoi(residue.c_str());
143  pose_resnum = pose.pdb_info()->pdb2pose(chain,resnum, ins_code);
144  }
145  return pose_resnum;
146 }
147 
148 //Build a vector of the associated penalty scores for each antibody residue in the sequence
149 //with antibody residue pose numbers as indices
152  Size start_res,
153  Size stop_res,
156 ) {
157  utility::vector1<Real> penalty;
158  Size n = 1;
159  for (Size m = 1 ; m <= stop_res ; ++m){
160  if (m >= start_res && m <= stop_res){
161  penalty.push_back(1.5);
162  //if you hit the end of the flank region at c-term end of a cdr, go back and reassign the correct penalties
163  //for cdrs and cdr flanking regions
164  if (m == res2[n]+2){
165  penalty[res1[n]-2] = 0.5;
166  penalty[res1[n]-1] = 0.5;
167  penalty[res2[n]+1] = 0.5;
168  penalty[res2[n]+2] = 0.5;
169  for (Size p = res1[n] ; p <= res2[n] ; ++p){
170  penalty[p] = 0.0;
171  }
172  if(n < res2.size()) n++;
173  }
174  }
175  else{
176  penalty.push_back(0);
177  }
178  }
179  return penalty;
180 }
181 
182 
183 void
185  core::pose::Pose const & pose,
188  std::string antchains
189 ) {
190  utility::vector1<Real> abpenalty;
191  ConstantFuncOP flankpenaltyfunc (new ConstantFunc(0.5));
192  ConstantFuncOP noncdrpenaltyfunc (new ConstantFunc(1.5));
193 
194  //set up antigen and antibody chain limits
195  Size ant_start_chain = pose::get_chain_id_from_chain(antchains[0], pose);
196  Size ant_stop_chain = pose::get_chain_id_from_chain(antchains[antchains.length()-1], pose);
197  Size ab_start_chain = pose.chain(res1[1]);
198  Size ab_stop_chain = pose.chain(res1[res1.size()]);
199 
200  Size ant_start_res = pose.conformation().chain_begin(ant_start_chain);
201  Size ant_stop_res = pose.conformation().chain_end(ant_stop_chain);
202  Size ab_start_res = pose.conformation().chain_begin(ab_start_chain);
203  Size ab_stop_res = pose.conformation().chain_end(ab_stop_chain);
204 
205  abpenalty = calc_penalty_vec(ab_start_res, ab_stop_res, res1, res2);
206 
207 /* TR.Info << "Abpenalty Vector: ";
208  for (Size p = 1 ; p <= abpenalty.size() ; ++p){
209  TR.Info << abpenalty[p] << " ";
210  }
211  TR.Info << std::endl;*/
212 
213  //Find residues at interface and setup constraints
214  //loop over all antibody residues
215  for (Size i = ab_start_res ; i <= ab_stop_res ; ++i){
216  id::AtomID atom1(pose.residue_type(i).atom_index("CA"),i);
217  //now loop over all antigen residues
218  for (Size j = ant_start_res ; j <= ant_stop_res ; ++j){
219  //check for residues at interface
220  if (pose.residue(i).xyz("CA").distance(pose.residue(j).xyz("CA")) < 8.0){
221  TR.Info << "Residue " << pose.residue(i).name3() << " " << pose.pdb_info()->pose2pdb(i) << " is at interface" << std::endl;
222  id::AtomID atom2(pose.residue_type(j).atom_index("CA"),j);
223  runtime_assert(atom1.valid() && atom2.valid());
224  if (abpenalty[i] == 1.5){
225  add_individual_constraint( new AtomPairConstraint(atom1,atom2,noncdrpenaltyfunc));
226  }
227  else if (abpenalty[i] == 0.5){
228  add_individual_constraint( new AtomPairConstraint(atom1,atom2,flankpenaltyfunc));
229  }
230  break;
231  }
232  }
233 
234  }
235 
236 } // setup_csts
237 
238 } // constraints
239 } // scoring
240 } // core
241 
242