28 #include <basic/MetricValue.hh>
32 #include <basic/Tracer.hh>
35 #include <utility/vector1.hh>
36 #include <utility/string_util.hh>
42 #include <utility/options/BooleanVectorOption.hh>
45 static basic::Tracer
tr(
"protocols.fldsgn.NcontactsCalculator");
54 for (
Size j=1; j<= 50 ; ++j ) {
74 ignore_loops_( false ),
75 ignore_same_sselement_( false ),
76 ignore_same_sheet_( false ),
77 use_only_calpha_( false )
86 ignore_loops_( false ),
87 ignore_same_sselement_( false ),
88 ignore_same_sheet_( false ),
89 use_only_calpha_( false )
95 condist_( rval.condist_ ),
96 isep_residue_( rval.isep_residue_ ),
97 ignore_loops_( rval.ignore_loops_ ),
98 ignore_same_sselement_( rval.ignore_same_sselement_ ),
99 ignore_same_sheet_( rval.ignore_same_sheet_ ),
100 use_only_calpha_( rval.use_only_calpha_ )
113 using namespace core;
114 if ( key ==
"all_heavy_atm" ) {
115 basic::check_cast( valptr, &
nc_allatm_,
"total_nlcontacts expects to return a Real" );
116 (
static_cast<basic::MetricValue<Real> *
>(valptr))->set(
nc_allatm_ );
118 }
else if (key ==
"sidechain_heavy_apolar_atm" ) {
119 basic::check_cast( valptr, &
nc_hpatm_,
"special_region_nlcontacts expects to return a Real" );
120 (
static_cast<basic::MetricValue<Real> *
>(valptr))->set(
nc_hpatm_ );
122 }
else if ( key ==
"sidechain_heavy_atm_apolar_aa" ) {
123 basic::check_cast( valptr, &
nc_hpres_,
"special_region2_nlcontacts expects to return a Real" );
124 (
static_cast<basic::MetricValue<Real> *
>(valptr))->set(
nc_hpres_ );
126 }
else if ( key ==
"ss_entropy" ) {
127 basic::check_cast( valptr, &
ss_entrpy_,
"special_region1_intra_nlcontacts expects to return a Real" );
128 (
static_cast<basic::MetricValue<Real> *
>(valptr))->set(
ss_entrpy_ );
131 tr <<
"NcontactsCalculator cannot compute the requested metric " << key << std::endl;
145 if ( key ==
"all_heavy_atm" ) {
148 }
else if ( key ==
"sidechain_heavy_apolar_atm" ) {
149 result = utility::to_string(
nc_hpatm_ );
151 }
else if ( key ==
"sidechain_heavy_atm_apolar_aa" ) {
152 result = utility::to_string(
nc_hpres_ );
153 }
else if ( key ==
"ss_entrpy" ) {
156 basic::Error() <<
"NcontactsCalculator cannot compute metric " << key << std::endl;
180 SheetSetOP sheet_set =
new SheetSet( ssinfo, spairset );
183 Size max_ssele = ssinfo->ss_element_id( nres );
192 if(
ignore_loops_ && ssinfo->secstruct( iaa ) ==
'L' )
continue;
194 Size iaa_ssele( ssinfo->ss_element_id( iaa ) );
196 for (
Size jaa=iaa+isep_residue_; jaa<=nres; ++jaa ) {
199 if(
ignore_loops_ && ssinfo->secstruct( jaa ) ==
'L' )
continue;
201 Size jaa_ssele( ssinfo->ss_element_id( jaa ) );
208 ssinfo->secstruct( iaa ) ==
'E' && ssinfo->secstruct( jaa ) ==
'E' &&
209 sheet_set->which_sheet( ssinfo->strand_id( iaa ) ) ==
210 sheet_set->which_sheet( ssinfo->strand_id( jaa ) ) )
continue;
213 for (
Size iatm=1, iatm_end=ires.natoms(); iatm<=iatm_end; ++iatm ) {
215 if( ires.atom_type(
int(iatm) ).is_heavyatom() ){
218 for (
Size jatm=1, jatm_end=jres.natoms(); jatm<=jatm_end; ++jatm ) {
220 if( jres.atom_type(
int(jatm)).is_heavyatom() ) {
222 Atom const & iatom( ires.atom( iatm ) );
223 Atom const & jatom( jres.atom( jatm ) );
224 Size const iadex ( ires.atom_type_index(
int(iatm) ) );
225 Size const jadex ( jres.atom_type_index(
int(jatm) ) );
228 ires.atom_type( iatm ).name() !=
"CAbb") || jres.atom_type( jatm ).name() !=
"CAbb" )
continue;
230 calc_sselements[ iaa_ssele ][ jaa_ssele ] =
true;
232 Real const dsq( iatom.xyz().distance_squared( jatom.xyz() ));
234 if( dsq <= condist2 ){
240 ncon_sselements[iaa_ssele][jaa_ssele] ++ ;
242 if( !ires.atom_is_backbone(
int(iatm) ) && !jres.atom_is_backbone(
int(jatm) ) &&
243 !ires.type().is_polar() && !jres.type().is_polar() ) {
268 for (
Size i=1 ;i<=max_ssele; ++i ) {
269 for (
Size j=1 ;j<=max_ssele; ++j ) {
270 if ( calc_sselements[ i ][ j ] ) {
271 tot += ncon_sselements[i][j];
276 for (
Size i=1 ;i<=max_ssele; ++i ) {
277 for (
Size j=1 ;j<=max_ssele; ++j ) {
278 if ( calc_sselements[ i ][ j ] ) {
280 ss_entrpy_ += -prob*( std::log( prob )/std::log( 2.0 ) );