Skip to content
cschaerfe edited this page Feb 20, 2015 · 4 revisions

How can I write a BALL Protein into a DCD file

Open the DCD trajectory file and append your protein as a snapshot.

# 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 your protein into a BALL::System
PDBFile f("myProtein.pdb");
System S;
f >> S;

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

// 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 output DCD trajectory file
DCDFile dcdout;
dcdout.open("myDCDoutput.dcd", std::ios::out);

// take a snapshot of the whole system (containing our protein)
SnapShot snapshot;
snapshot.takeSnapShot(S);

// and append it to the output DCD trajectory file
dcdout.append(snapshot);

// finally we have to close the output-stream
dcdout.close();
Clone this wiki locally