3
* $Date: 2007-01-04 18:46:10 +0100 (Thu, 04 Jan 2007) $
6
* Copyright (C) 2004-2007 The Chemistry Development Kit (CDK) project
8
* Contact: cdk-devel@lists.sourceforge.net
10
* This program is free software; you can redistribute it and/or
11
* modify it under the terms of the GNU Lesser General Public License
12
* as published by the Free Software Foundation; either version 2.1
13
* of the License, or (at your option) any later version.
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU Lesser General Public License for more details.
20
* You should have received a copy of the GNU Lesser General Public License
21
* along with this program; if not, write to the Free Software
22
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24
package org.openscience.cdk.qsar.descriptors.atomic;
26
import org.openscience.cdk.Molecule;
27
import org.openscience.cdk.exception.CDKException;
28
import org.openscience.cdk.graph.BFSShortestPath;
29
import org.openscience.cdk.graph.MoleculeGraphs;
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.IAtomicDescriptor;
35
import org.openscience.cdk.qsar.result.IntegerResult;
38
* This class returns the number of bonds on the shortest path between two atoms.
40
* <p>This descriptor uses these parameters:
45
* <td>Description</td>
48
* <td>focusPosition</td>
50
* <td>The position of the second atom</td>
55
* @cdk.created 2004-11-13
57
* @cdk.set qsar-descriptors
58
* @cdk.dictref qsar-descriptors:bondsToAtom
60
public class BondsToAtomDescriptor implements IAtomicDescriptor {
62
private int focusPosition = 0;
63
private org._3pq.jgrapht.Graph mygraph = null;
64
java.util.List mylist = null;
65
Object startVertex = null;
66
Object endVertex = null;
69
* Constructor for the BondsToAtomDescriptor object
71
public BondsToAtomDescriptor() {}
75
* Gets the specification attribute of the BondsToAtomDescriptor object
77
*@return The specification value
79
public DescriptorSpecification getSpecification() {
80
return new DescriptorSpecification(
81
"http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#bondsToAtom",
82
this.getClass().getName(),
83
"$Id: BondsToAtomDescriptor.java 7636 2007-01-04 17:46:10Z egonw $",
84
"The Chemistry Development Kit");
89
* Sets the parameters attribute of the BondsToAtomDescriptor object
91
* @param params The parameter is the position to focus
92
* @exception CDKException Description of the Exception
94
public void setParameters(Object[] params) throws CDKException {
95
if (params.length > 1) {
96
throw new CDKException("BondsToAtomDescriptor only expects one parameters");
98
if (!(params[0] instanceof Integer)) {
99
throw new CDKException("The parameter must be of type Integer");
101
focusPosition = ((Integer) params[0]).intValue();
106
* Gets the parameters attribute of the BondsToAtomDescriptor object
108
*@return The parameters value
110
public Object[] getParameters() {
111
Object[] params = new Object[1];
112
params[0] = new Integer(focusPosition);
118
* This method calculate the number of bonds on the shortest path between two atoms.
120
*@param atom The IAtom for which the DescriptorValue is requested
121
*@param container Parameter is the atom container.
122
*@return The number of bonds on the shortest path between two atoms
123
*@exception CDKException Description of the Exception
126
public DescriptorValue calculate(IAtom atom, IAtomContainer container) throws CDKException {
127
mygraph = MoleculeGraphs.getMoleculeGraph((Molecule)container);
131
IAtom focus = container.getAtom(focusPosition);
133
startVertex = target;
136
mylist = BFSShortestPath.findPathBetween(mygraph,startVertex,endVertex);
138
bondsToAtom = mylist.size();
140
return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new IntegerResult(bondsToAtom));
146
* Gets the parameterNames attribute of the BondsToAtomDescriptor object
148
*@return The parameterNames value
150
public String[] getParameterNames() {
151
String[] params = new String[1];
152
params[0] = "focusPosition";
158
* Gets the parameterType attribute of the BondsToAtomDescriptor object
160
*@param name Description of the Parameter
161
*@return The parameterType value
163
public Object getParameterType(String name) {
164
return new Integer(0);