22 #include <basic/Tracer.hh>
23 #include <basic/datacache/BasicDataCache.hh>
24 #include <basic/datacache/CacheableString.hh>
25 #include <basic/datacache/CacheableStringFloatMap.hh>
26 #include <basic/datacache/CacheableStringMap.hh>
27 #include <basic/options/option.hh>
28 #include <basic/options/keys/in.OptionKeys.gen.hh>
30 #include <numeric/constants.hh>
31 #include <numeric/xyz.functions.hh>
32 #include <numeric/xyzVector.string.hh>
33 #include <ObjexxFCL/string.functions.hh>
34 #include <utility/io/izstream.hh>
35 #include <utility/exit.hh>
36 #include <utility/string_util.hh>
37 #include <utility/excn/Exceptions.hh>
71 #include <utility/vector1.hh>
73 #include <boost/foreach.hpp>
74 #define foreach BOOST_FOREACH
81 #include <boost/functional/hash.hpp>
86 static basic::Tracer
TR(
"core.pose.util");
105 assert(jump_num <= pose->num_jump());
114 if (upstream_res.
natoms() < 3 || downstream_res.
natoms() < 3) {
115 TR.Warning <<
"Insufficient number of atoms for stub creation on one or more"
116 <<
" jump residues-- " << upstream <<
", " << downstream
131 assert(upstream_stub.
valid());
132 assert(downstream_stub.
valid());
141 using basic::datacache::BasicDataCache;
148 const BasicDataCache& cache = pose.
data();
153 static_cast<PositionConservedResiduesStore
const *
>(
156 return store->is_conserved(residue);
168 assert( nres == positions.size() );
173 for (
Size i=1; i<= nres; ++i ) {
174 Size const seqpos( positions[i] );
180 if ( prev_rsd.is_upper_terminus() || rsd.is_lower_terminus() || prev_rsd.chain() != rsd.chain() ) {
195 int const jump_number,
206 TR << src.
fold_tree() <<
'\n' << f1 <<
'\n' << f2 <<
'\n';
209 ObjexxFCL::FArray1D_bool partner1_pos( nres,
false );
213 for (
Size i=1; i<= nres; ++i ) {
214 if ( partner1_pos(i) ) partner1_pos_list.push_back( i );
215 else partner2_pos_list.push_back( i );
223 partner1.
dump_pdb(
"partner1.pdb" );
224 partner2.
dump_pdb(
"partner2.pdb" );
236 const int sstemp_offset=3;
240 sstemp[sstemp_offset-1] = 3;
241 sstemp[sstemp_offset+0] = 3;
249 sstemp[sstemp_offset+i] = 3;
254 if ( pose.
phi(i) < -20.0 && pose.
psi(i) > -90.0 && pose.
psi(i) < -10.0 ) {
255 sstemp[sstemp_offset+i] = 1;
256 }
else if ( pose.
phi(i) < -20.0 && (pose.
psi(i) > 20.0 || pose.
psi(i) < -170.0) ) {
257 sstemp[sstemp_offset+i] = 2;
259 sstemp[sstemp_offset+i] = 3;
266 if ( sstemp[sstemp_offset+i] == 2 ) {
267 if ( sstemp[sstemp_offset+i-1] == 2 && sstemp[sstemp_offset+i+1] == 2 ) {
269 }
else if ( sstemp[sstemp_offset+i-1] == 2 && sstemp[sstemp_offset+i-2] == 2 ) {
271 }
else if ( sstemp[sstemp_offset+i+1] == 2 && sstemp[sstemp_offset+i+2] == 2 ) {
276 }
else if ( sstemp[sstemp_offset+i] == 1 ) {
277 if ( sstemp[sstemp_offset+i-1] == 1 && sstemp[sstemp_offset+i+1] == 1 ) {
279 }
else if ( sstemp[sstemp_offset+i-1] == 1 && sstemp[sstemp_offset+i-2] == 1 ) {
281 }
else if ( sstemp[sstemp_offset+i+1] == 1 && sstemp[sstemp_offset+i+2] == 1 ) {
294 }
else if ( ss[i] == 2 ) {
310 TR.Warning <<
"addVirtualResAsRoot() called but pose is already rooted on a VRT residue ... continuing." << std::endl;
316 TR.Warning <<
"addVirtualResAsRoot() called with empty pose!" << std::endl;
321 int last_peptide_res = nres;
329 int r_start =
static_cast< int > ( std::floor( static_cast< double > (last_peptide_res) /3. ) );
330 int r_end =
static_cast< int > ( std::ceil ( 2.* static_cast< double > (last_peptide_res)/3. ) );
332 int r_start =
static_cast< int > ( std::floor( last_peptide_res/3 ) );
333 int r_end =
static_cast< int > ( std::ceil ( 2*last_peptide_res/3 ) );
337 for (
int i=r_start; i<=r_end; ++i ) {
341 if (!rsd.is_protein() )
continue;
344 this_d = (atom.xyz() -
xyz).length();
345 if (this_d < d_min) {
356 if (rsd_type_list.size() == 0) {
357 utility_exit_with_message(
"Cannot find residue type VRT" );
362 for (
Size j=1; j<= new_res->natoms(); ++j ) {
363 new_res->atom(j).xyz( new_res->atom(j).xyz()+
xyz );
378 TR.Debug <<
"addVirtualResAsRoot() setting new fold tree to " << newF << std::endl;
379 TR.Debug <<
" i_min = " << i_min <<
" d_min = " << d_min << std::endl;
390 for (
int i=1; i<= nres; ++i ) {
393 for (
Size j=1; j<= rsd.nheavyatoms(); ++j ) {
395 massSum += atom.xyz();
411 using basic::datacache::CacheableStringFloatMap;
412 using basic::datacache::CacheableStringFloatMapCOP;
419 CacheableStringFloatMapCOP data
420 =
dynamic_cast< CacheableStringFloatMap
const *
>
422 assert( data.get() != NULL );
424 std::map< std::string, float >::const_iterator it = data->map().find( name );
425 if ( it == data->map().end() ) {
439 using basic::datacache::CacheableStringFloatMap;
440 using basic::datacache::CacheableStringFloatMapOP;
446 new CacheableStringFloatMap()
450 CacheableStringFloatMapOP data
451 =
dynamic_cast< CacheableStringFloatMap*
>
454 runtime_assert( data.get() != NULL );
455 data->map()[name] = value;
464 using basic::datacache::CacheableStringMap;
465 using basic::datacache::CacheableStringMapOP;
471 new CacheableStringMap()
475 CacheableStringMapOP data
476 =
dynamic_cast< CacheableStringMap*
>
479 runtime_assert( data.get() != NULL );
480 data->map()[key] = val;
489 using basic::datacache::CacheableStringMap;
490 using basic::datacache::CacheableStringMapOP;
496 new CacheableStringMap()
500 CacheableStringMapOP data
501 =
dynamic_cast< CacheableStringMap*
>
504 runtime_assert( data.get() != NULL );
505 data->map()[key] = val;
513 using basic::datacache::CacheableStringFloatMap;
516 new CacheableStringFloatMap()
521 using basic::datacache::CacheableStringMap;
524 new CacheableStringMap()
529 using basic::datacache::CacheableStringMap;
532 new CacheableStringMap()
542 using basic::datacache::CacheableStringFloatMap;
543 using basic::datacache::CacheableStringFloatMapOP;
549 CacheableStringFloatMapOP data
550 =
dynamic_cast< CacheableStringFloatMap*
>
552 assert( data.get() != NULL );
554 data->map().erase( name );
566 if ( comment_map.find( key ) == comment_map.end() ) {
570 val = comment_map[ key ];
583 if ( score_line_strings_map.find( key ) == score_line_strings_map.end() ) {
587 val = score_line_strings_map[ key ];
595 using basic::datacache::CacheableStringMap;
596 using basic::datacache::CacheableStringMapOP;
599 CacheableStringMapOP data
600 =
dynamic_cast< CacheableStringMap*
>
602 std::map< std::string, std::string >::iterator it;
603 it = data->map().find(key);
604 if ( it != data->map().end() ) {
605 data->map().erase(it);
610 std::map< std::string, std::string >
615 using basic::datacache::CacheableStringMap;
616 using basic::datacache::CacheableStringMapCOP;
618 std::map< std::string, std::string > score_line_strings;
620 CacheableStringMapCOP data
621 =
dynamic_cast< CacheableStringMap
const *
>
623 score_line_strings = data->map();
624 runtime_assert( data.get() != NULL );
626 return score_line_strings;
629 std::map< std::string, std::string >
634 using basic::datacache::CacheableStringMap;
635 using basic::datacache::CacheableStringMapCOP;
637 std::map< std::string, std::string > comments;
639 CacheableStringMapCOP data
640 =
dynamic_cast< const CacheableStringMap*
>
642 comments = data->map();
643 runtime_assert( data.get() != NULL );
650 using namespace basic::options;
655 utility::io::izstream data( filename );
658 TR.Warning <<
"Cannot open psipred_ss2 file " << filename << std::endl;
664 while( getline( data, line ) ) {
665 if( line[0] ==
'#' || line ==
"" )
667 std::istringstream line_stream( line );
670 line_stream >> pos >> aa >> sec;
672 if ( sec !=
'H' && sec !=
'E' && sec !=
'C' ) {
673 TR.Warning <<
"unrecognized secstruct char : " << sec <<
" at seqpos " << count << std::endl;
676 secstructs.push_back(
'L' );
678 secstructs.push_back( sec );
688 assert( secstructs.size() == nres);
689 if( secstructs.size() != nres )
706 typedef std::map< int, char > Conf2PDB;
711 TR.Warning <<
"WARNING: conf2pdb_chain(): PDBInfo does not exist, returning empty map" << std::endl;
716 int const conf = pose.
chain( i );
717 char const pdb = pose.
pdb_info()->chain( i );
719 Conf2PDB::iterator c2p = conf2pdb.find( conf );
720 if ( c2p != conf2pdb.end() ) {
721 if ( c2p->second != pdb ) {
734 TR.Warning <<
"WARNING: conf2pdb_chain(): chain mapping inconsistent, returning empty map; ";
735 TR.Warning <<
"existing " << c2p->first <<
" -> " << c2p->second <<
" | ";
736 TR.Warning <<
"new " << conf <<
" -> " << pdb << std::endl;
743 conf2pdb[ conf ] = pdb;
779 bool const start_from_existing_numbering,
780 bool const keep_insertion_codes,
781 bool const rotate_chain_ids
786 typedef std::map< int, char > Conf2PDB;
789 TR.Warning <<
"WARNING: renumber_pdbinfo_based_on_conf_chains(): no PDBInfo, returning" << std::endl;
796 if ( conf2pdb.empty() ) {
797 TR.Warning <<
"WARNING: renumber_pdbinfo_based_on_conf_chains(): Request to fix PDBInfo chains, but ";
798 TR.Warning <<
"chain mapping is inconsistent, so that step will be skipped." << std::endl;
808 std::string letters(
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" );
809 for ( Conf2PDB::iterator i = conf2pdb.begin(), ie = conf2pdb.end(); i != ie; ++i ) {
811 std::string::size_type
const j = letters.find( i->second );
812 if ( j != std::string::npos ) {
813 if ( rotate_chain_ids ) {
814 letters.push_back( letters.at( j ) );
816 letters.erase( j, 1 );
823 for ( Conf2PDB::iterator i = conf2pdb.begin(), ie = conf2pdb.end(); i != ie; ++i ) {
825 if ( rotate_chain_ids ) {
826 i->second = letters.at( lidx % letters.size() );
828 runtime_assert( lidx < letters.size() );
829 i->second = letters.at( lidx );
842 chain_endings.push_back( pose.
n_residue() );
846 Size const chain_end = *i;
851 pdb_res = pdbinfo.
number( res ) - 1;
855 Conf2PDB::const_iterator c2p = conf2pdb.find( pose.
chain( chain_end ) );
856 assert( ( fix_chains && c2p != conf2pdb.end() ) || !fix_chains );
858 for ( ; res <= chain_end; ++res ) {
860 chain = pdbinfo.
chain( res );
868 icode = pdbinfo.
icode( res );
869 if ( keep_insertion_codes && ( pdbinfo.
icode( res ) ==
' ' || res == 1 ) ) {
871 }
else if ( !keep_insertion_codes ) {
937 throw utility::excn::EXCN_Msg_Exception(
"Pose utility remove_ligand_canonical_residues: I have received a pose with only one residue but cannot delete the last residue of the pose.");
953 core::Real const n_dec(pow(static_cast< Real > (10), static_cast< int > (n_dec_places)));
958 if(lhssize != rhssize) {
959 TR.Warning <<
"poses of different length in compare_atom_coordinates; doomed to fail!" << std::endl;
967 if(lhstype.name() != rhstype.name()) {
968 TR.Warning <<
"nonmatching ResidueTypes at " << i <<
" in compare_atom_coordinates" << std::endl;
974 core::Size const lhsatmsize(lhsatoms.size()), rhsatmsize(rhsatoms.size());
975 if(lhsatmsize != rhsatmsize) {
976 TR.Warning <<
"nonmatching numbers of atoms at residue " << i <<
" in compare_atom_coordinates" << std::endl;
977 TR.Warning <<
"How did we even get here? ResidueType comparison should have failed!" << std::endl;
982 for(
core::Size atm(1); atm <= lhsatmsize; ++atm){
983 if( (std::floor(lhsatoms[atm].
xyz().x()*n_dec) != std::floor(rhsatoms[atm].
xyz().x()*n_dec))
984 || (std::floor(lhsatoms[atm].
xyz().y()*n_dec) != std::floor(rhsatoms[atm].
xyz().y()*n_dec))
985 || (std::floor(lhsatoms[atm].
xyz().z()*n_dec) != std::floor(rhsatoms[atm].
xyz().z()*n_dec)) )
1000 std::stringstream lhs_str;
1004 std::stringstream rhs_str;
1007 return lhs_str.str() == rhs_str.str();
1024 std::map < id::AtomID , id::AtomID > atom_id_map;
1026 copy_dofs( pose, scratch_pose, atom_id_map );
1038 std::map < id::AtomID , id::AtomID > atom_id_map;
1040 copy_dofs( pose, chunk_pose, atom_id_map );
1048 Pose const & scratch_pose,
1053 std::map < id::AtomID , id::AtomID > atom_id_map;
1055 copy_dofs( pose, scratch_pose, atom_id_map );
1064 Pose const & scratch_pose,
1066 bool const backbone_only ,
1067 bool const ignore_virtual )
1070 std::map < id::AtomID , id::AtomID > atom_id_map;
1072 copy_dofs( pose, scratch_pose, atom_id_map );
1080 Pose const & scratch_pose,
1081 std::map < id::AtomID , id::AtomID >
const & atom_id_map )
1091 std::map < id::AtomID , id::AtomID >
const & atom_id_map ){
1093 std::map< id::AtomID, Size > atom_id_domain_map;
1102 atom_id_domain_map[
id::AtomID( j, i ) ] = 0;
1106 copy_dofs( pose, scratch_pose, atom_id_map, atom_id_domain_map );
1115 std::map< id::AtomID, Size >::const_iterator it1 = atom_id_domain_map.find( atom_id1 );
1116 std::map< id::AtomID, Size >::const_iterator it2 = atom_id_domain_map.find( atom_id2 );
1118 Size domain1( 999 );
1119 Size domain2( 999 );
1121 if ( it1 != atom_id_domain_map.end() ) domain1 = it1->second;
1122 if ( it2 != atom_id_domain_map.end() ) domain2 = it2->second;
1124 if ( domain1 == 0)
return true;
1126 if ( domain2 == 0)
return true;
1129 if ( domain1 < 999 && domain2 < 999 && domain1 != domain2 )
return true;
1143 for (
Size i = 1; i <= atom_ids1.size(); i++ ) {
1144 for (
Size j = 1; j <= atom_ids2.size(); j++ ) {
1145 if ( !
check_domain_map( atom_id_domain_map, atom_ids1[ i ], atom_ids2[ j ] ) )
return false;
1156 std::map < id::AtomID , id::AtomID >
const & atom_id_map,
1157 std::map< id::AtomID, Size >
const & atom_id_domain_map )
1160 using namespace core::id;
1161 using namespace core::kinematics;
1162 using namespace core::pose;
1165 AtomID current_atom_scratch_atom_id( 1, 1);
1166 AtomID input_stub_atom1_scratch_atom_id( 1, 1);
1167 AtomID input_stub_atom2_scratch_atom_id( 1, 1);
1168 AtomID input_stub_atom3_scratch_atom_id( 1, 1);
1170 AtomID stub_atom1_scratch_atom_id( 1, 1);
1171 AtomID stub_atom2_scratch_atom_id( 1, 1);
1172 AtomID stub_atom3_scratch_atom_id( 1, 1);
1173 AtomID reference_scratch_atom_id( 1, 1);
1174 AtomID dummy_atom_id( 1, 1);
1178 for ( std::map < id::AtomID , id::AtomID >::const_iterator
1179 it=atom_id_map.begin(), it_end = atom_id_map.end(); it != it_end; ++it ) {
1181 bool verbose(
false );
1183 Size const i = (it->first).rsd();
1184 Size const j = (it->first).atomno();
1193 if ( verbose ){ std::cout <<
"No current atom id? " <<
" skipping " << pose.
residue( i ).
name1() << i <<
" " << pose.
residue( i ).
atom_name( j ) << std::endl;}
1199 if ( current_atom->is_jump() ) {
1203 if ( !current_atom->parent() ) {
1204 if ( verbose ){ std::cout <<
"No parent " <<
" skipping " << pose.
residue( i ).
name1() << i <<
" " << pose.
residue( i ).
atom_name( j ) << std::endl;}
1211 if ( !
get_scratch_atom_id( input_stub_atom1_scratch_atom_id, atom_id_map, input_stub_atom1 ) ) {
1212 if ( verbose ){ std::cout <<
"No JUMP input_stub_atom1? " <<
" skipping " << pose.
residue( i ).
name1() << i <<
" " << pose.
residue( i ).
atom_name( j ) << std::endl;}
1215 if ( !
get_scratch_atom_id( input_stub_atom2_scratch_atom_id, atom_id_map, input_stub_atom2 ) ) {
1216 if ( verbose ){ std::cout <<
"No JUMP input_stub_atom2? " <<
" skipping " << pose.
residue( i ).
name1() << i <<
" " << pose.
residue( i ).
atom_name( j ) << std::endl;}
1219 if ( !
get_scratch_atom_id( input_stub_atom3_scratch_atom_id, atom_id_map, input_stub_atom3 ) ) {
1220 if ( verbose ){ std::cout <<
"No JUMP input_stub_atom3? " <<
" skipping " << pose.
residue( i ).
name1() << i <<
" " << pose.
residue( i ).
atom_name( j ) << std::endl;}
1223 Stub const input_stub( scratch_pose.
xyz( input_stub_atom1_scratch_atom_id ),
1224 scratch_pose.
xyz( input_stub_atom2_scratch_atom_id ),
1225 scratch_pose.
xyz( input_stub_atom3_scratch_atom_id ) );
1231 if ( verbose ){ std::cout <<
"No JUMP stub_atom1? " <<
" skipping " << pose.
residue( i ).
name1() << i <<
" " << pose.
residue( i ).
atom_name( j ) << std::endl;}
1235 if ( verbose ){ std::cout <<
"No JUMP stub_atom2? " <<
" skipping " << pose.
residue( i ).
name1() << i <<
" " << pose.
residue( i ).
atom_name( j ) << std::endl; }
1239 Size const stub3_rsd = stub_atom3->id().rsd();
1240 Size const stub3_atmno = stub_atom3->id().atomno();
1241 if ( verbose ){ std::cout <<
"No JUMP stub_atom3? " <<
" skipping " << pose.
residue( i ).
name1() << i <<
" " << pose.
residue( i ).
atom_name( j ) <<
1247 Stub const stub( scratch_pose.
xyz( stub_atom1_scratch_atom_id ),
1248 scratch_pose.
xyz( stub_atom2_scratch_atom_id ),
1249 scratch_pose.
xyz( stub_atom3_scratch_atom_id ) );
1251 Jump const jump( input_stub, stub );
1254 std::cout <<
"copy_dofs set jump --> " << pose.
residue( i ).
name1() << i <<
" " << pose.
residue( i ).
atom_name( j ) <<
" " << jump << std::endl;
1256 std::cout <<
"input_stub defined by: " << std::endl;
1257 std::cout <<
" " << input_stub_atom1->id().rsd() <<
" " << pose.
residue( input_stub_atom1->id().rsd() ).atom_name( input_stub_atom1->id().atomno() ) << std::endl;
1258 std::cout <<
" " << input_stub_atom2->id().rsd() <<
" " << pose.
residue( input_stub_atom2->id().rsd() ).atom_name( input_stub_atom2->id().atomno() ) << std::endl;
1259 std::cout <<
" " << input_stub_atom3->id().rsd() <<
" " << pose.
residue( input_stub_atom3->id().rsd() ).atom_name( input_stub_atom3->id().atomno() ) << std::endl;
1260 std::cout <<
" should match --> " << std::endl;
1265 std::cout <<
"stub defined by: " << std::endl;
1266 std::cout <<
" " << stub_atom1->id().rsd() <<
" " << pose.
residue( stub_atom1->id().rsd() ).atom_name( stub_atom1->id().atomno() ) << std::endl;
1267 std::cout <<
" " << stub_atom2->id().rsd() <<
" " << pose.
residue( stub_atom2->id().rsd() ).atom_name( stub_atom2->id().atomno() ) << std::endl;
1268 std::cout <<
" " << stub_atom3->id().rsd() <<
" " << pose.
residue( stub_atom3->id().rsd() ).atom_name( stub_atom3->id().atomno() ) << std::endl;
1269 std::cout <<
" should match --> " << std::endl;
1273 std::cout <<
"OLD " << pose.
jump(
AtomID( j, i ) ) << std::endl;
1285 if ( verbose ) std::cout <<
"NEW " << pose.
jump(
AtomID( j, i ) ) << std::endl;
1294 if ( !
get_scratch_atom_id( input_stub_atom1_scratch_atom_id, atom_id_map, input_stub_atom1 ) ) {
1295 if ( verbose ) { std::cout <<
"No D input_stub_atom1? " <<
" skipping " << pose.
residue( i ).
name1() << i <<
" " << pose.
residue( i ).
atom_name( j ) << std::endl; }
1299 if (
check_domain_map( atom_id_domain_map, current_atom->id(), input_stub_atom1->id() ) ){
1301 Real const d = ( scratch_pose.
xyz( current_atom_scratch_atom_id ) -
1302 scratch_pose.
xyz( input_stub_atom1_scratch_atom_id ) ).length();
1307 if ( verbose ) { std::cout <<
"D not OK to change? " << pose.
residue( i ).
name1() << i <<
" " << pose.
residue( i ).
atom_name( j ) << std::endl; }
1324 bool problem_with_sister(
false );
1325 for (
Size n = 0; n < input_stub_atom1->n_children(); n++ ) {
1328 if ( verbose ) { std::cout <<
"No THETA ... Sister atom outside region of interest? " <<
" skipping " << pose.
residue( i ).
name1() << i <<
" " << pose.
residue( i ).
atom_name( j ) << std::endl; }
1329 problem_with_sister =
true;
1335 if (problem_with_sister)
continue;
1339 if ( !
get_scratch_atom_id( input_stub_atom2_scratch_atom_id, atom_id_map, input_stub_atom2 ) ) {
1340 if ( verbose ) std::cout <<
"No THETA input_stub_atom2? " <<
" skipping " << pose.
residue( i ).
name1() << i <<
" " << pose.
residue( i ).
atom_name( j ) << std::endl;
1344 if ( input_stub_atom2_scratch_atom_id == current_atom_scratch_atom_id ) {
1345 if ( verbose ) { std::cout <<
"Part of jump triumvirate, No THETA " <<
" skipping " << pose.
residue( i ).
name1() << i <<
" " << pose.
residue( i ).
atom_name( j ) << std::endl; }
1351 downstream_atom_ids.push_back( current_atom->id() );
1352 upstream_atom_ids.push_back( input_stub_atom2->id() );
1353 for (
Size n = 0; n < input_stub_atom1->n_children(); n++ ) {
1354 if( input_stub_atom1->child( n ) == current_atom )
continue;
1355 upstream_atom_ids.push_back( input_stub_atom1->child( n )->id() );
1360 if (
check_domain_map( atom_id_domain_map, upstream_atom_ids, downstream_atom_ids ) ){
1362 Real const theta = angle_radians(
1363 scratch_pose.
xyz( current_atom_scratch_atom_id ),
1364 scratch_pose.
xyz( input_stub_atom1_scratch_atom_id ),
1365 scratch_pose.
xyz( input_stub_atom2_scratch_atom_id ) );
1370 AtomID const & granny = input_stub_atom2->id();
1371 std::cout <<
"Good job, change THETA! " << pose.
residue( i ).
name1() << i <<
" " << pose.
residue( i ).
atom_name( j ) <<
" " << ( atom_id_domain_map.find( current_atom->id() ) )->second <<
"; stub_atom2: " << pose.
residue( granny.
rsd() ).name1() << granny.
rsd()<<
" " << pose.
residue( granny.
rsd() ).atom_name( granny.
atomno() ) <<
" " << ( atom_id_domain_map.find( input_stub_atom2->id() ) )->second << std::endl;
1375 if ( verbose ) { std::cout <<
"THETA not OK to change? " << pose.
residue( i ).
name1() << i <<
" " << pose.
residue( i ).
atom_name( j ) << ( atom_id_domain_map.find( current_atom->id() ) )->second << std::endl; }
1386 bool stub3_is_external_sister(
false );
1387 bool stub3_is_external_granny(
false );
1393 if ( input_stub_atom3 == current_atom ) {
1394 if ( verbose ) { std::cout <<
"Part of jump triumvirate, No PHI " <<
" skipping " << pose.
residue( i ).
name1() << i <<
" " << pose.
residue( i ).
atom_name( j ) << std::endl; }
1398 if ( !
get_scratch_atom_id( input_stub_atom3_scratch_atom_id, atom_id_map, input_stub_atom3 ) ||
1399 ( input_stub_atom3_scratch_atom_id == current_atom_scratch_atom_id )
1409 if ( !input_stub_atom1->is_jump() &&
1410 !input_stub_atom3->is_jump() &&
1411 input_stub_atom3->input_stub_atom3() == input_stub_atom1->input_stub_atom2() &&
1413 input_stub_atom1->input_stub_atom2() ) ){
1415 reference_atom = input_stub_atom1->input_stub_atom2();
1417 stub3_is_external_sister =
true;
1418 atom_to_move = input_stub_atom3;
1420 if ( verbose ) { std::cout <<
"SPECIAL CASE input_stub_atom3 is external sister! " << pose.
residue( i ).
name1() << i <<
" " << pose.
residue( i ).
atom_name( j ) << std::endl; }
1425 for (
Size n = 0; n < input_stub_atom2->n_children(); n++ ) {
1426 reference_atom = input_stub_atom2->child( n );
1427 if( reference_atom == input_stub_atom1 )
continue;
1429 stub3_is_external_granny =
true;
1430 atom_to_move = current_atom;
1435 if ( !stub3_is_external_granny ) {
1437 if ( verbose ) {std::cout <<
"No PHI input_stub_atom3? " <<
" skipping " << pose.
residue( i ).
name1() << i <<
" " << pose.
residue( i ).
atom_name( j ) << std::endl; }
1441 if ( verbose ) { std::cout <<
"SPECIAL CASE input_stub_atom3 is external granny! " << pose.
residue( i ).
name1() << i <<
" " << pose.
residue( i ).
atom_name( j ) << std::endl; }
1450 upstream_atom_ids.clear();
1451 downstream_atom_ids.clear();
1452 for (
Size n = 0; n < input_stub_atom1->n_children(); n++ ) {
1453 if( input_stub_atom1->child( n ) == input_stub_atom3 )
continue;
1454 downstream_atom_ids.push_back( input_stub_atom1->child( n )->id() );
1456 if ( stub3_is_external_sister ) downstream_atom_ids.push_back( input_stub_atom3->id() );
1459 if ( input_stub_atom2->parent() ) upstream_atom_ids.push_back( input_stub_atom2->parent()->id() );
1461 for (
Size n = 0; n < input_stub_atom2->n_children(); n++ ) {
1462 if( input_stub_atom2->child( n ) == input_stub_atom1 )
continue;
1463 upstream_atom_ids.push_back( input_stub_atom2->child( n )->id() );
1467 if (
check_domain_map( atom_id_domain_map, upstream_atom_ids, downstream_atom_ids ) ) {
1469 if ( stub3_is_external_sister || stub3_is_external_granny ) {
1471 Real const phi = dihedral_radians(
1472 scratch_pose.
xyz( current_atom_scratch_atom_id ),
1473 scratch_pose.
xyz( input_stub_atom1_scratch_atom_id ),
1474 scratch_pose.
xyz( input_stub_atom2_scratch_atom_id ),
1475 scratch_pose.
xyz( reference_scratch_atom_id ) );
1477 Real const reference_phi = dihedral_radians(
1478 reference_pose.
xyz( current_atom->id() ),
1479 reference_pose.
xyz( input_stub_atom1->id() ),
1480 reference_pose.
xyz( input_stub_atom2->id() ),
1481 reference_pose.
xyz( reference_atom->id() ) );
1485 if ( verbose ) std::cout <<
"Good JOB, CHANGED PHI THROUGH OFFSET! " << pose.
residue( i ).
name1() << i <<
" " << pose.
residue( i ).
atom_name( j ) << std::endl;
1487 }
else if (
check_domain_map( atom_id_domain_map, current_atom->id(), input_stub_atom3->id() ) ){
1489 Real const phi = dihedral_radians(
1490 scratch_pose.
xyz( current_atom_scratch_atom_id ),
1491 scratch_pose.
xyz( input_stub_atom1_scratch_atom_id ),
1492 scratch_pose.
xyz( input_stub_atom2_scratch_atom_id ),
1493 scratch_pose.
xyz( input_stub_atom3_scratch_atom_id ) );
1497 if ( verbose ) std::cout <<
"Good JOB, CHANGED PHI! " << pose.
residue( i ).
name1() << i <<
" " << pose.
residue( i ).
atom_name( j ) << std::endl;
1501 AtomID const & great_granny = input_stub_atom3->id();
1502 std::cout <<
"special case but current and input_stub_atom3 in same domain? "
1504 <<
" " << ( atom_id_domain_map.find( current_atom->id() ) )->second
1505 <<
" in map? " << ( atom_id_domain_map.find( current_atom->id() ) != atom_id_domain_map.end() )
1506 <<
"; stub_atom3: " << pose.
residue( great_granny.
rsd() ).name1()
1507 << great_granny.
rsd()<<
" " << pose.
residue( great_granny.
rsd() ).atom_name( great_granny.
atomno() )
1508 <<
" " << ( atom_id_domain_map.find( great_granny ) )->second
1509 <<
" in map? " << ( atom_id_domain_map.find( great_granny ) != atom_id_domain_map.end() )
1530 std::map< core::id::AtomID, core::id::AtomID>
const & atom_id_map,
1534 using namespace core::id;
1536 if ( !other_atom )
return false;
1538 std::map< AtomID, AtomID >::const_iterator iter( atom_id_map.find( other_atom->id() ) );
1539 if ( iter == atom_id_map.end() )
return false;
1541 other_scratch_atom_id = iter->second;
1550 std::map < core::id::AtomID , core::id::AtomID > & atom_id_map,
1554 using namespace core::id;
1556 for ( ResMap::const_iterator
1557 it=res_map.begin(), it_end = res_map.end(); it != it_end; ++it ) {
1559 Size const i = it->first;
1560 Size const i_scratch_pose = it->second;
1570 for (
Size j = 1; j <= rsd_type.natoms(); j++ ) {
1575 atom_id_map[
AtomID( j, i ) ] =
AtomID( count, i_scratch_pose );
1586 std::map < core::id::AtomID , core::id::AtomID > & atom_id_map,
1590 bool const backbone_only ,
1591 bool const ignore_virtual )
1593 using namespace core::id;
1595 for ( ResMap::const_iterator
1596 it=res_map.begin(), it_end = res_map.end(); it != it_end; ++it ) {
1598 Size const i1 = it->first;
1599 Size const i2 = it->second;
1604 for (
Size j1 = 1; j1 <= rsd_type1.natoms(); j1++ ) {
1607 if ( ignore_virtual && rsd_type1.is_virtual( j1 ) )
continue;
1609 std::string const & atom_name1 = rsd_type1.atom_name( j1 );
1611 if ( ! rsd_type2.has( atom_name1 ) )
continue;
1619 if ( backbone_only &&
1620 !( j1 <= rsd_type1.last_backbone_atom() ) &&
1621 !( j1 > rsd_type1.nheavyatoms() && j1 < rsd_type1.first_sidechain_hydrogen() ) )
continue;
1624 Size const j2 = rsd_type2.atom_index( atom_name1 );
1627 if ( ignore_virtual && rsd_type2.is_virtual( j2 ) )
continue;
1643 std::map < core::id::AtomID , core::id::AtomID > & atom_id_map,
1647 using namespace core::id;
1649 for ( ResMap::const_iterator it=res_map.begin(), it_end = res_map.end(); it != it_end; ++it ) {
1651 Size const full_seq_num = it->first;
1652 Size const chunk_seq_num = it->second;
1658 for(
Size j1 = 1; j1 <= rsd_type1.natoms(); j1++ ) {
1659 for(
Size j2=1; j2<=chunk_atom_names_list[chunk_seq_num].size(); j2++){
1661 std::string const & atom_name1 = rsd_type1.atom_name( j1 );
1662 std::string const & atom_name2 = chunk_atom_names_list[chunk_seq_num][j2];
1664 if(atom_name1==atom_name2){
1665 atom_id_map[
AtomID( j1, full_seq_num ) ] =
AtomID( j2, chunk_seq_num );
1694 bool raise_exception
1696 using namespace core::id;
1698 if ( named_atom_id.
valid() ) {
1701 if ( rt.
has( named_atom_id.
atom() ) ) {
1727 using namespace core::id;
1746 using namespace core::id;
1772 static_cast< basic::datacache::CacheableString
const &
>
1781 using basic::datacache::CacheableString;
1806 for(
core::Size ires = ir; ires <= std::min( srclength, std::min( tgtlength, jr)) ; ires++){
1827 for(
core::Size ijmp = 1; ijmp <= srcjmps ; ijmp++){
1833 TR.Debug <<
"In transfer_jumps() unable to map jump: " << srcedge_i.
start() <<
" , " << srcedge_i.
stop() << std::endl;
1873 if ( old_rsd.
nchi() == new_rsd_type.nchi() ) {
1874 for (
Size chino=1; chino <= old_rsd.
nchi(); ++chino ) {
1875 new_rsd->set_chi( chino, old_rsd.
chi( chino ) );
1878 TR <<
"The chi angles will not be updated and your dunbrack score for this rotamer will be huge; this function is only meant to add a variant type to a residue of the same type" << std::endl;
1896 chemical::ResidueType const & new_rsd_type( rsd_set.get_residue_type_with_variant_added( old_rsd.
type(), variant_type ) );
1899 if ( old_rsd.
nchi() == new_rsd_type.nchi() ) {
1900 for (
Size chino=1; chino <= old_rsd.
nchi(); ++chino ) {
1901 new_rsd->set_chi( chino, old_rsd.
chi( chino ) );
1904 TR <<
"The chi angles will not be updated and your dunbrack score for this rotamer will be huge; this function is only meant to add a variant type to a residue of the same type" << std::endl;
1921 runtime_assert( seqpos != 0 );
1926 chemical::ResidueType const & new_rsd_type( rsd_set.get_residue_type_with_variant_added( old_rsd.type(), variant_type ) );
1947 chemical::ResidueType const & new_rsd_type( rsd_set.get_residue_type_with_variant_removed( old_rsd.type(), variant_type ) );
2011 for (
Size i = 1; i <= n_res; ++i ) {
2018 int const n_torsions( rsd.mainchain_atoms().size() );
2019 for (
int j=1; j<= n_torsions; ++j ) {
2023 dof_map[ id ] = tor_id;
2031 int const n_torsions( rsd.nchi() );
2032 for (
int j=1; j<= n_torsions; ++j ) {
2036 dof_map[ id ] = tor_id;
2045 for (
int j=1; j<= 6; ++j ) {
2048 dof_map[ id ] =tor_id;
2080 for (
Size i = 1; i <= n_res; ++i ) {
2089 int const n_torsions( rsd.mainchain_atoms().size() );
2090 for (
int j=1; j<= n_torsions; ++j ) {
2092 if ( mm_setting == PHI_default )
continue;
2100 dof_mask[ id ] = mm_setting;
2114 int const n_torsions( rsd.nchi() );
2115 for (
int j=1; j<= n_torsions; ++j ) {
2117 if ( mm_setting == PHI_default )
continue;
2121 dof_mask[ id ] = mm_setting;
2123 TR.Warning <<
"WARNING: Unable to find atom_tree atom for this " <<
2124 " Rosetta chi angle: " << i <<
' ' << j << std::endl;
2134 for (
int j=1; j<= 6; ++j ) {
2137 dof_mask[ id ] =
true;
2146 it != it_end; ++it ) {
2147 dof_mask[ it->first ] = it->second;
2155 assert(chain.size()==1);
2156 char chain_char= chain[0];
2164 if(this_char == chain){
2171 std::set<core::Size>
2173 std::set<core::Size> jump_ids;
2174 std::set<core::Size>::const_iterator chain_id= chain_ids.begin();
2175 for(; chain_id != chain_ids.end(); ++chain_id){
2177 jump_ids.insert(jump_id);
2187 if(chain_id==ligand_chain_id){
2197 assert(chain.size()==1);
2198 if( chain.size() > 1) utility_exit_with_message(
"Multiple chain_ids per chain! Are you using '-treat_residues_in_these_chains_as_separate_chemical_entities', and not using compatible movers?" );
2199 char chain_char= chain[0];
2206 assert(chain_ids.size() == 1);
2207 return chain_ids[1];
2212 assert(chain.size()==1);
2213 char chain_char= chain[0];
2223 if(this_char == chain){
2224 chain_ids.push_back(i);
2254 assert(chain.size()==1);
2255 char chain_char= chain[0];
2261 return pose.
chain(ligand_residue_id);
2275 for(; begin <=
end; ++begin){
2284 return pose.
pdb_info()->chain(first_chain_residue);
2293 for (; begin <=
end; ++begin) {
2296 TR.Debug <<
"# of heavy atoms: "<< total_heavy_atoms << std::endl;
2297 return total_heavy_atoms;
2306 for (; begin <=
end; ++begin) {
2309 TR.Debug <<
"# of heavy atoms: "<< total_atoms << std::endl;
2319 for (; begin <=
end; ++begin) {
2322 TR.Debug <<
"# of heavy atoms: "<< total_hbond_acceptors << std::endl;
2323 return total_hbond_acceptors;
2332 for (; begin <=
end; ++begin) {
2335 TR.Debug <<
"# of heavy atoms: "<< total_hbond_donors << std::endl;
2336 return total_hbond_donors;
2345 for (; begin <=
end; ++begin) {
2348 return total_chi_angles;
2358 for (; begin <=
end; ++begin) {
2371 for (; begin <=
end; ++begin) {
2385 for(
core::Size res_num = chain_begin; res_num <= chain_end; ++res_num)
2388 for(
core::Size atom_num = 1; atom_num <= natoms; ++atom_num)
2392 boost::hash_combine(hash,current_xyz);
2407 if((
int)chain_id == pose.
chain(res_num))
2412 for(
core::Size atom_num = 1; atom_num <= natoms; ++atom_num)
2416 boost::hash_combine(hash,current_xyz);
2426 std::stringstream coord_stream;
2432 if((
int)chain_id == pose.
chain(res_num))
2438 for(
core::Size atom_num = 1; atom_num <= natoms; ++atom_num)
2442 coord_stream << numeric::truncate_and_serialize_xyz_vector(current_xyz,5);
2445 return utility::string_to_sha1(coord_stream.str());
2454 using basic::options::option;
2455 using namespace basic::options::OptionKeys;
2457 if ( basic::options::option[ basic::options::OptionKeys::in::fix_disulf ].user() ) {
2463 if ( option[ in::detect_disulf ].user() ?
2464 option[ in::detect_disulf ]() :
2475 using basic::datacache::CacheableString;
2476 using basic::datacache::CacheableStringOP;
2480 if( data.get() == NULL )
return std::string(
"UnknownTag");
2481 else return data->str();
2492 if ( first_pdbinfo && !first_pdbinfo->obsolete() && second_pdbinfo && !second_pdbinfo->obsolete() ) {
2495 retval[ii] = second_pdbinfo->pdb2pose( first_pdbinfo->chain(ii), first_pdbinfo->number(ii), first_pdbinfo->icode(ii) );
2498 TR <<
"One or both poses do not have usable PDBInfo, using sequence alignment instead." << std::endl;
2569 count += resi.
nchi();
2575 void lregister_util( lua_State * lstate ) {
2576 luabind::module(lstate,
"core")
2578 luabind::namespace_(
"pose")
2582 luabind::def(
"get_comment", &
get_comment, luabind::pure_out_value(_3)),