25 #include <basic/basic.hh>
26 #include <basic/prof.hh>
27 #include <basic/Tracer.hh>
31 #include <ObjexxFCL/FArray1D.hh>
39 #include <numeric/constants.hh>
40 #include <numeric/conversions.hh>
41 #include <numeric/xyz.functions.hh>
42 #include <numeric/xyzMatrix.hh>
43 #include <numeric/xyzVector.hh>
46 #include <utility/assert.hh>
56 #include <utility/vector1.hh>
61 namespace kinematics {
63 static basic::Tracer
TR(
"core.kinematics.AtomTree" );
78 internal_coords_need_updating_( false ),
79 xyz_coords_need_updating_( false ),
80 topological_match_to_( 0 ),
91 internal_coords_need_updating_( false ),
92 xyz_coords_need_updating_( false ),
93 topological_match_to_( 0 ),
108 utility::pointer::ReferenceCount(),
113 internal_coords_need_updating_( false ),
114 xyz_coords_need_updating_( false ),
115 topological_match_to_( 0 ),
124 assert( self_pointer() ==
this );
144 bool const add_bonded_atom,
151 update_internal_coords();
156 if ( !id2.valid() || // root
157 !atom_pointer_.has( id2 ) ||
158 atom_pointer_[ id2 ] == 0 ) {
161 utility_exit_with_message("add_atom: parent not in the tree");
164 parent = atom_pointer_[ id2 ];
167 // create the new atom
168 AtomOP atom( add_bonded_atom ?
169 static_cast< AtomOP >( new BondedAtom() ) :
170 static_cast< AtomOP >( new JumpAtom() ) );
172 atom_pointer_.set( id1, atom );
175 parent->append_atom( atom );
183 internal_coords_need_updating_ = true;
185 xyz_coords_need_updating_ = true;
320 A = M1 *
R * M2.transposed();
321 b = M1 *
t + v1 - A * v2;
335 Size const old_size(
size() ), new_size( old_size - 1 );
340 for (
Size i=1; i<= natoms; ++i ) {
342 if ( !atom )
continue;
343 if (
Size(atom->parent()->id().rsd()) != seqpos ) {
346 anchor = atom->parent();
350 if (
Size((*iter)->id().rsd()) != seqpos ) {
359 utility_exit_with_message(
"AtomTree::delete_seqpos can't handle deleting the root residue");
364 anchor->replace_atom(
root, child );
366 anchor->delete_atom(
root );
378 for (
Size i=1; i<= old_size; ++i ) {
379 if ( i < seqpos ) old2new[i] = i;
380 else if ( i == seqpos ) old2new[i] = 0;
381 else old2new[i] = i-1;
426 for (
Size i=1; i<= outgoing.size(); ++i ) assert( outgoing[i].atom1.rsd() == seqpos );
427 for (
Size i=1; i<= new_atoms.size(); ++i ) assert( new_atoms[i]->
id() ==
AtomID( i, seqpos ) );
439 for (
Size i=1; i<= outgoing.size(); ++i ) {
441 AtomOP old_parent( child->parent() );
442 assert( child->id().rsd() != seqpos );
445 assert( old_atoms.empty() && !incoming.
atom1.
valid() );
446 assert( !old_root_atom );
447 old_root_atom = child;
448 }
else if ( old_parent->id().rsd() != seqpos ) {
450 assert( old_atoms.empty() && old_parent->id() == incoming.
atom1 );
451 assert( !old_root_atom );
452 old_root_atom = child;
455 old_parent->delete_atom( child );
457 AtomOP new_parent( new_atoms[ outgoing[i].atom1.atomno() ]() );
458 new_parent->insert_atom( child );
462 if ( old_root_atom ) {
463 assert( old_atoms.empty() );
465 for (
Size i=1; i<= old_atoms.size(); ++i ) {
466 AtomOP old_atom( old_atoms[i]() );
468 if ( ! old_atom->parent() ) {
471 assert( !old_root_atom );
472 old_root_atom = old_atom;
473 }
else if ( old_atom->parent()->id().rsd() != seqpos ) {
475 assert( incoming.
atom1 == old_atom->parent()->id() );
476 assert( !old_root_atom );
477 old_root_atom = old_atom;
480 for (
Size i=0; i< old_atom->n_children(); ++i ) assert( old_atom->child(i)->id().rsd() == seqpos );
486 if ( old_root_atom ) {
489 assert( outgoing.empty() && old_atoms.empty() );
494 assert(
root_ == old_root_atom );
495 root_ = new_root_atom;
496 new_root_atom->parent(0);
581 AtomID const & atom1_in_id,
582 AtomID const & atom2_in_id,
583 AtomID const & atom3_in_id,
584 AtomID const & atom4_in_id,
588 using numeric::conversions::degrees;
589 using numeric::constants::d::pi_2;
590 using numeric::constants::d::pi;
591 using numeric::dihedral;
592 using numeric::dihedral_radians;
594 bool const debug(
false );
613 AtomCOP atom1( atom1_in ), atom2( atom2_in ),
614 atom3( atom3_in ), atom4( atom4_in );
620 if ( !atom4->is_jump() &&
621 !atom4->keep_dof_fixed(
PHI ) &&
622 atom4->input_stub_atom1() == atom3 &&
623 atom4->input_stub_atom2() == atom2 &&
624 atom4->input_stub_atom3() == atom1 ) {
626 }
else if ( !atom1->is_jump() &&
627 !atom1->keep_dof_fixed(
PHI ) &&
628 atom1->input_stub_atom1() == atom2 &&
629 atom1->input_stub_atom2() == atom3 &&
630 atom1->input_stub_atom3() == atom4 ) {
636 }
else if ( !atom4->is_jump() &&
637 !atom4->keep_dof_fixed(
PHI ) &&
638 atom4->input_stub_atom1() == atom3 &&
639 atom4->input_stub_atom2() == atom2 ) {
641 }
else if ( !atom1->is_jump() &&
642 !atom1->keep_dof_fixed(
PHI ) &&
643 atom1->input_stub_atom1() == atom2 &&
644 atom1->input_stub_atom2() == atom3 ) {
657 if ( atom4->input_stub_atom3() == atom1 ) {
662 assert( !atom4->is_jump() &&
663 atom4->input_stub_atom0() == atom3 &&
664 atom4->input_stub_atom1() == atom3 &&
665 atom4->input_stub_atom2() == atom2 &&
666 atom4->parent() == atom3 );
669 if ( atom1->parent() == atom3 ) {
670 Size const atom1_index( atom3->child_index( atom1 ) ),
671 atom4_index( atom3->child_index( atom4 ) );
672 if ( atom1_index < atom4_index ) {
673 Real const current_value( atom3->dihedral_between_bonded_children( atom1, atom4 ) );
674 offset = current_value - atom4->dof(
PHI);
676 ASSERT_ONLY(
Real const actual_current_value
677 ( dihedral_radians( atom4->xyz(), atom3->xyz(), atom2->xyz(), atom1->xyz() ) );)
678 assert( std::abs( basic::subtract_radian_angles( actual_current_value, current_value ) ) < 1e-3 );
679 assert( std::abs( basic::subtract_radian_angles( current_value, atom4->dof(
PHI ) + offset ) ) < 1e-3 );
683 Real const current_value( atom3->dihedral_between_bonded_children( atom1, atom4 ) );
684 offset = current_value - atom1->dof(
PHI );
685 ASSERT_ONLY(
Real const actual_current_value
686 ( dihedral_radians( atom4->xyz(), atom3->xyz(), atom2->xyz(), atom1->xyz() ) );)
687 assert( std::abs( basic::subtract_radian_angles( actual_current_value, current_value ) ) < 1e-3 );
688 assert( std::abs( basic::subtract_radian_angles( current_value, atom1->dof(
PHI ) + offset ) ) < 1e-3 );
693 if ( atom4 != atom3->get_nonjump_atom(0) ) {
694 AtomCOP new_atom4( atom3->get_nonjump_atom(0) );
695 offset += atom3->dihedral_between_bonded_children( new_atom4, atom4 );
698 ASSERT_ONLY(
Real const actual_dihedral
699 ( dihedral_radians( atom4->xyz(), atom3->xyz(), atom2->xyz(),
700 new_atom4->xyz() ) );)
701 assert( std::abs( basic::subtract_radian_angles
702 ( actual_dihedral, offset ) ) < 1e-3 );
710 AtomCOP dof_atom1( atom4->input_stub_atom3() );
712 if ( dof_atom1 == atom1 ) {
714 }
else if ( atom1->parent() == atom2 && !atom1->is_jump() &&
715 atom3->parent() == atom2 && !atom3->is_jump() ) {
746 theta1( pi - atom3->dof(
THETA ) ),
747 theta3( pi - atom1->dof(
THETA ) ),
748 phi2( atom2->dihedral_between_bonded_children( atom1, atom3 ) ),
750 phi2 = basic::periodic_range( phi2, pi_2 );
757 theta3 = basic::periodic_range( theta3, pi_2 );
762 theta1 = basic::periodic_range( theta1, pi_2 );
767 if ( !( 0 <= theta1 && theta1 <= pi &&
768 0 <= theta3 && theta3 <= pi &&
769 0 <= phi2 && phi2 <= pi ) ) {
770 std::cerr <<
"dof_atom1 " << dof_atom1->id() << std::endl;
771 std::cerr <<
"atom1 " << atom1->id() << std::endl;
772 std::cerr <<
"atom2 " << atom2->id() << std::endl;
773 std::cerr <<
"atom3 " << atom3->id() << std::endl;
774 std::cerr <<
"atom4 " << atom4->id() << std::endl;
775 std::cerr <<
"THETA1 " << theta1 << std::endl;
776 std::cerr <<
"THETA3 " << theta3 << std::endl;
777 std::cerr <<
"PHI2 " << phi2 << std::endl;
779 utility_exit_with_message
780 (
"AtomTree::torsion_angle_dof_id: angle range error" );
794 Real const cos_theta2 = std::cos( theta1 ) * std::cos( theta3 ) +
795 std::sin( theta1 ) * std::sin( theta3 ) * std::cos( phi2 );
796 Real const theta2 = std::acos( cos_theta2 );
797 assert( 0 <= theta2 && theta2 <= pi );
800 Real cos_phi3 = ( cos( theta3 ) - cos( theta1 ) * cos_theta2 ) /
801 ( sin( theta1 ) * sin( theta2 ) );
815 Real const dihedral_from_atom1_to_dof_atom1
816 ( sign_factor * std::acos( cos_phi3 ) );
818 offset += dihedral_from_atom1_to_dof_atom1;
821 using basic::periodic_range;
822 using basic::subtract_radian_angles;
823 Real const actual_dihedral_from_atom1_to_dof_atom1
824 ( dihedral_radians( atom1->xyz(), atom2->xyz(), atom3->xyz(),
827 Real const actual_dihedral_of_interest
828 ( dihedral_radians( atom1_in->xyz(), atom2_in->xyz(),
829 atom3_in->xyz(), atom4_in->xyz()) );
831 ASSERT_ONLY(
Real const dev1
832 ( std::abs( subtract_radian_angles
833 ( actual_dihedral_from_atom1_to_dof_atom1,
834 dihedral_from_atom1_to_dof_atom1 ) ) );)
836 ASSERT_ONLY(
Real const dev2
837 ( std::abs( subtract_radian_angles( actual_dihedral_of_interest,
838 dof( dof_id ) + offset ) ) );)
841 ASSERT_ONLY(
Real const dev3
842 ( std::abs( subtract_radian_angles
844 dihedral_radians( atom4->xyz(),
845 atom4->input_stub_atom1()->xyz(),
846 atom4->input_stub_atom2()->xyz(),
847 atom4->input_stub_atom3()->xyz()))));)
849 assert( dev1 < 1e-3 && dev2 < 1e-3 && dev3 < 1e-3 );
852 TR.Trace <<
"offset: " << offset <<
" sgn_fac: " << sign_factor <<
853 ' ' << dihedral_from_atom1_to_dof_atom1 <<
" =?= " <<
854 actual_dihedral_from_atom1_to_dof_atom1 <<
855 ' ' << periodic_range(
dof( dof_id ) + offset, pi_2 ) <<
856 " =?= " << actual_dihedral_of_interest << std::endl;
904 runtime_assert( ids.size() == xyzs.size() );
987 set_dof(
id, setting - offset );
1006 if ( dof_id.
valid() ) {
1007 assert( offset == 0.0 );
1009 set_dof( dof_id, numeric::constants::d::pi - setting );
1028 if ( dof_id.
valid() ) {
1029 assert( offset == 0.0 );
1030 return numeric::constants::d::pi -
dof( dof_id );
1032 TR <<
"unable to find DOF_ID for bond_angle: " << atom1 <<
' ' << atom2 <<
' ' << atom3 << std::endl;
1042 AtomID const & atom1_in_id,
1043 AtomID const & atom2_in_id,
1044 AtomID const & atom3_in_id,
1062 AtomCOP atom1( atom1_in ), atom2( atom2_in ), atom3( atom3_in );
1068 if ( !atom3->is_jump() &&
1069 !atom3->keep_dof_fixed(
THETA ) &&
1070 atom3->input_stub_atom1() == atom2 &&
1071 atom3->input_stub_atom2() == atom1 ) {
1075 }
else if ( !atom1->is_jump() &&
1076 !atom1->keep_dof_fixed(
THETA ) &&
1077 atom1->input_stub_atom1() == atom2 &&
1078 atom1->input_stub_atom2() == atom3 ) {
1104 if ( dof_id.
valid() ) {
1122 if ( dof_id.
valid() ) {
1123 return dof( dof_id );
1125 TR <<
"unable to find DOF_ID for bond_length: " << atom1 <<
' ' << atom2 << std::endl;
1144 if ( !atom2->is_jump() &&
1145 atom2->input_stub_atom1() == atom1 ) {
1147 return DOF_ID( atom2->id(),
D );
1149 }
else if ( !atom1->is_jump() &&
1150 atom1->input_stub_atom1() == atom2 ) {
1152 return DOF_ID( atom1->id(),
D );
1182 if ( !
id.valid() ) {
1184 TR <<
"AtomTree::torsion_angle() cant find dof! " <<
1185 atom1 <<
' ' << atom2 <<
' ' << atom3 <<
' ' << atom4 << std::endl;
1194 return atom_pointer_[
id.atom_id() ]->dof(
id.type() ) + offset;
1224 if ( src.
root() ) utility_exit_with_message(
"AtomTree::copy_coords: I'm empty but src is not!");
1250 int current_color(1), biggest_color(1);
1251 root_->update_domain_map( current_color, biggest_color, domain_map,
1252 dof_moved, xyz_moved );
1272 Size const new_size,
1357 if ( !
root_ ) utility_exit_with_message(
"phil how did we get here?-1");
1359 PROF_START( basic::ATOM_TREE_UPDATE_INTERNAL_COORDS );
1361 PROF_STOP ( basic::ATOM_TREE_UPDATE_INTERNAL_COORDS );
1376 RT const & target_rt
1383 for (
Size i=1; i<= 3; ++i ) {
1385 for (
Size j=1; j<= 3; ++j ) {
1387 if ( atom1->is_jump() && atom1->parent() == atom2 ) {
1388 assert( !jump_atom );
1391 }
else if ( atom2->is_jump() && atom2->parent() == atom1 ) {
1392 assert( !jump_atom );
1399 utility_exit_with_message(
"AtomTree::set_stub_transform: No jump between these atoms!" );
1405 if ( dir == -1 ) rt.
reverse();
1415 return jump_atom->id();
1438 if ( !
root_ ) utility_exit_with_message(
"phil how did we get here-2?");
1440 PROF_START( basic::ATOM_TREE_UPDATE_XYZ_COORDS );
1452 PROF_STOP ( basic::ATOM_TREE_UPDATE_XYZ_COORDS );
1510 assert( observer->topological_match_to_ == 0 );
1511 bool resize_topo_observers_array_(
false );
1514 resize_topo_observers_array_ =
true;
1520 if ( resize_topo_observers_array_ ) {
1526 valid_observers.reserve( n_valid + 1 );
1556 assert( observer->topological_match_to_() == this );
1557 bool found(
false );
1562 observer->topological_match_to_ = 0;
1605 bool const atom1_in_frag( frag_xyz.count(
id.atom1 ) );
1606 bool const atom2_in_frag( frag_xyz.count(
id.atom2 ) );
1610 if ( atom1->is_jump() ) {
1611 if ( !atom1_in_frag && atom1->parent() && frag_xyz.count( atom1->parent()->atom_id() ) ) {
1612 frag_atom = atom1->parent();
1613 nonfrag_atom = atom1;
1615 }
else if ( atom1_in_frag && ( !atom1->parent() || !frag_xyz.count( atom1->parent()->atom_id() ) ) ) {
1617 nonfrag_atom = atom1->parent();
1622 if ( atom1_in_frag && !atom2_in_frag ) {
1627 }
else if ( atom2_in_frag && !atom1_in_frag ) {
1633 utility_exit_with_message(
"AtomTree::get_frag_atoms failed" );
1651 assert( frag_xyz.count(
id ) );
1656 AtomCOP parent( atom->parent() ), child1( atom->get_nonjump_atom(0) ), child2( atom->get_nonjump_atom(1) );
1658 if ( !atom->is_jump() && parent && frag_xyz.count( parent->atom_id() ) ) {
1659 ids.push_back( parent->atom_id() );
1661 if ( child1 && frag_xyz.count( child1->atom_id() ) ) {
1662 ids.push_back( child1->atom_id() );
1664 if ( child2 && frag_xyz.count( child2->atom_id() ) ) {
1665 ids.push_back( child2->atom_id() );
1667 if ( child1 && frag_xyz.count( child1->atom_id() ) ) {
1668 AtomCOP gchild1( child1->get_nonjump_atom(0) );
1669 if ( gchild1 && frag_xyz.count( gchild1->atom_id() ) ) {
1670 ids.push_back( gchild1->atom_id() );
1673 if ( child2 && frag_xyz.count( child2->atom_id() ) ) {
1674 AtomCOP gchild2( child2->get_nonjump_atom(0) );
1675 if ( gchild2 && frag_xyz.count( gchild2->atom_id() ) ) {
1676 ids.push_back( gchild2->atom_id() );
1679 if ( !atom->is_jump() && parent && frag_xyz.count( parent->atom_id() ) ) {
1680 AtomCOP gparent( parent->parent() );
1681 if ( !parent->is_jump() && gparent && frag_xyz.count( gparent->atom_id() ) ) {
1682 ids.push_back( gparent->atom_id() );
1684 for (
Size i=0; i<parent->n_children(); ++i ) {
1685 AtomCOP sibling( parent->child(i) );
1686 if ( sibling != atom && !sibling->is_jump() && frag_xyz.count( sibling->atom_id() ) ) {
1687 ids.push_back( sibling->atom_id() );
1691 if ( ids.size() < 2 ) {
1693 return StubID(
id,
id,
id );
1695 return StubID(
id, ids[1], ids[2] );
1711 AtomID const stub_atom1_id( stubid.
atom1 ), stub_atom2_id( stubid.
atom2 ), stub_atom3_id( stubid.
atom3 );
1714 if ( !frag_xyz.count( stub_atom1_id ) && stub_atom1->is_jump() &&
1715 stub_atom1->parent() && frag_xyz.count( stub_atom1->parent()->atom_id()) &&
1716 stub_atom1->stub_atom1_id() == stub_atom1_id &&
1717 stub_atom1->stub_atom2_id() == stub_atom2_id &&
1718 stub_atom1->stub_atom3_id() == stub_atom3_id ) {
1721 StubID const instub_id( stub_atom1->input_stub_atom1_id(),
1722 stub_atom1->input_stub_atom2_id(),
1723 stub_atom1->input_stub_atom3_id() );
1724 assert( stub_atom1->input_stub_atom0_id() == stub_atom1->input_stub_atom1_id() );
1730 TR.Trace <<
"get_frag_local_stub:: making jump: " <<
1732 instub_id.atom1 <<
' ' << instub_id.atom2 <<
' ' << instub_id.atom3 << std::endl;
1734 current_rt.make_jump( instub, outstub );
1758 if ( frag_xyz.count(
id ) )
return frag_xyz.find(
id )->second;
1762 if ( ( atom->parent() && frag_xyz.count( atom->parent()->atom_id() ) ) ||
1763 ( atom->parent() && atom->parent()->parent() && frag_xyz.count( atom->parent()->parent()->atom_id() ) ) ) {
1770 for (
Size i=0; i< atom->n_children(); ++i ) {
1771 if ( frag_xyz.count( atom->child(i)->atom_id() ) ) {
1772 assert( child == 0 );
1773 child = atom->child(i);
1791 AtomID const id( atom->atom_id() );
1792 assert( !frag_xyz.count(
id ) );
1793 bool const frag_child( atom->parent() && frag_xyz.count( atom->parent()->atom_id() ) );
1794 ASSERT_ONLY(
bool const frag_gchild
1795 ( atom->parent() && atom->parent()->parent() && frag_xyz.count( atom->parent()->parent()->atom_id() ) );)
1796 assert( frag_child || frag_gchild );
1798 AtomID id1( atom->input_stub_atom1_id() );
1799 AtomID id2( atom->input_stub_atom2_id() );
1800 AtomID id3( atom->input_stub_atom3_id() );
1801 assert( atom->input_stub_atom0_id() == id1 );
1803 if (
id == id1 ||
id == id2 ||
id == id3 ) {
1816 if ( fail )
return Vector(0.0);
1834 AtomCOP parent( child->parent() );
1836 assert( frag_xyz.count( child->atom_id() ) && ! frag_xyz.count( parent->atom_id() ) );
1840 if ( fail )
return Vector(0.0);
1859 StubID const & instub_id,
1860 FragRT const & outstub_transforms,
1868 AtomCOP instub_frag_atom(0), instub_nonfrag_atom(0);
1869 get_frag_atoms( instub_id, frag_xyz, instub_frag_atom, instub_nonfrag_atom );
1871 assert( instub_frag_atom->parent() == instub_nonfrag_atom );
1875 for ( FragRT::const_iterator it= outstub_transforms.begin(), ite= outstub_transforms.end(); it != ite; ++it ) {
1876 StubID const & outstub_id( it->first );
1877 AtomCOP outstub_frag_atom(0), outstub_nonfrag_atom(0);
1878 get_frag_atoms( outstub_id, frag_xyz, outstub_frag_atom, outstub_nonfrag_atom );
1879 outstub_nonfrag_atoms.push_back( outstub_nonfrag_atom );
1880 assert( outstub_nonfrag_atom->parent() == outstub_frag_atom );
1884 Stub const & stub1( instub );
1886 RT const & rt( it->second );
1912 moving_atoms.push_back( outstub_nonfrag_atom->atom_id() );
1916 for ( FragXYZ::const_iterator it=frag_xyz.begin(), ite= frag_xyz.end(); it != ite; ++it ) {
1917 AtomID const & id( it->first );
1925 assert( ( atom->parent() && frag_xyz.count( atom->parent()->atom_id() ) ) || atom == instub_frag_atom );
1928 for (
Size i=0; i< atom->n_children(); ++i ) {
1929 assert( frag_xyz.count( atom->child(i)->atom_id() ) ||
1930 ( std::find( outstub_nonfrag_atoms.begin(), outstub_nonfrag_atoms.end(), atom->child(i) ) !=
1931 outstub_nonfrag_atoms.end()));
1934 moving_atoms.push_back(
id );
1941 for ( FragRT::const_iterator it= outstub_transforms.begin(), ite= outstub_transforms.end(); it != ite; ++it ) {
1960 if ( !atom1->is_jump() || atom2->is_jump() || atom3->is_jump() ||
1961 atom2->parent() != atom1 || atom3->parent() != atom2 ) {
1962 utility_exit_with_message(
"set_jump_atom_stub_id failed!" );
1965 atom1->delete_atom( atom2 );
1966 atom1->insert_atom( atom2 );
1967 atom2->delete_atom( atom3 );
1968 atom2->insert_atom( atom3 );
1972 assert( atom1->stub_atom1() == atom1 && atom1->stub_atom2() == atom2 && atom1->stub_atom3() == atom3 );
1982 StubID const & instub_id,
1983 FragRT const & outstub_transforms,
1997 AtomCOP frag_atom, nonfrag_atom;
1999 if ( frag_atom->parent() == nonfrag_atom ) {
2000 TR.Trace <<
"AtomTree::insert_fragment: instub is incoming" << std::endl;
2001 incoming_stub_frag_atoms.push_back( frag_atom );
2002 incoming_local_stubs.push_back(
Stub() );
2003 incoming_stub_ids.push_back( instub_id );
2004 }
else if ( nonfrag_atom && nonfrag_atom->parent() == frag_atom ) {
2005 TR.Trace <<
"AtomTree::insert_fragment: instub is outgoing" << std::endl;
2006 outgoing_stub_nonfrag_atoms.push_back( nonfrag_atom );
2007 outgoing_local_stubs.push_back(
Stub() );
2008 outgoing_stub_ids.push_back( instub_id );
2012 for ( FragRT::const_iterator it= outstub_transforms.begin(), ite= outstub_transforms.end(); it != ite; ++it ) {
2013 StubID const & outstub_id( it->first );
2014 AtomCOP frag_atom, nonfrag_atom;
2016 if ( nonfrag_atom && nonfrag_atom->parent() == frag_atom ) {
2017 TR.Trace <<
"AtomTree::insert_fragment: outstub is outgoing" << std::endl;
2018 outgoing_stub_nonfrag_atoms.push_back( nonfrag_atom );
2019 outgoing_local_stubs.push_back(
Stub( it->second ) );
2020 outgoing_stub_ids.push_back( outstub_id );
2021 }
else if ( frag_atom->parent() == nonfrag_atom ) {
2022 TR.Trace <<
"AtomTree::insert_fragment: outstub is incoming" << std::endl;
2023 incoming_stub_frag_atoms.push_back( frag_atom );
2024 incoming_local_stubs.push_back(
Stub( it->second ) );
2025 incoming_stub_ids.push_back( outstub_id );
2029 for ( FragXYZ::const_iterator it=frag_xyz.begin(), ite= frag_xyz.end(); it != ite; ++it ) {
2032 if ( ( atom->parent() == 0 || !frag_xyz.count( atom->parent()->atom_id() ) ) &&
2033 ( std::find( incoming_stub_frag_atoms.begin(), incoming_stub_frag_atoms.end(),
atom ) ==
2034 incoming_stub_frag_atoms.end() ) ) {
2036 TR.Trace <<
"AtomTree::insert_fragment: found new incoming connection: " << atom->atom_id() << std::endl;
2038 if ( atom->is_jump() ) {
2042 StubID const stubid( atom->stub_atom1_id(), atom->stub_atom2_id(), atom->stub_atom3_id() );
2045 incoming_stub_frag_atoms.push_back( atom );
2046 incoming_local_stubs.push_back( stub );
2047 incoming_stub_ids.push_back( stubid );
2055 incoming_stub_frag_atoms.push_back( atom );
2056 incoming_stub_ids.push_back( stubid );
2065 for (
Size i=0; i< atom->n_children(); ++i ) {
2066 AtomOP child( atom->child(i) );
2067 if ( !frag_xyz.count( child->atom_id() ) &&
2068 ( std::find( outgoing_stub_nonfrag_atoms.begin(), outgoing_stub_nonfrag_atoms.end(), child ) ==
2069 outgoing_stub_nonfrag_atoms.end() ) ) {
2071 TR.Trace <<
"AtomTree::insert_fragment: found new outgoing connection: " << atom->atom_id() << std::endl;
2073 StubID const stubid( child->stub_atom1_id(), child->stub_atom2_id(), child->stub_atom3_id() );
2076 outgoing_stub_nonfrag_atoms.push_back( child );
2077 outgoing_stub_ids.push_back( stubid );
2078 outgoing_local_stubs.push_back( outstub );
2089 for (
Size i=1; i<= incoming_stub_frag_atoms.size(); ++i ) {
2090 AtomCOP instub_atom( incoming_stub_frag_atoms[i] );
2091 Stub const & local_instub( incoming_local_stubs[ i ] );
2093 FragRT new_outstub_transforms;
2095 for ( FragXYZ::const_iterator it=frag_xyz.begin(), ite= frag_xyz.end(); it != ite; ++it ) {
2096 AtomID const & id( it->first );
2098 if ( frag_atom->atom_is_on_path_from_root( instub_atom ) ) {
2099 new_frag_xyz[ id ] = local_instub.
global2local( it->second );
2102 for (
Size j=1; j<= outgoing_stub_nonfrag_atoms.size(); ++j ) {
2103 AtomCOP outstub_atom( outgoing_stub_nonfrag_atoms[j] );
2104 if ( outstub_atom->atom_is_on_path_from_root( instub_atom ) ) {
2105 new_outstub_transforms[ outgoing_stub_ids[j] ] =
RT( local_instub, outgoing_local_stubs[j] );
2109 TR.Trace <<
"AtomTree::insert_fragment: inserting single fragment nout= " << new_outstub_transforms.size() <<
2110 " natoms= " << new_frag_xyz.size() << std::endl;
2127 for (
Size i=0; i< parent->n_nonjump_children(); ++i ) {
2129 if ( child->id().rsd() == parent->id().rsd() ) {
2130 sameresidue_child = child;
2134 if ( sameresidue_child ) {
2135 assert( !sameresidue_child->is_jump() );
2136 parent->delete_atom( sameresidue_child );
2137 parent->insert_atom( sameresidue_child );
2139 TR.Warning <<
"promote_sameresidue_nonjump_child failed, parent has no non-jump, same-residue children!" <<