15 #include <basic/Tracer.hh>
43 #include <basic/options/option.hh>
44 #include <basic/options/keys/in.OptionKeys.gen.hh>
45 #include <basic/options/keys/cm.OptionKeys.gen.hh>
56 #include <utility/vector1.hh>
57 #include <utility/string_util.hh>
58 #include <utility/file/FileName.hh>
59 #include <utility/file/file_sys_util.hh>
66 #include <numeric/random/random.hh>
72 namespace comparative_modeling {
74 #define NO_LOOP_SIZE_CST 0
79 static numeric::random::RandomGenerator
RG(298211);
80 static basic::Tracer
tr(
"protocols.comparative_modeling.util");
83 using namespace basic::options;
84 using namespace basic::options::OptionKeys;
85 using namespace core::sequence;
90 if ( option[ cm::aln_format ]() ==
"mini" ) {
92 }
else if ( option[ cm::aln_format ]() ==
"grishin" ) {
96 "Error: don't recognize alignment format " +
97 option[ cm::aln_format ]() +
"!"
99 utility_exit_with_message( msg );
102 runtime_assert( alns.size() > 0 );
123 assert(unaligned_regions);
125 const Size query_idx = 1;
126 const Size templ_idx = 2;
130 for (
Size resi = 1; resi <= num_residues; resi++) {
131 Size t_resi = mapping[resi];
133 bool const gap_exists(
135 (resi > 1 && mapping[ resi - 1 ] != t_resi - 1) ||
136 (resi < num_residues && mapping[ resi + 1 ] != t_resi + 1));
138 if (gap_exists) unaligned_residues.push_back( resi );
146 unaligned_residues.clear();
148 const Loop& loop = *i;
150 unaligned_residues.push_back(j);
154 vector1<Size> bounded_unaligned_residues(unaligned_residues);
155 for (
Size i = 2; i <= unaligned_residues.size(); ++i) {
156 Size prev_residue = unaligned_residues[i - 1];
157 Size curr_residue = unaligned_residues[i];
160 Size delta = curr_residue - prev_residue - 1;
161 if (delta == 0 || delta >= min_size)
164 for (
Size j = (prev_residue + 1); j <= (curr_residue - 1); ++j)
165 bounded_unaligned_residues.push_back(j);
167 std::sort(bounded_unaligned_residues.begin(), bounded_unaligned_residues.end());
180 Size const query_idx( 1 );
181 Size const templ_idx( 2 );
185 tr.Debug <<
"called loops_from_alignment with arguments:" << std::endl;
186 tr.Debug << nres << std::endl;
187 tr.Debug << aln << std::endl;
188 tr.Debug << min_loop_size << std::endl;
189 mapping_.show(
tr.Debug );
191 for (
Size resi = 1; resi <= nres; resi++ ) {
192 Size t_resi = mapping_[ resi ];
195 bool const gap_exists(
197 ( resi > 1 && mapping_[ resi - 1 ] != t_resi - 1 ) ||
198 ( resi < nres && mapping_[ resi + 1 ] != t_resi + 1 )
200 if ( gap_exists ) unaligned_residues.push_back( resi );
203 tr.flush_all_channels();
223 Size const query_idx( 1 );
224 Size const templ_idx( 2 );
227 tr.Debug <<
"called loops_from_multiple_alignments with arguments:" << std::endl;
228 tr.Debug << nres1 << std::endl;
229 tr.Debug << aln1 << std::endl;
230 tr.Debug << nres1 << std::endl;
231 tr.Debug << aln2 << std::endl;
232 tr.Debug << min_loop_size << std::endl;
233 mapping1_.show(
tr.Debug );
234 mapping2_.show(
tr.Debug );
236 for (
Size resi = 1; resi <= nres1; resi++ ) {
237 Size t_resi1 = mapping1_[ resi ];
243 ( resi > 1 && mapping1_[ resi - 1 ] != t_resi1 - 1 ) ||
244 ( resi < nres1 && mapping1_[ resi + 1 ] != t_resi1 + 1 );
249 Size t_resi2 = mapping2_[ t_resi1 ];
250 gap_exists = t_resi2 == 0 ||
251 ( t_resi1 > 1 && mapping2_[ t_resi1 - 1 ] != t_resi2 - 1 ) ||
252 ( t_resi1 < nres2 && mapping2_[ t_resi1 + 1 ] != t_resi2 + 1 );
256 unaligned_residues.push_back( resi );
259 tr.flush_all_channels();
276 if ( unaligned_residues.size() == 0 ) {
277 tr.Warning <<
"No unaligned residues, no loops found." << std::endl;
281 Size loop_stop ( *unaligned_residues.begin() );
282 Size loop_start( *unaligned_residues.begin() );
286 end = unaligned_residues.end();
287 next !=
end; ++it, ++next
289 tr.Debug <<
"residue " << *it <<
" is unaligned." << std::endl;
290 if ( *next - *it > 1 ) {
293 while ( (loop_stop - loop_start + 1) < min_loop_size ) {
294 if ( loop_stop < nres )
296 if ( loop_start > 1 && (loop_stop - loop_start + 1) < min_loop_size )
299 tr.Debug <<
"adding loop from " << loop_start <<
" to " << loop_stop
302 query_loops->add_loop( loop, 1 );
308 loop_stop = ( *(unaligned_residues.end() - 1) );
310 while ( (loop_stop - loop_start + 1) < min_loop_size ) {
311 if ( loop_stop < nres ) ++loop_stop;
312 if ( loop_start > 1 ) --loop_start;
314 tr.Debug <<
"adding loop from " << loop_start <<
" to " << loop_stop
317 query_loops->add_loop( loop , 1 );
319 tr.flush_all_channels();
336 dynamic_cast<core::conformation::symmetry::SymmetricConformation &> ( query_pose.
conformation()) );
338 nres = symm_info->num_independent_residues();
342 for ( Size i = 1; i <= nres - 1; ++i ) {
348 if ( dist > chainbreak_cutoff ) {
349 residues_near_chainbreak.push_back( i );
354 if ( residues_near_chainbreak.size() == 0 ) {
355 tr.Warning <<
"No chainbreaks found, so not picking any loops!"
363 residues_near_chainbreak,
374 using namespace basic::options;
375 using namespace basic::options::OptionKeys;
383 if ( my_loops->size() == 0 ) {
384 tr.Debug <<
"no loops found." << std::endl;
393 bool closed(
false );
394 for (
core::Size iter = 1; !closed && iter <= max_rebuild; iter++ ) {
396 loop_mover_name, my_loops
398 loop_mover->apply( query_pose );
405 if ( my_loops->size() == 0 ) {
406 tr.Debug <<
"closed loops on iteration " << iter <<
" ." << std::endl;
427 if ( !anchor_atom_dest.
valid() ) {
428 tr.Error <<
"Error: can't place ligands. "
429 <<
"Destination anchor atom is not valid!" << anchor_atom_dest
433 if ( !anchor_atom_source.
valid() ) {
434 tr.Error <<
"Error: can't place ligands. "
435 <<
"Source anchor atom is not valid! (" << anchor_atom_source <<
")"
451 anchor_atom_source.
rsd(),
455 anchor_atom_source.
rsd(),
459 tr.Debug <<
"adding ligand residues to fold-tree" << std::endl;
462 for (
Size jj = 1; jj <= ligand_indices.size(); ++jj ) {
463 tr.Error <<
"adding " << jj << std::endl;
465 anchor_atom_source.
rsd(),
466 ligand_indices[jj].rsd(),
467 static_cast< int > (jj),
468 anchor_atom_source.
atom(),
469 ligand_indices[jj].atom(),
472 tr.Error << out_edge << std::endl;
481 for (
Size jj = 1; jj <= ligand_indices.size(); ++jj ) {
483 source_pose.
residue( ligand_indices[jj].rsd() ),
484 anchor_atom_dest.
rsd(),
485 anchor_atom_dest.
atom(),
486 ligand_indices[jj].atom()
489 static_cast< int > (jj),
490 source_pose.
jump( static_cast< int > (jj) )
498 using namespace core::pose;
499 using namespace basic::options;
500 using namespace basic::options::OptionKeys;
502 if ( !psipred_ss2_ok ) {
503 std::string dssp_name( option[ in::file::dssp ]().name() );
515 using namespace basic::options;
516 using namespace basic::options::OptionKeys;
519 option[ in::file::template_pdb ]()
524 return template_poses;
531 std::map< std::string, core::pose::Pose >
540 using namespace core::chemical;
543 map< string, Pose > poses;
546 for ( iter it = fn_list.begin(),
end = fn_list.end(); it !=
end; ++it ) {
550 string name = utility::file_basename( *it );
551 name = name.substr( 0, 5 );
566 using namespace basic::options;
567 using namespace basic::options::OptionKeys;
568 using namespace core::sequence;
571 FileName fn1( option[ in::file::pssm ]()[1] );
572 FileName fn2( option[ in::file::pssm ]()[2] );
573 string const aligner_type( option[ cm::aligner ]() );
574 string const seq_score( option[ cm::seq_score ]()[1] );
575 Real const min_gap_open( option[ cm::min_gap_open ]() );
576 Real const max_gap_open( option[ cm::max_gap_open ]() );
577 Real const min_gap_extend( option[ cm::min_gap_extend ]() );
578 Real const max_gap_extend( option[ cm::max_gap_extend ]() );
579 Real const step_size( 0.5 );
581 runtime_assert( min_gap_open <= max_gap_open );
582 runtime_assert( min_gap_extend <= max_gap_extend );
590 prof1->read_from_file( fn1 );
591 prof1->convert_profile_to_probs( 1.0 );
594 prof2->read_from_file( fn2 );
595 prof2->convert_profile_to_probs( 1.0 );
598 prof1->id(
FileName( prof1->id() ).base() );
599 prof2->id(
FileName( prof2->id() ).base() );
602 for (
Real o = min_gap_open; o <= max_gap_open; o += step_size ) {
603 for (
Real e = min_gap_extend; e <= max_gap_extend;
627 for ( core::id::AtomID_Mask::AtomMap::const_iterator
628 it = selected[ pos ].begin(), eit = selected[ pos ].
end(); it != eit;
635 900.000 +
RG.uniform()*100.000,
636 900.000 +
RG.uniform()*100.000,
637 900.000 +
RG.uniform()*100.000
644 900.000 +
RG.uniform()*100.000,
645 900.000 +
RG.uniform()*100.000,
646 900.000 +
RG.uniform()*100.000