libRosetta Users Guide

Common Tasks

Here are some examples of performing common tasks in libRosetta. This is intended to give the flavor of libRosetta use but the code does not show the necessary header includes.

Read a PDB File

To read a Complex of structures from a PDB file

   typedef  ProteinBuilder::Proteins  Proteins; // This will become Complex
   Proteins proteins( read_pdb( protein_file.pdb ) ); // Collection of proteins
   Protein & protein( **proteins.begin() ); // Grab the first protein

Notes:

  • The Complex object will replace the simple structure collection returned by the PDB reader/builder.
  • The libRosetta PDB reader/builder is used for stand-alone libRosetta tests/demos at this point: the classic Rosetta input_pdb() will continue to handle PDB reading for some period after libRosetta is integrated due to the extra steps it performs after reading a PDB file.

Loop Over the Residues in a Protein

Given:

   using namespace rosetta::conformation::amino;
   using namespace rosetta::conformation::protein;
   Protein & protein( /* something */ );

you can loop over the residues by index:

   for ( Size i = 1, e = protein.n_residue(); i <= e; ++i ) {
      AminoAcid & aa( protein[ i ] );
      // Use AminoAcid aa
   }

or by iterator:
   for ( Protein::Iterator i = protein.begin(), e = protein.end(); i != e; ++i ) {
      AminoAcid & aa( **i ); // We dereference twice because containers hold smart pointers
      // Use AminoAcid aa
   }

Note: Index and/or iterator access is provided for access to constituents of libRosetta components where appropriate.

Using Residues

Here's a sample of some of the calls you can make on a residue:

   using namespace rosetta::conformation::amino;
   AminoAcid & aa( /* something */ );

   aa.id(); // Amino acid id string (ALA, ...)
   aa.identifier(); // Amino acid name string (Alanine, ...)
   aa.code(); // Amino acid code letter (A, ...)
   aa.n_chi(); // Number of chi angles
   aa.centroid(); // Centroid object
   aa.is_terminus(); // Is it a terminus?
   aa.is_N_terminus(); // Is it an N-terminus?
   aa[ CA ]; // C-alpha atom
   aa[ N_CA_C ]; // N-CA-C bond angle
   aa[ Chi3 ]; // Chi3 torsion angle
   aa.rotamer_index( 3 ); // Rotamer index of Chi3
   aa.packed_rotamer_number(); // Packed rotamer number
   aa.refold_sidechain(); // Refold the sidechain

Loop Over the Atoms in a Residue

Given:

   using namespace rosetta::conformation;
   using namespace rosetta::conformation::amino;
   AminoAcid & aa( /* something */ );

you can loop over all atoms in the residue by iterator:

   // Loop over all atoms in the residue
   for ( AminoAcid::Atoms_Iterator i = aa.atoms_begin(), e = aa.atoms_end(); i != e; ++i ) {
      Atom & atom( **i );
      // Use Atom atom
   }

or just the heavy atoms:

   // Loop over all heavy atoms in the residue
   for ( AminoAcid::Atoms_Iterator i = aa.heavy_atoms_begin(), e = aa.heavy_atoms_end(); i != e; ++i ) {
      Atom & atom( **i );
      // Use heavy Atom atom
   }

and you can loop over the atoms by index:

   // Loop over all atoms by index
   for ( Size i = 1, e = aa.n_atom(); i <= e; ++i ) {
      Atom & atom( aa.atom( i ) );
      // Use Atom atom
   }

Using Atoms

   atom.is_H()
   atom.is_heavy()
   atom.is_donor()
   atom.is_donor_H()
   atom.is_acceptor()
   atom.lj_radius()
   atom.position()                    // PointPosition == xyzVector
   distance( atom1, atom2 )           // == distance( atom1.position(), atom2.position() )
   distance_squared( atom1, atom2 )

Changing a Conformation

   using namespace rosetta::conformation::amino;
   using namespace rosetta::conformation::protein;
   Protein & protein( /* something */ );
   ...
   protein.psi( i ) = angle;
   protein.phi( i ) += delta_angle;
   aa[ Chi2 ] = angle;
   aa.chi( 2 ) = angle; // Same thing

Note: Internal angles in libRosetta are in radians. Use the numeric::conversions::radians() function to convert degrees values to radians.

Scoring a Conformation

   fullatom_energy( protein );
Additional scoring operations are being added.
Support | ©2007 Rosetta Commons