File: amberEnergy.C

package info (click to toggle)
ball 1.5.0%2Bgit20180813.37fc53c-11
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 239,924 kB
  • sloc: cpp: 326,149; ansic: 4,208; python: 2,303; yacc: 1,778; lex: 1,099; xml: 958; sh: 322; javascript: 164; makefile: 88
file content (78 lines) | stat: -rw-r--r-- 2,018 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
// $Id: amberEnergy.C,v 1.9.28.1 2007/08/06 16:22:06 oliver Exp $
//

#include <BALL/MOLMEC/AMBER/amber.h>
#include <BALL/STRUCTURE/fragmentDB.h>
#include <BALL/STRUCTURE/residueChecker.h>
#include <BALL/FORMAT/PDBFile.h>

using namespace BALL;
using namespace std;

int main(int argc, char** argv)
{
	Log.setPrefix(cout, "[%T]: ");
	Log.setPrefix(cerr, "[%T]: ERROR: ");

	// issue a usage hint if called without parameters
	if ((argc < 2) || (argc > 4))
	{
		Log.error() << argv[0] << " <pdb file> [<option file>]" << endl;
		return 1;
	}

	// open the PDB file
	PDBFile pdb(argv[1]);
	if (!pdb)
	{
		// if the file could not be opened, print error message and exit
		Log.error() << "cannot open PBD file " << argv[1] << endl;
		return 2;
	}

	// read the contents of the file into a system
	System S;
	pdb >> S;
	pdb.close();

	// normalize the names and build all bonds
	Log.info() << "normalizing names..." << endl;
	FragmentDB db("");
	S.apply(db.normalize_names);
	Log.info() << "building bonds..." << endl;
	S.apply(db.build_bonds);
	Log.info() << "adding H..." << endl;
	S.apply(db.add_hydrogens);

	Log.info() << "checking residues..." << endl;
	ResidueChecker rc(db);
	S.apply(rc);

	// create an AMBER force field and set its options from a file 
	AmberFF amber;
	if (argc > 2)
	{
		amber.options.readOptionFile(argv[2]);
	}

	// setup the force field
	Log.info() << "setting up force field..." << endl;
	amber.setup(S);

	// calculate the total energy and print it
	Log.info() << "total energy: " << amber.updateEnergy() << " kJ/mol   ";
  Log.info() << "stretch: " << amber.getStretchEnergy() << " kJ/mol   "
						 << "bend: " << amber.getBendEnergy() << " kJ/mol   "
						 << "torsion: " << amber.getTorsionEnergy() << " kJ/mol   "
						 << "ES: " << amber.getESEnergy() << " kJ/mol   "
						 << "vdW: " << amber.getVdWEnergy() << " kJ/mol" 
					   << endl;
	// alternatively
	Log.info() << amber.getResults() << endl;

	// done
	return 0;
}