58 #include <numeric/util.hh>
59 #include <numeric/xyz.functions.hh>
62 #include <utility/assert.hh>
63 #include <utility/exit.hh>
64 #include <utility/pointer/owning_ptr.hh>
65 #include <utility/pointer/access_ptr.hh>
66 #include <utility/io/izstream.hh>
72 #include <basic/Tracer.hh>
76 #include <utility/vector1.hh>
79 static basic::Tracer
TR(
"core.conformation.util" );
83 namespace conformation {
92 bool lookup_bond_length
113 a2( fixed_rsd.
xyz( fixed_connection.
atomno() ) ),
114 b3( moving_rsd.
xyz( moving_connection.
atomno() ) ),
116 a3( fixed_connection.
icoor().
build( fixed_rsd, conformation ) ),
117 b2( moving_connection.
icoor().
build( moving_rsd, conformation ) );
124 if( lookup_bond_length ){
125 std::cout<<
"moving atom_type_index " << moving_rsd_atom_type_index<< std::endl;
126 std::cout<<
"fixed atom_type_index " << fixed_rsd_atom_type_index<< std::endl;
132 Real bond_length= ideal_bond_lengths->get_bond_length( fixed_rsd_atom_type_index, moving_rsd_atom_type_index);
134 Vector new_bond= old_bond;
136 new_bond.normalize(bond_length);
137 Vector offset = new_bond - old_bond;
147 for (
Size i=1; i<= moving_rsd.
natoms(); ++i ) {
150 moving_rsd.
set_xyz(i, global );
156 moving_rsd.
actcoord() = global_action_coord;
176 idl.append_residue_by_bond( *idl_rsd );
182 Size const nbb( rsd.n_mainchain_atoms() );
183 runtime_assert( nbb >= 2 );
184 for (
Size i=2; i<= nbb; ++i ) {
186 bb1_idl( rsd.mainchain_atom(i-1), idl_pos ),
187 bb1 ( rsd.mainchain_atom(i-1), seqpos ),
188 bb2_idl( rsd.mainchain_atom( i), idl_pos ),
189 bb2 ( rsd.mainchain_atom( i), seqpos );
192 conformation.
set_bond_length( bb1, bb2, idl.bond_length( bb1_idl, bb2_idl ) );
196 bb3_idl( rsd.mainchain_atom(i+1), idl_pos ),
197 bb3 ( rsd.mainchain_atom(i+1), seqpos );
200 conformation.
set_bond_angle( bb1, bb2, bb3, idl.bond_angle( bb1_idl, bb2_idl, bb3_idl ) );
204 if ( seqpos>1 && rsd.is_polymer() && !rsd.is_lower_terminus() ) {
206 idl.prepend_polymer_residue_before_seqpos( *prev_rsd, 1,
true );
209 Size const nbb_prev( prev_rsd->n_mainchain_atoms() );
211 bb1_idl( prev_rsd->mainchain_atom( nbb_prev ), idl_pos-1 ),
212 bb1 ( prev_rsd->mainchain_atom( nbb_prev ), seqpos-1 ),
213 bb2_idl( rsd.mainchain_atom( 1 ), idl_pos ),
214 bb2 ( rsd.mainchain_atom( 1 ), seqpos ),
215 bb3_idl( rsd.mainchain_atom( 2 ), idl_pos ),
216 bb3 ( rsd.mainchain_atom( 2 ), seqpos );
217 conformation.
set_bond_angle( bb1, bb2, bb3, idl.bond_angle( bb1_idl, bb2_idl, bb3_idl ) );
220 if ( seqpos < conformation.
size() && rsd.is_polymer() && !rsd.is_upper_terminus() ) {
222 idl.append_polymer_residue_after_seqpos( *next_rsd, idl_pos,
true );
225 bb1_idl( rsd.mainchain_atom( nbb-1 ), idl_pos ),
226 bb1 ( rsd.mainchain_atom( nbb-1 ), seqpos ),
227 bb2_idl( rsd.mainchain_atom( nbb ), idl_pos ),
228 bb2 ( rsd.mainchain_atom( nbb ), seqpos ),
229 bb3_idl( next_rsd->mainchain_atom( 1 ), idl_pos+1 ),
230 bb3 ( next_rsd->mainchain_atom( 1 ), seqpos+1 );
233 conformation.
set_bond_angle( bb1, bb2, bb3, idl.bond_angle( bb1_idl, bb2_idl, bb3_idl ) );
236 conformation.
set_bond_length( bb2, bb3, idl.bond_length( bb2_idl, bb3_idl ) );
254 runtime_assert( seqpos < conformation.
size() && rsd.is_polymer() && !rsd.is_upper_terminus() );
257 TR.Warning <<
"insert_ideal_bonds_at_polymer_junction: seqpos (" << seqpos <<
") is a foldtree cutpoint, " <<
258 "returning!" << std::endl;
265 idl.append_residue_by_bond( *idl_rsd );
270 Size const nbb( rsd.n_mainchain_atoms() );
271 runtime_assert( nbb >= 2 );
274 idl.append_polymer_residue_after_seqpos( *next_rsd, idl_pos,
true );
277 bb1_idl( rsd.mainchain_atom( nbb-1 ), idl_pos ),
278 bb1 ( rsd.mainchain_atom( nbb-1 ), seqpos ),
279 bb2_idl( rsd.mainchain_atom( nbb ), idl_pos ),
280 bb2 ( rsd.mainchain_atom( nbb ), seqpos ),
281 bb3_idl( next_rsd->mainchain_atom( 1 ), idl_pos+1 ),
282 bb3 ( next_rsd->mainchain_atom( 1 ), seqpos+1 ),
283 bb4_idl( next_rsd->mainchain_atom( 2 ), idl_pos+1 ),
284 bb4 ( next_rsd->mainchain_atom( 2 ), seqpos+1 );
287 conformation.
set_bond_angle( bb1, bb2, bb3, idl.bond_angle( bb1_idl, bb2_idl, bb3_idl ) );
290 conformation.
set_bond_length( bb2, bb3, idl.bond_length( bb2_idl, bb3_idl ) );
293 conformation.
set_bond_angle( bb2, bb3, bb4, idl.bond_angle( bb2_idl, bb3_idl, bb4_idl ) );
310 runtime_assert( seqpos > 0 );
311 runtime_assert( conformation.
size() >= seqpos );
312 runtime_assert( conformation.
size() > 0 );
320 idl.append_residue_by_bond( *idl_rsd );
324 bool lower_connect(
false ), upper_connect(
false );
326 if ( rsd.is_polymer() ) {
328 if ( seqpos > 1 && !rsd.is_lower_terminus() && !conformation.
fold_tree().
is_cutpoint( seqpos-1 ) ) {
329 lower_connect =
true;
331 idl.prepend_polymer_residue_before_seqpos( *prev_rsd, 1,
true );
335 if ( seqpos < conformation.
size() && !rsd.is_upper_terminus() && !conformation.
fold_tree().
is_cutpoint( seqpos ) ) {
336 upper_connect =
true;
338 idl.append_polymer_residue_after_seqpos( *next_rsd, idl_pos,
true );
346 for (
Size i=1; i<= rsd.nchi(); ++i ) {
347 idl.set_torsion( TorsionID( idl_pos,
CHI, i ), rsd.chi( i ) );
350 if ( rsd.is_polymer() ) {
351 Size const nbb( rsd.n_mainchain_atoms() );
352 for (
Size i=1; i<= nbb; ++i ) {
354 idl.set_torsion( TorsionID( idl_pos,
BB, i ), rsd.mainchain_torsion( i ) );
360 if ( rsd.is_polymer() ) {
363 Size const nbb( rsd.n_mainchain_atoms() );
364 runtime_assert( nbb >= 2 );
365 for (
Size i=2; i<= nbb; ++i ) {
367 bb1_idl( rsd.mainchain_atom(i-1), idl_pos ),
368 bb1 ( rsd.mainchain_atom(i-1), seqpos ),
369 bb2_idl( rsd.mainchain_atom( i), idl_pos ),
370 bb2 ( rsd.mainchain_atom( i), seqpos );
373 conformation.
set_bond_length( bb1, bb2, idl.bond_length( bb1_idl, bb2_idl ) );
377 bb3_idl( rsd.mainchain_atom(i+1), idl_pos ),
378 bb3 ( rsd.mainchain_atom(i+1), seqpos );
381 conformation.
set_bond_angle( bb1, bb2, bb3, idl.bond_angle( bb1_idl, bb2_idl, bb3_idl ) );
385 if ( lower_connect ) {
386 Residue const & prev_rsd( idl.residue( idl_pos-1 ) );
388 Size const nbb_prev( prev_rsd.n_mainchain_atoms() );
390 bb1_idl( prev_rsd.mainchain_atom( nbb_prev ), idl_pos-1 ),
391 bb1 ( prev_rsd.mainchain_atom( nbb_prev ), seqpos-1 ),
392 bb2_idl( rsd.mainchain_atom( 1 ), idl_pos ),
393 bb2 ( rsd.mainchain_atom( 1 ), seqpos ),
394 bb3_idl( rsd.mainchain_atom( 2 ), idl_pos ),
395 bb3 ( rsd.mainchain_atom( 2 ), seqpos );
396 conformation.
set_bond_angle( bb1, bb2, bb3, idl.bond_angle( bb1_idl, bb2_idl, bb3_idl ) );
399 if ( upper_connect ) {
400 Residue const & next_rsd( idl.residue( idl_pos+1 ) );
403 bb1_idl( rsd.mainchain_atom( nbb-1 ), idl_pos ),
404 bb1 ( rsd.mainchain_atom( nbb-1 ), seqpos ),
405 bb2_idl( rsd.mainchain_atom( nbb ), idl_pos ),
406 bb2 ( rsd.mainchain_atom( nbb ), seqpos ),
407 bb3_idl( next_rsd.mainchain_atom( 1 ), idl_pos+1 ),
408 bb3 ( next_rsd.mainchain_atom( 1 ), seqpos+1 );
411 conformation.
set_bond_angle( bb1, bb2, bb3, idl.bond_angle( bb1_idl, bb2_idl, bb3_idl ) );
414 conformation.
set_bond_length( bb2, bb3, idl.bond_length( bb2_idl, bb3_idl ) );
420 ResidueOP idl_rsd( idl.residue( idl_pos ).clone() );
429 idl_rsd->orient_onto_residue( conformation.
residue( seqpos ) );
446 using namespace core::kinematics;
447 runtime_assert( conf.
size() >= seqpos && seqpos >= 1 );
456 miniconf_idl.append_residue_by_bond( *prsd_idl );
459 int seqpos_miniconf(1);
461 if ( rsd.is_polymer() ) {
467 miniconf.safely_prepend_polymer_residue_before_seqpos
468 ( prev_rsd, 1,
false );
470 miniconf_idl.safely_prepend_polymer_residue_before_seqpos
471 ( *pprev_rsd_idl, 1,
true );
477 miniconf.safely_append_polymer_residue_after_seqpos
478 ( next_rsd, seqpos_miniconf,
false );
480 miniconf_idl.safely_append_polymer_residue_after_seqpos
481 ( *pnext_rsd_idl, seqpos_miniconf,
true );
487 for (
Size atom = 1, atom_end = miniconf.residue( seqpos_miniconf ).natoms();
492 if( miniconf.atom_tree().atom(aid).is_jump() )
496 if( ! numeric::equal_by_epsilon(
497 miniconf.dof( dof_theta ), miniconf_idl.dof( dof_theta ), theta_epsilon ) ) {
498 TR <<
"Non-ideal residue detected: "
499 <<
" Residue #" << seqpos <<
" atom #" << atom <<
"( " << rsd.atom_name( atom ) <<
" ) " <<
": "
500 <<
" Ideal theta=" << miniconf_idl.dof( dof_theta)
501 <<
", Inspected theta=" << miniconf.dof( dof_theta )
506 if( ! numeric::equal_by_epsilon(
507 miniconf.dof( dof_D), miniconf_idl.dof (dof_D), D_epsilon ) ) {
508 TR <<
"Non-ideal residue detected: "
509 <<
" Residue #" << seqpos <<
" atom #" << atom <<
"( " << rsd.atom_name( atom ) <<
" ) " <<
": "
510 <<
" Ideal D=" << miniconf_idl.dof( dof_D)
511 <<
", Inspected D=" << miniconf.dof( dof_D )
536 bool any_missing(
false );
538 for (
Size i=1; i<= natoms; ++i ) {
540 if ( source_rsd.
has( atom_name ) ) {
543 TR.Debug <<
"copy_residue_coordinates_and_rebuild_missing_atoms: missing atom " << target_rsd.
name() <<
' ' <<
544 atom_name << std::endl;
563 os << rsd.
atom_name(
id.atomno() ) <<
" (" <<
id.atomno() <<
") " << rsd.
name() <<
' ' << rsd.
seqpos();
573 os <<
"ATOM ";
print_atom( atom.
id(), conf, os ) << std::endl;
620 chemical::ResidueType const & new_rsd_type( rsd_set.get_residue_type_with_variant_added( old_rsd.type(), variant_type ) );
641 chemical::ResidueType const & new_rsd_type( rsd_set.get_residue_type_with_variant_removed( old_rsd.type(), variant_type ) );
704 atom_pointer.
clear();
705 atom_pointer.
resize( residues.size() );
709 int const start_pos( fold_tree.
root() );
710 Residue const & rsd( *(residues[start_pos]) );
718 it_end = fold_tree.
end(); it != it_end; ++it ) {
719 if ( it->is_jump() ) {
730 std::cerr <<
"Failed to identify kinematics::Edge label in core/kinematics/util.cc::build_tree()" << std::endl;
731 std::cerr <<
"Label = " << it->label() << std::endl;
738 it_end = fold_tree.
end(); it != it_end; ++it ) {
739 if ( it->is_jump() && it->keep_stub_in_residue() ) {
759 int const estart ( edge.
start() );
760 int const estop ( edge.
stop () );
763 Size anchor_atomno, root_atomno;
768 assert( anchor_atom );
774 anchor_atom->insert_atom( atom_pointer[
id::AtomID( root_atomno, estop ) ]() );
804 assert( dir == 1 || dir == -1 );
807 for (
int pos=
start+dir; pos !=
stop + dir; pos += dir ) {
809 int const anchor_pos( pos-dir );
810 Size anchor_atomno, root_atomno;
818 assert( anchor_atom && root_atom );
819 anchor_atom->insert_atom( root_atom() );
844 int const estart ( edge.
start() );
845 int const estop ( edge.
stop () );
848 Size anchor_atomno, root_atomno;
856 assert( anchor_atom && root_atom );
858 anchor_atom->insert_atom( root_atom() );
871 int const forward( 1 );
872 int const backward( -1 );
875 if ( dir == forward ) {
888 }
else if ( dir == backward ) {
915 Size const mainchain_index( ( nbb-1 )/2 + 1 );
935 assert( seqpos ==
Size( fold_tree.
root() ) );
942 if ( seqpos ==
Size(edge.start()) && edge.has_atom_info() ) {
943 root_atomno = rsd.
atom_index( edge.upstream_atom() );
944 TR.Debug <<
"Using jump " << i <<
945 " anchor atom as atomtree root " << edge.upstream_atom() << std::endl;
969 bool root_atom_is_jump_atom(
false );
972 int const seqpos( rsd.
seqpos() );
974 if ( seqpos == fold_tree.
root() ) {
975 root_atom_is_jump_atom =
true;
983 if ( edge.is_peptide() ) {
986 }
else if ( edge.is_jump() ) {
988 root_atom_is_jump_atom =
true;
989 if ( edge.has_atom_info() ) {
990 root_atomno = rsd.
atom_index( edge.downstream_atom() );
999 int const estart ( edge.start() );
1000 int const estop ( edge.stop () );
1001 Size anchor_atno, root_atno;
1003 root_atomno = (
int) root_atno;
1006 assert( root_atomno );
1016 for (
Size kk=1; kk<=cut_nbrs.size(); ++kk ) {
1017 if ( cut_nbrs[kk] == atom_index )
return false;
1032 int const nchi( chi_atoms.size() );
1034 for (
int i=1; i<= nchi; ++i ) {
1036 if ( atom1 == atoms[2] &&
1037 atom2 == atoms[1] )
return true;
1039 if ( atom1 == atoms[3] &&
1040 atom2 == atoms[4] )
return true;
1057 int const nchi( chi_atoms.size() );
1060 for (
int i=1; i<= nchi; ++i ) {
1063 if ( atom2 == atoms[2] &&
1064 ( atom1 == atoms[1] || atom1 == atoms[3] ) )
return false;
1066 if ( atom2 == atoms[3] &&
1067 ( atom1 == atoms[2] || atom1 == atoms[4] ) )
return false;
1071 for (
int i=1; i<= nchi; ++i ) {
1074 if ( atom2 == atoms[2] &&
1075 atom1 != atoms[1] &&
1076 atom1 != atoms[3] )
return true;
1078 if ( atom2 == atoms[3] &&
1079 atom1 != atoms[2] &&
1080 atom1 != atoms[4] )
return true;
1082 if ( (atom2 == atoms[1] && is_done[ atoms[4] ]) ||
1083 (atom2 == atoms[4] && is_done[ atoms[1] ]) )
return true;
1099 int const natoms( rsd.
natoms() );
1102 links.resize( natoms );
1104 for (
int atomno1=1; atomno1<= natoms; ++atomno1 ) {
1107 for (
Size jj=1; jj<= nbrs.size(); ++jj ) {
1109 links[ atomno1 ].push_back( nbrs[jj] );
1148 is_done[atom1] =
true;
1153 assert( new_l.empty() );
1155 Size const n_nbrs( full_l.size() );
1157 if ( n_nbrs == 1 ) {
1158 Size const nbr( full_l[1] );
1159 if ( !is_done[nbr] ) {
1161 new_l.push_back( nbr );
1162 setup_atom_links( nbr, full_links, is_done, is_mainchain, is_chi, is_hydrogen, chi_atoms, new_links );
1168 for (
Size i=1; i<= n_nbrs; ++i ) {
1169 int const atom2( full_l[i] );
1170 if ( is_done[ atom2 ] )
continue;
1172 if ( is_mainchain[ atom2 ] && is_chi[ atom1 ] && is_chi[ atom2 ] &&
chi_continuation( atom1, atom2, chi_atoms ) ) {
1173 new_l.push_back( atom2 );
1175 is_hydrogen, chi_atoms, new_links );
1180 for (
Size i=1; i<= n_nbrs; ++i ) {
1181 int const atom2( full_l[i] );
1182 if ( is_done[ atom2 ] )
continue;
1184 if ( is_mainchain[ atom2 ] ) {
1185 new_l.push_back( atom2 );
1187 is_hydrogen, chi_atoms, new_links );
1192 for (
Size i=1; i<= n_nbrs; ++i ) {
1193 int const atom2( full_l[i] );
1194 if ( is_done[ atom2 ] )
continue;
1196 if ( is_chi[ atom1 ] && is_chi[ atom2 ] &&
chi_continuation( atom1, atom2, chi_atoms ) && !is_hydrogen[ atom2 ] ) {
1197 new_l.push_back( atom2 );
1199 is_hydrogen, chi_atoms, new_links );
1204 for (
Size i=1; i<= n_nbrs; ++i ) {
1205 int const atom2( full_l[i] );
1206 if ( is_done[ atom2 ] )
continue;
1208 if ( is_chi[ atom2 ] && !is_hydrogen[ atom2 ]) {
1209 new_l.push_back( atom2 );
1211 is_hydrogen, chi_atoms, new_links );
1217 for (
Size i=1; i<= n_nbrs; ++i ) {
1218 int const atom2( full_l[i] );
1219 if ( is_done[ atom2 ] )
continue;
1221 if ( is_chi[ atom2 ] ) {
1222 new_l.push_back( atom2 );
1224 is_hydrogen, chi_atoms, new_links );
1229 for (
Size i=1; i<= n_nbrs; ++i ) {
1230 int const atom2( full_l[i] );
1231 if ( is_done[ atom2 ] )
continue;
1232 if ( is_chi[ atom2 ] &&
chi_interruption( atom1, atom2, chi_atoms, is_done ) )
continue;
1233 if ( !is_hydrogen[ atom2 ] ) {
1234 new_l.push_back( atom2 );
1236 is_hydrogen, chi_atoms, new_links );
1242 for (
Size i=1; i<= n_nbrs; ++i ) {
1243 int const atom2( full_l[i] );
1244 if ( is_done[ atom2 ] )
continue;
1245 if ( is_chi[ atom2 ] &&
chi_interruption( atom1, atom2, chi_atoms, is_done ) )
continue;
1246 new_l.push_back( atom2 );
1248 is_hydrogen, chi_atoms, new_links );
1258 int const root_atomno,
1275 BVec is_chi( natoms,
false );
1278 for (
Size i=1; i<= chi_atoms.size(); ++i ) {
1279 for (
int j=1; j<= 4; ++j ) {
1280 is_chi[ chi_atoms[i][j] ] =
true;
1287 BVec is_mainchain( natoms,
false );
1289 for (
Size i=1; i<= mainchain.size(); ++i ) {
1290 is_mainchain[ mainchain[i] ] =
true;
1293 is_mainchain[ rsd.
atom_index(
"OVL1") ] =
true;
1294 is_mainchain[ rsd.
atom_index(
"OVL2") ] =
true;
1297 is_mainchain[ rsd.
atom_index(
"OVU1") ] =
true;
1302 BVec is_hydrogen( natoms,
false );
1303 for (
Size i=1; i<= natoms; ++i ) {
1309 links.resize( natoms );
1311 BVec is_done( natoms,
false );
1313 is_hydrogen, chi_atoms, links );
1318 for (
Size i=1; i<= natoms; ++i ){
1319 if ( !is_done[ i ] ) {
1320 std::cout <<
"Unable to setup links for residue " << std::endl;
1321 for (
Size j=1; j<= natoms; ++j ) {
1322 std::cout << rsd.
atom_name(j) <<
' ' << is_done[j] <<
' ' << is_mainchain[j] <<
' ' << is_chi[j] <<
' ' <<
1323 is_hydrogen[j] << std::endl;
1335 int const root_atomno,
1338 bool const root_is_jump_atom
1344 atom_ptr.resize( natoms );
1355 for (
Size i=1; i<= natoms; ++i ) {
1356 atom_ptr[i]->xyz( rsd.
atom(i).
xyz() );
1375 if ( fold_tree.
is_root( seqpos ) ) {
1379 Size anchor_atomno, root_atomno, anchor_pos;
1382 else anchor_pos = edge.start();
1390 new_rsd_out.clear();
1393 Size anchor_atomno, root_atomno;
1394 Size const root_pos( ( it->is_polymer() ) ? seqpos + it->polymer_direction() : it->stop() );
1450 Size const nres( fold_tree.
nres() );
1451 Size const old_nres( atom_tree.
size() );
1452 assert( nres == residues.size() && seqpos <= nres && old_nres == nres-1 );
1457 for (
Size i=1; i<= old_nres; ++i ) {
1458 if ( i< seqpos ) old2new[i] = i;
1459 else old2new[i] = i+1;
1464 assert( atom_tree.
size() == nres );
1477 int anchor_atomno(0);
1478 assert( seqpos != (
Size)fold_tree.
root() );
1482 if ( edge.is_jump() ) {
1484 assert( (seqpos == (
Size)edge.stop()) && ((
Size)anchor_rsd.
seqpos() == (
Size)edge.start()) );
1485 if ( edge.has_atom_info() ) {
1486 anchor_atomno = anchor_rsd.
atom_index( edge.upstream_atom() );
1490 }
else if ( edge.is_peptide() ) {
1492 int const dir( edge.polymer_direction() );
1493 assert( anchor_rsd.
seqpos() == seqpos-dir );
1497 assert( seqpos == static_cast< Size >( edge.stop() ) && anchor_rsd.
seqpos() ==
static_cast< Size >( edge.start() ) && edge.has_atom_info() );
1498 anchor_atomno = anchor_rsd.
atom_index( edge.upstream_atom() );
1500 assert( anchor_atomno );
1501 return anchor_atomno;
1513 int const forward( 1 ), backward( -1 );
1515 if ( dir == forward ) {
1528 }
else if ( dir == backward ) {
1551 Size const mainchain_index( ( nbb-1 )/2 + 1 );
1565 Size & anchor_atomno,
1569 ASSERT_ONLY(
Size const anchor_pos( anchor_rsd.
seqpos() );)
1570 ASSERT_ONLY(
Size const root_pos( root_rsd.
seqpos() );)
1575 assert( dir == 1 || dir == -1 );
1576 assert( root_pos == anchor_pos + dir );
1594 utility_exit_with_message(
"Unrecognized edge type!" );
1625 Size root_pos( edge.
stop() ), anchor_atomno, root_atomno;
1639 Size root_pos( edge.
stop() ), anchor_atomno, root_atomno;
1642 assert( root_atom->is_jump() );
1644 for (
Size i=0; i< root_atom->n_nonjump_children(); ++i ) {
1646 if (
Size(child->id().rsd()) == root_pos ) {
1647 same_residue_child = child;
1651 if ( same_residue_child ) {
1652 assert( !same_residue_child->is_jump() );
1653 root_atom->delete_atom( same_residue_child );
1654 root_atom->insert_atom( same_residue_child );
1656 TR.Warning <<
"Unable to keep stub in residue: jump_atom has no non-jump, same-residue children!" << std::endl;
1664 Size & anchor_atom_no,
1668 assert( rsd_anchor.
is_bonded( rsd_root ) );
1704 int const seqpos1( rsd1.
seqpos() );
1705 int const seqpos2( rsd2.
seqpos() );
1711 assert( mainchain1.size() == mainchain2.size() );
1714 if ( mainchain1.size() == 0 &&
1716 assert( rsd1.
atoms().size() == rsd2.
atoms().size() );
1718 for (
Size i=1, i_end = rsd1.
atoms().size(); i<= i_end; ++i ) {
1722 for (
Size i=1, i_end = mainchain1.size(); i<= i_end; ++i ) {
1728 for (
Size i=1; i<= 4; ++i ) {
1777 TR.Warning <<
"WARNING: change_cys_state() was called on non-cys residue " << index <<
", skipping!" << std::endl;
1796 variant_types.erase( std::find( variant_types.begin(), variant_types.end(),
chemical::DISULFIDE ) );
1802 for ( chemical::ResidueTypeCOPs::const_iterator
1803 type_iter = possible_types.begin(), type_end = possible_types.end();
1804 type_iter != type_end; ++type_iter )
1806 bool perfect_match(
true );
1807 for (
Size kk = 1; kk <= variant_types.size(); ++kk ) {
1808 if ( ! (*type_iter)->has_variant_type( variant_types[ kk ] ) ) {
1809 perfect_match =
false;
1814 if ( perfect_match ) {
1824 TR.Error <<
"ERROR: Couldn't find a " << cys_type_name3 <<
" equivalent for residue " << index <<
"." <<std::endl;
1837 rsd_id = atom_id.
rsd();
1839 TR.Error <<
"[ ERROR ] Can't resolve atom_id " << atom_id << std::endl;
1860 using namespace core::id;
1882 using namespace core::id;
1922 Size other_res( 0 );
1930 if ( other_res == 0 ) {
1931 TR.Error <<
"Error: Residue " << lower_res <<
" was disulfide bonded but had no partner" << std::endl;
1935 if(other_res == upper_res) {
1938 "Error: Disulfide bond wasn't reciprical");
1944 runtime_assert_msg(result,
"Error converting CYD->CYS");
1949 conformation.
residue(lower_res), *lower_cyd, conformation );
1959 Size other_res( 0 );
1967 if ( other_res == 0 ) {
1968 TR.Warning <<
"Warning: Residue " << upper_res <<
" was disulfide bonded but had no partner" << std::endl;
1974 runtime_assert_msg(result,
"Error converting CYD->CYS");
1979 conformation.
residue(upper_res), *upper_cyd, conformation );
1984 runtime_assert(conformation.
residue(lower_res).
name() ==
"CYD" && conformation.
residue(upper_res).
name() ==
"CYD" );
2010 Size a_connect_atom;
2032 for(
Size i=1; i<= conformation.
size(); ++i)
2039 Size connect_atom( 0);
2040 if( res.type().has_atom_name(
"SG" ))
2041 connect_atom = res.atom_index(
"SG" );
2042 else if( res.type().has_atom_name(
"CEN" ))
2043 connect_atom = res.atom_index(
"CEN" );
2045 TR.Warning <<
"Warning: unable to establish which atom to use for the disulfide to residue "
2058 if ( other_res == 0 ) {
2059 TR.Error <<
"Error: Residue " << i <<
" was disulfide bonded but had no partner" << std::endl;
2064 if( i < other_res ) {
2065 disulfides.push_back( std::make_pair(i, other_res) );
2086 if (omega > 90 || omega < -90) {
2088 if (psi < -130 || psi > 50) {
2094 if (psi < -90 || psi > 90) {
2102 if (psi < -130 || psi > 50) {
2108 if (psi < -90 || psi > 90) {