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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
|
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
// $Id: surfaceBase.C,v 1.2.28.1 2007-03-16 00:06:50 bertsch Exp $
//
#include <BALL/QSAR/surfaceBase.h>
#include <BALL/QSAR/partialChargeDescriptors.h>
#include <BALL/QSAR/simpleDescriptors.h>
#include <BALL/KERNEL/atomIterator.h>
#include <BALL/KERNEL/fragment.h>
#include <BALL/KERNEL/PTE.h>
#include <BALL/CONCEPT/timeStamp.h>
#include <BALL/STRUCTURE/numericalSAS.h>
#define BALL_QSAR_SURFACEBASE_DEBUG
#undef BALL_QSAR_SURFACEBASE_DEBUG
using namespace std;
namespace BALL
{
SurfaceBase::SurfaceBase()
: Descriptor()
{
}
SurfaceBase::SurfaceBase(const SurfaceBase& sb)
: Descriptor(sb)
{
}
SurfaceBase::SurfaceBase(const String& name)
: Descriptor(name)
{
}
SurfaceBase::SurfaceBase(const String& name, const String& unit)
: Descriptor(name, unit)
{
}
SurfaceBase& SurfaceBase::operator = (const SurfaceBase& sb)
{
this->setName(sb.getName());
this->setUnit(sb.getUnit());
return *this;
}
SurfaceBase::~SurfaceBase()
{
}
bool SurfaceBase::isValid_(AtomContainer& ac)
{
static HashMap<Handle, PreciseTime> mod_times;
PreciseTime last_mod = ac.getModificationTime();
Handle mol_handle = ac.getHandle();
if (mod_times.has(mol_handle))
{
if (mod_times[mol_handle] == last_mod)
{
return true;
}
else
{
mod_times[mol_handle] = last_mod;
return false;
}
}
else
{
mod_times.insert(std::make_pair(mol_handle, last_mod));
return false;
}
}
void SurfaceBase::computeAllDescriptors(AtomContainer& ac)
{
if (!isValid_(ac))
{
calculate_(ac);
}
}
void SurfaceBase::calculate_(AtomContainer& ac)
{
// first we must be shure that the PEOE charges are calculated
TotalPositivePartialCharge tppc;
ac.apply(tppc);
MolecularWeight mw;
ac.apply(mw);
// assign van der Waals radii for the SAS calculator
for (AtomIterator it = ac.beginAtom(); it != ac.endAtom(); ++it)
{
it->setRadius(it->getElement().getVanDerWaalsRadius());
}
// calc the areas for each atom
NumericalSAS sas;
sas.options.setInteger(NumericalSAS::Option::NUMBER_OF_POINTS, 400);
sas.options.setReal(NumericalSAS::Option::PROBE_RADIUS, 0.);
sas(ac);
HashMap<const Atom*, float> atom_areas = sas.getAtomAreas();
double tot_pos(0), tot_neg(0), tot_pos_pol(0), tot_neg_pol(0), tot_hyd(0), tot_pol(0), tot(0);
// add the atom areas
HashMap<const Atom*, float>::ConstIterator a_it(atom_areas.begin());
for (; a_it != atom_areas.end(); ++a_it)
{
float area = a_it->second;
double charge = a_it->first->getProperty("PEOEPartialCharge").getDouble();
// total positive polar van der Waals surface area
if (charge > 0.2) { tot_pos_pol += area; }
// total negative polar van der Waals surface area
if (charge < -0.2) { tot_neg_pol += area; }
// total polar van der Waals surface area
if (fabs(charge) > 0.2) { tot_pol += area; }
// total hydrophobic van der Waals surface area
if (fabs(charge) <= 0.2) { tot_hyd += area; }
// total positive van der Waals surface area
if (charge > 0) { tot_pos += area; }
// total negative van der Waals surface area
if (charge < 0) { tot_neg += area; }
// total van der Waals surface area
tot += area;
}
double vol = sas.getTotalVolume();
double rho(0);
if (vol != 0)
{
rho = ac.getProperty("MolecularWeight").getDouble()/vol;
}
ac.setProperty("PositiveVdWSurface", tot_pos);
ac.setProperty("NegativeVdWSurface", tot_neg);
ac.setProperty("PositivePolarVdWSurface", tot_pos_pol);
ac.setProperty("NegativePolarVdWSurface", tot_neg_pol);
ac.setProperty("HydrophobicVdWSurface", tot_hyd);
ac.setProperty("PolarVdWSurface", tot_pol);
ac.setProperty("VdWSurface", tot);
ac.setProperty("VdWVolume", vol);
ac.setProperty("Density", rho);
}
} // namespace BALL
|