energy.cpp
Go to the documentation of this file.
1 #include <openbabel/obconversion.h>
2 #include <openbabel/mol.h>
3 #include <openbabel/forcefield.h>
4 #include <openbabel/oberror.h>
5 
6 #include <iostream>
7 
8 using namespace OpenBabel;
9 using namespace std;
10 
12 OBERROR extern OBMessageHandler obErrorLog;
63 int main(int argc, char **argv)
64 {
65  OBConversion conv;
66  OBMol mol;
67  OBForceField *ff;
68 
69  // Avoid warning messages
70  OpenBabel::obErrorLog.SetOutputLevel(obError);
71 
72  if (argc < 2)
73  {
74  cout << "Usage: " << argv[0] << " <filename>" << endl;
75  return 1;
76  }
77 
78  // Read the file.
79  conv.SetInFormat(conv.FormatFromExt(argv[1]));
80  conv.ReadFile(&mol,argv[1]);
81 
82  // Get the forcefield.
83  ff=OBForceField::FindType("MMFF94");
84 
85  // Setup the forcefield.
86  if (!ff->Setup(mol))
87  {
88  cout << "Could not setup forcefield." << endl;
89  return 1;
90  }
91 
92  // Print the enegy and unit.
93  cout << ff->Energy() << " " << ff->GetUnit() << endl;
94 
95  return 0;
96 }
int main(int argc, char **argv)
Main body of the cuikbabelenergy application.
Definition: energy.cpp:63