Skip to content

Instantly share code, notes, and snippets.

@dstoeckel
Last active April 20, 2016 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dstoeckel/8bbfc8844f8d78973f0f to your computer and use it in GitHub Desktop.
Save dstoeckel/8bbfc8844f8d78973f0f to your computer and use it in GitHub Desktop.
Reads a PDB file passed via command line and displays its contents using a minimal BALL::VIEW application.
#include <BALL/FORMAT/PDBFile.h>
#include <BALL/KERNEL/system.h>
#include <BALL/STRUCTURE/secondaryStructureProcessor.h>
#include <BALL/VIEW/KERNEL/mainControl.h>
#include <BALL/VIEW/WIDGETS/scene.h>
#include <BALL/VIEW/MODELS/cartoonModel.h>
#include <BALL/VIEW/MODELS/standardColorProcessor.h>
#include <QtWidgets/QApplication>
BALL::System* importPDBFile(const char* fileName)
{
BALL::System* system = new BALL::System();
BALL::PDBFile infile;
infile.open(fileName);
infile >> *system;
BALL::FragmentDB db("");
system->apply(db.normalize_names);
system->apply(db.build_bonds);
BALL::SecondaryStructureProcessor modProc;
system->apply(modProc);
return system;
}
void showPeptideRepresentation(BALL::System* system, BALL::VIEW::MainControl& control)
{
control.insert(*system, "PDB File", false);
auto* scene = new BALL::VIEW::Scene(&control);
control.setCentralWidget(scene);
auto& repManager = control.getRepresentationManager();
auto* rep = repManager.createRepresentation();
rep->setComposite(system);
rep->setColorProcessor(new BALL::VIEW::SecondaryStructureColorProcessor());
rep->setModelProcessor(new BALL::VIEW::AddCartoonModel());
control.update(*rep);
repManager.focusRepresentation(*rep);
}
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
BALL::VIEW::MainControl control;
control.registerThis();
showPeptideRepresentation(importPDBFile(argv[1]), control);
control.show();
return app.exec();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment