Skip to content
dstoeckel edited this page Mar 16, 2015 · 2 revisions

How can I replace a residue by its rotamers?

Replacing a residue by its rotamer can be done using the rotamer libraries included in BALL.

 
#include <BALL/FORMAT/PDBFile.h>
#include <BALL/STRUCTURE/rotamerLibrary.h>
#include <BALL/STRUCTURE/fragmentDB.h>
#include <BALL/STRUCTURE/residueChecker.h>

using namespace BALL;
using namespace std;

  // read in file
  PDBFile infile("test_complex.pdb", std::ios::in);
	
  System S;
  infile >> S;
	
  // chose and initialize fragment database
  FragmentDB fdb;
  fdb.setFilename("fragments/Fragments.db");
  fdb.init();
  
  // deduce missing information
  S.apply(fdb.normalize_names);
  S.apply(fdb.build_bonds);
  S.apply(fdb.add_hydrogens);

  // chose and initialize rotamer library
  RotamerLibrary rl = RotamerLibrary("rotamers/bbind99.Aug.lib",fdb);
  ResidueChecker rc(fdb);
	
  // chose residue for which rotameres should be applied, e.g. residue 95
  Residue* r = S.beginProtein()->getResidue(95);
  cout << r->getFullName() << " " << r->countAtoms() << endl;
  ResidueRotamerSet *rs = rl.getRotamerSet(r->getName());

  // since Ala and Gly have no rotamers, no ResidueRotamerSet will be build for them
  // therefore check whether a ResidueRotamerSet was created
  if (rs) 
  {
    cout << " " << rs->getNumberOfTorsions() << " " << rs->getNumberOfRotamers() << endl;

    // output file name
    char name[255];
	
    for (Position i = 0; i < rs->getNumberOfRotamers(); i++)
    {	
      // select rotamer i and apply it to residue, e.g. 95
      rs->setRotamer(*r, rs->getRotamer(i));
      r->apply(rc);

      // write resulting file with residue 95 replaced by rotamer i
      sprintf(name, "test_complex_rotamer_%d", i); 
    }
  }
	
  infile.close();
Clone this wiki locally