25 #include <ObjexxFCL/string.functions.hh>
31 #include <numeric/NumericTraits.hh>
34 using namespace coarse;
36 using namespace conformation;
37 using namespace chemical;
38 using namespace ObjexxFCL;
40 using namespace pack::dunbrack;
48 left_justify( trimmed_name ); trim( trimmed_name );
54 os <<
"==============================" << endl;
55 os <<
"Coarse-Graining for residue " << fine_res_type_->name() << endl;
56 os <<
"-------------------------------" << endl;
57 for (BeadList::const_iterator it=beads_.begin(), eit=beads_.end(); it!=eit;++it,++bead_nr) {
58 os << bead_names_[bead_nr] << endl;
59 for (AtomList::const_iterator ait=it->begin(), eait=it->end(); ait!=eait; ++ait) {
60 os << ait->name_ <<
" ";
64 os <<
"==============================" << endl;
68 return coarse_res_type_->nchi();
73 return coarse_res_type_->name();
89 if (map_atom_to_bead(atom)<0) {
92 if (map_atom_to_bead(res.
atom_name(na))<0) {
105 AtomList::const_iterator ait;
108 for (BeadList::const_iterator it=beads_.begin(), eit=beads_.end(); it!=eit && !bfound;++it,bead_nr++) {
109 bfound=((ait=find(it->begin(),it->end(),
strip_whitespace(atom)))!=it->end());
112 return bfound ? bead_nr : -1;
131 coarse_res_type_=coarse_res_ptr;
133 fine_res_type_=fine_res_ptr;
136 assert( coarse_res.
name() == fine_res.
name() );
153 bead_names_.push_back(it->first);
158 cerr <<
"add bead " << it->first << endl;
164 add_remaining_sidechain(al,fine_res);
166 add_all_remaining(al,fine_res);
174 for (AtomList::const_iterator ait=full_atom.begin(),eait=full_atom.end(); ait!=eait; ++ait) {
175 cerr << ait->name_ << endl;
176 assert( fine_res.
has(ait->name_) && coarse_res.
has(ait->name_) );
183 fix_coarsetype_geometry( coarse_res_ptr );
195 for (
Size ai=1;ai<=crsd->natoms();ai++) {
198 c_type->set_xyz( ai, crsd->atom(ai).xyz() );
206 for (BeadList::const_iterator it=beads_.begin(), eit=beads_.end(); it!=eit;++it,++bead_nr) {
209 for (AtomList::const_iterator ait=it->begin(), eait=it->end(); ait!=eait; ++ait) {
213 new_rsd->atom(ait->name_).xyz(fine.
atom(ait->name_).
xyz());
217 cen+=fine.
atom(ait->name_).
xyz()*ait->weight_;
218 sum_weight+=ait->weight_;
227 if (sum_weight>0.0) {
228 new_rsd->atom(bead_names_[bead_nr]).xyz(cen/sum_weight);
231 cerr <<
"WARNING: empty bead " << bead_names_[bead_nr] <<
" in residue " << coarse_res_type_->name() << endl;
240 bool match_mask(
RotVector const& mask,
int nchi, DunbrackRotamer< FOUR, Real >
const & rotamer );
247 DunbrackRotamer< FOUR, Real >
const& rotamer
261 DunbrackRotamer< FOUR, Real >
const& rotamer,
287 using namespace scoring;
288 using namespace pack::dunbrack;
289 using namespace conformation;
291 bool bAverage(
false );
294 assert(coarse_rotset);
296 Size nchi=coarse_res_type_->nchi();
303 for (
Size chi=1;chi<=nchi; chi++) {
307 for (
Size chi=nchi+1;chi<=4; chi++) {
319 coarse_rotamer( *
this, fine_res_type_, coarse_res_type_, fine_high_res, nchi, new_chi, new_angle );
325 average_rotamers( *
this, fine_res_type_, coarse_res_type_, fine_rotamers, mask, nchi, chi_mean, chi_std, angle_mean, angle_std );
329 coarse_rot =
new CoarseRotamer( pnew, nchi, mask, chi_mean, chi_std, angle_mean, angle_std );
331 coarse_rot =
new CoarseRotamer( pnew, nchi, mask, new_chi, chi_std, new_angle, angle_std );
333 coarse_rotset->push_back(coarse_rot);
338 return coarse_rotset;
343 std::cerr <<
"Translator::get_RotamerLibrary() for " << name() << std::endl;
353 while (++mask[chi]>max_bins[chi]) {
355 if (chi>nchi)
return false;
366 while ( mask[chi] == rotamer.rotwell(chi) ) {
368 if ( chi>nchi )
return true;
384 DunbrackRotamer< FOUR, Real >
const & rotamer
389 for (
Size jj = 1; jj <= std::min(
Size( 4 ), fine_res_type->nchi()); ++jj ) {
390 fine_res->set_chi( jj, rotamer.chi_mean( jj ) );
397 pose->append_residue_by_bond(*coarse_res);
412 DunbrackRotamer< FOUR, Real >
const & rotamer,
417 const Real Pi = numeric::NumericTraits<Real>::pi();
420 for (
Size jj = 1; jj<=nchi; ++jj) {
422 const Size seqpos ( 1 );
423 chi[jj] = pose->chi( jj, seqpos);
442 const Real Pi = numeric::NumericTraits<Real>::pi();
446 FArray2D< Real > xy_mean_chi( nchi, 2, 0.0 );
447 FArray2D< Real > xy_mean_angle( nchi, 2, 0.0 );
449 for (
Size i=1; i<=fine_rotamers.size(); i++) {
453 Real p = rotamer.rotamer_probability();
456 coarse_rotamer( map, fine_res_type, coarse_res_type, rotamer, nchi, newChi, newAngle );
457 for (
Size jj = 1; jj <= nchi; ++jj) {
458 Real r_chi = 1-
sqr3(rotamer.chi_sd(jj)/180.0*Pi)/2.0;
459 xy_mean_chi( jj, 1)+= p * std::sin( newChi[jj] ) * r_chi;
460 xy_mean_chi( jj, 2)+= p * std::cos( newChi[jj] ) * r_chi;
462 xy_mean_angle( jj, 1)+= p * std::sin( newAngle[jj] );
463 xy_mean_angle( jj, 2)+= p * std::cos( newAngle[jj] );
469 for (
Size jj = 1; jj<=nchi; ++jj) {
470 chi_mean[jj]=std::atan2( xy_mean_chi(jj,1), xy_mean_chi(jj,2) ) * 180/Pi;
471 angle_mean[jj]=std::atan2( xy_mean_angle(jj,1), xy_mean_angle(jj,2) ) * 180/Pi;
473 Real r_chi = std::sqrt(
sqr( xy_mean_chi( jj, 1 ) )+
sqr( xy_mean_chi( jj, 2) ) )/pnew;
474 chi_std[jj] = pow( 2.0 * ( 1.0-r_chi ), 1/3.0 ) * 180 / Pi;
475 Real r_ang = std::sqrt(
sqr( xy_mean_angle( jj, 1 ) )+
sqr( xy_mean_angle( jj, 2) ) )/pnew;
476 angle_std[jj] = pow( 2.0 * (1.0 - r_ang), 1/3.0 ) * 180 / Pi;
491 using namespace pack::dunbrack;
496 for (
Size i=1; i<=fine_rotamers.size(); i++) {
499 Real p = rotamer.rotamer_probability();