34 #include <ObjexxFCL/format.hh>
35 #include <ObjexxFCL/string.functions.hh>
38 #include <utility/exit.hh>
42 #include <basic/prof.hh>
43 #include <basic/Tracer.hh>
44 #include <basic/options/option.hh>
54 #include <utility/vector1.hh>
59 static basic::Tracer
tr(
"protocols.noesy_assign.crosspeaks");
60 static basic::Tracer
tr_labels(
"protocols.noesy_assign.crosspeaks.labels");
64 using namespace basic;
68 namespace noesy_assign {
70 std::set< core::id::NamedAtomID > CrossPeak::unknown_resonances_;
72 CrossPeak::Spin::Spin(
Real freq ) : freq_ ( freq ) {}
78 if ( assignment == *it )
return ct;
96 cumulative_peak_volume_( 1.0 ),
97 distance_bound_( 100 ),
98 eliminated_( NOT_ELIMINATED ),
99 eliminated_due_to_dist_violations_( false ),
100 elimination_candidate_( false )
137 for (
Size ct1 = 1; ct1 <= n_assigned_1; ++ct1 ) {
138 for (
Size ct2 = 1; ct2 <= n_assigned_2; ++ct2 ) {
147 os <<
"peak: " <<
peak_id() <<
" ";
148 for (
Size i = 1; i<=2 ; i++ ) {
151 if ( i == 1 ) os <<
" <-> ";
158 Real const my_freq(
proton( iproton ).freq() );
159 Real const my_tolerance(
info( iproton ).proton_tolerance() );
162 if ( it->second->match( my_freq, my_tolerance,
folder( iproton ) ) ) {
171 if ( ind )
return ind;
177 for (
Size i=1; i<=digits; ++i ) {
180 d = floor( d + 0.5 );
181 for (
Size i=1; i<=digits; ++i ) {
198 using namespace core::scoring::constraints;
204 round(inv_weight,round_digits),
205 "automatic NOE Peak "+ObjexxFCL::string_of(
peak_id() )+
" "+
filename()+
" Volume: "+ObjexxFCL::string_of(
volume() )
209 using namespace basic::options;
210 using namespace basic::options::OptionKeys;
217 min_vc = std::max( min_vc, 0.1 );
220 Size ct_ambiguous( 0 );
221 PeakAssignments::const_iterator first_valid =
end();
222 for ( PeakAssignments::const_iterator it =
begin(); it !=
end(); ++it ) {
223 if ( (*it)->normalized_peak_volume() <= min_vc )
continue;
224 if ( !ct_ambiguous ) first_valid = it;
229 runtime_assert( ct_ambiguous < 2 );
232 if ( ct_ambiguous > 1 ) {
247 for ( PeakAssignments::const_iterator it = first_valid; it !=
end(); ++it ) {
248 if ( (*it)->normalized_peak_volume() <= min_vc )
continue;
250 my_fa_cst->add_individual_constraint( new_cst );
255 my_cen_cst->add_individual_constraint( new_cst->map_to_CEN( pose, centroid_pose, number_of_maps,
"CEN" ) );
256 max_maps = std::max( number_of_maps, max_maps );
258 my_cen_cst->add_individual_constraint( new_cst->map_to_CEN( pose, centroid_pose, number_of_maps,
"CB" ) );
265 Real mapped_inv_weight;
268 mapped_inv_weight = inv_weight * pow( 2.0,
double(max_maps) );
270 mapped_upl = pow( cum_new_distance, -1.0/6 );
271 mapped_inv_weight = inv_weight;
273 cen_cst = my_cen_cst->clone(
new BoundFunc( 1.5,
274 round(mapped_upl,round_digits),
275 round(mapped_inv_weight,round_digits),
276 "CEN mapped automatic NOE: Peak "+ ObjexxFCL::string_of(
peak_id() )
280 if ( first_valid ==
end() )
return;
292 my_cen_cst= my_fa_cst->map_to_CEN( pose, centroid_pose, number_of_maps,
"CEN" );
294 mapped_inv_weight = inv_weight*pow( 2.0,
double(number_of_maps) );
296 my_cen_cst= my_fa_cst->map_to_CEN( pose, centroid_pose, number_of_maps,
"CB" );
298 mapped_upl = pow( cum_new_distance, -1.0/6 );
299 mapped_inv_weight = inv_weight;
301 std::string const comment(
"CEN mapped automatic NOE: Peak "+ ObjexxFCL::string_of(
peak_id() ) );
302 cen_cst = my_cen_cst->clone(
new BoundFunc( 1.5,
round(mapped_upl,round_digits),
round(mapped_inv_weight,round_digits), comment ) );
310 return 1.0/(1+exp(-1.0/tau*5.0*(x-m)));
312 return 1.0-1./(1+exp(-1.0/tau*5.0*(x-m)));
316 Real max_vc_cs( 0.0 );
317 Real max_vc_sym( 0.0 );
322 if ( max_vc < (*ait)->normalized_peak_volume() ) {
323 max_vc = (*ait)->normalized_peak_volume();
324 max_vc_sym = (*ait)->symmetry_compliance();
325 max_vc_cs = (*ait)->chemshift_compliance();
332 s[1] =
sigmoid( max_vc_cs, tau[1], m[1], 1);
333 s[2] =
sigmoid( max_vc_sym, tau[2], m[2], 1);
334 s[3] = -
sigmoid( max_vc_sym, tau[3], m[3], -1);
335 s[4] =
sigmoid( max_vc, tau[4], m[4], 1 );
336 s[5] = -
sigmoid( overall_vc, tau[5], m[5], -1 );
337 return (w[1]*s[1]+w[2]*s[2]+w[3]*s[3]+w[4]*s[4]+w[5]*s[5]+0.4)/1.6;
344 Real const vc( (*ait)->normalized_peak_volume() );
345 if ( pclass==
HI_UNAMBIG && vc < 0.1 )
continue;
346 if ( pclass<=
MED_AMBIG && vc < 0.01 )
continue;
347 if ( viol > (*ait)->native_distance_viol() ) viol=(*ait)->native_distance_viol();
353 char const strings[][50] = {
"HI_UNAMBIG",
"HI_NEAR_UNAMBIG",
"HI_AMBIG",
"MED_AMBIG",
"MED_UNAMBIG",
"LOW_AMBIG" };
358 Size count_vc_0p1( 0 );
359 Size count_vc_0p01( 0 );
361 Real const vc( (*ait)->normalized_peak_volume() );
362 if ( vc > 0.1 ) ++count_vc_0p1;
363 if ( vc > 0.01 ) ++count_vc_0p01;
382 if ( pclass == HI ) {
383 if ( count_vc_0p01 == 1 ) {
385 }
else if ( count_vc_0p1 == 1 ) {
390 }
else if ( pclass == MED ) {
391 if ( count_vc_0p1 == 1 || count_vc_0p01 == 1 ) {
402 Real max_volume( 0.0 );
404 max_volume= std::max( max_volume, (*ait)->normalized_peak_volume() );
414 basic::ProfileThis doit( basic::NOESY_ASSIGN_CP_GEN_CST );
417 core::Real inv_weight( sqrt( 1.0*normalization )/params.cst_strength_ );
421 Size ct_ambiguous( 0 );
422 for ( PeakAssignments::const_iterator it =
begin(); it !=
end(); ++it ) {
423 if ( (*it)->normalized_peak_volume() <= params.min_volume_ )
continue;
427 if ( ct_ambiguous > 1 ) {
431 for ( PeakAssignments::const_iterator it =
begin(); it !=
end(); ++it ) {
432 if ( (*it)->normalized_peak_volume() <= params.min_volume_ )
continue;
433 constraint->add_individual_constraint( (*it)->create_constraint( pose ) );
437 for ( PeakAssignments::const_iterator it =
begin(); it !=
end(); ++it ) {
438 if ( (*it)->normalized_peak_volume() <= params.min_volume_ )
continue;
439 return (*it)->create_constraint( pose, func );
446 CrossPeak::create_centroid_constraint(
451 using namespace core::scoring::constraints;
455 core::Real inv_weight(
round( sqrt( 1.0*normalization )/params.cst_strength_, round_digits ) );
465 for ( PeakAssignments::const_iterator it =
begin(); it !=
end(); ++it ) {
466 if ( (*it)->normalized_peak_volume() <= params.min_volume_ )
continue;
469 constraint->add_individual_constraint( new_cst->map_to_CEN( pose, centroid_pose, number_of_maps,
"CB" ) );
470 cum_new_distance += pow( (eff_single_dist + params.centroid_mapping_distance_padding_*number_of_maps )*pow( new_cst->multiplicity(), 1.0/6 ), -6 );
471 sd += params.centroid_mapping_distance_padding_*( pow( new_cst->multiplicity()-1, 1.0/6 ) );
473 return constraint->clone(
new BoundFunc( 1.5,
round( pow( cum_new_distance, -1.0/6 ), round_digits), inv_weight,
"CB mapped automatic NOE: Peak "+ ObjexxFCL::string_of(
peak_id() ) ) );
482 Size min_seq( 99999 );
483 for ( PeakAssignments::const_iterator it =
begin(); it !=
end(); ++it ) {
484 if ( (*it)->normalized_peak_volume() <= volume_threshold )
continue;
485 Size res1( (*it)->resid( 1 ) );
486 Size res2( (*it)->resid( 2 ) );
487 Size diff( res1 < res2 ? res2-res1 : res1-res2 );
488 min_seq = min_seq < diff ? min_seq : diff;
494 static std::string const str_distviol(
"DistViol" );
496 static std::string const str_minvol(
"MinPeakVol");
497 static std::string const str_maxassign(
"MaxAssign");
512 if ( do_not_compute )
return false;
515 bool min_peak_volume_reached(
false );
516 for ( PeakAssignments::const_iterator it =
begin(); it !=
end() && !min_peak_volume_reached ; ++it ) {
517 min_peak_volume_reached = (*it)->normalized_peak_volume() > params.
min_volume_;
530 Real N_atom_sum( 0.0 );
531 Real N_res_sum( 0.0 );
532 for ( PeakAssignments::const_iterator it =
begin(); it !=
end(); ++it ) {
533 Real vol( (*it)->normalized_peak_volume() );
534 N_atom_sum += vol * (*it)->network_anchoring();
535 N_res_sum += vol * (*it)->network_anchoring_per_residue();
550 for ( PeakAssignments::const_iterator it =
begin(); it !=
end(); ++it ) {
551 Real vol( (*it)->normalized_peak_volume() );
565 if (
volume_ <= 0.0 )
throw utility::excn::EXCN_BadInput(
"Peak intensity negative or zero for "+ObjexxFCL::string_of(
peak_id_ ) );
566 for ( PeakAssignments::const_iterator it =
begin(); it !=
end(); ++it ) {
568 type1 = (*it)->calibration_atom_type( 1 );
569 type2 = (*it)->calibration_atom_type( 2 );
570 calibration_types.set( type1 );
571 calibration_types.set( type2 );
572 Real const cal( sqrt( calibrator( type1 ) * calibrator( type2 ) ) );
573 Real vol( (*it)->normalized_peak_volume() );
574 Real int_factor(1.0);
575 int_factor*=
resonances()[ (*it)->resonance_id( 1 ) ].intensity();
576 int_factor*=
resonances()[ (*it)->resonance_id( 2 ) ].intensity();
577 sum += (vol > params.
min_volume_ ? vol : 0 ) / cal / int_factor;
584 if ( max_dist > 0.01 ) {
598 else assign_labelled_spin( iproton );
603 Real const my_freq(
proton( iproton ).freq() );
604 Real const my_label_freq(
label( iproton ).freq() );
605 Real const my_tolerance(
info( iproton ).proton_tolerance() );
606 Real const my_label_tolerance(
info( iproton ).label_tolerance() );
610 if ( my_tolerance > 99 ) {
613 if ( it->second->match( my_label_freq, my_label_tolerance,
folder( iproton+2 ) ) ) {
616 std::string const& label_name( it->second->name() );
618 for ( ResonanceList::Resonances::const_iterator rit = residue_list.begin(); rit != residue_list.end(); ++rit ) {
619 if ( (*rit)->name()[ 0 ]==
'Q' || (*rit)->name().find(
"H") != std::string::npos ) {
625 if ( possible_label == label_name ) {
644 if ( it->second->match( my_freq, my_tolerance,
folder( iproton ) ) ) {
645 Size resid( it->second->atom().rsd() );
651 if ( label_reso.
match( my_label_freq, my_label_tolerance,
folder( iproton+2 ) ) ) {
658 exception.
show(
tr.Warning );
659 tr.Warning <<
" as label for atom " << it->second->atom().atom() <<
" " <<
resonances().
aa_from_resid( resid ) << std::endl;