~ubuntu-branches/debian/stretch/openbabel/stretch

« back to all changes in this revision

Viewing changes to test/logp_psa.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michael Banck
  • Date: 2008-07-22 23:54:58 UTC
  • mfrom: (3.1.10 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080722235458-3o606czluviz4akx
Tags: 2.2.0-2
* Upload to unstable.
* debian/control: Updated descriptions.
* debian/patches/gauss_cube_format.patch: New patch, makes the 
  gaussian cube format available again.
* debian/rules (DEB_DH_MAKESHLIBS_ARGS_libopenbabel3): Removed.
* debian/rules (DEB_CONFIGURE_EXTRA_FLAGS): Likewise.
* debian/libopenbabel3.install: Adjust formats directory to single 
  version hierarchy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**********************************************************************
 
2
logppsa.cpp - Unit tests for Open Babel OBLogP and OBPSA class
 
3
 
 
4
Copyright (C) 2007 Tim Vandermmeersch
 
5
 
 
6
This file is part of the Open Babel project.
 
7
For more information, see <http://openbabel.sourceforge.net/>
 
8
 
 
9
This program is free software; you can redistribute it and/or modify
 
10
it under the terms of the GNU General Public License as published by
 
11
the Free Software Foundation version 2 of the License.
 
12
 
 
13
This program is distributed in the hope that it will be useful,
 
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
GNU General Public License for more details.
 
17
***********************************************************************/
 
18
 
 
19
// used to set import/export for Cygwin DLLs
 
20
#ifdef WIN32
 
21
#define USING_OBDLL
 
22
#endif
 
23
 
 
24
#include <openbabel/babelconfig.h>
 
25
#include <openbabel/mol.h>
 
26
#include <openbabel/obconversion.h>
 
27
#include <openbabel/groupcontrib.h>
 
28
 
 
29
#include <stdio.h>
 
30
#include <iostream>
 
31
 
 
32
using namespace std;
 
33
using namespace OpenBabel;
 
34
 
 
35
int main(int argc,char *argv[])
 
36
{
 
37
  // turn off slow sync with C-style output (we don't use it anyway).
 
38
  std::ios::sync_with_stdio(false);
 
39
 
 
40
  if (argc != 1)
 
41
    {
 
42
      cout << "Usage: logp_psa" << endl;
 
43
      cout << " Unit tests for OBLogP and OBPSA " << endl;
 
44
      return(-1);
 
45
    }
 
46
 
 
47
  cout << "# Unit tests for OBLogP and OBPSA \n";
 
48
 
 
49
  // the number of tests for "prove"
 
50
  cout << "1..7\n";
 
51
 
 
52
  OBConversion obConversion;
 
53
  obConversion.SetInAndOutFormats("smi", "mdl");
 
54
  OBMol obMol;
 
55
  
 
56
  OBDescriptor* obLogP = OBDescriptor::FindType("logP");
 
57
  OBDescriptor* obPSA  = OBDescriptor::FindType("TPSA");
 
58
  double logP, psa;
 
59
 
 
60
  cout << "ok 1\n"; // for loading tests
 
61
  
 
62
  obConversion.ReadString(&obMol, "Oc1ccccc1OC");
 
63
  obMol.AddHydrogens();
 
64
  
 
65
  logP = obLogP->Predict(&obMol);
 
66
  if (IsNear(logP , 1.4008)) { // value from JOELib2
 
67
    cout << "ok 2 # " << logP << '\n';
 
68
  } else {
 
69
    cout << "not ok 2 # " << logP << '\n';
 
70
  }
 
71
  
 
72
  psa = obPSA->Predict(&obMol);
 
73
  if (IsNear(psa , 29.46)) { // value from JOELib2
 
74
    cout << "ok 3 # " << psa << '\n';
 
75
  } else {
 
76
    cout << "not ok 3 # " << psa << '\n';
 
77
  }
 
78
 
 
79
  obConversion.ReadString(&obMol, "c1ccccc1CBr");
 
80
  obMol.AddHydrogens();
 
81
  
 
82
  logP = obLogP->Predict(&obMol);
 
83
  if (IsNear(logP, 2.5815)) { // Value from JOELib2
 
84
    cout << "ok 4 # " << logP << '\n';
 
85
  } else {
 
86
    cout << "not ok 4 # " << logP << '\n';
 
87
  }
 
88
  
 
89
  psa = obPSA->Predict(&obMol);
 
90
  if (IsNear(psa, 0.0)) { // Value from JOELib2
 
91
    cout << "ok 5 # " << psa << '\n';
 
92
  } else {
 
93
    cout << "not ok 5 # " << psa << '\n';
 
94
  }
 
95
 
 
96
  obConversion.ReadString(&obMol, "Cc1ccccc1NC(=O)C");
 
97
  obMol.AddHydrogens();
 
98
  
 
99
  logP = obLogP->Predict(&obMol);
 
100
  if (IsNear(logP, 2.0264)) { // JOELib2 = 1.9534, more H added on N
 
101
    cout << "ok 6 # " << logP << '\n';
 
102
  } else {
 
103
    cout << "not ok 6 # " << logP << '\n';
 
104
  }
 
105
  
 
106
  psa = obPSA->Predict(&obMol);
 
107
  if (IsNear(psa, 29.1)) { // Value from JOELib2
 
108
    cout << "ok 7 # " << psa << '\n';
 
109
  } else {
 
110
    cout << "not ok 7 # " << psa << '\n';
 
111
  }
 
112
 
 
113
  return(0);
 
114
}
 
115
 
 
116