26 #include <basic/Tracer.hh>
27 #include <basic/prof.hh>
35 #include <utility/vector0.hh>
36 #include <utility/vector1.hh>
48 namespace constraints {
53 static basic::Tracer
tr(
"core.scoring.ConstraintSet");
58 revision_id_current_( false ),
59 conformation_pt_( NULL )
65 residue_pair_constraints_( other.residue_pair_constraints_.
size() ),
67 revision_id_current_( false ),
68 conformation_pt_( NULL )
70 basic::ProfileThis doit( basic::CONSTRAINT_SET_COPY );
77 bool first_insert (
true );
83 iter != iter_end; ++iter ) {
95 iter != iter_end; ++iter ) {
110 residue_pair_constraints_( other.residue_pair_constraints_.
size() ),
112 revision_id_current_( false ),
113 conformation_pt_( NULL )
115 basic::ProfileThis doit( basic::CONSTRAINT_SET_COPY );
121 bool first_insert (
true );
125 iter != iter_end; ++iter ) {
127 if( ((ii < start_residue) || (ii > end_residue)) &&
128 (( iter->first < start_residue) || (iter->first > end_residue )) ) {
133 if ( first_insert ) {
135 first_insert =
false;
146 iter != iter_end; ++iter ) {
149 if( (( iter->first < start_residue) || (iter->first > end_residue )) ) {
178 for ( ConstraintCOPs::const_iterator it = all_cst.begin(), eit = all_cst.end(); it!=eit; ++it ) {
179 ConstraintCOP new_cst = (*it)->remapped_clone( src, dest, smap );
180 if ( new_cst ) new_set->add_constraint( new_cst );
194 for ( ConstraintCOPs::const_iterator it = all_cst.begin(), eit = all_cst.end(); it!=eit; ++it ) {
196 new_cst->steal_def( src );
197 new_cst = new_cst->remapped_clone( src, dest, smap );
198 if ( new_cst ) new_set->add_constraint( new_cst );
213 assert( all_cst.size() != 0 );
218 for ( ConstraintCOPs::const_iterator it = all_cst.begin(), eit = all_cst.end(); it!=eit; ++it ) {
224 else tr.Debug <<
"when remapping the constraint set, one constraint could not be remapped. :( "<< std::endl;
279 it= seqpos_constraints.
begin(),
280 ite= seqpos_constraints.
end();
282 it->second->setup_for_scoring( confxyz, scfxn );
288 it->second->setup_for_scoring( confxyz, scfxn );
303 ite= seqpos_constraints.
end(); it != ite; ++it ) {
304 it->second->setup_for_derivatives( confxyz, scfxn );
310 it->second->setup_for_derivatives( confxyz, scfxn );
330 if ( it == pos1_constraints.
end() )
return;
331 Constraints const & pair_constraints( *(it->second) );
349 Size const seqpos( atom_id.
rsd() );
355 it->second->eval_ws_atom_derivative( atom_id, pose.
conformation(), weights, F1, F2 );
389 Size const seqpos( atom_id.
rsd() );
394 it->second->eval_ws_atom_derivative( atom_id, pose.
conformation(), weights, F1, F2 );
411 it->second->intra_residue_energy( rsd, sfxn.
weights(), emap );
424 it->second->intra_residue_energy( rsd, emap , emap );
486 if ( !residue_constraints.
has( seqpos ) ) {
490 residue_constraints.
find( seqpos )->second->add_constraint( cst );
508 for( ConstraintCOPs::iterator it = cst_list.begin();
509 it != cst_list.end();
524 if ( pos_list.size() == 1 ) {
526 tr.Trace <<
"add intra-res constraint " << std::endl;
528 }
else if ( pos_list.size() == 2 ) {
530 tr.Trace <<
"add res constraint " << std::endl;
535 tr.Trace <<
"add 3+body constraint " << std::endl;
546 bool object_comparison
549 if ( !residue_constraints.
has( seqpos ) )
return false;
554 if( csts_it->second->remove_constraint( cst, object_comparison ) ) {
556 if( csts_it->second->size() == 0 ) residue_constraints.
erase( seqpos );
572 bool object_comparison )
599 bool object_comparison )
602 bool success =
false;
603 for( ConstraintCOPs::iterator it = cst_list.begin();
604 it != cst_list.end();
607 if( success ==
false )
return false;
618 bool object_comparison )
625 bool success =
false;
626 if ( pos_list.size() == 1 ) {
628 tr.Trace <<
"remove intra-res constraint " << std::endl;
630 }
else if ( pos_list.size() == 2 ) {
632 tr.Trace <<
"remove res constraint " << std::endl;
637 tr.Trace <<
"remove 3+body constraint " << std::endl;
659 std::map<std::string, ConstraintCOP> all_constr;
660 std::stringstream constraintString;
663 constraintString.str(
"");
664 (*i)->show(constraintString);
665 all_constr.insert(std::make_pair(constraintString.str(),*i));
672 constraintString.str(
"");
673 (*i)->show(constraintString);
674 all_constr.insert(std::make_pair(constraintString.str(),*i));
679 constraintString.str(
"");
680 (*i)->show(constraintString);
681 all_constr.insert(std::make_pair(constraintString.str(),*i));
685 for(std::map<std::string, ConstraintCOP>::iterator i = all_constr.begin(), i_end = all_constr.end(); i != i_end; ++i) {
686 all.push_back(i->second);
710 std::cerr <<
"HUH?!? weird stuff is going on. ConstraintSet is hearing length voices that it shouldn't" << std::endl;
733 switch ( event.
tag ) {
735 case ConnectionEvent::DISCONNECT:
739 tr.Error <<
"ERROR: HUH?!? weird stuff is going on. ConstraintSet is hearing disconnection voices that it shouldn't" << std::endl;
743 case ConnectionEvent::TRANSFER:
799 using namespace core::scoring::constraints;
808 iter != iter_end; ++iter ) {
812 out <<
"ResiduePairConstraints (" << ii <<
"," << iter->first <<
")" << std::endl;
813 iter->second->show( out );
827 using namespace core::scoring::constraints;
832 it->second->show_definition( out, pose );
842 iter != iter_end; ++iter ) {
846 if ( ii < iter->first ) {
848 iter->second->show_definition( out, pose );
859 (*it)->show_def( out, pose );
867 using namespace core::scoring::constraints;
875 iter != iter_end; ++iter ) {
879 if ( ii > iter->first ) {
886 <<
" InterRes: " << intercount
900 using namespace core::scoring::constraints;
905 if ( verbose_level>0) out <<
"IntraResidueConstraints: ... ";
906 if ( verbose_level>50 ) out << std::endl;
909 if ( verbose_level>50 ) out <<
"IntraResidueConstraints ( " << it->first <<
" ) ";
910 Size viol = it->second->show_violations( out, pose, verbose_level, threshold );
911 if ( verbose_level>50 ) out <<
" " << viol <<
" violated" << std::endl;
916 if ( verbose_level>0) out <<
"ResiduePairConstraints: ... ";
917 if ( verbose_level>50 ) out << std::endl;
923 iter != iter_end; ++iter ) {
928 if ( ii > iter->first ) {
929 if ( verbose_level>50 ) out <<
"ResiduePairConstraints ( " << ii <<
" , " << iter->first <<
" ) ";
930 if ( verbose_level>80 ) out << std::endl;
931 viol=iter->second->show_violations( out, pose, verbose_level, threshold );
932 if ( verbose_level>50 ) out <<
" " << viol <<
" violated" << std::endl;
942 if ( verbose_level>0) out <<
"MultiConstraints: ... ";
943 if ( verbose_level>50 ) out << std::endl;
947 if ( verbose_level>80 ) out << std::endl;
948 viol=(*it)->show_violations( out, pose, verbose_level, threshold );
949 if ( verbose_level>50 ) out <<
" " << viol <<
" violated" << std::endl;
953 if ( verbose_level>0 ) out <<
"total violations: "<< total_viol << std::endl;