~ubuntu-branches/ubuntu/trusty/cdk/trusty-proposed

« back to all changes in this revision

Viewing changes to src/org/openscience/cdk/qsar/descriptors/atomic/AtomDegreeDescriptor.java

  • Committer: Bazaar Package Importer
  • Author(s): Paul Cager
  • Date: 2008-04-09 21:17:53 UTC
  • Revision ID: james.westby@ubuntu.com-20080409211753-46lmjw5z8mx5pd8d
Tags: upstream-1.0.2
ImportĀ upstreamĀ versionĀ 1.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  $RCSfile: $
 
2
 *  $Author: egonw $
 
3
 *  $Date: 2007-02-07 23:20:44 +0100 (Wed, 07 Feb 2007) $
 
4
 *  $Revision: 7895 $
 
5
 *
 
6
 *  Copyright (C) 2004-2007  The Chemistry Development Kit (CDK) project
 
7
 *
 
8
 *  Contact: cdk-devel@lists.sourceforge.net
 
9
 *
 
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.
 
14
 *
 
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.
 
19
 *
 
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.
 
23
 */
 
24
package org.openscience.cdk.qsar.descriptors.atomic;
 
25
 
 
26
import org.openscience.cdk.exception.CDKException;
 
27
import org.openscience.cdk.interfaces.IAtom;
 
28
import org.openscience.cdk.interfaces.IAtomContainer;
 
29
import org.openscience.cdk.qsar.DescriptorSpecification;
 
30
import org.openscience.cdk.qsar.DescriptorValue;
 
31
import org.openscience.cdk.qsar.IAtomicDescriptor;
 
32
import org.openscience.cdk.qsar.result.IntegerResult;
 
33
 
 
34
/**
 
35
 * This class returns the number of not-Hs substituents of an atom, also defined as "atom degree".
 
36
 *
 
37
 * <p>This descriptor uses these parameters:
 
38
 * <table border="1">
 
39
 *   <tr>
 
40
 *     <td>Name</td>
 
41
 *     <td>Default</td>
 
42
 *     <td>Description</td>
 
43
 *   </tr>
 
44
 *   <tr>
 
45
 *     <td></td>
 
46
 *     <td></td>
 
47
 *     <td>no parameters</td>
 
48
 *   </tr>
 
49
 * </table>
 
50
 * 
 
51
 * @author      mfe4
 
52
 * @cdk.created 2004-11-13
 
53
 * @cdk.module  qsar
 
54
 * @cdk.set     qsar-descriptors
 
55
 * @cdk.dictref qsar-descriptors:atomDegree
 
56
 */
 
57
public class AtomDegreeDescriptor implements IAtomicDescriptor {
 
58
 
 
59
    public DescriptorSpecification getSpecification() {
 
60
        return new DescriptorSpecification(
 
61
                "http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#atomDegree",
 
62
                this.getClass().getName(),
 
63
                "$Id: AtomDegreeDescriptor.java 7895 2007-02-07 22:20:44Z egonw $",
 
64
                "The Chemistry Development Kit");
 
65
    }
 
66
 
 
67
    /**
 
68
     * This descriptor does not have any parameter to be set.
 
69
     */
 
70
    public void setParameters(Object[] params) throws CDKException {
 
71
        // no parameters
 
72
    }
 
73
 
 
74
 
 
75
    /**
 
76
     *  Gets the parameters attribute of the AtomDegreeDescriptor object.
 
77
     *
 
78
     *@return    The parameters value
 
79
     *@see #setParameters
 
80
     */
 
81
    public Object[] getParameters() {
 
82
        return null;
 
83
    }
 
84
 
 
85
 
 
86
    /**
 
87
     * This method calculates the number of not-H substituents of an atom.
 
88
     *
 
89
     * @param  atom              The IAtom for which the DescriptorValue is requested
 
90
     * @param  container         The {@link IAtomContainer} for which this descriptor is to be calculated for
 
91
     * @return   The number of bonds on the shortest path between two atoms
 
92
     * @throws  CDKException  NOT CLEAR
 
93
     */
 
94
    public DescriptorValue calculate(IAtom atom, IAtomContainer container) throws CDKException {
 
95
        int atomDegree = 0;
 
96
        java.util.List neighboors = container.getConnectedAtomsList(atom);
 
97
        for (int i =0; i< neighboors.size();i++) {
 
98
            if(!((IAtom)neighboors.get(i)).getSymbol().equals("H")) atomDegree+=1;
 
99
        }
 
100
        return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new IntegerResult(atomDegree));
 
101
    }
 
102
 
 
103
 
 
104
    /**
 
105
     * Gets the parameterNames attribute of the AtomDegreeDescriptor object.
 
106
     *
 
107
     * @return    The parameterNames value
 
108
     */
 
109
    public String[] getParameterNames() {
 
110
        return new String[0];
 
111
    }
 
112
 
 
113
 
 
114
    /**
 
115
     * Gets the parameterType attribute of the AtomDegreeDescriptor object.
 
116
     *
 
117
     * @param  name  Description of the Parameter
 
118
     * @return       An Object of class equal to that of the parameter being requested
 
119
     */
 
120
    public Object getParameterType(String name) {
 
121
        return null;
 
122
    }
 
123
}
 
124