Skip to content

LoadDCDFileIntoProtein

dstoeckel edited this page Mar 16, 2015 · 2 revisions

How can I load a DCD-file trajectory snapshot into a BALL Protein?

Load the DCD trajectory file and iterate over all snapshots.

C++

# include <BALL/FORMAT/PDBFile.h>
# include <BALL/KERNEL/system.h>
# include <BALL/STRUCTURE/fragmentDB.h>
# include <BALL/FORMAT/trajectoryFile.h>
# include <BALL/FORMAT/DCDFile.h>

...
using namespace BALL;
using namespace std;
...

// read the PDB-file of the initial state into a BALL::System
PDBFile f("myInitialState.pdb");
System S;
f >> S;

// and store the system in a BALL::Protein
Protein protein;
protein.insert(S);

// now we open a fragment database
FragmentDB fragment_db("");

// and normalize the atom names, i.e. we convert different
// naming standards to the PDB naming scheme - just in case!
S.apply(fragment_db.normalize_names);

// now we create the bonds between the atoms (PDB files hardly
// ever contain a complete set of CONECT records)
S.apply(fragment_db.build_bonds);

// open the DCD trajectory file in which all atom positions are stored
DCDFile dcdin;
dcdin.open("myTrajectory.dcd");

// iterate over all snapshots in your DCD trajectory file
for (unsigned int i = 0; i != dcdin.getNumberOfSnapShots(); ++i)
{
  // read i-th snapshot from DCD file
  SnapShot snapshot;
  dcdin.read(snapshot);
  cout << "read snapshot " << i << endl;

  // apply atom coordinates of the snapshot to the system
  snapshot.applySnapShot(S);

  // and insert it into the protein
  protein.insert(S);

  // here you can use your actual snapshot, stored in _protein_
  // (eg. mapping, RMSD calculations, etc.)
  ...
}
Clone this wiki locally