4
* $Date: 2007-04-16 10:40:19 +0200 (Mon, 16 Apr 2007) $
7
* Copyright (C) 2004-2007 The Chemistry Development Kit (CDK) project
9
* Contact: cdk-devel@lists.sourceforge.net
11
* This program is free software; you can redistribute it and/or
12
* modify it under the terms of the GNU Lesser General Public License
13
* as published by the Free Software Foundation; either version 2.1
14
* of the License, or (at your option) any later version.
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU Lesser General Public License for more details.
21
* You should have received a copy of the GNU Lesser General Public License
22
* along with this program; if not, write to the Free Software
23
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
25
package org.openscience.cdk.qsar.descriptors.atomic;
27
import java.io.IOException;
29
import javax.vecmath.Point3d;
31
import org.openscience.cdk.config.AtomTypeFactory;
32
import org.openscience.cdk.exception.CDKException;
33
import org.openscience.cdk.interfaces.IAtom;
34
import org.openscience.cdk.interfaces.IAtomContainer;
35
import org.openscience.cdk.interfaces.IAtomType;
36
import org.openscience.cdk.qsar.DescriptorSpecification;
37
import org.openscience.cdk.qsar.DescriptorValue;
38
import org.openscience.cdk.qsar.IAtomicDescriptor;
39
import org.openscience.cdk.qsar.result.DoubleResult;
40
import org.openscience.cdk.tools.LoggingTool;
42
* Inductive atomic softness of an atom in a polyatomic system can be defined
43
* as charge delocalizing ability. Only works with 3D coordinates, which must be calculated beforehand. <p>
45
* This descriptor uses these parameters:
84
*@cdk.created 2004-11-03
86
*@cdk.set qsar-descriptors
87
* @cdk.dictref qsar-descriptors:atomicSoftness
89
public class InductiveAtomicSoftnessDescriptor implements IAtomicDescriptor {
91
private LoggingTool logger;
92
private AtomTypeFactory factory = null;
96
* Constructor for the InductiveAtomicSoftnessDescriptor object
98
*@exception IOException Description of the Exception
99
*@exception ClassNotFoundException Description of the Exception
101
public InductiveAtomicSoftnessDescriptor() throws IOException, ClassNotFoundException {
102
logger = new LoggingTool(this);
107
* Gets the specification attribute of the InductiveAtomicSoftnessDescriptor
110
*@return The specification value
112
public DescriptorSpecification getSpecification() {
113
return new DescriptorSpecification(
114
"http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#atomicSoftness",
115
this.getClass().getName(),
116
"$Id: InductiveAtomicSoftnessDescriptor.java 8201 2007-04-16 08:40:19Z egonw $",
117
"The Chemistry Development Kit");
122
* This descriptor does have any parameter.
124
public void setParameters(Object[] params) throws CDKException {
129
* Gets the parameters attribute of the InductiveAtomicSoftnessDescriptor
132
* @return The parameters value
133
* @see #setParameters
135
public Object[] getParameters() {
141
* It is needed to call the addExplicitHydrogensToSatisfyValency method from
142
* the class tools.HydrogenAdder, and 3D coordinates.
144
*@param atom The IAtom for which the DescriptorValue is requested
145
*@param ac AtomContainer
146
*@return a double with polarizability of the heavy atom
147
*@exception CDKException if any atom in the supplied AtomContainer has no 3D coordinates
149
public DescriptorValue calculate(IAtom atom, IAtomContainer ac) throws CDKException {
152
factory = AtomTypeFactory.getInstance(
153
"org/openscience/cdk/config/data/jmol_atomtypes.txt",
156
} catch (Exception exception) {
157
throw new CDKException("Could not instantiate AtomTypeFactory!", exception);
161
java.util.Iterator allAtoms = ac.atoms();
163
double atomicSoftness = 0;
164
double radiusTarget = 0;
169
String symbol = null;
170
IAtomType type = null;
172
symbol = target.getSymbol();
173
type = factory.getAtomType(symbol);
174
radiusTarget = type.getCovalentRadius();
175
} catch (Exception ex1) {
177
throw new CDKException("Problems with AtomTypeFactory due to " + ex1.toString(), ex1);
180
while (allAtoms.hasNext()) {
181
IAtom curAtom = (IAtom)allAtoms.next();
182
if (target.getPoint3d() == null || curAtom.getPoint3d() == null) {
183
throw new CDKException("The target atom or current atom had no 3D coordinates. These are required");
185
if (!target.equals(curAtom)) {
187
symbol = curAtom.getSymbol();
189
type = factory.getAtomType(symbol);
190
} catch (Exception ex1) {
192
throw new CDKException("Problems with AtomTypeFactory due to " + ex1.toString(), ex1);
195
radius = type.getCovalentRadius();
196
partial += radius * radius;
197
partial += (radiusTarget * radiusTarget);
198
partial = partial / (calculateSquareDistanceBetweenTwoAtoms(curAtom, target));
199
//logger.debug("SOFT: atom "+symbol+", radius "+radius+", distance "+calculateSquareDistanceBetweenTwoAtoms(allAtoms[i], target));
200
atomicSoftness += partial;
204
atomicSoftness = 2 * atomicSoftness;
205
atomicSoftness = atomicSoftness * 0.172;
206
return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new DoubleResult(atomicSoftness));
209
private double calculateSquareDistanceBetweenTwoAtoms(org.openscience.cdk.interfaces.IAtom atom1, org.openscience.cdk.interfaces.IAtom atom2) {
212
Point3d firstPoint = atom1.getPoint3d();
213
Point3d secondPoint = atom2.getPoint3d();
214
tmp = firstPoint.distance(secondPoint);
215
distance = tmp * tmp;
221
* Gets the parameterNames attribute of the InductiveAtomicSoftnessDescriptor object.
223
* @return The parameterNames value
225
public String[] getParameterNames() {
226
return new String[0];
231
* Gets the parameterType attribute of the InductiveAtomicSoftnessDescriptor object.
233
* @param name Description of the Parameter
234
* @return An Object of class equal to that of the parameter being requested
236
public Object getParameterType(String name) {