36 #include <basic/database/open.hh>
37 #include <basic/options/option.hh>
39 #include <basic/basic.hh>
40 #include <basic/interpolate.hh>
50 #include <numeric/xyz.functions.hh>
54 #include <utility/string_util.hh>
55 #include <utility/io/izstream.hh>
56 #include <utility/io/ozstream.hh>
66 #if defined(WIN32) || defined(__CYGWIN__)
71 #include <boost/cstdint.hpp>
78 #include <basic/Tracer.hh>
83 #include <basic/options/keys/out.OptionKeys.gen.hh>
85 #include <basic/options/keys/corrections.OptionKeys.gen.hh>
86 #include <basic/options/keys/in.OptionKeys.gen.hh>
89 #include <utility/vector1.hh>
96 static basic::Tracer
TR(
"core.pack.dunbrack");
131 dunlib->get_rotamer_from_chi( rsd.
chi(),
rot );
132 }
else { rot.resize( 0 ); }
147 dunlib->get_rotamer_from_chi( chi, rot );
148 }
else { rot.resize( 0 ); }
159 rot.resize( chi.size() );
163 for (
Size ii = 1; ii <= nchi; ++ii ) chi4[ ii ] = chi[ ii ];
167 for (
Size ii = 1; ii <= nchi; ++ii ) rot[ ii ] = rot4[ ii ];
168 for (
Size ii = nchi+1; ii <= rot.size(); ++ii ) rot[ ii ] = 0;
190 using namespace chemical;
199 for (
Size i = 1; i <= nchi; ++i ) {
201 Real chi_i = basic::periodic_range( chi[ i ], 360.0 );
205 if ( ( chi_i >= 0.0 ) && ( chi_i <= 120.0 ) ) { rot[i] = 1; }
206 else if ( std::abs(chi_i) >= 120.0 ) { rot[i] = 2; }
208 }
else if ( res ==
aa_pro ) {
210 if ( chi_i >= 0.0 ) { rot[i] = 1; }
214 }
else if ( i == 2 ) {
216 if ( ( chi_i >= 0.0 ) && ( chi_i <= 120.0 ) ) { rot[i] = 1; }
217 else if ( std::abs(chi_i) >= 120.0 ) { rot[i] = 2; }
223 if ( ( chi_i >= 0.0 ) && ( chi_i <= 120.0 ) ) { rot[i] = 1; }
224 else if ( std::abs(chi_i) >= 120.0 ) { rot[i] = 2; }
227 }
else if ( res ==
aa_asp ) {
228 if ( ( ( chi_i >= 30.0 ) && ( chi_i <= 90.0 ) ) ||
229 ( ( chi_i <= -90.0 ) && ( chi_i >= -150.0 ) ) ) {
231 }
else if ( ( ( chi_i >= -30.0 ) && ( chi_i <= 30.0 ) ) ||
232 ( std::abs(chi_i) >= 150.0 ) ) {
241 if ( ( ( chi_i >= 30.0 ) && ( chi_i <= 150.0 ) ) ||
242 ( ( chi_i <= -30.0 ) && ( chi_i >= -150.0 ) ) ) {
249 }
else if ( res ==
aa_trp ) {
250 if ( ( chi_i >= -180.0 ) && ( chi_i <= -60.0 ) ) { rot[i] = 1; }
251 else if ( ( chi_i >= -60.0 ) && ( chi_i <= 60.0 ) ) { rot[i] = 2; }
254 }
else if ( res ==
aa_asn ) {
257 if ( chi_i >= -150.0 && chi_i < -90.0 ) { rot[i] = 1; }
258 else if ( chi_i >= -90.0 && chi_i < -30.0 ) { rot[i] = 2; }
259 else if ( chi_i >= -30.0 && chi_i < 30.0 ) { rot[i] = 3; }
260 else if ( chi_i >= 30.0 && chi_i < 90.0 ) { rot[i] = 4; }
261 else if ( chi_i >= 90.0 && chi_i < 150.0 ) { rot[i] = 5; }
263 }
else if ( rot[1] == 2 ) {
264 if ( chi_i >= -180.0 && chi_i < -90.0 ) { rot[i] = 1; }
265 else if ( chi_i >= -90.0 && chi_i < -45.0 ) { rot[i] = 2; }
266 else if ( chi_i >= -45.0 && chi_i < 0.0 ) { rot[i] = 3; }
267 else if ( chi_i >= 0.0 && chi_i < 45.0 ) { rot[i] = 4; }
268 else if ( chi_i >= 45.0 && chi_i < 90.0 ) { rot[i] = 5; }
271 if ( chi_i >= -180.0 && chi_i < -105.0 ) { rot[i] = 1; }
272 else if ( chi_i >= -105.0 && chi_i < -45.0 ) { rot[i] = 2; }
273 else if ( chi_i >= -45.0 && chi_i < 15.0 ) { rot[i] = 3; }
274 else if ( chi_i >= 15.0 && chi_i < 60.0 ) { rot[i] = 4; }
275 else if ( chi_i >= 60.0 && chi_i < 120.0 ) { rot[i] = 5; }
278 }
else if ( res ==
aa_pro ) {
284 }
else if ( i == 3 ) {
286 if ( ( ( chi_i >= 30.0 ) && ( chi_i <= 90.0 ) ) ||
287 ( ( chi_i <= -90.0 ) && ( chi_i >= -150.0 ) ) ) { rot[i] = 1; }
288 else if ( ( ( chi_i >= -30.0 ) && ( chi_i <= 30.0 ) ) ||
289 ( std::abs(chi_i) >= 150.0 ) ) { rot[i] = 2; }
294 if ( ( chi_i >= 0.0 ) && ( chi_i <= 120.0 ) ) { rot[i] = 1; }
295 else if ( std::abs(chi_i) > 120.0 ) { rot[i] = 2; }
298 }
else if ( res ==
aa_gln ) {
301 if ( chi_i >= 135.0 || chi_i < -135.0 ) { rot[i] = 1; }
302 else if ( chi_i >= -135.0 && chi_i < -45.0 ) { rot[i] = 2; }
303 else if ( chi_i >= -45.0 && chi_i < 45.0 ) { rot[i] = 3; }
306 if ( chi_i >= -180.0 && chi_i < -90.0 ) { rot[i] = 1; }
307 else if ( chi_i >= -90.0 && chi_i < 0.0 ) { rot[i] = 2; }
308 else if ( chi_i >= 0.0 && chi_i < 90.0 ) { rot[i] = 3; }
311 }
else if ( res ==
aa_pro ) {
315 }
else if ( i == 4 ) {
317 if ( ( chi_i >= 0.0 ) && ( chi_i <= 120.0 ) ) { rot[i] = 1; }
318 else if ( std::abs(chi_i) > 120.0 ) { rot[i] = 2; }
366 return library->rotamer_energy( rsd, scratch );
374 bool curr_rotamer_only,
381 if ( curr_rotamer_only )
382 return library->best_rotamer_energy( rsd,
true,scratch );
384 return library->best_rotamer_energy( rsd,
false,scratch );
399 return library->rotamer_energy_deriv( rsd, scratch );
408 std::fill( dE_dbb.begin(), dE_dbb.end(), 0 );
409 std::fill( dE_dchi.begin(), dE_dchi.end(), 0 );
440 utility_exit_with_message(
"cant add rsd library twice");
442 libraries_.insert( std::make_pair( aa, rot_lib() ) );
522 TR.Debug <<
"Warning: using PDB_ROTAMERS for non-ligand ResidueType!" << std::endl;
529 return pdb_rotamers();
562 using namespace basic::options;
563 using namespace basic::options::OptionKeys;
565 if ( option[ in::file::no_binary_dunlib ] )
return false;
568 utility::io::izstream binlib( binary_filename.c_str(), std::ios::in | std::ios::binary );
577 if ( option[ corrections::score::dun10 ] ) {
612 using namespace basic::options;
613 using namespace basic::options::OptionKeys;
615 if ( option[ corrections::score::dun10 ] ) {
625 boost::int32_t version( 0 );
626 binlib.read( (
char*) & version,
sizeof( boost::int32_t ));
647 boost::int32_t version( 0 );
648 binlib.read( (
char*) & version,
sizeof( boost::int32_t ));
651 boost::int32_t nrotameric( 0 );
652 binlib.read( (
char*) & nrotameric,
sizeof( boost::int32_t ) );
653 boost::int32_t nsemirotameric( 0 );
654 binlib.read( (
char*) & nsemirotameric,
sizeof( boost::int32_t ) );
667 rotameric_amino_acids, rotameric_n_chi,
668 sraa, srnchi, scind, sampind, sym, astr );
671 if ( static_cast< Size > (nrotameric) != rotameric_amino_acids.size() )
return false;
672 if ( static_cast< Size > (nsemirotameric) != sraa.size() )
return false;
674 boost::int32_t * rotaa_bin =
new boost::int32_t[ nrotameric ];
675 boost::int32_t * rot_nchi_bin=
new boost::int32_t[ nrotameric ];
677 boost::int32_t * sraa_bin =
new boost::int32_t[ nsemirotameric ];
678 boost::int32_t * srnchi_bin =
new boost::int32_t[ nsemirotameric ];
679 boost::int32_t * scind_bin =
new boost::int32_t[ nsemirotameric ];
680 boost::int32_t * sampind_bin =
new boost::int32_t[ nsemirotameric ];
681 boost::int32_t * sym_bin =
new boost::int32_t[ nsemirotameric ];
682 Real * astr_bin =
new Real[ nsemirotameric ];
684 binlib.read( (
char*) rotaa_bin, nrotameric *
sizeof( boost::int32_t ));
685 binlib.read( (
char*) rot_nchi_bin, nrotameric *
sizeof( boost::int32_t ));
687 binlib.read( (
char*) sraa_bin, nsemirotameric *
sizeof( boost::int32_t ));
688 binlib.read( (
char*) srnchi_bin, nsemirotameric *
sizeof( boost::int32_t ));
689 binlib.read( (
char*) scind_bin, nsemirotameric *
sizeof( boost::int32_t ));
690 binlib.read( (
char*) sampind_bin, nsemirotameric *
sizeof( boost::int32_t ));
691 binlib.read( (
char*) sym_bin, nsemirotameric *
sizeof( boost::int32_t ));
692 binlib.read( (
char*) astr_bin, nsemirotameric *
sizeof(
Real ));
695 for (
Size ii = 1; ii <= rotameric_amino_acids.size(); ++ii ) {
696 if ( rotaa_bin[ ii - 1 ] != static_cast< boost::int32_t > ( rotameric_amino_acids[ ii ] ) ) good =
false;
697 if ( rot_nchi_bin[ ii - 1 ] != static_cast< boost::int32_t > ( rotameric_n_chi[ ii ] ) ) good =
false;
699 for (
Size ii = 1; ii <= sraa.size(); ++ii ) {
700 if ( sraa_bin[ ii - 1 ] != static_cast< boost::int32_t > ( sraa[ ii ] ) ) good =
false;
701 if ( srnchi_bin[ ii - 1 ] != static_cast< boost::int32_t > ( srnchi[ ii ] ) ) good =
false;
702 if ( scind_bin[ ii - 1 ] != static_cast< boost::int32_t > ( scind[ ii ] ) ) good =
false;
703 if ( sampind_bin[ ii - 1 ] != static_cast< boost::int32_t > ( sampind[ ii ] ) ) good =
false;
704 if ( sym_bin[ ii - 1 ] != static_cast< boost::int32_t > ( sym[ ii ] ) ) good =
false;
705 if ( astr_bin[ ii - 1 ] != astr[ ii ] ) good =
false;
709 delete [] rot_nchi_bin;
711 delete [] srnchi_bin;
713 delete [] sampind_bin;
729 using namespace basic::options;
730 using namespace basic::options::OptionKeys;
732 if ( option[ in::file::no_binary_dunlib ] )
return false;
733 if ( option[ out::file::dont_rewrite_dunbrack_database ] )
return false;
741 #ifdef WIN32 // binary file handling doesnt appear to work properly on windows 64 bit machines.
747 utility::io::izstream binlib( binary_filename.c_str(), std::ios::in | std::ios::binary );
757 if ( option[ corrections::score::dun10 ] ) {
787 using namespace basic::options;
788 using namespace basic::options::OptionKeys;
789 return basic::database::full_name( option[ corrections::score::dun02_file ]);
795 using namespace basic::options;
796 using namespace basic::options::OptionKeys;
798 if ( option[ corrections::score::dun10 ] ) {
816 using namespace basic::options;
817 using namespace basic::options::OptionKeys;
819 return basic::database::full_name( option[ corrections::score::dun10_dir ] +
"/" +
"Dunbrack10.lib.bin" );
882 using namespace basic::options;
883 using namespace basic::options::OptionKeys;
885 if ( option[ corrections::score::dun10 ] ) {
895 using namespace basic::options;
896 using namespace basic::options::OptionKeys;
898 if ( option[ corrections::score::dun10 ] ) {
908 using namespace chemical;
922 clock_t starttime = clock();
932 Size count_libraries_read( 0 );
933 while ( nextaa !=
"" ) {
937 aan, nchi_for_aa[ aan ], libstream,
true , nextaa,
true );
938 ++count_libraries_read;
943 memory_use_rotameric[ aan ] = newlib->memory_usage_in_bytes();
950 if ( count_libraries_read != nrot_aas ) {
951 std::cerr <<
"ERROR: expected to read " << nrot_aas <<
" libraries from Dun02, but read " << count_libraries_read << std::endl;
955 clock_t stoptime = clock();
956 TR <<
"Dunbrack library took " << ((double)stoptime-starttime)/CLOCKS_PER_SEC <<
" seconds to load from ASCII" << std::endl;
974 clock_t starttime = clock();
977 utility::io::izstream binlib( binary_filename.c_str(), std::ios::in | std::ios::binary );
980 utility_exit_with_message(
"Could not open binary Dunbrack02 file from database -- how did this happen?");
986 boost::int32_t version( 0 );
987 binlib.read( (
char*) & version,
sizeof( boost::int32_t ));
995 clock_t stoptime = clock();
996 TR <<
"Dunbrack library took " << ((double)stoptime-starttime)/CLOCKS_PER_SEC <<
" seconds to load from binary" << std::endl;
1004 using namespace chemical;
1005 using namespace utility;
1007 TR <<
"Reading Dunbrack Libraries" << std::endl;
1009 clock_t starttime = clock();
1021 std::string const regular_lib_suffix =
".bbdep.rotamers.lib";
1022 std::string const bbdep_contmin =
".bbdep.densities.lib";
1024 std::string const bbind_defs =
".Definitions.lib";
1059 rotameric_amino_acids, rotameric_n_chi,
1060 sraa, srnchi, scind, sampind, sym, astr
1063 for (
Size ii = 1; ii <= rotameric_amino_acids.size(); ++ii ) {
1068 std::transform(ii_lc_3lc.begin(), ii_lc_3lc.end(), ii_lc_3lc.begin(), tolower);
1069 std::string library_name = basic::options::option[basic::options::OptionKeys::corrections::score::dun10_dir]() +
"/" + ii_lc_3lc + regular_lib_suffix ;
1070 utility::io::izstream lib( library_name.c_str() );
1071 if ( !lib.good() ) {
1073 library_name = basic::database::full_name( basic::options::option[basic::options::OptionKeys::corrections::score::dun10_dir]() +
"/" + ii_lc_3lc + regular_lib_suffix );
1074 lib.open( library_name );
1076 if ( !lib.good() ) {
1077 utility_exit_with_message(
"Unable to open database file for Dun10 rotamer library: " + library_name );
1079 TR <<
"Reading " << library_name << std::endl;
1082 ii_aa, rotameric_n_chi[ ii ], lib,
false, next_aa_in_library,
false );
1083 if ( next_aa_in_library !=
"" ) {
1084 std::cerr <<
"ERROR: Inappropriate read from dun10 input while reading " << ii_aa
1085 <<
": \"" << next_aa_in_library <<
"\"" << std::endl;
1089 memory_use_rotameric.push_back( newlib->memory_usage_in_bytes() );
1096 for (
Size ii = 1; ii <= sraa.size(); ++ii ) {
1099 std::transform(ii_lc_3lc.begin(), ii_lc_3lc.end(), ii_lc_3lc.begin(), tolower);
1100 Size const nrchi = srnchi[ ii ] + 1;
1102 std::string reg_lib_name = basic::options::option[basic::options::OptionKeys::corrections::score::dun10_dir]() +
"/" + ii_lc_3lc + regular_lib_suffix ;
1103 std::string conmin_name = basic::options::option[basic::options::OptionKeys::corrections::score::dun10_dir]() +
"/" + ii_lc_3lc + bbdep_contmin ;
1104 std::string rotdef_name = basic::options::option[basic::options::OptionKeys::corrections::score::dun10_dir]() +
"/" + ii_lc_3lc + bbind_midfix + to_string(nrchi) + bbind_defs ;
1107 utility::io::izstream lib( reg_lib_name.c_str() );
1108 utility::io::izstream contmin( conmin_name.c_str() );
1109 utility::io::izstream defs( rotdef_name.c_str() );
1112 if ( !lib.good() ) {
1118 reg_lib_name = basic::database::full_name( basic::options::option[basic::options::OptionKeys::corrections::score::dun10_dir]() +
"/" + ii_lc_3lc + regular_lib_suffix );
1119 conmin_name = basic::database::full_name( basic::options::option[basic::options::OptionKeys::corrections::score::dun10_dir]() +
"/" + ii_lc_3lc + bbdep_contmin );
1120 rotdef_name = basic::database::full_name( basic::options::option[basic::options::OptionKeys::corrections::score::dun10_dir]() +
"/" + ii_lc_3lc + bbind_midfix + to_string(nrchi) + bbind_defs );
1123 lib.open(reg_lib_name);
1124 contmin.open(conmin_name);
1125 defs.open(rotdef_name);
1129 if ( !lib.good() ) {
1130 utility_exit_with_message(
"Unable to open database file for Dun10 rotamer library: " + reg_lib_name );
1132 if ( !contmin.good() ) {
1133 utility_exit_with_message(
"Unable to open database file for Dun10 rotamer library: " + conmin_name );
1135 if ( !defs.good() ) {
1136 utility_exit_with_message(
"Unable to open database file for Dun10 rotamer library: " + rotdef_name );
1139 TR <<
"Reading " << reg_lib_name << std::endl;
1140 TR <<
"Reading " << conmin_name << std::endl;
1141 TR <<
"Reading " << rotdef_name << std::endl;
1145 ii_aa, srnchi[ ii ],
1146 scind[ ii ], sampind[ ii ],
1147 sym[ ii ], astr[ ii ],
1148 defs, lib, contmin );
1150 memory_use_semirotameric.push_back( newlib->memory_usage_in_bytes() );
1156 TR <<
"Finished reading Dunbrack Libraries" << std::endl;
1158 clock_t stoptime = clock();
1159 TR <<
"Dunbrack 2010 library took " << ((double)stoptime-starttime)/CLOCKS_PER_SEC <<
" seconds to load from ASCII" << std::endl;
1162 TR <<
"Memory usage: " << std::endl;
1164 for (
Size ii = 1; ii <= memory_use_rotameric.size(); ++ii ) {
1165 total += memory_use_rotameric[ ii ];
1166 TR <<
chemical::name_from_aa(rotameric_amino_acids[ ii ]) <<
" with " << memory_use_rotameric[ ii ] <<
" bytes" << std::endl;
1169 for (
Size ii = 1; ii <= memory_use_semirotameric.size(); ++ii ) {
1170 total += memory_use_semirotameric[ ii ];
1173 TR <<
"Total memory on Dunbrack Libraries: " << total <<
" bytes." << std::endl;
1180 clock_t starttime = clock();
1183 utility::io::izstream binlib( binary_filename.c_str(), std::ios::in | std::ios::binary );
1186 utility_exit_with_message(
"Could not open binary Dunbrack10 file from database -- how did this happen?");
1192 boost::int32_t version( 0 );
1193 binlib.read( (
char*) & version,
sizeof( boost::int32_t ));
1202 boost::int32_t n_rotameric_aas( 0 );
1203 binlib.read( (
char*) & n_rotameric_aas,
sizeof( boost::int32_t ) );
1205 boost::int32_t n_semirotameric_aas( 0 );
1206 binlib.read( (
char*) & n_semirotameric_aas,
sizeof( boost::int32_t ) );
1208 Size const n_rotameric_arrays_read_of_int32s = 2;
1209 Size const n_semirot_arrays_read_of_int32s = 5;
1210 Size const n_semirot_arrays_read_of_Reals = 1;
1211 Size const bytes_to_skip =
1212 ( n_rotameric_arrays_read_of_int32s * n_rotameric_aas +
1213 n_semirot_arrays_read_of_int32s * n_semirotameric_aas ) *
sizeof( boost::int32_t ) +
1214 n_semirot_arrays_read_of_Reals * n_semirotameric_aas *
sizeof(
Real );
1218 char * temp_buffer =
new char[ bytes_to_skip ];
1219 binlib.read( temp_buffer, bytes_to_skip );
1220 delete [] temp_buffer;
1226 clock_t stoptime = clock();
1227 TR <<
"Dunbrack 2010 library took " << ((double)stoptime-starttime)/CLOCKS_PER_SEC <<
" seconds to load from binary" << std::endl;
1233 using namespace basic::options;
1234 using namespace basic::options::OptionKeys;
1236 if ( option[ corrections::score::dun10 ] ) {
1249 TR <<
"Opening file " << tempfilename <<
" for output." << std::endl;
1251 utility::io::ozstream binlib( tempfilename.c_str(), std::ios::out | std::ios::binary );
1258 binlib.write( (
char*) & version,
sizeof( boost::int32_t ));
1265 TR <<
"Moving temporary file to " << binary_filename.c_str() << std::endl;
1266 rename( tempfilename.c_str(), binary_filename.c_str() );
1268 TR <<
"Unable to open temporary file in rosetta database for writing the binary version of the Dunbrack02 library." << std::endl;
1280 TR <<
"Opening file " << tempfilename <<
" for output." << std::endl;
1282 utility::io::ozstream binlib( tempfilename.c_str(), std::ios::out | std::ios::binary );
1289 binlib.write( (
char*) & version,
sizeof( boost::int32_t ));
1302 rotameric_amino_acids, rotameric_n_chi,
1303 sraa, srnchi, scind, sampind, sym, astr );
1305 boost::int32_t nrotameric( static_cast< boost::int32_t > (rotameric_amino_acids.size() ));
1306 boost::int32_t nsemirotameric( static_cast< boost::int32_t > (sraa.size()) );
1308 binlib.write( (
char*) & nrotameric,
sizeof( boost::int32_t ) );
1309 binlib.write( (
char*) & nsemirotameric,
sizeof( boost::int32_t ) );
1312 boost::int32_t * rotaa_bin =
new boost::int32_t[ nrotameric ];
1313 boost::int32_t * rot_nchi_bin=
new boost::int32_t[ nrotameric ];
1315 boost::int32_t * sraa_bin =
new boost::int32_t[ nsemirotameric ];
1316 boost::int32_t * srnchi_bin =
new boost::int32_t[ nsemirotameric ];
1317 boost::int32_t * scind_bin =
new boost::int32_t[ nsemirotameric ];
1318 boost::int32_t * sampind_bin =
new boost::int32_t[ nsemirotameric ];
1319 boost::int32_t * sym_bin =
new boost::int32_t[ nsemirotameric ];
1320 Real * astr_bin =
new Real[ nsemirotameric ];
1322 for (
Size ii = 1; ii <= rotameric_amino_acids.size(); ++ii ) {
1323 rotaa_bin[ ii - 1 ] =
static_cast< boost::int32_t
> ( rotameric_amino_acids[ ii ] );
1324 rot_nchi_bin[ ii - 1 ] =
static_cast< boost::int32_t
> ( rotameric_n_chi[ ii ] );
1326 for (
Size ii = 1; ii <= sraa.size(); ++ii ) {
1327 sraa_bin[ ii - 1 ] =
static_cast< boost::int32_t
> ( sraa[ ii ] );
1328 srnchi_bin[ ii - 1 ] =
static_cast< boost::int32_t
> ( srnchi[ ii ] );
1329 scind_bin[ ii - 1 ] =
static_cast< boost::int32_t
> ( scind[ ii ] );
1330 sampind_bin[ ii - 1 ] =
static_cast< boost::int32_t
> ( sampind[ ii ] );
1331 sym_bin[ ii - 1 ] =
static_cast< boost::int32_t
> ( sym[ ii ] );
1332 astr_bin[ ii - 1 ] = astr[ ii ];
1336 binlib.write( (
char*) rotaa_bin, nrotameric *
sizeof( boost::int32_t ));
1337 binlib.write( (
char*) rot_nchi_bin, nrotameric *
sizeof( boost::int32_t ));
1339 binlib.write( (
char*) sraa_bin, nsemirotameric *
sizeof( boost::int32_t ));
1340 binlib.write( (
char*) srnchi_bin, nsemirotameric *
sizeof( boost::int32_t ));
1341 binlib.write( (
char*) scind_bin, nsemirotameric *
sizeof( boost::int32_t ));
1342 binlib.write( (
char*) sampind_bin, nsemirotameric *
sizeof( boost::int32_t ));
1343 binlib.write( (
char*) sym_bin, nsemirotameric *
sizeof( boost::int32_t ));
1344 binlib.write( (
char*) astr_bin, nsemirotameric *
sizeof(
Real ));
1346 delete [] rotaa_bin;
1347 delete [] rot_nchi_bin;
1349 delete [] srnchi_bin;
1350 delete [] scind_bin;
1351 delete [] sampind_bin;
1362 rename( tempfilename.c_str(), binary_filename.c_str() );
1364 TR <<
"Unable to open temporary file in rosetta database for writing the binary version of the Dunbrack '10 library." << std::endl;
1372 using namespace basic::options;
1373 using namespace basic::options::OptionKeys;
1377 char * tmpname_output = _tempnam( option[ in::path::database ](1).name().c_str(), prefix.c_str() );
1379 char * tmpname_output = tempnam( option[ in::path::database ](1).name().c_str(), prefix.c_str() );
1383 std::string str_name = option[ in::path::database ](1).name() +
"/" + prefix +
"XXXXXX";
1384 char *tmpname_output =
new char [str_name.size()+20];
1385 strcpy(tmpname_output, str_name.c_str());
1386 int fid = mkstemp( tmpname_output );
1388 utility_exit_with_message(
"Failed to open temporary file with mkstemp" );
1396 char * tmpname_output = tempnam( option[ in::path::database ](1).name().c_str(), prefix.c_str() );
1403 delete [] tmpname_output;
1405 free( tmpname_output );
1408 return tempfilename;
1415 utility::io::izstream & library,
1418 bool first_three_letter_code_already_read
1427 next_aa_in_library = r1->
read_from_file( library, first_three_letter_code_already_read );
1434 next_aa_in_library = r2->
read_from_file( library, first_three_letter_code_already_read );
1441 next_aa_in_library = r3->
read_from_file( library, first_three_letter_code_already_read );
1448 next_aa_in_library = r4->
read_from_file( library, first_three_letter_code_already_read );
1453 utility_exit_with_message(
"ERROR: too many chi angles desired for dunbrack library: " + n_chi );
1482 utility_exit_with_message(
"ERROR: too many chi angles desired for dunbrack library: " + n_chi );
1494 bool const use_bbind_rnchi_scoring,
1495 bool const use_bbind_rnchi_sampling,
1496 bool const nrchi_is_symmetric,
1497 Real const nrchi_start_angle,
1498 utility::io::izstream & rotamer_definitions,
1499 utility::io::izstream & regular_library,
1500 utility::io::izstream & continuous_minimization_bbdep
1511 rotamer_definitions, regular_library, continuous_minimization_bbdep );
1519 rotamer_definitions, regular_library, continuous_minimization_bbdep );
1525 utility_exit_with_message(
"ERROR: too many chi angles desired for semi-rotameric dunbrack library: " + nchi );
1537 bool const use_bbind_rnchi_scoring,
1538 bool const use_bbind_rnchi_sampling,
1539 bool const nrchi_is_symmetric,
1540 Real const nrchi_start_angle
1561 utility_exit_with_message(
"ERROR: too many chi angles desired for semi-rotameric dunbrack library: " + nchi );
1576 using namespace basic::options;
1577 using namespace basic::options::OptionKeys;
1579 static bool initialized(
false );
1591 if ( ! initialized ) {
1593 if ( option[ corrections::score::dun10 ] ) {
1595 rotameric_amino_acids, rotameric_n_chi,
1596 sraa, srnchi, scind, sampind, sym, astr );
1599 rotameric_amino_acids, rotameric_n_chi );
1604 Size find_rot_aa = 1;
1605 while ( find_rot_aa <= rotameric_amino_acids.size() ) {
1606 if ( rotameric_amino_acids[ find_rot_aa ] == aa_in ) {
1607 return create_rotameric_dunlib( aa_in, rotameric_n_chi[ find_rot_aa ], ! (option[ corrections::score::dun10 ] ) );
1612 Size find_semirot_aa = 1;
1613 while ( find_semirot_aa <= sraa.size() ) {
1614 if ( sraa[ find_semirot_aa ] == aa_in ) {
1615 Size i = find_semirot_aa;
1639 using namespace chemical;
1642 rotameric_amino_acids.reserve( 10 ); rotameric_n_chi.reserve( 10 );
1643 rotameric_amino_acids.push_back(
aa_cys ); rotameric_n_chi.push_back( 1 );
1644 rotameric_amino_acids.push_back(
aa_ile ); rotameric_n_chi.push_back( 2 );
1645 rotameric_amino_acids.push_back(
aa_lys ); rotameric_n_chi.push_back( 4 );
1646 rotameric_amino_acids.push_back(
aa_leu ); rotameric_n_chi.push_back( 2 );
1647 rotameric_amino_acids.push_back(
aa_met ); rotameric_n_chi.push_back( 3 );
1648 rotameric_amino_acids.push_back(
aa_pro ); rotameric_n_chi.push_back( 3 );
1649 rotameric_amino_acids.push_back(
aa_arg ); rotameric_n_chi.push_back( 4 );
1650 rotameric_amino_acids.push_back(
aa_ser ); rotameric_n_chi.push_back( 1 );
1651 rotameric_amino_acids.push_back(
aa_thr ); rotameric_n_chi.push_back( 1 );
1652 rotameric_amino_acids.push_back(
aa_val ); rotameric_n_chi.push_back( 1 );
1656 Size const n_semi_rotameric_aas = 8;
1657 sraa.resize( n_semi_rotameric_aas );
1658 srnchi.resize( n_semi_rotameric_aas );
1659 scind.resize( n_semi_rotameric_aas );
1660 sampind.resize( n_semi_rotameric_aas );
1661 sym.resize( n_semi_rotameric_aas );
1662 astr.resize( n_semi_rotameric_aas );
1666 sraa[++i] =
aa_asp; srnchi[i] = 1; scind[i] = 0; sampind[i] = 0; sym[i]=1; astr[i] = -90;
1667 sraa[++i] =
aa_glu; srnchi[i] = 2; scind[i] = 0; sampind[i] = 0; sym[i]=1; astr[i] = -90;
1668 sraa[++i] =
aa_phe; srnchi[i] = 1; scind[i] = 0; sampind[i] = 0; sym[i]=1; astr[i] = -30;
1669 sraa[++i] =
aa_his; srnchi[i] = 1; scind[i] = 0; sampind[i] = 0; sym[i]=0; astr[i] = -180;
1670 sraa[++i] =
aa_asn; srnchi[i] = 1; scind[i] = 0; sampind[i] = 0; sym[i]=0; astr[i] = -180;
1671 sraa[++i] =
aa_gln; srnchi[i] = 2; scind[i] = 0; sampind[i] = 0; sym[i]=0; astr[i] = -180;
1672 sraa[++i] =
aa_trp; srnchi[i] = 1; scind[i] = 0; sampind[i] = 0; sym[i]=0; astr[i] = -180;
1673 sraa[++i] =
aa_tyr; srnchi[i] = 1; scind[i] = 0; sampind[i] = 0; sym[i]=1; astr[i] = -30;
1683 using namespace chemical;
1686 Size n_rotameric_aas;
1688 rotameric_amino_acids.resize( 0 ); rotameric_amino_acids.reserve( n_rotameric_aas );
1689 rotameric_n_chi.resize( 0 ); rotameric_n_chi.reserve( n_rotameric_aas );
1692 if ( nchi_for_aa[ ii ] != 0 ) {
1693 rotameric_amino_acids.push_back(
AA(ii) );
1694 rotameric_n_chi.push_back( nchi_for_aa[ ii ] );
1703 Size & n_rotameric_aas
1706 using namespace chemical;
1708 std::fill( nchi_for_aa.begin(), nchi_for_aa.end(), 0 );
1709 n_rotameric_aas = 0;
1711 nchi_for_aa[
aa_cys ] = 1; ++n_rotameric_aas;
1712 nchi_for_aa[
aa_asp ] = 2; ++n_rotameric_aas;
1713 nchi_for_aa[
aa_glu ] = 3; ++n_rotameric_aas;
1714 nchi_for_aa[
aa_phe ] = 2; ++n_rotameric_aas;
1715 nchi_for_aa[
aa_his ] = 2; ++n_rotameric_aas;
1716 nchi_for_aa[
aa_ile ] = 2; ++n_rotameric_aas;
1717 nchi_for_aa[
aa_lys ] = 4; ++n_rotameric_aas;
1718 nchi_for_aa[
aa_leu ] = 2; ++n_rotameric_aas;
1719 nchi_for_aa[
aa_met ] = 3; ++n_rotameric_aas;
1720 nchi_for_aa[
aa_asn ] = 2; ++n_rotameric_aas;
1721 nchi_for_aa[
aa_pro ] = 3; ++n_rotameric_aas;
1722 nchi_for_aa[
aa_gln ] = 3; ++n_rotameric_aas;
1723 nchi_for_aa[
aa_arg ] = 4; ++n_rotameric_aas;
1724 nchi_for_aa[
aa_ser ] = 1; ++n_rotameric_aas;
1725 nchi_for_aa[
aa_thr ] = 1; ++n_rotameric_aas;
1726 nchi_for_aa[
aa_val ] = 1; ++n_rotameric_aas;
1727 nchi_for_aa[
aa_trp ] = 2; ++n_rotameric_aas;
1728 nchi_for_aa[
aa_tyr ] = 2; ++n_rotameric_aas;
1737 bool const nrchi_is_symmetric,
1738 Real const nrchi_start_angle,
1739 utility::io::izstream & rotamer_definitions,
1740 utility::io::izstream & regular_library,
1741 utility::io::izstream & continuous_minimization_bbdep
1747 srsrdl.
read_from_files( rotamer_definitions, regular_library, continuous_minimization_bbdep );
1754 bool const nrchi_is_symmetric,
1755 Real const nrchi_start_angle
1758 Real const nrchi_periodicity = nrchi_is_symmetric ? 180.0 : 360.0;
1759 Real const nrchi_bbdep_step_size = nrchi_is_symmetric ? 5.0 : 10.0;
1760 Real const nrchi_bbind_step_size = nrchi_is_symmetric ? 0.5 : 1.0;
1786 utility::io::ozstream out( filename );
1800 using namespace boost;
1802 Size count_libraries( 0 );
1807 if ( srdl ) ++count_libraries;
1812 boost::int32_t
const nlibraries = count_libraries;
1813 out.write( (
char*) & nlibraries,
sizeof( boost::int32_t ) );
1819 if ( ! srdl )
continue;
1822 boost::int32_t
const which_aa( it->first );
1823 out.write( (
char*) &which_aa,
sizeof( boost::int32_t ) );
1826 srdl->write_to_binary( out );
1839 using namespace boost;
1842 boost::int32_t nlibraries( 0 );
1843 in.read( (
char*) &nlibraries,
sizeof( boost::int32_t ) );
1844 for (
Size ii = 1; ii <=
Size( nlibraries ); ++ii ) {
1848 in.read( (
char*) &which_aa32,
sizeof( boost::int32_t ) );
1849 AA which_aa( static_cast< AA >( which_aa32 ) );
1854 utility_exit_with_message(
"Error reading single residue rotamer library for " +
name_from_aa( which_aa ) );
1856 single_lib->read_from_binary( in );
1884 std::string dir_name = basic::database::full_name(
"/rotamer/ncaa_rotlibs/" );
1886 utility::io::izstream rotlib_in( dir_name + file_name );
1887 std::cout <<
"Reading in rot lib " << dir_name + file_name <<
"...";
1901 switch ( n_rotlib_chi ) {
1906 ncaa_rotlib = r1;
break;
1911 ncaa_rotlib = r2;
break;
1916 ncaa_rotlib = r3;
break;
1921 ncaa_rotlib = r4;
break;
1923 utility_exit_with_message(
"ERROR: too many chi angles desired for ncaa library: " + n_rotlib_chi );
1929 std::cout <<
"done!" << std::endl;