26 #include <basic/Tracer.hh>
27 #include <basic/datacache/BasicDataCache.hh>
28 #include <basic/database/sql_utils.hh>
37 #include <utility/vector1.hh>
38 #include <utility/sql_database/DatabaseSessionManager.hh>
41 #include <cppdb/frontend.h>
47 static basic::Tracer
TR(
"protocols.docking.util");
54 using std::min_element;
57 using std::stringstream;
58 using cppdb::statement;
61 using utility::sql_database::sessionOP;
62 using basic::database::safely_prepare_statement;
63 using basic::database::safely_read_from_database;
98 string const & partner_chainID,
103 movable_jumps.clear();
106 utility_exit_with_message(
"Attempting to setup foldtree between interface partners, however, the pdb_info object associated with the pose does not exits.");
112 if ( partner_chainID ==
"_") {
115 if(f.num_jump() == 0){
116 utility_exit_with_message(
"Attempting to auto-detect interface partner chains, however the pose contains no jumps.");
118 cutpoint = f.cutpoint_by_jump(1);
119 movable_jumps.push_back(1);
121 char first_chain_second_partner;
122 for (
Size i=1; i<=partner_chainID.length()-1; i++ ) {
123 if (partner_chainID[i-1] ==
'_') {
124 first_chain_second_partner = partner_chainID[i];
128 if ( pdb_info->chain( i ) == first_chain_second_partner ) {
134 utility_exit_with_message(
135 "Attempting to setup foldtree between interface partners, "
136 "however, the cutpoint could not be identified because "
137 "the pdb chain identifier could not be found for "
138 "the first chain of the second partner");
142 for (
Size i=1; i<=f.num_jump(); ++i) {
143 Size const current_cutpoint = f.cutpoint_by_jump(i);
144 if( current_cutpoint == cutpoint ) {
145 movable_jumps.push_back( i );
178 Size const interface_id,
179 sessionOP db_session,
184 " partner.partner_id AS partner,\n"
185 " chain.chain_id AS chain\n"
187 " interface_partners AS partner,\n"
188 " interface_partner_chains AS chain\n"
190 " partner.interface_id = ? AND\n"
191 " chain.partner_id = partner.partner_id;");
192 statement stmt(safely_prepare_statement(sele, db_session));
193 stmt.bind(1, interface_id);
194 result res(safely_read_from_database(stmt));
196 map<Size, vector1< Size > > partner_to_chains;
200 res >> partner >> chain;
201 partner_to_chains[partner].push_back(chain);
215 if(partner_to_chains.size() != 2){
216 stringstream error_msg;
218 <<
"The current implementation of setup_foldtree requires "
219 <<
"that there be exactly two chains at an interface, however, "
220 <<
"'" << partner_to_chains.size() <<
"' partners were given.";
221 utility_exit_with_message(error_msg.str());
229 p_cs = partner_to_chains.begin(),
230 p_cs_end = partner_to_chains.end();
231 p_cs != p_cs_end; ++p_cs){
233 first_and_last_chains.push_back(
235 *min_element(p_cs->second.begin(), p_cs->second.end()),
236 *max_element(p_cs->second.begin(), p_cs->second.end())));
239 Size first_chain_second_partner;
240 if(first_and_last_chains[1].second < first_and_last_chains[2].first){
241 first_chain_second_partner = first_and_last_chains[2].first;
242 }
else if(first_and_last_chains[2].second < first_and_last_chains[1].first){
243 first_chain_second_partner = first_and_last_chains[1].first;
245 utility_exit_with_message(
246 "The current implementation of setup_foldtree requires "
247 "that the chains of one partner come before all "
248 "the chains of the second partner.");
252 if ( (
Size)pose.
chain(i) == first_chain_second_partner ) {
258 utility_exit_with_message(
259 "Attempting to setup foldtree between interface partners, "
260 "however, the cutpoint could not be identified because "
261 "the pdb chain identifier could not be found for "
262 "the first chain of the second partner");
265 movable_jumps.clear();
269 for (
Size i=1; i<=f.num_jump(); ++i) {
270 Size const current_cutpoint = f.cutpoint_by_jump(i);
271 if( current_cutpoint == cutpoint ) {
272 movable_jumps.push_back( i );
287 runtime_assert_string_msg(
288 movable_jumps.size() > 0,
289 "Unable to set up interface foldtree because there are no movable jumps");
302 if( movable_jumps.size() == 1 ) {
307 TR.Debug <<
"cutpoint: " << cutpoint << std::endl;
308 TR.Debug <<
"jump1: " << jump_pos1 << std::endl;
309 TR.Debug <<
"jump2: " << jump_pos2 << std::endl;
314 f.new_jump( jump_pos1, jump_pos2, cutpoint);
315 movable_jumps.clear();
316 movable_jumps.push_back( 1 );
318 Size chain_begin(0), chain_end(0);
321 chain_end = cutpoint;
322 chain_begin = conformation.chain_begin( pose.
chain(chain_end) );
323 while (chain_begin != 1){
324 chain_end = chain_begin-1;
325 f.new_jump( chain_end, chain_begin, chain_end);
326 chain_begin = conformation.chain_begin( pose.
chain(chain_end) );
330 chain_begin = cutpoint+1;
331 chain_end = conformation.chain_end( pose.
chain(chain_begin) );
333 chain_begin = chain_end+1;
334 f.new_jump( chain_end, chain_begin, chain_end);
335 chain_end = conformation.chain_end( pose.
chain(chain_begin) );
347 std::sort( movable_jumps.begin(), movable_jumps.end() );
349 Size const base_cutpoint = cutpoint;
351 for(DockJumps::const_iterator
352 curr_jump = movable_jumps.begin(),
353 last_movable_jump = movable_jumps.end();
354 curr_jump != last_movable_jump; ++curr_jump ) {
355 Size const curr_cutpoint = f.cutpoint_by_jump( *curr_jump );
356 Size const chain_begin = conformation.chain_begin( pose.
chain(curr_cutpoint+1) );
357 Size const chain_end = conformation.chain_end( pose.
chain(curr_cutpoint+1) );
360 <<
"Adjusting Jump (cut) for #" << *curr_jump
361 <<
"(" << curr_cutpoint <<
"): "
362 <<
"begin " << chain_begin
363 <<
" end " << chain_end
364 <<
" base_cutpoint " << base_cutpoint
365 <<
" base_jump_pos " << base_jump_pos
366 <<
" moving_jump_pos " << moving_jump_pos << endl;
367 f.slide_jump( *curr_jump, base_jump_pos, moving_jump_pos );
373 runtime_assert( f.check_fold_tree() );
378 using namespace core::scoring;
379 using namespace protocols::scoring;