4
* $Date: 2007-10-14 21:39:12 +0200 (Sun, 14 Oct 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.molecular;
27
import org.openscience.cdk.CDKConstants;
28
import org.openscience.cdk.aromaticity.HueckelAromaticityDetector;
29
import org.openscience.cdk.exception.CDKException;
30
import org.openscience.cdk.interfaces.IAtom;
31
import org.openscience.cdk.interfaces.IAtomContainer;
32
import org.openscience.cdk.qsar.DescriptorSpecification;
33
import org.openscience.cdk.qsar.DescriptorValue;
34
import org.openscience.cdk.qsar.IMolecularDescriptor;
35
import org.openscience.cdk.qsar.result.IDescriptorResult;
36
import org.openscience.cdk.qsar.result.IntegerResult;
39
* This descriptor calculates the number of hydrogen bond acceptors using a slightly simplified version of the
40
* <a href="http://www.chemie.uni-erlangen.de/model2001/abstracts/rester.html">PHACIR atom types</a>.
41
* The following groups are counted as hydrogen bond acceptors:
43
* <li>any oxygen where the formal charge of the oxygen is non-positive (i.e. formal charge <= 0) <b>except</b></li>
45
* <li>an aromatic ether oxygen (i.e. an ether oxygen that is adjacent to at least one aromatic carbon)</li>
46
* <li>an oxygen that is adjacent to a nitrogen</li>
48
* <li>any nitrogen where the formal charge of the nitrogen is non-positive (i.e. formal charge <= 0) <b>except</b></li>
50
* <li>a nitrogen that is adjacent to an oxygen</li>
54
* Returns a single value named <i>nHBAcc</i>.
56
* <p>This descriptor uses these parameters:
61
* <td>Description</td>
64
* <td>checkAromaticity</td>
66
* <td>true if the aromaticity has to be checked</td>
70
* This descriptor works properly with AtomContainers whose atoms contain <b>implicit hydrogens</b> or <b>explicit
74
* @cdk.created 2005-22-07
76
* @cdk.set qsar-descriptors
77
* @cdk.dictref qsar-descriptors:hBondacceptors
79
public class HBondAcceptorCountDescriptor implements IMolecularDescriptor {
80
// only parameter of this descriptor; true if aromaticity has to be checked prior to descriptor calculation, false otherwise
81
private boolean checkAromaticity = false;
84
* Constructor for the HBondAcceptorCountDescriptor object
86
public HBondAcceptorCountDescriptor() { }
89
* Gets the specification attribute of the HBondAcceptorCountDescriptor object.
91
* @return The specification value
93
public DescriptorSpecification getSpecification() {
94
return new DescriptorSpecification(
95
"http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#hBondacceptors",
96
this.getClass().getName(),
97
"$Id: HBondAcceptorCountDescriptor.java 9058 2007-10-14 19:39:12Z egonw $",
98
"The Chemistry Development Kit");
102
* Sets the parameters attribute of the HBondAcceptorCountDescriptor object.
104
* @param params a boolean true means that aromaticity has to be checked
105
* @exception CDKException Description of the Exception
107
public void setParameters(Object[] params) throws CDKException {
108
if (params.length != 1) {
109
throw new CDKException("HBondAcceptorCountDescriptor expects a single parameter");
111
if (!(params[0] instanceof Boolean)) {
112
throw new CDKException("The parameter must be of type Boolean");
114
// ok, all should be fine
115
checkAromaticity = ((Boolean)params[0]).booleanValue();
119
* Gets the parameters attribute of the HBondAcceptorCountDescriptor object.
121
* @return The parameters value
123
public Object[] getParameters() {
124
// return the parameters as used for the descriptor calculation
125
Object[] params = new Object[1];
126
params[0] = new Boolean(checkAromaticity);
131
* Calculates the number of H bond acceptors.
133
* @param atomContainer AtomContainer
134
* @return number of H bond acceptors
135
* @exception CDKException Possible Exceptions
137
public DescriptorValue calculate(IAtomContainer atomContainer) throws CDKException {
138
int hBondAcceptors = 0;
142
ac = (IAtomContainer) atomContainer.clone();
143
} catch (CloneNotSupportedException e) {
144
throw new CDKException("Error during clone");
147
// aromaticity is detected prior to descriptor calculation if the respective parameter is set to true
148
if (checkAromaticity)
149
HueckelAromaticityDetector.detectAromaticity(ac);
151
//org.openscience.cdk.interfaces.IAtom[] atoms = ac.getAtoms();
152
// labelled for loop to allow for labelled continue statements within the loop
154
for (int atomIndex = 0; atomIndex < ac.getAtomCount(); atomIndex++)
156
// looking for suitable nitrogen atoms
157
if(ac.getAtom(atomIndex).getSymbol().equals("N") && ac.getAtom(atomIndex).getFormalCharge() <= 0)
159
// excluding nitrogens that are adjacent to an oxygen
160
java.util.List neighbours = ac.getConnectedAtomsList(ac.getAtom(atomIndex));
161
for(int neighbourIndex = 0; neighbourIndex < neighbours.size(); neighbourIndex++)
162
if(((IAtom)neighbours.get(neighbourIndex)).getSymbol().equals("O"))
166
// looking for suitable oxygen atoms
167
if(ac.getAtom(atomIndex).getSymbol().equals("O") && ac.getAtom(atomIndex).getFormalCharge() <= 0)
169
//excluding oxygens that are adjacent to a nitrogen or to an aromatic carbon
170
java.util.List neighbours = ac.getConnectedAtomsList(ac.getAtom(atomIndex));
171
for(int neighbourIndex = 0; neighbourIndex < neighbours.size(); neighbourIndex++)
172
if(((IAtom)neighbours.get(neighbourIndex)).getSymbol().equals("N") ||
173
(((IAtom)neighbours.get(neighbourIndex)).getSymbol().equals("C") && ((IAtom)neighbours.get(neighbourIndex)).getFlag(CDKConstants.ISAROMATIC)))
179
return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(),
180
new IntegerResult(hBondAcceptors), new String[] {"nHBAcc"});
184
* Returns the specific type of the DescriptorResult object.
186
* The return value from this method really indicates what type of result will
187
* be obtained from the {@link org.openscience.cdk.qsar.DescriptorValue} object. Note that the same result
188
* can be achieved by interrogating the {@link org.openscience.cdk.qsar.DescriptorValue} object; this method
189
* allows you to do the same thing, without actually calculating the descriptor.
191
* @return an object that implements the {@link org.openscience.cdk.qsar.result.IDescriptorResult} interface indicating
192
* the actual type of values returned by the descriptor in the {@link org.openscience.cdk.qsar.DescriptorValue} object
194
public IDescriptorResult getDescriptorResultType() {
195
return new IntegerResult(1);
199
* Gets the parameterNames attribute of the HBondAcceptorCountDescriptor object.
201
* @return The parameterNames value
203
public String[] getParameterNames() {
204
String[] params = new String[1];
205
params[0] = "checkAromaticity";
210
* Gets the parameterType attribute of the HBondAcceptorCountDescriptor object.
212
* @param name Description of the Parameter
213
* @return The parameterType value
215
public Object getParameterType(String name) {
216
return Boolean.FALSE;